@mx-cartographer/experiences 9.4.12-alpha.al1 → 9.4.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -1
- package/dist/common/context/hooks.d.ts +1 -0
- package/dist/common/context/hooks.es.js +18 -17
- package/dist/common/context/hooks.es.js.map +1 -1
- package/dist/common/context/index.d.ts +1 -1
- package/dist/common/index.es.js +130 -129
- package/dist/core/stores/InsightsV2Store.d.ts +24 -7
- package/dist/core/stores/InsightsV2Store.es.js +18 -23
- package/dist/core/stores/InsightsV2Store.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/MakeTransferActionBlock.d.ts +4 -27
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/MakeTransferActionBlock.es.js +253 -206
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/MakeTransferActionBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/MakeTransferActionBlockLayer.d.ts +5 -4
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/MakeTransferActionBlockLayer.es.js +12 -20
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/MakeTransferActionBlockLayer.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/index.d.ts +2 -0
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/layout.d.ts +9 -43
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/layout.es.js +12 -79
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/PlaceholderActionBlock.es.js +35 -13
- package/dist/insights-v2/actionBlocks/PlaceholderActionBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.es.js +17 -13
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChart.es.js +7 -7
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChart.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/DoubleBarChartBlock.es.js +17 -13
- package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/DoubleBarChartBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/index.d.ts +1 -0
- package/dist/insights-v2/blocks/ComponentBlocks/BudgetBlock/BudgetBlock.es.js +19 -25
- package/dist/insights-v2/blocks/ComponentBlocks/BudgetBlock/BudgetBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/createVariantBlock.d.ts +29 -0
- package/dist/insights-v2/blocks/createVariantBlock.es.js +13 -0
- package/dist/insights-v2/blocks/createVariantBlock.es.js.map +1 -0
- package/dist/insights-v2/components/chartblocks/BarchartV2.es.js +24 -25
- package/dist/insights-v2/components/chartblocks/BarchartV2.es.js.map +1 -1
- package/dist/insights-v2/components/chartblocks/DoubleBarChart.es.js +18 -19
- package/dist/insights-v2/components/chartblocks/DoubleBarChart.es.js.map +1 -1
- package/dist/insights-v2/index.es.js +52 -50
- package/dist/insights-v2/mappings/blocks.es.js +20 -20
- package/package.json +1 -1
|
@@ -1,57 +1,23 @@
|
|
|
1
1
|
import { GlobalCopy, MakeTransferCopy } from '../../../core';
|
|
2
2
|
import { SaveExtraBlockData } from '../../../core/types/InsightsInstanceSlotData';
|
|
3
3
|
/**
|
|
4
|
-
* MakeTransfer drilldown variants. The block uses the VALUE (e.g. "SaveAnExtra100")
|
|
4
|
+
* MakeTransfer drilldown variants. The block uses the VALUE (e.g. "SaveAnExtra100"),
|
|
5
|
+
* which is also the key each variant registers under (see ./index).
|
|
5
6
|
*/
|
|
6
7
|
export declare const variants: {
|
|
7
8
|
readonly SAVE_ENOUGH_TO_LIVE_ON: "SaveEnoughToLiveOn";
|
|
8
9
|
readonly SAVE_AN_EXTRA_100: "SaveAnExtra100";
|
|
9
10
|
};
|
|
10
11
|
export type MakeTransferVariant = (typeof variants)[keyof typeof variants];
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* Per-variant layout for the MakeTransfer drilldown — mirrors the Beat Blocks
|
|
17
|
-
* `layout.ts` pattern: the component reads this config instead of branching on
|
|
18
|
-
* the variant inline.
|
|
19
|
-
*/
|
|
20
|
-
export interface MakeTransferLayoutConfig {
|
|
21
|
-
/** Rows in the projected-savings table. */
|
|
22
|
-
monthsTable: readonly MonthRow[];
|
|
23
|
-
/** Stepper increment/decrement step. */
|
|
24
|
-
deltaAmount: number;
|
|
25
|
-
/** Starting stepper amount; when null, defaults to `averageMonthlySpend`. */
|
|
26
|
-
initialAmount: number | null;
|
|
27
|
-
/** Index of the last table row (its divider has no left inset). */
|
|
28
|
-
lastRowIndex: number;
|
|
29
|
-
/** Available/expenses card with "total remaining" (save-extra only). */
|
|
30
|
-
showRemainingCard: boolean;
|
|
31
|
-
/** SVG timeline + balances header section (save-enough only). */
|
|
32
|
-
showBalancesSection: boolean;
|
|
33
|
-
/** Total available-balances footer (save-enough only). */
|
|
34
|
-
showTotalBalances: boolean;
|
|
35
|
-
/** `insights_feed.make_transfer` copy keys resolved for this variant. */
|
|
36
|
-
copyKeys: {
|
|
37
|
-
title: keyof MakeTransferCopy;
|
|
38
|
-
bodyContent: keyof MakeTransferCopy;
|
|
39
|
-
bodyDescription: keyof MakeTransferCopy;
|
|
40
|
-
};
|
|
41
|
-
/** `instance_slot_data` field names feeding this variant's figures. */
|
|
42
|
-
dataKeys: {
|
|
43
|
-
/** Field for the "average monthly spend" / "expenses" figure. */
|
|
44
|
-
averageMonthlySpend: keyof SaveExtraBlockData;
|
|
45
|
-
/** SAVE_ENOUGH_TO_LIVE_ON: duration overlaid on the timeline SVG. */
|
|
46
|
-
timePeriod?: keyof SaveExtraBlockData;
|
|
47
|
-
/** SAVE_AN_EXTRA_100: total-remaining figure. */
|
|
48
|
-
totalRemaining?: keyof SaveExtraBlockData;
|
|
49
|
-
};
|
|
12
|
+
/** Props shared by every MakeTransfer variant. Each variant reads the fields it
|
|
13
|
+
* needs directly off `slotData` — no per-variant key indirection. */
|
|
14
|
+
export interface MakeTransferVariantProps {
|
|
15
|
+
slotData?: SaveExtraBlockData;
|
|
16
|
+
copy: MakeTransferCopy;
|
|
50
17
|
}
|
|
51
18
|
/** Maps the payload variant key to the block's variant VALUE (defaults to save-extra). */
|
|
52
19
|
export declare const resolveMakeTransferVariant: (variant?: string | null) => MakeTransferVariant;
|
|
53
|
-
/** Layout config for a resolved block variant. */
|
|
54
|
-
export declare const getMakeTransferLayout: (variant: MakeTransferVariant) => MakeTransferLayoutConfig;
|
|
55
20
|
/** Variant-specific, localized drawer title from `insights_feed.make_transfer`. */
|
|
56
21
|
export declare const getMakeTransferDrawerTitle: (variant: string | null | undefined, copy: GlobalCopy) => string;
|
|
57
|
-
|
|
22
|
+
/** Coerce a payload figure (number or numeric string) to a number, else undefined. */
|
|
23
|
+
export declare const toNumber: (value?: string | number) => number | undefined;
|
|
@@ -1,85 +1,18 @@
|
|
|
1
|
-
var
|
|
1
|
+
var e = {
|
|
2
2
|
SAVE_ENOUGH_TO_LIVE_ON: "SaveEnoughToLiveOn",
|
|
3
3
|
SAVE_AN_EXTRA_100: "SaveAnExtra100"
|
|
4
|
-
},
|
|
5
|
-
save_enough_to_live_on:
|
|
6
|
-
save_an_extra_100:
|
|
7
|
-
}, t =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
label: "3 months",
|
|
14
|
-
value: 3
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
label: "6 months",
|
|
18
|
-
value: 6
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
label: "9 months",
|
|
22
|
-
value: 9
|
|
23
|
-
}
|
|
24
|
-
], n = [
|
|
25
|
-
{
|
|
26
|
-
label: "3 months",
|
|
27
|
-
value: 3
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
label: "6 months",
|
|
31
|
-
value: 6
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
label: "9 months",
|
|
35
|
-
value: 9
|
|
36
|
-
}
|
|
37
|
-
], o = {
|
|
38
|
-
[a.SAVE_AN_EXTRA_100]: {
|
|
39
|
-
monthsTable: n,
|
|
40
|
-
deltaAmount: 5,
|
|
41
|
-
initialAmount: 100,
|
|
42
|
-
lastRowIndex: n.length - 1,
|
|
43
|
-
showRemainingCard: !0,
|
|
44
|
-
showBalancesSection: !1,
|
|
45
|
-
showTotalBalances: !1,
|
|
46
|
-
copyKeys: {
|
|
47
|
-
title: "save_extra_title",
|
|
48
|
-
bodyContent: "body_saving_content",
|
|
49
|
-
bodyDescription: "body_saving_description"
|
|
50
|
-
},
|
|
51
|
-
dataKeys: {
|
|
52
|
-
averageMonthlySpend: "upcoming_expenses",
|
|
53
|
-
totalRemaining: "total_remaining"
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
[a.SAVE_ENOUGH_TO_LIVE_ON]: {
|
|
57
|
-
monthsTable: t,
|
|
58
|
-
deltaAmount: 50,
|
|
59
|
-
initialAmount: null,
|
|
60
|
-
lastRowIndex: t.length - 1,
|
|
61
|
-
showRemainingCard: !1,
|
|
62
|
-
showBalancesSection: !0,
|
|
63
|
-
showTotalBalances: !0,
|
|
64
|
-
copyKeys: {
|
|
65
|
-
title: "save_enough_title",
|
|
66
|
-
bodyContent: "body_spending_content",
|
|
67
|
-
bodyDescription: "body_spending_description"
|
|
68
|
-
},
|
|
69
|
-
dataKeys: {
|
|
70
|
-
averageMonthlySpend: "avg_monthly_spend",
|
|
71
|
-
timePeriod: "time_period"
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}, i = (e) => s[e ?? ""] ?? a.SAVE_AN_EXTRA_100, r = (e) => o[e], v = (e, _) => {
|
|
75
|
-
const l = o[i(e)];
|
|
76
|
-
return _.insights_feed?.make_transfer[l.copyKeys.title] ?? "";
|
|
77
|
-
};
|
|
4
|
+
}, t = {
|
|
5
|
+
save_enough_to_live_on: e.SAVE_ENOUGH_TO_LIVE_ON,
|
|
6
|
+
save_an_extra_100: e.SAVE_AN_EXTRA_100
|
|
7
|
+
}, n = (_) => t[_ ?? ""] ?? e.SAVE_AN_EXTRA_100, E = (_, a) => {
|
|
8
|
+
const r = a.insights_feed?.make_transfer;
|
|
9
|
+
return r ? n(_) === e.SAVE_ENOUGH_TO_LIVE_ON ? r.save_enough_title : r.save_extra_title : "";
|
|
10
|
+
}, A = (_) => _ == null || _ === "" ? void 0 : Number(_);
|
|
78
11
|
export {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
12
|
+
E as getMakeTransferDrawerTitle,
|
|
13
|
+
n as resolveMakeTransferVariant,
|
|
14
|
+
A as toNumber,
|
|
15
|
+
e as variants
|
|
83
16
|
};
|
|
84
17
|
|
|
85
18
|
//# sourceMappingURL=layout.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/MakeTransferActionBlock/layout.ts"],"sourcesContent":["import type { GlobalCopy, MakeTransferCopy } from '../../../core'\nimport type { SaveExtraBlockData } from '../../../core/types/InsightsInstanceSlotData'\n\n/**\n * MakeTransfer drilldown variants. The block uses the VALUE (e.g. \"SaveAnExtra100\").\n */\nexport const variants = {\n SAVE_ENOUGH_TO_LIVE_ON: 'SaveEnoughToLiveOn',\n SAVE_AN_EXTRA_100: 'SaveAnExtra100',\n} as const\n\nexport type MakeTransferVariant = (typeof variants)[keyof typeof variants]\n\n// The beat payload sends the variant as a snake_case key; map it to the value.\nconst VARIANT_BY_KEY: Record<string, MakeTransferVariant> = {\n save_enough_to_live_on: variants.SAVE_ENOUGH_TO_LIVE_ON,\n save_an_extra_100: variants.SAVE_AN_EXTRA_100,\n}\n\
|
|
1
|
+
{"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/MakeTransferActionBlock/layout.ts"],"sourcesContent":["import type { GlobalCopy, MakeTransferCopy } from '../../../core'\nimport type { SaveExtraBlockData } from '../../../core/types/InsightsInstanceSlotData'\n\n/**\n * MakeTransfer drilldown variants. The block uses the VALUE (e.g. \"SaveAnExtra100\"),\n * which is also the key each variant registers under (see ./index).\n */\nexport const variants = {\n SAVE_ENOUGH_TO_LIVE_ON: 'SaveEnoughToLiveOn',\n SAVE_AN_EXTRA_100: 'SaveAnExtra100',\n} as const\n\nexport type MakeTransferVariant = (typeof variants)[keyof typeof variants]\n\n// The beat payload sends the variant as a snake_case key; map it to the value.\nconst VARIANT_BY_KEY: Record<string, MakeTransferVariant> = {\n save_enough_to_live_on: variants.SAVE_ENOUGH_TO_LIVE_ON,\n save_an_extra_100: variants.SAVE_AN_EXTRA_100,\n}\n\n/** Props shared by every MakeTransfer variant. Each variant reads the fields it\n * needs directly off `slotData` — no per-variant key indirection. */\nexport interface MakeTransferVariantProps {\n slotData?: SaveExtraBlockData\n copy: MakeTransferCopy\n}\n\n/** Maps the payload variant key to the block's variant VALUE (defaults to save-extra). */\nexport const resolveMakeTransferVariant = (variant?: string | null): MakeTransferVariant =>\n VARIANT_BY_KEY[variant ?? ''] ?? variants.SAVE_AN_EXTRA_100\n\n/** Variant-specific, localized drawer title from `insights_feed.make_transfer`. */\nexport const getMakeTransferDrawerTitle = (\n variant: string | null | undefined,\n copy: GlobalCopy,\n): string => {\n const makeTransfer = copy.insights_feed?.make_transfer\n if (!makeTransfer) return ''\n return resolveMakeTransferVariant(variant) === variants.SAVE_ENOUGH_TO_LIVE_ON\n ? makeTransfer.save_enough_title\n : makeTransfer.save_extra_title\n}\n\n/** Coerce a payload figure (number or numeric string) to a number, else undefined. */\nexport const toNumber = (value?: string | number): number | undefined =>\n value === undefined || value === null || value === '' ? undefined : Number(value)\n"],"mappings":"AAOA,IAAa,IAAW;AAAA,EACtB,wBAAwB;AAAA,EACxB,mBAAmB;AACrB,GAKM,IAAsD;AAAA,EAC1D,wBAAwB,EAAS;AAAA,EACjC,mBAAmB,EAAS;AAC9B,GAUa,IAAA,CAA8B,MACzC,EAAe,KAAW,EAAA,KAAO,EAAS,mBAG/B,IAAA,CACX,GACA,MACW;AACX,QAAM,IAAe,EAAK,eAAe;AACzC,SAAK,IACE,EAA2B,CAAO,MAAM,EAAS,yBACpD,EAAa,oBACb,EAAa,mBAHS;AAI5B,GAGa,IAAA,CAAY,MACA,KAAU,QAAQ,MAAU,KAAK,SAAY,OAAO,CAAK"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { useInsightsV2Store as
|
|
2
|
-
import {
|
|
1
|
+
import { useActionContext as h, useInsightsV2Store as m } from "../../common/context/hooks.es.js";
|
|
2
|
+
import { createVariantBlock as p } from "../blocks/createVariantBlock.es.js";
|
|
3
|
+
import { observer as i } from "mobx-react-lite";
|
|
3
4
|
import l from "@mui/material/Stack";
|
|
4
|
-
import { H3 as
|
|
5
|
-
import { jsx as
|
|
6
|
-
var
|
|
7
|
-
const {
|
|
5
|
+
import { H3 as s, Text as a } from "@mxenabled/mxui";
|
|
6
|
+
import { jsx as n, jsxs as e } from "react/jsx-runtime";
|
|
7
|
+
var c = i(({ beat: t }) => {
|
|
8
|
+
const { chartBarIndex: r = 0, tabIndex: o = 0 } = h() ?? {};
|
|
8
9
|
return /* @__PURE__ */ e(l, {
|
|
9
10
|
sx: {
|
|
10
11
|
alignItems: "center",
|
|
@@ -13,20 +14,41 @@ var g = c(function({ beat: i }) {
|
|
|
13
14
|
textAlign: "center"
|
|
14
15
|
},
|
|
15
16
|
children: [
|
|
16
|
-
/* @__PURE__ */
|
|
17
|
-
/* @__PURE__ */
|
|
18
|
-
/* @__PURE__ */ e(
|
|
19
|
-
/* @__PURE__ */ e(
|
|
17
|
+
/* @__PURE__ */ n(s, { children: "Action Block Layer Drilldown" }),
|
|
18
|
+
/* @__PURE__ */ n(a, { children: "This is a placeholder action block. Replace it with your own implementation by registering your block in src/insights-v2/mappings/blocks.ts." }),
|
|
19
|
+
/* @__PURE__ */ e(a, { children: ["Beat: ", t.guid] }),
|
|
20
|
+
/* @__PURE__ */ e(a, { children: [
|
|
20
21
|
"Drilldown: chartBarIndex ",
|
|
21
|
-
|
|
22
|
+
r,
|
|
22
23
|
", tabIndex ",
|
|
23
|
-
o
|
|
24
|
+
o
|
|
24
25
|
] })
|
|
25
26
|
]
|
|
26
27
|
});
|
|
28
|
+
}), g = ({ beat: t }) => /* @__PURE__ */ e(l, {
|
|
29
|
+
sx: {
|
|
30
|
+
alignItems: "center",
|
|
31
|
+
gap: 8,
|
|
32
|
+
p: 24,
|
|
33
|
+
textAlign: "center"
|
|
34
|
+
},
|
|
35
|
+
children: [/* @__PURE__ */ n(s, { children: "Action Block Layer Drilldown (compact)" }), /* @__PURE__ */ e(a, { children: ["Beat: ", t.guid] })]
|
|
36
|
+
}), x = p({
|
|
37
|
+
variants: {
|
|
38
|
+
default: c,
|
|
39
|
+
compact: g
|
|
40
|
+
},
|
|
41
|
+
fallback: c,
|
|
42
|
+
name: "Placeholder"
|
|
43
|
+
}), A = i(function({ beat: r }) {
|
|
44
|
+
const { actionDrawer: o } = m(), d = o.trigger === "secondaryCta" ? r.insights_payload?.secondary_cta : r.insights_payload?.primary_cta;
|
|
45
|
+
return /* @__PURE__ */ n(x, {
|
|
46
|
+
beat: r,
|
|
47
|
+
variant: d?.variant
|
|
48
|
+
});
|
|
27
49
|
});
|
|
28
50
|
export {
|
|
29
|
-
|
|
51
|
+
A as PlaceholderActionBlock
|
|
30
52
|
};
|
|
31
53
|
|
|
32
54
|
//# sourceMappingURL=PlaceholderActionBlock.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlaceholderActionBlock.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/PlaceholderActionBlock.tsx"],"sourcesContent":["import Stack from '@mui/material/Stack'\n\nimport { H3, Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport { useInsightsV2Store } from '../../common'\nimport { type ActionBlockProps } from '../mappings/blocks'\n\
|
|
1
|
+
{"version":3,"file":"PlaceholderActionBlock.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/PlaceholderActionBlock.tsx"],"sourcesContent":["import Stack from '@mui/material/Stack'\n\nimport { H3, Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport { useActionContext, useInsightsV2Store } from '../../common'\nimport type { Beat, DrilldownPayload } from '../../core'\n\nimport { createVariantBlock } from '../blocks/createVariantBlock'\nimport { type ActionBlockProps } from '../mappings/blocks'\n\n// This block doubles as the reference example for the two building blocks a real\n// action block uses:\n// 1. useActionContext<T>() — read the drawer's opaque, block-specific context.\n// 2. createVariantBlock — dispatch to a per-variant component with a fallback.\n// Register a block with variants exactly like `PlaceholderVariants` below, then\n// wire it into src/insights-v2/mappings/blocks.ts.\n\ninterface PlaceholderVariantProps {\n beat: Beat\n}\n\n/** Default variant — also the fallback for unknown/absent variants.\n * Wrapped in `observer` because it reads the drawer's observable context via\n * useActionContext; without it a memoized ancestor would stop it re-rendering.\n * This is the copy-paste template for real blocks, so it must model the rule. */\nconst DefaultPlaceholder = observer(({ beat }: PlaceholderVariantProps) => {\n // Chart drilldowns put { chartBarIndex, tabIndex } on the drawer context; a\n // CTA open carries none, so default to 0.\n const { chartBarIndex = 0, tabIndex = 0 } = useActionContext<DrilldownPayload>() ?? {}\n\n return (\n <Stack sx={{ alignItems: 'center', gap: 8, p: 24, textAlign: 'center' }}>\n <H3>Action Block Layer Drilldown</H3>\n <Text>\n This is a placeholder action block. Replace it with your own implementation by registering\n your block in src/insights-v2/mappings/blocks.ts.\n </Text>\n <Text>Beat: {beat.guid}</Text>\n <Text>\n Drilldown: chartBarIndex {chartBarIndex}, tabIndex {tabIndex}\n </Text>\n </Stack>\n )\n})\n\n/** A second sample variant, to show registry dispatch with more than one entry. */\nconst CompactPlaceholder = ({ beat }: PlaceholderVariantProps) => (\n <Stack sx={{ alignItems: 'center', gap: 8, p: 24, textAlign: 'center' }}>\n <H3>Action Block Layer Drilldown (compact)</H3>\n <Text>Beat: {beat.guid}</Text>\n </Stack>\n)\n\n// Register one component per backend `variant`; unknown/absent variants fall\n// back to DefaultPlaceholder.\nconst PlaceholderVariants = createVariantBlock<PlaceholderVariantProps>({\n variants: {\n default: DefaultPlaceholder,\n compact: CompactPlaceholder,\n },\n fallback: DefaultPlaceholder,\n name: 'Placeholder',\n})\n\nexport const PlaceholderActionBlock = observer(function PlaceholderActionBlock({\n beat,\n}: ActionBlockProps) {\n const { actionDrawer } = useInsightsV2Store()\n const cta =\n actionDrawer.trigger === 'secondaryCta'\n ? beat.insights_payload?.secondary_cta\n : beat.insights_payload?.primary_cta\n\n return <PlaceholderVariants beat={beat} variant={cta?.variant} />\n})\n"],"mappings":";;;;;;AA0BA,IAAM,IAAqB,EAAA,CAAU,EAAE,MAAA,EAAA,MAAoC;AAGzE,QAAM,EAAE,eAAA,IAAgB,GAAG,UAAA,IAAW,EAAA,IAAM,EAAmC,KAAK,CAAC;AAErF,SACE,gBAAA,EAAC,GAAD;AAAA,IAAO,IAAI;AAAA,MAAE,YAAY;AAAA,MAAU,KAAK;AAAA,MAAG,GAAG;AAAA,MAAI,WAAW;AAAA,IAAS;AAAA,IAAtE,UAAA;AAAA,MACE,gBAAA,EAAC,GAAD,EAAA,UAAI,+BAAgC,CAAA;AAAA,MACpC,gBAAA,EAAC,GAAD,EAAA,UAAM,+IAGA,CAAA;AAAA,MACN,gBAAA,EAAC,GAAD,EAAA,UAAA,CAAM,UAAO,EAAK,IAAW,EAAA,CAAA;AAAA,MAC7B,gBAAA,EAAC,GAAD,EAAA,UAAA;AAAA,QAAM;AAAA,QACsB;AAAA,QAAc;AAAA,QAAY;AAAA,MAChD,EAAA,CAAA;AAAA,IACD;AAAA;AAEX,CAAC,GAGK,IAAA,CAAsB,EAAE,MAAA,EAAA,MAC5B,gBAAA,EAAC,GAAD;AAAA,EAAO,IAAI;AAAA,IAAE,YAAY;AAAA,IAAU,KAAK;AAAA,IAAG,GAAG;AAAA,IAAI,WAAW;AAAA,EAAS;AAAA,EAAtE,UAAA,CACE,gBAAA,EAAC,GAAD,EAAA,UAAI,yCAA0C,CAAA,GAC9C,gBAAA,EAAC,GAAD,EAAA,UAAA,CAAM,UAAO,EAAK,IAAW,EAAA,CAAA,CACxB;IAKH,IAAsB,EAA4C;AAAA,EACtE,UAAU;AAAA,IACR,SAAS;AAAA,IACT,SAAS;AAAA,EACX;AAAA,EACA,UAAU;AAAA,EACV,MAAM;AACR,CAAC,GAEY,IAAyB,EAAS,SAAgC,EAC7E,MAAA,EAAA,GACmB;AACnB,QAAM,EAAE,cAAA,EAAA,IAAiB,EAAmB,GACtC,IACJ,EAAa,YAAY,iBACrB,EAAK,kBAAkB,gBACvB,EAAK,kBAAkB;AAE7B,SAAO,gBAAA,EAAC,GAAD;AAAA,IAA2B,MAAA;AAAA,IAAM,SAAS,GAAK;AAAA,EAAU,CAAA;AAClE,CAAC"}
|
|
@@ -1,25 +1,29 @@
|
|
|
1
|
-
import { useInsightsV2Store as
|
|
2
|
-
import { formatCurrency as
|
|
3
|
-
import { BarChartV2 as
|
|
4
|
-
import { EmptyBarChart as
|
|
5
|
-
import { barChartVariant as
|
|
6
|
-
import
|
|
1
|
+
import { useInsightsV2Store as b } from "../../../../common/context/hooks.es.js";
|
|
2
|
+
import { formatCurrency as B } from "../../../../core/utils/NumberFormatting.es.js";
|
|
3
|
+
import { BarChartV2 as C } from "../../../components/chartblocks/BarchartV2.es.js";
|
|
4
|
+
import { EmptyBarChart as x } from "../../../components/chartblocks/EmptyBarChart.es.js";
|
|
5
|
+
import { barChartVariant as _, buildChartData as v, buildDataSeries as A } from "./utils.es.js";
|
|
6
|
+
import D from "react";
|
|
7
7
|
import { jsx as o } from "react/jsx-runtime";
|
|
8
|
-
import { useTheme as
|
|
8
|
+
import { useTheme as y } from "@mui/material/styles";
|
|
9
9
|
var E = ({ payload: n, beatGuid: m = "" }) => {
|
|
10
|
-
const s =
|
|
11
|
-
return t.length ? /* @__PURE__ */ o(
|
|
10
|
+
const s = y(), { openActionDrawer: c } = b(), { instance_slot: i, instance_slot_data: a } = n, { data_series: l, ariaLabel: h = "", average_amount: e = 0, legends: d = [] } = a, t = v(A(l), h), [p] = D.useState(t.length - 1), { color: u } = _(i, a, s), [f, g] = d.map((r) => r.label);
|
|
11
|
+
return t.length ? /* @__PURE__ */ o(C, {
|
|
12
12
|
amounts: {
|
|
13
13
|
average: e,
|
|
14
|
-
formattedAverage:
|
|
14
|
+
formattedAverage: B(e, "0,0")
|
|
15
15
|
},
|
|
16
16
|
color: u,
|
|
17
17
|
data: t,
|
|
18
18
|
monthlyAmountLabel: f,
|
|
19
|
-
onBarClick: (
|
|
19
|
+
onBarClick: (r) => c({
|
|
20
|
+
guid: m,
|
|
21
|
+
trigger: "chartBar",
|
|
22
|
+
context: { chartBarIndex: r }
|
|
23
|
+
}),
|
|
20
24
|
selectedTabIndex: p,
|
|
21
|
-
trendAmountLabel:
|
|
22
|
-
}) : /* @__PURE__ */ o(
|
|
25
|
+
trendAmountLabel: g
|
|
26
|
+
}) : /* @__PURE__ */ o(x, {});
|
|
23
27
|
};
|
|
24
28
|
export {
|
|
25
29
|
E as BarchartBlock
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BarchartBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.tsx"],"sourcesContent":["import React from 'react'\nimport { useTheme } from '@mui/material/styles'\n\nimport { formatCurrency, useInsightsV2Store } from '../../../../common'\nimport type { DataSeries } from '../../../../core'\nimport type { BarChartBlockData } from '../../../../core/types/InsightsInstanceSlotData'\n\nimport { BarChartV2 } from '../../../components/chartblocks/BarchartV2'\nimport { EmptyBarChart } from '../../../components/chartblocks/EmptyBarChart'\n\nimport type { BlockProps } from '../../types'\n\nimport { barChartVariant, buildChartData, buildDataSeries } from './utils'\n\nexport const BarchartBlock = ({ payload, beatGuid = '' }: BlockProps<BarChartBlockData>) => {\n const theme = useTheme()\n const {
|
|
1
|
+
{"version":3,"file":"BarchartBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.tsx"],"sourcesContent":["import React from 'react'\nimport { useTheme } from '@mui/material/styles'\n\nimport { formatCurrency, useInsightsV2Store } from '../../../../common'\nimport type { DataSeries, DrilldownPayload } from '../../../../core'\nimport type { BarChartBlockData } from '../../../../core/types/InsightsInstanceSlotData'\n\nimport { BarChartV2 } from '../../../components/chartblocks/BarchartV2'\nimport { EmptyBarChart } from '../../../components/chartblocks/EmptyBarChart'\n\nimport type { BlockProps } from '../../types'\n\nimport { barChartVariant, buildChartData, buildDataSeries } from './utils'\n\nexport const BarchartBlock = ({ payload, beatGuid = '' }: BlockProps<BarChartBlockData>) => {\n const theme = useTheme()\n const { openActionDrawer } = useInsightsV2Store()\n const { instance_slot, instance_slot_data } = payload\n const { data_series, ariaLabel = '', average_amount = 0, legends = [] } = instance_slot_data\n const chartData = buildChartData(buildDataSeries(data_series as DataSeries), ariaLabel)\n const [selectedTabIndex] = React.useState(chartData.length - 1)\n const { color } = barChartVariant(instance_slot, instance_slot_data, theme)\n\n const [monthlyAmountLabel, trendAmountLabel] = legends.map((legend) => legend.label)\n\n return chartData.length ? (\n <BarChartV2\n amounts={{\n average: average_amount,\n formattedAverage: formatCurrency(average_amount, '0,0'),\n }}\n color={color}\n data={chartData}\n monthlyAmountLabel={monthlyAmountLabel}\n onBarClick={(index) =>\n openActionDrawer({\n guid: beatGuid,\n trigger: 'chartBar',\n context: { chartBarIndex: index } satisfies DrilldownPayload,\n })\n }\n selectedTabIndex={selectedTabIndex}\n trendAmountLabel={trendAmountLabel}\n />\n ) : (\n <EmptyBarChart />\n )\n}\n"],"mappings":";;;;;;;;AAcA,IAAa,IAAA,CAAiB,EAAE,SAAA,GAAS,UAAA,IAAW,GAAA,MAAwC;AAC1F,QAAM,IAAQ,EAAS,GACjB,EAAE,kBAAA,EAAA,IAAqB,EAAmB,GAC1C,EAAE,eAAA,GAAe,oBAAA,EAAA,IAAuB,GACxC,EAAE,aAAA,GAAa,WAAA,IAAY,IAAI,gBAAA,IAAiB,GAAG,SAAA,IAAU,CAAC,EAAA,IAAM,GACpE,IAAY,EAAe,EAAgB,CAAyB,GAAG,CAAS,GAChF,CAAC,CAAA,IAAoB,EAAM,SAAS,EAAU,SAAS,CAAC,GACxD,EAAE,OAAA,EAAA,IAAU,EAAgB,GAAe,GAAoB,CAAK,GAEpE,CAAC,GAAoB,CAAA,IAAoB,EAAQ,IAAA,CAAK,MAAW,EAAO,KAAK;AAEnF,SAAO,EAAU,SACf,gBAAA,EAAC,GAAD;AAAA,IACE,SAAS;AAAA,MACP,SAAS;AAAA,MACT,kBAAkB,EAAe,GAAgB,KAAK;AAAA,IACxD;AAAA,IACO,OAAA;AAAA,IACP,MAAM;AAAA,IACc,oBAAA;AAAA,IACpB,YAAA,CAAa,MACX,EAAiB;AAAA,MACf,MAAM;AAAA,MACN,SAAS;AAAA,MACT,SAAS,EAAE,eAAe,EAAM;AAAA,IAClC,CAAC;AAAA,IAEe,kBAAA;AAAA,IACA,kBAAA;AAAA,EACnB,CAAA,IAED,gBAAA,EAAC,GAAD,CAAgB,CAAA;AAEpB"}
|
|
@@ -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 (
|
|
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"}
|
|
@@ -3,12 +3,12 @@ import { Text as l } from "@mxenabled/mxui";
|
|
|
3
3
|
import { jsx as e, jsxs as i } from "react/jsx-runtime";
|
|
4
4
|
import c from "@mui/material/Box";
|
|
5
5
|
import { PieChart as m } from "@mui/x-charts/PieChart";
|
|
6
|
-
var w = ({ data:
|
|
7
|
-
const d =
|
|
6
|
+
var w = ({ data: a, centerLabel: n, centerValue: h }) => {
|
|
7
|
+
const d = a.some((t) => t.label && t.labelValue), r = !d, u = a.map((t, s) => ({
|
|
8
8
|
id: s,
|
|
9
9
|
color: t.color,
|
|
10
10
|
value: t.value
|
|
11
|
-
})), x = r ? 30 : 53, p = r ? 35 : 63, f = 2, b = () => r ? "body1" :
|
|
11
|
+
})), x = r ? 30 : 53, p = r ? 35 : 63, f = 2, b = () => r ? "body1" : n ? "h3" : "h2";
|
|
12
12
|
return /* @__PURE__ */ i(o, {
|
|
13
13
|
sx: {
|
|
14
14
|
alignItems: "center",
|
|
@@ -42,10 +42,10 @@ var w = ({ data: n, centerLabel: a, centerValue: h }) => {
|
|
|
42
42
|
sx: { ...r && { fontWeight: 600 } },
|
|
43
43
|
variant: b(),
|
|
44
44
|
children: h
|
|
45
|
-
}),
|
|
45
|
+
}), n && /* @__PURE__ */ e(l, {
|
|
46
46
|
sx: { color: "text.secondary" },
|
|
47
47
|
variant: r ? "caption" : "body2",
|
|
48
|
-
children:
|
|
48
|
+
children: n
|
|
49
49
|
})]
|
|
50
50
|
})]
|
|
51
51
|
}), d && /* @__PURE__ */ e(o, {
|
|
@@ -53,7 +53,7 @@ var w = ({ data: n, centerLabel: a, centerValue: h }) => {
|
|
|
53
53
|
gap: 24,
|
|
54
54
|
pl: 24
|
|
55
55
|
},
|
|
56
|
-
children:
|
|
56
|
+
children: a.map((t, s) => t.label && t.labelValue && /* @__PURE__ */ i(o, { children: [/* @__PURE__ */ i(o, {
|
|
57
57
|
sx: {
|
|
58
58
|
gap: 8,
|
|
59
59
|
flexDirection: "row",
|
|
@@ -76,7 +76,7 @@ var w = ({ data: n, centerLabel: a, centerValue: h }) => {
|
|
|
76
76
|
},
|
|
77
77
|
variant: "subtitle2",
|
|
78
78
|
children: t.labelValue
|
|
79
|
-
})] }, s))
|
|
79
|
+
})] }, t.label ?? s))
|
|
80
80
|
})]
|
|
81
81
|
});
|
|
82
82
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DonutChart.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChart.tsx"],"sourcesContent":["import Box from '@mui/material/Box'\nimport Stack from '@mui/material/Stack'\nimport { Text } from '@mxenabled/mxui'\nimport { PieChart } from '@mui/x-charts/PieChart'\ninterface DonutSegment {\n color: string\n label?: string\n labelValue?: React.ReactNode\n value: number\n}\n\ninterface DonutChartV2Props {\n data: DonutSegment[]\n centerLabel?: string\n centerValue: string\n}\n\nconst DonutChartV2 = ({ data, centerLabel, centerValue }: DonutChartV2Props) => {\n const hasLegend = data.some((segment) => segment.label && segment.labelValue)\n const isEmbedded = !hasLegend\n\n const chartData = data.map((item, index) => ({\n id: index,\n color: item.color,\n value: item.value,\n }))\n const innerRadius = isEmbedded ? 30 : 53\n const outerRadius = isEmbedded ? 35 : 63\n const cornerRadius = 2\n\n const getCenterValueVariant = () => {\n if (isEmbedded) return 'body1'\n if (centerLabel) return 'h3'\n return 'h2'\n }\n\n return (\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', px: 16, py: 4 }}>\n <Box\n sx={{\n alignItems: 'center',\n display: 'flex',\n justifyContent: 'center',\n position: 'relative',\n }}\n >\n <PieChart\n height={isEmbedded ? 72 : 125}\n series={[\n {\n cornerRadius,\n data: chartData,\n innerRadius,\n outerRadius,\n },\n ]}\n slots={{ tooltip: () => null }}\n width={isEmbedded ? 72 : 125}\n />\n\n <Box sx={{ position: 'absolute', textAlign: 'center' }}>\n <Text sx={{ ...(isEmbedded && { fontWeight: 600 }) }} variant={getCenterValueVariant()}>\n {centerValue}\n </Text>\n {centerLabel && (\n <Text sx={{ color: 'text.secondary' }} variant={isEmbedded ? 'caption' : 'body2'}>\n {centerLabel}\n </Text>\n )}\n </Box>\n </Box>\n\n {hasLegend && (\n <Stack sx={{ gap: 24, pl: 24 }}>\n {data.map(\n (segment, index) =>\n segment.label &&\n segment.labelValue && (\n <Stack key={index}>\n <Stack sx={{ gap: 8, flexDirection: 'row', alignItems: 'center' }}>\n <Box\n sx={{\n backgroundColor: segment.color,\n borderRadius: '2px',\n height: 12,\n width: 12,\n }}\n />\n <Text sx={{ fontWeight: 400 }} variant=\"subtitle2\">\n {segment.label}\n </Text>\n </Stack>\n <Text sx={{ fontWeight: 400, pl: 20 }} variant=\"subtitle2\">\n {segment.labelValue}\n </Text>\n </Stack>\n ),\n )}\n </Stack>\n )}\n </Stack>\n )\n}\n\nexport default DonutChartV2\n"],"mappings":";;;;;AAiBA,IAAM,IAAA,CAAgB,EAAE,MAAA,GAAM,aAAA,GAAa,aAAA,EAAA,MAAqC;AAC9E,QAAM,IAAY,EAAK,KAAA,CAAM,MAAY,EAAQ,SAAS,EAAQ,UAAU,GACtE,IAAa,CAAC,GAEd,IAAY,EAAK,IAAA,CAAK,GAAM,OAAW;AAAA,IAC3C,IAAI;AAAA,IACJ,OAAO,EAAK;AAAA,IACZ,OAAO,EAAK;AAAA,EACd,EAAE,GACI,IAAc,IAAa,KAAK,IAChC,IAAc,IAAa,KAAK,IAChC,IAAe,GAEf,IAAA,MACA,IAAmB,UACnB,IAAoB,OACjB;AAGT,SACE,gBAAA,EAAC,GAAD;AAAA,IAAO,IAAI;AAAA,MAAE,YAAY;AAAA,MAAU,eAAe;AAAA,MAAO,IAAI;AAAA,MAAI,IAAI;AAAA,IAAE;AAAA,IAAvE,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,MACE,IAAI;AAAA,QACF,YAAY;AAAA,QACZ,SAAS;AAAA,QACT,gBAAgB;AAAA,QAChB,UAAU;AAAA,MACZ;AAAA,MANF,UAAA,CAQE,gBAAA,EAAC,GAAD;AAAA,QACE,QAAQ,IAAa,KAAK;AAAA,QAC1B,QAAQ,CACN;AAAA,UACE,cAAA;AAAA,UACA,MAAM;AAAA,UACN,aAAA;AAAA,UACA,aAAA;AAAA,QACF,CACF;AAAA,QACA,OAAO,EAAE,SAAA,MAAe,KAAK;AAAA,QAC7B,OAAO,IAAa,KAAK;AAAA,MAC1B,CAAA,GAED,gBAAA,EAAC,GAAD;AAAA,QAAK,IAAI;AAAA,UAAE,UAAU;AAAA,UAAY,WAAW;AAAA,QAAS;AAAA,QAArD,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,UAAM,IAAI,EAAE,GAAI,KAAc,EAAE,YAAY,IAAI,EAAG;AAAA,UAAG,SAAS,EAAsB;AAAA,UAClF,UAAA;AAAA,QACG,CAAA,GACL,KACC,gBAAA,EAAC,GAAD;AAAA,UAAM,IAAI,EAAE,OAAO,iBAAiB;AAAA,UAAG,SAAS,IAAa,YAAY;AAAA,UACtE,UAAA;AAAA,QACG,CAAA,CAEL;AAAA,MACF,CAAA,CAAA;AAAA,IAEJ,CAAA,GAAA,KACC,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI;AAAA,QAAE,KAAK;AAAA,QAAI,IAAI;AAAA,MAAG;AAAA,MAC1B,UAAA,EAAK,IAAA,CACH,GAAS,MACR,EAAQ,SACR,EAAQ,cACN,gBAAA,EAAC,GAAD,EAAA,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,QAAO,IAAI;AAAA,UAAE,KAAK;AAAA,UAAG,eAAe;AAAA,UAAO,YAAY;AAAA,QAAS;AAAA,QAAhE,UAAA,CACE,gBAAA,EAAC,GAAD,EACE,IAAI;AAAA,UACF,iBAAiB,EAAQ;AAAA,UACzB,cAAc;AAAA,UACd,QAAQ;AAAA,UACR,OAAO;AAAA,QACT,EACD,CAAA,GACD,gBAAA,EAAC,GAAD;AAAA,UAAM,IAAI,EAAE,YAAY,IAAI;AAAA,UAAG,SAAQ;AAAA,UACpC,UAAA,EAAQ;AAAA,QACL,CAAA,CACD;AAAA,MACP,CAAA,GAAA,gBAAA,EAAC,GAAD;AAAA,QAAM,IAAI;AAAA,UAAE,YAAY;AAAA,UAAK,IAAI;AAAA,QAAG;AAAA,QAAG,SAAQ;AAAA,QAC5C,UAAA,EAAQ;AAAA,MACL,CAAA,CACD,EAAA,GAjBK,
|
|
1
|
+
{"version":3,"file":"DonutChart.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChart.tsx"],"sourcesContent":["import Box from '@mui/material/Box'\nimport Stack from '@mui/material/Stack'\nimport { Text } from '@mxenabled/mxui'\nimport { PieChart } from '@mui/x-charts/PieChart'\ninterface DonutSegment {\n color: string\n label?: string\n labelValue?: React.ReactNode\n value: number\n}\n\ninterface DonutChartV2Props {\n data: DonutSegment[]\n centerLabel?: string\n centerValue: string\n}\n\nconst DonutChartV2 = ({ data, centerLabel, centerValue }: DonutChartV2Props) => {\n const hasLegend = data.some((segment) => segment.label && segment.labelValue)\n const isEmbedded = !hasLegend\n\n const chartData = data.map((item, index) => ({\n id: index,\n color: item.color,\n value: item.value,\n }))\n const innerRadius = isEmbedded ? 30 : 53\n const outerRadius = isEmbedded ? 35 : 63\n const cornerRadius = 2\n\n const getCenterValueVariant = () => {\n if (isEmbedded) return 'body1'\n if (centerLabel) return 'h3'\n return 'h2'\n }\n\n return (\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', px: 16, py: 4 }}>\n <Box\n sx={{\n alignItems: 'center',\n display: 'flex',\n justifyContent: 'center',\n position: 'relative',\n }}\n >\n <PieChart\n height={isEmbedded ? 72 : 125}\n series={[\n {\n cornerRadius,\n data: chartData,\n innerRadius,\n outerRadius,\n },\n ]}\n slots={{ tooltip: () => null }}\n width={isEmbedded ? 72 : 125}\n />\n\n <Box sx={{ position: 'absolute', textAlign: 'center' }}>\n <Text sx={{ ...(isEmbedded && { fontWeight: 600 }) }} variant={getCenterValueVariant()}>\n {centerValue}\n </Text>\n {centerLabel && (\n <Text sx={{ color: 'text.secondary' }} variant={isEmbedded ? 'caption' : 'body2'}>\n {centerLabel}\n </Text>\n )}\n </Box>\n </Box>\n\n {hasLegend && (\n <Stack sx={{ gap: 24, pl: 24 }}>\n {data.map(\n (segment, index) =>\n segment.label &&\n segment.labelValue && (\n <Stack key={segment.label ?? index}>\n <Stack sx={{ gap: 8, flexDirection: 'row', alignItems: 'center' }}>\n <Box\n sx={{\n backgroundColor: segment.color,\n borderRadius: '2px',\n height: 12,\n width: 12,\n }}\n />\n <Text sx={{ fontWeight: 400 }} variant=\"subtitle2\">\n {segment.label}\n </Text>\n </Stack>\n <Text sx={{ fontWeight: 400, pl: 20 }} variant=\"subtitle2\">\n {segment.labelValue}\n </Text>\n </Stack>\n ),\n )}\n </Stack>\n )}\n </Stack>\n )\n}\n\nexport default DonutChartV2\n"],"mappings":";;;;;AAiBA,IAAM,IAAA,CAAgB,EAAE,MAAA,GAAM,aAAA,GAAa,aAAA,EAAA,MAAqC;AAC9E,QAAM,IAAY,EAAK,KAAA,CAAM,MAAY,EAAQ,SAAS,EAAQ,UAAU,GACtE,IAAa,CAAC,GAEd,IAAY,EAAK,IAAA,CAAK,GAAM,OAAW;AAAA,IAC3C,IAAI;AAAA,IACJ,OAAO,EAAK;AAAA,IACZ,OAAO,EAAK;AAAA,EACd,EAAE,GACI,IAAc,IAAa,KAAK,IAChC,IAAc,IAAa,KAAK,IAChC,IAAe,GAEf,IAAA,MACA,IAAmB,UACnB,IAAoB,OACjB;AAGT,SACE,gBAAA,EAAC,GAAD;AAAA,IAAO,IAAI;AAAA,MAAE,YAAY;AAAA,MAAU,eAAe;AAAA,MAAO,IAAI;AAAA,MAAI,IAAI;AAAA,IAAE;AAAA,IAAvE,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,MACE,IAAI;AAAA,QACF,YAAY;AAAA,QACZ,SAAS;AAAA,QACT,gBAAgB;AAAA,QAChB,UAAU;AAAA,MACZ;AAAA,MANF,UAAA,CAQE,gBAAA,EAAC,GAAD;AAAA,QACE,QAAQ,IAAa,KAAK;AAAA,QAC1B,QAAQ,CACN;AAAA,UACE,cAAA;AAAA,UACA,MAAM;AAAA,UACN,aAAA;AAAA,UACA,aAAA;AAAA,QACF,CACF;AAAA,QACA,OAAO,EAAE,SAAA,MAAe,KAAK;AAAA,QAC7B,OAAO,IAAa,KAAK;AAAA,MAC1B,CAAA,GAED,gBAAA,EAAC,GAAD;AAAA,QAAK,IAAI;AAAA,UAAE,UAAU;AAAA,UAAY,WAAW;AAAA,QAAS;AAAA,QAArD,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,UAAM,IAAI,EAAE,GAAI,KAAc,EAAE,YAAY,IAAI,EAAG;AAAA,UAAG,SAAS,EAAsB;AAAA,UAClF,UAAA;AAAA,QACG,CAAA,GACL,KACC,gBAAA,EAAC,GAAD;AAAA,UAAM,IAAI,EAAE,OAAO,iBAAiB;AAAA,UAAG,SAAS,IAAa,YAAY;AAAA,UACtE,UAAA;AAAA,QACG,CAAA,CAEL;AAAA,MACF,CAAA,CAAA;AAAA,IAEJ,CAAA,GAAA,KACC,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI;AAAA,QAAE,KAAK;AAAA,QAAI,IAAI;AAAA,MAAG;AAAA,MAC1B,UAAA,EAAK,IAAA,CACH,GAAS,MACR,EAAQ,SACR,EAAQ,cACN,gBAAA,EAAC,GAAD,EAAA,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,QAAO,IAAI;AAAA,UAAE,KAAK;AAAA,UAAG,eAAe;AAAA,UAAO,YAAY;AAAA,QAAS;AAAA,QAAhE,UAAA,CACE,gBAAA,EAAC,GAAD,EACE,IAAI;AAAA,UACF,iBAAiB,EAAQ;AAAA,UACzB,cAAc;AAAA,UACd,QAAQ;AAAA,UACR,OAAO;AAAA,QACT,EACD,CAAA,GACD,gBAAA,EAAC,GAAD;AAAA,UAAM,IAAI,EAAE,YAAY,IAAI;AAAA,UAAG,SAAQ;AAAA,UACpC,UAAA,EAAQ;AAAA,QACL,CAAA,CACD;AAAA,MACP,CAAA,GAAA,gBAAA,EAAC,GAAD;AAAA,QAAM,IAAI;AAAA,UAAE,YAAY;AAAA,UAAK,IAAI;AAAA,QAAG;AAAA,QAAG,SAAQ;AAAA,QAC5C,UAAA,EAAQ;AAAA,MACL,CAAA,CACD,EAAA,GAjBK,EAAQ,SAAS,CAiBtB,CAEb;AAAA,IACK,CAAA,CAEJ;AAAA;AAEX"}
|
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
import { useInsightsV2Store as
|
|
2
|
-
import { DoubleBarChart as
|
|
3
|
-
import { buildComparisonSeries as
|
|
4
|
-
import { getLayoutConfig as
|
|
1
|
+
import { useInsightsV2Store as f } from "../../../../common/context/hooks.es.js";
|
|
2
|
+
import { DoubleBarChart as g } from "../../../components/chartblocks/DoubleBarChart.es.js";
|
|
3
|
+
import { buildComparisonSeries as h } from "./comparisonUtils.es.js";
|
|
4
|
+
import { getLayoutConfig as b } from "./layout.es.js";
|
|
5
5
|
import { jsx as B } from "react/jsx-runtime";
|
|
6
|
-
import { useTheme as
|
|
7
|
-
var L = ({ payload: { instance_slot:
|
|
8
|
-
const
|
|
9
|
-
return /* @__PURE__ */ B(
|
|
10
|
-
bars:
|
|
6
|
+
import { useTheme as x } from "@mui/material/styles";
|
|
7
|
+
var L = ({ payload: { instance_slot: r, instance_slot_data: o, widget_type: t }, beatGuid: e = "" }) => {
|
|
8
|
+
const a = x(), { openActionDrawer: i } = f(), { variant: n } = r, { ariaLabel: s = "", data_series: m, legends: c } = o, l = h(m, s), p = b(a, n)?.color ?? [];
|
|
9
|
+
return /* @__PURE__ */ B(g, {
|
|
10
|
+
bars: l,
|
|
11
11
|
colors: p,
|
|
12
12
|
isMini: t === "mini",
|
|
13
|
-
legends:
|
|
14
|
-
onBarClick: (
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
legends: c,
|
|
14
|
+
onBarClick: (u, d) => i({
|
|
15
|
+
guid: e,
|
|
16
|
+
trigger: "chartBar",
|
|
17
|
+
context: {
|
|
18
|
+
chartBarIndex: u,
|
|
19
|
+
tabIndex: d
|
|
20
|
+
}
|
|
17
21
|
})
|
|
18
22
|
});
|
|
19
23
|
};
|
package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/DoubleBarChartBlock.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DoubleBarChartBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/DoubleBarChartBlock.tsx"],"sourcesContent":["import { useTheme } from '@mui/material/styles'\n\nimport { useInsightsV2Store } from '../../../../common'\nimport type { DataSeries } from '../../../../core'\nimport { DoubleBarChart } from '../../../components/chartblocks/DoubleBarChart'\n\nimport type { BlockProps } from '../../types'\n\nimport { buildComparisonSeries } from './comparisonUtils'\nimport { getLayoutConfig } from './layout'\n\n/**\n * Card block for the double-bar chart. Mirrors BarchartBlock: it builds the shaped series\n * (buildComparisonSeries) and resolves the card palette (getLayoutConfig), then renders the reusable\n * DoubleBarChart and injects the card click behavior \\u2014 open the shared drawer scoped to this beat\n * (chartBarIndex = clicked column, tabIndex = clicked sub-series).\n */\nexport const DoubleBarChartBlock = ({\n payload: { instance_slot, instance_slot_data, widget_type },\n beatGuid = '',\n}: BlockProps) => {\n const theme = useTheme()\n const {
|
|
1
|
+
{"version":3,"file":"DoubleBarChartBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/DoubleBarChartBlock.tsx"],"sourcesContent":["import { useTheme } from '@mui/material/styles'\n\nimport { useInsightsV2Store } from '../../../../common'\nimport type { DataSeries, DrilldownPayload } from '../../../../core'\nimport { DoubleBarChart } from '../../../components/chartblocks/DoubleBarChart'\n\nimport type { BlockProps } from '../../types'\n\nimport { buildComparisonSeries } from './comparisonUtils'\nimport { getLayoutConfig } from './layout'\n\n/**\n * Card block for the double-bar chart. Mirrors BarchartBlock: it builds the shaped series\n * (buildComparisonSeries) and resolves the card palette (getLayoutConfig), then renders the reusable\n * DoubleBarChart and injects the card click behavior \\u2014 open the shared drawer scoped to this beat\n * (chartBarIndex = clicked column, tabIndex = clicked sub-series).\n */\nexport const DoubleBarChartBlock = ({\n payload: { instance_slot, instance_slot_data, widget_type },\n beatGuid = '',\n}: BlockProps) => {\n const theme = useTheme()\n const { openActionDrawer } = useInsightsV2Store()\n const { variant } = instance_slot\n const { ariaLabel = '', data_series, legends } = instance_slot_data\n const bars = buildComparisonSeries(data_series as DataSeries, ariaLabel)\n // getLayoutConfig returns undefined for an unknown/unsupported variant; fall back to an empty\n // palette so an unregistered beat can't throw on mount.\n const colors = getLayoutConfig(theme, variant)?.color ?? []\n\n return (\n <DoubleBarChart\n bars={bars}\n colors={colors}\n isMini={widget_type === 'mini'}\n legends={legends}\n onBarClick={(columnIndex, subIndex) =>\n openActionDrawer({\n guid: beatGuid,\n trigger: 'chartBar',\n context: { chartBarIndex: columnIndex, tabIndex: subIndex } satisfies DrilldownPayload,\n })\n }\n />\n )\n}\n"],"mappings":";;;;;;AAiBA,IAAa,IAAA,CAAuB,EAClC,SAAS,EAAE,eAAA,GAAe,oBAAA,GAAoB,aAAA,EAAA,GAC9C,UAAA,IAAW,GAAA,MACK;AAChB,QAAM,IAAQ,EAAS,GACjB,EAAE,kBAAA,EAAA,IAAqB,EAAmB,GAC1C,EAAE,SAAA,EAAA,IAAY,GACd,EAAE,WAAA,IAAY,IAAI,aAAA,GAAa,SAAA,EAAA,IAAY,GAC3C,IAAO,EAAsB,GAA2B,CAAS,GAGjE,IAAS,EAAgB,GAAO,CAAO,GAAG,SAAS,CAAC;AAE1D,SACE,gBAAA,EAAC,GAAD;AAAA,IACQ,MAAA;AAAA,IACE,QAAA;AAAA,IACR,QAAQ,MAAgB;AAAA,IACf,SAAA;AAAA,IACT,YAAA,CAAa,GAAa,MACxB,EAAiB;AAAA,MACf,MAAM;AAAA,MACN,SAAS;AAAA,MACT,SAAS;AAAA,QAAE,eAAe;AAAA,QAAa,UAAU;AAAA,MAAS;AAAA,IAC5D,CAAC;AAAA,EAEJ,CAAA;AAEL"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './BarchartBlock';
|
|
2
2
|
export * from './BarchartBlock/utils';
|
|
3
3
|
export * from './DoubleBarChartBlock';
|
|
4
|
+
export { default as StepChartBlock } from './StepChartBlock/StepChartBlock';
|
|
4
5
|
export { default as DonutChartBlock } from './DonutChartBlock/DonutChartBlock';
|
|
5
6
|
export { default as DoubleProgressBarBlock } from './DoubleProgressBarBlock/DoubleProgressBarBlock';
|
|
@@ -1,42 +1,36 @@
|
|
|
1
1
|
import { buildDynamicCopy as a } from "../../../../core/utils/Localization.es.js";
|
|
2
2
|
import { getCategoryColor as h } from "../../../../core/utils/CategoryUtil.es.js";
|
|
3
|
-
import { formatCurrency as
|
|
3
|
+
import { formatCurrency as r } from "../../../../core/utils/NumberFormatting.es.js";
|
|
4
4
|
import C from "../../../components/ComponentBlocks/StatusIndicator.es.js";
|
|
5
5
|
import { getColorByBudgetTier as x } from "./util.es.js";
|
|
6
6
|
import { CategoryIcon as B, MerchantLogo as T, Text as k } from "@mxenabled/mxui";
|
|
7
|
-
import { jsx as
|
|
7
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
8
8
|
import { alpha as v, useTheme as G } from "@mui/material/styles";
|
|
9
9
|
var W = ({ payload: i }) => {
|
|
10
|
-
const { budget_percent: c, amount: l, budget_tier: m, category_guid: o, merchant_guid: d, spent_amount: u, budgeted_amount: p, localized_payload:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
borderColor: n,
|
|
20
|
-
borderWidth: 1,
|
|
21
|
-
borderStyle: "solid"
|
|
22
|
-
}
|
|
23
|
-
});
|
|
10
|
+
const { budget_percent: c, amount: l, budget_tier: m, category_guid: o, merchant_guid: d, spent_amount: u, budgeted_amount: p, localized_payload: t } = i.instance_slot_data, s = x(m), g = G(), n = o ? h(o, g) : "", b = o && o !== null ? /* @__PURE__ */ e(B, {
|
|
11
|
+
categoryGuid: o,
|
|
12
|
+
size: 44,
|
|
13
|
+
sx: {
|
|
14
|
+
color: "text.primary",
|
|
15
|
+
bgcolor: v(n, 0.25),
|
|
16
|
+
borderColor: n,
|
|
17
|
+
borderWidth: 1,
|
|
18
|
+
borderStyle: "solid"
|
|
24
19
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}, _ = a(r?.spent_label || "", e(u, "0,0.00")), f = a(r?.budgeted_label || "", e(p, "0,0.00")), y = /* @__PURE__ */ t(k, {
|
|
20
|
+
}) : /* @__PURE__ */ e(T, {
|
|
21
|
+
categoryGuid: o || "",
|
|
22
|
+
merchantGuid: d || ""
|
|
23
|
+
}), _ = a(t?.spent_label || "", r(u, "0,0.00")), f = a(t?.budgeted_label || "", r(p, "0,0.00")), y = /* @__PURE__ */ e(k, {
|
|
30
24
|
bold: !0,
|
|
31
25
|
variant: "h2",
|
|
32
|
-
children: o && o !== null ? a(
|
|
26
|
+
children: o && o !== null ? a(t?.amount_left_label || "", r(l, "0,0.00")) : r(l, "0,0.00")
|
|
33
27
|
});
|
|
34
|
-
return /* @__PURE__ */
|
|
28
|
+
return /* @__PURE__ */ e(C, {
|
|
35
29
|
amount: y,
|
|
36
30
|
borderRadius: "12px",
|
|
37
31
|
completeColor: s,
|
|
38
|
-
icon:
|
|
39
|
-
label:
|
|
32
|
+
icon: b,
|
|
33
|
+
label: t?.primary_text || "",
|
|
40
34
|
leftLabel: _,
|
|
41
35
|
percentComplete: c,
|
|
42
36
|
rightLabel: f,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BudgetBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ComponentBlocks/BudgetBlock/BudgetBlock.tsx"],"sourcesContent":["import { alpha, useTheme } from '@mui/material/styles'\n\nimport { CategoryIcon, MerchantLogo, Text } from '@mxenabled/mxui'\n\nimport { buildDynamicCopy, formatCurrency } from '../../../../common'\nimport type { BudgetBlockData } from '../../../../core/types/InsightsInstanceSlotData'\nimport { getCategoryColor } from '../../../../core/utils/CategoryUtil'\n\nimport StatusIndicator from '../../../components/ComponentBlocks/StatusIndicator'\n\nimport type { BlockProps } from '../../types'\n\nimport { getColorByBudgetTier } from './util'\n\nexport const BudgetBlock = ({ payload }: BlockProps<BudgetBlockData>) => {\n const {\n budget_percent,\n amount,\n budget_tier,\n category_guid,\n merchant_guid,\n spent_amount,\n budgeted_amount,\n localized_payload,\n } = payload.instance_slot_data\n\n const color = getColorByBudgetTier(budget_tier)\n\n const theme = useTheme()\n\n const
|
|
1
|
+
{"version":3,"file":"BudgetBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ComponentBlocks/BudgetBlock/BudgetBlock.tsx"],"sourcesContent":["import { alpha, useTheme } from '@mui/material/styles'\n\nimport { CategoryIcon, MerchantLogo, Text } from '@mxenabled/mxui'\n\nimport { buildDynamicCopy, formatCurrency } from '../../../../common'\nimport type { BudgetBlockData } from '../../../../core/types/InsightsInstanceSlotData'\nimport { getCategoryColor } from '../../../../core/utils/CategoryUtil'\n\nimport StatusIndicator from '../../../components/ComponentBlocks/StatusIndicator'\n\nimport type { BlockProps } from '../../types'\n\nimport { getColorByBudgetTier } from './util'\n\nexport const BudgetBlock = ({ payload }: BlockProps<BudgetBlockData>) => {\n const {\n budget_percent,\n amount,\n budget_tier,\n category_guid,\n merchant_guid,\n spent_amount,\n budgeted_amount,\n localized_payload,\n } = payload.instance_slot_data\n\n const color = getColorByBudgetTier(budget_tier)\n\n const theme = useTheme()\n\n const avatarBgColor = category_guid ? getCategoryColor(category_guid, theme) : ''\n\n // Precomputed as a JSX element (not a component defined during render) so it\n // isn't remounted on every re-render.\n const icon =\n category_guid && category_guid !== null ? (\n <CategoryIcon\n categoryGuid={category_guid}\n size={44}\n sx={{\n color: 'text.primary',\n bgcolor: alpha(avatarBgColor, 0.25),\n borderColor: avatarBgColor,\n borderWidth: 1,\n borderStyle: 'solid',\n }}\n />\n ) : (\n <MerchantLogo categoryGuid={category_guid || ''} merchantGuid={merchant_guid || ''} />\n )\n\n const block_left_footer = buildDynamicCopy(\n localized_payload?.spent_label || '',\n formatCurrency(spent_amount, '0,0.00'),\n ) as string\n\n const block_right_footer = buildDynamicCopy(\n localized_payload?.budgeted_label || '',\n formatCurrency(budgeted_amount, '0,0.00'),\n ) as string\n\n const amountToDisplay = (\n <Text bold={true} variant=\"h2\">\n {category_guid && category_guid !== null\n ? (buildDynamicCopy(\n localized_payload?.amount_left_label || '',\n formatCurrency(amount, '0,0.00'),\n ) as string)\n : formatCurrency(amount, '0,0.00')}\n </Text>\n )\n\n return (\n <StatusIndicator\n amount={amountToDisplay}\n borderRadius=\"12px\"\n completeColor={color}\n icon={icon}\n label={localized_payload?.primary_text || ''}\n leftLabel={block_left_footer}\n percentComplete={budget_percent}\n rightLabel={block_right_footer}\n sx={{ '& .details-container': { gap: 12 } }}\n />\n )\n}\n"],"mappings":";;;;;;;;AAcA,IAAa,IAAA,CAAe,EAAE,SAAA,EAAA,MAA2C;AACvE,QAAM,EACJ,gBAAA,GACA,QAAA,GACA,aAAA,GACA,eAAA,GACA,eAAA,GACA,cAAA,GACA,iBAAA,GACA,mBAAA,EAAA,IACE,EAAQ,oBAEN,IAAQ,EAAqB,CAAW,GAExC,IAAQ,EAAS,GAEjB,IAAgB,IAAgB,EAAiB,GAAe,CAAK,IAAI,IAIzE,IACJ,KAAiB,MAAkB,OACjC,gBAAA,EAAC,GAAD;AAAA,IACE,cAAc;AAAA,IACd,MAAM;AAAA,IACN,IAAI;AAAA,MACF,OAAO;AAAA,MACP,SAAS,EAAM,GAAe,IAAI;AAAA,MAClC,aAAa;AAAA,MACb,aAAa;AAAA,MACb,aAAa;AAAA,IACf;AAAA,EACD,CAAA,IAED,gBAAA,EAAC,GAAD;AAAA,IAAc,cAAc,KAAiB;AAAA,IAAI,cAAc,KAAiB;AAAA,EAAK,CAAA,GAGnF,IAAoB,EACxB,GAAmB,eAAe,IAClC,EAAe,GAAc,QAAQ,CACvC,GAEM,IAAqB,EACzB,GAAmB,kBAAkB,IACrC,EAAe,GAAiB,QAAQ,CAC1C,GAEM,IACJ,gBAAA,EAAC,GAAD;AAAA,IAAM,MAAM;AAAA,IAAM,SAAQ;AAAA,IACvB,UAAA,KAAiB,MAAkB,OAC/B,EACC,GAAmB,qBAAqB,IACxC,EAAe,GAAQ,QAAQ,CACjC,IACA,EAAe,GAAQ,QAAQ;AAAA,EAC/B,CAAA;AAGR,SACE,gBAAA,EAAC,GAAD;AAAA,IACE,QAAQ;AAAA,IACR,cAAa;AAAA,IACb,eAAe;AAAA,IACT,MAAA;AAAA,IACN,OAAO,GAAmB,gBAAgB;AAAA,IAC1C,WAAW;AAAA,IACX,iBAAiB;AAAA,IACjB,YAAY;AAAA,IACZ,IAAI,EAAE,wBAAwB,EAAE,KAAK,GAAG,EAAE;AAAA,EAC3C,CAAA;AAEL"}
|