@mx-cartographer/experiences 9.7.150 → 9.7.152
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -4
- package/dist/core/types/Insights.d.ts +7 -10
- package/dist/core/types/Insights.es.js.map +1 -1
- package/dist/core/types/localization/InsightsFeedCopy.d.ts +13 -7
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.es.js +33 -36
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListBlock.es.js +91 -54
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListSubscriptionHeader.d.ts +12 -0
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListSubscriptionHeader.es.js +76 -0
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListSubscriptionHeader.es.js.map +1 -0
- package/dist/insights-v2/actionBlocks/TransactionListBlock/layout.d.ts +14 -0
- package/dist/insights-v2/actionBlocks/TransactionListBlock/layout.es.js +76 -37
- package/dist/insights-v2/actionBlocks/TransactionListBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/DebtsBlock/DebtsBlock.d.ts +4 -23
- package/dist/insights-v2/blocks/ComponentBlocks/DebtsBlock/DebtsBlock.es.js +95 -72
- package/dist/insights-v2/blocks/ComponentBlocks/DebtsBlock/DebtsBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/QuizBlock/QuizBlock.es.js +6 -6
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js +4 -4
- package/dist/insights-v2/components/SubscriptionStatus/subscriptionFrequency.d.ts +3 -1
- package/dist/insights-v2/components/SubscriptionStatus/subscriptionFrequency.es.js +5 -4
- package/dist/insights-v2/components/SubscriptionStatus/subscriptionFrequency.es.js.map +1 -1
- package/dist/insights-v2/components/drawerTip.d.ts +2 -0
- package/dist/insights-v2/components/drawerTip.es.js +10 -0
- package/dist/insights-v2/components/drawerTip.es.js.map +1 -0
- package/dist/insights-v2/index.d.ts +0 -1
- package/dist/insights-v2/index.es.js +104 -106
- package/dist/transactions/components/shared/TransactionList.d.ts +2 -0
- package/dist/transactions/components/shared/TransactionList.es.js +48 -47
- package/dist/transactions/components/shared/TransactionList.es.js.map +1 -1
- package/dist/transactions/components/shared/transactionlist/TransactionRow.d.ts +2 -0
- package/dist/transactions/components/shared/transactionlist/TransactionRow.es.js +50 -45
- package/dist/transactions/components/shared/transactionlist/TransactionRow.es.js.map +1 -1
- package/package.json +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/DebtsBlock/layout.d.ts +0 -17
- package/dist/insights-v2/blocks/ComponentBlocks/DebtsBlock/layout.es.js +0 -24
- package/dist/insights-v2/blocks/ComponentBlocks/DebtsBlock/layout.es.js.map +0 -1
- package/dist/insights-v2/components/ComponentBlocks/DepositLogo.es.js +0 -30
- package/dist/insights-v2/components/ComponentBlocks/DepositLogo.es.js.map +0 -1
- package/dist/insights-v2/components/DebtPayoffCard.d.ts +0 -48
- package/dist/insights-v2/components/DebtPayoffCard.es.js +0 -132
- package/dist/insights-v2/components/DebtPayoffCard.es.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionListBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionListBlock/TransactionListBlock.tsx"],"sourcesContent":["import React from 'react'\n\nimport { observer } from 'mobx-react-lite'\n\nimport {\n Drawer,\n useAccountStore,\n useGlobalCopyStore,\n useInsightsV2Store,\n useTransactionStore,\n} from '../../../common'\nimport type { Beat, Transaction } from '../../../core'\nimport type { InsightsInstanceSlotData } from '../../../core/types/InsightsInstanceSlotData'\nimport { TransactionDetailsBlock } from '../TransactionDetailsBlock'\nimport { TransactionList } from '../../../transactions'\nimport { selectTransactionsByGuids } from '../../CommonUtils'\nimport { getDynamicCtaBasedOnTriggers } from '../util'\nimport { HelpBlock } from '../HelpBlock'\nimport { readHelpHeader, readSummary, TRANSACTION_LIST_VARIANTS } from './layout'\nimport { TransactionAccountSubline } from './TransactionAccountSubline'\nimport { TransactionListHelpHeader } from './TransactionListHelpHeader'\nimport { TransactionListSummaryCard } from './TransactionListSummaryCard'\n\nconst isStringArray = (value: unknown): value is string[] =>\n Array.isArray(value) && value.every((item) => typeof item === 'string')\n\n/**\n * The guids the drawer lists, from the first source that names them: the clicked CTA's own\n * `drilldown_data` (each drawer's data rides on the CTA that opens it), then the card-level\n * `drilldown_data`, then V1's `instance_slot_data`. The payload is untrusted, so a present but\n * malformed list fails closed (no rows, and a warning) rather than showing another source's rows; a\n * non-array would otherwise reach new Set() inside selectTransactionsByGuids and match per-character.\n */\nconst resolveTransactionGuids = (\n beat: Beat,\n ctaDrilldown: Record<string, unknown> | undefined,\n): string[] | undefined => {\n const drilldown = beat.insights_payload?.drilldown_data\n const slotData = (beat.insights_payload?.instance_slot_data ?? {}) as InsightsInstanceSlotData\n const [source, value]: [string, unknown] =\n ctaDrilldown && Object.hasOwn(ctaDrilldown, 'transaction_guids')\n ? ['cta.drilldown_data', ctaDrilldown.transaction_guids]\n : drilldown && Object.hasOwn(drilldown, 'transaction_guids')\n ? ['drilldown_data', drilldown.transaction_guids]\n : ['instance_slot_data', slotData.transaction_guids]\n\n if (value == null) return undefined\n if (isStringArray(value)) return value\n\n console.warn(\n `[TransactionListBlock] ${source}.transaction_guids is not a list of guids — listing no transactions.`,\n )\n return undefined\n}\n\nexport interface TransactionListBlockProps {\n beat: Beat\n}\n\n/**\n * Opens a date-grouped list of the transactions a beat points at. Tapping a row stacks\n * the Transaction Details drawer over the list.\n *\n * ActionBlockLayer owns the outer Drawer (title, close button, copy-loaded gate).\n */\nexport const TransactionListBlock = observer(function TransactionListBlock({\n beat,\n}: TransactionListBlockProps) {\n const { common: commonCopy, insights_feed: insightsCopy } = useGlobalCopyStore()\n const { actionDrawer, setActionContext } = useInsightsV2Store()\n const transactionStore = useTransactionStore()\n const accountStore = useAccountStore()\n\n const [isDetailsOpen, setIsDetailsOpen] = React.useState(false)\n const [isHelpOpen, setIsHelpOpen] = React.useState(false)\n\n // The clicked CTA carries the drawer's own data (its guids, and the summary figures), so resolve\n // which CTA opened this drawer first. `readSummary` fails closed (no finite `amount` -> undefined),\n // so a plain list renders no card. A zero-state envelope, or one naming no transactions, has no\n // figures to head.\n const { primary_cta, secondary_cta, in_description_cta, is_zero_state, drilldown_data, title } =\n beat.insights_payload ?? {}\n const currentCta = getDynamicCtaBasedOnTriggers(\n actionDrawer,\n primary_cta,\n secondary_cta,\n in_description_cta,\n )\n\n const guids = resolveTransactionGuids(beat, currentCta?.drilldown_data)\n const transactions = selectTransactionsByGuids(transactionStore.detailedTransactions, guids)\n const summary = readSummary(currentCta)\n // Count comes from the CTA's `drilldown_data`; fall back to the named guid count so the pill never\n // flashes \"0 transactions\" if the payload omits it.\n const count = summary?.count ?? guids?.length ?? 0\n const showSummary = summary !== undefined && !is_zero_state && (guids?.length ?? 0) > 0\n const helpHeader = readHelpHeader(currentCta, drilldown_data)\n\n // Only the summary-header drawer (Replenish Savings' Savings Withdrawal) subtitles its rows with the\n // account's institution logo and name (Figma: Drilldown | Replenish Savings); every other list keeps\n // the category.\n const renderSecondaryText =\n currentCta?.variant === TRANSACTION_LIST_VARIANTS.SUMMARY_HEADER\n ? (transaction: Transaction) => (\n <TransactionAccountSubline\n institutionGuid={\n accountStore.accounts.find(({ guid }) => guid === transaction.account_guid)\n ?.institution_guid\n }\n transaction={transaction}\n />\n )\n : undefined\n\n const handleRowClick = (guid: string) => {\n setActionContext({ transaction_guid: guid })\n setIsDetailsOpen(true)\n }\n\n const handleDetailsClose = () => {\n setIsDetailsOpen(false)\n // Clear only the key this nested drawer owns — same convention as TransactionHistoryBlock.\n // `setActionContext` merges, so an explicit `{}` would be a no-op; naming the key keeps the\n // outer drawer's own context intact.\n setActionContext({ transaction_guid: undefined })\n }\n\n return (\n <>\n {showSummary && (\n <TransactionListSummaryCard copy={insightsCopy.general} count={count} summary={summary} />\n )}\n {helpHeader && (\n <TransactionListHelpHeader\n descriptionHtml={helpHeader.descriptionHtml}\n learnMoreLabel={helpHeader.learnMore?.label}\n onLearnMore={() => setIsHelpOpen(true)}\n title={title ?? ''}\n />\n )}\n <TransactionList\n onClick={handleRowClick}\n renderSecondaryText={renderSecondaryText}\n transaction={transactions}\n />\n {helpHeader?.learnMore && (\n <Drawer\n ariaLabelClose={commonCopy.close_aria}\n isOpen={isHelpOpen}\n onClose={() => setIsHelpOpen(false)}\n title={helpHeader.learnMore.label}\n >\n <HelpBlock beat={beat} />\n </Drawer>\n )}\n <Drawer\n ariaLabelClose={commonCopy.close_aria}\n isOpen={isDetailsOpen}\n onClose={handleDetailsClose}\n title={insightsCopy.general.transaction_details_title}\n >\n <TransactionDetailsBlock beat={beat} />\n </Drawer>\n </>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;AAuBA,IAAM,IAAA,CAAiB,MACrB,MAAM,QAAQ,CAAK,KAAK,EAAM,MAAA,CAAO,MAAS,OAAO,KAAS,QAAQ,GASlE,IAAA,CACJ,GACA,MACyB;AACzB,QAAM,IAAY,EAAK,kBAAkB,gBACnC,IAAY,EAAK,kBAAkB,sBAAsB,CAAC,GAC1D,CAAC,GAAQ,CAAA,IACb,KAAgB,OAAO,OAAO,GAAc,mBAAmB,IAC3D,CAAC,sBAAsB,EAAa,iBAAiB,IACrD,KAAa,OAAO,OAAO,GAAW,mBAAmB,IACvD,CAAC,kBAAkB,EAAU,iBAAiB,IAC9C,CAAC,sBAAsB,EAAS,iBAAiB;AAEzD,MAAI,KAAS,MACb;AAAA,QAAI,EAAc,CAAK,EAAG,QAAO;AAEjC,YAAQ,KACN,0BAA0B,CAAA,sEAC5B;AAAA;AAEF,GAYa,KAAuB,EAAS,SAA8B,EACzE,MAAA,EAA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AC,GAAD;AAAA,MACE,iBAAiB,EAAW;AAAA,MAC5B,gBAAgB,EAAW,WAAW;AAAA,MACtC,aAAA,MAAmB,EAAc,EAAI;AAAA,MACrC,OAAO,KAAS;AAAA,IACjB,CAAA;AAAA,IAEH,gBAAA,EAAC,GAAD;AAAA,MACE,SAAS;AAAA,MACY,qBAAA;AAAA,MACrB,aAAa;AAAA,IACd,CAAA;AAAA,IACA,GAAY,aACX,gBAAA,EAAC,GAAD;AAAA,MACE,gBAAgB,EAAW;AAAA,MAC3B,QAAQ;AAAA,MACR,SAAA,MAAe,EAAc,EAAK;AAAA,MAClC,OAAO,EAAW,UAAU;AAAA,MAE5B,UAAA,gBAAA,EAAC,GAAD,EAAiB,MAAA,EAAO,CAAA;AAAA,IAClB,CAAA;AAAA,IAEV,gBAAA,EAAC,GAAD;AAAA,MACE,gBAAgB,EAAW;AAAA,MAC3B,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,OAAO,EAAa,QAAQ;AAAA,MAE5B,UAAA,gBAAA,EAAC,GAAD,EAA+B,MAAA,EAAO,CAAA;AAAA,IAChC,CAAA;AAAA,EACR,EAAA,CAAA;AAEN,CAAC"}
|
|
1
|
+
{"version":3,"file":"TransactionListBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionListBlock/TransactionListBlock.tsx"],"sourcesContent":["import React from 'react'\n\nimport { observer } from 'mobx-react-lite'\n\nimport { Text } from '@mxenabled/mxui'\n\nimport {\n Drawer,\n useAccountStore,\n useGlobalCopyStore,\n useInsightsV2Store,\n useTransactionStore,\n} from '../../../common'\nimport type { Beat, Transaction } from '../../../core'\nimport type { InsightsInstanceSlotData } from '../../../core/types/InsightsInstanceSlotData'\nimport {\n RecurringTransactionBlock,\n useRecurringTransactionPrepare,\n} from '../RecurringTransactionBlock'\nimport { TransactionDetailsBlock } from '../TransactionDetailsBlock'\nimport { TransactionList } from '../../../transactions'\nimport { selectTransactionsByGuids } from '../../CommonUtils'\nimport { getDynamicCtaBasedOnTriggers } from '../util'\nimport { HelpBlock } from '../HelpBlock'\nimport { frequencyWord } from '../../components/SubscriptionStatus/subscriptionFrequency'\nimport {\n ACCOUNT_SUBLINE_VARIANTS,\n readHelpHeader,\n readSubscriptionHeader,\n readSummary,\n readTransactionFrequencies,\n TRANSACTION_LIST_VARIANTS,\n} from './layout'\nimport { TransactionAccountSubline } from './TransactionAccountSubline'\nimport { TransactionListHelpHeader } from './TransactionListHelpHeader'\nimport { TransactionListSubscriptionHeader } from './TransactionListSubscriptionHeader'\nimport { TransactionListSummaryCard } from './TransactionListSummaryCard'\n\nconst isStringArray = (value: unknown): value is string[] =>\n Array.isArray(value) && value.every((item) => typeof item === 'string')\n\n/**\n * The guids the drawer lists, from the first source that names them: the clicked CTA's own\n * `drilldown_data` (each drawer's data rides on the CTA that opens it), then the card-level\n * `drilldown_data`, then V1's `instance_slot_data`. The payload is untrusted, so a present but\n * malformed list fails closed (no rows, and a warning) rather than showing another source's rows; a\n * non-array would otherwise reach new Set() inside selectTransactionsByGuids and match per-character.\n */\nconst resolveTransactionGuids = (\n beat: Beat,\n ctaDrilldown: Record<string, unknown> | undefined,\n): string[] | undefined => {\n const drilldown = beat.insights_payload?.drilldown_data\n const slotData = (beat.insights_payload?.instance_slot_data ?? {}) as InsightsInstanceSlotData\n const [source, value]: [string, unknown] =\n ctaDrilldown && Object.hasOwn(ctaDrilldown, 'transaction_guids')\n ? ['cta.drilldown_data', ctaDrilldown.transaction_guids]\n : drilldown && Object.hasOwn(drilldown, 'transaction_guids')\n ? ['drilldown_data', drilldown.transaction_guids]\n : ['instance_slot_data', slotData.transaction_guids]\n\n if (value == null) return undefined\n if (isStringArray(value)) return value\n\n console.warn(\n `[TransactionListBlock] ${source}.transaction_guids is not a list of guids — listing no transactions.`,\n )\n return undefined\n}\n\n/** The shared Expense Details, with its own open-time load: the list's drawer only loads transactions. */\nconst SubscriptionExpenseDetails = (\n props: React.ComponentProps<typeof RecurringTransactionBlock>,\n) => {\n useRecurringTransactionPrepare(props)\n\n return <RecurringTransactionBlock {...props} />\n}\n\nexport interface TransactionListBlockProps {\n beat: Beat\n}\n\n/**\n * Opens a date-grouped list of the transactions a beat points at. Tapping a row stacks\n * the Transaction Details drawer over the list.\n *\n * ActionBlockLayer owns the outer Drawer (title, close button, copy-loaded gate).\n */\nexport const TransactionListBlock = observer(function TransactionListBlock({\n beat,\n}: TransactionListBlockProps) {\n const {\n common: commonCopy,\n insights_feed: insightsCopy,\n recurring: recurringCopy,\n } = useGlobalCopyStore()\n const { actionDrawer, setActionContext } = useInsightsV2Store()\n const transactionStore = useTransactionStore()\n const accountStore = useAccountStore()\n\n const [isDetailsOpen, setIsDetailsOpen] = React.useState(false)\n const [isHelpOpen, setIsHelpOpen] = React.useState(false)\n\n // The clicked CTA carries the drawer's own data (its guids, and the summary figures), so resolve\n // which CTA opened this drawer first. `readSummary` fails closed (no finite `amount` -> undefined),\n // so a plain list renders no card. A zero-state envelope, or one naming no transactions, has no\n // figures to head.\n const { primary_cta, secondary_cta, in_description_cta, is_zero_state, drilldown_data, title } =\n beat.insights_payload ?? {}\n const currentCta = getDynamicCtaBasedOnTriggers(\n actionDrawer,\n primary_cta,\n secondary_cta,\n in_description_cta,\n )\n\n const guids = resolveTransactionGuids(beat, currentCta?.drilldown_data)\n const transactions = selectTransactionsByGuids(transactionStore.detailedTransactions, guids)\n const summary = readSummary(currentCta)\n // Count comes from the CTA's `drilldown_data`; fall back to the named guid count so the pill never\n // flashes \"0 transactions\" if the payload omits it.\n const count = summary?.count ?? guids?.length ?? 0\n // One answer for \"lists something\", so the header, summary and captions never disagree.\n const hasRows = !is_zero_state && (guids?.length ?? 0) > 0\n const showSummary = summary !== undefined && hasRows\n const helpHeader = readHelpHeader(currentCta, drilldown_data)\n const subscriptionHeader = hasRows ? readSubscriptionHeader(currentCta) : undefined\n\n // Account-subtitled drawers (Figma: the Replenish Savings and Monthly Subscription Aggregate V2 drilldowns).\n const renderSecondaryText = ACCOUNT_SUBLINE_VARIANTS.has(currentCta?.variant)\n ? (transaction: Transaction) => (\n <TransactionAccountSubline\n institutionGuid={\n accountStore.accounts.find(({ guid }) => guid === transaction.account_guid)\n ?.institution_guid\n }\n transaction={transaction}\n />\n )\n : undefined\n\n // Each amount is captioned with its merchant's schedule, worded from the host's `recurring` copy.\n const frequencies = hasRows ? readTransactionFrequencies(currentCta) : undefined\n const renderAmountCaption = frequencies\n ? (transaction: Transaction) => {\n const word = frequencyWord(recurringCopy, frequencies.get(transaction.guid))\n\n return word ? (\n <Text\n bold={true}\n color=\"text.secondary\"\n sx={{ textTransform: 'uppercase' }}\n variant=\"caption\"\n >\n {word}\n </Text>\n ) : null\n }\n : undefined\n\n // A subscription row opens its schedule's Expense Details; any other row, Transaction Details.\n const [expenseGuid, setExpenseGuid] = React.useState<string | null>(null)\n const isSubscriptionList = currentCta?.variant === TRANSACTION_LIST_VARIANTS.SUBSCRIPTION_LIST\n\n const handleRowClick = (guid: string) => {\n const repeatingGuid = isSubscriptionList\n ? transactions.find((transaction) => transaction.guid === guid)?.repeating_transaction_guid\n : undefined\n\n if (repeatingGuid) {\n setExpenseGuid(repeatingGuid)\n return\n }\n\n setActionContext({ transaction_guid: guid })\n setIsDetailsOpen(true)\n }\n\n const closeExpenseDetails = () => setExpenseGuid(null)\n\n const handleDetailsClose = () => {\n setIsDetailsOpen(false)\n // Clear only the key this nested drawer owns — same convention as TransactionHistoryBlock.\n // `setActionContext` merges, so an explicit `{}` would be a no-op; naming the key keeps the\n // outer drawer's own context intact.\n setActionContext({ transaction_guid: undefined })\n }\n\n return (\n <>\n {showSummary && (\n <TransactionListSummaryCard copy={insightsCopy.general} count={count} summary={summary} />\n )}\n {subscriptionHeader && (\n <TransactionListSubscriptionHeader\n copy={insightsCopy.transaction_list_block ?? {}}\n header={subscriptionHeader}\n tipTitle={insightsCopy.general.tip_section_title}\n />\n )}\n {helpHeader && (\n <TransactionListHelpHeader\n descriptionHtml={helpHeader.descriptionHtml}\n learnMoreLabel={helpHeader.learnMore?.label}\n onLearnMore={() => setIsHelpOpen(true)}\n title={title ?? ''}\n />\n )}\n <TransactionList\n onClick={handleRowClick}\n renderAmountCaption={renderAmountCaption}\n renderSecondaryText={renderSecondaryText}\n transaction={transactions}\n />\n {helpHeader?.learnMore && (\n <Drawer\n ariaLabelClose={commonCopy.close_aria}\n isOpen={isHelpOpen}\n onClose={() => setIsHelpOpen(false)}\n title={helpHeader.learnMore.label}\n >\n <HelpBlock beat={beat} />\n </Drawer>\n )}\n <Drawer\n ariaLabelClose={commonCopy.close_aria}\n isOpen={isDetailsOpen}\n onClose={handleDetailsClose}\n title={insightsCopy.general.transaction_details_title}\n >\n <TransactionDetailsBlock beat={beat} />\n </Drawer>\n <Drawer\n ariaLabelClose={recurringCopy.close_drawer_aria}\n isOpen={expenseGuid !== null}\n onClose={closeExpenseDetails}\n title={recurringCopy.expense_details}\n >\n {expenseGuid && (\n <SubscriptionExpenseDetails\n beat={beat}\n layout=\"insights\"\n onDeleted={closeExpenseDetails}\n repeatingTransactionGuid={expenseGuid}\n />\n )}\n </Drawer>\n </>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsCA,IAAM,KAAA,CAAiB,MACrB,MAAM,QAAQ,CAAK,KAAK,EAAM,MAAA,CAAO,MAAS,OAAO,KAAS,QAAQ,GASlE,KAAA,CACJ,GACA,MACyB;AACzB,QAAM,IAAY,EAAK,kBAAkB,gBACnC,IAAY,EAAK,kBAAkB,sBAAsB,CAAC,GAC1D,CAAC,GAAQ,CAAA,IACb,KAAgB,OAAO,OAAO,GAAc,mBAAmB,IAC3D,CAAC,sBAAsB,EAAa,iBAAiB,IACrD,KAAa,OAAO,OAAO,GAAW,mBAAmB,IACvD,CAAC,kBAAkB,EAAU,iBAAiB,IAC9C,CAAC,sBAAsB,EAAS,iBAAiB;AAEzD,MAAI,KAAS,MACb;AAAA,QAAI,GAAc,CAAK,EAAG,QAAO;AAEjC,YAAQ,KACN,0BAA0B,CAAA,sEAC5B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;AAAA,MACE,gBAAgB,EAAW;AAAA,MAC3B,QAAQ;AAAA,MACR,SAAA,MAAe,EAAc,EAAK;AAAA,MAClC,OAAO,EAAW,UAAU;AAAA,MAE5B,UAAA,gBAAA,EAAC,IAAD,EAAiB,MAAA,EAAO,CAAA;AAAA,IAClB,CAAA;AAAA,IAEV,gBAAA,EAAC,GAAD;AAAA,MACE,gBAAgB,EAAW;AAAA,MAC3B,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,OAAO,EAAa,QAAQ;AAAA,MAE5B,UAAA,gBAAA,EAAC,GAAD,EAA+B,MAAA,EAAO,CAAA;AAAA,IAChC,CAAA;AAAA,IACR,gBAAA,EAAC,GAAD;AAAA,MACE,gBAAgB,EAAc;AAAA,MAC9B,QAAQ,MAAgB;AAAA,MACxB,SAAS;AAAA,MACT,OAAO,EAAc;AAAA,MAEpB,UAAA,KACC,gBAAA,EAAC,IAAD;AAAA,QACQ,MAAA;AAAA,QACN,QAAO;AAAA,QACP,WAAW;AAAA,QACX,0BAA0B;AAAA,MAC3B,CAAA;AAAA,IAEG,CAAA;AAAA,EACR,EAAA,CAAA;AAEN,CAAC"}
|
package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListSubscriptionHeader.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { InsightsFeedCopy } from '../../../core/types/localization';
|
|
2
|
+
import { SubscriptionListHeader } from './layout';
|
|
3
|
+
export interface TransactionListSubscriptionHeaderProps {
|
|
4
|
+
header: SubscriptionListHeader;
|
|
5
|
+
/** The caption and tip strings the header reads. */
|
|
6
|
+
copy: Pick<NonNullable<InsightsFeedCopy['transaction_list_block']>, 'subscriptions_in_month' | 'subscriptions_tip_message'>;
|
|
7
|
+
/** The bold tip label ("Tip"), `insights_feed.general.tip_section_title`. */
|
|
8
|
+
tipTitle: string;
|
|
9
|
+
}
|
|
10
|
+
/** The Subscriptions drawer's header: the count tile and the tip (Figma 1268:54330). */
|
|
11
|
+
export declare const TransactionListSubscriptionHeader: ({ header, copy, tipTitle, }: TransactionListSubscriptionHeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export default TransactionListSubscriptionHeader;
|
package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListSubscriptionHeader.es.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { buildDynamicCopy as m } from "../../../core/utils/Localization.es.js";
|
|
2
|
+
import { DATE_FORMATS_INTL as l, formatDate as d } from "../../../core/constants/DateFormats.es.js";
|
|
3
|
+
import { getLogoElevation as u } from "../../components/logoShadow.es.js";
|
|
4
|
+
import { TipSection as f } from "../../../insights/components/shared/ChartDrawerTemplate/TipSection.es.js";
|
|
5
|
+
import { DRAWER_TIP_ICON as g } from "../../components/drawerTip.es.js";
|
|
6
|
+
import n from "@mui/material/Stack";
|
|
7
|
+
import { Text as p } from "@mxenabled/mxui";
|
|
8
|
+
import { Icon as h } from "@mxenabled/mx-icons";
|
|
9
|
+
import { jsx as r, jsxs as e } from "react/jsx-runtime";
|
|
10
|
+
import { alpha as x } from "@mui/material/styles";
|
|
11
|
+
import b from "@mui/material/Box";
|
|
12
|
+
var j = ({ header: o, copy: i, tipTitle: a }) => {
|
|
13
|
+
const s = a && i.subscriptions_tip_message ? i.subscriptions_tip_message : void 0, t = o.month && i.subscriptions_in_month ? m(i.subscriptions_in_month, d(o.month, l.MONTH_LONG)) : void 0;
|
|
14
|
+
return /* @__PURE__ */ e(n, {
|
|
15
|
+
sx: {
|
|
16
|
+
gap: 16,
|
|
17
|
+
px: 24,
|
|
18
|
+
pt: 24,
|
|
19
|
+
pb: 12
|
|
20
|
+
},
|
|
21
|
+
children: [/* @__PURE__ */ e(n, {
|
|
22
|
+
sx: {
|
|
23
|
+
alignItems: "center",
|
|
24
|
+
bgcolor: "background.paper",
|
|
25
|
+
borderRadius: "8px",
|
|
26
|
+
boxShadow: u,
|
|
27
|
+
flexDirection: "row",
|
|
28
|
+
gap: 12,
|
|
29
|
+
p: 16
|
|
30
|
+
},
|
|
31
|
+
children: [/* @__PURE__ */ r(b, {
|
|
32
|
+
sx: {
|
|
33
|
+
alignItems: "center",
|
|
34
|
+
bgcolor: (c) => x(c.palette.primary.main, 0.15),
|
|
35
|
+
borderRadius: "4px",
|
|
36
|
+
color: "primary.main",
|
|
37
|
+
display: "flex",
|
|
38
|
+
height: 56,
|
|
39
|
+
justifyContent: "center",
|
|
40
|
+
width: 56
|
|
41
|
+
},
|
|
42
|
+
children: /* @__PURE__ */ r(h, {
|
|
43
|
+
"aria-hidden": !0,
|
|
44
|
+
fill: !0,
|
|
45
|
+
name: "currency_exchange",
|
|
46
|
+
size: 32
|
|
47
|
+
})
|
|
48
|
+
}), /* @__PURE__ */ e(n, {
|
|
49
|
+
"aria-label": t ? `${o.count} ${t}` : String(o.count),
|
|
50
|
+
role: "group",
|
|
51
|
+
children: [/* @__PURE__ */ r(p, {
|
|
52
|
+
"aria-hidden": !0,
|
|
53
|
+
bold: !0,
|
|
54
|
+
component: "p",
|
|
55
|
+
variant: "h1",
|
|
56
|
+
children: o.count
|
|
57
|
+
}), t && /* @__PURE__ */ r(p, {
|
|
58
|
+
"aria-hidden": !0,
|
|
59
|
+
color: "text.secondary",
|
|
60
|
+
variant: "caption",
|
|
61
|
+
children: t
|
|
62
|
+
})]
|
|
63
|
+
})]
|
|
64
|
+
}), s && /* @__PURE__ */ r(f, {
|
|
65
|
+
icon: g,
|
|
66
|
+
message: m(s, /* @__PURE__ */ r("strong", { children: a })),
|
|
67
|
+
sx: { m: 0 }
|
|
68
|
+
})]
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
export {
|
|
72
|
+
j as TransactionListSubscriptionHeader,
|
|
73
|
+
j as default
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
//# sourceMappingURL=TransactionListSubscriptionHeader.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransactionListSubscriptionHeader.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionListBlock/TransactionListSubscriptionHeader.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\n\nimport Box from '@mui/material/Box'\nimport Stack from '@mui/material/Stack'\nimport { alpha } from '@mui/material/styles'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { Text } from '@mxenabled/mxui'\n\nimport { DATE_FORMATS_INTL, formatDate } from '../../../core/constants'\nimport type { InsightsFeedCopy } from '../../../core/types/localization'\nimport { buildDynamicCopy } from '../../../core/utils/Localization'\nimport { TipSection } from '../../../insights/components/shared/ChartDrawerTemplate/TipSection'\nimport { getLogoElevation } from '../../components/logoShadow'\nimport { DRAWER_TIP_ICON } from '../../components/drawerTip'\n\nimport type { SubscriptionListHeader } from './layout'\n\nexport interface TransactionListSubscriptionHeaderProps {\n header: SubscriptionListHeader\n /** The caption and tip strings the header reads. */\n copy: Pick<\n NonNullable<InsightsFeedCopy['transaction_list_block']>,\n 'subscriptions_in_month' | 'subscriptions_tip_message'\n >\n /** The bold tip label (\"Tip\"), `insights_feed.general.tip_section_title`. */\n tipTitle: string\n}\n\n/** The Subscriptions drawer's header: the count tile and the tip (Figma 1268:54330). */\nexport const TransactionListSubscriptionHeader = ({\n header,\n copy,\n tipTitle,\n}: TransactionListSubscriptionHeaderProps) => {\n // Both halves or neither: a tip without its bold label would read \": Review…\".\n const tip =\n tipTitle && copy.subscriptions_tip_message ? copy.subscriptions_tip_message : undefined\n const caption =\n header.month && copy.subscriptions_in_month\n ? (buildDynamicCopy(\n copy.subscriptions_in_month,\n formatDate(header.month, DATE_FORMATS_INTL.MONTH_LONG),\n ) as string)\n : undefined\n\n return (\n <Stack sx={{ gap: 16, px: 24, pt: 24, pb: 12 }}>\n <Stack\n sx={{\n alignItems: 'center',\n bgcolor: 'background.paper',\n borderRadius: '8px',\n boxShadow: getLogoElevation,\n flexDirection: 'row',\n gap: 12,\n p: 16,\n }}\n >\n <Box\n sx={{\n alignItems: 'center',\n bgcolor: (theme) => alpha(theme.palette.primary.main, 0.15),\n borderRadius: '4px',\n color: 'primary.main',\n display: 'flex',\n height: 56,\n justifyContent: 'center',\n width: 56,\n }}\n >\n <Icon aria-hidden={true} fill={true} name=\"currency_exchange\" size={32} />\n </Box>\n {/* Read as one label: \"3 Subscriptions in October\", never a bare \"3\" read twice. */}\n <Stack\n aria-label={caption ? `${header.count} ${caption}` : String(header.count)}\n role=\"group\"\n >\n <Text aria-hidden={true} bold={true} component=\"p\" variant=\"h1\">\n {header.count}\n </Text>\n {caption && (\n <Text aria-hidden={true} color=\"text.secondary\" variant=\"caption\">\n {caption}\n </Text>\n )}\n </Stack>\n </Stack>\n\n {tip && (\n <TipSection\n icon={DRAWER_TIP_ICON}\n message={buildDynamicCopy(tip, <strong>{tipTitle}</strong>) as ReactNode}\n sx={{ m: 0 }}\n />\n )}\n </Stack>\n )\n}\n\nexport default TransactionListSubscriptionHeader\n"],"mappings":";;;;;;;;;;;AA8BA,IAAa,IAAA,CAAqC,EAChD,QAAA,GACA,MAAA,GACA,UAAA,EAAA,MAC4C;AAE5C,QAAM,IACJ,KAAY,EAAK,4BAA4B,EAAK,4BAA4B,QAC1E,IACJ,EAAO,SAAS,EAAK,yBAChB,EACC,EAAK,wBACL,EAAW,EAAO,OAAO,EAAkB,UAAU,CACvD,IACA;AAEN,SACE,gBAAA,EAAC,GAAD;AAAA,IAAO,IAAI;AAAA,MAAE,KAAK;AAAA,MAAI,IAAI;AAAA,MAAI,IAAI;AAAA,MAAI,IAAI;AAAA,IAAG;AAAA,IAA7C,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,MACE,IAAI;AAAA,QACF,YAAY;AAAA,QACZ,SAAS;AAAA,QACT,cAAc;AAAA,QACd,WAAW;AAAA,QACX,eAAe;AAAA,QACf,KAAK;AAAA,QACL,GAAG;AAAA,MACL;AAAA,MATF,UAAA,CAWE,gBAAA,EAAC,GAAD;AAAA,QACE,IAAI;AAAA,UACF,YAAY;AAAA,UACZ,SAAA,CAAU,MAAU,EAAM,EAAM,QAAQ,QAAQ,MAAM,IAAI;AAAA,UAC1D,cAAc;AAAA,UACd,OAAO;AAAA,UACP,SAAS;AAAA,UACT,QAAQ;AAAA,UACR,gBAAgB;AAAA,UAChB,OAAO;AAAA,QACT;AAAA,QAEA,UAAA,gBAAA,EAAC,GAAD;AAAA,UAAM,eAAa;AAAA,UAAM,MAAM;AAAA,UAAM,MAAK;AAAA,UAAoB,MAAM;AAAA,QAAK,CAAA;AAAA,MACtE,CAAA,GAEL,gBAAA,EAAC,GAAD;AAAA,QACE,cAAY,IAAU,GAAG,EAAO,KAAA,IAAS,CAAA,KAAY,OAAO,EAAO,KAAK;AAAA,QACxE,MAAK;AAAA,QAFP,UAAA,CAIE,gBAAA,EAAC,GAAD;AAAA,UAAM,eAAa;AAAA,UAAM,MAAM;AAAA,UAAM,WAAU;AAAA,UAAI,SAAQ;AAAA,UACxD,UAAA,EAAO;AAAA,QACJ,CAAA,GACL,KACC,gBAAA,EAAC,GAAD;AAAA,UAAM,eAAa;AAAA,UAAM,OAAM;AAAA,UAAiB,SAAQ;AAAA,UACrD,UAAA;AAAA,QACG,CAAA,CAEH;AAAA,MACF,CAAA,CAAA;AAAA,IAEN,CAAA,GAAA,KACC,gBAAA,EAAC,GAAD;AAAA,MACE,MAAM;AAAA,MACN,SAAS,EAAiB,GAAK,gBAAA,EAAC,UAAD,EAAA,UAAS,EAAiB,CAAA,CAAC;AAAA,MAC1D,IAAI,EAAE,GAAG,EAAE;AAAA,IACZ,CAAA,CAEE;AAAA;AAEX"}
|
|
@@ -9,7 +9,11 @@ export declare const TRANSACTION_LIST_VARIANTS: {
|
|
|
9
9
|
readonly HELP_HEADER: "help_header";
|
|
10
10
|
/** Opens Micro Deposits' Deposit History list. */
|
|
11
11
|
readonly DEPOSIT_HISTORY: "deposit_history";
|
|
12
|
+
/** Opens Monthly Subscription Aggregate's Subscriptions list under a count tile and a tip. */
|
|
13
|
+
readonly SUBSCRIPTION_LIST: "subscription_list";
|
|
12
14
|
};
|
|
15
|
+
/** Variants whose rows are subtitled with the account (institution logo and name), not the category. */
|
|
16
|
+
export declare const ACCOUNT_SUBLINE_VARIANTS: ReadonlySet<string | null | undefined>;
|
|
13
17
|
export declare const HELP_HEADER_VARIANT: "help_header";
|
|
14
18
|
/** Drawer title: the variant's title when it has one, otherwise the beat's own title. Add new variants here. */
|
|
15
19
|
export declare const getTransactionListDrawerTitle: (variant: string | null | undefined, copy: GlobalCopy, beat?: Beat) => string;
|
|
@@ -49,4 +53,14 @@ export interface TransactionListSummary {
|
|
|
49
53
|
* `count` (number of transactions).
|
|
50
54
|
*/
|
|
51
55
|
export declare const readSummary: (cta: DrilldownCta | undefined) => TransactionListSummary | undefined;
|
|
56
|
+
/** Each listed transaction's schedule, from `drilldown_data.transaction_frequencies`; malformed rows are dropped. */
|
|
57
|
+
export declare const readTransactionFrequencies: (cta: DrilldownCta | undefined) => Map<string, number> | undefined;
|
|
58
|
+
export interface SubscriptionListHeader {
|
|
59
|
+
/** Subscriptions paid in the month, from the CTA's `drilldown_data.count`. */
|
|
60
|
+
count: number;
|
|
61
|
+
/** The month paid in, as local midnight on the 1st; omitted when missing or unparseable. */
|
|
62
|
+
month?: Date;
|
|
63
|
+
}
|
|
64
|
+
/** The count tile's figures; only for `subscription_list` with a positive integer `count`. */
|
|
65
|
+
export declare const readSubscriptionHeader: (cta: DrilldownCta | undefined) => SubscriptionListHeader | undefined;
|
|
52
66
|
export {};
|
|
@@ -1,68 +1,107 @@
|
|
|
1
|
-
import { asNonEmptyText as
|
|
2
|
-
import { readHelp as
|
|
3
|
-
import { parseISO as
|
|
4
|
-
var
|
|
1
|
+
import { asNonEmptyText as d, asNumber as f } from "../../blocks/slotReaders.es.js";
|
|
2
|
+
import { readHelp as p } from "../HelpBlock/layout.es.js";
|
|
3
|
+
import { parseISO as S } from "date-fns/parseISO";
|
|
4
|
+
var a = {
|
|
5
5
|
SUMMARY_HEADER: "summary_header",
|
|
6
6
|
GENERIC_LIST: "generic_list",
|
|
7
7
|
HELP_HEADER: "help_header",
|
|
8
|
-
DEPOSIT_HISTORY: "deposit_history"
|
|
9
|
-
|
|
8
|
+
DEPOSIT_HISTORY: "deposit_history",
|
|
9
|
+
SUBSCRIPTION_LIST: "subscription_list"
|
|
10
|
+
}, b = /* @__PURE__ */ new Set([a.SUMMARY_HEADER, a.SUBSCRIPTION_LIST]), I = a.HELP_HEADER, y = (t, r, e) => {
|
|
10
11
|
switch (t) {
|
|
11
|
-
case
|
|
12
|
-
case
|
|
12
|
+
case a.GENERIC_LIST:
|
|
13
|
+
case a.HELP_HEADER:
|
|
13
14
|
return r.transactions?.transactions_title ?? "";
|
|
14
|
-
case
|
|
15
|
+
case a.DEPOSIT_HISTORY:
|
|
15
16
|
return r.insights_feed?.transaction_list_block?.deposit_history_drawer_title ?? "";
|
|
17
|
+
case a.SUBSCRIPTION_LIST:
|
|
18
|
+
return r.insights_feed?.transaction_list_block?.subscriptions_drawer_title ?? "";
|
|
16
19
|
default:
|
|
17
20
|
return e?.insights_payload?.title ?? "";
|
|
18
21
|
}
|
|
19
|
-
},
|
|
20
|
-
if (t?.variant !==
|
|
21
|
-
const e =
|
|
22
|
+
}, H = (t, r) => {
|
|
23
|
+
if (t?.variant !== I) return;
|
|
24
|
+
const e = d(r?.help_label), n = p(r);
|
|
22
25
|
return {
|
|
23
|
-
descriptionHtml:
|
|
24
|
-
...e &&
|
|
25
|
-
...
|
|
26
|
+
descriptionHtml: d(r?.description_html),
|
|
27
|
+
...e && n && { learnMore: {
|
|
28
|
+
...n,
|
|
26
29
|
label: e
|
|
27
30
|
} }
|
|
28
31
|
};
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
}, T = (t) => typeof t == "number" && Number.isInteger(t) && t > 0 ? t : void 0, m = Date.UTC(2e3, 0, 1), E = Date.UTC(2100, 0, 1), u = /* @__PURE__ */ new WeakMap(), s = (t, r) => {
|
|
33
|
+
const e = u.get(t) ?? /* @__PURE__ */ new Set();
|
|
34
|
+
e.has(r) || (u.set(t, e.add(r)), console.warn(r));
|
|
35
|
+
}, c = (t, r, e) => {
|
|
32
36
|
if (t == null || t === "") return;
|
|
33
|
-
let
|
|
34
|
-
if (typeof t == "number" && Number.isFinite(t))
|
|
37
|
+
let n;
|
|
38
|
+
if (typeof t == "number" && Number.isFinite(t)) n = t < 1e12 ? t * 1e3 : t;
|
|
35
39
|
else if (typeof t == "string") {
|
|
36
|
-
const i =
|
|
37
|
-
|
|
40
|
+
const i = S(t).getTime();
|
|
41
|
+
n = Number.isNaN(i) ? void 0 : i;
|
|
38
42
|
}
|
|
39
|
-
if (
|
|
40
|
-
|
|
43
|
+
if (n === void 0 || n < m || n > E) {
|
|
44
|
+
s(e, `[TransactionListBlock] drilldown_data.${r} is unparseable or out of range (${typeof t})`);
|
|
41
45
|
return;
|
|
42
46
|
}
|
|
43
|
-
return new Date(
|
|
44
|
-
},
|
|
45
|
-
if (t?.variant !==
|
|
47
|
+
return new Date(n);
|
|
48
|
+
}, L = (t) => {
|
|
49
|
+
if (t?.variant !== a.SUMMARY_HEADER) return;
|
|
46
50
|
const r = t?.drilldown_data;
|
|
47
51
|
if (!r) return;
|
|
48
|
-
const e =
|
|
52
|
+
const e = f(r.amount);
|
|
49
53
|
if (e === void 0) {
|
|
50
|
-
Object.keys(r).length > 0 &&
|
|
54
|
+
Object.keys(r).length > 0 && s(r, "[TransactionListBlock] drilldown_data has no finite `amount` — no summary header.");
|
|
51
55
|
return;
|
|
52
56
|
}
|
|
53
57
|
return {
|
|
54
58
|
amount: e,
|
|
55
|
-
startDate:
|
|
56
|
-
endDate:
|
|
57
|
-
count:
|
|
59
|
+
startDate: c(r.start_date, "start_date", r),
|
|
60
|
+
endDate: c(r.end_date, "end_date", r),
|
|
61
|
+
count: T(r.count)
|
|
62
|
+
};
|
|
63
|
+
}, v = /^(\d{4})-(\d{2})-\d{2}$/, N = (t, r) => {
|
|
64
|
+
const e = typeof t == "string" ? v.exec(t) : null, n = e ? Number(e[2]) : 0;
|
|
65
|
+
if (e && n >= 1 && n <= 12) return new Date(Number(e[1]), n - 1, 1);
|
|
66
|
+
const i = c(t, "date", r);
|
|
67
|
+
return i && new Date(i.getUTCFullYear(), i.getUTCMonth(), 1);
|
|
68
|
+
}, w = (t) => {
|
|
69
|
+
if (t?.variant !== a.SUBSCRIPTION_LIST) return;
|
|
70
|
+
const r = t.drilldown_data, e = r?.transaction_frequencies;
|
|
71
|
+
if (e == null) return;
|
|
72
|
+
if (!Array.isArray(e)) {
|
|
73
|
+
s(r, "[TransactionListBlock] drilldown_data.transaction_frequencies is not a list — captioning no rows.");
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const n = /* @__PURE__ */ new Map();
|
|
77
|
+
let i = 0;
|
|
78
|
+
return e.forEach((o) => {
|
|
79
|
+
const _ = typeof o == "object" && o !== null ? d(o.transaction_guid) : void 0, l = typeof o == "object" && o !== null ? f(o.recurrence_type) : void 0;
|
|
80
|
+
_ && l !== void 0 ? n.set(_, l) : i += 1;
|
|
81
|
+
}), i > 0 && s(r, `[TransactionListBlock] dropped ${i} malformed drilldown_data.transaction_frequencies row(s).`), n.size > 0 ? n : void 0;
|
|
82
|
+
}, D = (t) => {
|
|
83
|
+
if (t?.variant !== a.SUBSCRIPTION_LIST) return;
|
|
84
|
+
const r = t.drilldown_data;
|
|
85
|
+
if (!r) return;
|
|
86
|
+
const e = T(r.count);
|
|
87
|
+
if (e === void 0) {
|
|
88
|
+
Object.keys(r).length > 0 && s(r, "[TransactionListBlock] drilldown_data has no positive integer `count` — no subscription header.");
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
count: e,
|
|
93
|
+
month: N(r.date, r)
|
|
58
94
|
};
|
|
59
95
|
};
|
|
60
96
|
export {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
97
|
+
b as ACCOUNT_SUBLINE_VARIANTS,
|
|
98
|
+
I as HELP_HEADER_VARIANT,
|
|
99
|
+
a as TRANSACTION_LIST_VARIANTS,
|
|
100
|
+
y as getTransactionListDrawerTitle,
|
|
101
|
+
H as readHelpHeader,
|
|
102
|
+
D as readSubscriptionHeader,
|
|
103
|
+
L as readSummary,
|
|
104
|
+
w as readTransactionFrequencies
|
|
66
105
|
};
|
|
67
106
|
|
|
68
107
|
//# sourceMappingURL=layout.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionListBlock/layout.ts"],"sourcesContent":["import { parseISO } from 'date-fns/parseISO'\n\nimport type {\n Beat,\n DrilldownData,\n GlobalCopy,\n InDescriptionCTA,\n PrimaryCTA,\n SecondaryCTA,\n} from '../../../core'\nimport { asNonEmptyText, asNumber } from '../../blocks/slotReaders'\nimport { readHelp, type HelpContent } from '../HelpBlock/layout'\n\ntype DrilldownCta = PrimaryCTA | SecondaryCTA | InDescriptionCTA\n\n/** The transaction_list_block CTA variants. */\nexport const TRANSACTION_LIST_VARIANTS = {\n SUMMARY_HEADER: 'summary_header',\n GENERIC_LIST: 'generic_list',\n /** Opens the list under the beat's title, description and \"Learn More\". */\n HELP_HEADER: 'help_header',\n /** Opens Micro Deposits' Deposit History list. */\n DEPOSIT_HISTORY: 'deposit_history',\n} as const\n\nexport const HELP_HEADER_VARIANT = TRANSACTION_LIST_VARIANTS.HELP_HEADER\n\n/** Drawer title: the variant's title when it has one, otherwise the beat's own title. Add new variants here. */\nexport const getTransactionListDrawerTitle = (\n variant: string | null | undefined,\n copy: GlobalCopy,\n beat?: Beat,\n): string => {\n switch (variant) {\n case TRANSACTION_LIST_VARIANTS.GENERIC_LIST:\n case TRANSACTION_LIST_VARIANTS.HELP_HEADER:\n return copy.transactions?.transactions_title ?? ''\n case TRANSACTION_LIST_VARIANTS.DEPOSIT_HISTORY:\n return copy.insights_feed?.transaction_list_block?.deposit_history_drawer_title ?? ''\n default:\n return beat?.insights_payload?.title ?? ''\n }\n}\n\nexport interface HelpHeaderContent {\n /** Pre-localized HTML under the title, from the payload's `drilldown_data.description_html`. */\n descriptionHtml?: string\n /** The \"Learn More\" link and the help drawer it opens; absent when the beat carries no help. */\n learnMore?: HelpContent & { label: string }\n}\n\n/**\n * The help-header variant's text, read from the payload's `drilldown_data` (shared by every CTA\n * of the card): `description_html`, and `help_label` with the `help_title` / `help_html` that\n * `readHelp` reads. Only the `help_header` variant renders the block.\n */\nexport const readHelpHeader = (\n cta: DrilldownCta | undefined,\n drilldown: DrilldownData | undefined,\n): HelpHeaderContent | undefined => {\n if (cta?.variant !== HELP_HEADER_VARIANT) return undefined\n\n const label = asNonEmptyText(drilldown?.help_label)\n const help = readHelp(drilldown)\n\n return {\n descriptionHtml: asNonEmptyText(drilldown?.description_html),\n ...(label && help && { learnMore: { ...help, label } }),\n }\n}\n\nexport interface TransactionListSummary {\n /** Headline figure (e.g. total withdrawn). */\n amount: number\n /** Validated range endpoints; rendered as `{start} – {end}`. Omitted when the payload value is\n * missing or unparseable (so the drawer never crashes on an Invalid Date). */\n startDate?: Date\n endDate?: Date\n /** Number of transactions for the pill, from the CTA's `drilldown_data.count`. */\n count?: number\n}\n\n// `> 0`: the card only shows with >= 1 guid, so a `count` of 0 is dropped and falls back to the\n// guid count rather than rendering \"0 transactions\".\nconst toCount = (value: unknown): number | undefined =>\n typeof value === 'number' && Number.isInteger(value) && value > 0 ? value : undefined\n\n// Sane epoch window so a bad/typo payload can't render a far-past/future date.\nconst EPOCH_MIN = Date.UTC(2000, 0, 1)\nconst EPOCH_MAX = Date.UTC(2100, 0, 1)\n\n// `readSummary` runs on every observer re-render (no `useMemo` by design), so warn at most once per\n// distinct payload object instead of on every render. Keyed on the `drilldown_data` object, which is\n// a stable reference across re-renders of the same beat.\nconst warnedPayloads = new WeakSet<object>()\nconst warnOncePerPayload = (source: object, message: string): void => {\n if (warnedPayloads.has(source)) return\n warnedPayloads.add(source)\n console.warn(message)\n}\n\n/**\n * Parse a payload date value to a validated `Date`, or `undefined`. Accepts unix seconds or\n * milliseconds (auto-detected) and ISO strings. Fails closed (no throw): an unparseable or\n * out-of-range value returns undefined and warns, so `formatDate`/`intlFormat` never sees an Invalid\n * Date (which throws `RangeError` and takes down the whole drawer render).\n */\nconst toDate = (value: unknown, field: string, source: object): Date | undefined => {\n // Missing/empty is a normal \"no range\" case — return quietly, don't warn.\n if (value === undefined || value === null || value === '') return undefined\n\n let ms: number | undefined\n if (typeof value === 'number' && Number.isFinite(value)) {\n // < 1e12 is treated as seconds (1e12 ms is year 33658). Trade-off: genuine ms timestamps from\n // ~2000-2001 would be misread as seconds and fall outside the window below (dropped, not shown).\n ms = value < 1e12 ? value * 1000 : value\n } else if (typeof value === 'string') {\n const parsed = parseISO(value).getTime()\n ms = Number.isNaN(parsed) ? undefined : parsed\n }\n\n if (ms === undefined || ms < EPOCH_MIN || ms > EPOCH_MAX) {\n warnOncePerPayload(\n source,\n `[TransactionListBlock] drilldown_data.${field} is unparseable or out of range (${typeof value})`,\n )\n return undefined\n }\n return new Date(ms)\n}\n\n/**\n * Summary-header figures for the drawer, read from the clicked CTA's `drilldown_data` (the backend\n * hangs a drilldown's own data off the CTA that opens it). Fails closed throughout: only the\n * `summary_header` variant renders a header (so figures from a different CTA that `getDynamicCta…`\n * fell back to can't be misattributed), then without a finite `amount` there is still no header, and\n * each date is validated to a real `Date` or dropped — an unparseable value never reaches\n * `formatDate` (which throws on an Invalid Date).\n *\n * `drilldown_data` fields: `amount` (number), `start_date`/`end_date` (unix seconds|ms or ISO),\n * `count` (number of transactions).\n */\nexport const readSummary = (cta: DrilldownCta | undefined): TransactionListSummary | undefined => {\n // Defense-in-depth on financial figures: only the summary-header variant shows the card.\n if (cta?.variant !== TRANSACTION_LIST_VARIANTS.SUMMARY_HEADER) return undefined\n\n const source = cta?.drilldown_data\n if (!source) return undefined\n\n const amount = asNumber(source.amount)\n if (amount === undefined) {\n // `drilldown_data` present but no usable amount -> surface the likely contract drift (field\n // rename) instead of a silently missing header.\n if (Object.keys(source).length > 0) {\n warnOncePerPayload(\n source,\n '[TransactionListBlock] drilldown_data has no finite `amount` — no summary header.',\n )\n }\n return undefined\n }\n\n return {\n amount,\n startDate: toDate(source.start_date, 'start_date', source),\n endDate: toDate(source.end_date, 'end_date', source),\n count: toCount(source.count),\n }\n}\n"],"mappings":";;;AAgBA,IAAa,IAA4B;AAAA,EACvC,gBAAgB;AAAA,EAChB,cAAc;AAAA,EAEd,aAAa;AAAA,EAEb,iBAAiB;AACnB,GAEa,IAAsB,EAA0B,aAGhD,IAAA,CACX,GACA,GACA,MACW;AACX,UAAQ,GAAR;AAAA,IACE,KAAK,EAA0B;AAAA,IAC/B,KAAK,EAA0B;AAC7B,aAAO,EAAK,cAAc,sBAAsB;AAAA,IAClD,KAAK,EAA0B;AAC7B,aAAO,EAAK,eAAe,wBAAwB,gCAAgC;AAAA,IACrF;AACE,aAAO,GAAM,kBAAkB,SAAS;AAAA,EAC5C;AACF,GAca,IAAA,CACX,GACA,MACkC;AAClC,MAAI,GAAK,YAAY,EAAqB;AAE1C,QAAM,IAAQ,EAAe,GAAW,UAAU,GAC5C,IAAO,EAAS,CAAS;AAE/B,SAAO;AAAA,IACL,iBAAiB,EAAe,GAAW,gBAAgB;AAAA,IAC3D,GAAI,KAAS,KAAQ,EAAE,WAAW;AAAA,MAAE,GAAG;AAAA,MAAM,OAAA;AAAA,IAAM,EAAE;AAAA,EACvD;AACF,GAeM,IAAA,CAAW,MACf,OAAO,KAAU,YAAY,OAAO,UAAU,CAAK,KAAK,IAAQ,IAAI,IAAQ,QAGxE,IAAY,KAAK,IAAI,KAAM,GAAG,CAAC,GAC/B,IAAY,KAAK,IAAI,MAAM,GAAG,CAAC,GAK/B,IAAiB,oBAAI,QAAgB,GACrC,IAAA,CAAsB,GAAgB,MAA0B;AACpE,EAAI,EAAe,IAAI,CAAM,MAC7B,EAAe,IAAI,CAAM,GACzB,QAAQ,KAAK,CAAO;AACtB,GAQM,IAAA,CAAU,GAAgB,GAAe,MAAqC;AAElF,MAA2B,KAAU,QAAQ,MAAU,GAAI;AAE3D,MAAI;AACJ,MAAI,OAAO,KAAU,YAAY,OAAO,SAAS,CAAK,EAGpD,CAAA,IAAK,IAAQ,OAAO,IAAQ,MAAO;AAAA,WAC1B,OAAO,KAAU,UAAU;AACpC,UAAM,IAAS,EAAS,CAAK,EAAE,QAAQ;AACvC,IAAA,IAAK,OAAO,MAAM,CAAM,IAAI,SAAY;AAAA,EAC1C;AAEA,MAAI,MAAO,UAAa,IAAK,KAAa,IAAK,GAAW;AACxD,IAAA,EACE,GACA,yCAAyC,CAAA,oCAAyC,OAAO,CAAA,GAC3F;AACA;AAAA,EACF;AACA,SAAO,IAAI,KAAK,CAAE;AACpB,GAaa,IAAA,CAAe,MAAsE;AAEhG,MAAI,GAAK,YAAY,EAA0B,eAAgB;AAE/D,QAAM,IAAS,GAAK;AACpB,MAAI,CAAC,EAAQ;AAEb,QAAM,IAAS,EAAS,EAAO,MAAM;AACrC,MAAI,MAAW,QAAW;AAGxB,IAAI,OAAO,KAAK,CAAM,EAAE,SAAS,KAC/B,EACE,GACA,mFACF;AAEF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,QAAA;AAAA,IACA,WAAW,EAAO,EAAO,YAAY,cAAc,CAAM;AAAA,IACzD,SAAS,EAAO,EAAO,UAAU,YAAY,CAAM;AAAA,IACnD,OAAO,EAAQ,EAAO,KAAK;AAAA,EAC7B;AACF"}
|
|
1
|
+
{"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionListBlock/layout.ts"],"sourcesContent":["import { parseISO } from 'date-fns/parseISO'\n\nimport type {\n Beat,\n DrilldownData,\n GlobalCopy,\n InDescriptionCTA,\n PrimaryCTA,\n SecondaryCTA,\n} from '../../../core'\nimport { asNonEmptyText, asNumber } from '../../blocks/slotReaders'\nimport { readHelp, type HelpContent } from '../HelpBlock/layout'\n\ntype DrilldownCta = PrimaryCTA | SecondaryCTA | InDescriptionCTA\n\n/** The transaction_list_block CTA variants. */\nexport const TRANSACTION_LIST_VARIANTS = {\n SUMMARY_HEADER: 'summary_header',\n GENERIC_LIST: 'generic_list',\n /** Opens the list under the beat's title, description and \"Learn More\". */\n HELP_HEADER: 'help_header',\n /** Opens Micro Deposits' Deposit History list. */\n DEPOSIT_HISTORY: 'deposit_history',\n /** Opens Monthly Subscription Aggregate's Subscriptions list under a count tile and a tip. */\n SUBSCRIPTION_LIST: 'subscription_list',\n} as const\n\n/** Variants whose rows are subtitled with the account (institution logo and name), not the category. */\nexport const ACCOUNT_SUBLINE_VARIANTS: ReadonlySet<string | null | undefined> = new Set([\n TRANSACTION_LIST_VARIANTS.SUMMARY_HEADER,\n TRANSACTION_LIST_VARIANTS.SUBSCRIPTION_LIST,\n])\n\nexport const HELP_HEADER_VARIANT = TRANSACTION_LIST_VARIANTS.HELP_HEADER\n\n/** Drawer title: the variant's title when it has one, otherwise the beat's own title. Add new variants here. */\nexport const getTransactionListDrawerTitle = (\n variant: string | null | undefined,\n copy: GlobalCopy,\n beat?: Beat,\n): string => {\n switch (variant) {\n case TRANSACTION_LIST_VARIANTS.GENERIC_LIST:\n case TRANSACTION_LIST_VARIANTS.HELP_HEADER:\n return copy.transactions?.transactions_title ?? ''\n case TRANSACTION_LIST_VARIANTS.DEPOSIT_HISTORY:\n return copy.insights_feed?.transaction_list_block?.deposit_history_drawer_title ?? ''\n case TRANSACTION_LIST_VARIANTS.SUBSCRIPTION_LIST:\n return copy.insights_feed?.transaction_list_block?.subscriptions_drawer_title ?? ''\n default:\n return beat?.insights_payload?.title ?? ''\n }\n}\n\nexport interface HelpHeaderContent {\n /** Pre-localized HTML under the title, from the payload's `drilldown_data.description_html`. */\n descriptionHtml?: string\n /** The \"Learn More\" link and the help drawer it opens; absent when the beat carries no help. */\n learnMore?: HelpContent & { label: string }\n}\n\n/**\n * The help-header variant's text, read from the payload's `drilldown_data` (shared by every CTA\n * of the card): `description_html`, and `help_label` with the `help_title` / `help_html` that\n * `readHelp` reads. Only the `help_header` variant renders the block.\n */\nexport const readHelpHeader = (\n cta: DrilldownCta | undefined,\n drilldown: DrilldownData | undefined,\n): HelpHeaderContent | undefined => {\n if (cta?.variant !== HELP_HEADER_VARIANT) return undefined\n\n const label = asNonEmptyText(drilldown?.help_label)\n const help = readHelp(drilldown)\n\n return {\n descriptionHtml: asNonEmptyText(drilldown?.description_html),\n ...(label && help && { learnMore: { ...help, label } }),\n }\n}\n\nexport interface TransactionListSummary {\n /** Headline figure (e.g. total withdrawn). */\n amount: number\n /** Validated range endpoints; rendered as `{start} – {end}`. Omitted when the payload value is\n * missing or unparseable (so the drawer never crashes on an Invalid Date). */\n startDate?: Date\n endDate?: Date\n /** Number of transactions for the pill, from the CTA's `drilldown_data.count`. */\n count?: number\n}\n\n// `> 0`: the card only shows with >= 1 guid, so a `count` of 0 is dropped and falls back to the\n// guid count rather than rendering \"0 transactions\".\nconst toCount = (value: unknown): number | undefined =>\n typeof value === 'number' && Number.isInteger(value) && value > 0 ? value : undefined\n\n// Sane epoch window so a bad/typo payload can't render a far-past/future date.\nconst EPOCH_MIN = Date.UTC(2000, 0, 1)\nconst EPOCH_MAX = Date.UTC(2100, 0, 1)\n\n// The readers run on every observer re-render, so each distinct warning fires once per payload object.\nconst warnedPayloads = new WeakMap<object, Set<string>>()\nconst warnOncePerPayload = (source: object, message: string): void => {\n const warned = warnedPayloads.get(source) ?? new Set<string>()\n if (warned.has(message)) return\n warnedPayloads.set(source, warned.add(message))\n console.warn(message)\n}\n\n/**\n * Parse a payload date value to a validated `Date`, or `undefined`. Accepts unix seconds or\n * milliseconds (auto-detected) and ISO strings. Fails closed (no throw): an unparseable or\n * out-of-range value returns undefined and warns, so `formatDate`/`intlFormat` never sees an Invalid\n * Date (which throws `RangeError` and takes down the whole drawer render).\n */\nconst toDate = (value: unknown, field: string, source: object): Date | undefined => {\n // Missing/empty is a normal \"no range\" case — return quietly, don't warn.\n if (value === undefined || value === null || value === '') return undefined\n\n let ms: number | undefined\n if (typeof value === 'number' && Number.isFinite(value)) {\n // < 1e12 is treated as seconds (1e12 ms is year 33658). Trade-off: genuine ms timestamps from\n // ~2000-2001 would be misread as seconds and fall outside the window below (dropped, not shown).\n ms = value < 1e12 ? value * 1000 : value\n } else if (typeof value === 'string') {\n const parsed = parseISO(value).getTime()\n ms = Number.isNaN(parsed) ? undefined : parsed\n }\n\n if (ms === undefined || ms < EPOCH_MIN || ms > EPOCH_MAX) {\n warnOncePerPayload(\n source,\n `[TransactionListBlock] drilldown_data.${field} is unparseable or out of range (${typeof value})`,\n )\n return undefined\n }\n return new Date(ms)\n}\n\n/**\n * Summary-header figures for the drawer, read from the clicked CTA's `drilldown_data` (the backend\n * hangs a drilldown's own data off the CTA that opens it). Fails closed throughout: only the\n * `summary_header` variant renders a header (so figures from a different CTA that `getDynamicCta…`\n * fell back to can't be misattributed), then without a finite `amount` there is still no header, and\n * each date is validated to a real `Date` or dropped — an unparseable value never reaches\n * `formatDate` (which throws on an Invalid Date).\n *\n * `drilldown_data` fields: `amount` (number), `start_date`/`end_date` (unix seconds|ms or ISO),\n * `count` (number of transactions).\n */\nexport const readSummary = (cta: DrilldownCta | undefined): TransactionListSummary | undefined => {\n // Defense-in-depth on financial figures: only the summary-header variant shows the card.\n if (cta?.variant !== TRANSACTION_LIST_VARIANTS.SUMMARY_HEADER) return undefined\n\n const source = cta?.drilldown_data\n if (!source) return undefined\n\n const amount = asNumber(source.amount)\n if (amount === undefined) {\n // `drilldown_data` present but no usable amount -> surface the likely contract drift (field\n // rename) instead of a silently missing header.\n if (Object.keys(source).length > 0) {\n warnOncePerPayload(\n source,\n '[TransactionListBlock] drilldown_data has no finite `amount` — no summary header.',\n )\n }\n return undefined\n }\n\n return {\n amount,\n startDate: toDate(source.start_date, 'start_date', source),\n endDate: toDate(source.end_date, 'end_date', source),\n count: toCount(source.count),\n }\n}\n\nconst DATE_ONLY = /^(\\d{4})-(\\d{2})-\\d{2}$/\n\n/** The month a drilldown date names, as local midnight on the 1st. A date-only string already names its month. */\nconst toMonthStart = (value: unknown, source: object): Date | undefined => {\n const dateOnly = typeof value === 'string' ? DATE_ONLY.exec(value) : null\n const month = dateOnly ? Number(dateOnly[2]) : 0\n if (dateOnly && month >= 1 && month <= 12) return new Date(Number(dateOnly[1]), month - 1, 1)\n\n // An epoch or a timestamp is an instant: its UTC month is the one tupac meant.\n const date = toDate(value, 'date', source)\n return date && new Date(date.getUTCFullYear(), date.getUTCMonth(), 1)\n}\n\n/** Each listed transaction's schedule, from `drilldown_data.transaction_frequencies`; malformed rows are dropped. */\nexport const readTransactionFrequencies = (\n cta: DrilldownCta | undefined,\n): Map<string, number> | undefined => {\n if (cta?.variant !== TRANSACTION_LIST_VARIANTS.SUBSCRIPTION_LIST) return undefined\n\n const source = cta.drilldown_data\n const rows = source?.transaction_frequencies\n if (rows === undefined || rows === null) return undefined\n\n if (!Array.isArray(rows)) {\n warnOncePerPayload(\n source as object,\n '[TransactionListBlock] drilldown_data.transaction_frequencies is not a list — captioning no rows.',\n )\n return undefined\n }\n\n const byGuid = new Map<string, number>()\n let dropped = 0\n rows.forEach((row) => {\n const guid =\n typeof row === 'object' && row !== null ? asNonEmptyText(row.transaction_guid) : undefined\n const type = typeof row === 'object' && row !== null ? asNumber(row.recurrence_type) : undefined\n\n if (guid && type !== undefined) byGuid.set(guid, type)\n else dropped += 1\n })\n\n if (dropped > 0) {\n warnOncePerPayload(\n source as object,\n `[TransactionListBlock] dropped ${dropped} malformed drilldown_data.transaction_frequencies row(s).`,\n )\n }\n\n return byGuid.size > 0 ? byGuid : undefined\n}\n\nexport interface SubscriptionListHeader {\n /** Subscriptions paid in the month, from the CTA's `drilldown_data.count`. */\n count: number\n /** The month paid in, as local midnight on the 1st; omitted when missing or unparseable. */\n month?: Date\n}\n\n/** The count tile's figures; only for `subscription_list` with a positive integer `count`. */\nexport const readSubscriptionHeader = (\n cta: DrilldownCta | undefined,\n): SubscriptionListHeader | undefined => {\n if (cta?.variant !== TRANSACTION_LIST_VARIANTS.SUBSCRIPTION_LIST) return undefined\n\n const source = cta.drilldown_data\n if (!source) return undefined\n\n const count = toCount(source.count)\n if (count === undefined) {\n if (Object.keys(source).length > 0) {\n warnOncePerPayload(\n source,\n '[TransactionListBlock] drilldown_data has no positive integer `count` — no subscription header.',\n )\n }\n return undefined\n }\n\n return {\n count,\n month: toMonthStart(source.date, source),\n }\n}\n"],"mappings":";;;AAgBA,IAAa,IAA4B;AAAA,EACvC,gBAAgB;AAAA,EAChB,cAAc;AAAA,EAEd,aAAa;AAAA,EAEb,iBAAiB;AAAA,EAEjB,mBAAmB;AACrB,GAGa,IAAmE,oBAAI,IAAI,CACtF,EAA0B,gBAC1B,EAA0B,iBAC5B,CAAC,GAEY,IAAsB,EAA0B,aAGhD,IAAA,CACX,GACA,GACA,MACW;AACX,UAAQ,GAAR;AAAA,IACE,KAAK,EAA0B;AAAA,IAC/B,KAAK,EAA0B;AAC7B,aAAO,EAAK,cAAc,sBAAsB;AAAA,IAClD,KAAK,EAA0B;AAC7B,aAAO,EAAK,eAAe,wBAAwB,gCAAgC;AAAA,IACrF,KAAK,EAA0B;AAC7B,aAAO,EAAK,eAAe,wBAAwB,8BAA8B;AAAA,IACnF;AACE,aAAO,GAAM,kBAAkB,SAAS;AAAA,EAC5C;AACF,GAca,IAAA,CACX,GACA,MACkC;AAClC,MAAI,GAAK,YAAY,EAAqB;AAE1C,QAAM,IAAQ,EAAe,GAAW,UAAU,GAC5C,IAAO,EAAS,CAAS;AAE/B,SAAO;AAAA,IACL,iBAAiB,EAAe,GAAW,gBAAgB;AAAA,IAC3D,GAAI,KAAS,KAAQ,EAAE,WAAW;AAAA,MAAE,GAAG;AAAA,MAAM,OAAA;AAAA,IAAM,EAAE;AAAA,EACvD;AACF,GAeM,IAAA,CAAW,MACf,OAAO,KAAU,YAAY,OAAO,UAAU,CAAK,KAAK,IAAQ,IAAI,IAAQ,QAGxE,IAAY,KAAK,IAAI,KAAM,GAAG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;AAAA,EACF;AAEA,SAAO;AAAA,IACL,OAAA;AAAA,IACA,OAAO,EAAa,EAAO,MAAM,CAAM;AAAA,EACzC;AACF"}
|
|
@@ -1,28 +1,9 @@
|
|
|
1
1
|
import { InsightsPayload } from '../../../../core';
|
|
2
|
-
export { PAYOFF_STYLE } from './layout';
|
|
3
2
|
interface DebtsBlockProps {
|
|
4
3
|
payload: InsightsPayload;
|
|
5
4
|
beatGuid?: string;
|
|
6
5
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*
|
|
12
|
-
* - `projected_payoff` — one account on the `DebtPayoffCard`. Its facts arrive flat on
|
|
13
|
-
* `instance_slot` (the shape it shipped with): the balance (`amount`), `payoff_date`,
|
|
14
|
-
* `monthly_payment`, `interest_rate`, plus the shared account/institution fields.
|
|
15
|
-
* - `debt_summary` — the beat's several debt accounts on a `TransactionListCard`, read from
|
|
16
|
-
* `instance_slot.data`: one row per account from `series` (pre-localized `logo`, `primary_text`
|
|
17
|
-
* name, `secondary_text` rate, `amount` balance, in the order sent), an optional `header_text`,
|
|
18
|
-
* and the total owed (`amount`) as the footer. With no rows there is nothing to summarize and the
|
|
19
|
-
* block renders nothing.
|
|
20
|
-
*
|
|
21
|
-
* Captions and payoff row labels come from `insights_feed.debts_block` copy, which ships
|
|
22
|
-
* separately. Each variant needs only its own keys: until they have shipped, the card shows what
|
|
23
|
-
* needs no copy (the account row, the summary rows) but never an unlabelled figure, and warns once
|
|
24
|
-
* per mount so the rollout gap is traceable. A row with no value (or an unparseable date) is
|
|
25
|
-
* dropped rather than rendered blank.
|
|
26
|
-
*/
|
|
27
|
-
declare const DebtsBlock: ({ payload }: DebtsBlockProps) => import("react/jsx-runtime").JSX.Element;
|
|
28
|
-
export default DebtsBlock;
|
|
6
|
+
declare const _default: (({ payload }: DebtsBlockProps) => import("react/jsx-runtime").JSX.Element | null) & {
|
|
7
|
+
displayName: string;
|
|
8
|
+
};
|
|
9
|
+
export default _default;
|
|
@@ -1,77 +1,100 @@
|
|
|
1
|
-
import { DATE_FORMATS_INTL as
|
|
2
|
-
import { useGlobalCopyStore as
|
|
3
|
-
import { slot as
|
|
4
|
-
import { CURRENCY_FORMAT as
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import j from "
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import { jsx as
|
|
14
|
-
import
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
1
|
+
import { DATE_FORMATS_INTL as R, formatDate as k } from "../../../../core/constants/DateFormats.es.js";
|
|
2
|
+
import { useGlobalCopyStore as w } from "../../../../common/context/hooks.es.js";
|
|
3
|
+
import { slot as s } from "../../../../core/types/Insights.es.js";
|
|
4
|
+
import { CURRENCY_FORMAT as b, formatCurrency as f } from "../../../../core/utils/NumberFormatting.es.js";
|
|
5
|
+
import { asLogoRef as A, asNonEmptyText as C, asNumber as _, asText as L } from "../../slotReaders.es.js";
|
|
6
|
+
import F from "../../../components/LogoFromGuid.es.js";
|
|
7
|
+
import O from "../../../components/InsightTransactionRow.es.js";
|
|
8
|
+
import { parseDueDate as j } from "../RepeatingTransactionBlock/weekStrip.es.js";
|
|
9
|
+
import { useEffect as E } from "react";
|
|
10
|
+
import { observer as I } from "mobx-react-lite";
|
|
11
|
+
import y from "@mui/material/Stack";
|
|
12
|
+
import { Text as D } from "@mxenabled/mxui";
|
|
13
|
+
import { Fragment as N, jsx as a, jsxs as v } from "react/jsx-runtime";
|
|
14
|
+
import S from "@mui/material/Divider";
|
|
15
|
+
var B = 32, G = (r) => {
|
|
16
|
+
if (Array.isArray(r))
|
|
17
|
+
for (const o of r) {
|
|
18
|
+
if (typeof o != "object" || o === null) continue;
|
|
19
|
+
const { amount: t, logo: l, primary_text: i, secondary_text: n } = o, e = C(i);
|
|
20
|
+
if (e) return {
|
|
21
|
+
name: e,
|
|
22
|
+
account: L(n),
|
|
23
|
+
amount: _(t),
|
|
24
|
+
logo: A(l)
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}, M = ({ grey: r, label: o, value: t }) => /* @__PURE__ */ v(N, { children: [/* @__PURE__ */ a(S, {}), /* @__PURE__ */ v(y, {
|
|
28
|
+
sx: {
|
|
29
|
+
alignItems: "center",
|
|
30
|
+
bgcolor: r ? "background.default" : "background.paper",
|
|
31
|
+
flexDirection: "row",
|
|
32
|
+
justifyContent: "space-between",
|
|
33
|
+
minHeight: 40,
|
|
34
|
+
px: 16,
|
|
35
|
+
py: 2
|
|
36
|
+
},
|
|
37
|
+
children: [/* @__PURE__ */ a(D, {
|
|
38
|
+
color: "text.primary",
|
|
39
|
+
variant: "subtitle2",
|
|
40
|
+
children: o
|
|
41
|
+
}), /* @__PURE__ */ a(D, {
|
|
42
|
+
bold: !0,
|
|
43
|
+
color: "text.primary",
|
|
44
|
+
variant: "caption",
|
|
45
|
+
children: t
|
|
46
|
+
})]
|
|
47
|
+
})] }), H = ({ payload: r }) => {
|
|
48
|
+
const o = w().insights_feed?.debts_block, t = o?.payment_due_label, l = o?.minimum_payment_label, i = o?.balance_label, n = r.instance_slot?.data, e = G(s(n, "series")), g = L(s(n, "due_date")), c = g ? j(g) : null, u = _(s(n, "minimum_payment")), d = _(s(n, "amount")), x = e !== void 0, p = [
|
|
49
|
+
c && !t && "payment_due_label",
|
|
50
|
+
u !== void 0 && !l && "minimum_payment_label",
|
|
51
|
+
d !== void 0 && !i && "balance_label"
|
|
52
|
+
].filter(Boolean).join(", ");
|
|
53
|
+
if (E(() => {
|
|
54
|
+
x && p && console.warn(`debts_block: copy missing ${p}; hiding those lines`);
|
|
55
|
+
}, [x, p]), !e) return null;
|
|
56
|
+
const h = [
|
|
57
|
+
t && c ? {
|
|
58
|
+
label: t,
|
|
59
|
+
value: k(c, R.FULL_MONTH_DAY)
|
|
60
|
+
} : null,
|
|
61
|
+
l && u !== void 0 ? {
|
|
62
|
+
label: l,
|
|
63
|
+
value: f(u, b.cents)
|
|
64
|
+
} : null,
|
|
65
|
+
i && d !== void 0 ? {
|
|
66
|
+
label: i,
|
|
67
|
+
value: f(d, b.cents)
|
|
68
|
+
} : null
|
|
69
|
+
].filter((m) => m !== null);
|
|
70
|
+
return /* @__PURE__ */ a(y, {
|
|
71
|
+
sx: { px: 16 },
|
|
72
|
+
children: /* @__PURE__ */ v(y, {
|
|
73
|
+
sx: {
|
|
74
|
+
border: "1px solid",
|
|
75
|
+
borderColor: "divider",
|
|
76
|
+
borderRadius: "8px",
|
|
77
|
+
overflow: "hidden",
|
|
78
|
+
width: "100%"
|
|
79
|
+
},
|
|
80
|
+
children: [/* @__PURE__ */ a(O, {
|
|
81
|
+
amount: e.amount === void 0 ? "" : f(e.amount, b.cents),
|
|
82
|
+
leading: /* @__PURE__ */ a(F, {
|
|
83
|
+
logo: e.logo,
|
|
84
|
+
size: B
|
|
85
|
+
}),
|
|
86
|
+
subtitle: e.account ?? "",
|
|
87
|
+
title: e.name
|
|
88
|
+
}), h.map((m, T) => /* @__PURE__ */ a(M, {
|
|
89
|
+
grey: T === h.length - 1,
|
|
90
|
+
label: m.label,
|
|
91
|
+
value: m.value
|
|
92
|
+
}, m.label))]
|
|
93
|
+
})
|
|
71
94
|
});
|
|
72
|
-
};
|
|
95
|
+
}, oe = I(H);
|
|
73
96
|
export {
|
|
74
|
-
|
|
97
|
+
oe as default
|
|
75
98
|
};
|
|
76
99
|
|
|
77
100
|
//# sourceMappingURL=DebtsBlock.es.js.map
|