@mx-cartographer/experiences 9.7.160 → 9.7.161
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.d.ts +11 -1
- package/dist/common/components/CurrencyDialog.es.js +50 -44
- package/dist/common/components/CurrencyDialog.es.js.map +1 -1
- package/dist/common/components/index.d.ts +1 -1
- package/dist/core/types/localization/InsightsFeedCopy.d.ts +8 -0
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.d.ts +1 -1
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js +91 -91
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/layout.d.ts +42 -2
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/layout.es.js +75 -15
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/QuizMerchantBlock/QuizMerchantBlock.es.js +3 -3
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListBlock.es.js +64 -59
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListCreditLimitHeader.d.ts +11 -0
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListCreditLimitHeader.es.js +138 -0
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListCreditLimitHeader.es.js.map +1 -0
- package/dist/insights-v2/actionBlocks/TransactionListBlock/layout.d.ts +13 -0
- package/dist/insights-v2/actionBlocks/TransactionListBlock/layout.es.js +80 -63
- package/dist/insights-v2/actionBlocks/TransactionListBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChartBlock.es.js +14 -14
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChartBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/layout.d.ts +9 -2
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/layout.es.js +14 -7
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/utils.d.ts +7 -1
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/utils.es.js +14 -7
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/utils.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/SavingsSummaryBlock/SavingsSummaryBlock.es.js +1 -1
- package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/SVGImageBlock.es.js +4 -4
- package/dist/insights-v2/components/CompactInsightCard.es.js +164 -138
- package/dist/insights-v2/components/CompactInsightCard.es.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
## [9.7.161] - 11-16-2026
|
|
2
|
+
|
|
3
|
+
- **ADDED** - Credit Card Close to Limit experiences Insights V2 changes (WEC-2030)
|
|
4
|
+
|
|
1
5
|
## [9.7.160] - 11-16-2026
|
|
2
6
|
|
|
3
7
|
- **ADDED** - `ErrorBoundary` (`./common`) accepts an optional `fallback`; without it the default message is unchanged (WEC-2262)
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { ButtonProps } from '@mui/material/Button';
|
|
3
|
+
declare const UNIT_ADORNMENTS: {
|
|
4
|
+
currency: {
|
|
5
|
+
startAdornment: import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
};
|
|
7
|
+
percent: {
|
|
8
|
+
endAdornment: import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export type CurrencyDialogUnit = keyof typeof UNIT_ADORNMENTS;
|
|
3
12
|
interface CurrencyDialogProps {
|
|
4
13
|
closeAriaLabel: string;
|
|
5
14
|
/** Body copy; a node so callers can emphasise part of it (e.g. a bold account name). */
|
|
@@ -27,6 +36,7 @@ interface CurrencyDialogProps {
|
|
|
27
36
|
/** A line under the title, e.g. the account a setting applies to. */
|
|
28
37
|
subtitle?: ReactNode;
|
|
29
38
|
title: string;
|
|
39
|
+
unit?: CurrencyDialogUnit;
|
|
30
40
|
}
|
|
31
|
-
declare const CurrencyDialog: ({ closeAriaLabel, content, errorText, inputLabel, inputValue, isOpen, isPrimaryDisabled, handleInputChange, handleInputClick, handleModalClose, handlePrimaryAction, handleSecondaryAction, primaryColor, primaryText, secondaryColor, secondaryText, subtitle, title, }: CurrencyDialogProps) => import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
declare const CurrencyDialog: ({ closeAriaLabel, content, errorText, inputLabel, inputValue, isOpen, isPrimaryDisabled, handleInputChange, handleInputClick, handleModalClose, handlePrimaryAction, handleSecondaryAction, primaryColor, primaryText, secondaryColor, secondaryText, subtitle, title, unit, }: CurrencyDialogProps) => import("react/jsx-runtime").JSX.Element;
|
|
32
42
|
export default CurrencyDialog;
|
|
@@ -1,34 +1,43 @@
|
|
|
1
|
-
import { useScreenSize as
|
|
2
|
-
import
|
|
3
|
-
import { H3 as j, P as
|
|
1
|
+
import { useScreenSize as N } from "../hooks/useScreenSize.es.js";
|
|
2
|
+
import l from "@mui/material/Stack";
|
|
3
|
+
import { H3 as j, P as A } from "@mxenabled/mxui";
|
|
4
4
|
import f from "@mui/material/Button";
|
|
5
5
|
import { Icon as $ } from "@mxenabled/mx-icons";
|
|
6
|
-
import { jsx as o, jsxs as
|
|
6
|
+
import { jsx as o, jsxs as r } 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
10
|
import w from "@mui/material/DialogActions";
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
var
|
|
14
|
-
|
|
11
|
+
import h from "@mui/material/InputAdornment";
|
|
12
|
+
import P from "@mui/material/TextField";
|
|
13
|
+
var W = {
|
|
14
|
+
currency: { startAdornment: /* @__PURE__ */ o(h, {
|
|
15
|
+
position: "start",
|
|
16
|
+
children: "$"
|
|
17
|
+
}) },
|
|
18
|
+
percent: { endAdornment: /* @__PURE__ */ o(h, {
|
|
19
|
+
position: "end",
|
|
20
|
+
children: "%"
|
|
21
|
+
}) }
|
|
22
|
+
}, X = ({ closeAriaLabel: u, content: g, errorText: a, inputLabel: t, inputValue: e, isOpen: x, isPrimaryDisabled: b = !1, handleInputChange: C, handleInputClick: D, handleModalClose: c, handlePrimaryAction: m, handleSecondaryAction: y, primaryColor: v = "primary", primaryText: s, secondaryColor: I = "primary", secondaryText: n, subtitle: k, title: p, unit: S = "currency" }) => {
|
|
23
|
+
const d = b || (t ? !(e !== "" && e !== "0" && !isNaN(parseFloat(e ?? "0"))) : !1), { isSmallMobile: M } = N();
|
|
15
24
|
return /* @__PURE__ */ o(B, {
|
|
16
|
-
"aria-label":
|
|
25
|
+
"aria-label": p,
|
|
17
26
|
"aria-labelledby": "modal-title",
|
|
18
27
|
maxWidth: "xs",
|
|
19
|
-
onClose:
|
|
20
|
-
open:
|
|
28
|
+
onClose: c,
|
|
29
|
+
open: x,
|
|
21
30
|
role: "dialog",
|
|
22
31
|
sx: {
|
|
23
32
|
"& .MuiDialogContent-root": { p: 0 },
|
|
24
|
-
...
|
|
33
|
+
...M && { "& .MuiDialog-paper": { minWidth: "100%" } }
|
|
25
34
|
},
|
|
26
|
-
children: /* @__PURE__ */ o(F, { children: /* @__PURE__ */
|
|
27
|
-
onSubmit: (
|
|
28
|
-
|
|
35
|
+
children: /* @__PURE__ */ o(F, { children: /* @__PURE__ */ r("form", {
|
|
36
|
+
onSubmit: (i) => {
|
|
37
|
+
i.preventDefault(), d || m();
|
|
29
38
|
},
|
|
30
39
|
children: [
|
|
31
|
-
/* @__PURE__ */
|
|
40
|
+
/* @__PURE__ */ r(l, {
|
|
32
41
|
sx: {
|
|
33
42
|
alignItems: "center",
|
|
34
43
|
flexDirection: "row",
|
|
@@ -39,15 +48,15 @@ var X = ({ closeAriaLabel: h, content: g, errorText: a, inputLabel: r, inputValu
|
|
|
39
48
|
pr: 16,
|
|
40
49
|
pt: 24
|
|
41
50
|
},
|
|
42
|
-
children: [/* @__PURE__ */
|
|
51
|
+
children: [/* @__PURE__ */ r(l, {
|
|
43
52
|
sx: { gap: 4 },
|
|
44
53
|
children: [/* @__PURE__ */ o(j, {
|
|
45
54
|
id: "modal-title",
|
|
46
|
-
children:
|
|
47
|
-
}),
|
|
55
|
+
children: p
|
|
56
|
+
}), k]
|
|
48
57
|
}), /* @__PURE__ */ o(H, {
|
|
49
|
-
"aria-label":
|
|
50
|
-
onClick:
|
|
58
|
+
"aria-label": u,
|
|
59
|
+
onClick: c,
|
|
51
60
|
sx: {
|
|
52
61
|
minHeight: 24,
|
|
53
62
|
position: "absolute",
|
|
@@ -60,59 +69,56 @@ var X = ({ closeAriaLabel: h, content: g, errorText: a, inputLabel: r, inputValu
|
|
|
60
69
|
})
|
|
61
70
|
})]
|
|
62
71
|
}),
|
|
63
|
-
/* @__PURE__ */
|
|
72
|
+
/* @__PURE__ */ r(l, {
|
|
64
73
|
sx: {
|
|
65
74
|
gap: 24,
|
|
66
75
|
px: 24
|
|
67
76
|
},
|
|
68
|
-
children: [/* @__PURE__ */ o(
|
|
77
|
+
children: [/* @__PURE__ */ o(A, {
|
|
69
78
|
variant: "subtitle1",
|
|
70
79
|
children: g
|
|
71
|
-
}),
|
|
80
|
+
}), t && /* @__PURE__ */ o(P, {
|
|
72
81
|
autoFocus: !0,
|
|
73
82
|
error: !!a,
|
|
74
83
|
helperText: a,
|
|
75
84
|
inputMode: "decimal",
|
|
76
|
-
label:
|
|
77
|
-
onChange: ({ target: { value:
|
|
78
|
-
/^\d*\.?\d*$/.test(
|
|
85
|
+
label: t,
|
|
86
|
+
onChange: ({ target: { value: i } }) => {
|
|
87
|
+
/^\d*\.?\d*$/.test(i) && C?.(i);
|
|
79
88
|
},
|
|
80
|
-
onClick:
|
|
89
|
+
onClick: D,
|
|
81
90
|
slotProps: {
|
|
82
|
-
input:
|
|
83
|
-
position: "start",
|
|
84
|
-
children: "$"
|
|
85
|
-
}) },
|
|
91
|
+
input: W[S],
|
|
86
92
|
formHelperText: { role: "alert" },
|
|
87
93
|
htmlInput: {
|
|
88
|
-
"aria-label":
|
|
94
|
+
"aria-label": t,
|
|
89
95
|
noValidate: !0,
|
|
90
96
|
pattern: "[0-9]*\\.?[0-9]*"
|
|
91
97
|
}
|
|
92
98
|
},
|
|
93
99
|
type: "text",
|
|
94
|
-
value:
|
|
100
|
+
value: e
|
|
95
101
|
})]
|
|
96
102
|
}),
|
|
97
|
-
/* @__PURE__ */
|
|
103
|
+
/* @__PURE__ */ r(w, {
|
|
98
104
|
sx: {
|
|
99
105
|
justifyContent: "flex-end",
|
|
100
106
|
gap: 16,
|
|
101
107
|
p: 24,
|
|
102
108
|
">:not(style)~:not(style)": { ml: 0 }
|
|
103
109
|
},
|
|
104
|
-
children: [
|
|
105
|
-
"aria-label":
|
|
106
|
-
color:
|
|
107
|
-
onClick:
|
|
108
|
-
children:
|
|
110
|
+
children: [n && /* @__PURE__ */ o(f, {
|
|
111
|
+
"aria-label": n,
|
|
112
|
+
color: I,
|
|
113
|
+
onClick: y,
|
|
114
|
+
children: n
|
|
109
115
|
}), /* @__PURE__ */ o(f, {
|
|
110
|
-
"aria-label":
|
|
111
|
-
color:
|
|
116
|
+
"aria-label": s,
|
|
117
|
+
color: v,
|
|
112
118
|
disabled: d,
|
|
113
|
-
onClick:
|
|
119
|
+
onClick: m,
|
|
114
120
|
variant: "contained",
|
|
115
|
-
children:
|
|
121
|
+
children: s
|
|
116
122
|
})]
|
|
117
123
|
})
|
|
118
124
|
]
|
|
@@ -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\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}\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}: 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 ...(isSmallMobile && { '& .MuiDialog-paper': { minWidth: '100%' } }),\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:
|
|
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 ...(isSmallMobile && { '& .MuiDialog-paper': { minWidth: '100%' } }),\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,IAAiB,WACjB,eAAA,GACA,UAAA,GACA,OAAA,GACA,MAAA,IAAO,WAAA,MACkB;AAIzB,QAAM,IAAmB,MAAsB,IAAa,EAF5C,MAAe,MAAM,MAAe,OAAO,CAAC,MADvC,WAAW,KAAc,GACoB,CAAY,KAEP,KAEjE,EAAE,eAAA,EAAA,IAAkB,EAAc;AAExC,SACE,gBAAA,EAAC,GAAD;AAAA,IACE,cAAY;AAAA,IACZ,mBAAgB;AAAA,IAChB,UAAS;AAAA,IACT,SAAS;AAAA,IACT,MAAM;AAAA,IACN,MAAK;AAAA,IACL,IAAI;AAAA,MACF,4BA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,CAAC,CAAC;AAAA,YACT,YAAY;AAAA,YACZ,WAAU;AAAA,YACV,OAAO;AAAA,YACP,UAAA,CAAW,EAAE,QAAQ,EAAE,OAAA,EAAA,EAAA,MAAc;AACnC,cAAK,cAAc,KAAK,CAAK,KAE7B,IAAoB,CAAK;AAAA,YAC3B;AAAA,YACA,SAAS;AAAA,YACT,WAAW;AAAA,cACT,OAAO,EAAgB,CAAA;AAAA,cAEvB,gBAAgB,EAAE,MAAM,QAAQ;AAAA,cAChC,WAAW;AAAA,gBACT,cAAc;AAAA,gBACd,YAAY;AAAA,gBACZ,SAAS;AAAA,cACX;AAAA,YACF;AAAA,YACA,MAAK;AAAA,YACL,OAAO;AAAA,UACR,CAAA,CAEE;AAAA;QACP,gBAAA,EAAC,GAAD;AAAA,UACE,IAAI;AAAA,YACF,gBAAgB;AAAA,YAChB,KAAK;AAAA,YACL,GAAG;AAAA,YACH,4BAA4B,EAAE,IAAI,EAAE;AAAA,UACtC;AAAA,UANF,UAAA,CAQG,KACC,gBAAA,EAAC,GAAD;AAAA,YACE,cAAY;AAAA,YACZ,OAAO;AAAA,YACP,SAAS;AAAA,YAER,UAAA;AAAA,UACK,CAAA,GAEV,gBAAA,EAAC,GAAD;AAAA,YACE,cAAY;AAAA,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"}
|
|
@@ -11,7 +11,7 @@ export { default as MiniWidgetContainer } from './MiniWidgetContainer';
|
|
|
11
11
|
export { WidgetContainer } from './WidgetContainer';
|
|
12
12
|
export { default as ConnectDrawer } from './ConnectDrawer';
|
|
13
13
|
export { default as ConnectWidgetPanel, type ConnectWidgetPanelProps } from './ConnectWidgetPanel';
|
|
14
|
-
export { default as CurrencyDialog } from './CurrencyDialog';
|
|
14
|
+
export { default as CurrencyDialog, type CurrencyDialogUnit } from './CurrencyDialog';
|
|
15
15
|
export { default as CurrencyInput } from './CurrencyInput';
|
|
16
16
|
export { default as Loader } from './Loader';
|
|
17
17
|
export { default as ResponsiveButton } from './ResponsiveButton';
|
|
@@ -177,6 +177,10 @@ export interface TransactionHistoryBlock {
|
|
|
177
177
|
}
|
|
178
178
|
export interface TransactionListBlockCopy {
|
|
179
179
|
deposit_history_drawer_title?: string;
|
|
180
|
+
/** Credit Card Close to Limit's Spending list (`credit_limit_header`): its title, the limit's label and `_1{percentage}` utilization. */
|
|
181
|
+
credit_limit_header_drawer_title?: string;
|
|
182
|
+
credit_limit_header_credit_limit?: string;
|
|
183
|
+
credit_limit_header_utilization?: string;
|
|
180
184
|
/** The Subscriptions drawer's title (Monthly Subscription Aggregate V2). */
|
|
181
185
|
subscriptions_drawer_title?: string;
|
|
182
186
|
/** `_1{month}`: the count tile's caption, e.g. "Subscriptions in October". */
|
|
@@ -351,8 +355,12 @@ export interface AmountInputModalVariantCopy {
|
|
|
351
355
|
export interface AmountInputModalCopy {
|
|
352
356
|
low_balance_threshold: AmountInputModalVariantCopy;
|
|
353
357
|
safety_net: AmountInputModalVariantCopy;
|
|
358
|
+
/** Credit Card Close to Limit's alert percentage; optional because older host copy lacks it. */
|
|
359
|
+
credit_limit_percentage?: AmountInputModalVariantCopy;
|
|
354
360
|
/** Validation message for anything but a positive whole-dollar amount. */
|
|
355
361
|
whole_number_error: string;
|
|
362
|
+
/** Validation message for anything but a whole number from 1 to 100 (credit_limit_percentage). */
|
|
363
|
+
percentage_error?: string;
|
|
356
364
|
/** Shown in the dialog when the save request fails; the value stays so Save can be retried. */
|
|
357
365
|
save_error: string;
|
|
358
366
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ActionBlockProps } from '../../mappings/blocks';
|
|
2
|
-
/** `amount_input_modal_block`: one
|
|
2
|
+
/** `amount_input_modal_block`: one amount or percentage setting in a modal, picked by the CTA variant. */
|
|
3
3
|
export declare const AmountInputModalBlock: (({ beat, }: ActionBlockProps) => import("react/jsx-runtime").JSX.Element) & {
|
|
4
4
|
displayName: string;
|
|
5
5
|
};
|
|
@@ -1,146 +1,146 @@
|
|
|
1
|
-
import { buildDynamicCopy as
|
|
2
|
-
import
|
|
3
|
-
import { useCategoryStore as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { useBeatActions as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { CreateBudgetDialog as
|
|
12
|
-
import { AMOUNT_INPUT_VARIANTS as io, CREATE_BUDGET_VARIANT as no, findLowBalanceProfile as ro, isAmountInputVariant as x, isWholeAmount as ao, resolveAmountInputVariant as so, toInputValue as co } from "./layout.es.js";
|
|
1
|
+
import { buildDynamicCopy as X } from "../../../core/utils/Localization.es.js";
|
|
2
|
+
import Y from "../../../common/utils/AccountDisplayName.es.js";
|
|
3
|
+
import { useCategoryStore as Z, useGlobalCopyStore as N, useInsightsV2Store as k, useSettingsStore as oo, useUserStore as eo } from "../../../common/context/hooks.es.js";
|
|
4
|
+
import V from "../../../common/components/Loader.es.js";
|
|
5
|
+
import to from "../../../common/components/CurrencyDialog.es.js";
|
|
6
|
+
import { useBeatActions as no } from "../../beatActions.es.js";
|
|
7
|
+
import { useCtaHandler as io } from "../../ctaActions/useCtaAction.es.js";
|
|
8
|
+
import { useAnalyticsEvent as ro } from "../../analytics/useAnalyticsEvent.es.js";
|
|
9
|
+
import { useOpenedCta as so } from "../useOpenedCta.es.js";
|
|
10
|
+
import { AMOUNT_SETTINGS as ao, CREATE_BUDGET_VARIANT as co, findLowBalanceProfile as lo, isAmountInputVariant as w, resolveAmountInputVariant as uo, toInputValue as mo } from "./layout.es.js";
|
|
11
|
+
import { CreateBudgetDialog as po } from "./CreateBudgetDialog.es.js";
|
|
13
12
|
import r from "react";
|
|
14
|
-
import { observer as
|
|
15
|
-
import
|
|
16
|
-
import { H3 as
|
|
17
|
-
import { Icon as
|
|
18
|
-
import { jsx as
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
var
|
|
22
|
-
const
|
|
23
|
-
return /* @__PURE__ */
|
|
24
|
-
"aria-labelledby":
|
|
13
|
+
import { observer as M } from "mobx-react-lite";
|
|
14
|
+
import G from "@mui/material/Stack";
|
|
15
|
+
import { H3 as fo, InstitutionLogo as yo, Text as B } from "@mxenabled/mxui";
|
|
16
|
+
import { Icon as go } from "@mxenabled/mx-icons";
|
|
17
|
+
import { jsx as e, jsxs as R } from "react/jsx-runtime";
|
|
18
|
+
import ho from "@mui/material/Dialog";
|
|
19
|
+
import _o from "@mui/material/IconButton";
|
|
20
|
+
var C = ({ children: y, closeAriaLabel: n, heading: i, onClose: t }) => {
|
|
21
|
+
const s = r.useId();
|
|
22
|
+
return /* @__PURE__ */ e(ho, {
|
|
23
|
+
"aria-labelledby": i ? s : void 0,
|
|
25
24
|
maxWidth: "xs",
|
|
26
|
-
onClose:
|
|
25
|
+
onClose: t,
|
|
27
26
|
open: !0,
|
|
28
|
-
children: /* @__PURE__ */
|
|
27
|
+
children: /* @__PURE__ */ R(G, {
|
|
29
28
|
sx: {
|
|
30
29
|
gap: 12,
|
|
31
30
|
p: 24,
|
|
32
31
|
position: "relative"
|
|
33
32
|
},
|
|
34
33
|
children: [
|
|
35
|
-
|
|
36
|
-
id:
|
|
37
|
-
children:
|
|
34
|
+
i && /* @__PURE__ */ e(fo, {
|
|
35
|
+
id: s,
|
|
36
|
+
children: i
|
|
38
37
|
}),
|
|
39
|
-
/* @__PURE__ */
|
|
40
|
-
"aria-label":
|
|
41
|
-
onClick:
|
|
38
|
+
/* @__PURE__ */ e(_o, {
|
|
39
|
+
"aria-label": n || "Close",
|
|
40
|
+
onClick: t,
|
|
42
41
|
sx: {
|
|
43
42
|
position: "absolute",
|
|
44
43
|
right: 8,
|
|
45
44
|
top: 18
|
|
46
45
|
},
|
|
47
|
-
children: /* @__PURE__ */
|
|
46
|
+
children: /* @__PURE__ */ e(go, {
|
|
48
47
|
name: "close",
|
|
49
48
|
sx: { color: "action.active" }
|
|
50
49
|
})
|
|
51
50
|
}),
|
|
52
|
-
|
|
51
|
+
y
|
|
53
52
|
]
|
|
54
53
|
})
|
|
55
54
|
});
|
|
56
|
-
},
|
|
57
|
-
const { common:
|
|
55
|
+
}, $o = M(function({ beat: n }) {
|
|
56
|
+
const { common: i } = N(), { closeActionDrawer: t } = k(), s = Z(), c = so(n), [l] = r.useState(() => uo(c)), d = l === co;
|
|
58
57
|
return r.useEffect(() => {
|
|
59
|
-
|
|
60
|
-
}, [
|
|
61
|
-
closeAriaLabel:
|
|
62
|
-
onClose:
|
|
63
|
-
children: /* @__PURE__ */
|
|
64
|
-
}) : /* @__PURE__ */
|
|
65
|
-
beat:
|
|
66
|
-
variant:
|
|
58
|
+
d && !s.categoriesLoaded && s.loadCategories();
|
|
59
|
+
}, [s, d]), d ? s.categoriesLoaded ? /* @__PURE__ */ e(po, { beat: n }) : /* @__PURE__ */ e(C, {
|
|
60
|
+
closeAriaLabel: i?.close_aria,
|
|
61
|
+
onClose: t,
|
|
62
|
+
children: /* @__PURE__ */ e(V, {})
|
|
63
|
+
}) : /* @__PURE__ */ e(vo, {
|
|
64
|
+
beat: n,
|
|
65
|
+
variant: l
|
|
67
66
|
});
|
|
68
|
-
}),
|
|
69
|
-
const { common:
|
|
67
|
+
}), vo = M(function({ beat: n, variant: i }) {
|
|
68
|
+
const { common: t, insights_feed: s } = N(), { closeActionDrawer: c } = k(), l = oo(), { userInsightProfile: d } = eo(), $ = io(n, no()), S = ro(), u = s?.amount_input_modal, o = w(i) ? ao[i] : void 0, m = !!o?.needsNotificationProfiles, g = {
|
|
69
|
+
insightProfile: d,
|
|
70
|
+
lowBalanceProfile: m ? lo(l.notificationProfiles, n.primary_account_guid) : void 0
|
|
71
|
+
}, A = o?.read(g), [F, H] = r.useState(m), p = r.useRef(!0);
|
|
70
72
|
r.useEffect(() => (p.current = !0, () => {
|
|
71
73
|
p.current = !1;
|
|
72
74
|
}), []), r.useEffect(() => {
|
|
73
|
-
|
|
74
|
-
p.current &&
|
|
75
|
+
m && l.loadNotificationProfiles().finally(() => {
|
|
76
|
+
p.current && H(!1);
|
|
75
77
|
});
|
|
76
|
-
}, [
|
|
77
|
-
const [
|
|
78
|
-
if (
|
|
79
|
-
closeAriaLabel:
|
|
80
|
-
onClose:
|
|
81
|
-
children: /* @__PURE__ */
|
|
78
|
+
}, [m, l]);
|
|
79
|
+
const [O, U] = r.useState(null), [I, b] = r.useState(!1), [j, h] = r.useState(!1), f = O ?? mo(A);
|
|
80
|
+
if (F) return /* @__PURE__ */ e(C, {
|
|
81
|
+
closeAriaLabel: t?.close_aria,
|
|
82
|
+
onClose: c,
|
|
83
|
+
children: /* @__PURE__ */ e(V, {})
|
|
82
84
|
});
|
|
83
|
-
const
|
|
84
|
-
if (!
|
|
85
|
-
return console.warn(`amount_input_modal_block: ${
|
|
86
|
-
closeAriaLabel:
|
|
87
|
-
heading:
|
|
88
|
-
onClose:
|
|
89
|
-
children: /* @__PURE__ */
|
|
85
|
+
const a = w(i) ? u?.[i] : 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(g);
|
|
86
|
+
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 "${i}"` : `unknown variant "${i}"` : "copy namespace missing"}`), /* @__PURE__ */ e(C, {
|
|
88
|
+
closeAriaLabel: t?.close_aria,
|
|
89
|
+
heading: t?.error_heading,
|
|
90
|
+
onClose: c,
|
|
91
|
+
children: /* @__PURE__ */ e(B, { children: t?.error_message })
|
|
90
92
|
});
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
},
|
|
94
|
-
if (!
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
threshold: _
|
|
100
|
-
}, { analytics: d.EDIT_INSIGHT_THRESHOLD_SAVE }) : await A("updateUserInsightProfile", { fields: { savings_opportunity_minimum_checking_account_balance: _ } }, { analytics: d.EDIT_SAFETY_NET_SAVE });
|
|
101
|
-
p.current && (v(!1), Y ? l() : y(!0));
|
|
93
|
+
const P = () => {
|
|
94
|
+
S(o.analytics.cancel), c();
|
|
95
|
+
}, { inputSelected: L } = o.analytics, E = o.hasEditCopy && !!A, T = n.primary_account ? Y(n.primary_account) : "", _ = o.isValid(f), K = f !== "" && !_, W = async () => {
|
|
96
|
+
if (!_ || I) return;
|
|
97
|
+
const v = Number(f);
|
|
98
|
+
b(!0), h(!1);
|
|
99
|
+
const [q, J] = o.save(v, g), Q = await $(q, J, { analytics: o.analytics.save });
|
|
100
|
+
p.current && (b(!1), Q ? c() : h(!0));
|
|
102
101
|
};
|
|
103
|
-
return /* @__PURE__ */
|
|
104
|
-
closeAriaLabel:
|
|
105
|
-
content:
|
|
106
|
-
errorText:
|
|
107
|
-
handleInputChange: (
|
|
108
|
-
|
|
102
|
+
return /* @__PURE__ */ e(to, {
|
|
103
|
+
closeAriaLabel: t.close_aria,
|
|
104
|
+
content: X(E && a.description_edit || a.description, /* @__PURE__ */ e("strong", { children: T }, "account")),
|
|
105
|
+
errorText: K ? x : j ? u.save_error : void 0,
|
|
106
|
+
handleInputChange: (v) => {
|
|
107
|
+
U(v), h(!1);
|
|
109
108
|
},
|
|
110
|
-
handleInputClick:
|
|
111
|
-
handleModalClose:
|
|
109
|
+
handleInputClick: L ? () => S(L) : void 0,
|
|
110
|
+
handleModalClose: P,
|
|
112
111
|
handlePrimaryAction: () => {
|
|
113
112
|
W();
|
|
114
113
|
},
|
|
115
|
-
handleSecondaryAction:
|
|
116
|
-
inputLabel:
|
|
114
|
+
handleSecondaryAction: P,
|
|
115
|
+
inputLabel: a.input_label,
|
|
117
116
|
inputValue: f,
|
|
118
117
|
isOpen: !0,
|
|
119
|
-
isPrimaryDisabled:
|
|
120
|
-
primaryText:
|
|
121
|
-
secondaryText:
|
|
122
|
-
subtitle:
|
|
118
|
+
isPrimaryDisabled: I || !_,
|
|
119
|
+
primaryText: t.save_button,
|
|
120
|
+
secondaryText: o.hasCancel ? t.cancel_button : void 0,
|
|
121
|
+
subtitle: o.showsAccount && n.primary_account ? /* @__PURE__ */ R(G, {
|
|
123
122
|
sx: {
|
|
124
123
|
alignItems: "center",
|
|
125
124
|
flexDirection: "row",
|
|
126
125
|
gap: 8
|
|
127
126
|
},
|
|
128
|
-
children: [/* @__PURE__ */
|
|
127
|
+
children: [/* @__PURE__ */ e(yo, {
|
|
129
128
|
alt: "",
|
|
130
|
-
institutionGuid:
|
|
129
|
+
institutionGuid: n.primary_account.institution_guid ?? "",
|
|
131
130
|
size: 16
|
|
132
|
-
}), /* @__PURE__ */
|
|
131
|
+
}), /* @__PURE__ */ e(B, {
|
|
133
132
|
color: "text.secondary",
|
|
134
133
|
uppercase: !0,
|
|
135
134
|
variant: "body2",
|
|
136
|
-
children:
|
|
135
|
+
children: T
|
|
137
136
|
})]
|
|
138
137
|
}) : void 0,
|
|
139
|
-
title:
|
|
138
|
+
title: E && a.title_edit || a.title,
|
|
139
|
+
unit: o.unit
|
|
140
140
|
});
|
|
141
141
|
});
|
|
142
142
|
export {
|
|
143
|
-
|
|
143
|
+
$o as AmountInputModalBlock
|
|
144
144
|
};
|
|
145
145
|
|
|
146
146
|
//# 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 { ANALYTICS_EVENTS_CONFIG, 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_INPUT_VARIANTS,\n CREATE_BUDGET_VARIANT,\n findLowBalanceProfile,\n isAmountInputVariant,\n isWholeAmount,\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 whole-dollar amount 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/** The low-balance threshold and safety-net settings (the two `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 isLowBalance = variant === AMOUNT_INPUT_VARIANTS.LOW_BALANCE_THRESHOLD\n\n const lowBalanceProfile = isLowBalance\n ? findLowBalanceProfile(settingsStore.notificationProfiles, beat.primary_account_guid)\n : undefined\n const savedAmount = isLowBalance\n ? lowBalanceProfile?.threshold\n : userInsightProfile?.savings_opportunity_minimum_checking_account_balance\n\n // Mounting is the open, so profiles reload here and the threshold prefills as saved now.\n const [isLoadingProfiles, setIsLoadingProfiles] = React.useState(isLowBalance)\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 (!isLowBalance) return\n\n void settingsStore.loadNotificationProfiles().finally(() => {\n if (isMounted.current) setIsLoadingProfiles(false)\n })\n }, [isLowBalance, 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 hasCopy =\n !!variantCopy?.title &&\n !!variantCopy.description &&\n !!variantCopy.input_label &&\n !!copy?.whole_number_error &&\n !!copy.save_error &&\n !!commonCopy?.save_button &&\n // Cancel renders for the low-balance variant only.\n (!isLowBalance || !!commonCopy.cancel_button) &&\n !!commonCopy.close_aria\n const hasProfile = isLowBalance ? !!lowBalanceProfile : !!userInsightProfile\n\n if (!copy || !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 : !isAmountInputVariant(variant)\n ? `unknown variant \"${variant}\"`\n : !hasCopy\n ? `copy incomplete for \"${variant}\"`\n : isLowBalance\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(\n isLowBalance\n ? ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_CANCELED\n : ANALYTICS_EVENTS_CONFIG.EDIT_SAFETY_NET_CANCEL,\n )\n closeActionDrawer()\n }\n\n const isEdit = !isLowBalance && !!savedAmount\n const accountName = beat.primary_account ? getAccountDisplayName(beat.primary_account) : ''\n const isValid = isWholeAmount(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 ok = isLowBalance\n ? await runHandler(\n 'updateNotificationProfileThreshold',\n { profileGuid: lowBalanceProfile?.guid, threshold: amount },\n { analytics: ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_SAVE },\n )\n : await runHandler(\n 'updateUserInsightProfile',\n { fields: { savings_opportunity_minimum_checking_account_balance: amount } },\n { analytics: ANALYTICS_EVENTS_CONFIG.EDIT_SAFETY_NET_SAVE },\n )\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 ? copy.whole_number_error : saveFailed ? copy.save_error : undefined}\n handleInputChange={(next) => {\n setTyped(next)\n setSaveFailed(false)\n }}\n handleInputClick={\n // Pulse fires input-selected for the threshold dialog only (EditThreshold.js); the\n // safety-net dialog has no input event.\n isLowBalance\n ? () => fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.EDIT_INSIGHT_THRESHOLD_INPUT_SELECTED)\n : undefined\n }\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={isLowBalance ? commonCopy.cancel_button : undefined}\n subtitle={\n isLowBalance && 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 />\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAwCA,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;AAA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IAC3C,uBAAuB;AAAA,IACvB,YAAY,EAAY;AAAA,IACxB,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,mBAAmB,KAAY,CAAC;AAAA,IAChC,aAAa,EAAW;AAAA,IACxB,eAAe,IAAe,EAAW,gBAAgB;AAAA,IACzD,UACE,KAAgB,EAAK,kBACnB,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,EAC1D,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 >\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,IAE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