@mx-cartographer/experiences 9.7.117 → 9.7.118

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.
Files changed (56) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/common/components/drawer/Drawer.d.ts +3 -0
  3. package/dist/common/components/drawer/Drawer.es.js +30 -29
  4. package/dist/common/components/drawer/Drawer.es.js.map +1 -1
  5. package/dist/common/components/drawer/Header.d.ts +3 -0
  6. package/dist/common/components/drawer/Header.es.js +51 -45
  7. package/dist/common/components/drawer/Header.es.js.map +1 -1
  8. package/dist/core/stores/InsightsV2Store.d.ts +10 -0
  9. package/dist/core/stores/InsightsV2Store.es.js +15 -7
  10. package/dist/core/stores/InsightsV2Store.es.js.map +1 -1
  11. package/dist/insights-v2/actionBlocks/ActionBlockLayer.es.js +44 -33
  12. package/dist/insights-v2/actionBlocks/ActionBlockLayer.es.js.map +1 -1
  13. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.d.ts +1 -9
  14. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js +96 -83
  15. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js.map +1 -1
  16. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.d.ts +5 -0
  17. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.es.js +62 -0
  18. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.es.js.map +1 -0
  19. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/layout.es.js.map +1 -1
  20. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetDetailsBlock.es.js +212 -145
  21. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetDetailsBlock.es.js.map +1 -1
  22. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetSummary.d.ts +3 -1
  23. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetSummary.es.js +36 -36
  24. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetSummary.es.js.map +1 -1
  25. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/layout.d.ts +32 -2
  26. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/layout.es.js +68 -22
  27. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/layout.es.js.map +1 -1
  28. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/useBudgetDetailsPrepare.d.ts +3 -0
  29. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/useBudgetDetailsPrepare.es.js +34 -0
  30. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/useBudgetDetailsPrepare.es.js.map +1 -0
  31. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +61 -61
  32. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js.map +1 -1
  33. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.d.ts +1 -0
  34. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js +42 -40
  35. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js.map +1 -1
  36. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.es.js +3 -3
  37. package/dist/insights-v2/actionBlocks/util.d.ts +2 -11
  38. package/dist/insights-v2/actionBlocks/util.es.js +16 -6
  39. package/dist/insights-v2/actionBlocks/util.es.js.map +1 -1
  40. package/dist/insights-v2/analytics/analyticsEventsConfig.d.ts +16 -0
  41. package/dist/insights-v2/analytics/analyticsEventsConfig.es.js +19 -2
  42. package/dist/insights-v2/analytics/analyticsEventsConfig.es.js.map +1 -1
  43. package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.es.js +8 -8
  44. package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.es.js.map +1 -1
  45. package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.d.ts +1 -1
  46. package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.es.js +28 -27
  47. package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.es.js.map +1 -1
  48. package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/AccountBlock.es.js +4 -4
  49. package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js +4 -4
  50. package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/SVGImageBlock.es.js +4 -4
  51. package/dist/insights-v2/components/BaseLayout.es.js +137 -118
  52. package/dist/insights-v2/components/BaseLayout.es.js.map +1 -1
  53. package/dist/insights-v2/mappings/blocks.d.ts +1 -0
  54. package/dist/insights-v2/mappings/blocks.es.js +131 -121
  55. package/dist/insights-v2/mappings/blocks.es.js.map +1 -1
  56. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [9.7.118] - 11-06-2026
2
+
3
+ - **FIXED** - Category Spending's mini card fits Figma: its 94px chart and 24px legend share the full chart's 122px, so the card's action is no longer cut off (`category_color` mini only) (WEC-2215)
4
+ - **FIXED** - Every Insights 2.0 mini card keeps its description 12px under its block and its link 16px from the card's bottom in the host's fixed-height slot (pulse's 312px), as Figma's minis do; a shorter description leaves the spare height between them (WEC-2215)
5
+ - **FIXED** - The Budget Details drawer always shows the amount left under the bar, $0.00 once over budget, as the Budgets drawer does (WEC-2215)
6
+ - **ADDED** - Category Spending V2 Storybook QA page (`InsightsV2/Insights/CategorySpendingV2`): full, mini, micro, notification and the drill-down for 3 states without a budget and 3 with one (WEC-2215)
7
+ - **ADDED** - Category Spending on Insights 2.0: Create a Budget (a loader until categories load), a Budget Details drawer that matches Figma with the month's transactions and Export CSV, Try Again on failed budget changes, budget analytics, and bar clicks that open Spending History in every state (with a budget, with the primary CTA's `category_spend` variant) (WEC-2215)
8
+
1
9
  ## [9.7.117] - 11-06-2026
2
10
 
3
11
  - **ADDED** - Monthly Deposit Summary on Insights 2.0: the deposit summary donut palette and the Deposit Summary drawer with six months of deposit bars, a trend line and Income / Other Deposits tabs (WEC-2097)
@@ -1,11 +1,14 @@
1
1
  import { default as React } from 'react';
2
2
  import { default as Button } from '@mui/material/Button';
3
3
  import { SxProps } from '@mui/material/styles';
4
+ import { DrawerHeaderAction } from './Header';
4
5
  export type CopyObject = {
5
6
  close_drawer_aria: string;
6
7
  };
7
8
  interface DrawerProps {
8
9
  ariaLabelClose?: string;
10
+ /** `back` (default) or `close`, see DrawerHeader. */
11
+ headerAction?: DrawerHeaderAction;
9
12
  className?: string;
10
13
  footerStyles?: SxProps;
11
14
  hasSecondaryAction?: boolean;
@@ -1,15 +1,15 @@
1
- import { useFocusReturn as y } from "../../hooks/useFocusReturn.es.js";
2
- import D from "./Footer.es.js";
3
- import F from "./Header.es.js";
1
+ import { useFocusReturn as D } from "../../hooks/useFocusReturn.es.js";
2
+ import F from "./Footer.es.js";
3
+ import j from "./Header.es.js";
4
4
  import "react";
5
- import j from "@mui/material/Stack";
6
- import { Drawer as C } from "@mxenabled/mxui";
7
- import { jsx as r, jsxs as v } from "react/jsx-runtime";
8
- import B from "@mui/material/Box";
9
- var G = ({ ariaLabelClose: i = "Close", children: s, footerStyles: u = {}, hasSecondaryAction: d = !0, id: p, isOpen: e, isPrimaryDisabled: m, onClose: o, onPrimaryAction: t, onSecondaryAction: l, primaryButtonProps: c, primaryColor: f = "primary", primaryText: h, secondaryColor: n = "primary", secondaryText: b, shouldShowHeaderBorders: w = !0, shouldShowHeaderShadow: g = !1, title: a, ...x }) => {
10
- const { onExited: k, onFocus: R, rootRef: S } = y(e);
11
- return /* @__PURE__ */ r(C, {
12
- id: p,
5
+ import C from "@mui/material/Stack";
6
+ import { Drawer as v } from "@mxenabled/mxui";
7
+ import { jsx as r, jsxs as B } from "react/jsx-runtime";
8
+ import M from "@mui/material/Box";
9
+ var I = ({ ariaLabelClose: i = "Close", children: s, headerAction: u, footerStyles: d = {}, hasSecondaryAction: p = !0, id: m, isOpen: e, isPrimaryDisabled: c, onClose: o, onPrimaryAction: t, onSecondaryAction: l, primaryButtonProps: f, primaryColor: n = "primary", primaryText: h, secondaryColor: b = "primary", secondaryText: w, shouldShowHeaderBorders: g = !0, shouldShowHeaderShadow: x = !1, title: a, ...k }) => {
10
+ const { onExited: R, onFocus: S, rootRef: y } = D(e);
11
+ return /* @__PURE__ */ r(v, {
12
+ id: m,
13
13
  isOpen: e,
14
14
  onClose: o,
15
15
  sx: {
@@ -20,48 +20,49 @@ var G = ({ ariaLabelClose: i = "Close", children: s, footerStyles: u = {}, hasSe
20
20
  height: "100%",
21
21
  "& .MuiToolbar-root": { backgroundColor: "background.paper" }
22
22
  },
23
- ...x,
23
+ ...k,
24
24
  disableRestoreFocus: !0,
25
- onFocus: R,
26
- ref: S,
25
+ onFocus: S,
26
+ ref: y,
27
27
  slotProps: {
28
28
  paper: { "aria-labelledby": `${a?.replace(/\s+/g, "-").toLowerCase()}-header-title` },
29
- transition: { onExited: k }
29
+ transition: { onExited: R }
30
30
  },
31
- children: /* @__PURE__ */ v(j, {
31
+ children: /* @__PURE__ */ B(C, {
32
32
  height: "100%",
33
33
  justifyContent: "space-between",
34
34
  children: [
35
- /* @__PURE__ */ r(F, {
35
+ /* @__PURE__ */ r(j, {
36
+ action: u,
36
37
  ariaLabelClose: i,
37
38
  onClose: o,
38
- shouldShowBorders: w,
39
- shouldShowShadow: g,
39
+ shouldShowBorders: g,
40
+ shouldShowShadow: x,
40
41
  title: a
41
42
  }),
42
- /* @__PURE__ */ r(B, {
43
+ /* @__PURE__ */ r(M, {
43
44
  height: "100%",
44
45
  overflow: "auto",
45
46
  children: s
46
47
  }),
47
- t && /* @__PURE__ */ r(D, {
48
- footerStyles: u,
49
- hasSecondaryAction: d,
50
- isPrimaryDisabled: m,
48
+ t && /* @__PURE__ */ r(F, {
49
+ footerStyles: d,
50
+ hasSecondaryAction: p,
51
+ isPrimaryDisabled: c,
51
52
  onPrimaryAction: t,
52
53
  onSecondaryAction: l ?? o,
53
- primaryButtonProps: c,
54
- primaryColor: f,
54
+ primaryButtonProps: f,
55
+ primaryColor: n,
55
56
  primaryText: h,
56
- secondaryColor: n,
57
- secondaryText: b
57
+ secondaryColor: b,
58
+ secondaryText: w
58
59
  })
59
60
  ]
60
61
  })
61
62
  });
62
63
  };
63
64
  export {
64
- G as default
65
+ I as default
65
66
  };
66
67
 
67
68
  //# sourceMappingURL=Drawer.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Drawer.es.js","names":[],"sources":["../../../../src/common/components/drawer/Drawer.tsx"],"sourcesContent":["import React from 'react'\n\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Stack from '@mui/material/Stack'\nimport type { SxProps } from '@mui/material/styles'\n\nimport { Drawer as KMuiDrawer } from '@mxenabled/mxui'\n\nimport { useFocusReturn } from '../../hooks/useFocusReturn'\n\nimport Footer from './Footer'\nimport Header from './Header'\n\nexport type CopyObject = {\n close_drawer_aria: string\n}\n\ninterface DrawerProps {\n ariaLabelClose?: string\n className?: string\n footerStyles?: SxProps\n hasSecondaryAction?: boolean\n id?: string\n isOpen: boolean\n isPrimaryDisabled?: boolean\n onClose: () => void\n onPrimaryAction?: () => void\n onSecondaryAction?: () => void\n primaryButtonProps?: React.ComponentProps<typeof Button>\n primaryColor?: 'primary' | 'inherit' | 'secondary' | 'success' | 'error' | 'info' | 'warning'\n primaryText?: string\n secondaryColor?: 'primary' | 'inherit' | 'secondary' | 'success' | 'error' | 'info' | 'warning'\n secondaryText?: string\n shouldShowHeaderBorders?: boolean\n shouldShowHeaderShadow?: boolean\n sx?: SxProps\n title: string\n}\n\nconst Drawer: React.FC<React.PropsWithChildren<DrawerProps>> = ({\n ariaLabelClose = 'Close',\n children,\n footerStyles = {},\n hasSecondaryAction = true,\n id,\n isOpen,\n isPrimaryDisabled,\n onClose,\n onPrimaryAction,\n onSecondaryAction,\n primaryButtonProps,\n primaryColor = 'primary',\n primaryText,\n secondaryColor = 'primary',\n secondaryText,\n shouldShowHeaderBorders = true,\n shouldShowHeaderShadow = false,\n title,\n ...rest\n}) => {\n const { onExited, onFocus, rootRef } = useFocusReturn(isOpen)\n\n return (\n <KMuiDrawer\n id={id}\n isOpen={isOpen}\n onClose={onClose}\n sx={{\n '& .MuiDrawer-paper': {\n backgroundColor: 'background.default',\n borderRadius: 0,\n },\n height: '100%',\n '& .MuiToolbar-root': {\n backgroundColor: 'background.paper',\n },\n }}\n {...rest}\n disableRestoreFocus={true}\n onFocus={onFocus}\n ref={rootRef}\n slotProps={{\n paper: {\n 'aria-labelledby': `${title?.replace(/\\s+/g, '-').toLowerCase()}-header-title`,\n },\n transition: { onExited },\n }}\n >\n <Stack height=\"100%\" justifyContent=\"space-between\">\n <Header\n ariaLabelClose={ariaLabelClose}\n onClose={onClose}\n shouldShowBorders={shouldShowHeaderBorders}\n shouldShowShadow={shouldShowHeaderShadow}\n title={title}\n />\n\n <Box height=\"100%\" overflow=\"auto\">\n {children}\n </Box>\n\n {onPrimaryAction && (\n <Footer\n footerStyles={footerStyles}\n hasSecondaryAction={hasSecondaryAction}\n isPrimaryDisabled={isPrimaryDisabled}\n onPrimaryAction={onPrimaryAction}\n onSecondaryAction={onSecondaryAction ?? onClose}\n primaryButtonProps={primaryButtonProps}\n primaryColor={primaryColor}\n primaryText={primaryText}\n secondaryColor={secondaryColor}\n secondaryText={secondaryText}\n />\n )}\n </Stack>\n </KMuiDrawer>\n )\n}\n\nexport default Drawer\n"],"mappings":";;;;;;;;AAwCA,IAAM,IAAA,CAA0D,EAC9D,gBAAA,IAAiB,SACjB,UAAA,GACA,cAAA,IAAe,CAAC,GAChB,oBAAA,IAAqB,IACrB,IAAA,GACA,QAAA,GACA,mBAAA,GACA,SAAA,GACA,iBAAA,GACA,mBAAA,GACA,oBAAA,GACA,cAAA,IAAe,WACf,aAAA,GACA,gBAAA,IAAiB,WACjB,eAAA,GACA,yBAAA,IAA0B,IAC1B,wBAAA,IAAyB,IACzB,OAAA,GACA,GAAG,EAAA,MACC;AACJ,QAAM,EAAE,UAAA,GAAU,SAAA,GAAS,SAAA,EAAA,IAAY,EAAe,CAAM;AAE5D,SACE,gBAAA,EAAC,GAAD;AAAA,IACM,IAAA;AAAA,IACI,QAAA;AAAA,IACC,SAAA;AAAA,IACT,IAAI;AAAA,MACF,sBAAsB;AAAA,QACpB,iBAAiB;AAAA,QACjB,cAAc;AAAA,MAChB;AAAA,MACA,QAAQ;AAAA,MACR,sBAAsB,EACpB,iBAAiB,mBACnB;AAAA,IACF;AAAA,IACA,GAAI;AAAA,IACJ,qBAAqB;AAAA,IACZ,SAAA;AAAA,IACT,KAAK;AAAA,IACL,WAAW;AAAA,MACT,OAAO,EACL,mBAAmB,GAAG,GAAO,QAAQ,QAAQ,GAAG,EAAE,YAAY,CAAA,gBAChE;AAAA,MACA,YAAY,EAAE,UAAA,EAAS;AAAA,IACzB;AAAA,IAEA,UAAA,gBAAA,EAAC,GAAD;AAAA,MAAO,QAAO;AAAA,MAAO,gBAAe;AAAA,MAApC,UAAA;AAAA,QACE,gBAAA,EAAC,GAAD;AAAA,UACkB,gBAAA;AAAA,UACP,SAAA;AAAA,UACT,mBAAmB;AAAA,UACnB,kBAAkB;AAAA,UACX,OAAA;AAAA,QACR,CAAA;AAAA,QAED,gBAAA,EAAC,GAAD;AAAA,UAAK,QAAO;AAAA,UAAO,UAAS;AAAA,UACzB,UAAA;AAAA,QACE,CAAA;AAAA,QAEJ,KACC,gBAAA,EAAC,GAAD;AAAA,UACgB,cAAA;AAAA,UACM,oBAAA;AAAA,UACD,mBAAA;AAAA,UACF,iBAAA;AAAA,UACjB,mBAAmB,KAAqB;AAAA,UACpB,oBAAA;AAAA,UACN,cAAA;AAAA,UACD,aAAA;AAAA,UACG,gBAAA;AAAA,UACD,eAAA;AAAA,QAChB,CAAA;AAAA,MAEE;AAAA;EACG,CAAA;AAEhB"}
1
+ {"version":3,"file":"Drawer.es.js","names":[],"sources":["../../../../src/common/components/drawer/Drawer.tsx"],"sourcesContent":["import React from 'react'\n\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Stack from '@mui/material/Stack'\nimport type { SxProps } from '@mui/material/styles'\n\nimport { Drawer as KMuiDrawer } from '@mxenabled/mxui'\n\nimport { useFocusReturn } from '../../hooks/useFocusReturn'\n\nimport Footer from './Footer'\nimport Header, { type DrawerHeaderAction } from './Header'\n\nexport type CopyObject = {\n close_drawer_aria: string\n}\n\ninterface DrawerProps {\n ariaLabelClose?: string\n /** `back` (default) or `close`, see DrawerHeader. */\n headerAction?: DrawerHeaderAction\n className?: string\n footerStyles?: SxProps\n hasSecondaryAction?: boolean\n id?: string\n isOpen: boolean\n isPrimaryDisabled?: boolean\n onClose: () => void\n onPrimaryAction?: () => void\n onSecondaryAction?: () => void\n primaryButtonProps?: React.ComponentProps<typeof Button>\n primaryColor?: 'primary' | 'inherit' | 'secondary' | 'success' | 'error' | 'info' | 'warning'\n primaryText?: string\n secondaryColor?: 'primary' | 'inherit' | 'secondary' | 'success' | 'error' | 'info' | 'warning'\n secondaryText?: string\n shouldShowHeaderBorders?: boolean\n shouldShowHeaderShadow?: boolean\n sx?: SxProps\n title: string\n}\n\nconst Drawer: React.FC<React.PropsWithChildren<DrawerProps>> = ({\n ariaLabelClose = 'Close',\n children,\n headerAction,\n footerStyles = {},\n hasSecondaryAction = true,\n id,\n isOpen,\n isPrimaryDisabled,\n onClose,\n onPrimaryAction,\n onSecondaryAction,\n primaryButtonProps,\n primaryColor = 'primary',\n primaryText,\n secondaryColor = 'primary',\n secondaryText,\n shouldShowHeaderBorders = true,\n shouldShowHeaderShadow = false,\n title,\n ...rest\n}) => {\n const { onExited, onFocus, rootRef } = useFocusReturn(isOpen)\n\n return (\n <KMuiDrawer\n id={id}\n isOpen={isOpen}\n onClose={onClose}\n sx={{\n '& .MuiDrawer-paper': {\n backgroundColor: 'background.default',\n borderRadius: 0,\n },\n height: '100%',\n '& .MuiToolbar-root': {\n backgroundColor: 'background.paper',\n },\n }}\n {...rest}\n disableRestoreFocus={true}\n onFocus={onFocus}\n ref={rootRef}\n slotProps={{\n paper: {\n 'aria-labelledby': `${title?.replace(/\\s+/g, '-').toLowerCase()}-header-title`,\n },\n transition: { onExited },\n }}\n >\n <Stack height=\"100%\" justifyContent=\"space-between\">\n <Header\n action={headerAction}\n ariaLabelClose={ariaLabelClose}\n onClose={onClose}\n shouldShowBorders={shouldShowHeaderBorders}\n shouldShowShadow={shouldShowHeaderShadow}\n title={title}\n />\n\n <Box height=\"100%\" overflow=\"auto\">\n {children}\n </Box>\n\n {onPrimaryAction && (\n <Footer\n footerStyles={footerStyles}\n hasSecondaryAction={hasSecondaryAction}\n isPrimaryDisabled={isPrimaryDisabled}\n onPrimaryAction={onPrimaryAction}\n onSecondaryAction={onSecondaryAction ?? onClose}\n primaryButtonProps={primaryButtonProps}\n primaryColor={primaryColor}\n primaryText={primaryText}\n secondaryColor={secondaryColor}\n secondaryText={secondaryText}\n />\n )}\n </Stack>\n </KMuiDrawer>\n )\n}\n\nexport default Drawer\n"],"mappings":";;;;;;;;AA0CA,IAAM,IAAA,CAA0D,EAC9D,gBAAA,IAAiB,SACjB,UAAA,GACA,cAAA,GACA,cAAA,IAAe,CAAC,GAChB,oBAAA,IAAqB,IACrB,IAAA,GACA,QAAA,GACA,mBAAA,GACA,SAAA,GACA,iBAAA,GACA,mBAAA,GACA,oBAAA,GACA,cAAA,IAAe,WACf,aAAA,GACA,gBAAA,IAAiB,WACjB,eAAA,GACA,yBAAA,IAA0B,IAC1B,wBAAA,IAAyB,IACzB,OAAA,GACA,GAAG,EAAA,MACC;AACJ,QAAM,EAAE,UAAA,GAAU,SAAA,GAAS,SAAA,EAAA,IAAY,EAAe,CAAM;AAE5D,SACE,gBAAA,EAAC,GAAD;AAAA,IACM,IAAA;AAAA,IACI,QAAA;AAAA,IACC,SAAA;AAAA,IACT,IAAI;AAAA,MACF,sBAAsB;AAAA,QACpB,iBAAiB;AAAA,QACjB,cAAc;AAAA,MAChB;AAAA,MACA,QAAQ;AAAA,MACR,sBAAsB,EACpB,iBAAiB,mBACnB;AAAA,IACF;AAAA,IACA,GAAI;AAAA,IACJ,qBAAqB;AAAA,IACZ,SAAA;AAAA,IACT,KAAK;AAAA,IACL,WAAW;AAAA,MACT,OAAO,EACL,mBAAmB,GAAG,GAAO,QAAQ,QAAQ,GAAG,EAAE,YAAY,CAAA,gBAChE;AAAA,MACA,YAAY,EAAE,UAAA,EAAS;AAAA,IACzB;AAAA,IAEA,UAAA,gBAAA,EAAC,GAAD;AAAA,MAAO,QAAO;AAAA,MAAO,gBAAe;AAAA,MAApC,UAAA;AAAA,QACE,gBAAA,EAAC,GAAD;AAAA,UACE,QAAQ;AAAA,UACQ,gBAAA;AAAA,UACP,SAAA;AAAA,UACT,mBAAmB;AAAA,UACnB,kBAAkB;AAAA,UACX,OAAA;AAAA,QACR,CAAA;AAAA,QAED,gBAAA,EAAC,GAAD;AAAA,UAAK,QAAO;AAAA,UAAO,UAAS;AAAA,UACzB,UAAA;AAAA,QACE,CAAA;AAAA,QAEJ,KACC,gBAAA,EAAC,GAAD;AAAA,UACgB,cAAA;AAAA,UACM,oBAAA;AAAA,UACD,mBAAA;AAAA,UACF,iBAAA;AAAA,UACjB,mBAAmB,KAAqB;AAAA,UACpB,oBAAA;AAAA,UACN,cAAA;AAAA,UACD,aAAA;AAAA,UACG,gBAAA;AAAA,UACD,eAAA;AAAA,QAChB,CAAA;AAAA,MAEE;AAAA;EACG,CAAA;AAEhB"}
@@ -1,5 +1,8 @@
1
1
  import { default as React } from 'react';
2
+ /** `back` (default): an arrow on the left. `close`: an X on the right, as Figma's Budget Details. */
3
+ export type DrawerHeaderAction = 'back' | 'close';
2
4
  interface DrawerHeaderProps {
5
+ action?: DrawerHeaderAction;
3
6
  ariaLabelClose: string;
4
7
  onClose: () => void;
5
8
  shouldShowBorders: boolean;
@@ -1,52 +1,58 @@
1
1
  import "react";
2
- import d from "@mui/material/Stack";
3
- import { H2 as l } from "@mxenabled/mxui";
4
- import { ArrowBack as c } from "@mxenabled/mx-icons";
5
- import { jsx as r, jsxs as m } from "react/jsx-runtime";
6
- import e from "@mui/material/Box";
7
- import n from "@mui/material/IconButton";
8
- var k = ({ ariaLabelClose: a, onClose: t, shouldShowBorders: i, shouldShowShadow: p, title: o }) => /* @__PURE__ */ m(d, {
9
- "aria-labelledby": `${o?.replace(/\s+/g, "-").toLowerCase()}-header-title`,
10
- direction: "row",
11
- sx: {
12
- alignItems: "center",
13
- backgroundColor: "background.paper",
14
- ...i && {
15
- borderBottom: 1,
16
- borderColor: "divider"
17
- },
18
- ...p && { boxShadow: "0px 2px 8px 0px #6A73811F" },
19
- padding: "8px 8px 8px 8px"
20
- },
21
- children: [
22
- /* @__PURE__ */ r(n, {
23
- "aria-label": a,
24
- autoFocus: !0,
2
+ import s from "@mui/material/Stack";
3
+ import { H2 as x } from "@mxenabled/mxui";
4
+ import { ArrowBack as m, Close as b } from "@mxenabled/mx-icons";
5
+ import { jsx as r, jsxs as f } from "react/jsx-runtime";
6
+ import i from "@mui/material/Box";
7
+ import u from "@mui/material/IconButton";
8
+ var S = ({ action: c = "back", ariaLabelClose: n, onClose: p, shouldShowBorders: d, shouldShowShadow: l, title: e }) => {
9
+ const o = c === "back", a = /* @__PURE__ */ r(u, {
10
+ "aria-label": n,
11
+ autoFocus: !0,
12
+ color: o ? "primary" : "default",
13
+ onClick: p,
14
+ children: o ? /* @__PURE__ */ r(m, {
25
15
  color: "primary",
26
- onClick: t,
27
- children: /* @__PURE__ */ r(c, {
28
- color: "primary",
29
- sx: { fontSize: 22 }
30
- })
31
- }),
32
- /* @__PURE__ */ r(e, {
33
- sx: {
34
- flexGrow: 1,
35
- margin: "auto",
36
- textAlign: "center"
16
+ sx: { fontSize: 22 }
17
+ }) : /* @__PURE__ */ r(b, { sx: {
18
+ color: "action.active",
19
+ fontSize: 22
20
+ } })
21
+ }), t = /* @__PURE__ */ r(i, { width: "44px" });
22
+ return /* @__PURE__ */ f(s, {
23
+ "aria-labelledby": `${e?.replace(/\s+/g, "-").toLowerCase()}-header-title`,
24
+ direction: "row",
25
+ sx: {
26
+ alignItems: "center",
27
+ backgroundColor: "background.paper",
28
+ ...d && {
29
+ borderBottom: 1,
30
+ borderColor: "divider"
37
31
  },
38
- children: /* @__PURE__ */ r(l, {
39
- bold: !0,
40
- id: `${o?.replace(/\s+/g, "-").toLowerCase()}-header-title`,
41
- variant: "body1",
42
- children: o
43
- })
44
- }),
45
- /* @__PURE__ */ r(e, { width: "44px" })
46
- ]
47
- });
32
+ ...l && { boxShadow: "0px 2px 8px 0px #6A73811F" },
33
+ padding: "8px 8px 8px 8px"
34
+ },
35
+ children: [
36
+ o ? a : t,
37
+ /* @__PURE__ */ r(i, {
38
+ sx: {
39
+ flexGrow: 1,
40
+ margin: "auto",
41
+ textAlign: "center"
42
+ },
43
+ children: /* @__PURE__ */ r(x, {
44
+ bold: !0,
45
+ id: `${e?.replace(/\s+/g, "-").toLowerCase()}-header-title`,
46
+ variant: "body1",
47
+ children: e
48
+ })
49
+ }),
50
+ o ? t : a
51
+ ]
52
+ });
53
+ };
48
54
  export {
49
- k as default
55
+ S as default
50
56
  };
51
57
 
52
58
  //# sourceMappingURL=Header.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Header.es.js","names":[],"sources":["../../../../src/common/components/drawer/Header.tsx"],"sourcesContent":["import React from 'react'\n\nimport Box from '@mui/material/Box'\nimport Stack from '@mui/material/Stack'\nimport IconButton from '@mui/material/IconButton'\n\nimport { ArrowBack } from '@mxenabled/mx-icons'\n\nimport { H2 } from '@mxenabled/mxui'\n\ninterface DrawerHeaderProps {\n ariaLabelClose: string\n onClose: () => void\n shouldShowBorders: boolean\n shouldShowShadow?: boolean\n title: string\n}\n\nconst DrawerHeader: React.FC<DrawerHeaderProps> = ({\n ariaLabelClose,\n onClose,\n shouldShowBorders,\n shouldShowShadow,\n title,\n}) => {\n return (\n <Stack\n aria-labelledby={`${title?.replace(/\\s+/g, '-').toLowerCase()}-header-title`}\n direction=\"row\"\n sx={{\n alignItems: 'center',\n backgroundColor: 'background.paper',\n ...(shouldShowBorders && {\n borderBottom: 1,\n borderColor: 'divider',\n }),\n ...(shouldShowShadow && {\n boxShadow: '0px 2px 8px 0px #6A73811F',\n }),\n padding: '8px 8px 8px 8px',\n }}\n >\n <IconButton aria-label={ariaLabelClose} autoFocus={true} color=\"primary\" onClick={onClose}>\n <ArrowBack color=\"primary\" sx={{ fontSize: 22 }} />\n </IconButton>\n <Box\n sx={{\n flexGrow: 1,\n margin: 'auto',\n textAlign: 'center',\n }}\n >\n <H2\n bold={true}\n id={`${title?.replace(/\\s+/g, '-').toLowerCase()}-header-title`}\n variant=\"body1\"\n >\n {title}\n </H2>\n </Box>\n {/* placeholder for when we add a button here, this also ensures the title text is centered */}\n <Box width=\"44px\" />\n </Stack>\n )\n}\n\nexport default DrawerHeader\n"],"mappings":";;;;;;;AAkBA,IAAM,IAAA,CAA6C,EACjD,gBAAA,GACA,SAAA,GACA,mBAAA,GACA,kBAAA,GACA,OAAA,EAAA,MAGE,gBAAA,EAAC,GAAD;AAAA,EACE,mBAAiB,GAAG,GAAO,QAAQ,QAAQ,GAAG,EAAE,YAAY,CAAA;AAAA,EAC5D,WAAU;AAAA,EACV,IAAI;AAAA,IACF,YAAY;AAAA,IACZ,iBAAiB;AAAA,IACjB,GAAI,KAAqB;AAAA,MACvB,cAAc;AAAA,MACd,aAAa;AAAA,IACf;AAAA,IACA,GAAI,KAAoB,EACtB,WAAW,4BACb;AAAA,IACA,SAAS;AAAA,EACX;AAAA,EAdF,UAAA;AAAA,IAgBE,gBAAA,EAAC,GAAD;AAAA,MAAY,cAAY;AAAA,MAAgB,WAAW;AAAA,MAAM,OAAM;AAAA,MAAU,SAAS;AAAA,MAChF,UAAA,gBAAA,EAAC,GAAD;AAAA,QAAW,OAAM;AAAA,QAAU,IAAI,EAAE,UAAU,GAAG;AAAA,MAAI,CAAA;AAAA,IACxC,CAAA;AAAA,IACZ,gBAAA,EAAC,GAAD;AAAA,MACE,IAAI;AAAA,QACF,UAAU;AAAA,QACV,QAAQ;AAAA,QACR,WAAW;AAAA,MACb;AAAA,MAEA,UAAA,gBAAA,EAAC,GAAD;AAAA,QACE,MAAM;AAAA,QACN,IAAI,GAAG,GAAO,QAAQ,QAAQ,GAAG,EAAE,YAAY,CAAA;AAAA,QAC/C,SAAQ;AAAA,QAEP,UAAA;AAAA,MACC,CAAA;AAAA,IACD,CAAA;AAAA,IAEL,gBAAA,EAAC,GAAD,EAAK,OAAM,OAAQ,CAAA;AAAA,EACd"}
1
+ {"version":3,"file":"Header.es.js","names":[],"sources":["../../../../src/common/components/drawer/Header.tsx"],"sourcesContent":["import React from 'react'\n\nimport Box from '@mui/material/Box'\nimport Stack from '@mui/material/Stack'\nimport IconButton from '@mui/material/IconButton'\n\nimport { ArrowBack, Close } from '@mxenabled/mx-icons'\n\nimport { H2 } from '@mxenabled/mxui'\n\n/** `back` (default): an arrow on the left. `close`: an X on the right, as Figma's Budget Details. */\nexport type DrawerHeaderAction = 'back' | 'close'\n\ninterface DrawerHeaderProps {\n action?: DrawerHeaderAction\n ariaLabelClose: string\n onClose: () => void\n shouldShowBorders: boolean\n shouldShowShadow?: boolean\n title: string\n}\n\nconst DrawerHeader: React.FC<DrawerHeaderProps> = ({\n action = 'back',\n ariaLabelClose,\n onClose,\n shouldShowBorders,\n shouldShowShadow,\n title,\n}) => {\n const isBack = action === 'back'\n const button = (\n <IconButton\n aria-label={ariaLabelClose}\n autoFocus={true}\n color={isBack ? 'primary' : 'default'}\n onClick={onClose}\n >\n {isBack ? (\n <ArrowBack color=\"primary\" sx={{ fontSize: 22 }} />\n ) : (\n <Close sx={{ color: 'action.active', fontSize: 22 }} />\n )}\n </IconButton>\n )\n // Keeps the title centred opposite the button.\n const spacer = <Box width=\"44px\" />\n\n return (\n <Stack\n aria-labelledby={`${title?.replace(/\\s+/g, '-').toLowerCase()}-header-title`}\n direction=\"row\"\n sx={{\n alignItems: 'center',\n backgroundColor: 'background.paper',\n ...(shouldShowBorders && {\n borderBottom: 1,\n borderColor: 'divider',\n }),\n ...(shouldShowShadow && {\n boxShadow: '0px 2px 8px 0px #6A73811F',\n }),\n padding: '8px 8px 8px 8px',\n }}\n >\n {isBack ? button : spacer}\n <Box\n sx={{\n flexGrow: 1,\n margin: 'auto',\n textAlign: 'center',\n }}\n >\n <H2\n bold={true}\n id={`${title?.replace(/\\s+/g, '-').toLowerCase()}-header-title`}\n variant=\"body1\"\n >\n {title}\n </H2>\n </Box>\n {isBack ? spacer : button}\n </Stack>\n )\n}\n\nexport default DrawerHeader\n"],"mappings":";;;;;;;AAsBA,IAAM,IAAA,CAA6C,EACjD,QAAA,IAAS,QACT,gBAAA,GACA,SAAA,GACA,mBAAA,GACA,kBAAA,GACA,OAAA,EAAA,MACI;AACJ,QAAM,IAAS,MAAW,QACpB,IACJ,gBAAA,EAAC,GAAD;AAAA,IACE,cAAY;AAAA,IACZ,WAAW;AAAA,IACX,OAAO,IAAS,YAAY;AAAA,IAC5B,SAAS;AAAA,IAER,UAAA,IACC,gBAAA,EAAC,GAAD;AAAA,MAAW,OAAM;AAAA,MAAU,IAAI,EAAE,UAAU,GAAG;AAAA,IAAI,CAAA,IAElD,gBAAA,EAAC,GAAD,EAAO,IAAI;AAAA,MAAE,OAAO;AAAA,MAAiB,UAAU;AAAA,IAAG,EAAI,CAAA;AAAA,EAE9C,CAAA,GAGR,IAAS,gBAAA,EAAC,GAAD,EAAK,OAAM,OAAQ,CAAA;AAElC,SACE,gBAAA,EAAC,GAAD;AAAA,IACE,mBAAiB,GAAG,GAAO,QAAQ,QAAQ,GAAG,EAAE,YAAY,CAAA;AAAA,IAC5D,WAAU;AAAA,IACV,IAAI;AAAA,MACF,YAAY;AAAA,MACZ,iBAAiB;AAAA,MACjB,GAAI,KAAqB;AAAA,QACvB,cAAc;AAAA,QACd,aAAa;AAAA,MACf;AAAA,MACA,GAAI,KAAoB,EACtB,WAAW,4BACb;AAAA,MACA,SAAS;AAAA,IACX;AAAA,IAdF,UAAA;AAAA,MAgBG,IAAS,IAAS;AAAA,MACnB,gBAAA,EAAC,GAAD;AAAA,QACE,IAAI;AAAA,UACF,UAAU;AAAA,UACV,QAAQ;AAAA,UACR,WAAW;AAAA,QACb;AAAA,QAEA,UAAA,gBAAA,EAAC,GAAD;AAAA,UACE,MAAM;AAAA,UACN,IAAI,GAAG,GAAO,QAAQ,QAAQ,GAAG,EAAE,YAAY,CAAA;AAAA,UAC/C,SAAQ;AAAA,UAEP,UAAA;AAAA,QACC,CAAA;AAAA,MACD,CAAA;AAAA,MACJ,IAAS,IAAS;AAAA,IACd;AAAA;AAEX"}
@@ -39,6 +39,13 @@ type OpenActionDrawerArgs = {
39
39
  trigger: Exclude<ActionDrawerTrigger, 'inDescriptionCta'>;
40
40
  cta?: never;
41
41
  });
42
+ /** beatContext key: the beat's active_at as its card last rendered it (a sampled refresh drops it). */
43
+ export declare const BEAT_ACTIVE_AT_KEY = "active_at";
44
+ /** A message a block hands over when it closes its own drawer, shown after it unmounts. */
45
+ export interface ActionNotice {
46
+ message: string;
47
+ severity: 'success' | 'error';
48
+ }
42
49
  /** Lifecycle of a beat's CTA action (see insights-v2/ctaActions), keyed by beat guid. */
43
50
  export type CtaStatus = 'pending' | 'done' | 'error';
44
51
  /**
@@ -55,6 +62,8 @@ export declare class InsightsV2Store {
55
62
  * insights never reflects another card's pending or error state.
56
63
  */
57
64
  ctaStatus: Record<string, CtaStatus>;
65
+ /** The notice per beat guid that outlives its drawer session; ActionBlockLayer draws it. */
66
+ actionNotice: Record<string, ActionNotice | undefined>;
58
67
  /**
59
68
  * Per-beat scratch input collected on the card or in its blocks (e.g. the account a user
60
69
  * picked before pressing Save), keyed by beat guid. Unlike `actionDrawer.context`, which is
@@ -65,6 +74,7 @@ export declare class InsightsV2Store {
65
74
  */
66
75
  beatContext: Record<string, Record<string, unknown>>;
67
76
  constructor(globalStore: GlobalStore);
77
+ setActionNotice: (guid: string, notice: ActionNotice | undefined) => void;
68
78
  setCtaStatus: (guid: string, status: CtaStatus) => void;
69
79
  /** Merges `values` into the beat's scratch input. */
70
80
  setBeatContext: (guid: string, values: Record<string, unknown>) => void;
@@ -1,18 +1,25 @@
1
1
  import { makeAutoObservable as o } from "mobx";
2
- var i = {
2
+ var r = {
3
3
  isDrawerOpen: !1,
4
4
  trigger: "primaryCta",
5
5
  guid: "",
6
6
  context: void 0,
7
7
  cta: void 0
8
- }, n = class {
8
+ }, n = "active_at", c = class {
9
9
  globalStore;
10
- actionDrawer = i;
10
+ actionDrawer = r;
11
11
  ctaStatus = {};
12
+ actionNotice = {};
12
13
  beatContext = {};
13
14
  constructor(t) {
14
15
  this.globalStore = t, o(this);
15
16
  }
17
+ setActionNotice = (t, e) => {
18
+ this.actionNotice = {
19
+ ...this.actionNotice,
20
+ [t]: e
21
+ };
22
+ };
16
23
  setCtaStatus = (t, e) => {
17
24
  this.ctaStatus = {
18
25
  ...this.ctaStatus,
@@ -37,13 +44,13 @@ var i = {
37
44
  }
38
45
  };
39
46
  };
40
- openActionDrawer = ({ guid: t, trigger: e, context: a, cta: r }) => {
47
+ openActionDrawer = ({ guid: t, trigger: e, context: a, cta: i }) => {
41
48
  this.actionDrawer = {
42
49
  isDrawerOpen: !0,
43
50
  trigger: e,
44
51
  guid: t,
45
52
  context: a,
46
- cta: r
53
+ cta: i
47
54
  };
48
55
  };
49
56
  openCtaDrawer = (t, e) => {
@@ -61,8 +68,9 @@ var i = {
61
68
  };
62
69
  };
63
70
  export {
64
- i as CLOSED_ACTION_DRAWER,
65
- n as InsightsV2Store
71
+ n as BEAT_ACTIVE_AT_KEY,
72
+ r as CLOSED_ACTION_DRAWER,
73
+ c as InsightsV2Store
66
74
  };
67
75
 
68
76
  //# sourceMappingURL=InsightsV2Store.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"InsightsV2Store.es.js","names":[],"sources":["../../../src/core/stores/InsightsV2Store.ts"],"sourcesContent":["import { makeAutoObservable } from 'mobx'\n\nimport type { InDescriptionCTA } from '../types/Insights'\n\nimport type { GlobalStore } from './GlobalStore'\n\n// `inDescriptionCta`: the link inside a card's description (`insights_payload.in_description_cta`).\nexport type ActionDrawerTrigger = 'primaryCta' | 'secondaryCta' | 'chartBar' | 'inDescriptionCta'\n\nexport interface ActionDrawerState {\n isDrawerOpen: boolean\n trigger: ActionDrawerTrigger\n guid: string\n /**\n * Block-specific drilldown data for the current drawer SESSION, opaque to the\n * store. Each action block defines and reads its own shape (via\n * useActionContext<T>()). Chart drilldowns put `{ chartBarIndex, tabIndex }`\n * here; CTAs carry none.\n *\n * This is an accumulating bag, not a single owner's value: a nested drawer\n * (e.g. TransactionDetailsBlock opened from a row inside TransactionHistory\n * Block) adds its own key via `setActionContext` ON TOP of whatever the outer\n * drawer already put here, so the outer block's own context survives while the\n * nested block is open. It resets to a clean slate only when a NEW drawer\n * session starts (`openActionDrawer`/`openCtaDrawer`, which fully replace the\n * envelope) — not on every `setActionContext` call.\n */\n context: unknown\n /**\n * Block and variant an `inDescriptionCta` drawer runs; without it the beat's own\n * `in_description_cta` is used. Replaced on each open, kept through close like `trigger`.\n */\n cta?: DrawerCta\n}\n\nexport const CLOSED_ACTION_DRAWER: ActionDrawerState = {\n isDrawerOpen: false,\n trigger: 'primaryCta',\n guid: '',\n context: undefined,\n cta: undefined,\n}\n\n/** What an `inDescriptionCta` opener picks: the block, its variant and step (`action_key`). */\nexport type DrawerCta = Pick<InDescriptionCTA, 'block' | 'variant' | 'action_key'>\n\n// Only the `inDescriptionCta` trigger accepts a `cta`.\ntype OpenActionDrawerArgs = {\n guid: string\n context?: unknown\n} & (\n | { trigger: 'inDescriptionCta'; cta?: DrawerCta }\n | { trigger: Exclude<ActionDrawerTrigger, 'inDescriptionCta'>; cta?: never }\n)\n\n/** Lifecycle of a beat's CTA action (see insights-v2/ctaActions), keyed by beat guid. */\nexport type CtaStatus = 'pending' | 'done' | 'error'\n\n/**\n * UI state shared across the insights-v2 widget tree. Owns the action drawer so\n * cards, charts, and action blocks coordinate through the store instead of prop\n * drilling. The drawer state is a fixed envelope (isDrawerOpen/guid/trigger) plus\n * an opaque `context` bag, so per-block drilldown data never leaks into this shape.\n */\nexport class InsightsV2Store {\n globalStore: GlobalStore\n\n actionDrawer: ActionDrawerState = CLOSED_ACTION_DRAWER\n\n /**\n * CTA action status per beat guid. Keyed by guid (not block) so a block shared by many\n * insights never reflects another card's pending or error state.\n */\n ctaStatus: Record<string, CtaStatus> = {}\n\n /**\n * Per-beat scratch input collected on the card or in its blocks (e.g. the account a user\n * picked before pressing Save), keyed by beat guid. Unlike `actionDrawer.context`, which is\n * replaced whenever any drawer session starts, this survives other cards' drawers opening.\n * CTA steps read it via `disabledWhen` and their `params` callback (`beatContextOf`). Ships\n * ahead of its first block writer (Designate's account picker) on purpose: it is the layer's\n * only way to keep a pick alive across other cards' drawer sessions.\n */\n beatContext: Record<string, Record<string, unknown>> = {}\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n\n makeAutoObservable(this)\n }\n\n setCtaStatus = (guid: string, status: CtaStatus) => {\n this.ctaStatus = { ...this.ctaStatus, [guid]: status }\n }\n\n /** Merges `values` into the beat's scratch input. */\n setBeatContext = (guid: string, values: Record<string, unknown>) => {\n this.beatContext = { ...this.beatContext, [guid]: { ...this.beatContext[guid], ...values } }\n }\n\n /**\n * Merges keys into the current drawer session's context bag — it does NOT\n * replace it. A nested drawer (e.g. a row click inside TransactionHistoryBlock\n * opening TransactionDetailsBlock) calls this to layer its own key (e.g.\n * `transaction_guid`) on top of whatever context the outer drawer already set\n * (e.g. `chartBarIndex`), so the outer block keeps reading its own keys via\n * useActionContext while the nested block is open. The bag only returns to a\n * clean slate when a new drawer session starts via `openActionDrawer`/\n * `openCtaDrawer`, which fully replace the envelope.\n */\n setActionContext = (context: Record<string, unknown>) => {\n this.actionDrawer = {\n ...this.actionDrawer,\n context: {\n ...(this.actionDrawer.context as Record<string, unknown> | undefined),\n ...context,\n },\n }\n }\n\n /**\n * Generic drawer opener — the only opener a new action block needs. Pass the\n * beat guid, the CTA/source that triggered it, and (optionally) a block-specific\n * context object the block reads back via useActionContext. `cta` overrides the CTA an\n * `inDescriptionCta` drawer runs, for this session only.\n */\n openActionDrawer = ({ guid, trigger, context, cta }: OpenActionDrawerArgs) => {\n this.actionDrawer = { isDrawerOpen: true, trigger, guid, context, cta }\n }\n\n /** Convenience opener for CTA drawers (no drilldown context). */\n openCtaDrawer = (guid: string, trigger: 'primaryCta' | 'secondaryCta') => {\n this.openActionDrawer({ guid, trigger })\n }\n\n closeActionDrawer = () => {\n // Preserve `trigger`, `context` and `cta` so the drawer keeps its variant-specific\n // title/content through the slide-out animation (ActionBlockLayer stays\n // mounted while closing). Only flip isDrawerOpen off and clear the beat guid.\n this.actionDrawer = { ...this.actionDrawer, isDrawerOpen: false, guid: '' }\n }\n}\n"],"mappings":";AAmCA,IAAa,IAA0C;AAAA,EACrD,cAAc;AAAA,EACd,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,KAAK;AACP,GAuBa,IAAb,MAA6B;AAAA,EAC3B;AAAA,EAEA,eAAkC;AAAA,EAMlC,YAAuC,CAAC;AAAA,EAUxC,cAAuD,CAAC;AAAA,EAExD,YAAY,GAA0B;AACpC,SAAK,cAAc,GAEnB,EAAmB,IAAI;AAAA,EACzB;AAAA,EAEA,eAAA,CAAgB,GAAc,MAAsB;AAClD,SAAK,YAAY;AAAA,MAAE,GAAG,KAAK;AAAA,MAAY,CAAA,CAAA,GAAO;AAAA,IAAO;AAAA,EACvD;AAAA,EAGA,iBAAA,CAAkB,GAAc,MAAoC;AAClE,SAAK,cAAc;AAAA,MAAE,GAAG,KAAK;AAAA,MAAc,CAAA,CAAA,GAAO;AAAA,QAAE,GAAG,KAAK,YAAY,CAAA;AAAA,QAAO,GAAG;AAAA,MAAO;AAAA,IAAE;AAAA,EAC7F;AAAA,EAYA,mBAAA,CAAoB,MAAqC;AACvD,SAAK,eAAe;AAAA,MAClB,GAAG,KAAK;AAAA,MACR,SAAS;AAAA,QACP,GAAI,KAAK,aAAa;AAAA,QACtB,GAAG;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAAA,EAQA,mBAAA,CAAoB,EAAE,MAAA,GAAM,SAAA,GAAS,SAAA,GAAS,KAAA,EAAA,MAAgC;AAC5E,SAAK,eAAe;AAAA,MAAE,cAAc;AAAA,MAAM,SAAA;AAAA,MAAS,MAAA;AAAA,MAAM,SAAA;AAAA,MAAS,KAAA;AAAA,IAAI;AAAA,EACxE;AAAA,EAGA,gBAAA,CAAiB,GAAc,MAA2C;AACxE,SAAK,iBAAiB;AAAA,MAAE,MAAA;AAAA,MAAM,SAAA;AAAA,IAAQ,CAAC;AAAA,EACzC;AAAA,EAEA,oBAAA,MAA0B;AAIxB,SAAK,eAAe;AAAA,MAAE,GAAG,KAAK;AAAA,MAAc,cAAc;AAAA,MAAO,MAAM;AAAA,IAAG;AAAA,EAC5E;AACF"}
1
+ {"version":3,"file":"InsightsV2Store.es.js","names":[],"sources":["../../../src/core/stores/InsightsV2Store.ts"],"sourcesContent":["import { makeAutoObservable } from 'mobx'\n\nimport type { InDescriptionCTA } from '../types/Insights'\n\nimport type { GlobalStore } from './GlobalStore'\n\n// `inDescriptionCta`: the link inside a card's description (`insights_payload.in_description_cta`).\nexport type ActionDrawerTrigger = 'primaryCta' | 'secondaryCta' | 'chartBar' | 'inDescriptionCta'\n\nexport interface ActionDrawerState {\n isDrawerOpen: boolean\n trigger: ActionDrawerTrigger\n guid: string\n /**\n * Block-specific drilldown data for the current drawer SESSION, opaque to the\n * store. Each action block defines and reads its own shape (via\n * useActionContext<T>()). Chart drilldowns put `{ chartBarIndex, tabIndex }`\n * here; CTAs carry none.\n *\n * This is an accumulating bag, not a single owner's value: a nested drawer\n * (e.g. TransactionDetailsBlock opened from a row inside TransactionHistory\n * Block) adds its own key via `setActionContext` ON TOP of whatever the outer\n * drawer already put here, so the outer block's own context survives while the\n * nested block is open. It resets to a clean slate only when a NEW drawer\n * session starts (`openActionDrawer`/`openCtaDrawer`, which fully replace the\n * envelope) — not on every `setActionContext` call.\n */\n context: unknown\n /**\n * Block and variant an `inDescriptionCta` drawer runs; without it the beat's own\n * `in_description_cta` is used. Replaced on each open, kept through close like `trigger`.\n */\n cta?: DrawerCta\n}\n\nexport const CLOSED_ACTION_DRAWER: ActionDrawerState = {\n isDrawerOpen: false,\n trigger: 'primaryCta',\n guid: '',\n context: undefined,\n cta: undefined,\n}\n\n/** What an `inDescriptionCta` opener picks: the block, its variant and step (`action_key`). */\nexport type DrawerCta = Pick<InDescriptionCTA, 'block' | 'variant' | 'action_key'>\n\n// Only the `inDescriptionCta` trigger accepts a `cta`.\ntype OpenActionDrawerArgs = {\n guid: string\n context?: unknown\n} & (\n | { trigger: 'inDescriptionCta'; cta?: DrawerCta }\n | { trigger: Exclude<ActionDrawerTrigger, 'inDescriptionCta'>; cta?: never }\n)\n\n/** beatContext key: the beat's active_at as its card last rendered it (a sampled refresh drops it). */\nexport const BEAT_ACTIVE_AT_KEY = 'active_at'\n\n/** A message a block hands over when it closes its own drawer, shown after it unmounts. */\nexport interface ActionNotice {\n message: string\n severity: 'success' | 'error'\n}\n\n/** Lifecycle of a beat's CTA action (see insights-v2/ctaActions), keyed by beat guid. */\nexport type CtaStatus = 'pending' | 'done' | 'error'\n\n/**\n * UI state shared across the insights-v2 widget tree. Owns the action drawer so\n * cards, charts, and action blocks coordinate through the store instead of prop\n * drilling. The drawer state is a fixed envelope (isDrawerOpen/guid/trigger) plus\n * an opaque `context` bag, so per-block drilldown data never leaks into this shape.\n */\nexport class InsightsV2Store {\n globalStore: GlobalStore\n\n actionDrawer: ActionDrawerState = CLOSED_ACTION_DRAWER\n\n /**\n * CTA action status per beat guid. Keyed by guid (not block) so a block shared by many\n * insights never reflects another card's pending or error state.\n */\n ctaStatus: Record<string, CtaStatus> = {}\n\n /** The notice per beat guid that outlives its drawer session; ActionBlockLayer draws it. */\n actionNotice: Record<string, ActionNotice | undefined> = {}\n\n /**\n * Per-beat scratch input collected on the card or in its blocks (e.g. the account a user\n * picked before pressing Save), keyed by beat guid. Unlike `actionDrawer.context`, which is\n * replaced whenever any drawer session starts, this survives other cards' drawers opening.\n * CTA steps read it via `disabledWhen` and their `params` callback (`beatContextOf`). Ships\n * ahead of its first block writer (Designate's account picker) on purpose: it is the layer's\n * only way to keep a pick alive across other cards' drawer sessions.\n */\n beatContext: Record<string, Record<string, unknown>> = {}\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n\n makeAutoObservable(this)\n }\n\n setActionNotice = (guid: string, notice: ActionNotice | undefined) => {\n this.actionNotice = { ...this.actionNotice, [guid]: notice }\n }\n\n setCtaStatus = (guid: string, status: CtaStatus) => {\n this.ctaStatus = { ...this.ctaStatus, [guid]: status }\n }\n\n /** Merges `values` into the beat's scratch input. */\n setBeatContext = (guid: string, values: Record<string, unknown>) => {\n this.beatContext = { ...this.beatContext, [guid]: { ...this.beatContext[guid], ...values } }\n }\n\n /**\n * Merges keys into the current drawer session's context bag — it does NOT\n * replace it. A nested drawer (e.g. a row click inside TransactionHistoryBlock\n * opening TransactionDetailsBlock) calls this to layer its own key (e.g.\n * `transaction_guid`) on top of whatever context the outer drawer already set\n * (e.g. `chartBarIndex`), so the outer block keeps reading its own keys via\n * useActionContext while the nested block is open. The bag only returns to a\n * clean slate when a new drawer session starts via `openActionDrawer`/\n * `openCtaDrawer`, which fully replace the envelope.\n */\n setActionContext = (context: Record<string, unknown>) => {\n this.actionDrawer = {\n ...this.actionDrawer,\n context: {\n ...(this.actionDrawer.context as Record<string, unknown> | undefined),\n ...context,\n },\n }\n }\n\n /**\n * Generic drawer opener — the only opener a new action block needs. Pass the\n * beat guid, the CTA/source that triggered it, and (optionally) a block-specific\n * context object the block reads back via useActionContext. `cta` overrides the CTA an\n * `inDescriptionCta` drawer runs, for this session only.\n */\n openActionDrawer = ({ guid, trigger, context, cta }: OpenActionDrawerArgs) => {\n this.actionDrawer = { isDrawerOpen: true, trigger, guid, context, cta }\n }\n\n /** Convenience opener for CTA drawers (no drilldown context). */\n openCtaDrawer = (guid: string, trigger: 'primaryCta' | 'secondaryCta') => {\n this.openActionDrawer({ guid, trigger })\n }\n\n closeActionDrawer = () => {\n // Preserve `trigger`, `context` and `cta` so the drawer keeps its variant-specific\n // title/content through the slide-out animation (ActionBlockLayer stays\n // mounted while closing). Only flip isDrawerOpen off and clear the beat guid.\n this.actionDrawer = { ...this.actionDrawer, isDrawerOpen: false, guid: '' }\n }\n}\n"],"mappings":";AAmCA,IAAa,IAA0C;AAAA,EACrD,cAAc;AAAA,EACd,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,KAAK;AACP,GAea,IAAqB,aAiBrB,IAAb,MAA6B;AAAA,EAC3B;AAAA,EAEA,eAAkC;AAAA,EAMlC,YAAuC,CAAC;AAAA,EAGxC,eAAyD,CAAC;AAAA,EAU1D,cAAuD,CAAC;AAAA,EAExD,YAAY,GAA0B;AACpC,SAAK,cAAc,GAEnB,EAAmB,IAAI;AAAA,EACzB;AAAA,EAEA,kBAAA,CAAmB,GAAc,MAAqC;AACpE,SAAK,eAAe;AAAA,MAAE,GAAG,KAAK;AAAA,MAAe,CAAA,CAAA,GAAO;AAAA,IAAO;AAAA,EAC7D;AAAA,EAEA,eAAA,CAAgB,GAAc,MAAsB;AAClD,SAAK,YAAY;AAAA,MAAE,GAAG,KAAK;AAAA,MAAY,CAAA,CAAA,GAAO;AAAA,IAAO;AAAA,EACvD;AAAA,EAGA,iBAAA,CAAkB,GAAc,MAAoC;AAClE,SAAK,cAAc;AAAA,MAAE,GAAG,KAAK;AAAA,MAAc,CAAA,CAAA,GAAO;AAAA,QAAE,GAAG,KAAK,YAAY,CAAA;AAAA,QAAO,GAAG;AAAA,MAAO;AAAA,IAAE;AAAA,EAC7F;AAAA,EAYA,mBAAA,CAAoB,MAAqC;AACvD,SAAK,eAAe;AAAA,MAClB,GAAG,KAAK;AAAA,MACR,SAAS;AAAA,QACP,GAAI,KAAK,aAAa;AAAA,QACtB,GAAG;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAAA,EAQA,mBAAA,CAAoB,EAAE,MAAA,GAAM,SAAA,GAAS,SAAA,GAAS,KAAA,EAAA,MAAgC;AAC5E,SAAK,eAAe;AAAA,MAAE,cAAc;AAAA,MAAM,SAAA;AAAA,MAAS,MAAA;AAAA,MAAM,SAAA;AAAA,MAAS,KAAA;AAAA,IAAI;AAAA,EACxE;AAAA,EAGA,gBAAA,CAAiB,GAAc,MAA2C;AACxE,SAAK,iBAAiB;AAAA,MAAE,MAAA;AAAA,MAAM,SAAA;AAAA,IAAQ,CAAC;AAAA,EACzC;AAAA,EAEA,oBAAA,MAA0B;AAIxB,SAAK,eAAe;AAAA,MAAE,GAAG,KAAK;AAAA,MAAc,cAAc;AAAA,MAAO,MAAM;AAAA,IAAG;AAAA,EAC5E;AACF"}
@@ -1,43 +1,54 @@
1
- import { useGlobalCopyStore as C, useGlobalUiStore as _, useInsightsV2Store as h } from "../../common/context/hooks.es.js";
2
- import B from "../../common/components/drawer/Drawer.es.js";
3
- import v from "../../common/components/Loader.es.js";
4
- import { hasDrawerBlock as w } from "../mappings/hasDrawerBlock.es.js";
5
- import { getDynamicCtaBasedOnTriggers as D } from "./util.es.js";
6
- import { actionBlocks as b } from "../mappings/blocks.es.js";
7
- import { observer as L } from "mobx-react-lite";
8
- import x from "@mui/material/Stack";
9
- import { Text as A } from "@mxenabled/mxui";
10
- import { jsx as e } from "react/jsx-runtime";
11
- var m = ({ actionBlock: s, ...o }) => {
12
- const { Component: i, usePrepare: n } = s;
13
- return n(o), /* @__PURE__ */ e(i, { ...o });
14
- }, q = L(function({ beat: o }) {
15
- const i = C(), n = i.common, { isCopyLoaded: p } = _(), { actionDrawer: c, closeActionDrawer: d } = h();
1
+ import { useGlobalCopyStore as S, useGlobalUiStore as b, useInsightsV2Store as w } from "../../common/context/hooks.es.js";
2
+ import D from "../../common/components/drawer/Drawer.es.js";
3
+ import L from "../../common/components/Loader.es.js";
4
+ import { hasDrawerBlock as x } from "../mappings/hasDrawerBlock.es.js";
5
+ import O from "../components/shared/StatusSnackbar.es.js";
6
+ import { getDynamicCtaBasedOnTriggers as T } from "./util.es.js";
7
+ import { actionBlocks as j } from "../mappings/blocks.es.js";
8
+ import { useRef as F } from "react";
9
+ import { observer as G } from "mobx-react-lite";
10
+ import N from "@mui/material/Stack";
11
+ import { Text as R } from "@mxenabled/mxui";
12
+ import { Fragment as d, jsx as e, jsxs as u } from "react/jsx-runtime";
13
+ var V = (c, o) => {
14
+ const r = F(void 0);
15
+ return c ? (r.current ??= o, r.current) : (r.current = void 0, o);
16
+ }, f = ({ actionBlock: c, ...o }) => {
17
+ const { Component: r, usePrepare: i } = c;
18
+ return i(o), /* @__PURE__ */ e(r, { ...o });
19
+ }, W = G(function({ beat: o }) {
20
+ const r = S(), i = r.common, { isCopyLoaded: g } = b(), { actionDrawer: a, actionNotice: k, closeActionDrawer: y, setActionNotice: h } = w(), { primary_cta: v, secondary_cta: C, in_description_cta: _ } = o.insights_payload ?? {}, s = a.isDrawerOpen && a.guid === o.guid, t = V(s, T(a, v, C, _));
16
21
  if (!o.insights_payload) return null;
17
- const { primary_cta: u, secondary_cta: f, in_description_cta: k } = o.insights_payload, a = c.isDrawerOpen && c.guid === o.guid;
18
- if (!p) return a ? /* @__PURE__ */ e(v, {}) : null;
19
- const r = D(c, u, f, k), l = w(r?.block), t = l ? b[r?.block] : void 0;
20
- if (t?.presentation === "modal") return a ? /* @__PURE__ */ e(m, {
21
- actionBlock: t,
22
+ if (!g) return s ? /* @__PURE__ */ e(L, {}) : null;
23
+ const l = k[o.guid], p = /* @__PURE__ */ e(O, {
24
+ closeAriaLabel: i.close_aria,
25
+ message: l?.message ?? "",
26
+ onClose: () => h(o.guid, void 0),
27
+ open: !!l,
28
+ severity: l?.severity
29
+ }), m = x(t?.block), n = m ? j[t?.block] : void 0;
30
+ if (n?.presentation === "modal") return /* @__PURE__ */ u(d, { children: [s && /* @__PURE__ */ e(f, {
31
+ actionBlock: n,
22
32
  beat: o
23
- }, r?.block) : null;
24
- const y = t?.title?.(r?.variant, i, o), g = t ? y || r?.label || "" : l ? n.error_heading : r?.label ?? "";
25
- return /* @__PURE__ */ e(B, {
26
- ariaLabelClose: n.close_aria,
27
- isOpen: a,
28
- onClose: d,
29
- title: g,
30
- children: t ? /* @__PURE__ */ e(m, {
31
- actionBlock: t,
33
+ }, t?.block), p] });
34
+ const B = n?.title?.(t?.variant, r, o), A = n ? B || t?.label || "" : m ? i.error_heading : t?.label ?? "";
35
+ return /* @__PURE__ */ u(d, { children: [/* @__PURE__ */ e(D, {
36
+ ariaLabelClose: i.close_aria,
37
+ headerAction: n?.headerAction,
38
+ isOpen: s,
39
+ onClose: y,
40
+ title: A,
41
+ children: n ? /* @__PURE__ */ e(f, {
42
+ actionBlock: n,
32
43
  beat: o
33
- }, r?.block) : l ? /* @__PURE__ */ e(x, {
44
+ }, t?.block) : m ? /* @__PURE__ */ e(N, {
34
45
  sx: { p: 24 },
35
- children: /* @__PURE__ */ e(A, { children: n.error_message })
46
+ children: /* @__PURE__ */ e(R, { children: i.error_message })
36
47
  }) : null
37
- });
48
+ }), p] });
38
49
  });
39
50
  export {
40
- q as ActionBlockLayer
51
+ W as ActionBlockLayer
41
52
  };
42
53
 
43
54
  //# sourceMappingURL=ActionBlockLayer.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ActionBlockLayer.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/ActionBlockLayer.tsx"],"sourcesContent":["import Stack from '@mui/material/Stack'\n\nimport { Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport {\n Drawer,\n Loader,\n useGlobalCopyStore,\n useGlobalUiStore,\n useInsightsV2Store,\n} from '../../common'\nimport { type Beat } from '../../core'\nimport {\n actionBlocks,\n hasDrawerBlock,\n type ActionBlockEntry,\n type ActionBlockProps,\n} from '../mappings/blocks'\nimport { getDynamicCtaBasedOnTriggers } from './util'\n\ninterface ActionBlockLayerProps {\n beat: Beat\n}\n\n/**\n * Renders a registered action block. Callers MUST key this per block name — a\n * block with `usePrepare` and one without run a different number of hooks, so\n * reusing the same fiber across a block switch violates the rules of hooks.\n */\nconst ActionBlockRunner = ({\n actionBlock,\n ...blockProps\n}: ActionBlockProps & { actionBlock: ActionBlockEntry }) => {\n const { Component, usePrepare } = actionBlock\n\n usePrepare(blockProps)\n\n return <Component {...blockProps} />\n}\n\n// `observer` is required: this reads `isCopyLoaded` off GlobalUiStore and the\n// action drawer off InsightsV2Store. Without it the component never re-renders\n// and stays stuck on <Loader /> forever.\nexport const ActionBlockLayer = observer(function ActionBlockLayer({\n beat,\n}: ActionBlockLayerProps) {\n const copy = useGlobalCopyStore()\n const commonCopy = copy.common\n const { isCopyLoaded } = useGlobalUiStore()\n const { actionDrawer, closeActionDrawer } = useInsightsV2Store()\n\n // Mirrors BaseLayout's guard — the layer is exported, so callers are not\n // guaranteed to have narrowed this already.\n if (!beat.insights_payload) return null\n\n const { primary_cta, secondary_cta, in_description_cta } = beat.insights_payload\n\n // Every card in the feed renders its own layer against the shared store, so\n // this card's drawer only opens when its beat is the one that triggered it.\n const isCurrentBeatOpen = actionDrawer.isDrawerOpen && actionDrawer.guid === beat.guid\n\n if (!isCopyLoaded) return isCurrentBeatOpen ? <Loader /> : null\n\n const currentCta = getDynamicCtaBasedOnTriggers(\n actionDrawer,\n primary_cta,\n secondary_cta,\n in_description_cta,\n )\n\n // A CTA without a real block never opens a drawer (BaseLayout won't trigger it);\n // a real-but-unknown block shows the error (\"oops\") content.\n const blockValid = hasDrawerBlock(currentCta?.block)\n const actionBlock = blockValid\n ? actionBlocks[currentCta?.block as keyof typeof actionBlocks]\n : undefined\n\n // A modal block owns its dialog: no drawer behind it, and nothing mounted until it is opened.\n if (actionBlock?.presentation === 'modal') {\n return isCurrentBeatOpen ? (\n <ActionBlockRunner actionBlock={actionBlock} beat={beat} key={currentCta?.block} />\n ) : null\n }\n\n const resolvedTitle = actionBlock?.title?.(currentCta?.variant, copy, beat)\n const drawerTitle = actionBlock\n ? resolvedTitle || currentCta?.label || ''\n : blockValid\n ? commonCopy.error_heading\n : (currentCta?.label ?? '')\n\n return (\n <Drawer\n ariaLabelClose={commonCopy.close_aria}\n isOpen={isCurrentBeatOpen}\n onClose={closeActionDrawer}\n title={drawerTitle}\n >\n {actionBlock ? (\n <ActionBlockRunner actionBlock={actionBlock} beat={beat} key={currentCta?.block} />\n ) : blockValid ? (\n <Stack sx={{ p: 24 }}>\n <Text>{commonCopy.error_message}</Text>\n </Stack>\n ) : null}\n </Drawer>\n )\n})\n"],"mappings":";;;;;;;;;;AA8BA,IAAM,IAAA,CAAqB,EACzB,aAAA,GACA,GAAG,EAAA,MACuD;AAC1D,QAAM,EAAE,WAAA,GAAW,YAAA,EAAA,IAAe;AAElC,SAAA,EAAW,CAAU,GAEd,gBAAA,EAAC,GAAD,EAAW,GAAI,EAAa,CAAA;AACrC,GAKa,IAAmB,EAAS,SAA0B,EACjE,MAAA,EAAA,GACwB;AACxB,QAAM,IAAO,EAAmB,GAC1B,IAAa,EAAK,QAClB,EAAE,cAAA,EAAA,IAAiB,EAAiB,GACpC,EAAE,cAAA,GAAc,mBAAA,EAAA,IAAsB,EAAmB;AAI/D,MAAI,CAAC,EAAK,iBAAkB,QAAO;AAEnC,QAAM,EAAE,aAAA,GAAa,eAAA,GAAe,oBAAA,EAAA,IAAuB,EAAK,kBAI1D,IAAoB,EAAa,gBAAgB,EAAa,SAAS,EAAK;AAElF,MAAI,CAAC,EAAc,QAAO,IAAoB,gBAAA,EAAC,GAAD,CAAS,CAAA,IAAI;AAE3D,QAAM,IAAa,EACjB,GACA,GACA,GACA,CACF,GAIM,IAAa,EAAe,GAAY,KAAK,GAC7C,IAAc,IAChB,EAAa,GAAY,KAAA,IACzB;AAGJ,MAAI,GAAa,iBAAiB,QAChC,QAAO,IACL,gBAAA,EAAC,GAAD;AAAA,IAAgC,aAAA;AAAA,IAAmB,MAAA;AAAA,EAA+B,GAApB,GAAY,KAAQ,IAChF;AAGN,QAAM,IAAgB,GAAa,QAAQ,GAAY,SAAS,GAAM,CAAI,GACpE,IAAc,IAChB,KAAiB,GAAY,SAAS,KACtC,IACE,EAAW,gBACV,GAAY,SAAS;AAE5B,SACE,gBAAA,EAAC,GAAD;AAAA,IACE,gBAAgB,EAAW;AAAA,IAC3B,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,OAAO;AAAA,IAEN,UAAA,IACC,gBAAA,EAAC,GAAD;AAAA,MAAgC,aAAA;AAAA,MAAmB,MAAA;AAAA,IAA+B,GAApB,GAAY,KAAQ,IAChF,IACF,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI,EAAE,GAAG,GAAG;AAAA,MACjB,UAAA,gBAAA,EAAC,GAAD,EAAA,UAAO,EAAW,cAAoB,CAAA;AAAA,IACjC,CAAA,IACL;AAAA,EACE,CAAA;AAEZ,CAAC"}
1
+ {"version":3,"file":"ActionBlockLayer.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/ActionBlockLayer.tsx"],"sourcesContent":["import { useRef } from 'react'\n\nimport Stack from '@mui/material/Stack'\n\nimport { Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport {\n Drawer,\n Loader,\n useGlobalCopyStore,\n useGlobalUiStore,\n useInsightsV2Store,\n} from '../../common'\nimport { type Beat, type InDescriptionCTA, type PrimaryCTA, type SecondaryCTA } from '../../core'\nimport {\n actionBlocks,\n hasDrawerBlock,\n type ActionBlockEntry,\n type ActionBlockProps,\n} from '../mappings/blocks'\nimport StatusSnackbar from '../components/shared/StatusSnackbar'\nimport { getDynamicCtaBasedOnTriggers } from './util'\n\ninterface ActionBlockLayerProps {\n beat: Beat\n}\n\ntype OpenedCta = PrimaryCTA | SecondaryCTA | InDescriptionCTA | undefined\n\n/** Keeps the CTA the user pressed for the open session: a refreshed beat may name another CTA there. */\nconst useSessionCta = (isOpen: boolean, resolved: OpenedCta): OpenedCta => {\n const pinned = useRef<OpenedCta>(undefined)\n\n if (!isOpen) {\n pinned.current = undefined\n return resolved\n }\n pinned.current ??= resolved\n\n return pinned.current\n}\n\n/**\n * Renders a registered action block. Callers MUST key this per block name — a\n * block with `usePrepare` and one without run a different number of hooks, so\n * reusing the same fiber across a block switch violates the rules of hooks.\n */\nconst ActionBlockRunner = ({\n actionBlock,\n ...blockProps\n}: ActionBlockProps & { actionBlock: ActionBlockEntry }) => {\n const { Component, usePrepare } = actionBlock\n\n usePrepare(blockProps)\n\n return <Component {...blockProps} />\n}\n\n// `observer` is required: this reads `isCopyLoaded` off GlobalUiStore and the\n// action drawer off InsightsV2Store. Without it the component never re-renders\n// and stays stuck on <Loader /> forever.\nexport const ActionBlockLayer = observer(function ActionBlockLayer({\n beat,\n}: ActionBlockLayerProps) {\n const copy = useGlobalCopyStore()\n const commonCopy = copy.common\n const { isCopyLoaded } = useGlobalUiStore()\n const { actionDrawer, actionNotice, closeActionDrawer, setActionNotice } = useInsightsV2Store()\n\n const { primary_cta, secondary_cta, in_description_cta } = beat.insights_payload ?? {}\n\n // Every card in the feed renders its own layer against the shared store, so\n // this card's drawer only opens when its beat is the one that triggered it.\n const isCurrentBeatOpen = actionDrawer.isDrawerOpen && actionDrawer.guid === beat.guid\n\n const currentCta = useSessionCta(\n isCurrentBeatOpen,\n getDynamicCtaBasedOnTriggers(actionDrawer, primary_cta, secondary_cta, in_description_cta),\n )\n\n // Mirrors BaseLayout's guard — the layer is exported, so callers are not\n // guaranteed to have narrowed this already.\n if (!beat.insights_payload) return null\n\n if (!isCopyLoaded) return isCurrentBeatOpen ? <Loader /> : null\n\n // A block that closes its own drawer hands its message here, so it shows after the unmount.\n const notice = actionNotice[beat.guid]\n const noticeSnackbar = (\n <StatusSnackbar\n closeAriaLabel={commonCopy.close_aria}\n message={notice?.message ?? ''}\n onClose={() => setActionNotice(beat.guid, undefined)}\n open={Boolean(notice)}\n severity={notice?.severity}\n />\n )\n\n // A CTA without a real block never opens a drawer (BaseLayout won't trigger it);\n // a real-but-unknown block shows the error (\"oops\") content.\n const blockValid = hasDrawerBlock(currentCta?.block)\n const actionBlock = blockValid\n ? actionBlocks[currentCta?.block as keyof typeof actionBlocks]\n : undefined\n\n // A modal block owns its dialog: no drawer behind it, and nothing mounted until it is opened.\n if (actionBlock?.presentation === 'modal') {\n return (\n <>\n {isCurrentBeatOpen && (\n <ActionBlockRunner actionBlock={actionBlock} beat={beat} key={currentCta?.block} />\n )}\n {noticeSnackbar}\n </>\n )\n }\n\n const resolvedTitle = actionBlock?.title?.(currentCta?.variant, copy, beat)\n const drawerTitle = actionBlock\n ? resolvedTitle || currentCta?.label || ''\n : blockValid\n ? commonCopy.error_heading\n : (currentCta?.label ?? '')\n\n return (\n <>\n <Drawer\n ariaLabelClose={commonCopy.close_aria}\n headerAction={actionBlock?.headerAction}\n isOpen={isCurrentBeatOpen}\n onClose={closeActionDrawer}\n title={drawerTitle}\n >\n {actionBlock ? (\n <ActionBlockRunner actionBlock={actionBlock} beat={beat} key={currentCta?.block} />\n ) : blockValid ? (\n <Stack sx={{ p: 24 }}>\n <Text>{commonCopy.error_message}</Text>\n </Stack>\n ) : null}\n </Drawer>\n {noticeSnackbar}\n </>\n )\n})\n"],"mappings":";;;;;;;;;;;;AA+BA,IAAM,IAAA,CAAiB,GAAiB,MAAmC;AACzE,QAAM,IAAS,EAAkB,MAAS;AAE1C,SAAK,KAIL,EAAO,YAAY,GAEZ,EAAO,YALZ,EAAO,UAAU,QACV;AAKX,GAOM,IAAA,CAAqB,EACzB,aAAA,GACA,GAAG,EAAA,MACuD;AAC1D,QAAM,EAAE,WAAA,GAAW,YAAA,EAAA,IAAe;AAElC,SAAA,EAAW,CAAU,GAEd,gBAAA,EAAC,GAAD,EAAW,GAAI,EAAa,CAAA;AACrC,GAKa,IAAmB,EAAS,SAA0B,EACjE,MAAA,EAAA,GACwB;AACxB,QAAM,IAAO,EAAmB,GAC1B,IAAa,EAAK,QAClB,EAAE,cAAA,EAAA,IAAiB,EAAiB,GACpC,EAAE,cAAA,GAAc,cAAA,GAAc,mBAAA,GAAmB,iBAAA,EAAA,IAAoB,EAAmB,GAExF,EAAE,aAAA,GAAa,eAAA,GAAe,oBAAA,EAAA,IAAuB,EAAK,oBAAoB,CAAC,GAI/E,IAAoB,EAAa,gBAAgB,EAAa,SAAS,EAAK,MAE5E,IAAa,EACjB,GACA,EAA6B,GAAc,GAAa,GAAe,CAAkB,CAC3F;AAIA,MAAI,CAAC,EAAK,iBAAkB,QAAO;AAEnC,MAAI,CAAC,EAAc,QAAO,IAAoB,gBAAA,EAAC,GAAD,CAAS,CAAA,IAAI;AAG3D,QAAM,IAAS,EAAa,EAAK,IAAA,GAC3B,IACJ,gBAAA,EAAC,GAAD;AAAA,IACE,gBAAgB,EAAW;AAAA,IAC3B,SAAS,GAAQ,WAAW;AAAA,IAC5B,SAAA,MAAe,EAAgB,EAAK,MAAM,MAAS;AAAA,IACnD,MAAM,EAAQ;AAAA,IACd,UAAU,GAAQ;AAAA,EACnB,CAAA,GAKG,IAAa,EAAe,GAAY,KAAK,GAC7C,IAAc,IAChB,EAAa,GAAY,KAAA,IACzB;AAGJ,MAAI,GAAa,iBAAiB,QAChC,QACE,gBAAA,EAAA,GAAA,EAAA,UAAA,CACG,KACC,gBAAA,EAAC,GAAD;AAAA,IAAgC,aAAA;AAAA,IAAmB,MAAA;AAAA,EAA+B,GAApB,GAAY,KAAQ,GAEnF,CACD,EAAA,CAAA;AAIN,QAAM,IAAgB,GAAa,QAAQ,GAAY,SAAS,GAAM,CAAI,GACpE,IAAc,IAChB,KAAiB,GAAY,SAAS,KACtC,IACE,EAAW,gBACV,GAAY,SAAS;AAE5B,SACE,gBAAA,EAAA,GAAA,EAAA,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,IACE,gBAAgB,EAAW;AAAA,IAC3B,cAAc,GAAa;AAAA,IAC3B,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,OAAO;AAAA,IAEN,UAAA,IACC,gBAAA,EAAC,GAAD;AAAA,MAAgC,aAAA;AAAA,MAAmB,MAAA;AAAA,IAA+B,GAApB,GAAY,KAAQ,IAChF,IACF,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI,EAAE,GAAG,GAAG;AAAA,MACjB,UAAA,gBAAA,EAAC,GAAD,EAAA,UAAO,EAAW,cAAoB,CAAA;AAAA,IACjC,CAAA,IACL;AAAA,EACE,CAAA,GACP,CACD,EAAA,CAAA;AAEN,CAAC"}
@@ -1,13 +1,5 @@
1
1
  import { ActionBlockProps } from '../../mappings/blocks';
2
- /**
3
- * `amount_input_modal_block`: one whole-dollar setting edited in a dialog (Figma 441:24913 and
4
- * 5402:34137). The CTA's variant picks what is edited:
5
- * - `low_balance_threshold`: the `threshold` on the beat account's low-balance alert profile;
6
- * - `safety_net`: `savings_opportunity_minimum_checking_account_balance` on the insight profile.
7
- *
8
- * Registered with `presentation: 'modal'`, so no drawer opens behind it; closing the dialog ends
9
- * the action-drawer session. `observer` is required: the starting values are read from stores.
10
- */
2
+ /** `amount_input_modal_block`: one whole-dollar amount in a modal, picked by the CTA variant. */
11
3
  export declare const AmountInputModalBlock: (({ beat, }: ActionBlockProps) => import("react/jsx-runtime").JSX.Element) & {
12
4
  displayName: string;
13
5
  };