@mx-cartographer/experiences 9.7.192 → 9.7.193
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 +6 -0
- package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/CreditUtilizationBlock.es.js +16 -15
- package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/CreditUtilizationBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/layout.d.ts +5 -1
- package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/layout.es.js +37 -33
- package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/layout.d.ts +2 -0
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/layout.es.js +17 -15
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/layout.es.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## [9.7.193] - 11-19-2026
|
|
2
|
+
|
|
3
|
+
- **ADDED** - Credit Utilization Insights 2.0 donut (credit_utilization variant) coloured by the utilization band (WEC-2348)
|
|
4
|
+
- **CHANGED** - Credit Utilization drawer reads its sums and cards from the Learn More CTA's drilldown_data, falling back to the legacy instance_slot_data (WEC-2348)
|
|
5
|
+
- **ADDED** - Credit Utilization Storybook QA page with every state (including No longer relevant) and widget (WEC-2348)
|
|
6
|
+
|
|
1
7
|
## [9.7.192] - 11-19-2026
|
|
2
8
|
|
|
3
9
|
- **FIXED** - Monthly Credit Card Interest Summary V2 card: the fees wash and the category tile's 1.5px border match Figma (WEC-2336)
|
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
import { useAccountStore as m, useGlobalCopyStore as p } from "../../../common/context/hooks.es.js";
|
|
2
2
|
import C from "../../../common/components/drawer/Drawer.es.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import v from "./
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
3
|
+
import { useOpenedCta as _ } from "../useOpenedCta.es.js";
|
|
4
|
+
import { useRequiredCopy as f } from "../useRequiredCopy.es.js";
|
|
5
|
+
import { AccountDetailsBlock as y } from "../AccountDetailsBlock/AccountDetailsBlock.es.js";
|
|
6
|
+
import { readCardRows as g, readDrawerFacts as v, readSummary as z } from "./layout.es.js";
|
|
7
|
+
import G from "./CreditUtilizationContent.es.js";
|
|
8
|
+
import { useState as h } from "react";
|
|
9
|
+
import { observer as k } from "mobx-react-lite";
|
|
10
|
+
import { Fragment as A, jsx as e, jsxs as B } from "react/jsx-runtime";
|
|
11
|
+
var D = (i, o) => ({
|
|
11
12
|
...i,
|
|
12
13
|
accountLoaded: o !== void 0,
|
|
13
14
|
institutionGuid: o?.institution_guid ?? ""
|
|
14
|
-
}),
|
|
15
|
-
const [a, n] =
|
|
16
|
-
return /* @__PURE__ */
|
|
15
|
+
}), S = (i) => i.insights_feed?.credit_utilization, M = k(function({ beat: o }) {
|
|
16
|
+
const [a, n] = h(null), { accounts: r } = p(), { accounts: s } = m(), d = f(S), c = v(_(o), o.insights_payload?.instance_slot_data), u = new Map(s.map((t) => [t.guid, t])), l = g(c?.data_series).map((t) => D(t, u.get(t.guid)));
|
|
17
|
+
return /* @__PURE__ */ B(A, { children: [/* @__PURE__ */ e(G, {
|
|
17
18
|
accountDetailsLabel: r?.account_details,
|
|
18
19
|
cards: l,
|
|
19
20
|
copy: d,
|
|
20
21
|
onCardClick: ({ guid: t }) => n(t),
|
|
21
|
-
summary:
|
|
22
|
+
summary: z(c)
|
|
22
23
|
}), /* @__PURE__ */ e(C, {
|
|
23
24
|
ariaLabelClose: r?.close_account_details_aria,
|
|
24
25
|
isOpen: a !== null,
|
|
25
26
|
onClose: () => n(null),
|
|
26
27
|
title: r?.account_details,
|
|
27
|
-
children: a && /* @__PURE__ */ e(
|
|
28
|
+
children: a && /* @__PURE__ */ e(y, { beat: {
|
|
28
29
|
...o,
|
|
29
30
|
primary_account: void 0,
|
|
30
31
|
primary_account_guid: a
|
|
@@ -32,8 +33,8 @@ var k = (i, o) => ({
|
|
|
32
33
|
})] });
|
|
33
34
|
});
|
|
34
35
|
export {
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
M as CreditUtilizationBlock,
|
|
37
|
+
S as selectCreditUtilizationCopy
|
|
37
38
|
};
|
|
38
39
|
|
|
39
40
|
//# sourceMappingURL=CreditUtilizationBlock.es.js.map
|
package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/CreditUtilizationBlock.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreditUtilizationBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/CreditUtilizationBlock/CreditUtilizationBlock.tsx"],"sourcesContent":["import { useState } from 'react'\n\nimport { observer } from 'mobx-react-lite'\n\nimport { Drawer, useAccountStore, useGlobalCopyStore } from '../../../common'\nimport type { Account, GlobalCopy } from '../../../core'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { AccountDetailsBlock } from '../AccountDetailsBlock'\nimport { useRequiredCopy } from '../useRequiredCopy'\n\nimport CreditUtilizationContent, { type CreditUtilizationCard } from './CreditUtilizationContent'\nimport { readCardRows, readSummary, type CreditCardRow } from './layout'\n\nconst toCard = (row: CreditCardRow, account?: Account): CreditUtilizationCard => ({\n ...row,\n accountLoaded: account !== undefined,\n institutionGuid: account?.institution_guid ?? '',\n})\n\nexport const selectCreditUtilizationCopy = (copy: GlobalCopy) =>\n copy.insights_feed?.credit_utilization\n\nexport const CreditUtilizationBlock = observer(function CreditUtilizationBlock({\n beat,\n}: ActionBlockProps) {\n const [tappedAccountGuid, setTappedAccountGuid] = useState<string | null>(null)\n const { accounts: accountsCopy } = useGlobalCopyStore()\n const { accounts } = useAccountStore()\n const copy = useRequiredCopy(selectCreditUtilizationCopy)\n\n const data = beat.insights_payload?.instance_slot_data\n const accountByGuid = new Map(accounts.map((account) => [account.guid, account]))\n const cards = readCardRows(data?.data_series).map((row) =>\n toCard(row, accountByGuid.get(row.guid)),\n )\n\n return (\n <>\n <CreditUtilizationContent\n accountDetailsLabel={accountsCopy?.account_details}\n cards={cards}\n copy={copy}\n onCardClick={({ guid }) => setTappedAccountGuid(guid)}\n summary={readSummary(data)}\n />\n <Drawer\n ariaLabelClose={accountsCopy?.close_account_details_aria}\n isOpen={tappedAccountGuid !== null}\n onClose={() => setTappedAccountGuid(null)}\n title={accountsCopy?.account_details}\n >\n {tappedAccountGuid && (\n <AccountDetailsBlock\n beat={{ ...beat, primary_account: undefined, primary_account_guid: tappedAccountGuid }}\n />\n )}\n </Drawer>\n </>\n )\n})\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"CreditUtilizationBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/CreditUtilizationBlock/CreditUtilizationBlock.tsx"],"sourcesContent":["import { useState } from 'react'\n\nimport { observer } from 'mobx-react-lite'\n\nimport { Drawer, useAccountStore, useGlobalCopyStore } from '../../../common'\nimport type { Account, GlobalCopy } from '../../../core'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { AccountDetailsBlock } from '../AccountDetailsBlock'\nimport { useOpenedCta } from '../useOpenedCta'\nimport { useRequiredCopy } from '../useRequiredCopy'\n\nimport CreditUtilizationContent, { type CreditUtilizationCard } from './CreditUtilizationContent'\nimport { readCardRows, readDrawerFacts, readSummary, type CreditCardRow } from './layout'\n\nconst toCard = (row: CreditCardRow, account?: Account): CreditUtilizationCard => ({\n ...row,\n accountLoaded: account !== undefined,\n institutionGuid: account?.institution_guid ?? '',\n})\n\nexport const selectCreditUtilizationCopy = (copy: GlobalCopy) =>\n copy.insights_feed?.credit_utilization\n\nexport const CreditUtilizationBlock = observer(function CreditUtilizationBlock({\n beat,\n}: ActionBlockProps) {\n const [tappedAccountGuid, setTappedAccountGuid] = useState<string | null>(null)\n const { accounts: accountsCopy } = useGlobalCopyStore()\n const { accounts } = useAccountStore()\n const copy = useRequiredCopy(selectCreditUtilizationCopy)\n\n const data = readDrawerFacts(useOpenedCta(beat), beat.insights_payload?.instance_slot_data)\n const accountByGuid = new Map(accounts.map((account) => [account.guid, account]))\n const cards = readCardRows(data?.data_series).map((row) =>\n toCard(row, accountByGuid.get(row.guid)),\n )\n\n return (\n <>\n <CreditUtilizationContent\n accountDetailsLabel={accountsCopy?.account_details}\n cards={cards}\n copy={copy}\n onCardClick={({ guid }) => setTappedAccountGuid(guid)}\n summary={readSummary(data)}\n />\n <Drawer\n ariaLabelClose={accountsCopy?.close_account_details_aria}\n isOpen={tappedAccountGuid !== null}\n onClose={() => setTappedAccountGuid(null)}\n title={accountsCopy?.account_details}\n >\n {tappedAccountGuid && (\n <AccountDetailsBlock\n beat={{ ...beat, primary_account: undefined, primary_account_guid: tappedAccountGuid }}\n />\n )}\n </Drawer>\n </>\n )\n})\n"],"mappings":";;;;;;;;;;AAcA,IAAM,IAAA,CAAU,GAAoB,OAA8C;AAAA,EAChF,GAAG;AAAA,EACH,eAAe,MAAY;AAAA,EAC3B,iBAAiB,GAAS,oBAAoB;AAChD,IAEa,IAAA,CAA+B,MAC1C,EAAK,eAAe,oBAET,IAAyB,EAAS,SAAgC,EAC7E,MAAA,EAAA,GACmB;AACnB,QAAM,CAAC,GAAmB,CAAA,IAAwB,EAAwB,IAAI,GACxE,EAAE,UAAU,EAAA,IAAiB,EAAmB,GAChD,EAAE,UAAA,EAAA,IAAa,EAAgB,GAC/B,IAAO,EAAgB,CAA2B,GAElD,IAAO,EAAgB,EAAa,CAAI,GAAG,EAAK,kBAAkB,kBAAkB,GACpF,IAAgB,IAAI,IAAI,EAAS,IAAA,CAAK,MAAY,CAAC,EAAQ,MAAM,CAAO,CAAC,CAAC,GAC1E,IAAQ,EAAa,GAAM,WAAW,EAAE,IAAA,CAAK,MACjD,EAAO,GAAK,EAAc,IAAI,EAAI,IAAI,CAAC,CACzC;AAEA,SACE,gBAAA,EAAA,GAAA,EAAA,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,IACE,qBAAqB,GAAc;AAAA,IAC5B,OAAA;AAAA,IACD,MAAA;AAAA,IACN,aAAA,CAAc,EAAE,MAAA,EAAA,MAAW,EAAqB,CAAI;AAAA,IACpD,SAAS,EAAY,CAAI;AAAA,EAC1B,CAAA,GACD,gBAAA,EAAC,GAAD;AAAA,IACE,gBAAgB,GAAc;AAAA,IAC9B,QAAQ,MAAsB;AAAA,IAC9B,SAAA,MAAe,EAAqB,IAAI;AAAA,IACxC,OAAO,GAAc;AAAA,IAEpB,UAAA,KACC,gBAAA,EAAC,GAAD,EACE,MAAM;AAAA,MAAE,GAAG;AAAA,MAAM,iBAAiB;AAAA,MAAW,sBAAsB;AAAA,IAAkB,EACtF,CAAA;AAAA,EAEG,CAAA,CACR,EAAA,CAAA;AAEN,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Theme } from '@mui/material/styles';
|
|
2
|
-
import { DataSeries } from '../../../core';
|
|
2
|
+
import { DataSeries, DrilldownData } from '../../../core';
|
|
3
3
|
import { InsightsInstanceSlotData } from '../../../core/types/InsightsInstanceSlotData';
|
|
4
4
|
export type UtilizationBand = 'excellent' | 'good' | 'fair' | 'needs_work';
|
|
5
5
|
export interface UtilizationBandSpec {
|
|
@@ -29,6 +29,10 @@ export interface CreditCardRow {
|
|
|
29
29
|
limit: number | null;
|
|
30
30
|
percentage: number | null;
|
|
31
31
|
}
|
|
32
|
+
/** The drawer's facts: the opening CTA's `drilldown_data` (Insights 2.0), else the legacy `instance_slot_data`. */
|
|
33
|
+
export declare const readDrawerFacts: (cta: {
|
|
34
|
+
drilldown_data?: DrilldownData;
|
|
35
|
+
} | undefined, legacy?: InsightsInstanceSlotData) => InsightsInstanceSlotData | undefined;
|
|
32
36
|
export declare const readSummary: (data?: InsightsInstanceSlotData) => CreditUtilizationSummary | undefined;
|
|
33
37
|
/** One object per `data` row, keyed by `names` (pulse's `buildDataSeries`). */
|
|
34
38
|
export declare const readCardRows: (series?: DataSeries | unknown[]) => CreditCardRow[];
|
|
@@ -1,70 +1,74 @@
|
|
|
1
|
-
import { asNumber as
|
|
2
|
-
var
|
|
1
|
+
import { asNumber as c } from "../../blocks/slotReaders.es.js";
|
|
2
|
+
var m = {
|
|
3
3
|
band: "needs_work",
|
|
4
4
|
range: ">30%",
|
|
5
5
|
maxPercent: 1 / 0,
|
|
6
|
-
color: (
|
|
7
|
-
},
|
|
6
|
+
color: (a) => a.palette.error.main
|
|
7
|
+
}, i = [
|
|
8
8
|
{
|
|
9
9
|
band: "excellent",
|
|
10
10
|
range: "0-10%",
|
|
11
11
|
maxPercent: 10,
|
|
12
|
-
color: (
|
|
12
|
+
color: (a) => a.palette.success.dark
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
15
|
band: "good",
|
|
16
16
|
range: "11-20%",
|
|
17
17
|
maxPercent: 20,
|
|
18
|
-
color: (
|
|
18
|
+
color: (a) => a.palette.success.main
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
band: "fair",
|
|
22
22
|
range: "21-30%",
|
|
23
23
|
maxPercent: 30,
|
|
24
|
-
color: (
|
|
24
|
+
color: (a) => a.palette.warning.main
|
|
25
25
|
},
|
|
26
|
-
|
|
27
|
-
], l = (
|
|
28
|
-
const
|
|
29
|
-
return
|
|
30
|
-
},
|
|
31
|
-
const t =
|
|
32
|
-
|
|
26
|
+
m
|
|
27
|
+
], l = (a) => Math.min(100, Math.max(0, Math.round(a))), p = (a) => i.find(({ maxPercent: n }) => l(a) <= n) ?? m, v = (a) => {
|
|
28
|
+
const n = l(a), t = 100 / i.length, e = i.findIndex(({ maxPercent: d }) => n <= d), r = e === 0 ? 0 : i[e - 1].maxPercent, o = Math.min(i[e].maxPercent, 100);
|
|
29
|
+
return t * (e + (n - r) / (o - r));
|
|
30
|
+
}, _ = (a, n) => {
|
|
31
|
+
const t = a?.drilldown_data;
|
|
32
|
+
return t !== void 0 && ["accounts_balance_sum", "data_series"].some((e) => t[e] != null) ? t : n;
|
|
33
|
+
}, b = (a) => {
|
|
34
|
+
const n = c(a?.accounts_balance_sum), t = c(a?.accounts_credit_limit_sum), e = c(a?.credit_utilization_percentage);
|
|
35
|
+
if (!(n === void 0 || t === void 0 || e === void 0))
|
|
33
36
|
return {
|
|
34
|
-
balance:
|
|
35
|
-
limit:
|
|
36
|
-
percentage: l(
|
|
37
|
+
balance: n,
|
|
38
|
+
limit: t,
|
|
39
|
+
percentage: l(e)
|
|
37
40
|
};
|
|
38
|
-
},
|
|
39
|
-
if (!
|
|
40
|
-
const { names:
|
|
41
|
-
return
|
|
42
|
-
const
|
|
43
|
-
if (typeof
|
|
44
|
-
const r =
|
|
41
|
+
}, f = (a) => {
|
|
42
|
+
if (!a || Array.isArray(a) || !a.names || !Array.isArray(a.data)) return [];
|
|
43
|
+
const { names: n } = a;
|
|
44
|
+
return a.data.flatMap((t) => {
|
|
45
|
+
const e = Object.fromEntries(n.map((u, s) => [u, t[s]]));
|
|
46
|
+
if (typeof e.guid != "string" || typeof e.label != "string") return [];
|
|
47
|
+
const r = c(e.amount) ?? 0, o = c(e.total_amount);
|
|
45
48
|
if (o === void 0 || o <= 0) return [{
|
|
46
49
|
amount: r,
|
|
47
|
-
guid:
|
|
48
|
-
label:
|
|
50
|
+
guid: e.guid,
|
|
51
|
+
label: e.label,
|
|
49
52
|
limit: null,
|
|
50
53
|
percentage: null
|
|
51
54
|
}];
|
|
52
|
-
const
|
|
55
|
+
const d = c(e.percentage) ?? r / o * 100;
|
|
53
56
|
return [{
|
|
54
57
|
amount: r,
|
|
55
|
-
guid:
|
|
56
|
-
label:
|
|
58
|
+
guid: e.guid,
|
|
59
|
+
label: e.label,
|
|
57
60
|
limit: o,
|
|
58
|
-
percentage: l(
|
|
61
|
+
percentage: l(d)
|
|
59
62
|
}];
|
|
60
63
|
});
|
|
61
64
|
};
|
|
62
65
|
export {
|
|
63
|
-
|
|
64
|
-
|
|
66
|
+
i as UTILIZATION_BANDS,
|
|
67
|
+
v as getLegendPosition,
|
|
65
68
|
p as getUtilizationBand,
|
|
66
69
|
l as normalizePercent,
|
|
67
|
-
|
|
70
|
+
f as readCardRows,
|
|
71
|
+
_ as readDrawerFacts,
|
|
68
72
|
b as readSummary
|
|
69
73
|
};
|
|
70
74
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/CreditUtilizationBlock/layout.ts"],"sourcesContent":["import type { Theme } from '@mui/material/styles'\n\nimport type { DataSeries } from '../../../core'\nimport type { InsightsInstanceSlotData } from '../../../core/types/InsightsInstanceSlotData'\nimport { asNumber } from '../../blocks/slotReaders'\n\nexport type UtilizationBand = 'excellent' | 'good' | 'fair' | 'needs_work'\n\nexport interface UtilizationBandSpec {\n band: UtilizationBand\n range: string\n /** Highest whole percentage in the band. */\n maxPercent: number\n color: (theme: Theme) => string\n}\n\nconst NEEDS_WORK: UtilizationBandSpec = {\n band: 'needs_work',\n range: '>30%',\n maxPercent: Infinity,\n color: (theme) => theme.palette.error.main,\n}\n\n/** Ordered from best to worst, as the legend shows them. */\nexport const UTILIZATION_BANDS: UtilizationBandSpec[] = [\n {\n band: 'excellent',\n range: '0-10%',\n maxPercent: 10,\n color: (theme) => theme.palette.success.dark,\n },\n { band: 'good', range: '11-20%', maxPercent: 20, color: (theme) => theme.palette.success.main },\n { band: 'fair', range: '21-30%', maxPercent: 30, color: (theme) => theme.palette.warning.main },\n NEEDS_WORK,\n]\n\n/** Whole percent within 0-100, the only form the drawer shows, bands or announces. */\nexport const normalizePercent = (percent: number): number =>\n Math.min(100, Math.max(0, Math.round(percent)))\n\nexport const getUtilizationBand = (percent: number): UtilizationBandSpec =>\n UTILIZATION_BANDS.find(({ maxPercent }) => normalizePercent(percent) <= maxPercent) ?? NEEDS_WORK\n\nexport const RECOMMENDED_MAX_PERCENT = 30\n\nexport const getLegendPosition = (percent: number): number => {\n const value = normalizePercent(percent)\n const share = 100 / UTILIZATION_BANDS.length\n const index = UTILIZATION_BANDS.findIndex(({ maxPercent }) => value <= maxPercent)\n const from = index === 0 ? 0 : UTILIZATION_BANDS[index - 1].maxPercent\n const to = Math.min(UTILIZATION_BANDS[index].maxPercent, 100)\n\n return share * (index + (value - from) / (to - from))\n}\n\nexport interface CreditUtilizationSummary {\n balance: number\n limit: number\n percentage: number\n}\n\nexport interface CreditCardRow {\n guid: string\n label: string\n amount: number\n /** `null` when the institution did not share the card's limit. */\n limit: number | null\n percentage: number | null\n}\n\nexport const readSummary = (\n data?: InsightsInstanceSlotData,\n): CreditUtilizationSummary | undefined => {\n const balance = asNumber(data?.accounts_balance_sum)\n const limit = asNumber(data?.accounts_credit_limit_sum)\n const percentage = asNumber(data?.credit_utilization_percentage)\n\n if (balance === undefined || limit === undefined || percentage === undefined) return undefined\n\n return { balance, limit, percentage: normalizePercent(percentage) }\n}\n\n/** One object per `data` row, keyed by `names` (pulse's `buildDataSeries`). */\nexport const readCardRows = (series?: DataSeries | unknown[]): CreditCardRow[] => {\n if (!series || Array.isArray(series) || !series.names || !Array.isArray(series.data)) return []\n\n const { names } = series\n\n return series.data.flatMap((values: unknown[]): CreditCardRow[] => {\n const row = Object.fromEntries(names.map((name, index) => [name, values[index]]))\n\n if (typeof row.guid !== 'string' || typeof row.label !== 'string') return []\n\n const amount = asNumber(row.amount) ?? 0\n const limit = asNumber(row.total_amount)\n\n if (limit === undefined || limit <= 0) {\n return [{ amount, guid: row.guid, label: row.label, limit: null, percentage: null }]\n }\n\n const percentage = asNumber(row.percentage) ?? (amount / limit) * 100\n\n return [\n { amount, guid: row.guid, label: row.label, limit, percentage: normalizePercent(percentage) },\n ]\n })\n}\n"],"mappings":";AAgBA,IAAM,IAAkC;AAAA,EACtC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,OAAA,CAAQ,MAAU,EAAM,QAAQ,MAAM;AACxC,GAGa,IAA2C;AAAA,EACtD;AAAA,IACE,MAAM;AAAA,IACN,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,OAAA,CAAQ,MAAU,EAAM,QAAQ,QAAQ;AAAA,EAC1C;AAAA,EACA;AAAA,IAAE,MAAM;AAAA,IAAQ,OAAO;AAAA,IAAU,YAAY;AAAA,IAAI,OAAA,CAAQ,MAAU,EAAM,QAAQ,QAAQ;AAAA,EAAK;AAAA,EAC9F;AAAA,IAAE,MAAM;AAAA,IAAQ,OAAO;AAAA,IAAU,YAAY;AAAA,IAAI,OAAA,CAAQ,MAAU,EAAM,QAAQ,QAAQ;AAAA,EAAK;AAAA,EAC9F;AACF,GAGa,IAAA,CAAoB,MAC/B,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,KAAK,MAAM,CAAO,CAAC,CAAC,GAEnC,IAAA,CAAsB,MACjC,EAAkB,KAAA,CAAM,EAAE,YAAA,EAAA,MAAiB,EAAiB,CAAO,KAAK,CAAU,KAAK,GAI5E,IAAA,CAAqB,MAA4B;AAC5D,QAAM,IAAQ,EAAiB,CAAO,GAChC,IAAQ,MAAM,EAAkB,QAChC,IAAQ,EAAkB,UAAA,CAAW,EAAE,YAAA,EAAA,MAAiB,KAAS,CAAU,GAC3E,IAAO,MAAU,IAAI,IAAI,EAAkB,IAAQ,CAAA,EAAG,YACtD,IAAK,KAAK,IAAI,EAAkB,CAAA,EAAO,YAAY,GAAG;AAE5D,SAAO,KAAS,KAAS,IAAQ,MAAS,IAAK;AACjD,
|
|
1
|
+
{"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/CreditUtilizationBlock/layout.ts"],"sourcesContent":["import type { Theme } from '@mui/material/styles'\n\nimport type { DataSeries, DrilldownData } from '../../../core'\nimport type { InsightsInstanceSlotData } from '../../../core/types/InsightsInstanceSlotData'\nimport { asNumber } from '../../blocks/slotReaders'\n\nexport type UtilizationBand = 'excellent' | 'good' | 'fair' | 'needs_work'\n\nexport interface UtilizationBandSpec {\n band: UtilizationBand\n range: string\n /** Highest whole percentage in the band. */\n maxPercent: number\n color: (theme: Theme) => string\n}\n\nconst NEEDS_WORK: UtilizationBandSpec = {\n band: 'needs_work',\n range: '>30%',\n maxPercent: Infinity,\n color: (theme) => theme.palette.error.main,\n}\n\n/** Ordered from best to worst, as the legend shows them. */\nexport const UTILIZATION_BANDS: UtilizationBandSpec[] = [\n {\n band: 'excellent',\n range: '0-10%',\n maxPercent: 10,\n color: (theme) => theme.palette.success.dark,\n },\n { band: 'good', range: '11-20%', maxPercent: 20, color: (theme) => theme.palette.success.main },\n { band: 'fair', range: '21-30%', maxPercent: 30, color: (theme) => theme.palette.warning.main },\n NEEDS_WORK,\n]\n\n/** Whole percent within 0-100, the only form the drawer shows, bands or announces. */\nexport const normalizePercent = (percent: number): number =>\n Math.min(100, Math.max(0, Math.round(percent)))\n\nexport const getUtilizationBand = (percent: number): UtilizationBandSpec =>\n UTILIZATION_BANDS.find(({ maxPercent }) => normalizePercent(percent) <= maxPercent) ?? NEEDS_WORK\n\nexport const RECOMMENDED_MAX_PERCENT = 30\n\nexport const getLegendPosition = (percent: number): number => {\n const value = normalizePercent(percent)\n const share = 100 / UTILIZATION_BANDS.length\n const index = UTILIZATION_BANDS.findIndex(({ maxPercent }) => value <= maxPercent)\n const from = index === 0 ? 0 : UTILIZATION_BANDS[index - 1].maxPercent\n const to = Math.min(UTILIZATION_BANDS[index].maxPercent, 100)\n\n return share * (index + (value - from) / (to - from))\n}\n\nexport interface CreditUtilizationSummary {\n balance: number\n limit: number\n percentage: number\n}\n\nexport interface CreditCardRow {\n guid: string\n label: string\n amount: number\n /** `null` when the institution did not share the card's limit. */\n limit: number | null\n percentage: number | null\n}\n\n/** The drawer's facts: the opening CTA's `drilldown_data` (Insights 2.0), else the legacy `instance_slot_data`. */\nexport const readDrawerFacts = (\n cta: { drilldown_data?: DrilldownData } | undefined,\n legacy?: InsightsInstanceSlotData,\n): InsightsInstanceSlotData | undefined => {\n const drilldown = cta?.drilldown_data\n const hasFacts =\n drilldown !== undefined &&\n ['accounts_balance_sum', 'data_series'].some((key) => drilldown[key] != null)\n\n return hasFacts ? (drilldown as InsightsInstanceSlotData) : legacy\n}\n\nexport const readSummary = (\n data?: InsightsInstanceSlotData,\n): CreditUtilizationSummary | undefined => {\n const balance = asNumber(data?.accounts_balance_sum)\n const limit = asNumber(data?.accounts_credit_limit_sum)\n const percentage = asNumber(data?.credit_utilization_percentage)\n\n if (balance === undefined || limit === undefined || percentage === undefined) return undefined\n\n return { balance, limit, percentage: normalizePercent(percentage) }\n}\n\n/** One object per `data` row, keyed by `names` (pulse's `buildDataSeries`). */\nexport const readCardRows = (series?: DataSeries | unknown[]): CreditCardRow[] => {\n if (!series || Array.isArray(series) || !series.names || !Array.isArray(series.data)) return []\n\n const { names } = series\n\n return series.data.flatMap((values: unknown[]): CreditCardRow[] => {\n const row = Object.fromEntries(names.map((name, index) => [name, values[index]]))\n\n if (typeof row.guid !== 'string' || typeof row.label !== 'string') return []\n\n const amount = asNumber(row.amount) ?? 0\n const limit = asNumber(row.total_amount)\n\n if (limit === undefined || limit <= 0) {\n return [{ amount, guid: row.guid, label: row.label, limit: null, percentage: null }]\n }\n\n const percentage = asNumber(row.percentage) ?? (amount / limit) * 100\n\n return [\n { amount, guid: row.guid, label: row.label, limit, percentage: normalizePercent(percentage) },\n ]\n })\n}\n"],"mappings":";AAgBA,IAAM,IAAkC;AAAA,EACtC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,OAAA,CAAQ,MAAU,EAAM,QAAQ,MAAM;AACxC,GAGa,IAA2C;AAAA,EACtD;AAAA,IACE,MAAM;AAAA,IACN,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,OAAA,CAAQ,MAAU,EAAM,QAAQ,QAAQ;AAAA,EAC1C;AAAA,EACA;AAAA,IAAE,MAAM;AAAA,IAAQ,OAAO;AAAA,IAAU,YAAY;AAAA,IAAI,OAAA,CAAQ,MAAU,EAAM,QAAQ,QAAQ;AAAA,EAAK;AAAA,EAC9F;AAAA,IAAE,MAAM;AAAA,IAAQ,OAAO;AAAA,IAAU,YAAY;AAAA,IAAI,OAAA,CAAQ,MAAU,EAAM,QAAQ,QAAQ;AAAA,EAAK;AAAA,EAC9F;AACF,GAGa,IAAA,CAAoB,MAC/B,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,KAAK,MAAM,CAAO,CAAC,CAAC,GAEnC,IAAA,CAAsB,MACjC,EAAkB,KAAA,CAAM,EAAE,YAAA,EAAA,MAAiB,EAAiB,CAAO,KAAK,CAAU,KAAK,GAI5E,IAAA,CAAqB,MAA4B;AAC5D,QAAM,IAAQ,EAAiB,CAAO,GAChC,IAAQ,MAAM,EAAkB,QAChC,IAAQ,EAAkB,UAAA,CAAW,EAAE,YAAA,EAAA,MAAiB,KAAS,CAAU,GAC3E,IAAO,MAAU,IAAI,IAAI,EAAkB,IAAQ,CAAA,EAAG,YACtD,IAAK,KAAK,IAAI,EAAkB,CAAA,EAAO,YAAY,GAAG;AAE5D,SAAO,KAAS,KAAS,IAAQ,MAAS,IAAK;AACjD,GAkBa,IAAA,CACX,GACA,MACyC;AACzC,QAAM,IAAY,GAAK;AAKvB,SAHE,MAAc,UACd,CAAC,wBAAwB,aAAa,EAAE,KAAA,CAAM,MAAQ,EAAU,CAAA,KAAQ,IAAI,IAE3D,IAAyC;AAC9D,GAEa,IAAA,CACX,MACyC;AACzC,QAAM,IAAU,EAAS,GAAM,oBAAoB,GAC7C,IAAQ,EAAS,GAAM,yBAAyB,GAChD,IAAa,EAAS,GAAM,6BAA6B;AAE/D,MAAI,EAAA,MAAY,UAAa,MAAU,UAAa,MAAe;AAEnE,WAAO;AAAA,MAAE,SAAA;AAAA,MAAS,OAAA;AAAA,MAAO,YAAY,EAAiB,CAAU;AAAA,IAAE;AACpE,GAGa,IAAA,CAAgB,MAAqD;AAChF,MAAI,CAAC,KAAU,MAAM,QAAQ,CAAM,KAAK,CAAC,EAAO,SAAS,CAAC,MAAM,QAAQ,EAAO,IAAI,EAAG,QAAO,CAAC;AAE9F,QAAM,EAAE,OAAA,EAAA,IAAU;AAElB,SAAO,EAAO,KAAK,QAAA,CAAS,MAAuC;AACjE,UAAM,IAAM,OAAO,YAAY,EAAM,IAAA,CAAK,GAAM,MAAU,CAAC,GAAM,EAAO,CAAA,CAAM,CAAC,CAAC;AAEhF,QAAI,OAAO,EAAI,QAAS,YAAY,OAAO,EAAI,SAAU,SAAU,QAAO,CAAC;AAE3E,UAAM,IAAS,EAAS,EAAI,MAAM,KAAK,GACjC,IAAQ,EAAS,EAAI,YAAY;AAEvC,QAAI,MAAU,UAAa,KAAS,EAClC,QAAO,CAAC;AAAA,MAAE,QAAA;AAAA,MAAQ,MAAM,EAAI;AAAA,MAAM,OAAO,EAAI;AAAA,MAAO,OAAO;AAAA,MAAM,YAAY;AAAA,IAAK,CAAC;AAGrF,UAAM,IAAa,EAAS,EAAI,UAAU,KAAM,IAAS,IAAS;AAElE,WAAO,CACL;AAAA,MAAE,QAAA;AAAA,MAAQ,MAAM,EAAI;AAAA,MAAM,OAAO,EAAI;AAAA,MAAO,OAAA;AAAA,MAAO,YAAY,EAAiB,CAAU;AAAA,IAAE,CAC9F;AAAA,EACF,CAAC;AACH"}
|
|
@@ -4,6 +4,8 @@ export declare const donutChartVariant: {
|
|
|
4
4
|
readonly DepositSummary: "deposit_summary";
|
|
5
5
|
/** Credit Card Close to Limit; the embedded card's small donut reuses it. */
|
|
6
6
|
readonly CreditLimit: "credit_limit";
|
|
7
|
+
/** Credit Utilization: the arc coloured by the utilization in the centre. */
|
|
8
|
+
readonly CreditUtilization: "credit_utilization";
|
|
7
9
|
};
|
|
8
10
|
export type DonutChartVariant = (typeof donutChartVariant)[keyof typeof donutChartVariant];
|
|
9
11
|
/** `remainderOfTotal`: the second arc is what is left of the second legend value after the first. */
|
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
var
|
|
1
|
+
var i = {
|
|
2
2
|
DepositSummary: "deposit_summary",
|
|
3
|
-
CreditLimit: "credit_limit"
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
CreditLimit: "credit_limit",
|
|
4
|
+
CreditUtilization: "credit_utilization"
|
|
5
|
+
}, e = (t) => {
|
|
6
|
+
const o = { colors: [t.palette.success.main, t.palette.success.light] }, r = [t.palette.warning.main, t.palette.divider], a = {
|
|
7
|
+
dynamicPrimary: "creditUtilization",
|
|
8
|
+
secondaryColor: t.palette.divider
|
|
9
|
+
};
|
|
6
10
|
return {
|
|
7
|
-
[
|
|
8
|
-
[
|
|
9
|
-
colors:
|
|
11
|
+
[i.DepositSummary]: o,
|
|
12
|
+
[i.CreditLimit]: {
|
|
13
|
+
colors: r,
|
|
10
14
|
arcs: "remainderOfTotal"
|
|
11
15
|
},
|
|
16
|
+
[i.CreditUtilization]: a,
|
|
12
17
|
CostOfLivingToIncome: { secondaryColor: t.palette.divider },
|
|
13
|
-
MonthlyDepositSummaryV2:
|
|
18
|
+
MonthlyDepositSummaryV2: o,
|
|
14
19
|
MonthlyNonEssentialCategorySummaryV2: { colors: [t.palette.chartMono.chartMono3 ?? t.palette.text.primary, t.palette.chartMono.chartMono5 ?? t.palette.divider] },
|
|
15
|
-
CreditCardCloseToLimit: { colors:
|
|
16
|
-
CreditUtilization:
|
|
17
|
-
dynamicPrimary: "creditUtilization",
|
|
18
|
-
secondaryColor: t.palette.divider
|
|
19
|
-
}
|
|
20
|
+
CreditCardCloseToLimit: { colors: r },
|
|
21
|
+
CreditUtilization: a
|
|
20
22
|
};
|
|
21
23
|
};
|
|
22
24
|
export {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
i as donutChartVariant,
|
|
26
|
+
e as getLayoutConfig
|
|
25
27
|
};
|
|
26
28
|
|
|
27
29
|
//# sourceMappingURL=layout.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/DonutChartBlock/layout.ts"],"sourcesContent":["import { type Theme } from '@mui/material/styles'\n\n/** Ditto's `donut_chart_block` variants; the template-name keys below are V1 aliases. */\nexport const donutChartVariant = {\n DepositSummary: 'deposit_summary',\n /** Credit Card Close to Limit; the embedded card's small donut reuses it. */\n CreditLimit: 'credit_limit',\n} as const\n\nexport type DonutChartVariant = (typeof donutChartVariant)[keyof typeof donutChartVariant]\n\n/** `remainderOfTotal`: the second arc is what is left of the second legend value after the first. */\ntype DonutArcs = { arcs?: 'remainderOfTotal' }\n\nexport type DonutChartLayoutConfig = DonutArcs &\n (\n | { colors: [string, string] }\n | { secondaryColor: string }\n | { dynamicPrimary: 'creditUtilization'; secondaryColor: string }\n )\n\nexport const getLayoutConfig = (theme: Theme): Record<string, DonutChartLayoutConfig> => {\n const depositSummary: DonutChartLayoutConfig = {\n colors: [theme.palette.success.main, theme.palette.success.light],\n }\n\n const creditLimitColors: [string, string] = [theme.palette.warning.main, theme.palette.divider]\n\n return {\n [donutChartVariant.DepositSummary]: depositSummary,\n // Spending and the rest of the limit, while the legend shows the full limit (pulse Chart.js).\n [donutChartVariant.CreditLimit]: { colors: creditLimitColors, arcs: 'remainderOfTotal' },\n\n // V1 aliases: the template name as the variant.\n CostOfLivingToIncome: {\n secondaryColor: theme.palette.divider,\n },\n MonthlyDepositSummaryV2: depositSummary,\n MonthlyNonEssentialCategorySummaryV2: {\n colors: [\n theme.palette.chartMono.chartMono3 ?? theme.palette.text.primary,\n theme.palette.chartMono.chartMono5 ?? theme.palette.divider,\n ],\n },\n CreditCardCloseToLimit: { colors: creditLimitColors },\n CreditUtilization:
|
|
1
|
+
{"version":3,"file":"layout.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/DonutChartBlock/layout.ts"],"sourcesContent":["import { type Theme } from '@mui/material/styles'\n\n/** Ditto's `donut_chart_block` variants; the template-name keys below are V1 aliases. */\nexport const donutChartVariant = {\n DepositSummary: 'deposit_summary',\n /** Credit Card Close to Limit; the embedded card's small donut reuses it. */\n CreditLimit: 'credit_limit',\n /** Credit Utilization: the arc coloured by the utilization in the centre. */\n CreditUtilization: 'credit_utilization',\n} as const\n\nexport type DonutChartVariant = (typeof donutChartVariant)[keyof typeof donutChartVariant]\n\n/** `remainderOfTotal`: the second arc is what is left of the second legend value after the first. */\ntype DonutArcs = { arcs?: 'remainderOfTotal' }\n\nexport type DonutChartLayoutConfig = DonutArcs &\n (\n | { colors: [string, string] }\n | { secondaryColor: string }\n | { dynamicPrimary: 'creditUtilization'; secondaryColor: string }\n )\n\nexport const getLayoutConfig = (theme: Theme): Record<string, DonutChartLayoutConfig> => {\n const depositSummary: DonutChartLayoutConfig = {\n colors: [theme.palette.success.main, theme.palette.success.light],\n }\n\n const creditLimitColors: [string, string] = [theme.palette.warning.main, theme.palette.divider]\n const creditUtilization: DonutChartLayoutConfig = {\n dynamicPrimary: 'creditUtilization',\n secondaryColor: theme.palette.divider,\n }\n\n return {\n [donutChartVariant.DepositSummary]: depositSummary,\n // Spending and the rest of the limit, while the legend shows the full limit (pulse Chart.js).\n [donutChartVariant.CreditLimit]: { colors: creditLimitColors, arcs: 'remainderOfTotal' },\n [donutChartVariant.CreditUtilization]: creditUtilization,\n\n // V1 aliases: the template name as the variant.\n CostOfLivingToIncome: {\n secondaryColor: theme.palette.divider,\n },\n MonthlyDepositSummaryV2: depositSummary,\n MonthlyNonEssentialCategorySummaryV2: {\n colors: [\n theme.palette.chartMono.chartMono3 ?? theme.palette.text.primary,\n theme.palette.chartMono.chartMono5 ?? theme.palette.divider,\n ],\n },\n CreditCardCloseToLimit: { colors: creditLimitColors },\n CreditUtilization: creditUtilization,\n }\n}\n"],"mappings":"AAGA,IAAa,IAAoB;AAAA,EAC/B,gBAAgB;AAAA,EAEhB,aAAa;AAAA,EAEb,mBAAmB;AACrB,GAca,IAAA,CAAmB,MAAyD;AACvF,QAAM,IAAyC,EAC7C,QAAQ,CAAC,EAAM,QAAQ,QAAQ,MAAM,EAAM,QAAQ,QAAQ,KAAK,EAClE,GAEM,IAAsC,CAAC,EAAM,QAAQ,QAAQ,MAAM,EAAM,QAAQ,OAAO,GACxF,IAA4C;AAAA,IAChD,gBAAgB;AAAA,IAChB,gBAAgB,EAAM,QAAQ;AAAA,EAChC;AAEA,SAAO;AAAA,IACJ,CAAA,EAAkB,cAAA,GAAiB;AAAA,IAEnC,CAAA,EAAkB,WAAA,GAAc;AAAA,MAAE,QAAQ;AAAA,MAAmB,MAAM;AAAA,IAAmB;AAAA,IACtF,CAAA,EAAkB,iBAAA,GAAoB;AAAA,IAGvC,sBAAsB,EACpB,gBAAgB,EAAM,QAAQ,QAChC;AAAA,IACA,yBAAyB;AAAA,IACzB,sCAAsC,EACpC,QAAQ,CACN,EAAM,QAAQ,UAAU,cAAc,EAAM,QAAQ,KAAK,SACzD,EAAM,QAAQ,UAAU,cAAc,EAAM,QAAQ,OACtD,EACF;AAAA,IACA,wBAAwB,EAAE,QAAQ,EAAkB;AAAA,IACpD,mBAAmB;AAAA,EACrB;AACF"}
|