@mx-cartographer/experiences 9.7.164 → 9.7.165

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 (23) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/insights-v2/actionBlocks/AccountListBlock/AccountListBlock.es.js +34 -37
  3. package/dist/insights-v2/actionBlocks/AccountListBlock/AccountListBlock.es.js.map +1 -1
  4. package/dist/insights-v2/actionBlocks/ActionBlockLayer.es.js +40 -37
  5. package/dist/insights-v2/actionBlocks/ActionBlockLayer.es.js.map +1 -1
  6. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffCalculatorBlock.d.ts +3 -1
  7. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffCalculatorBlock.es.js +54 -51
  8. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffCalculatorBlock.es.js.map +1 -1
  9. package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/index.d.ts +1 -1
  10. package/dist/insights-v2/actionBlocks/PayoffStrategiesBlock/PayoffStrategiesBlock.es.js +24 -27
  11. package/dist/insights-v2/actionBlocks/PayoffStrategiesBlock/PayoffStrategiesBlock.es.js.map +1 -1
  12. package/dist/insights-v2/actionBlocks/PlaceholderActionBlock.es.js.map +1 -1
  13. package/dist/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashBlock.d.ts +3 -1
  14. package/dist/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashBlock.es.js +49 -46
  15. package/dist/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashBlock.es.js.map +1 -1
  16. package/dist/insights-v2/actionBlocks/RemainingCashBlock/index.d.ts +1 -1
  17. package/dist/insights-v2/actionBlocks/useAccountsLoadState.d.ts +3 -0
  18. package/dist/insights-v2/actionBlocks/useAccountsLoadState.es.js +7 -0
  19. package/dist/insights-v2/actionBlocks/useAccountsLoadState.es.js.map +1 -0
  20. package/dist/insights-v2/mappings/blocks.d.ts +6 -0
  21. package/dist/insights-v2/mappings/blocks.es.js +144 -136
  22. package/dist/insights-v2/mappings/blocks.es.js.map +1 -1
  23. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"PayoffStrategiesBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/PayoffStrategiesBlock/PayoffStrategiesBlock.tsx"],"sourcesContent":["import { useState } from 'react'\n\nimport { observer } from 'mobx-react-lite'\n\nimport { Drawer, Loader, useAccountStore, useGlobalCopyStore } from '../../../common'\nimport type { GlobalCopy } from '../../../core'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { AccountDetailsBlock } from '../AccountDetailsBlock'\nimport { useRequiredCopy } from '../useRequiredCopy'\n\nimport PayoffStrategiesContent from './PayoffStrategiesContent'\nimport { buildStrategies, resolveStrategyAccounts, toPayoffAccountRow } from './layout'\n\nexport const selectPayoffStrategiesCopy = (copy: GlobalCopy) => copy.insights_feed?.general\n\n/**\n * Debt Payoff Strategies drawer: Avalanche / Snowball tabs, each with the strategy's words and the\n * beat's debt accounts in that strategy's order. A tapped account opens its Account Details (the\n * shared AccountDetailsBlock) in a nested drawer.\n */\nexport const PayoffStrategiesBlock = observer(function PayoffStrategiesBlock({\n beat,\n}: ActionBlockProps) {\n const [tappedAccountGuid, setTappedAccountGuid] = useState<string | null>(null)\n const { accounts: accountsCopy } = useGlobalCopyStore()\n const { accountsLoaded, visibleAccounts } = useAccountStore()\n const copy = useRequiredCopy(selectPayoffStrategiesCopy)\n\n if (!accountsLoaded) return <Loader />\n\n const rows = resolveStrategyAccounts(beat, visibleAccounts).map(toPayoffAccountRow)\n const closeAccountDetails = () => setTappedAccountGuid(null)\n\n return (\n <>\n <PayoffStrategiesContent\n accounts={rows}\n copy={copy}\n onAccountClick={setTappedAccountGuid}\n strategies={buildStrategies(copy)}\n />\n <Drawer\n ariaLabelClose={accountsCopy?.close_account_details_aria}\n isOpen={tappedAccountGuid !== null}\n onClose={closeAccountDetails}\n title={accountsCopy?.account_details}\n >\n {tappedAccountGuid && (\n // The shared block shows the beat's account, so hand it the tapped one instead.\n <AccountDetailsBlock\n beat={{ ...beat, primary_account: undefined, primary_account_guid: tappedAccountGuid }}\n />\n )}\n </Drawer>\n </>\n )\n})\n"],"mappings":";;;;;;;;;;AAaA,IAAa,IAAA,CAA8B,MAAqB,EAAK,eAAe,SAOvE,IAAwB,EAAS,SAA+B,EAC3E,MAAA,EAAA,GACmB;AACnB,QAAM,CAAC,GAAmB,CAAA,IAAwB,EAAwB,IAAI,GACxE,EAAE,UAAU,EAAA,IAAiB,EAAmB,GAChD,EAAE,gBAAA,GAAgB,iBAAA,EAAA,IAAoB,EAAgB,GACtD,IAAO,EAAgB,CAA0B;AAEvD,MAAI,CAAC,EAAgB,QAAO,gBAAA,EAAC,GAAD,CAAS,CAAA;AAErC,QAAM,IAAO,EAAwB,GAAM,CAAe,EAAE,IAAI,CAAkB,GAC5E,IAAA,MAA4B,EAAqB,IAAI;AAE3D,SACE,gBAAA,EAAA,GAAA,EAAA,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,IACE,UAAU;AAAA,IACJ,MAAA;AAAA,IACN,gBAAgB;AAAA,IAChB,YAAY,EAAgB,CAAI;AAAA,EACjC,CAAA,GACD,gBAAA,EAAC,GAAD;AAAA,IACE,gBAAgB,GAAc;AAAA,IAC9B,QAAQ,MAAsB;AAAA,IAC9B,SAAS;AAAA,IACT,OAAO,GAAc;AAAA,IAEpB,UAAA,KAEC,gBAAA,EAAC,GAAD,EACE,MAAM;AAAA,MAAE,GAAG;AAAA,MAAM,iBAAiB;AAAA,MAAW,sBAAsB;AAAA,IAAkB,EACtF,CAAA;AAAA,EAEG,CAAA,CACR,EAAA,CAAA;AAEN,CAAC"}
1
+ {"version":3,"file":"PayoffStrategiesBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/PayoffStrategiesBlock/PayoffStrategiesBlock.tsx"],"sourcesContent":["import { useState } from 'react'\n\nimport { observer } from 'mobx-react-lite'\n\nimport { Drawer, useAccountStore, useGlobalCopyStore } from '../../../common'\nimport type { GlobalCopy } from '../../../core'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { AccountDetailsBlock } from '../AccountDetailsBlock'\nimport { useRequiredCopy } from '../useRequiredCopy'\n\nimport PayoffStrategiesContent from './PayoffStrategiesContent'\nimport { buildStrategies, resolveStrategyAccounts, toPayoffAccountRow } from './layout'\n\nexport const selectPayoffStrategiesCopy = (copy: GlobalCopy) => copy.insights_feed?.general\n\n/**\n * Debt Payoff Strategies drawer: Avalanche / Snowball tabs, each with the strategy's words and the\n * beat's debt accounts in that strategy's order. A tapped account opens its Account Details (the\n * shared AccountDetailsBlock) in a nested drawer.\n */\nexport const PayoffStrategiesBlock = observer(function PayoffStrategiesBlock({\n beat,\n}: ActionBlockProps) {\n const [tappedAccountGuid, setTappedAccountGuid] = useState<string | null>(null)\n const { accounts: accountsCopy } = useGlobalCopyStore()\n const { visibleAccounts } = useAccountStore()\n const copy = useRequiredCopy(selectPayoffStrategiesCopy)\n\n const rows = resolveStrategyAccounts(beat, visibleAccounts).map(toPayoffAccountRow)\n const closeAccountDetails = () => setTappedAccountGuid(null)\n\n return (\n <>\n <PayoffStrategiesContent\n accounts={rows}\n copy={copy}\n onAccountClick={setTappedAccountGuid}\n strategies={buildStrategies(copy)}\n />\n <Drawer\n ariaLabelClose={accountsCopy?.close_account_details_aria}\n isOpen={tappedAccountGuid !== null}\n onClose={closeAccountDetails}\n title={accountsCopy?.account_details}\n >\n {tappedAccountGuid && (\n // The shared block shows the beat's account, so hand it the tapped one instead.\n <AccountDetailsBlock\n beat={{ ...beat, primary_account: undefined, primary_account_guid: tappedAccountGuid }}\n />\n )}\n </Drawer>\n </>\n )\n})\n"],"mappings":";;;;;;;;;AAaA,IAAa,IAAA,CAA8B,MAAqB,EAAK,eAAe,SAOvE,IAAwB,EAAS,SAA+B,EAC3E,MAAA,EAAA,GACmB;AACnB,QAAM,CAAC,GAAmB,CAAA,IAAwB,EAAwB,IAAI,GACxE,EAAE,UAAU,EAAA,IAAiB,EAAmB,GAChD,EAAE,iBAAA,EAAA,IAAoB,EAAgB,GACtC,IAAO,EAAgB,CAA0B,GAEjD,IAAO,EAAwB,GAAM,CAAe,EAAE,IAAI,CAAkB,GAC5E,IAAA,MAA4B,EAAqB,IAAI;AAE3D,SACE,gBAAA,EAAA,GAAA,EAAA,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,IACE,UAAU;AAAA,IACJ,MAAA;AAAA,IACN,gBAAgB;AAAA,IAChB,YAAY,EAAgB,CAAI;AAAA,EACjC,CAAA,GACD,gBAAA,EAAC,GAAD;AAAA,IACE,gBAAgB,GAAc;AAAA,IAC9B,QAAQ,MAAsB;AAAA,IAC9B,SAAS;AAAA,IACT,OAAO,GAAc;AAAA,IAEpB,UAAA,KAEC,gBAAA,EAAC,GAAD,EACE,MAAM;AAAA,MAAE,GAAG;AAAA,MAAM,iBAAiB;AAAA,MAAW,sBAAsB;AAAA,IAAkB,EACtF,CAAA;AAAA,EAEG,CAAA,CACR,EAAA,CAAA;AAEN,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"PlaceholderActionBlock.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/PlaceholderActionBlock.tsx"],"sourcesContent":["import Stack from '@mui/material/Stack'\n\nimport { H3, Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport { useActionContext } from '../../common'\nimport type { Beat, DrilldownPayload } from '../../core'\n\nimport { createVariantBlock } from '../blocks/createVariantBlock'\nimport { type ActionBlockProps } from '../mappings/blocks'\nimport { useOpenedCta } from './useOpenedCta'\n\n// This block doubles as the reference example for the two building blocks a real\n// action block uses:\n// 1. useActionContext<T>() — read the drawer's opaque, block-specific context.\n// 2. createVariantBlock — dispatch to a per-variant component with a fallback.\n// Register a block with variants exactly like `PlaceholderVariants` below, then\n// wire it into src/insights-v2/mappings/blocks.ts. Declare its copy selector as the\n// entry's `copy` and read it with `useRequiredCopy`; render `BlockErrorMessage` when\n// its data is missing for good.\n\ninterface PlaceholderVariantProps {\n beat: Beat\n}\n\n/** Default variant — also the fallback for unknown/absent variants.\n * Wrapped in `observer` because it reads the drawer's observable context via\n * useActionContext; without it a memoized ancestor would stop it re-rendering.\n * This is the copy-paste template for real blocks, so it must model the rule. */\nconst DefaultPlaceholder = observer(({ beat }: PlaceholderVariantProps) => {\n // Chart drilldowns put { chartBarIndex, tabIndex } on the drawer context; a\n // CTA open carries none, so default to 0.\n const { chartBarIndex = 0, tabIndex = 0 } = useActionContext<DrilldownPayload>() ?? {}\n\n return (\n <Stack sx={{ alignItems: 'center', gap: 8, p: 24, textAlign: 'center' }}>\n <H3>Action Block Layer Drilldown</H3>\n <Text>\n This is a placeholder action block. Replace it with your own implementation by registering\n your block in src/insights-v2/mappings/blocks.ts.\n </Text>\n <Text>Beat: {beat.guid}</Text>\n <Text>\n Drilldown: chartBarIndex {chartBarIndex}, tabIndex {tabIndex}\n </Text>\n </Stack>\n )\n})\n\n/** A second sample variant, to show registry dispatch with more than one entry. */\nconst CompactPlaceholder = ({ beat }: PlaceholderVariantProps) => (\n <Stack sx={{ alignItems: 'center', gap: 8, p: 24, textAlign: 'center' }}>\n <H3>Action Block Layer Drilldown (compact)</H3>\n <Text>Beat: {beat.guid}</Text>\n </Stack>\n)\n\n// Register one component per backend `variant`; unknown/absent variants fall\n// back to DefaultPlaceholder.\nconst PlaceholderVariants = createVariantBlock<PlaceholderVariantProps>({\n variants: {\n default: DefaultPlaceholder,\n compact: CompactPlaceholder,\n },\n fallback: DefaultPlaceholder,\n name: 'Placeholder',\n})\n\nexport const PlaceholderActionBlock = observer(function PlaceholderActionBlock({\n beat,\n}: ActionBlockProps) {\n const cta = useOpenedCta(beat)\n\n return <PlaceholderVariants beat={beat} variant={cta?.variant} />\n})\n"],"mappings":";;;;;;;AA6BA,IAAM,IAAqB,EAAA,CAAU,EAAE,MAAA,EAAA,MAAoC;AAGzE,QAAM,EAAE,eAA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src/insights-v2/actionBlocks/PlaceholderActionBlock.tsx"],"sourcesContent":["import Stack from '@mui/material/Stack'\n\nimport { H3, Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport { useActionContext } from '../../common'\nimport type { Beat, DrilldownPayload } from '../../core'\n\nimport { createVariantBlock } from '../blocks/createVariantBlock'\nimport { type ActionBlockProps } from '../mappings/blocks'\nimport { useOpenedCta } from './useOpenedCta'\n\n// This block doubles as the reference example for the two building blocks a real\n// action block uses:\n// 1. useActionContext<T>() — read the drawer's opaque, block-specific context.\n// 2. createVariantBlock — dispatch to a per-variant component with a fallback.\n// Register a block with variants exactly like `PlaceholderVariants` below, then\n// wire it into src/insights-v2/mappings/blocks.ts. Declare its copy selector as the\n// entry's `copy` and read it with `useRequiredCopy`, and declare `useLoadState` when it waits for\n// store data; render `BlockErrorMessage` when its data is missing for good.\n\ninterface PlaceholderVariantProps {\n beat: Beat\n}\n\n/** Default variant — also the fallback for unknown/absent variants.\n * Wrapped in `observer` because it reads the drawer's observable context via\n * useActionContext; without it a memoized ancestor would stop it re-rendering.\n * This is the copy-paste template for real blocks, so it must model the rule. */\nconst DefaultPlaceholder = observer(({ beat }: PlaceholderVariantProps) => {\n // Chart drilldowns put { chartBarIndex, tabIndex } on the drawer context; a\n // CTA open carries none, so default to 0.\n const { chartBarIndex = 0, tabIndex = 0 } = useActionContext<DrilldownPayload>() ?? {}\n\n return (\n <Stack sx={{ alignItems: 'center', gap: 8, p: 24, textAlign: 'center' }}>\n <H3>Action Block Layer Drilldown</H3>\n <Text>\n This is a placeholder action block. Replace it with your own implementation by registering\n your block in src/insights-v2/mappings/blocks.ts.\n </Text>\n <Text>Beat: {beat.guid}</Text>\n <Text>\n Drilldown: chartBarIndex {chartBarIndex}, tabIndex {tabIndex}\n </Text>\n </Stack>\n )\n})\n\n/** A second sample variant, to show registry dispatch with more than one entry. */\nconst CompactPlaceholder = ({ beat }: PlaceholderVariantProps) => (\n <Stack sx={{ alignItems: 'center', gap: 8, p: 24, textAlign: 'center' }}>\n <H3>Action Block Layer Drilldown (compact)</H3>\n <Text>Beat: {beat.guid}</Text>\n </Stack>\n)\n\n// Register one component per backend `variant`; unknown/absent variants fall\n// back to DefaultPlaceholder.\nconst PlaceholderVariants = createVariantBlock<PlaceholderVariantProps>({\n variants: {\n default: DefaultPlaceholder,\n compact: CompactPlaceholder,\n },\n fallback: DefaultPlaceholder,\n name: 'Placeholder',\n})\n\nexport const PlaceholderActionBlock = observer(function PlaceholderActionBlock({\n beat,\n}: ActionBlockProps) {\n const cta = useOpenedCta(beat)\n\n return <PlaceholderVariants beat={beat} variant={cta?.variant} />\n})\n"],"mappings":";;;;;;;AA6BA,IAAM,IAAqB,EAAA,CAAU,EAAE,MAAA,EAAA,MAAoC;AAGzE,QAAM,EAAE,eAAA,IAAgB,GAAG,UAAA,IAAW,EAAA,IAAM,EAAmC,KAAK,CAAC;AAErF,SACE,gBAAA,EAAC,GAAD;AAAA,IAAO,IAAI;AAAA,MAAE,YAAY;AAAA,MAAU,KAAK;AAAA,MAAG,GAAG;AAAA,MAAI,WAAW;AAAA,IAAS;AAAA,IAAtE,UAAA;AAAA,MACE,gBAAA,EAAC,GAAD,EAAA,UAAI,+BAAgC,CAAA;AAAA,MACpC,gBAAA,EAAC,GAAD,EAAA,UAAM,+IAGA,CAAA;AAAA,MACN,gBAAA,EAAC,GAAD,EAAA,UAAA,CAAM,UAAO,EAAK,IAAW,EAAA,CAAA;AAAA,MAC7B,gBAAA,EAAC,GAAD,EAAA,UAAA;AAAA,QAAM;AAAA,QACsB;AAAA,QAAc;AAAA,QAAY;AAAA,MAChD,EAAA,CAAA;AAAA,IACD;AAAA;AAEX,CAAC,GAGK,IAAA,CAAsB,EAAE,MAAA,EAAA,MAC5B,gBAAA,EAAC,GAAD;AAAA,EAAO,IAAI;AAAA,IAAE,YAAY;AAAA,IAAU,KAAK;AAAA,IAAG,GAAG;AAAA,IAAI,WAAW;AAAA,EAAS;AAAA,EAAtE,UAAA,CACE,gBAAA,EAAC,GAAD,EAAA,UAAI,yCAA0C,CAAA,GAC9C,gBAAA,EAAC,GAAD,EAAA,UAAA,CAAM,UAAO,EAAK,IAAW,EAAA,CAAA,CACxB;IAKH,IAAsB,EAA4C;AAAA,EACtE,UAAU;AAAA,IACR,SAAS;AAAA,IACT,SAAS;AAAA,EACX;AAAA,EACA,UAAU;AAAA,EACV,MAAM;AACR,CAAC,GAEY,IAAyB,EAAS,SAAgC,EAC7E,MAAA,EAAA,GACmB;AACnB,QAAM,IAAM,EAAa,CAAI;AAE7B,SAAO,gBAAA,EAAC,GAAD;AAAA,IAA2B,MAAA;AAAA,IAAM,SAAS,GAAK;AAAA,EAAU,CAAA;AAClE,CAAC"}
@@ -1,6 +1,8 @@
1
1
  import { GlobalCopy } from '../../../core';
2
- import { ActionBlockProps } from '../../mappings/blocks';
2
+ import { ActionBlockProps, BlockLoadState } from '../../mappings/blocks';
3
3
  export declare const selectRemainingCashCopy: (copy: GlobalCopy) => import('../../../core').RemainingCashCopy | undefined;
4
+ /** Waits for the accounts and the recurring expenses; another widget may still be loading either. */
5
+ export declare const useRemainingCashLoadState: () => BlockLoadState;
4
6
  /** Remaining Cash drawer: today's figures from CashflowStore, not the card's (see docs/action-blocks/remaining-cash-block.md). */
5
7
  export declare const RemainingCashBlock: ((_props: ActionBlockProps) => import("react/jsx-runtime").JSX.Element) & {
6
8
  displayName: string;
@@ -1,78 +1,81 @@
1
- import { CategoryGuids as f } from "../../../core/constants/Category.es.js";
2
- import { DEFAULT_INSTITUTION_LOGO_URL as h } from "../../../core/constants/InstitutionLogo.es.js";
3
- import _ from "../../../common/utils/AccountDisplayName.es.js";
4
- import { useAccountStore as y, useAppConfig as C, useCashflowStore as x } from "../../../common/context/hooks.es.js";
5
- import { getAccountStartingBalance as R } from "../../../core/utils/AccountUtils.es.js";
6
- import T from "../../../common/components/Loader.es.js";
7
- import a from "../../components/CategoryTile.es.js";
8
- import { useRequiredCopy as G } from "../useRequiredCopy.es.js";
9
- import { ErrorCard as L } from "../../components/ErrorCard.es.js";
10
- import { useRecurringExpensesLoadState as E } from "../RecurringTransactionBlock/useRecurringTransactionPrepare.es.js";
11
- import { foldOtherRows as r, getCaption as U } from "./layout.es.js";
12
- import A from "./RemainingCashContent.es.js";
13
- import { observer as I } from "mobx-react-lite";
14
- import { InstitutionLogo as s } from "@mxenabled/mxui";
1
+ import { CategoryGuids as d } from "../../../core/constants/Category.es.js";
2
+ import { DEFAULT_INSTITUTION_LOGO_URL as g } from "../../../core/constants/InstitutionLogo.es.js";
3
+ import l from "../../../common/utils/AccountDisplayName.es.js";
4
+ import { useAccountStore as h, useAppConfig as _, useCashflowStore as y } from "../../../common/context/hooks.es.js";
5
+ import { getAccountStartingBalance as f } from "../../../core/utils/AccountUtils.es.js";
6
+ import r from "../../components/CategoryTile.es.js";
7
+ import { useRequiredCopy as C } from "../useRequiredCopy.es.js";
8
+ import { useRecurringExpensesLoadState as x } from "../RecurringTransactionBlock/useRecurringTransactionPrepare.es.js";
9
+ import { foldOtherRows as m, getCaption as R } from "./layout.es.js";
10
+ import T from "./RemainingCashContent.es.js";
11
+ import { observer as G } from "mobx-react-lite";
12
+ import { InstitutionLogo as c } from "@mxenabled/mxui";
15
13
  import { jsx as t } from "react/jsx-runtime";
16
- var O = (i) => i.insights_feed?.remaining_cash, J = I(function(w) {
17
- const { config: m } = C(), { uiStore: n } = x(), { accountsLoaded: c } = y(), { failed: u, ready: p, retry: d } = E(), o = G(O);
18
- if (u) return /* @__PURE__ */ t(L, { onRetry: d });
19
- if (!p || !c) return /* @__PURE__ */ t(T, {});
20
- const g = r(n.selectedCashAccounts.map((e) => ({
21
- amount: R(e, m.display_available_balance_in_accounts),
14
+ var L = (a) => a.insights_feed?.remaining_cash, D = () => {
15
+ const { accountsLoaded: a } = h(), { failed: s, ready: i, retry: o } = x();
16
+ return {
17
+ failed: s,
18
+ ready: i && a,
19
+ retry: o
20
+ };
21
+ }, H = G(function(s) {
22
+ const { config: i } = _(), { uiStore: o } = y(), n = C(L), u = m(o.selectedCashAccounts.map((e) => ({
23
+ amount: f(e, i.display_available_balance_in_accounts),
22
24
  key: e.guid,
23
- leading: /* @__PURE__ */ t(s, {
25
+ leading: /* @__PURE__ */ t(c, {
24
26
  alt: "",
25
27
  institutionGuid: e.institution_guid ?? "",
26
28
  size: 32
27
29
  }),
28
- name: _(e)
30
+ name: l(e)
29
31
  })), {
30
- multi: o.other_accounts,
31
- one: o.other_accounts_one
32
- }, /* @__PURE__ */ t(s, {
32
+ multi: n.other_accounts,
33
+ one: n.other_accounts_one
34
+ }, /* @__PURE__ */ t(c, {
33
35
  alt: "",
34
36
  institutionGuid: "",
35
- logoUrl: h,
37
+ logoUrl: g,
36
38
  size: 32
37
- })), l = r(n.expensesTilNextIncome.map((e) => ({
39
+ })), p = m(o.expensesTilNextIncome.map((e) => ({
38
40
  amount: e.amount,
39
41
  key: `${e.repeatingTransactionGuid}-${e.expectedDate.getTime()}`,
40
- leading: /* @__PURE__ */ t(a, {
42
+ leading: /* @__PURE__ */ t(r, {
41
43
  categoryGuid: e.categoryGuid,
42
44
  size: 32
43
45
  }),
44
46
  name: e.name
45
47
  })), {
46
- multi: o.other_expenses,
47
- one: o.other_expenses_one
48
- }, /* @__PURE__ */ t(a, {
49
- categoryGuid: f.UNCATEGORIZED,
48
+ multi: n.other_expenses,
49
+ one: n.other_expenses_one
50
+ }, /* @__PURE__ */ t(r, {
51
+ categoryGuid: d.UNCATEGORIZED,
50
52
  size: 32
51
53
  }));
52
- return /* @__PURE__ */ t(A, {
54
+ return /* @__PURE__ */ t(T, {
53
55
  accounts: {
54
- header: o.accounts_header,
55
- rows: g
56
+ header: n.accounts_header,
57
+ rows: u
56
58
  },
57
59
  expenses: {
58
- header: o.recurring_expenses_header,
59
- rows: l
60
+ header: n.recurring_expenses_header,
61
+ rows: p
60
62
  },
61
63
  summary: {
62
- remaining: n.hasUpcomingPayday ? {
63
- amount: n.remainingUntilPayday,
64
- caption: U(o, n.daysUntilNextIncome)
64
+ remaining: o.hasUpcomingPayday ? {
65
+ amount: o.remainingUntilPayday,
66
+ caption: R(n, o.daysUntilNextIncome)
65
67
  } : void 0,
66
- cashOnHand: n.selectedCashBalance,
67
- cashOnHandLabel: o.cash_on_hand,
68
- upcomingExpenses: n.upcomingExpensesTotal,
69
- upcomingExpensesLabel: o.upcoming_expenses
68
+ cashOnHand: o.selectedCashBalance,
69
+ cashOnHandLabel: n.cash_on_hand,
70
+ upcomingExpenses: o.upcomingExpensesTotal,
71
+ upcomingExpensesLabel: n.upcoming_expenses
70
72
  }
71
73
  });
72
74
  });
73
75
  export {
74
- J as RemainingCashBlock,
75
- O as selectRemainingCashCopy
76
+ H as RemainingCashBlock,
77
+ L as selectRemainingCashCopy,
78
+ D as useRemainingCashLoadState
76
79
  };
77
80
 
78
81
  //# sourceMappingURL=RemainingCashBlock.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RemainingCashBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashBlock.tsx"],"sourcesContent":["import { InstitutionLogo } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport { Loader, useAccountStore, useAppConfig, useCashflowStore } from '../../../common'\nimport getAccountDisplayName from '../../../common/utils/AccountDisplayName'\nimport { CategoryGuids } from '../../../core/constants/Category'\nimport { DEFAULT_INSTITUTION_LOGO_URL } from '../../../core/constants/InstitutionLogo'\nimport { getAccountStartingBalance } from '../../../core/utils/AccountUtils'\nimport type { GlobalCopy } from '../../../core'\nimport CategoryTile from '../../components/CategoryTile'\nimport { ErrorCard } from '../../components/ErrorCard'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { useRecurringExpensesLoadState } from '../RecurringTransactionBlock'\nimport { useRequiredCopy } from '../useRequiredCopy'\n\nimport { foldOtherRows, getCaption } from './layout'\nimport RemainingCashContent from './RemainingCashContent'\n\nexport const selectRemainingCashCopy = (copy: GlobalCopy) => copy.insights_feed?.remaining_cash\n\n/** Remaining Cash drawer: today's figures from CashflowStore, not the card's (see docs/action-blocks/remaining-cash-block.md). */\nexport const RemainingCashBlock = observer(function RemainingCashBlock(_props: ActionBlockProps) {\n const { config } = useAppConfig()\n const { uiStore } = useCashflowStore()\n const { accountsLoaded } = useAccountStore()\n const { failed, ready, retry } = useRecurringExpensesLoadState()\n const copy = useRequiredCopy(selectRemainingCashCopy)\n\n if (failed) return <ErrorCard onRetry={retry} />\n\n // `accountsLoaded` / `ready` cover another widget's request still in flight.\n if (!ready || !accountsLoaded) return <Loader />\n\n const accountRows = foldOtherRows(\n uiStore.selectedCashAccounts.map((account) => ({\n amount: getAccountStartingBalance(account, config.display_available_balance_in_accounts),\n key: account.guid,\n // Decorative: the row's visible name already says which account it is.\n leading: (\n <InstitutionLogo alt=\"\" institutionGuid={account.institution_guid ?? ''} size={32} />\n ),\n name: getAccountDisplayName(account),\n })),\n { multi: copy.other_accounts, one: copy.other_accounts_one },\n <InstitutionLogo alt=\"\" institutionGuid=\"\" logoUrl={DEFAULT_INSTITUTION_LOGO_URL} size={32} />,\n )\n const expenseRows = foldOtherRows(\n uiStore.expensesTilNextIncome.map((expense) => ({\n amount: expense.amount,\n key: `${expense.repeatingTransactionGuid}-${expense.expectedDate.getTime()}`,\n leading: <CategoryTile categoryGuid={expense.categoryGuid} size={32} />,\n name: expense.name,\n })),\n { multi: copy.other_expenses, one: copy.other_expenses_one },\n <CategoryTile categoryGuid={CategoryGuids.UNCATEGORIZED} size={32} />,\n )\n\n return (\n <RemainingCashContent\n accounts={{ header: copy.accounts_header, rows: accountRows }}\n expenses={{ header: copy.recurring_expenses_header, rows: expenseRows }}\n summary={{\n remaining: uiStore.hasUpcomingPayday\n ? {\n amount: uiStore.remainingUntilPayday,\n caption: getCaption(copy, uiStore.daysUntilNextIncome),\n }\n : undefined,\n cashOnHand: uiStore.selectedCashBalance,\n cashOnHandLabel: copy.cash_on_hand,\n upcomingExpenses: uiStore.upcomingExpensesTotal,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Q;AAAA,MAAc,MAAM;AAAA,IAAK,CAAA;AAAA,IACtE,MAAM,EAAQ;AAAA,EAChB,EAAE,GACF;AAAA,IAAE,OAAO,EAAK;AAAA,IAAgB,KAAK,EAAK;AAAA,EAAmB,GAC3D,gBAAA,EAAC,GAAD;AAAA,IAAc,cAAc,EAAc;AAAA,IAAe,MAAM;AAAA,EAAK,CAAA,CACtE;AAEA,SACE,gBAAA,EAAC,GAAD;AAAA,IACE,UAAU;AAAA,MAAE,QAAQ,EAAK;AAAA,MAAiB,MAAM;AAAA,IAAY;AAAA,IAC5D,UAAU;AAAA,MAAE,QAAQ,EAAK;AAAA,MAA2B,MAAM;AAAA,IAAY;AAAA,IACtE,SAAS;AAAA,MACP,WAAW,EAAQ,oBACf;AAAA,QACE,QAAQ,EAAQ;AAAA,QAChB,SAAS,EAAW,GAAM,EAAQ,mBAAmB;AAAA,MACvD,IACA;AAAA,MACJ,YAAY,EAAQ;AAAA,MACpB,iBAAiB,EAAK;AAAA,MACtB,kBAAkB,EAAQ;AAAA,MAC1B,uBAAuB,EAAK;AAAA,IAC9B;AAAA,EACD,CAAA;AAEL,CAAC"}
1
+ {"version":3,"file":"RemainingCashBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashBlock.tsx"],"sourcesContent":["import { InstitutionLogo } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport { useAccountStore, useAppConfig, useCashflowStore } from '../../../common'\nimport getAccountDisplayName from '../../../common/utils/AccountDisplayName'\nimport { CategoryGuids } from '../../../core/constants/Category'\nimport { DEFAULT_INSTITUTION_LOGO_URL } from '../../../core/constants/InstitutionLogo'\nimport { getAccountStartingBalance } from '../../../core/utils/AccountUtils'\nimport type { GlobalCopy } from '../../../core'\nimport CategoryTile from '../../components/CategoryTile'\nimport type { ActionBlockProps, BlockLoadState } from '../../mappings/blocks'\nimport { useRecurringExpensesLoadState } from '../RecurringTransactionBlock'\nimport { useRequiredCopy } from '../useRequiredCopy'\n\nimport { foldOtherRows, getCaption } from './layout'\nimport RemainingCashContent from './RemainingCashContent'\n\nexport const selectRemainingCashCopy = (copy: GlobalCopy) => copy.insights_feed?.remaining_cash\n\n/** Waits for the accounts and the recurring expenses; another widget may still be loading either. */\nexport const useRemainingCashLoadState = (): BlockLoadState => {\n const { accountsLoaded } = useAccountStore()\n const { failed, ready, retry } = useRecurringExpensesLoadState()\n\n return { failed, ready: ready && accountsLoaded, retry }\n}\n\n/** Remaining Cash drawer: today's figures from CashflowStore, not the card's (see docs/action-blocks/remaining-cash-block.md). */\nexport const RemainingCashBlock = observer(function RemainingCashBlock(_props: ActionBlockProps) {\n const { config } = useAppConfig()\n const { uiStore } = useCashflowStore()\n const copy = useRequiredCopy(selectRemainingCashCopy)\n\n const accountRows = foldOtherRows(\n uiStore.selectedCashAccounts.map((account) => ({\n amount: getAccountStartingBalance(account, config.display_available_balance_in_accounts),\n key: account.guid,\n // Decorative: the row's visible name already says which account it is.\n leading: (\n <InstitutionLogo alt=\"\" institutionGuid={account.institution_guid ?? ''} size={32} />\n ),\n name: getAccountDisplayName(account),\n })),\n { multi: copy.other_accounts, one: copy.other_accounts_one },\n <InstitutionLogo alt=\"\" institutionGuid=\"\" logoUrl={DEFAULT_INSTITUTION_LOGO_URL} size={32} />,\n )\n const expenseRows = foldOtherRows(\n uiStore.expensesTilNextIncome.map((expense) => ({\n amount: expense.amount,\n key: `${expense.repeatingTransactionGuid}-${expense.expectedDate.getTime()}`,\n leading: <CategoryTile categoryGuid={expense.categoryGuid} size={32} />,\n name: expense.name,\n })),\n { multi: copy.other_expenses, one: copy.other_expenses_one },\n <CategoryTile categoryGuid={CategoryGuids.UNCATEGORIZED} size={32} />,\n )\n\n return (\n <RemainingCashContent\n accounts={{ header: copy.accounts_header, rows: accountRows }}\n expenses={{ header: copy.recurring_expenses_header, rows: expenseRows }}\n summary={{\n remaining: uiStore.hasUpcomingPayday\n ? {\n amount: uiStore.remainingUntilPayday,\n caption: getCaption(copy, uiStore.daysUntilNextIncome),\n }\n : undefined,\n cashOnHand: uiStore.selectedCashBalance,\n cashOnHandLabel: copy.cash_on_hand,\n upcomingExpenses: uiStore.upcomingExpensesTotal,\n upcomingExpensesLabel: copy.upcoming_expenses,\n }}\n />\n )\n})\n"],"mappings":";;;;;;;;;;;;;AAiBA,IAAa,IAAA,CAA2B,MAAqB,EAAK,eAAe,gBAGpE,IAAA,MAAkD;AAC7D,QAAM,EAAE,gBAAA,EAAA,IAAmB,EAAgB,GACrC,EAAE,QAAA,GAAQ,OAAA,GAAO,OAAA,EAAA,IAAU,EAA8B;AAE/D,SAAO;AAAA,IAAE,QAAA;AAAA,IAAQ,OAAO,KAAS;AAAA,IAAgB,OAAA;AAAA,EAAM;AACzD,GAGa,IAAqB,EAAS,SAA4B,GAA0B;AAC/F,QAAM,EAAE,QAAA,EAAA,IAAW,EAAa,GAC1B,EAAE,SAAA,EAAA,IAAY,EAAiB,GAC/B,IAAO,EAAgB,CAAuB,GAE9C,IAAc,EAClB,EAAQ,qBAAqB,IAAA,CAAK,OAAa;AAAA,IAC7C,QAAQ,EAA0B,GAAS,EAAO,qCAAqC;AAAA,IACvF,KAAK,EAAQ;AAAA,IAEb,SACE,gBAAA,EAAC,GAAD;AAAA,MAAiB,KAAI;AAAA,MAAG,iBAAiB,EAAQ,oBAAoB;AAAA,MAAI,MAAM;AAAA,IAAK,CAAA;AAAA,IAEtF,MAAM,EAAsB,CAAO;AAAA,EACrC,EAAE,GACF;AAAA,IAAE,OAAO,EAAK;AAAA,IAAgB,KAAK,EAAK;AAAA,EAAmB,GAC3D,gBAAA,EAAC,GAAD;AAAA,IAAiB,KAAI;AAAA,IAAG,iBAAgB;AAAA,IAAG,SAAS;AAAA,IAA8B,MAAM;AAAA,EAAK,CAAA,CAC/F,GACM,IAAc,EAClB,EAAQ,sBAAsB,IAAA,CAAK,OAAa;AAAA,IAC9C,QAAQ,EAAQ;AAAA,IAChB,KAAK,GAAG,EAAQ,wBAAA,IAA4B,EAAQ,aAAa,QAAQ,CAAA;AAAA,IACzE,SAAS,gBAAA,EAAC,GAAD;AAAA,MAAc,cAAc,EAAQ;AAAA,MAAc,MAAM;AAAA,IAAK,CAAA;AAAA,IACtE,MAAM,EAAQ;AAAA,EAChB,EAAE,GACF;AAAA,IAAE,OAAO,EAAK;AAAA,IAAgB,KAAK,EAAK;AAAA,EAAmB,GAC3D,gBAAA,EAAC,GAAD;AAAA,IAAc,cAAc,EAAc;AAAA,IAAe,MAAM;AAAA,EAAK,CAAA,CACtE;AAEA,SACE,gBAAA,EAAC,GAAD;AAAA,IACE,UAAU;AAAA,MAAE,QAAQ,EAAK;AAAA,MAAiB,MAAM;AAAA,IAAY;AAAA,IAC5D,UAAU;AAAA,MAAE,QAAQ,EAAK;AAAA,MAA2B,MAAM;AAAA,IAAY;AAAA,IACtE,SAAS;AAAA,MACP,WAAW,EAAQ,oBACf;AAAA,QACE,QAAQ,EAAQ;AAAA,QAChB,SAAS,EAAW,GAAM,EAAQ,mBAAmB;AAAA,MACvD,IACA;AAAA,MACJ,YAAY,EAAQ;AAAA,MACpB,iBAAiB,EAAK;AAAA,MACtB,kBAAkB,EAAQ;AAAA,MAC1B,uBAAuB,EAAK;AAAA,IAC9B;AAAA,EACD,CAAA;AAEL,CAAC"}
@@ -1 +1 @@
1
- export { RemainingCashBlock, selectRemainingCashCopy } from './RemainingCashBlock';
1
+ export { RemainingCashBlock, selectRemainingCashCopy, useRemainingCashLoadState, } from './RemainingCashBlock';
@@ -0,0 +1,3 @@
1
+ import { BlockLoadState } from '../mappings/blocks';
2
+ /** Ready once the account store has loaded its accounts (it never unloads them). */
3
+ export declare const useAccountsLoadState: () => BlockLoadState;
@@ -0,0 +1,7 @@
1
+ import { useAccountStore as o } from "../../common/context/hooks.es.js";
2
+ var e = () => ({ ready: o().accountsLoaded });
3
+ export {
4
+ e as useAccountsLoadState
5
+ };
6
+
7
+ //# sourceMappingURL=useAccountsLoadState.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAccountsLoadState.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/useAccountsLoadState.ts"],"sourcesContent":["import { useAccountStore } from '../../common'\nimport type { BlockLoadState } from '../mappings/blocks'\n\n/** Ready once the account store has loaded its accounts (it never unloads them). */\nexport const useAccountsLoadState = (): BlockLoadState => ({\n ready: useAccountStore().accountsLoaded,\n})\n"],"mappings":";AAIA,IAAa,IAAA,OAA8C,EACzD,OAAO,EAAgB,EAAE,eAC3B"}
@@ -3,9 +3,15 @@ export interface ActionBlockProps {
3
3
  beat: Beat;
4
4
  }
5
5
  export { hasDrawerBlock } from './hasDrawerBlock';
6
+ export interface BlockLoadState {
7
+ ready: boolean;
8
+ failed?: boolean;
9
+ retry?: () => void;
10
+ }
6
11
  export interface ActionBlockEntry {
7
12
  Component: React.ComponentType<ActionBlockProps>;
8
13
  usePrepare: (props: ActionBlockProps) => void;
14
+ useLoadState?: (props: ActionBlockProps) => BlockLoadState;
9
15
  title?: (variant: string | null | undefined, copy: GlobalCopy, beat?: Beat) => string;
10
16
  copy?: (copy: GlobalCopy) => unknown;
11
17
  presentation?: 'drawer' | 'modal';