@mx-cartographer/experiences 9.7.170 → 9.7.171
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 +4 -0
- package/dist/common/components/CurrencyDialog.es.js +40 -37
- package/dist/common/components/CurrencyDialog.es.js.map +1 -1
- package/dist/common/components/SubheaderRow.es.js +11 -8
- package/dist/common/components/SubheaderRow.es.js.map +1 -1
- package/dist/core/types/InsightsInstanceSlotData.d.ts +2 -0
- package/dist/core/types/InsightsInstanceSlotData.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js +35 -34
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/layout.d.ts +1 -1
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListCreditLimitHeader.d.ts +2 -4
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListCreditLimitHeader.es.js +43 -69
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListCreditLimitHeader.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChart.d.ts +3 -1
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChart.es.js +15 -13
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChart.es.js.map +1 -1
- package/dist/insights-v2/components/CompactInsightCard.es.js +23 -17
- package/dist/insights-v2/components/CompactInsightCard.es.js.map +1 -1
- package/dist/microinsights/MicroCardTemplate.es.js +1 -1
- package/dist/microinsights/MicroCardTemplate.es.js.map +1 -1
- package/dist/notifications/components/NotificationCard.es.js +18 -17
- package/dist/notifications/components/NotificationCard.es.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
## [9.7.171] - 11-17-2026
|
|
2
|
+
|
|
3
|
+
- **CHANGED** - Credit Card Close to Limit's embedded card matches Figma (bold amounts, "Remains", a tighter donut), and micro card titles and notification rows use Figma's line height and logo size (WEC-2030)
|
|
4
|
+
|
|
1
5
|
## [9.7.170] - 11-17-2026
|
|
2
6
|
|
|
3
7
|
- **CHANGED** - Insights 2.0 action blocks keep each CTA variant's drawer title in the block's variant table; no visible change (WEC-2262)
|
|
@@ -1,43 +1,46 @@
|
|
|
1
1
|
import { useScreenSize as N } from "../hooks/useScreenSize.es.js";
|
|
2
2
|
import l from "@mui/material/Stack";
|
|
3
|
-
import { H3 as
|
|
3
|
+
import { H3 as $, P as j } from "@mxenabled/mxui";
|
|
4
4
|
import f from "@mui/material/Button";
|
|
5
|
-
import { Icon as
|
|
6
|
-
import { jsx as
|
|
5
|
+
import { Icon as A } from "@mxenabled/mx-icons";
|
|
6
|
+
import { jsx as r, jsxs as e } from "react/jsx-runtime";
|
|
7
7
|
import B from "@mui/material/Dialog";
|
|
8
8
|
import F from "@mui/material/DialogContent";
|
|
9
9
|
import H from "@mui/material/IconButton";
|
|
10
|
-
import
|
|
10
|
+
import R from "@mui/material/DialogActions";
|
|
11
11
|
import h from "@mui/material/InputAdornment";
|
|
12
|
-
import
|
|
13
|
-
var
|
|
14
|
-
currency: { startAdornment: /* @__PURE__ */
|
|
12
|
+
import w from "@mui/material/TextField";
|
|
13
|
+
var P = {
|
|
14
|
+
currency: { startAdornment: /* @__PURE__ */ r(h, {
|
|
15
15
|
position: "start",
|
|
16
16
|
children: "$"
|
|
17
17
|
}) },
|
|
18
|
-
percent: { endAdornment: /* @__PURE__ */
|
|
18
|
+
percent: { endAdornment: /* @__PURE__ */ r(h, {
|
|
19
19
|
position: "end",
|
|
20
20
|
children: "%"
|
|
21
21
|
}) }
|
|
22
|
-
}, X = ({ closeAriaLabel: u, content:
|
|
23
|
-
const d = b || (t ? !(
|
|
24
|
-
return /* @__PURE__ */
|
|
22
|
+
}, X = ({ closeAriaLabel: u, content: x, errorText: a, inputLabel: t, inputValue: i, isOpen: g, isPrimaryDisabled: b = !1, handleInputChange: C, handleInputClick: D, handleModalClose: s, handlePrimaryAction: c, handleSecondaryAction: y, primaryColor: v = "primary", primaryText: m, secondaryColor: I = "primary", secondaryText: n, subtitle: k, title: p, unit: S = "currency" }) => {
|
|
23
|
+
const d = b || (t ? !(i !== "" && i !== "0" && !isNaN(parseFloat(i ?? "0"))) : !1), { isSmallMobile: M } = N();
|
|
24
|
+
return /* @__PURE__ */ r(B, {
|
|
25
25
|
"aria-label": p,
|
|
26
26
|
"aria-labelledby": "modal-title",
|
|
27
27
|
maxWidth: "xs",
|
|
28
|
-
onClose:
|
|
29
|
-
open:
|
|
28
|
+
onClose: s,
|
|
29
|
+
open: g,
|
|
30
30
|
role: "dialog",
|
|
31
31
|
sx: {
|
|
32
32
|
"& .MuiDialogContent-root": { p: 0 },
|
|
33
|
-
|
|
33
|
+
"& .MuiDialog-paper": {
|
|
34
|
+
borderRadius: (o) => `${o.shape.borderRadius}px`,
|
|
35
|
+
...M && { minWidth: "100%" }
|
|
36
|
+
}
|
|
34
37
|
},
|
|
35
|
-
children: /* @__PURE__ */
|
|
36
|
-
onSubmit: (
|
|
37
|
-
|
|
38
|
+
children: /* @__PURE__ */ r(F, { children: /* @__PURE__ */ e("form", {
|
|
39
|
+
onSubmit: (o) => {
|
|
40
|
+
o.preventDefault(), d || c();
|
|
38
41
|
},
|
|
39
42
|
children: [
|
|
40
|
-
/* @__PURE__ */
|
|
43
|
+
/* @__PURE__ */ e(l, {
|
|
41
44
|
sx: {
|
|
42
45
|
alignItems: "center",
|
|
43
46
|
flexDirection: "row",
|
|
@@ -48,47 +51,47 @@ var W = {
|
|
|
48
51
|
pr: 16,
|
|
49
52
|
pt: 24
|
|
50
53
|
},
|
|
51
|
-
children: [/* @__PURE__ */
|
|
54
|
+
children: [/* @__PURE__ */ e(l, {
|
|
52
55
|
sx: { gap: 4 },
|
|
53
|
-
children: [/* @__PURE__ */
|
|
56
|
+
children: [/* @__PURE__ */ r($, {
|
|
54
57
|
id: "modal-title",
|
|
55
58
|
children: p
|
|
56
59
|
}), k]
|
|
57
|
-
}), /* @__PURE__ */
|
|
60
|
+
}), /* @__PURE__ */ r(H, {
|
|
58
61
|
"aria-label": u,
|
|
59
|
-
onClick:
|
|
62
|
+
onClick: s,
|
|
60
63
|
sx: {
|
|
61
64
|
minHeight: 24,
|
|
62
65
|
position: "absolute",
|
|
63
66
|
right: 8,
|
|
64
67
|
top: 18
|
|
65
68
|
},
|
|
66
|
-
children: /* @__PURE__ */
|
|
69
|
+
children: /* @__PURE__ */ r(A, {
|
|
67
70
|
name: "close",
|
|
68
71
|
sx: { color: "action.active" }
|
|
69
72
|
})
|
|
70
73
|
})]
|
|
71
74
|
}),
|
|
72
|
-
/* @__PURE__ */
|
|
75
|
+
/* @__PURE__ */ e(l, {
|
|
73
76
|
sx: {
|
|
74
77
|
gap: 24,
|
|
75
78
|
px: 24
|
|
76
79
|
},
|
|
77
|
-
children: [/* @__PURE__ */
|
|
80
|
+
children: [/* @__PURE__ */ r(j, {
|
|
78
81
|
variant: "subtitle1",
|
|
79
|
-
children:
|
|
80
|
-
}), t && /* @__PURE__ */
|
|
82
|
+
children: x
|
|
83
|
+
}), t && /* @__PURE__ */ r(w, {
|
|
81
84
|
autoFocus: !0,
|
|
82
85
|
error: !!a,
|
|
83
86
|
helperText: a,
|
|
84
87
|
inputMode: "decimal",
|
|
85
88
|
label: t,
|
|
86
|
-
onChange: ({ target: { value:
|
|
87
|
-
/^\d*\.?\d*$/.test(
|
|
89
|
+
onChange: ({ target: { value: o } }) => {
|
|
90
|
+
/^\d*\.?\d*$/.test(o) && C?.(o);
|
|
88
91
|
},
|
|
89
92
|
onClick: D,
|
|
90
93
|
slotProps: {
|
|
91
|
-
input:
|
|
94
|
+
input: P[S],
|
|
92
95
|
formHelperText: { role: "alert" },
|
|
93
96
|
htmlInput: {
|
|
94
97
|
"aria-label": t,
|
|
@@ -97,28 +100,28 @@ var W = {
|
|
|
97
100
|
}
|
|
98
101
|
},
|
|
99
102
|
type: "text",
|
|
100
|
-
value:
|
|
103
|
+
value: i
|
|
101
104
|
})]
|
|
102
105
|
}),
|
|
103
|
-
/* @__PURE__ */
|
|
106
|
+
/* @__PURE__ */ e(R, {
|
|
104
107
|
sx: {
|
|
105
108
|
justifyContent: "flex-end",
|
|
106
109
|
gap: 16,
|
|
107
110
|
p: 24,
|
|
108
111
|
">:not(style)~:not(style)": { ml: 0 }
|
|
109
112
|
},
|
|
110
|
-
children: [n && /* @__PURE__ */
|
|
113
|
+
children: [n && /* @__PURE__ */ r(f, {
|
|
111
114
|
"aria-label": n,
|
|
112
115
|
color: I,
|
|
113
116
|
onClick: y,
|
|
114
117
|
children: n
|
|
115
|
-
}), /* @__PURE__ */
|
|
116
|
-
"aria-label":
|
|
118
|
+
}), /* @__PURE__ */ r(f, {
|
|
119
|
+
"aria-label": m,
|
|
117
120
|
color: v,
|
|
118
121
|
disabled: d,
|
|
119
|
-
onClick:
|
|
122
|
+
onClick: c,
|
|
120
123
|
variant: "contained",
|
|
121
|
-
children:
|
|
124
|
+
children: m
|
|
122
125
|
})]
|
|
123
126
|
})
|
|
124
127
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CurrencyDialog.es.js","names":[],"sources":["../../../src/common/components/CurrencyDialog.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { H3, P } from '@mxenabled/mxui'\n\nimport Button, { type ButtonProps } from '@mui/material/Button'\nimport Dialog from '@mui/material/Dialog'\nimport DialogActions from '@mui/material/DialogActions'\nimport DialogContent from '@mui/material/DialogContent'\nimport IconButton from '@mui/material/IconButton'\nimport InputAdornment from '@mui/material/InputAdornment'\nimport Stack from '@mui/material/Stack'\nimport TextField from '@mui/material/TextField'\n\nimport { useScreenSize } from '../hooks'\n\nconst UNIT_ADORNMENTS = {\n currency: { startAdornment: <InputAdornment position=\"start\">$</InputAdornment> },\n percent: { endAdornment: <InputAdornment position=\"end\">%</InputAdornment> },\n}\n\nexport type CurrencyDialogUnit = keyof typeof UNIT_ADORNMENTS\n\ninterface CurrencyDialogProps {\n closeAriaLabel: string\n /** Body copy; a node so callers can emphasise part of it (e.g. a bold account name). */\n content?: ReactNode\n /** Validation or save error, shown under the input and marking it invalid. */\n errorText?: string\n inputLabel?: string\n inputValue?: string\n isOpen: boolean\n /** Disables the primary button on top of the built-in input check (e.g. while saving). */\n isPrimaryDisabled?: boolean\n handleInputChange?: (value: string) => void\n /**\n * Click on the amount input (e.g. analytics). Click, not focus: the input autofocuses on open,\n * so a focus callback would fire per open rather than per user interaction.\n */\n handleInputClick?: () => void\n handleModalClose: () => void\n handlePrimaryAction: () => void\n handleSecondaryAction?: () => void\n primaryColor?: ButtonProps['color']\n primaryText: string\n secondaryColor?: ButtonProps['color']\n secondaryText?: string\n /** A line under the title, e.g. the account a setting applies to. */\n subtitle?: ReactNode\n title: string\n unit?: CurrencyDialogUnit\n}\n\n// Created for V2 of BudgetDetailsDrawer.\n// The previous design will be replaced once the new design is finalized.\n// Also needs to be updated to use the mxui library\n// with the updated Dialog components.\n\nconst CurrencyDialog = ({\n closeAriaLabel,\n content,\n errorText,\n inputLabel,\n inputValue,\n isOpen,\n isPrimaryDisabled = false,\n handleInputChange,\n handleInputClick,\n handleModalClose,\n handlePrimaryAction,\n handleSecondaryAction,\n primaryColor = 'primary',\n primaryText,\n secondaryColor = 'primary',\n secondaryText,\n subtitle,\n title,\n unit = 'currency',\n}: CurrencyDialogProps) => {\n const numericValue = parseFloat(inputValue ?? '0')\n const isValid = inputValue !== '' && inputValue !== '0' && !isNaN(numericValue)\n // One rule for the button and for Enter: the form's submit must not bypass a disabled button.\n const isPrimaryBlocked = isPrimaryDisabled || (inputLabel ? !isValid : false)\n\n const { isSmallMobile } = useScreenSize()\n\n return (\n <Dialog\n aria-label={title}\n aria-labelledby=\"modal-title\"\n maxWidth=\"xs\"\n onClose={handleModalClose}\n open={isOpen}\n role=\"dialog\"\n sx={{\n '& .MuiDialogContent-root': { p: 0 },\n
|
|
1
|
+
{"version":3,"file":"CurrencyDialog.es.js","names":[],"sources":["../../../src/common/components/CurrencyDialog.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { H3, P } from '@mxenabled/mxui'\n\nimport Button, { type ButtonProps } from '@mui/material/Button'\nimport Dialog from '@mui/material/Dialog'\nimport DialogActions from '@mui/material/DialogActions'\nimport DialogContent from '@mui/material/DialogContent'\nimport IconButton from '@mui/material/IconButton'\nimport InputAdornment from '@mui/material/InputAdornment'\nimport Stack from '@mui/material/Stack'\nimport TextField from '@mui/material/TextField'\n\nimport { useScreenSize } from '../hooks'\n\nconst UNIT_ADORNMENTS = {\n currency: { startAdornment: <InputAdornment position=\"start\">$</InputAdornment> },\n percent: { endAdornment: <InputAdornment position=\"end\">%</InputAdornment> },\n}\n\nexport type CurrencyDialogUnit = keyof typeof UNIT_ADORNMENTS\n\ninterface CurrencyDialogProps {\n closeAriaLabel: string\n /** Body copy; a node so callers can emphasise part of it (e.g. a bold account name). */\n content?: ReactNode\n /** Validation or save error, shown under the input and marking it invalid. */\n errorText?: string\n inputLabel?: string\n inputValue?: string\n isOpen: boolean\n /** Disables the primary button on top of the built-in input check (e.g. while saving). */\n isPrimaryDisabled?: boolean\n handleInputChange?: (value: string) => void\n /**\n * Click on the amount input (e.g. analytics). Click, not focus: the input autofocuses on open,\n * so a focus callback would fire per open rather than per user interaction.\n */\n handleInputClick?: () => void\n handleModalClose: () => void\n handlePrimaryAction: () => void\n handleSecondaryAction?: () => void\n primaryColor?: ButtonProps['color']\n primaryText: string\n secondaryColor?: ButtonProps['color']\n secondaryText?: string\n /** A line under the title, e.g. the account a setting applies to. */\n subtitle?: ReactNode\n title: string\n unit?: CurrencyDialogUnit\n}\n\n// Created for V2 of BudgetDetailsDrawer.\n// The previous design will be replaced once the new design is finalized.\n// Also needs to be updated to use the mxui library\n// with the updated Dialog components.\n\nconst CurrencyDialog = ({\n closeAriaLabel,\n content,\n errorText,\n inputLabel,\n inputValue,\n isOpen,\n isPrimaryDisabled = false,\n handleInputChange,\n handleInputClick,\n handleModalClose,\n handlePrimaryAction,\n handleSecondaryAction,\n primaryColor = 'primary',\n primaryText,\n secondaryColor = 'primary',\n secondaryText,\n subtitle,\n title,\n unit = 'currency',\n}: CurrencyDialogProps) => {\n const numericValue = parseFloat(inputValue ?? '0')\n const isValid = inputValue !== '' && inputValue !== '0' && !isNaN(numericValue)\n // One rule for the button and for Enter: the form's submit must not bypass a disabled button.\n const isPrimaryBlocked = isPrimaryDisabled || (inputLabel ? !isValid : false)\n\n const { isSmallMobile } = useScreenSize()\n\n return (\n <Dialog\n aria-label={title}\n aria-labelledby=\"modal-title\"\n maxWidth=\"xs\"\n onClose={handleModalClose}\n open={isOpen}\n role=\"dialog\"\n sx={{\n '& .MuiDialogContent-root': { p: 0 },\n // Figma's dialog paper is the theme's 4px radius, not MuiPaper's 8px.\n '& .MuiDialog-paper': {\n borderRadius: (theme) => `${theme.shape.borderRadius}px`,\n ...(isSmallMobile && { minWidth: '100%' }),\n },\n }}\n >\n <DialogContent>\n <form\n onSubmit={(e) => {\n e.preventDefault()\n if (!isPrimaryBlocked) handlePrimaryAction()\n }}\n >\n <Stack\n sx={{\n alignItems: 'center',\n flexDirection: 'row',\n justifyContent: 'space-between',\n pb: 12,\n pl: 24,\n position: 'relative',\n pr: 16,\n pt: 24,\n }}\n >\n <Stack sx={{ gap: 4 }}>\n <H3 id=\"modal-title\">{title}</H3>\n {subtitle}\n </Stack>\n <IconButton\n aria-label={closeAriaLabel}\n onClick={handleModalClose}\n sx={{ minHeight: 24, position: 'absolute', right: 8, top: 18 }}\n >\n <Icon name=\"close\" sx={{ color: 'action.active' }} />\n </IconButton>\n </Stack>\n <Stack sx={{ gap: 24, px: 24 }}>\n <P variant=\"subtitle1\">{content}</P>\n {inputLabel && (\n <TextField\n autoFocus={true}\n error={!!errorText}\n helperText={errorText}\n inputMode=\"decimal\"\n label={inputLabel}\n onChange={({ target: { value } }) => {\n if (!/^\\d*\\.?\\d*$/.test(value)) return\n\n handleInputChange?.(value)\n }}\n onClick={handleInputClick}\n slotProps={{\n input: UNIT_ADORNMENTS[unit],\n // Announce errors: focus is usually on the primary button when one appears.\n formHelperText: { role: 'alert' },\n htmlInput: {\n 'aria-label': inputLabel,\n noValidate: true,\n pattern: '[0-9]*\\\\.?[0-9]*',\n },\n }}\n type=\"text\"\n value={inputValue}\n />\n )}\n </Stack>\n <DialogActions\n sx={{\n justifyContent: 'flex-end',\n gap: 16,\n p: 24,\n '>:not(style)~:not(style)': { ml: 0 },\n }}\n >\n {secondaryText && (\n <Button\n aria-label={secondaryText}\n color={secondaryColor}\n onClick={handleSecondaryAction}\n >\n {secondaryText}\n </Button>\n )}\n <Button\n aria-label={primaryText}\n color={primaryColor}\n disabled={isPrimaryBlocked}\n onClick={handlePrimaryAction}\n variant=\"contained\"\n >\n {primaryText}\n </Button>\n </DialogActions>\n </form>\n </DialogContent>\n </Dialog>\n )\n}\n\nexport default CurrencyDialog\n"],"mappings":";;;;;;;;;;;;AAgBA,IAAM,IAAkB;AAAA,EACtB,UAAU,EAAE,gBAAgB,gBAAA,EAAC,GAAD;AAAA,IAAgB,UAAS;AAAA,IAAQ,UAAA;AAAA,EAAiB,CAAA,EAAE;AAAA,EAChF,SAAS,EAAE,cAAc,gBAAA,EAAC,GAAD;AAAA,IAAgB,UAAS;AAAA,IAAM,UAAA;AAAA,EAAiB,CAAA,EAAE;AAC7E,GAuCM,IAAA,CAAkB,EACtB,gBAAA,GACA,SAAA,GACA,WAAA,GACA,YAAA,GACA,YAAA,GACA,QAAA,GACA,mBAAA,IAAoB,IACpB,mBAAA,GACA,kBAAA,GACA,kBAAA,GACA,qBAAA,GACA,uBAAA,GACA,cAAA,IAAe,WACf,aAAA,GACA,gBAAA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,YACZ,OAAO;AAAA,YACP,UAAU;AAAA,YACV,SAAS;AAAA,YACT,SAAQ;AAAA,YAEP,UAAA;AAAA,UACK,CAAA,CACK;AAAA;MACX;AAAA,IACO,CAAA,EAAA,CAAA;AAAA,EACT,CAAA;AAEZ"}
|
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
import "react";
|
|
2
|
-
import { Text as
|
|
2
|
+
import { Text as i } from "@mxenabled/mxui";
|
|
3
3
|
import { jsx as o } from "react/jsx-runtime";
|
|
4
|
-
import
|
|
5
|
-
var
|
|
4
|
+
import e from "@mui/material/Box";
|
|
5
|
+
var m = ({ bgcolor: t = "background.default", children: r }) => /* @__PURE__ */ o(e, {
|
|
6
6
|
display: "inline-block",
|
|
7
7
|
sx: {
|
|
8
|
-
bgcolor:
|
|
8
|
+
bgcolor: t,
|
|
9
9
|
py: 6,
|
|
10
10
|
width: "100%"
|
|
11
11
|
},
|
|
12
|
-
children: /* @__PURE__ */ o(
|
|
12
|
+
children: /* @__PURE__ */ o(i, {
|
|
13
13
|
bold: !0,
|
|
14
|
-
sx: {
|
|
14
|
+
sx: {
|
|
15
|
+
fontWeight: "fontWeightBold",
|
|
16
|
+
pl: 24
|
|
17
|
+
},
|
|
15
18
|
variant: "caption",
|
|
16
|
-
children:
|
|
19
|
+
children: r
|
|
17
20
|
})
|
|
18
21
|
});
|
|
19
22
|
export {
|
|
20
|
-
|
|
23
|
+
m as default
|
|
21
24
|
};
|
|
22
25
|
|
|
23
26
|
//# sourceMappingURL=SubheaderRow.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubheaderRow.es.js","names":[],"sources":["../../../src/common/components/SubheaderRow.tsx"],"sourcesContent":["import React, { PropsWithChildren } from 'react'\n\nimport Box from '@mui/material/Box'\n\nimport { Text } from '@mxenabled/mxui'\n\ninterface SubheaderRowProps {\n bgcolor?: string\n}\n\nconst SubheaderRow: React.FC<PropsWithChildren<SubheaderRowProps>> = ({\n bgcolor = 'background.default',\n children,\n}) => (\n <Box display=\"inline-block\" sx={{ bgcolor, py: 6, width: '100%' }}>\n <Text bold={true} sx={{ pl: 24 }} variant=\"caption\">\n {children}\n </Text>\n </Box>\n)\n\nexport default SubheaderRow\n"],"mappings":";;;;AAUA,IAAM,IAAA,CAAgE,EACpE,SAAA,IAAU,sBACV,UAAA,EAAA,MAEA,gBAAA,EAAC,GAAD;AAAA,EAAK,SAAQ;AAAA,EAAe,IAAI;AAAA,IAAE,SAAA;AAAA,IAAS,IAAI;AAAA,IAAG,OAAO;AAAA,EAAO;AAAA,
|
|
1
|
+
{"version":3,"file":"SubheaderRow.es.js","names":[],"sources":["../../../src/common/components/SubheaderRow.tsx"],"sourcesContent":["import React, { PropsWithChildren } from 'react'\n\nimport Box from '@mui/material/Box'\n\nimport { Text } from '@mxenabled/mxui'\n\ninterface SubheaderRowProps {\n bgcolor?: string\n}\n\nconst SubheaderRow: React.FC<PropsWithChildren<SubheaderRowProps>> = ({\n bgcolor = 'background.default',\n children,\n}) => (\n <Box display=\"inline-block\" sx={{ bgcolor, py: 6, width: '100%' }}>\n {/* Figma's date header is Bold 700; mxui Text's bold is 600. */}\n <Text bold={true} sx={{ fontWeight: 'fontWeightBold', pl: 24 }} variant=\"caption\">\n {children}\n </Text>\n </Box>\n)\n\nexport default SubheaderRow\n"],"mappings":";;;;AAUA,IAAM,IAAA,CAAgE,EACpE,SAAA,IAAU,sBACV,UAAA,EAAA,MAEA,gBAAA,EAAC,GAAD;AAAA,EAAK,SAAQ;AAAA,EAAe,IAAI;AAAA,IAAE,SAAA;AAAA,IAAS,IAAI;AAAA,IAAG,OAAO;AAAA,EAAO;AAAA,EAE9D,UAAA,gBAAA,EAAC,GAAD;AAAA,IAAM,MAAM;AAAA,IAAM,IAAI;AAAA,MAAE,YAAY;AAAA,MAAkB,IAAI;AAAA,IAAG;AAAA,IAAG,SAAQ;AAAA,IACrE,UAAA;AAAA,EACG,CAAA;AACH,CAAA"}
|
|
@@ -24,6 +24,8 @@ export interface DonutChartMain {
|
|
|
24
24
|
value: string | number;
|
|
25
25
|
value_type: string;
|
|
26
26
|
label: string;
|
|
27
|
+
/** The embedded donut's shorter caption (Credit Card Close to Limit: "Remains"). */
|
|
28
|
+
compact_label?: string;
|
|
27
29
|
}
|
|
28
30
|
export interface DonutChartBlockData {
|
|
29
31
|
main: DonutChartMain;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InsightsInstanceSlotData.es.js","names":[],"sources":["../../../src/core/types/InsightsInstanceSlotData.ts"],"sourcesContent":["import type { DataSeries, Legends, LogoRef } from '../../core'\n\nexport interface InsightsInstanceSlotData\n extends\n Partial<BudgetBlockData>,\n Partial<DonutChartBlockData>,\n Partial<ImageBlockData>,\n Partial<AccountBlockData>,\n Partial<SaveExtraBlockData>,\n Partial<StepChartBlockData>,\n Partial<SVGImageBlockData>,\n Partial<AccountSwitchBlockData>,\n Partial<TransactionDetailsBlockData>,\n Partial<CreditUtilizationBlockData>,\n Partial<MerchantBlockData>,\n Partial<CommonProps> {}\n\n//when any of the type is used more than one times, we can use the common props\ninterface CommonProps {\n amount?: number\n ariaLabel?: string\n date?: string\n legends?: Legends[]\n category_guid?: string\n data_series?: DataSeries | DataSet[]\n transaction_guids?: string[]\n account_guids?: string[]\n primary_transaction_guid?: string\n}\n\n//BarChart Block: `instance_slot.data` (Insights 2.0)\nexport interface BarChartBlockData {\n series?: DataSeries\n category_guid?: string\n average_amount?: number\n /** [0] monthly amount, [1] trend. */\n additional_data?: Legends[]\n}\n\n//DonutChart Block: `instance_slot.data` (Insights 2.0) — the same shape V1 sent as `instance_slot_data`.\n/** The donut's centre: the total and its caption (\"$6,306\" / \"Total\"). */\nexport interface DonutChartMain {\n value: string | number\n value_type: string\n label: string\n}\nexport interface DonutChartBlockData {\n main: DonutChartMain\n /** The category whose colour fills the primary slice (Cost of Living to Income: Housing). */\n category_guid?: string\n /** Legend rows beside the donut: a label, its amount and an optional share (\"$5,550.00 (88%)\"). */\n legends?: Legends[]\n}\n\n//DoubleBarChart Block\n// TODO : This has to be revisited again to update the below types based on API response once we have the final shape of the data_series for double bar chart from BE\nexport interface LegendProps extends Legends {\n amount: number\n formattedAmount: string\n label: string\n color?: string\n}\n\nexport interface DataSet extends DataSeries {\n ariaLabelComparison: string\n ariaLabelMain: string\n comparison: number\n // The comparison bar's transaction guids (data_series aggregated_guids), for the drawer filter.\n comparisonGuids?: string[]\n // The month's 'yyyy-MM-dd' date (the main row's).\n date?: string\n formattedComparison: string\n formattedMain: string\n label: string\n main: number\n // The main bar's transaction guids (data_series aggregated_guids), for the drawer filter.\n mainGuids?: string[]\n}\n\n//DoubleProgressBar Block\n\n//Image Block\nexport interface ImageBlockData {\n image: string\n}\n\n//Account Block\nexport interface AccountBlockData {\n sub_text: string\n institution_guid?: string\n institution_name?: string\n icon_name?: string\n /** Header bar text (standard card), or the colored category strip label (deposit cards). */\n header_text?: string\n // Deposit variants (Unified Deposit, Unified Deposit Emergency Fund, Savings Account Deposit)\n /** Merchant guid — renders a real merchant logo in the deposit card when present. */\n merchant_guid?: string\n /** Merchant display name — logo alt text and the payer line under the amount. */\n merchant_name?: string\n /** Secondary label beside the amount, e.g. `On {date}, you saved` or `Balance as of MM/DD/YY`. */\n label?: string\n}\n\nexport interface SaveExtraBlockData {\n /** Styled segments `[lead-in, amount digits, trailing copy]`, e.g. `['Save an extra', '100', 'to help your funds grow']`. */\n primary_text?: string[]\n /** Styled segments `[projected balance, caption]`, e.g. `['$8,313.87', 'After payday & projected expenses']`. */\n secondary_text?: string[]\n /** MakeTransfer drilldown: available balance (both variants). */\n available_balance?: number\n /** SAVE_ENOUGH_TO_LIVE_ON: average monthly spend. */\n avg_monthly_spend?: number\n /** SAVE_ENOUGH_TO_LIVE_ON: how long the balance lasts, overlaid on the timeline SVG (e.g. \"2 months, 11 days\"). */\n time_period?: string\n /** SAVE_AN_EXTRA_100: upcoming expenses (the \"Expenses\" figure). */\n upcoming_expenses?: number\n /** SAVE_AN_EXTRA_100: total remaining after expenses. */\n total_remaining?: number\n /** SAVE_ENOUGH_TO_LIVE_ON: date for the \"Your available balances as of {date}\" line. */\n date?: string\n}\n\n// AccountSwitch Block. State comes from `instance_slot.variant`, not a data flag.\nexport interface AccountSwitchBlockData {\n discovered_institution_guid: string\n discovered_institution_name: string\n held_institution_guid: string\n held_institution_name: string\n}\n\n// AccountSwitch Block: `instance_slot.data` (Insights 2.0, Discovered Accounts V2). Each slot is\n// optional: tupac omits `to_logo` when the user holds no FI-managed account. `logo` is the compact\n// card's (micro, notification) discovered institution.\nexport interface AccountSwitchBlockV2Data {\n from_logo?: LogoRef\n to_logo?: LogoRef\n logo?: LogoRef\n}\n\n// StepChart Block\nexport interface StepChartBlockData {\n completed_steps: number\n label_1: string\n label_2?: string\n}\n\n//Budgets Blocks\nexport enum BudgetTierType {\n LOW_BUDGET_TIER = 'LOW',\n MEDIUM_BUDGET_TIER = 'MEDIUM',\n OFF_TRACK_BUDGET_TIER = 'OFF_TRACK',\n}\n\nexport type BudgetTierValue = `${BudgetTierType}`\n\nexport interface BudgetLocalizedPayload {\n primary_text?: string\n amount_left_label?: string\n spent_label?: string\n budgeted_label?: string\n}\n\nexport interface BudgetBlockData {\n budget_percent: number\n budget_tier: BudgetTierValue\n category_guid?: string\n merchant_guid?: string\n spent_amount: number\n budgeted_amount: number\n localized_payload: BudgetLocalizedPayload\n}\n\nexport interface SVGImageBlockData {\n isCIBC?: boolean\n}\n\n// TransactionDetails Action Block\n// The drawer's subject is `InsightsPayload.primary_transaction_guid`; only action configuration\n// lives here.\nexport interface TransactionDetailsBlockData {\n /** `TopActions` member names, e.g. `['Category', 'Date', 'Memo']`. Omit for the defaults. */\n top_actions?: string[]\n /** `BottomActions` member names, e.g. `['MerchantBudget', 'HideTransaction']`. Omit for defaults. */\n bottom_actions?: string[]\n}\n\n// Credit Utilization action block. The per-card rows are the beat's `data_series` table\n// (`guid`, `label`, `amount`, `total_amount`, `percentage`), carried on `CommonProps.data_series`.\nexport interface CreditUtilizationBlockData {\n accounts_balance_sum?: number\n accounts_credit_limit_sum?: number\n credit_utilization_percentage?: number\n}\n\n// Merchant block `instance_slot.data`; `primary_text` is ditto's name.\nexport interface MerchantBlockData {\n merchant_name?: string\n logo?: LogoRef\n amount?: number\n /** Pre-localized eyebrow; ditto sends `header_text`. */\n date?: string\n header_text?: string\n status_text?: string\n logos?: LogoRef[]\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"InsightsInstanceSlotData.es.js","names":[],"sources":["../../../src/core/types/InsightsInstanceSlotData.ts"],"sourcesContent":["import type { DataSeries, Legends, LogoRef } from '../../core'\n\nexport interface InsightsInstanceSlotData\n extends\n Partial<BudgetBlockData>,\n Partial<DonutChartBlockData>,\n Partial<ImageBlockData>,\n Partial<AccountBlockData>,\n Partial<SaveExtraBlockData>,\n Partial<StepChartBlockData>,\n Partial<SVGImageBlockData>,\n Partial<AccountSwitchBlockData>,\n Partial<TransactionDetailsBlockData>,\n Partial<CreditUtilizationBlockData>,\n Partial<MerchantBlockData>,\n Partial<CommonProps> {}\n\n//when any of the type is used more than one times, we can use the common props\ninterface CommonProps {\n amount?: number\n ariaLabel?: string\n date?: string\n legends?: Legends[]\n category_guid?: string\n data_series?: DataSeries | DataSet[]\n transaction_guids?: string[]\n account_guids?: string[]\n primary_transaction_guid?: string\n}\n\n//BarChart Block: `instance_slot.data` (Insights 2.0)\nexport interface BarChartBlockData {\n series?: DataSeries\n category_guid?: string\n average_amount?: number\n /** [0] monthly amount, [1] trend. */\n additional_data?: Legends[]\n}\n\n//DonutChart Block: `instance_slot.data` (Insights 2.0) — the same shape V1 sent as `instance_slot_data`.\n/** The donut's centre: the total and its caption (\"$6,306\" / \"Total\"). */\nexport interface DonutChartMain {\n value: string | number\n value_type: string\n label: string\n /** The embedded donut's shorter caption (Credit Card Close to Limit: \"Remains\"). */\n compact_label?: string\n}\nexport interface DonutChartBlockData {\n main: DonutChartMain\n /** The category whose colour fills the primary slice (Cost of Living to Income: Housing). */\n category_guid?: string\n /** Legend rows beside the donut: a label, its amount and an optional share (\"$5,550.00 (88%)\"). */\n legends?: Legends[]\n}\n\n//DoubleBarChart Block\n// TODO : This has to be revisited again to update the below types based on API response once we have the final shape of the data_series for double bar chart from BE\nexport interface LegendProps extends Legends {\n amount: number\n formattedAmount: string\n label: string\n color?: string\n}\n\nexport interface DataSet extends DataSeries {\n ariaLabelComparison: string\n ariaLabelMain: string\n comparison: number\n // The comparison bar's transaction guids (data_series aggregated_guids), for the drawer filter.\n comparisonGuids?: string[]\n // The month's 'yyyy-MM-dd' date (the main row's).\n date?: string\n formattedComparison: string\n formattedMain: string\n label: string\n main: number\n // The main bar's transaction guids (data_series aggregated_guids), for the drawer filter.\n mainGuids?: string[]\n}\n\n//DoubleProgressBar Block\n\n//Image Block\nexport interface ImageBlockData {\n image: string\n}\n\n//Account Block\nexport interface AccountBlockData {\n sub_text: string\n institution_guid?: string\n institution_name?: string\n icon_name?: string\n /** Header bar text (standard card), or the colored category strip label (deposit cards). */\n header_text?: string\n // Deposit variants (Unified Deposit, Unified Deposit Emergency Fund, Savings Account Deposit)\n /** Merchant guid — renders a real merchant logo in the deposit card when present. */\n merchant_guid?: string\n /** Merchant display name — logo alt text and the payer line under the amount. */\n merchant_name?: string\n /** Secondary label beside the amount, e.g. `On {date}, you saved` or `Balance as of MM/DD/YY`. */\n label?: string\n}\n\nexport interface SaveExtraBlockData {\n /** Styled segments `[lead-in, amount digits, trailing copy]`, e.g. `['Save an extra', '100', 'to help your funds grow']`. */\n primary_text?: string[]\n /** Styled segments `[projected balance, caption]`, e.g. `['$8,313.87', 'After payday & projected expenses']`. */\n secondary_text?: string[]\n /** MakeTransfer drilldown: available balance (both variants). */\n available_balance?: number\n /** SAVE_ENOUGH_TO_LIVE_ON: average monthly spend. */\n avg_monthly_spend?: number\n /** SAVE_ENOUGH_TO_LIVE_ON: how long the balance lasts, overlaid on the timeline SVG (e.g. \"2 months, 11 days\"). */\n time_period?: string\n /** SAVE_AN_EXTRA_100: upcoming expenses (the \"Expenses\" figure). */\n upcoming_expenses?: number\n /** SAVE_AN_EXTRA_100: total remaining after expenses. */\n total_remaining?: number\n /** SAVE_ENOUGH_TO_LIVE_ON: date for the \"Your available balances as of {date}\" line. */\n date?: string\n}\n\n// AccountSwitch Block. State comes from `instance_slot.variant`, not a data flag.\nexport interface AccountSwitchBlockData {\n discovered_institution_guid: string\n discovered_institution_name: string\n held_institution_guid: string\n held_institution_name: string\n}\n\n// AccountSwitch Block: `instance_slot.data` (Insights 2.0, Discovered Accounts V2). Each slot is\n// optional: tupac omits `to_logo` when the user holds no FI-managed account. `logo` is the compact\n// card's (micro, notification) discovered institution.\nexport interface AccountSwitchBlockV2Data {\n from_logo?: LogoRef\n to_logo?: LogoRef\n logo?: LogoRef\n}\n\n// StepChart Block\nexport interface StepChartBlockData {\n completed_steps: number\n label_1: string\n label_2?: string\n}\n\n//Budgets Blocks\nexport enum BudgetTierType {\n LOW_BUDGET_TIER = 'LOW',\n MEDIUM_BUDGET_TIER = 'MEDIUM',\n OFF_TRACK_BUDGET_TIER = 'OFF_TRACK',\n}\n\nexport type BudgetTierValue = `${BudgetTierType}`\n\nexport interface BudgetLocalizedPayload {\n primary_text?: string\n amount_left_label?: string\n spent_label?: string\n budgeted_label?: string\n}\n\nexport interface BudgetBlockData {\n budget_percent: number\n budget_tier: BudgetTierValue\n category_guid?: string\n merchant_guid?: string\n spent_amount: number\n budgeted_amount: number\n localized_payload: BudgetLocalizedPayload\n}\n\nexport interface SVGImageBlockData {\n isCIBC?: boolean\n}\n\n// TransactionDetails Action Block\n// The drawer's subject is `InsightsPayload.primary_transaction_guid`; only action configuration\n// lives here.\nexport interface TransactionDetailsBlockData {\n /** `TopActions` member names, e.g. `['Category', 'Date', 'Memo']`. Omit for the defaults. */\n top_actions?: string[]\n /** `BottomActions` member names, e.g. `['MerchantBudget', 'HideTransaction']`. Omit for defaults. */\n bottom_actions?: string[]\n}\n\n// Credit Utilization action block. The per-card rows are the beat's `data_series` table\n// (`guid`, `label`, `amount`, `total_amount`, `percentage`), carried on `CommonProps.data_series`.\nexport interface CreditUtilizationBlockData {\n accounts_balance_sum?: number\n accounts_credit_limit_sum?: number\n credit_utilization_percentage?: number\n}\n\n// Merchant block `instance_slot.data`; `primary_text` is ditto's name.\nexport interface MerchantBlockData {\n merchant_name?: string\n logo?: LogoRef\n amount?: number\n /** Pre-localized eyebrow; ditto sends `header_text`. */\n date?: string\n header_text?: string\n status_text?: string\n logos?: LogoRef[]\n}\n"],"mappings":"AAqJA,IAAY,IAAL,0BAAA,GAAA;AACL,SAAA,EAAA,kBAAA,OACA,EAAA,qBAAA,UACA,EAAA,wBAAA;AACF,GAAA,CAAA,CAAA"}
|
|
@@ -3,72 +3,73 @@ import Y from "../../../common/utils/AccountDisplayName.es.js";
|
|
|
3
3
|
import { useCategoryStore as Z, useGlobalCopyStore as N, useInsightsV2Store as k, useSettingsStore as oo, useUserStore as eo } from "../../../common/context/hooks.es.js";
|
|
4
4
|
import V from "../../../common/components/Loader.es.js";
|
|
5
5
|
import to from "../../../common/components/CurrencyDialog.es.js";
|
|
6
|
-
import { useBeatActions as
|
|
7
|
-
import { useCtaHandler as
|
|
6
|
+
import { useBeatActions as io } from "../../beatActions.es.js";
|
|
7
|
+
import { useCtaHandler as no } from "../../ctaActions/useCtaAction.es.js";
|
|
8
8
|
import { useAnalyticsEvent as ro } from "../../analytics/useAnalyticsEvent.es.js";
|
|
9
9
|
import { useOpenedCta as so } from "../useOpenedCta.es.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { CreateBudgetDialog as ao } from "./CreateBudgetDialog.es.js";
|
|
11
|
+
import { AMOUNT_SETTINGS as co, CREATE_BUDGET_VARIANT as lo, findLowBalanceProfile as uo, isAmountInputVariant as w, resolveAmountInputVariant as mo, toInputValue as po } from "./layout.es.js";
|
|
12
12
|
import r from "react";
|
|
13
13
|
import { observer as M } from "mobx-react-lite";
|
|
14
|
-
import
|
|
15
|
-
import { H3 as fo, InstitutionLogo as
|
|
16
|
-
import { Icon as
|
|
17
|
-
import { jsx as e, jsxs as
|
|
14
|
+
import R from "@mui/material/Stack";
|
|
15
|
+
import { H3 as fo, InstitutionLogo as go, Text as B } from "@mxenabled/mxui";
|
|
16
|
+
import { Icon as yo } from "@mxenabled/mx-icons";
|
|
17
|
+
import { jsx as e, jsxs as $ } from "react/jsx-runtime";
|
|
18
18
|
import ho from "@mui/material/Dialog";
|
|
19
19
|
import _o from "@mui/material/IconButton";
|
|
20
|
-
var C = ({ children:
|
|
20
|
+
var C = ({ children: g, closeAriaLabel: i, heading: n, onClose: t }) => {
|
|
21
21
|
const s = r.useId();
|
|
22
22
|
return /* @__PURE__ */ e(ho, {
|
|
23
|
-
"aria-labelledby":
|
|
23
|
+
"aria-labelledby": n ? s : void 0,
|
|
24
24
|
maxWidth: "xs",
|
|
25
25
|
onClose: t,
|
|
26
26
|
open: !0,
|
|
27
|
-
|
|
27
|
+
sx: { "& .MuiDialog-paper": { borderRadius: (c) => `${c.shape.borderRadius}px` } },
|
|
28
|
+
children: /* @__PURE__ */ $(R, {
|
|
28
29
|
sx: {
|
|
29
30
|
gap: 12,
|
|
30
31
|
p: 24,
|
|
31
32
|
position: "relative"
|
|
32
33
|
},
|
|
33
34
|
children: [
|
|
34
|
-
|
|
35
|
+
n && /* @__PURE__ */ e(fo, {
|
|
35
36
|
id: s,
|
|
36
|
-
children:
|
|
37
|
+
children: n
|
|
37
38
|
}),
|
|
38
39
|
/* @__PURE__ */ e(_o, {
|
|
39
|
-
"aria-label":
|
|
40
|
+
"aria-label": i || "Close",
|
|
40
41
|
onClick: t,
|
|
41
42
|
sx: {
|
|
42
43
|
position: "absolute",
|
|
43
44
|
right: 8,
|
|
44
45
|
top: 18
|
|
45
46
|
},
|
|
46
|
-
children: /* @__PURE__ */ e(
|
|
47
|
+
children: /* @__PURE__ */ e(yo, {
|
|
47
48
|
name: "close",
|
|
48
49
|
sx: { color: "action.active" }
|
|
49
50
|
})
|
|
50
51
|
}),
|
|
51
|
-
|
|
52
|
+
g
|
|
52
53
|
]
|
|
53
54
|
})
|
|
54
55
|
});
|
|
55
|
-
},
|
|
56
|
-
const { common:
|
|
56
|
+
}, Go = M(function({ beat: i }) {
|
|
57
|
+
const { common: n } = N(), { closeActionDrawer: t } = k(), s = Z(), c = so(i), [l] = r.useState(() => mo(c)), d = l === lo;
|
|
57
58
|
return r.useEffect(() => {
|
|
58
59
|
d && !s.categoriesLoaded && s.loadCategories();
|
|
59
|
-
}, [s, d]), d ? s.categoriesLoaded ? /* @__PURE__ */ e(
|
|
60
|
-
closeAriaLabel:
|
|
60
|
+
}, [s, d]), d ? s.categoriesLoaded ? /* @__PURE__ */ e(ao, { beat: i }) : /* @__PURE__ */ e(C, {
|
|
61
|
+
closeAriaLabel: n?.close_aria,
|
|
61
62
|
onClose: t,
|
|
62
63
|
children: /* @__PURE__ */ e(V, {})
|
|
63
64
|
}) : /* @__PURE__ */ e(vo, {
|
|
64
|
-
beat:
|
|
65
|
+
beat: i,
|
|
65
66
|
variant: l
|
|
66
67
|
});
|
|
67
|
-
}), vo = M(function({ beat:
|
|
68
|
-
const { common: t, insights_feed: s } = N(), { closeActionDrawer: c } = k(), l = oo(), { userInsightProfile: d } = eo(),
|
|
68
|
+
}), vo = M(function({ beat: i, variant: n }) {
|
|
69
|
+
const { common: t, insights_feed: s } = N(), { closeActionDrawer: c } = k(), l = oo(), { userInsightProfile: d } = eo(), G = no(i, io()), S = ro(), u = s?.amount_input_modal, o = w(n) ? co[n] : void 0, m = !!o?.needsNotificationProfiles, y = {
|
|
69
70
|
insightProfile: d,
|
|
70
|
-
lowBalanceProfile: m ?
|
|
71
|
-
}, A = o?.read(
|
|
71
|
+
lowBalanceProfile: m ? uo(l.notificationProfiles, i.primary_account_guid) : void 0
|
|
72
|
+
}, A = o?.read(y), [F, H] = r.useState(m), p = r.useRef(!0);
|
|
72
73
|
r.useEffect(() => (p.current = !0, () => {
|
|
73
74
|
p.current = !1;
|
|
74
75
|
}), []), r.useEffect(() => {
|
|
@@ -76,15 +77,15 @@ var C = ({ children: y, closeAriaLabel: n, heading: i, onClose: t }) => {
|
|
|
76
77
|
p.current && H(!1);
|
|
77
78
|
});
|
|
78
79
|
}, [m, l]);
|
|
79
|
-
const [O, U] = r.useState(null), [I, b] = r.useState(!1), [j, h] = r.useState(!1), f = O ??
|
|
80
|
+
const [O, U] = r.useState(null), [I, b] = r.useState(!1), [j, h] = r.useState(!1), f = O ?? po(A);
|
|
80
81
|
if (F) return /* @__PURE__ */ e(C, {
|
|
81
82
|
closeAriaLabel: t?.close_aria,
|
|
82
83
|
onClose: c,
|
|
83
84
|
children: /* @__PURE__ */ e(V, {})
|
|
84
85
|
});
|
|
85
|
-
const a = w(
|
|
86
|
+
const a = w(n) ? u?.[n] : void 0, x = o ? u?.[o.errorKey] : void 0, D = !!a?.title && !!a.description && !!a.input_label && !!x && !!u?.save_error && !!t?.save_button && (!o?.hasCancel || !!t.cancel_button) && !!t.close_aria, z = !!o?.hasSource(y);
|
|
86
87
|
if (!u || !o || !a || !D || !z)
|
|
87
|
-
return console.warn(`amount_input_modal_block: ${u ? o ? D ? m ? "no low-balance profile for the account" : "user insight profile not set by the host" : `copy incomplete for "${
|
|
88
|
+
return console.warn(`amount_input_modal_block: ${u ? o ? D ? m ? "no low-balance profile for the account" : "user insight profile not set by the host" : `copy incomplete for "${n}"` : `unknown variant "${n}"` : "copy namespace missing"}`), /* @__PURE__ */ e(C, {
|
|
88
89
|
closeAriaLabel: t?.close_aria,
|
|
89
90
|
heading: t?.error_heading,
|
|
90
91
|
onClose: c,
|
|
@@ -92,11 +93,11 @@ var C = ({ children: y, closeAriaLabel: n, heading: i, onClose: t }) => {
|
|
|
92
93
|
});
|
|
93
94
|
const P = () => {
|
|
94
95
|
S(o.analytics.cancel), c();
|
|
95
|
-
}, { inputSelected: L } = o.analytics, E = o.hasEditCopy && !!A, T =
|
|
96
|
+
}, { inputSelected: L } = o.analytics, E = o.hasEditCopy && !!A, T = i.primary_account ? Y(i.primary_account) : "", _ = o.isValid(f), K = f !== "" && !_, W = async () => {
|
|
96
97
|
if (!_ || I) return;
|
|
97
98
|
const v = Number(f);
|
|
98
99
|
b(!0), h(!1);
|
|
99
|
-
const [q, J] = o.save(v,
|
|
100
|
+
const [q, J] = o.save(v, y), Q = await G(q, J, { analytics: o.analytics.save });
|
|
100
101
|
p.current && (b(!1), Q ? c() : h(!0));
|
|
101
102
|
};
|
|
102
103
|
return /* @__PURE__ */ e(to, {
|
|
@@ -118,15 +119,15 @@ var C = ({ children: y, closeAriaLabel: n, heading: i, onClose: t }) => {
|
|
|
118
119
|
isPrimaryDisabled: I || !_,
|
|
119
120
|
primaryText: t.save_button,
|
|
120
121
|
secondaryText: o.hasCancel ? t.cancel_button : void 0,
|
|
121
|
-
subtitle: o.showsAccount &&
|
|
122
|
+
subtitle: o.showsAccount && i.primary_account ? /* @__PURE__ */ $(R, {
|
|
122
123
|
sx: {
|
|
123
124
|
alignItems: "center",
|
|
124
125
|
flexDirection: "row",
|
|
125
126
|
gap: 8
|
|
126
127
|
},
|
|
127
|
-
children: [/* @__PURE__ */ e(
|
|
128
|
+
children: [/* @__PURE__ */ e(go, {
|
|
128
129
|
alt: "",
|
|
129
|
-
institutionGuid:
|
|
130
|
+
institutionGuid: i.primary_account.institution_guid ?? "",
|
|
130
131
|
size: 16
|
|
131
132
|
}), /* @__PURE__ */ e(B, {
|
|
132
133
|
color: "text.secondary",
|
|
@@ -140,7 +141,7 @@ var C = ({ children: y, closeAriaLabel: n, heading: i, onClose: t }) => {
|
|
|
140
141
|
});
|
|
141
142
|
});
|
|
142
143
|
export {
|
|
143
|
-
|
|
144
|
+
Go as AmountInputModalBlock
|
|
144
145
|
};
|
|
145
146
|
|
|
146
147
|
//# sourceMappingURL=AmountInputModalBlock.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AmountInputModalBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.tsx"],"sourcesContent":["import React from 'react'\n\nimport Stack from '@mui/material/Stack'\n\nimport MuiDialog from '@mui/material/Dialog'\nimport IconButton from '@mui/material/IconButton'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { H3, InstitutionLogo, Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport {\n CurrencyDialog,\n Loader,\n buildDynamicCopy,\n useCategoryStore,\n useGlobalCopyStore,\n useInsightsV2Store,\n useSettingsStore,\n useUserStore,\n} from '../../../common'\nimport getAccountDisplayName from '../../../common/utils/AccountDisplayName'\nimport { useAnalyticsEvent } from '../../analytics'\nimport { useBeatActions } from '../../beatActions'\nimport { useCtaHandler } from '../../ctaActions'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { useOpenedCta } from '../useOpenedCta'\n\nimport { CreateBudgetDialog } from './CreateBudgetDialog'\nimport {\n AMOUNT_SETTINGS,\n CREATE_BUDGET_VARIANT,\n findLowBalanceProfile,\n isAmountInputVariant,\n resolveAmountInputVariant,\n toInputValue,\n} from './layout'\n\n/** Dialog frame for the formless states: loading and a non-retriable problem. */\nconst StatusDialog = ({\n children,\n closeAriaLabel,\n heading,\n onClose,\n}: React.PropsWithChildren<{ closeAriaLabel?: string; heading?: string; onClose: () => void }>) => {\n const headingId = React.useId()\n\n return (\n <MuiDialog\n aria-labelledby={heading ? headingId : undefined}\n maxWidth=\"xs\"\n onClose={onClose}\n open={true}\n >\n <Stack sx={{ gap: 12, p: 24, position: 'relative' }}>\n {heading && <H3 id={headingId}>{heading}</H3>}\n <IconButton\n aria-label={closeAriaLabel || 'Close'}\n onClick={onClose}\n sx={{ position: 'absolute', right: 8, top: 18 }}\n >\n <Icon name=\"close\" sx={{ color: 'action.active' }} />\n </IconButton>\n {children}\n </Stack>\n </MuiDialog>\n )\n}\n\n/** `amount_input_modal_block`: one amount or percentage setting in a modal, picked by the CTA variant. */\nexport const AmountInputModalBlock = observer(function AmountInputModalBlock({\n beat,\n}: ActionBlockProps) {\n const { common: commonCopy } = useGlobalCopyStore()\n const { closeActionDrawer } = useInsightsV2Store()\n const categoryStore = useCategoryStore()\n const openedCta = useOpenedCta(beat)\n // Read once on open: a refreshed beat must not swap the dialog under its snackbar.\n const [variant] = React.useState(() => resolveAmountInputVariant(openedCta))\n const isCreateBudget = variant === CREATE_BUDGET_VARIANT\n\n // The create dialog names the category, so it waits for the category store.\n React.useEffect(() => {\n if (isCreateBudget && !categoryStore.categoriesLoaded) void categoryStore.loadCategories()\n }, [categoryStore, isCreateBudget])\n\n if (!isCreateBudget) return <AmountSettingDialog beat={beat} variant={variant} />\n\n return categoryStore.categoriesLoaded ? (\n <CreateBudgetDialog beat={beat} />\n ) : (\n <StatusDialog closeAriaLabel={commonCopy?.close_aria} onClose={closeActionDrawer}>\n <Loader />\n </StatusDialog>\n )\n})\n\n/** One amount or percentage setting, per its `AMOUNT_SETTINGS` entry (`AMOUNT_INPUT_VARIANTS`). */\nconst AmountSettingDialog = observer(function AmountSettingDialog({\n beat,\n variant,\n}: ActionBlockProps & { variant?: string }) {\n const { common: commonCopy, insights_feed: insightsFeedCopy } = useGlobalCopyStore()\n const { closeActionDrawer } = useInsightsV2Store()\n const settingsStore = useSettingsStore()\n const { userInsightProfile } = useUserStore()\n const runHandler = useCtaHandler(beat, useBeatActions())\n const fireAnalyticsEvent = useAnalyticsEvent()\n\n const copy = insightsFeedCopy?.amount_input_modal\n const setting = isAmountInputVariant(variant) ? AMOUNT_SETTINGS[variant] : undefined\n const needsNotificationProfiles = !!setting?.needsNotificationProfiles\n\n const sources = {\n insightProfile: userInsightProfile,\n lowBalanceProfile: needsNotificationProfiles\n ? findLowBalanceProfile(settingsStore.notificationProfiles, beat.primary_account_guid)\n : undefined,\n }\n const savedAmount = setting?.read(sources)\n\n // Mounting is the open, so profiles reload here and the threshold prefills as saved now.\n const [isLoadingProfiles, setIsLoadingProfiles] = React.useState(needsNotificationProfiles)\n // False once unmounted: a save that resolves after the user closed the dialog must not close\n // (or update) whatever action session is open by then.\n const isMounted = React.useRef(true)\n\n React.useEffect(() => {\n isMounted.current = true\n\n return () => {\n isMounted.current = false\n }\n }, [])\n\n React.useEffect(() => {\n if (!needsNotificationProfiles) return\n\n void settingsStore.loadNotificationProfiles().finally(() => {\n if (isMounted.current) setIsLoadingProfiles(false)\n })\n }, [needsNotificationProfiles, settingsStore])\n\n // `null` until the user types: the field shows the saved amount until then.\n const [typed, setTyped] = React.useState<string | null>(null)\n const [isSaving, setIsSaving] = React.useState(false)\n const [saveFailed, setSaveFailed] = React.useState(false)\n\n const value = typed ?? toInputValue(savedAmount)\n\n if (isLoadingProfiles) {\n return (\n <StatusDialog closeAriaLabel={commonCopy?.close_aria} onClose={closeActionDrawer}>\n <Loader />\n </StatusDialog>\n )\n }\n\n // Copy ships separately (see the doc's Rollout order), so check every string the form renders:\n // a partial ship falls to the error dialog instead of throwing mid-render.\n const variantCopy = isAmountInputVariant(variant) ? copy?.[variant] : undefined\n const errorCopy = setting ? copy?.[setting.errorKey] : undefined\n const hasCopy =\n !!variantCopy?.title &&\n !!variantCopy.description &&\n !!variantCopy.input_label &&\n !!errorCopy &&\n !!copy?.save_error &&\n !!commonCopy?.save_button &&\n (!setting?.hasCancel || !!commonCopy.cancel_button) &&\n !!commonCopy.close_aria\n const hasProfile = !!setting?.hasSource(sources)\n\n if (!copy || !setting || !variantCopy || !hasCopy || !hasProfile) {\n // One message to the user; distinct warnings so a rollout problem can be traced to its cause.\n console.warn(\n `amount_input_modal_block: ${\n !copy\n ? 'copy namespace missing'\n : !setting\n ? `unknown variant \"${variant}\"`\n : !hasCopy\n ? `copy incomplete for \"${variant}\"`\n : needsNotificationProfiles\n ? 'no low-balance profile for the account'\n : 'user insight profile not set by the host'\n }`,\n )\n\n return (\n <StatusDialog\n closeAriaLabel={commonCopy?.close_aria}\n heading={commonCopy?.error_heading}\n onClose={closeActionDrawer}\n >\n <Text>{commonCopy?.error_message}</Text>\n </StatusDialog>\n )\n }\n\n // Trigger 4 — user dismissed without saving (close icon, Cancel button, backdrop). Pulse\n // parity: EditThreshold.js close button / EditSafetyNet.js cancel button.\n const handleDismiss = () => {\n fireAnalyticsEvent(setting.analytics.cancel)\n closeActionDrawer()\n }\n\n const { inputSelected } = setting.analytics\n const isEdit = setting.hasEditCopy && !!savedAmount\n const accountName = beat.primary_account ? getAccountDisplayName(beat.primary_account) : ''\n const isValid = setting.isValid(value)\n const isInvalid = value !== '' && !isValid\n\n const handleSave = async () => {\n // Guarded here too, not only by the disabled button: Enter submits the dialog's form directly.\n if (!isValid || isSaving) return\n\n const amount = Number(value)\n\n setIsSaving(true)\n setSaveFailed(false)\n\n // Trigger 2: save analytics ride the handler run, fired only on success.\n const [handler, params] = setting.save(amount, sources)\n const ok = await runHandler(handler, params, { analytics: setting.analytics.save })\n\n if (!isMounted.current) return\n\n setIsSaving(false)\n\n if (ok) closeActionDrawer()\n else setSaveFailed(true)\n }\n\n return (\n <CurrencyDialog\n closeAriaLabel={commonCopy.close_aria}\n // Only strings and the <strong> go in, so the result is renderable (the helper's type also\n // admits raw DOM nodes).\n content={\n buildDynamicCopy(\n (isEdit && variantCopy.description_edit) || variantCopy.description,\n <strong key=\"account\">{accountName}</strong>,\n ) as React.ReactNode\n }\n errorText={isInvalid ? errorCopy : saveFailed ? copy.save_error : undefined}\n handleInputChange={(next) => {\n setTyped(next)\n setSaveFailed(false)\n }}\n handleInputClick={inputSelected ? () => fireAnalyticsEvent(inputSelected) : undefined}\n handleModalClose={handleDismiss}\n handlePrimaryAction={() => void handleSave()}\n handleSecondaryAction={handleDismiss}\n inputLabel={variantCopy.input_label}\n inputValue={value}\n isOpen={true}\n isPrimaryDisabled={isSaving || !isValid}\n primaryText={commonCopy.save_button}\n secondaryText={setting.hasCancel ? commonCopy.cancel_button : undefined}\n subtitle={\n setting.showsAccount && beat.primary_account ? (\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 8 }}>\n {/* Decorative: the account name is the visible text beside it. */}\n <InstitutionLogo\n alt=\"\"\n institutionGuid={beat.primary_account.institution_guid ?? ''}\n size={16}\n />\n <Text color=\"text.secondary\" uppercase={true} variant=\"body2\">\n {accountName}\n </Text>\n </Stack>\n ) : undefined\n }\n title={(isEdit && variantCopy.title_edit) || variantCopy.title}\n unit={setting.unit}\n />\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAuCA,IAAM,IAAA,CAAgB,EACpB,UAAA,GACA,gBAAA,GACA,SAAA,GACA,SAAA,EAAA,MACiG;AACjG,QAAM,IAAY,EAAM,MAAM;AAE9B,SACE,gBAAA,EAAC,IAAD;AAAA,IACE,mBAAiB,IAAU,IAAY;AAAA,IACvC,UAAS;AAAA,IACA,SAAA;AAAA,IACT,MAAM;AAAA,IAEN,UAAA,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI;AAAA,QAAE,KAAK;AAAA,QAAI,GAAG;AAAA,QAAI,UAAU;AAAA,MAAW;AAAA,MAAlD,UAAA;AAAA,QACG,KAAW,gBAAA,EAAC,IAAD;AAAA,UAAI,IAAI;AAAA,UAAY,UAAA;AAAA,QAAY,CAAA;AAAA,QAC5C,gBAAA,EAAC,IAAD;AAAA,UACE,cAAY,KAAkB;AAAA,UAC9B,SAAS;AAAA,UACT,IAAI;AAAA,YAAE,UAAU;AAAA,YAAY,OAAO;AAAA,YAAG,KAAK;AAAA,UAAG;AAAA,UAE9C,UAAA,gBAAA,EAAC,IAAD;AAAA,YAAM,MAAK;AAAA,YAAQ,IAAI,EAAE,OAAO,gBAAgB;AAAA,UAAI,CAAA;AAAA,QAC1C,CAAA;AAAA,QACX;AAAA,MACI;AAAA;EACE,CAAA;AAEf,GAGa,KAAwB,EAAS,SAA+B,EAC3E,MAAA,EAAA,GACmB;AACnB,QAAM,EAAE,QAAQ,EAAA,IAAe,EAAmB,GAC5C,EAAE,mBAAA,EAAA,IAAsB,EAAmB,GAC3C,IAAgB,EAAiB,GACjC,IAAY,GAAa,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AY,EAAW,gBAAgB;AAAA,IAC9D,UACE,EAAQ,gBAAgB,EAAK,kBAC3B,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI;AAAA,QAAE,YAAY;AAAA,QAAU,eAAe;AAAA,QAAO,KAAK;AAAA,MAAE;AAAA,MAAhE,UAAA,CAEE,gBAAA,EAAC,IAAD;AAAA,QACE,KAAI;AAAA,QACJ,iBAAiB,EAAK,gBAAgB,oBAAoB;AAAA,QAC1D,MAAM;AAAA,MACP,CAAA,GACD,gBAAA,EAAC,GAAD;AAAA,QAAM,OAAM;AAAA,QAAiB,WAAW;AAAA,QAAM,SAAQ;AAAA,QACnD,UAAA;AAAA,MACG,CAAA,CACD;AAAA,IACL,CAAA,IAAA;AAAA,IAEN,OAAQ,KAAU,EAAY,cAAe,EAAY;AAAA,IACzD,MAAM,EAAQ;AAAA,EACf,CAAA;AAEL,CAAC"}
|
|
1
|
+
{"version":3,"file":"AmountInputModalBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.tsx"],"sourcesContent":["import React from 'react'\n\nimport Stack from '@mui/material/Stack'\n\nimport MuiDialog from '@mui/material/Dialog'\nimport IconButton from '@mui/material/IconButton'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { H3, InstitutionLogo, Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport {\n CurrencyDialog,\n Loader,\n buildDynamicCopy,\n useCategoryStore,\n useGlobalCopyStore,\n useInsightsV2Store,\n useSettingsStore,\n useUserStore,\n} from '../../../common'\nimport getAccountDisplayName from '../../../common/utils/AccountDisplayName'\nimport { useAnalyticsEvent } from '../../analytics'\nimport { useBeatActions } from '../../beatActions'\nimport { useCtaHandler } from '../../ctaActions'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { useOpenedCta } from '../useOpenedCta'\n\nimport { CreateBudgetDialog } from './CreateBudgetDialog'\nimport {\n AMOUNT_SETTINGS,\n CREATE_BUDGET_VARIANT,\n findLowBalanceProfile,\n isAmountInputVariant,\n resolveAmountInputVariant,\n toInputValue,\n} from './layout'\n\n/** Dialog frame for the formless states: loading and a non-retriable problem. */\nconst StatusDialog = ({\n children,\n closeAriaLabel,\n heading,\n onClose,\n}: React.PropsWithChildren<{ closeAriaLabel?: string; heading?: string; onClose: () => void }>) => {\n const headingId = React.useId()\n\n return (\n <MuiDialog\n aria-labelledby={heading ? headingId : undefined}\n maxWidth=\"xs\"\n onClose={onClose}\n open={true}\n // Same 4px theme radius as CurrencyDialog, so the loading/error states match the form.\n sx={{ '& .MuiDialog-paper': { borderRadius: (theme) => `${theme.shape.borderRadius}px` } }}\n >\n <Stack sx={{ gap: 12, p: 24, position: 'relative' }}>\n {heading && <H3 id={headingId}>{heading}</H3>}\n <IconButton\n aria-label={closeAriaLabel || 'Close'}\n onClick={onClose}\n sx={{ position: 'absolute', right: 8, top: 18 }}\n >\n <Icon name=\"close\" sx={{ color: 'action.active' }} />\n </IconButton>\n {children}\n </Stack>\n </MuiDialog>\n )\n}\n\n/** `amount_input_modal_block`: one amount or percentage setting in a modal, picked by the CTA variant. */\nexport const AmountInputModalBlock = observer(function AmountInputModalBlock({\n beat,\n}: ActionBlockProps) {\n const { common: commonCopy } = useGlobalCopyStore()\n const { closeActionDrawer } = useInsightsV2Store()\n const categoryStore = useCategoryStore()\n const openedCta = useOpenedCta(beat)\n // Read once on open: a refreshed beat must not swap the dialog under its snackbar.\n const [variant] = React.useState(() => resolveAmountInputVariant(openedCta))\n const isCreateBudget = variant === CREATE_BUDGET_VARIANT\n\n // The create dialog names the category, so it waits for the category store.\n React.useEffect(() => {\n if (isCreateBudget && !categoryStore.categoriesLoaded) void categoryStore.loadCategories()\n }, [categoryStore, isCreateBudget])\n\n if (!isCreateBudget) return <AmountSettingDialog beat={beat} variant={variant} />\n\n return categoryStore.categoriesLoaded ? (\n <CreateBudgetDialog beat={beat} />\n ) : (\n <StatusDialog closeAriaLabel={commonCopy?.close_aria} onClose={closeActionDrawer}>\n <Loader />\n </StatusDialog>\n )\n})\n\n/** One amount or percentage setting, per its `AMOUNT_SETTINGS` entry (`AMOUNT_INPUT_VARIANTS`). */\nconst AmountSettingDialog = observer(function AmountSettingDialog({\n beat,\n variant,\n}: ActionBlockProps & { variant?: string }) {\n const { common: commonCopy, insights_feed: insightsFeedCopy } = useGlobalCopyStore()\n const { closeActionDrawer } = useInsightsV2Store()\n const settingsStore = useSettingsStore()\n const { userInsightProfile } = useUserStore()\n const runHandler = useCtaHandler(beat, useBeatActions())\n const fireAnalyticsEvent = useAnalyticsEvent()\n\n const copy = insightsFeedCopy?.amount_input_modal\n const setting = isAmountInputVariant(variant) ? AMOUNT_SETTINGS[variant] : undefined\n const needsNotificationProfiles = !!setting?.needsNotificationProfiles\n\n const sources = {\n insightProfile: userInsightProfile,\n lowBalanceProfile: needsNotificationProfiles\n ? findLowBalanceProfile(settingsStore.notificationProfiles, beat.primary_account_guid)\n : undefined,\n }\n const savedAmount = setting?.read(sources)\n\n // Mounting is the open, so profiles reload here and the threshold prefills as saved now.\n const [isLoadingProfiles, setIsLoadingProfiles] = React.useState(needsNotificationProfiles)\n // False once unmounted: a save that resolves after the user closed the dialog must not close\n // (or update) whatever action session is open by then.\n const isMounted = React.useRef(true)\n\n React.useEffect(() => {\n isMounted.current = true\n\n return () => {\n isMounted.current = false\n }\n }, [])\n\n React.useEffect(() => {\n if (!needsNotificationProfiles) return\n\n void settingsStore.loadNotificationProfiles().finally(() => {\n if (isMounted.current) setIsLoadingProfiles(false)\n })\n }, [needsNotificationProfiles, settingsStore])\n\n // `null` until the user types: the field shows the saved amount until then.\n const [typed, setTyped] = React.useState<string | null>(null)\n const [isSaving, setIsSaving] = React.useState(false)\n const [saveFailed, setSaveFailed] = React.useState(false)\n\n const value = typed ?? toInputValue(savedAmount)\n\n if (isLoadingProfiles) {\n return (\n <StatusDialog closeAriaLabel={commonCopy?.close_aria} onClose={closeActionDrawer}>\n <Loader />\n </StatusDialog>\n )\n }\n\n // Copy ships separately (see the doc's Rollout order), so check every string the form renders:\n // a partial ship falls to the error dialog instead of throwing mid-render.\n const variantCopy = isAmountInputVariant(variant) ? copy?.[variant] : undefined\n const errorCopy = setting ? copy?.[setting.errorKey] : undefined\n const hasCopy =\n !!variantCopy?.title &&\n !!variantCopy.description &&\n !!variantCopy.input_label &&\n !!errorCopy &&\n !!copy?.save_error &&\n !!commonCopy?.save_button &&\n (!setting?.hasCancel || !!commonCopy.cancel_button) &&\n !!commonCopy.close_aria\n const hasProfile = !!setting?.hasSource(sources)\n\n if (!copy || !setting || !variantCopy || !hasCopy || !hasProfile) {\n // One message to the user; distinct warnings so a rollout problem can be traced to its cause.\n console.warn(\n `amount_input_modal_block: ${\n !copy\n ? 'copy namespace missing'\n : !setting\n ? `unknown variant \"${variant}\"`\n : !hasCopy\n ? `copy incomplete for \"${variant}\"`\n : needsNotificationProfiles\n ? 'no low-balance profile for the account'\n : 'user insight profile not set by the host'\n }`,\n )\n\n return (\n <StatusDialog\n closeAriaLabel={commonCopy?.close_aria}\n heading={commonCopy?.error_heading}\n onClose={closeActionDrawer}\n >\n <Text>{commonCopy?.error_message}</Text>\n </StatusDialog>\n )\n }\n\n // Trigger 4 — user dismissed without saving (close icon, Cancel button, backdrop). Pulse\n // parity: EditThreshold.js close button / EditSafetyNet.js cancel button.\n const handleDismiss = () => {\n fireAnalyticsEvent(setting.analytics.cancel)\n closeActionDrawer()\n }\n\n const { inputSelected } = setting.analytics\n const isEdit = setting.hasEditCopy && !!savedAmount\n const accountName = beat.primary_account ? getAccountDisplayName(beat.primary_account) : ''\n const isValid = setting.isValid(value)\n const isInvalid = value !== '' && !isValid\n\n const handleSave = async () => {\n // Guarded here too, not only by the disabled button: Enter submits the dialog's form directly.\n if (!isValid || isSaving) return\n\n const amount = Number(value)\n\n setIsSaving(true)\n setSaveFailed(false)\n\n // Trigger 2: save analytics ride the handler run, fired only on success.\n const [handler, params] = setting.save(amount, sources)\n const ok = await runHandler(handler, params, { analytics: setting.analytics.save })\n\n if (!isMounted.current) return\n\n setIsSaving(false)\n\n if (ok) closeActionDrawer()\n else setSaveFailed(true)\n }\n\n return (\n <CurrencyDialog\n closeAriaLabel={commonCopy.close_aria}\n // Only strings and the <strong> go in, so the result is renderable (the helper's type also\n // admits raw DOM nodes).\n content={\n buildDynamicCopy(\n (isEdit && variantCopy.description_edit) || variantCopy.description,\n <strong key=\"account\">{accountName}</strong>,\n ) as React.ReactNode\n }\n errorText={isInvalid ? errorCopy : saveFailed ? copy.save_error : undefined}\n handleInputChange={(next) => {\n setTyped(next)\n setSaveFailed(false)\n }}\n handleInputClick={inputSelected ? () => fireAnalyticsEvent(inputSelected) : undefined}\n handleModalClose={handleDismiss}\n handlePrimaryAction={() => void handleSave()}\n handleSecondaryAction={handleDismiss}\n inputLabel={variantCopy.input_label}\n inputValue={value}\n isOpen={true}\n isPrimaryDisabled={isSaving || !isValid}\n primaryText={commonCopy.save_button}\n secondaryText={setting.hasCancel ? commonCopy.cancel_button : undefined}\n subtitle={\n setting.showsAccount && beat.primary_account ? (\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 8 }}>\n {/* Decorative: the account name is the visible text beside it. */}\n <InstitutionLogo\n alt=\"\"\n institutionGuid={beat.primary_account.institution_guid ?? ''}\n size={16}\n />\n <Text color=\"text.secondary\" uppercase={true} variant=\"body2\">\n {accountName}\n </Text>\n </Stack>\n ) : undefined\n }\n title={(isEdit && variantCopy.title_edit) || variantCopy.title}\n unit={setting.unit}\n />\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAuCA,IAAM,IAAA,CAAgB,EACpB,UAAA,GACA,gBAAA,GACA,SAAA,GACA,SAAA,EAAA,MACiG;AACjG,QAAM,IAAY,EAAM,MAAM;AAE9B,SACE,gBAAA,EAAC,IAAD;AAAA,IACE,mBAAiB,IAAU,IAAY;AAAA,IACvC,UAAS;AAAA,IACA,SAAA;AAAA,IACT,MAAM;AAAA,IAEN,IAAI,EAAE,sBA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CAAA,CACD;AAAA,IACL,CAAA,IAAA;AAAA,IAEN,OAAQ,KAAU,EAAY,cAAe,EAAY;AAAA,IACzD,MAAM,EAAQ;AAAA,EACf,CAAA;AAEL,CAAC"}
|
|
@@ -24,7 +24,7 @@ export declare const resolveAmountInputVariant: (cta?: {
|
|
|
24
24
|
}) => string | undefined;
|
|
25
25
|
/** Whole dollars from 1 to `MAX_AMOUNT`, as pulse v1 accepted for its dollar settings. */
|
|
26
26
|
export declare const isWholeAmount: (value: string) => boolean;
|
|
27
|
-
/** The user's credit-limit alert as a whole 1-100 percent, else the default; the
|
|
27
|
+
/** The user's credit-limit alert as a whole 1-100 percent, else the default; the Edit Alert Limit dialog prefills it. */
|
|
28
28
|
export declare const resolveCreditLimitAlertPercent: (profile?: Pick<UserInsightProfile, "credit_card_close_to_limit_percentage"> | null) => number;
|
|
29
29
|
/** Where a setting's value can live; the dialog loads both and each variant reads its own. */
|
|
30
30
|
interface AmountSources {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AmountInputModalBlock/layout.ts"],"sourcesContent":["import type { NotificationProfile, UserInsightProfile } from '../../../core'\nimport { AccountNotificationTypes } from '../../../core/types/Notification'\nimport {\n ANALYTICS_EVENTS_CONFIG,\n type AnalyticsEventConfigEntry,\n} from '../../analytics/analyticsEventsConfig'\nimport type { CtaHandlerName } from '../../ctaActions/ctaHandlers'\nimport { actionBlocksKey } from '../../mappings/actionBlocksKey'\nimport { asNumber } from '../../blocks/slotReaders'\nimport type { CurrencyDialogUnit } from '../../../common/components'\n\n/** CTA variants `amount_input_modal_block` serves (ditto sets one on the beat's CTA). */\nexport const AMOUNT_INPUT_VARIANTS = {\n LOW_BALANCE_THRESHOLD: 'low_balance_threshold',\n SAFETY_NET: 'safety_net',\n CREDIT_LIMIT_PERCENTAGE: 'credit_limit_percentage',\n} as const\n\n/** Opens the Create Budget dialog instead of an amount setting (Category Spending). */\nexport const CREATE_BUDGET_VARIANT = 'create_budget'\n\nexport type AmountInputVariant = (typeof AMOUNT_INPUT_VARIANTS)[keyof typeof AMOUNT_INPUT_VARIANTS]\n\nexport const isAmountInputVariant = (variant?: string | null): variant is AmountInputVariant =>\n Object.values<string>(AMOUNT_INPUT_VARIANTS).includes(variant ?? '')\n\n/**\n * The variant the modal edits, from the CTA that opened it. ditto drives the shared\n * `amount_input_modal_block` by an explicit CTA variant, but gives Savings Opportunity's safety-net\n * reminder a dedicated `safety_net_block` with no variant, so there the block name selects it. An\n * explicit variant always wins (so an unknown one still falls to the block's \"unknown variant\" path).\n */\nexport const resolveAmountInputVariant = (cta?: {\n block?: string | null\n variant?: string | null\n}): string | undefined => {\n if (cta?.variant) return cta.variant\n if (cta?.block === actionBlocksKey.SAFETY_NET_ACTION_BLOCK)\n return AMOUNT_INPUT_VARIANTS.SAFETY_NET\n return undefined\n}\n\n/** Pulse v1's upper bound for a safety net; applied to both dollar settings. */\nconst MAX_AMOUNT = 1_000_000_000\n\nconst MAX_ALERT_PERCENT = 100\n\n/** A whole number from 1 to `max`, as pulse v1 validated its amount and threshold fields. */\nconst wholeNumberUpTo =\n (max: number) =>\n (value: string): boolean =>\n /^\\d+$/.test(value) && Number(value) >= 1 && Number(value) <= max\n\n/** Whole dollars from 1 to `MAX_AMOUNT`, as pulse v1 accepted for its dollar settings. */\nexport const isWholeAmount = wholeNumberUpTo(MAX_AMOUNT)\n\n/** tupac's default `credit_card_close_to_limit_percentage`, used when none (or an invalid one) is saved. */\nconst DEFAULT_CREDIT_LIMIT_ALERT_PERCENT = 75\n\n/** The user's credit-limit alert as a whole 1-100 percent, else the default; the dialog and the Spending header both read it. */\nexport const resolveCreditLimitAlertPercent = (\n profile?: Pick<UserInsightProfile, 'credit_card_close_to_limit_percentage'> | null,\n): number => {\n const saved = asNumber(profile?.credit_card_close_to_limit_percentage)\n // Rounded like the dialog's whole-number field, so a saved 60.6 shows 61 in both.\n const percent = saved === undefined ? undefined : Math.round(saved)\n return percent !== undefined && percent >= 1 && percent <= MAX_ALERT_PERCENT\n ? percent\n : DEFAULT_CREDIT_LIMIT_ALERT_PERCENT\n}\n\n/** A user insight profile field a variant prefills from and saves to. */\ntype InsightProfileField = keyof Pick<\n UserInsightProfile,\n 'savings_opportunity_minimum_checking_account_balance' | 'credit_card_close_to_limit_percentage'\n>\n\n/** Where a setting's value can live; the dialog loads both and each variant reads its own. */\ninterface AmountSources {\n insightProfile?: UserInsightProfile | null\n lowBalanceProfile?: NotificationProfile\n}\n\n/** A saved value read and written on a user insight profile field. */\nconst insightProfileField = (field: InsightProfileField) => ({\n read: ({ insightProfile }: AmountSources) => insightProfile?.[field],\n save: (amount: number): [CtaHandlerName, Record<string, unknown>] => [\n 'updateUserInsightProfile',\n { fields: { [field]: amount } },\n ],\n hasSource: ({ insightProfile }: AmountSources) => !!insightProfile,\n needsNotificationProfiles: false,\n})\n\n/** The account's low-balance alert threshold, on its notification profile. */\nconst lowBalanceThreshold = {\n read: ({ lowBalanceProfile }: AmountSources) => lowBalanceProfile?.threshold,\n save: (\n amount: number,\n { lowBalanceProfile }: AmountSources,\n ): [CtaHandlerName, Record<string, unknown>] => [\n 'updateNotificationProfileThreshold',\n { profileGuid: lowBalanceProfile?.guid, threshold: amount },\n ],\n hasSource: ({ lowBalanceProfile }: AmountSources) => !!lowBalanceProfile,\n needsNotificationProfiles: true,\n}\n\n/** What one variant edits, how it validates and words its field, and the pulse analytics it fires. */\ninterface AmountSetting {\n /** The saved value, from the setting's own source. */\n read: (sources: AmountSources) => number | null | undefined\n /** The CTA handler and params that save `amount`. */\n save: (amount: number, sources: AmountSources) => [CtaHandlerName, Record<string, unknown>]\n /** Whether the source the setting edits is loaded; without it the dialog shows the plain error. */\n hasSource: (sources: AmountSources) => boolean\n /** The source is the account's notification profile, which the dialog reloads on open. */\n needsNotificationProfiles: boolean\n isValid: (value: string) => boolean\n /** The `insights_feed.amount_input_modal` key of the validation message. */\n errorKey: 'whole_number_error' | 'percentage_error'\n unit: CurrencyDialogUnit\n hasCancel: boolean\n /** Switches to `title_edit` / `description_edit` once a value is saved. */\n hasEditCopy: boolean\n /** The account line under the title. */\n showsAccount: boolean\n analytics: {\n save: AnalyticsEventConfigEntry\n cancel: AnalyticsEventConfigEntry\n /** Pulse fires input-selected for the threshold dialogs only (EditThreshold.js). */\n inputSelected?: AnalyticsEventConfigEntry\n }\n}\n\nconst THRESHOLD_ANALYTICS = {\n save: ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_SAVE,\n cancel: ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_CANCELED,\n inputSelected: ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_INPUT_SELECTED,\n}\n\n/** Per-variant behaviour of the amount setting dialog; a new variant adds an entry here. */\nexport const AMOUNT_SETTINGS: Record<AmountInputVariant, AmountSetting> = {\n [AMOUNT_INPUT_VARIANTS.LOW_BALANCE_THRESHOLD]: {\n ...lowBalanceThreshold,\n isValid: isWholeAmount,\n errorKey: 'whole_number_error',\n unit: 'currency',\n hasCancel: true,\n hasEditCopy: false,\n showsAccount: true,\n analytics: THRESHOLD_ANALYTICS,\n },\n [AMOUNT_INPUT_VARIANTS.SAFETY_NET]: {\n ...insightProfileField('savings_opportunity_minimum_checking_account_balance'),\n isValid: isWholeAmount,\n errorKey: 'whole_number_error',\n unit: 'currency',\n hasCancel: false,\n hasEditCopy: true,\n showsAccount: false,\n analytics: {\n save: ANALYTICS_EVENTS_CONFIG.EDIT_SAFETY_NET_SAVE,\n cancel: ANALYTICS_EVENTS_CONFIG.EDIT_SAFETY_NET_CANCEL,\n },\n },\n [AMOUNT_INPUT_VARIANTS.CREDIT_LIMIT_PERCENTAGE]: {\n ...insightProfileField('credit_card_close_to_limit_percentage'),\n // Same rule as the Spending header's marker, so the field and the marker always agree.\n read: ({ insightProfile }) => resolveCreditLimitAlertPercent(insightProfile),\n isValid: wholeNumberUpTo(MAX_ALERT_PERCENT),\n errorKey: 'percentage_error',\n unit: 'percent',\n hasCancel: true,\n hasEditCopy: false,\n showsAccount: false,\n analytics: THRESHOLD_ANALYTICS,\n },\n}\n\n/** A saved amount as the field's starting text; nothing saved (or zero) starts empty. */\nexport const toInputValue = (amount?: number | null): string =>\n amount ? String(Math.round(amount)) : ''\n\n/** The account's low-balance alert profile, which holds the threshold (as pulse v1 looked it up). */\nexport const findLowBalanceProfile = (\n profiles: NotificationProfile[],\n accountGuid?: string | null,\n): NotificationProfile | undefined =>\n accountGuid\n ? profiles.find(\n (profile) =>\n profile.entity_guid === accountGuid &&\n profile.notification_type === AccountNotificationTypes.AccountBalanceLow,\n )\n : undefined\n"],"mappings":";;;;AAYA,IAAa,IAAwB;AAAA,EACnC,uBAAuB;AAAA,EACvB,YAAY;AAAA,EACZ,yBAAyB;AAC3B,GAGa,IAAwB,iBAIxB,IAAA,CAAwB,MACnC,OAAO,OAAe,CAAqB,EAAE,SAAS,KAAW,EAAE,GAQxD,IAAA,CAA6B,MAGhB;AACxB,MAAI,GAAK,QAAS,QAAO,EAAI;AAC7B,MAAI,GAAK,UAAU,EAAgB,wBACjC,QAAO,EAAsB;AAEjC,GAGM,IAAa,KAEb,IAAoB,KAGpB,IAAA,CACH,MAAA,CACA,MACC,QAAQ,KAAK,CAAK,KAAK,OAAO,CAAK,KAAK,KAAK,OAAO,CAAK,KAAK,GAGrD,IAAgB,EAAgB,CAAU,GAGjD,IAAqC,IAG9B,IAAA,CACX,MACW;AACX,QAAM,IAAQ,EAAS,GAAS,qCAAqC,GAE/D,IAAU,MAAU,SAAY,SAAY,KAAK,MAAM,CAAK;AAClE,SAAO,MAAY,UAAa,KAAW,KAAK,KAAW,IACvD,IACA;AACN,GAeM,IAAA,CAAuB,OAAgC;AAAA,EAC3D,MAAA,CAAO,EAAE,gBAAA,EAAA,MAAoC,IAAiB,CAAA;AAAA,EAC9D,MAAA,CAAO,MAA8D,CACnE,4BACA,EAAE,QAAQ,EAAA,CAA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cAAc;AAAA,IACd,WAAW;AAAA,EACb;AACF,GAGa,IAAA,CAAgB,MAC3B,IAAS,OAAO,KAAK,MAAM,CAAM,CAAC,IAAI,IAG3B,IAAA,CACX,GACA,MAEA,IACI,EAAS,KAAA,CACN,MACC,EAAQ,gBAAgB,KACxB,EAAQ,sBAAsB,EAAyB,iBAC3D,IACA"}
|
|
1
|
+
{"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AmountInputModalBlock/layout.ts"],"sourcesContent":["import type { NotificationProfile, UserInsightProfile } from '../../../core'\nimport { AccountNotificationTypes } from '../../../core/types/Notification'\nimport {\n ANALYTICS_EVENTS_CONFIG,\n type AnalyticsEventConfigEntry,\n} from '../../analytics/analyticsEventsConfig'\nimport type { CtaHandlerName } from '../../ctaActions/ctaHandlers'\nimport { actionBlocksKey } from '../../mappings/actionBlocksKey'\nimport { asNumber } from '../../blocks/slotReaders'\nimport type { CurrencyDialogUnit } from '../../../common/components'\n\n/** CTA variants `amount_input_modal_block` serves (ditto sets one on the beat's CTA). */\nexport const AMOUNT_INPUT_VARIANTS = {\n LOW_BALANCE_THRESHOLD: 'low_balance_threshold',\n SAFETY_NET: 'safety_net',\n CREDIT_LIMIT_PERCENTAGE: 'credit_limit_percentage',\n} as const\n\n/** Opens the Create Budget dialog instead of an amount setting (Category Spending). */\nexport const CREATE_BUDGET_VARIANT = 'create_budget'\n\nexport type AmountInputVariant = (typeof AMOUNT_INPUT_VARIANTS)[keyof typeof AMOUNT_INPUT_VARIANTS]\n\nexport const isAmountInputVariant = (variant?: string | null): variant is AmountInputVariant =>\n Object.values<string>(AMOUNT_INPUT_VARIANTS).includes(variant ?? '')\n\n/**\n * The variant the modal edits, from the CTA that opened it. ditto drives the shared\n * `amount_input_modal_block` by an explicit CTA variant, but gives Savings Opportunity's safety-net\n * reminder a dedicated `safety_net_block` with no variant, so there the block name selects it. An\n * explicit variant always wins (so an unknown one still falls to the block's \"unknown variant\" path).\n */\nexport const resolveAmountInputVariant = (cta?: {\n block?: string | null\n variant?: string | null\n}): string | undefined => {\n if (cta?.variant) return cta.variant\n if (cta?.block === actionBlocksKey.SAFETY_NET_ACTION_BLOCK)\n return AMOUNT_INPUT_VARIANTS.SAFETY_NET\n return undefined\n}\n\n/** Pulse v1's upper bound for a safety net; applied to both dollar settings. */\nconst MAX_AMOUNT = 1_000_000_000\n\nconst MAX_ALERT_PERCENT = 100\n\n/** A whole number from 1 to `max`, as pulse v1 validated its amount and threshold fields. */\nconst wholeNumberUpTo =\n (max: number) =>\n (value: string): boolean =>\n /^\\d+$/.test(value) && Number(value) >= 1 && Number(value) <= max\n\n/** Whole dollars from 1 to `MAX_AMOUNT`, as pulse v1 accepted for its dollar settings. */\nexport const isWholeAmount = wholeNumberUpTo(MAX_AMOUNT)\n\n/** tupac's default `credit_card_close_to_limit_percentage`, used when none (or an invalid one) is saved. */\nconst DEFAULT_CREDIT_LIMIT_ALERT_PERCENT = 75\n\n/** The user's credit-limit alert as a whole 1-100 percent, else the default; the Edit Alert Limit dialog prefills it. */\nexport const resolveCreditLimitAlertPercent = (\n profile?: Pick<UserInsightProfile, 'credit_card_close_to_limit_percentage'> | null,\n): number => {\n const saved = asNumber(profile?.credit_card_close_to_limit_percentage)\n // Rounded like the dialog's whole-number field, so a saved 60.6 prefills 61.\n const percent = saved === undefined ? undefined : Math.round(saved)\n return percent !== undefined && percent >= 1 && percent <= MAX_ALERT_PERCENT\n ? percent\n : DEFAULT_CREDIT_LIMIT_ALERT_PERCENT\n}\n\n/** A user insight profile field a variant prefills from and saves to. */\ntype InsightProfileField = keyof Pick<\n UserInsightProfile,\n 'savings_opportunity_minimum_checking_account_balance' | 'credit_card_close_to_limit_percentage'\n>\n\n/** Where a setting's value can live; the dialog loads both and each variant reads its own. */\ninterface AmountSources {\n insightProfile?: UserInsightProfile | null\n lowBalanceProfile?: NotificationProfile\n}\n\n/** A saved value read and written on a user insight profile field. */\nconst insightProfileField = (field: InsightProfileField) => ({\n read: ({ insightProfile }: AmountSources) => insightProfile?.[field],\n save: (amount: number): [CtaHandlerName, Record<string, unknown>] => [\n 'updateUserInsightProfile',\n { fields: { [field]: amount } },\n ],\n hasSource: ({ insightProfile }: AmountSources) => !!insightProfile,\n needsNotificationProfiles: false,\n})\n\n/** The account's low-balance alert threshold, on its notification profile. */\nconst lowBalanceThreshold = {\n read: ({ lowBalanceProfile }: AmountSources) => lowBalanceProfile?.threshold,\n save: (\n amount: number,\n { lowBalanceProfile }: AmountSources,\n ): [CtaHandlerName, Record<string, unknown>] => [\n 'updateNotificationProfileThreshold',\n { profileGuid: lowBalanceProfile?.guid, threshold: amount },\n ],\n hasSource: ({ lowBalanceProfile }: AmountSources) => !!lowBalanceProfile,\n needsNotificationProfiles: true,\n}\n\n/** What one variant edits, how it validates and words its field, and the pulse analytics it fires. */\ninterface AmountSetting {\n /** The saved value, from the setting's own source. */\n read: (sources: AmountSources) => number | null | undefined\n /** The CTA handler and params that save `amount`. */\n save: (amount: number, sources: AmountSources) => [CtaHandlerName, Record<string, unknown>]\n /** Whether the source the setting edits is loaded; without it the dialog shows the plain error. */\n hasSource: (sources: AmountSources) => boolean\n /** The source is the account's notification profile, which the dialog reloads on open. */\n needsNotificationProfiles: boolean\n isValid: (value: string) => boolean\n /** The `insights_feed.amount_input_modal` key of the validation message. */\n errorKey: 'whole_number_error' | 'percentage_error'\n unit: CurrencyDialogUnit\n hasCancel: boolean\n /** Switches to `title_edit` / `description_edit` once a value is saved. */\n hasEditCopy: boolean\n /** The account line under the title. */\n showsAccount: boolean\n analytics: {\n save: AnalyticsEventConfigEntry\n cancel: AnalyticsEventConfigEntry\n /** Pulse fires input-selected for the threshold dialogs only (EditThreshold.js). */\n inputSelected?: AnalyticsEventConfigEntry\n }\n}\n\nconst THRESHOLD_ANALYTICS = {\n save: ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_SAVE,\n cancel: ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_CANCELED,\n inputSelected: ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_INPUT_SELECTED,\n}\n\n/** Per-variant behaviour of the amount setting dialog; a new variant adds an entry here. */\nexport const AMOUNT_SETTINGS: Record<AmountInputVariant, AmountSetting> = {\n [AMOUNT_INPUT_VARIANTS.LOW_BALANCE_THRESHOLD]: {\n ...lowBalanceThreshold,\n isValid: isWholeAmount,\n errorKey: 'whole_number_error',\n unit: 'currency',\n hasCancel: true,\n hasEditCopy: false,\n showsAccount: true,\n analytics: THRESHOLD_ANALYTICS,\n },\n [AMOUNT_INPUT_VARIANTS.SAFETY_NET]: {\n ...insightProfileField('savings_opportunity_minimum_checking_account_balance'),\n isValid: isWholeAmount,\n errorKey: 'whole_number_error',\n unit: 'currency',\n hasCancel: false,\n hasEditCopy: true,\n showsAccount: false,\n analytics: {\n save: ANALYTICS_EVENTS_CONFIG.EDIT_SAFETY_NET_SAVE,\n cancel: ANALYTICS_EVENTS_CONFIG.EDIT_SAFETY_NET_CANCEL,\n },\n },\n [AMOUNT_INPUT_VARIANTS.CREDIT_LIMIT_PERCENTAGE]: {\n ...insightProfileField('credit_card_close_to_limit_percentage'),\n // A saved 0, over-100 or missing value prefills tupac's 75 default.\n read: ({ insightProfile }) => resolveCreditLimitAlertPercent(insightProfile),\n isValid: wholeNumberUpTo(MAX_ALERT_PERCENT),\n errorKey: 'percentage_error',\n unit: 'percent',\n hasCancel: true,\n hasEditCopy: false,\n showsAccount: false,\n analytics: THRESHOLD_ANALYTICS,\n },\n}\n\n/** A saved amount as the field's starting text; nothing saved (or zero) starts empty. */\nexport const toInputValue = (amount?: number | null): string =>\n amount ? String(Math.round(amount)) : ''\n\n/** The account's low-balance alert profile, which holds the threshold (as pulse v1 looked it up). */\nexport const findLowBalanceProfile = (\n profiles: NotificationProfile[],\n accountGuid?: string | null,\n): NotificationProfile | undefined =>\n accountGuid\n ? profiles.find(\n (profile) =>\n profile.entity_guid === accountGuid &&\n profile.notification_type ===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