@mx-cartographer/experiences 9.7.25 → 9.7.27
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 +8 -0
- package/dist/common/components/MiniWidgetContainer.es.js +35 -45
- package/dist/common/components/MiniWidgetContainer.es.js.map +1 -1
- package/dist/common/components/charts/LineChart.es.js +86 -85
- package/dist/common/components/charts/LineChart.es.js.map +1 -1
- package/dist/common/constants/Styles.d.ts +2 -0
- package/dist/common/constants/Styles.es.js +17 -0
- package/dist/common/constants/Styles.es.js.map +1 -0
- package/dist/common/constants/index.d.ts +1 -0
- package/dist/common/hooks/useAriaLive.es.js +12 -22
- package/dist/common/hooks/useAriaLive.es.js.map +1 -1
- package/dist/common/index.es.js +111 -109
- package/dist/core/stores/TrendsStore.d.ts +5 -0
- package/dist/core/types/Insights.d.ts +3 -0
- package/dist/core/types/Insights.es.js.map +1 -1
- package/dist/core/types/localization/InsightsFeedCopy.d.ts +2 -0
- package/dist/core/utils/DateUtil.d.ts +2 -0
- package/dist/core/utils/DateUtil.es.js +37 -35
- package/dist/core/utils/DateUtil.es.js.map +1 -1
- package/dist/core/utils/NumberFormatting.d.ts +1 -0
- package/dist/core/utils/NumberFormatting.es.js +14 -13
- package/dist/core/utils/NumberFormatting.es.js.map +1 -1
- package/dist/core/utils/TrendsUtil.d.ts +5 -0
- package/dist/core/utils/TrendsUtil.es.js +67 -59
- package/dist/core/utils/TrendsUtil.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/NoSpendDaysBlock/NoSpendDaysBlock.d.ts +3 -0
- package/dist/insights-v2/blocks/ComponentBlocks/NoSpendDaysBlock/NoSpendDaysBlock.es.js +101 -0
- package/dist/insights-v2/blocks/ComponentBlocks/NoSpendDaysBlock/NoSpendDaysBlock.es.js.map +1 -0
- package/dist/insights-v2/blocks/ComponentBlocks/NoSpendDaysBlock/NoSpendGraphic.d.ts +5 -0
- package/dist/insights-v2/blocks/ComponentBlocks/NoSpendDaysBlock/NoSpendGraphic.es.js +108 -0
- package/dist/insights-v2/blocks/ComponentBlocks/NoSpendDaysBlock/NoSpendGraphic.es.js.map +1 -0
- package/dist/insights-v2/blocks/ComponentBlocks/NoSpendDaysBlock/index.d.ts +1 -0
- package/dist/insights-v2/blocks/ComponentBlocks/index.d.ts +1 -0
- package/dist/insights-v2/index.es.js +87 -85
- package/dist/insights-v2/mappings/blocks.es.js +44 -42
- package/dist/insights-v2/mappings/blocks.es.js.map +1 -1
- package/dist/transactions/components/shared/TransactionList.d.ts +4 -0
- package/dist/transactions/components/shared/TransactionList.es.js +138 -84
- package/dist/transactions/components/shared/TransactionList.es.js.map +1 -1
- package/dist/trends/components/CategoryDetailChart.d.ts +2 -1
- package/dist/trends/components/CategoryDetailChart.es.js +55 -35
- package/dist/trends/components/CategoryDetailChart.es.js.map +1 -1
- package/dist/trends/components/CategoryDetails.es.js +68 -71
- package/dist/trends/components/CategoryDetails.es.js.map +1 -1
- package/dist/trends/utils/TrendsTable.es.js +25 -25
- package/dist/trends/utils/TrendsTable.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { RoundingFunction } from 'numeral';
|
|
2
2
|
import { CurrencyCodes } from '../constants/Numbers';
|
|
3
3
|
export declare const generateEqualIntervals: (minValue: number, maxValue: number, tickCount: number) => number[];
|
|
4
|
+
export declare const roundedAverage: (values: number[]) => number;
|
|
4
5
|
export declare const formatCurrency: (amount: number | undefined, formatting: string, roundingFunction?: RoundingFunction) => string;
|
|
5
6
|
export declare const getCurrencyCodes: () => CurrencyCodes;
|
|
6
7
|
export declare const isValidNumber: (value: any) => boolean;
|
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
import { getLocale as a } from "./Localization.es.js";
|
|
2
2
|
import { CurrencyCodes as l } from "../constants/Numbers.es.js";
|
|
3
|
-
import
|
|
4
|
-
var
|
|
5
|
-
const
|
|
3
|
+
import s from "numeral";
|
|
4
|
+
var g = (r, e, t) => {
|
|
5
|
+
const n = [], c = (e - r) / (t - 1);
|
|
6
6
|
for (let o = 0; o < t; o++) {
|
|
7
|
-
const
|
|
8
|
-
|
|
7
|
+
const i = r + o * c;
|
|
8
|
+
n.push(i);
|
|
9
9
|
}
|
|
10
|
-
return
|
|
11
|
-
}, w = (r, e, t) => a() === "fr-ca" ?
|
|
10
|
+
return n[t - 1] = e, n.map(Math.round);
|
|
11
|
+
}, v = (r) => r.length ? Math.round(r.reduce((e, t) => e + t, 0) / r.length) : 0, w = (r, e, t) => a() === "fr-ca" ? s(r).format(`${e} $`, t) : s(r).format(`$${e}`, t), y = () => a() === "fr-ca" ? l.CAD : l.USD, m = (r) => r != null && r !== "" && isFinite(r), d = {
|
|
12
12
|
style: "percent",
|
|
13
13
|
minimumFractionDigits: 2,
|
|
14
14
|
maximumFractionDigits: 2
|
|
15
|
-
}, $ = (r, e =
|
|
15
|
+
}, $ = (r, e = d) => m(r) ? new Intl.NumberFormat(a(), e).format(Number(r)) : r, f = (r) => new Intl.PluralRules(a(), r), C = (r, e = { type: "ordinal" }, t = {
|
|
16
16
|
one: "st",
|
|
17
17
|
two: "nd",
|
|
18
18
|
few: "rd",
|
|
19
19
|
other: "th"
|
|
20
|
-
}) => `${r}${t[
|
|
20
|
+
}) => `${r}${t[f(e).select(r)]}`;
|
|
21
21
|
export {
|
|
22
22
|
w as formatCurrency,
|
|
23
|
-
|
|
23
|
+
C as formatOrdinal,
|
|
24
24
|
$ as formatPercentage,
|
|
25
|
-
|
|
25
|
+
g as generateEqualIntervals,
|
|
26
26
|
y as getCurrencyCodes,
|
|
27
|
-
|
|
28
|
-
m as isValidNumber
|
|
27
|
+
f as getPluralRules,
|
|
28
|
+
m as isValidNumber,
|
|
29
|
+
v as roundedAverage
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
//# sourceMappingURL=NumberFormatting.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberFormatting.es.js","names":[],"sources":["../../../src/core/utils/NumberFormatting.ts"],"sourcesContent":["import numeral from 'numeral'\nimport type { RoundingFunction } from 'numeral'\n\nimport { CurrencyCodes } from '../constants/Numbers'\nimport { getLocale } from './Localization'\n\nexport const generateEqualIntervals = (\n minValue: number,\n maxValue: number,\n tickCount: number,\n): number[] => {\n const ticks: number[] = []\n const range = maxValue - minValue\n const step = range / (tickCount - 1) // The space between each tick\n\n for (let i = 0; i < tickCount; i++) {\n const tickValue = minValue + i * step\n ticks.push(tickValue)\n }\n\n ticks[tickCount - 1] = maxValue\n\n return ticks.map(Math.round)\n}\n\n// enhances numeral's localization functionality by puting the $ in the correct place\nexport const formatCurrency = (\n amount: number | undefined,\n formatting: string,\n roundingFunction?: RoundingFunction,\n) => {\n switch (getLocale()) {\n case 'fr-ca': {\n return numeral(amount).format(`${formatting} $`, roundingFunction)\n }\n default: {\n return numeral(amount).format(`$${formatting}`, roundingFunction)\n }\n }\n}\n\nexport const getCurrencyCodes = () => {\n switch (getLocale()) {\n case 'fr-ca':\n return CurrencyCodes.CAD\n default:\n return CurrencyCodes.USD\n }\n}\n\n// will return `true` if value is a string number, like '99', which matches Serenity logic\nexport const isValidNumber = (value: any) =>\n value !== undefined && value !== null && value !== '' && isFinite(value)\n\nconst defaultPercentStyle = {\n style: 'percent',\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n} as Intl.NumberFormatOptions\n\nexport const formatPercentage = (\n amount: number | string | undefined,\n options: Intl.NumberFormatOptions = defaultPercentStyle,\n) =>\n isValidNumber(amount)\n ? new Intl.NumberFormat(getLocale(), options).format(Number(amount))\n : amount\n\nexport const getPluralRules = (options: Intl.PluralRulesOptions) =>\n new Intl.PluralRules(getLocale(), options)\n\nexport const formatOrdinal = (\n number: number,\n options: Intl.PluralRulesOptions = { type: 'ordinal' },\n copy = {\n one: 'st',\n two: 'nd',\n few: 'rd',\n other: 'th',\n } as const,\n) => {\n const rule = getPluralRules(options).select(number)\n\n return `${number}${copy[rule as keyof typeof copy]}`\n}\n"],"mappings":";;;AAMA,IAAa,IAAA,CACX,GACA,GACA,MACa;AACb,QAAM,IAAkB,CAAC,GAEnB,KADQ,IAAW,MACH,IAAY;AAElC,WAAS,IAAI,GAAG,IAAI,GAAW,KAAK;AAClC,UAAM,IAAY,IAAW,IAAI;AACjC,IAAA,EAAM,KAAK,CAAS;AAAA,EACtB;AAEA,SAAA,EAAM,IAAY,CAAA,IAAK,GAEhB,EAAM,IAAI,KAAK,KAAK;AAC7B,
|
|
1
|
+
{"version":3,"file":"NumberFormatting.es.js","names":[],"sources":["../../../src/core/utils/NumberFormatting.ts"],"sourcesContent":["import numeral from 'numeral'\nimport type { RoundingFunction } from 'numeral'\n\nimport { CurrencyCodes } from '../constants/Numbers'\nimport { getLocale } from './Localization'\n\nexport const generateEqualIntervals = (\n minValue: number,\n maxValue: number,\n tickCount: number,\n): number[] => {\n const ticks: number[] = []\n const range = maxValue - minValue\n const step = range / (tickCount - 1) // The space between each tick\n\n for (let i = 0; i < tickCount; i++) {\n const tickValue = minValue + i * step\n ticks.push(tickValue)\n }\n\n ticks[tickCount - 1] = maxValue\n\n return ticks.map(Math.round)\n}\n\nexport const roundedAverage = (values: number[]) =>\n values.length ? Math.round(values.reduce((sum, value) => sum + value, 0) / values.length) : 0\n\n// enhances numeral's localization functionality by puting the $ in the correct place\nexport const formatCurrency = (\n amount: number | undefined,\n formatting: string,\n roundingFunction?: RoundingFunction,\n) => {\n switch (getLocale()) {\n case 'fr-ca': {\n return numeral(amount).format(`${formatting} $`, roundingFunction)\n }\n default: {\n return numeral(amount).format(`$${formatting}`, roundingFunction)\n }\n }\n}\n\nexport const getCurrencyCodes = () => {\n switch (getLocale()) {\n case 'fr-ca':\n return CurrencyCodes.CAD\n default:\n return CurrencyCodes.USD\n }\n}\n\n// will return `true` if value is a string number, like '99', which matches Serenity logic\nexport const isValidNumber = (value: any) =>\n value !== undefined && value !== null && value !== '' && isFinite(value)\n\nconst defaultPercentStyle = {\n style: 'percent',\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n} as Intl.NumberFormatOptions\n\nexport const formatPercentage = (\n amount: number | string | undefined,\n options: Intl.NumberFormatOptions = defaultPercentStyle,\n) =>\n isValidNumber(amount)\n ? new Intl.NumberFormat(getLocale(), options).format(Number(amount))\n : amount\n\nexport const getPluralRules = (options: Intl.PluralRulesOptions) =>\n new Intl.PluralRules(getLocale(), options)\n\nexport const formatOrdinal = (\n number: number,\n options: Intl.PluralRulesOptions = { type: 'ordinal' },\n copy = {\n one: 'st',\n two: 'nd',\n few: 'rd',\n other: 'th',\n } as const,\n) => {\n const rule = getPluralRules(options).select(number)\n\n return `${number}${copy[rule as keyof typeof copy]}`\n}\n"],"mappings":";;;AAMA,IAAa,IAAA,CACX,GACA,GACA,MACa;AACb,QAAM,IAAkB,CAAC,GAEnB,KADQ,IAAW,MACH,IAAY;AAElC,WAAS,IAAI,GAAG,IAAI,GAAW,KAAK;AAClC,UAAM,IAAY,IAAW,IAAI;AACjC,IAAA,EAAM,KAAK,CAAS;AAAA,EACtB;AAEA,SAAA,EAAM,IAAY,CAAA,IAAK,GAEhB,EAAM,IAAI,KAAK,KAAK;AAC7B,GAEa,IAAA,CAAkB,MAC7B,EAAO,SAAS,KAAK,MAAM,EAAO,OAAA,CAAQ,GAAK,MAAU,IAAM,GAAO,CAAC,IAAI,EAAO,MAAM,IAAI,GAGjF,IAAA,CACX,GACA,GACA,MAEQ,EAAU,MACX,UACI,EAAQ,CAAM,EAAE,OAAO,GAAG,CAAA,MAAgB,CAAgB,IAG1D,EAAQ,CAAM,EAAE,OAAO,IAAI,CAAA,IAAc,CAAgB,GAKzD,IAAA,MACH,EAAU,MACX,UACI,EAAc,MAEd,EAAc,KAKd,IAAA,CAAiB,MACL,KAAU,QAAQ,MAAU,MAAM,SAAS,CAAK,GAEnE,IAAsB;AAAA,EAC1B,OAAO;AAAA,EACP,uBAAuB;AAAA,EACvB,uBAAuB;AACzB,GAEa,IAAA,CACX,GACA,IAAoC,MAEpC,EAAc,CAAM,IAChB,IAAI,KAAK,aAAa,EAAU,GAAG,CAAO,EAAE,OAAO,OAAO,CAAM,CAAC,IACjE,GAEO,IAAA,CAAkB,MAC7B,IAAI,KAAK,YAAY,EAAU,GAAG,CAAO,GAE9B,IAAA,CACX,GACA,IAAmC,EAAE,MAAM,UAAU,GACrD,IAAO;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,OAAO;AACT,MAIO,GAAG,CAAA,GAAS,EAFN,EAAe,CAAO,EAAE,OAAO,CAEpB,CAAA,CAAA"}
|
|
@@ -16,10 +16,15 @@ export declare const getStackedLineChartData: (totals: MonthlyCategoryTotals[],
|
|
|
16
16
|
export declare const amountComparator: GridComparatorFn<string | number>;
|
|
17
17
|
export declare const categoryComparator: GridComparatorFn<string>;
|
|
18
18
|
export declare const buildCategoryDetailsChartData: (data: DetailedCategoryWithTransactions | null, monthsCount: number) => {
|
|
19
|
+
average: number;
|
|
19
20
|
monthlyAmounts: {
|
|
20
21
|
x: string;
|
|
21
22
|
y: number;
|
|
22
23
|
}[];
|
|
24
|
+
monthlyTotals: {
|
|
25
|
+
label: string;
|
|
26
|
+
amount: number;
|
|
27
|
+
}[];
|
|
23
28
|
tooltipLabels: {
|
|
24
29
|
label: string;
|
|
25
30
|
amount: number;
|
|
@@ -1,72 +1,80 @@
|
|
|
1
|
-
import { CategoryColors as y, CategoryGuidToName as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
|
12
|
+
return r;
|
|
10
13
|
}
|
|
11
|
-
var
|
|
12
|
-
const
|
|
13
|
-
top_level_category_guid:
|
|
14
|
-
category_guid:
|
|
15
|
-
amount:
|
|
16
|
-
year_month:
|
|
17
|
-
}, { top_level_category_guid: n, category_guid:
|
|
18
|
-
return
|
|
19
|
-
}, {}),
|
|
20
|
-
const
|
|
21
|
-
return Object.entries(
|
|
22
|
-
const
|
|
23
|
-
const
|
|
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(
|
|
26
|
-
y:
|
|
28
|
+
x: new Date(_, h - 1),
|
|
29
|
+
y: c
|
|
27
30
|
};
|
|
28
|
-
}).sort((
|
|
31
|
+
}).sort((l, c) => l.x.getTime() - c.x.getTime());
|
|
29
32
|
return {
|
|
30
|
-
top_level_category_guid:
|
|
31
|
-
category_guid:
|
|
32
|
-
category_name:
|
|
33
|
-
category_color:
|
|
34
|
-
dataset:
|
|
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
|
-
},
|
|
38
|
-
const
|
|
39
|
-
return (
|
|
40
|
-
},
|
|
41
|
-
const
|
|
42
|
-
return
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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:
|
|
53
|
-
amount:
|
|
54
|
-
header:
|
|
55
|
-
}, ...
|
|
52
|
+
label: t.name,
|
|
53
|
+
amount: a(t.monthlyAmounts),
|
|
54
|
+
header: n
|
|
55
|
+
}, ...u].sort((s, m) => m.amount - s.amount);
|
|
56
56
|
});
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
x:
|
|
60
|
-
y: Math.abs(
|
|
61
|
-
})) :
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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,
|
|
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, 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,KAAK,CAAO,GAAG,CAAA,GAAO,CAAA,EAAQ,GACrC,EAAQ,SAAS,EAAQ,SAAS,IAAI,CAAC;AAAA,EACzC;AAEA,SAAO;AACT;AAEA,IAAM,IAAA,CAA+B,MAC5B,EAAO,OAAA,CAAQ,GAAQ,MAAS;AACrC,QAAM,IAA+B;AAAA,IACnC,yBAAyB,EAAK;AAAA,IAC9B,eAAe,EAAK;AAAA,IACpB,QAAQ,EAAK;AAAA,IACb,YAAY,EAAK;AAAA,EACnB,GAEM,EAAE,yBAAA,GAAyB,eAAA,EAAA,IAAkB;AAGnD,SAAK,EAAO,CAAA,MACV,EAAO,CAAA,IAAiB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AM,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"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { formatDate as g } from "../../../../core/constants/DateFormats.es.js";
|
|
2
|
+
import { useGlobalCopyStore as y } from "../../../../common/context/hooks.es.js";
|
|
3
|
+
import { slot as _ } from "../../../../core/types/Insights.es.js";
|
|
4
|
+
import { ConfettiOverlay as h } from "../../../components/shared/ConfettiOverlay.es.js";
|
|
5
|
+
import { parseDueDate as S } from "../RepeatingTransactionBlock/weekStrip.es.js";
|
|
6
|
+
import x from "./NoSpendGraphic.es.js";
|
|
7
|
+
import i from "@mui/material/Stack";
|
|
8
|
+
import { Text as b } from "@mxenabled/mxui";
|
|
9
|
+
import { CheckCircle as D } from "@mxenabled/mx-icons";
|
|
10
|
+
import { jsx as n, jsxs as u } from "react/jsx-runtime";
|
|
11
|
+
var k = 5, w = [
|
|
12
|
+
"sunday",
|
|
13
|
+
"monday",
|
|
14
|
+
"tuesday",
|
|
15
|
+
"wednesday",
|
|
16
|
+
"thursday",
|
|
17
|
+
"friday",
|
|
18
|
+
"saturday"
|
|
19
|
+
], N = (t) => [
|
|
20
|
+
t.getFullYear(),
|
|
21
|
+
t.getMonth() + 1,
|
|
22
|
+
t.getDate()
|
|
23
|
+
].map((r) => String(r).padStart(2, "0")).join("-"), v = (t, r) => Array.from({ length: 7 }, (l, s) => {
|
|
24
|
+
const o = new Date(t);
|
|
25
|
+
o.setDate(t.getDate() + s);
|
|
26
|
+
const a = N(o);
|
|
27
|
+
return {
|
|
28
|
+
iso: a,
|
|
29
|
+
key: w[o.getDay()],
|
|
30
|
+
label: g(o, { weekday: "short" }),
|
|
31
|
+
isNoSpend: r.includes(a)
|
|
32
|
+
};
|
|
33
|
+
}), M = ({ payload: t }) => {
|
|
34
|
+
const r = y().insights_feed?.general, l = r?.weekly_no_spending_component_alt_text, { instance_slot: s = {} } = t, o = (e) => _(s.data, e) ?? s[e], a = o("start_date"), d = typeof a == "string" ? S(a.slice(0, 10)) : null;
|
|
35
|
+
if (!d) return null;
|
|
36
|
+
const p = o("no_spend_days"), f = Array.isArray(p) ? p.map((e) => String(e).slice(0, 10)) : [], c = v(d, f), m = c.filter((e) => e.isNoSpend).length;
|
|
37
|
+
return /* @__PURE__ */ u(i, {
|
|
38
|
+
sx: {
|
|
39
|
+
alignItems: "center",
|
|
40
|
+
gap: 1,
|
|
41
|
+
position: "relative",
|
|
42
|
+
pt: 14,
|
|
43
|
+
px: 16
|
|
44
|
+
},
|
|
45
|
+
children: [
|
|
46
|
+
m >= k && /* @__PURE__ */ n(h, {}),
|
|
47
|
+
/* @__PURE__ */ n(x, {
|
|
48
|
+
count: m,
|
|
49
|
+
label: r?.dollar_bill
|
|
50
|
+
}),
|
|
51
|
+
/* @__PURE__ */ n(i, {
|
|
52
|
+
component: "ul",
|
|
53
|
+
direction: "row",
|
|
54
|
+
sx: {
|
|
55
|
+
justifyContent: "space-between",
|
|
56
|
+
listStyle: "none",
|
|
57
|
+
m: 0,
|
|
58
|
+
p: 0,
|
|
59
|
+
position: "relative",
|
|
60
|
+
width: "100%"
|
|
61
|
+
},
|
|
62
|
+
children: c.map((e) => /* @__PURE__ */ u(i, {
|
|
63
|
+
"aria-label": e.isNoSpend ? l?.[`${e.key}_no_spend_day`] : l?.[`${e.key}_is_a_spend_day`],
|
|
64
|
+
component: "li",
|
|
65
|
+
sx: {
|
|
66
|
+
alignItems: "center",
|
|
67
|
+
gap: 4,
|
|
68
|
+
width: 24
|
|
69
|
+
},
|
|
70
|
+
children: [/* @__PURE__ */ n(b, {
|
|
71
|
+
"aria-hidden": "true",
|
|
72
|
+
color: e.isNoSpend ? "success.main" : "text.secondary",
|
|
73
|
+
sx: { fontWeight: e.isNoSpend ? 600 : 400 },
|
|
74
|
+
variant: "body2",
|
|
75
|
+
children: e.label
|
|
76
|
+
}), e.isNoSpend ? /* @__PURE__ */ n(D, {
|
|
77
|
+
"aria-hidden": !0,
|
|
78
|
+
filled: !0,
|
|
79
|
+
size: 24,
|
|
80
|
+
sx: { color: "success.main" }
|
|
81
|
+
}) : /* @__PURE__ */ n(i, {
|
|
82
|
+
"aria-hidden": "true",
|
|
83
|
+
sx: {
|
|
84
|
+
bgcolor: "action.disabledBackground",
|
|
85
|
+
border: "2px solid transparent",
|
|
86
|
+
backgroundClip: "content-box",
|
|
87
|
+
borderRadius: "50%",
|
|
88
|
+
height: 24,
|
|
89
|
+
width: 24
|
|
90
|
+
}
|
|
91
|
+
})]
|
|
92
|
+
}, e.iso))
|
|
93
|
+
})
|
|
94
|
+
]
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
export {
|
|
98
|
+
M as default
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
//# sourceMappingURL=NoSpendDaysBlock.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NoSpendDaysBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ComponentBlocks/NoSpendDaysBlock/NoSpendDaysBlock.tsx"],"sourcesContent":["import Stack from '@mui/material/Stack'\n\nimport { Text } from '@mxenabled/mxui'\nimport { CheckCircle } from '@mxenabled/mx-icons'\n\nimport { useGlobalCopyStore } from '../../../../common'\nimport { slot, type InstanceSlot } from '../../../../core'\nimport { formatDate } from '../../../../core/constants'\nimport { ConfettiOverlay } from '../../../components/shared/ConfettiOverlay'\nimport type { BlockProps } from '../../types'\nimport { parseDueDate } from '../RepeatingTransactionBlock/weekStrip'\n\nimport NoSpendGraphic from './NoSpendGraphic'\n\ntype NoSpendDaysSlot = Pick<InstanceSlot, 'start_date' | 'no_spend_days'>\n\nconst CONFETTI_MIN_DAYS = 5\n\nconst DAY_KEYS = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']\n\nconst toIsoDay = (date: Date) =>\n [date.getFullYear(), date.getMonth() + 1, date.getDate()]\n .map((part) => String(part).padStart(2, '0'))\n .join('-')\n\nconst buildWeek = (start: Date, noSpendDays: string[]) =>\n Array.from({ length: 7 }, (_, index) => {\n const date = new Date(start)\n date.setDate(start.getDate() + index)\n const iso = toIsoDay(date)\n return {\n iso,\n key: DAY_KEYS[date.getDay()],\n label: formatDate(date, { weekday: 'short' }),\n isNoSpend: noSpendDays.includes(iso),\n }\n })\n\nconst NoSpendDaysBlock = ({ payload }: BlockProps) => {\n const generalCopy = useGlobalCopyStore().insights_feed?.general\n const altText = generalCopy?.weekly_no_spending_component_alt_text\n\n const { instance_slot = {} } = payload\n const field = <K extends keyof NoSpendDaysSlot>(key: K) =>\n slot<InstanceSlot[K]>(instance_slot.data, key) ?? instance_slot[key]\n\n const startDate = field('start_date')\n const start = typeof startDate === 'string' ? parseDueDate(startDate.slice(0, 10)) : null\n\n if (!start) return null\n\n const rawDays = field('no_spend_days')\n const noSpendDays = Array.isArray(rawDays) ? rawDays.map((day) => String(day).slice(0, 10)) : []\n const week = buildWeek(start, noSpendDays)\n const count = week.filter((day) => day.isNoSpend).length\n\n return (\n <Stack sx={{ alignItems: 'center', gap: 1, position: 'relative', pt: 14, px: 16 }}>\n {count >= CONFETTI_MIN_DAYS && <ConfettiOverlay />}\n <NoSpendGraphic count={count} label={generalCopy?.dollar_bill} />\n <Stack\n component=\"ul\"\n direction=\"row\"\n sx={{\n justifyContent: 'space-between',\n listStyle: 'none',\n m: 0,\n p: 0,\n position: 'relative',\n width: '100%',\n }}\n >\n {week.map((day) => (\n <Stack\n aria-label={\n day.isNoSpend\n ? altText?.[`${day.key}_no_spend_day`]\n : altText?.[`${day.key}_is_a_spend_day`]\n }\n component=\"li\"\n key={day.iso}\n sx={{ alignItems: 'center', gap: 4, width: 24 }}\n >\n <Text\n aria-hidden=\"true\"\n color={day.isNoSpend ? 'success.main' : 'text.secondary'}\n sx={{ fontWeight: day.isNoSpend ? 600 : 400 }}\n variant=\"body2\"\n >\n {day.label}\n </Text>\n {day.isNoSpend ? (\n <CheckCircle\n aria-hidden={true}\n filled={true}\n size={24}\n sx={{ color: 'success.main' }}\n />\n ) : (\n <Stack\n aria-hidden=\"true\"\n sx={{\n bgcolor: 'action.disabledBackground',\n border: '2px solid transparent',\n backgroundClip: 'content-box',\n borderRadius: '50%',\n height: 24,\n width: 24,\n }}\n />\n )}\n </Stack>\n ))}\n </Stack>\n </Stack>\n )\n}\n\nexport default NoSpendDaysBlock\n"],"mappings":";;;;;;;;;;AAgBA,IAAM,IAAoB,GAEpB,IAAW;AAAA,EAAC;AAAA,EAAU;AAAA,EAAU;AAAA,EAAW;AAAA,EAAa;AAAA,EAAY;AAAA,EAAU;AAAU,GAExF,IAAA,CAAY,MAChB;AAAA,EAAC,EAAK,YAAY;AAAA,EAAG,EAAK,SAAS,IAAI;AAAA,EAAG,EAAK,QAAQ;AAAC,EACrD,IAAA,CAAK,MAAS,OAAO,CAAI,EAAE,SAAS,GAAG,GAAG,CAAC,EAC3C,KAAK,GAAG,GAEP,IAAA,CAAa,GAAa,MAC9B,MAAM,KAAK,EAAE,QAAQ,EAAE,GAAA,CAAI,GAAG,MAAU;AACtC,QAAM,IAAO,IAAI,KAAK,CAAK;AAC3B,EAAA,EAAK,QAAQ,EAAM,QAAQ,IAAI,CAAK;AACpC,QAAM,IAAM,EAAS,CAAI;AACzB,SAAO;AAAA,IACL,KAAA;AAAA,IACA,KAAK,EAAS,EAAK,OAAO,CAAA;AAAA,IAC1B,OAAO,EAAW,GAAM,EAAE,SAAS,QAAQ,CAAC;AAAA,IAC5C,WAA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AU,GAAG,EAAI,GAAA,eAAI,IACrB,IAAU,GAAG,EAAI,GAAA,iBAAI;AAAA,UAE3B,WAAU;AAAA,UAEV,IAAI;AAAA,YAAE,YAAY;AAAA,YAAU,KAAK;AAAA,YAAG,OAAO;AAAA,UAAG;AAAA,UARhD,UAAA,CAUE,gBAAA,EAAC,GAAD;AAAA,YACE,eAAY;AAAA,YACZ,OAAO,EAAI,YAAY,iBAAiB;AAAA,YACxC,IAAI,EAAE,YAAY,EAAI,YAAY,MAAM,IAAI;AAAA,YAC5C,SAAQ;AAAA,YAEP,UAAA,EAAI;AAAA,UACD,CAAA,GACL,EAAI,YACH,gBAAA,EAAC,GAAD;AAAA,YACE,eAAa;AAAA,YACb,QAAQ;AAAA,YACR,MAAM;AAAA,YACN,IAAI,EAAE,OAAO,eAAe;AAAA,UAC7B,CAAA,IAED,gBAAA,EAAC,GAAD;AAAA,YACE,eAAY;AAAA,YACZ,IAAI;AAAA,cACF,SAAS;AAAA,cACT,QAAQ;AAAA,cACR,gBAAgB;AAAA,cAChB,cAAc;AAAA,cACd,QAAQ;AAAA,cACR,OAAO;AAAA,YACT;AAAA,UACD,CAAA,CAEE;AAAA,QA/BA,GAAA,EAAI,GA+BJ,CACR;AAAA,MACI,CAAA;AAAA,IACF;AAAA;AAEX"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { jsx as t, jsxs as o } from "react/jsx-runtime";
|
|
2
|
+
var n = "#59AB8E", i = "#0D5F42", d = "#FBB346", s = "#FFDA6C", h = "M63.48 3.24C66.89 1.24 71.11 1.24 74.52 3.24L103.04 19.95C106.38 21.91 108.44 25.5 108.44 29.37V63.09C108.44 66.97 106.38 70.55 103.04 72.51L74.52 89.23C71.11 91.22 66.89 91.22 63.48 89.23L34.96 72.51C31.61 70.55 29.56 66.97 29.56 63.09V29.37C29.56 25.5 31.61 21.91 34.96 19.95Z", a = ({ x: r, y: e, rotate: x }) => /* @__PURE__ */ t("path", {
|
|
3
|
+
d: "M14 14C14 6 7.5 0 0 0V14Z",
|
|
4
|
+
fill: i,
|
|
5
|
+
transform: `translate(${r} ${e}) rotate(${x} 7 7)`
|
|
6
|
+
}), l = ({ x: r, y: e }) => /* @__PURE__ */ t("text", {
|
|
7
|
+
fill: n,
|
|
8
|
+
fontSize: 9.2,
|
|
9
|
+
fontWeight: 700,
|
|
10
|
+
x: r,
|
|
11
|
+
y: e,
|
|
12
|
+
children: "$"
|
|
13
|
+
}), c = ({ count: r, label: e }) => /* @__PURE__ */ o("svg", {
|
|
14
|
+
"aria-label": e,
|
|
15
|
+
height: 110,
|
|
16
|
+
role: "img",
|
|
17
|
+
style: { position: "relative" },
|
|
18
|
+
viewBox: "0 0 138 110",
|
|
19
|
+
width: 138,
|
|
20
|
+
children: [
|
|
21
|
+
/* @__PURE__ */ t("rect", {
|
|
22
|
+
fill: n,
|
|
23
|
+
height: 69,
|
|
24
|
+
rx: 2,
|
|
25
|
+
width: 138,
|
|
26
|
+
y: 12
|
|
27
|
+
}),
|
|
28
|
+
/* @__PURE__ */ t("rect", {
|
|
29
|
+
fill: "none",
|
|
30
|
+
height: 59.8,
|
|
31
|
+
rx: 1,
|
|
32
|
+
stroke: i,
|
|
33
|
+
strokeWidth: 5,
|
|
34
|
+
width: 128.8,
|
|
35
|
+
x: 4.6,
|
|
36
|
+
y: 16.6
|
|
37
|
+
}),
|
|
38
|
+
/* @__PURE__ */ t(a, {
|
|
39
|
+
rotate: 90,
|
|
40
|
+
x: 9.4,
|
|
41
|
+
y: 21.4
|
|
42
|
+
}),
|
|
43
|
+
/* @__PURE__ */ t(a, {
|
|
44
|
+
rotate: 180,
|
|
45
|
+
x: 114.5,
|
|
46
|
+
y: 21.4
|
|
47
|
+
}),
|
|
48
|
+
/* @__PURE__ */ t(a, {
|
|
49
|
+
rotate: 0,
|
|
50
|
+
x: 9.4,
|
|
51
|
+
y: 58
|
|
52
|
+
}),
|
|
53
|
+
/* @__PURE__ */ t(a, {
|
|
54
|
+
rotate: 270,
|
|
55
|
+
x: 114.5,
|
|
56
|
+
y: 58
|
|
57
|
+
}),
|
|
58
|
+
/* @__PURE__ */ t("circle", {
|
|
59
|
+
cx: 69,
|
|
60
|
+
cy: 46.5,
|
|
61
|
+
fill: i,
|
|
62
|
+
r: 16.5
|
|
63
|
+
}),
|
|
64
|
+
/* @__PURE__ */ t(l, {
|
|
65
|
+
x: 10,
|
|
66
|
+
y: 29
|
|
67
|
+
}),
|
|
68
|
+
/* @__PURE__ */ t(l, {
|
|
69
|
+
x: 121.4,
|
|
70
|
+
y: 29
|
|
71
|
+
}),
|
|
72
|
+
/* @__PURE__ */ t(l, {
|
|
73
|
+
x: 10,
|
|
74
|
+
y: 70.5
|
|
75
|
+
}),
|
|
76
|
+
/* @__PURE__ */ t(l, {
|
|
77
|
+
x: 121.4,
|
|
78
|
+
y: 70.5
|
|
79
|
+
}),
|
|
80
|
+
/* @__PURE__ */ o("g", {
|
|
81
|
+
style: { filter: "drop-shadow(0 3px 4px rgba(0,0,0,0.06)) drop-shadow(0 6px 6px rgba(0,0,0,0.16))" },
|
|
82
|
+
children: [/* @__PURE__ */ t("path", {
|
|
83
|
+
d: h,
|
|
84
|
+
fill: s
|
|
85
|
+
}), /* @__PURE__ */ t("path", {
|
|
86
|
+
d: h,
|
|
87
|
+
fill: d,
|
|
88
|
+
transform: "translate(69 46.2) scale(0.88) translate(-69 -46.2)"
|
|
89
|
+
})]
|
|
90
|
+
}),
|
|
91
|
+
/* @__PURE__ */ t("text", {
|
|
92
|
+
"aria-hidden": "true",
|
|
93
|
+
dominantBaseline: "central",
|
|
94
|
+
fill: "black",
|
|
95
|
+
fontSize: 53,
|
|
96
|
+
fontWeight: 700,
|
|
97
|
+
textAnchor: "middle",
|
|
98
|
+
x: 69,
|
|
99
|
+
y: 48,
|
|
100
|
+
children: r
|
|
101
|
+
})
|
|
102
|
+
]
|
|
103
|
+
});
|
|
104
|
+
export {
|
|
105
|
+
c as default
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
//# sourceMappingURL=NoSpendGraphic.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NoSpendGraphic.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ComponentBlocks/NoSpendDaysBlock/NoSpendGraphic.tsx"],"sourcesContent":["const BILL = '#59AB8E'\nconst BILL_DARK = '#0D5F42'\nconst BADGE = '#FBB346'\nconst BADGE_EDGE = '#FFDA6C'\n\nconst HEXAGON =\n 'M63.48 3.24C66.89 1.24 71.11 1.24 74.52 3.24L103.04 19.95C106.38 21.91 108.44 25.5 108.44 29.37V63.09C108.44 66.97 106.38 70.55 103.04 72.51L74.52 89.23C71.11 91.22 66.89 91.22 63.48 89.23L34.96 72.51C31.61 70.55 29.56 66.97 29.56 63.09V29.37C29.56 25.5 31.61 21.91 34.96 19.95Z'\n\nconst Corner = ({ x, y, rotate }: { x: number; y: number; rotate: number }) => (\n <path\n d=\"M14 14C14 6 7.5 0 0 0V14Z\"\n fill={BILL_DARK}\n transform={`translate(${x} ${y}) rotate(${rotate} 7 7)`}\n />\n)\n\nconst Dollar = ({ x, y }: { x: number; y: number }) => (\n <text fill={BILL} fontSize={9.2} fontWeight={700} x={x} y={y}>\n $\n </text>\n)\n\nconst NoSpendGraphic = ({ count, label }: { count: number; label?: string }) => (\n <svg\n aria-label={label}\n height={110}\n role=\"img\"\n style={{ position: 'relative' }}\n viewBox=\"0 0 138 110\"\n width={138}\n >\n <rect fill={BILL} height={69} rx={2} width={138} y={12} />\n <rect\n fill=\"none\"\n height={59.8}\n rx={1}\n stroke={BILL_DARK}\n strokeWidth={5}\n width={128.8}\n x={4.6}\n y={16.6}\n />\n <Corner rotate={90} x={9.4} y={21.4} />\n <Corner rotate={180} x={114.5} y={21.4} />\n <Corner rotate={0} x={9.4} y={58} />\n <Corner rotate={270} x={114.5} y={58} />\n <circle cx={69} cy={46.5} fill={BILL_DARK} r={16.5} />\n <Dollar x={10} y={29} />\n <Dollar x={121.4} y={29} />\n <Dollar x={10} y={70.5} />\n <Dollar x={121.4} y={70.5} />\n <g\n style={{\n filter: 'drop-shadow(0 3px 4px rgba(0,0,0,0.06)) drop-shadow(0 6px 6px rgba(0,0,0,0.16))',\n }}\n >\n <path d={HEXAGON} fill={BADGE_EDGE} />\n <path\n d={HEXAGON}\n fill={BADGE}\n transform=\"translate(69 46.2) scale(0.88) translate(-69 -46.2)\"\n />\n </g>\n <text\n aria-hidden=\"true\"\n dominantBaseline=\"central\"\n fill=\"black\"\n fontSize={53}\n fontWeight={700}\n textAnchor=\"middle\"\n x={69}\n y={48}\n >\n {count}\n </text>\n </svg>\n)\n\nexport default NoSpendGraphic\n"],"mappings":";AAAA,IAAM,IAAO,WACP,IAAY,WACZ,IAAQ,WACR,IAAa,WAEb,IACJ,0RAEI,IAAA,CAAU,EAAE,GAAA,GAAG,GAAA,GAAG,QAAA,EAAA,MACtB,gBAAA,EAAC,QAAD;AAAA,EACE,GAAE;AAAA,EACF,MAAM;AAAA,EACN,WAAW,aAAa,CAAA,IAAK,CAAA,YAAa,CAAA;AAC3C,CAAA,GAGG,IAAA,CAAU,EAAE,GAAA,GAAG,GAAA,EAAA,MACnB,gBAAA,EAAC,QAAD;AAAA,EAAM,MAAM;AAAA,EAAM,UAAU;AAAA,EAAK,YAAY;AAAA,EAAQ,GAAA;AAAA,EAAM,GAAA;AAAA,EAAG,UAAA;AAExD,CAAA,GAGF,IAAA,CAAkB,EAAE,OAAA,GAAO,OAAA,EAAA,MAC/B,gBAAA,EAAC,OAAD;AAAA,EACE,cAAY;AAAA,EACZ,QAAQ;AAAA,EACR,MAAK;AAAA,EACL,OAAO,EAAE,UAAU,WAAW;AAAA,EAC9B,SAAQ;AAAA,EACR,OAAO;AAAA,EANT,UAAA;AAAA,IAQE,gBAAA,EAAC,QAAD;AAAA,MAAM,MAAM;AAAA,MAAM,QAAQ;AAAA,MAAI,IAAI;AAAA,MAAG,OAAO;AAAA,MAAK,GAAG;AAAA,IAAK,CAAA;AAAA,IAC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AAA,GACrC,gBAAA,EAAC,QAAD;AAAA,QACE,GAAG;AAAA,QACH,MAAM;AAAA,QACN,WAAU;AAAA,MACX,CAAA,CACA;AAAA;IACH,gBAAA,EAAC,QAAD;AAAA,MACE,eAAY;AAAA,MACZ,kBAAiB;AAAA,MACjB,MAAK;AAAA,MACL,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,YAAW;AAAA,MACX,GAAG;AAAA,MACH,GAAG;AAAA,MAEF,UAAA;AAAA,IACG,CAAA;AAAA,EACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as NoSpendDaysBlock } from './NoSpendDaysBlock';
|
|
@@ -3,6 +3,7 @@ export * from './AccountSwitchBlock';
|
|
|
3
3
|
export * from './BudgetBlock';
|
|
4
4
|
export * from './DebtsBlock';
|
|
5
5
|
export * from './DetailedAccountBlock';
|
|
6
|
+
export * from './NoSpendDaysBlock';
|
|
6
7
|
export * from './RepeatingTransactionBlock';
|
|
7
8
|
export * from './SaveExtraBlock';
|
|
8
9
|
export * from './SavingsOpportunityBlock';
|