@mx-cartographer/experiences 9.7.153 → 9.7.155
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 +8 -0
- package/dist/insights-v2/actionBlocks/AccountListBlock/AccountListBlock.es.js +42 -42
- package/dist/insights-v2/actionBlocks/AccountListBlock/AccountListBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/ActionBlockLayer.es.js +37 -37
- package/dist/insights-v2/actionBlocks/ActionBlockLayer.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js +52 -52
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetDetailsBlock.es.js +87 -87
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetDetailsBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/MakeTransferActionBlockLayer.es.js +12 -12
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/MakeTransferActionBlockLayer.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/PayoffStrategiesBlock/PayoffStrategiesContent.es.js +18 -18
- package/dist/insights-v2/actionBlocks/PayoffStrategiesBlock/PayoffStrategiesContent.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/PlaceholderActionBlock.es.js +23 -22
- package/dist/insights-v2/actionBlocks/PlaceholderActionBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/SubscriptionStatusModalBlock.es.js +44 -44
- package/dist/insights-v2/actionBlocks/SubscriptionStatusModalBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/SurveyModalActionBlock.es.js +24 -24
- package/dist/insights-v2/actionBlocks/SurveyModalActionBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionDetailsBlock/useTransactionDetailsBlock.es.js +20 -20
- package/dist/insights-v2/actionBlocks/TransactionDetailsBlock/useTransactionDetailsBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionDetailsBlock/util.d.ts +1 -2
- package/dist/insights-v2/actionBlocks/TransactionDetailsBlock/util.es.js +3 -7
- package/dist/insights-v2/actionBlocks/TransactionDetailsBlock/util.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +75 -75
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.es.js +11 -11
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListBlock.es.js +58 -58
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListHeaderIconTile.d.ts +7 -0
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListHeaderIconTile.es.js +28 -0
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListHeaderIconTile.es.js.map +1 -0
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListSubscriptionHeader.es.js +14 -33
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListSubscriptionHeader.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListSummaryCard.es.js +24 -41
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListSummaryCard.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/useOpenedCta.d.ts +9 -0
- package/dist/insights-v2/actionBlocks/useOpenedCta.es.js +11 -0
- package/dist/insights-v2/actionBlocks/useOpenedCta.es.js.map +1 -0
- package/dist/insights-v2/actionBlocks/util.d.ts +2 -1
- package/dist/insights-v2/actionBlocks/util.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.es.js +18 -15
- package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/layout.d.ts +7 -0
- package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/layout.es.js +21 -11
- package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/components/AmountPill.d.ts +4 -2
- package/dist/insights-v2/components/AmountPill.es.js +6 -5
- package/dist/insights-v2/components/AmountPill.es.js.map +1 -1
- package/dist/insights-v2/components/MerchantHighlightCard.d.ts +6 -1
- package/dist/insights-v2/components/MerchantHighlightCard.es.js +26 -22
- package/dist/insights-v2/components/MerchantHighlightCard.es.js.map +1 -1
- package/dist/transactions/components/shared/TransactionList.d.ts +1 -1
- package/dist/transactions/components/shared/TransactionList.es.js.map +1 -1
- package/dist/transactions/components/shared/transactionlist/TransactionRow.d.ts +1 -1
- package/dist/transactions/components/shared/transactionlist/TransactionRow.es.js +49 -44
- package/dist/transactions/components/shared/transactionlist/TransactionRow.es.js.map +1 -1
- package/package.json +1 -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 { 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;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;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,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"}
|
|
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 { useOpenedCta } from '../useOpenedCta'\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 { 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 read\n // the CTA that 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 { is_zero_state, drilldown_data, title } = beat.insights_payload ?? {}\n const currentCta = useOpenedCta(beat)\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;AAAA;AAEF,GAGM,KAAA,CACJ,OAEA,EAA+B,CAAK,GAE7B,gBAAA,EA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A,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,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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface TransactionListHeaderIconTileProps {
|
|
2
|
+
/** An mx-icons name. */
|
|
3
|
+
name: string;
|
|
4
|
+
}
|
|
5
|
+
/** The icon tile that leads the Transaction List header cards. */
|
|
6
|
+
export declare const TransactionListHeaderIconTile: ({ name }: TransactionListHeaderIconTileProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export default TransactionListHeaderIconTile;
|
package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListHeaderIconTile.es.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Icon as t } from "@mxenabled/mx-icons";
|
|
2
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
3
|
+
import { alpha as o } from "@mui/material/styles";
|
|
4
|
+
import a from "@mui/material/Box";
|
|
5
|
+
var s = ({ name: i }) => /* @__PURE__ */ r(a, {
|
|
6
|
+
sx: {
|
|
7
|
+
alignItems: "center",
|
|
8
|
+
bgcolor: (e) => o(e.palette.primary.main, 0.15),
|
|
9
|
+
borderRadius: "4px",
|
|
10
|
+
color: "primary.main",
|
|
11
|
+
display: "flex",
|
|
12
|
+
height: 56,
|
|
13
|
+
justifyContent: "center",
|
|
14
|
+
width: 56
|
|
15
|
+
},
|
|
16
|
+
children: /* @__PURE__ */ r(t, {
|
|
17
|
+
"aria-hidden": !0,
|
|
18
|
+
fill: !0,
|
|
19
|
+
name: i,
|
|
20
|
+
size: 32
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
export {
|
|
24
|
+
s as TransactionListHeaderIconTile,
|
|
25
|
+
s as default
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=TransactionListHeaderIconTile.es.js.map
|
package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListHeaderIconTile.es.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransactionListHeaderIconTile.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionListBlock/TransactionListHeaderIconTile.tsx"],"sourcesContent":["import Box from '@mui/material/Box'\nimport { alpha } from '@mui/material/styles'\n\nimport { Icon } from '@mxenabled/mx-icons'\n\nexport interface TransactionListHeaderIconTileProps {\n /** An mx-icons name. */\n name: string\n}\n\n/** The icon tile that leads the Transaction List header cards. */\nexport const TransactionListHeaderIconTile = ({ name }: TransactionListHeaderIconTileProps) => (\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={name} size={32} />\n </Box>\n)\n\nexport default TransactionListHeaderIconTile\n"],"mappings":";;;;AAWA,IAAa,IAAA,CAAiC,EAAE,MAAA,EAAA,MAC9C,gBAAA,EAAC,GAAD;AAAA,EACE,IAAI;AAAA,IACF,YAAY;AAAA,IACZ,SAAA,CAAU,MAAU,EAAM,EAAM,QAAQ,QAAQ,MAAM,IAAI;AAAA,IAC1D,cAAc;AAAA,IACd,OAAO;AAAA,IACP,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,gBAAgB;AAAA,IAChB,OAAO;AAAA,EACT;AAAA,EAEA,UAAA,gBAAA,EAAC,GAAD;AAAA,IAAM,eAAa;AAAA,IAAM,MAAM;AAAA,IAAY,MAAA;AAAA,IAAM,MAAM;AAAA,EAAK,CAAA;AACzD,CAAA"}
|
package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListSubscriptionHeader.es.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import { buildDynamicCopy as
|
|
2
|
-
import { DATE_FORMATS_INTL as
|
|
1
|
+
import { buildDynamicCopy as c } from "../../../core/utils/Localization.es.js";
|
|
2
|
+
import { DATE_FORMATS_INTL as p, formatDate as d } from "../../../core/constants/DateFormats.es.js";
|
|
3
3
|
import { getLogoElevation as u } from "../../components/logoShadow.es.js";
|
|
4
|
-
import { TipSection as
|
|
4
|
+
import { TipSection as l } from "../../../insights/components/shared/ChartDrawerTemplate/TipSection.es.js";
|
|
5
5
|
import { DRAWER_TIP_ICON as g } from "../../components/drawerTip.es.js";
|
|
6
|
+
import { TransactionListHeaderIconTile as _ } from "./TransactionListHeaderIconTile.es.js";
|
|
6
7
|
import n from "@mui/material/Stack";
|
|
7
|
-
import { Text as
|
|
8
|
-
import { Icon as h } from "@mxenabled/mx-icons";
|
|
8
|
+
import { Text as m } from "@mxenabled/mxui";
|
|
9
9
|
import { jsx as r, jsxs as e } from "react/jsx-runtime";
|
|
10
|
-
|
|
11
|
-
|
|
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;
|
|
10
|
+
var L = ({ header: o, copy: i, tipTitle: a }) => {
|
|
11
|
+
const s = a && i.subscriptions_tip_message ? i.subscriptions_tip_message : void 0, t = o.month && i.subscriptions_in_month ? c(i.subscriptions_in_month, d(o.month, p.MONTH_LONG)) : void 0;
|
|
14
12
|
return /* @__PURE__ */ e(n, {
|
|
15
13
|
sx: {
|
|
16
14
|
gap: 16,
|
|
@@ -28,49 +26,32 @@ var j = ({ header: o, copy: i, tipTitle: a }) => {
|
|
|
28
26
|
gap: 12,
|
|
29
27
|
p: 16
|
|
30
28
|
},
|
|
31
|
-
children: [/* @__PURE__ */ r(
|
|
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, {
|
|
29
|
+
children: [/* @__PURE__ */ r(_, { name: "currency_exchange" }), /* @__PURE__ */ e(n, {
|
|
49
30
|
"aria-label": t ? `${o.count} ${t}` : String(o.count),
|
|
50
31
|
role: "group",
|
|
51
|
-
children: [/* @__PURE__ */ r(
|
|
32
|
+
children: [/* @__PURE__ */ r(m, {
|
|
52
33
|
"aria-hidden": !0,
|
|
53
34
|
bold: !0,
|
|
54
35
|
component: "p",
|
|
55
36
|
variant: "h1",
|
|
56
37
|
children: o.count
|
|
57
|
-
}), t && /* @__PURE__ */ r(
|
|
38
|
+
}), t && /* @__PURE__ */ r(m, {
|
|
58
39
|
"aria-hidden": !0,
|
|
59
40
|
color: "text.secondary",
|
|
60
41
|
variant: "caption",
|
|
61
42
|
children: t
|
|
62
43
|
})]
|
|
63
44
|
})]
|
|
64
|
-
}), s && /* @__PURE__ */ r(
|
|
45
|
+
}), s && /* @__PURE__ */ r(l, {
|
|
65
46
|
icon: g,
|
|
66
|
-
message:
|
|
47
|
+
message: c(s, /* @__PURE__ */ r("strong", { children: a })),
|
|
67
48
|
sx: { m: 0 }
|
|
68
49
|
})]
|
|
69
50
|
});
|
|
70
51
|
};
|
|
71
52
|
export {
|
|
72
|
-
|
|
73
|
-
|
|
53
|
+
L as TransactionListSubscriptionHeader,
|
|
54
|
+
L as default
|
|
74
55
|
};
|
|
75
56
|
|
|
76
57
|
//# sourceMappingURL=TransactionListSubscriptionHeader.es.js.map
|
|
@@ -1 +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
|
|
1
|
+
{"version":3,"file":"TransactionListSubscriptionHeader.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionListBlock/TransactionListSubscriptionHeader.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\n\nimport Stack from '@mui/material/Stack'\n\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 { TransactionListHeaderIconTile } from './TransactionListHeaderIconTile'\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 <TransactionListHeaderIconTile name=\"currency_exchange\" />\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":";;;;;;;;;AA4BA,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,EAA+B,MAAK,oBAAqB,CAAA,GAEzD,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"}
|
|
@@ -1,83 +1,66 @@
|
|
|
1
|
-
import { buildPluralCopy as
|
|
2
|
-
import { DATE_FORMATS_INTL as s, formatDate as
|
|
3
|
-
import { CURRENCY_FORMAT as
|
|
4
|
-
import { getLogoElevation as
|
|
1
|
+
import { buildPluralCopy as l } from "../../../core/utils/Localization.es.js";
|
|
2
|
+
import { DATE_FORMATS_INTL as s, formatDate as d } from "../../../core/constants/DateFormats.es.js";
|
|
3
|
+
import { CURRENCY_FORMAT as f, formatCurrency as x } from "../../../core/utils/NumberFormatting.es.js";
|
|
4
|
+
import { getLogoElevation as _ } from "../../components/logoShadow.es.js";
|
|
5
|
+
import { TransactionListHeaderIconTile as g } from "./TransactionListHeaderIconTile.es.js";
|
|
5
6
|
import n from "@mui/material/Stack";
|
|
6
|
-
import { Text as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { alpha as m } from "@mui/material/styles";
|
|
7
|
+
import { Text as i } from "@mxenabled/mxui";
|
|
8
|
+
import { jsx as o, jsxs as e } from "react/jsx-runtime";
|
|
9
|
+
import { alpha as T } from "@mui/material/styles";
|
|
10
10
|
import p from "@mui/material/Box";
|
|
11
|
-
var
|
|
12
|
-
const
|
|
13
|
-
return /* @__PURE__ */
|
|
11
|
+
var u = "_1{count} transactions", h = "_1{count} transaction", v = (t, a) => [t, a].filter((r) => r !== void 0).map((r) => d(r, s.MONTH_DAY)).join(" – "), S = ({ summary: t, count: a, copy: r }) => {
|
|
12
|
+
const c = v(t.startDate, t.endDate);
|
|
13
|
+
return /* @__PURE__ */ o(p, {
|
|
14
14
|
sx: {
|
|
15
15
|
px: 24,
|
|
16
16
|
pt: 24,
|
|
17
17
|
pb: 12
|
|
18
18
|
},
|
|
19
|
-
children: /* @__PURE__ */
|
|
19
|
+
children: /* @__PURE__ */ e(n, {
|
|
20
20
|
sx: {
|
|
21
21
|
bgcolor: "background.paper",
|
|
22
22
|
borderRadius: "8px",
|
|
23
|
-
boxShadow:
|
|
23
|
+
boxShadow: _,
|
|
24
24
|
gap: 11,
|
|
25
25
|
p: 16
|
|
26
26
|
},
|
|
27
|
-
children: [/* @__PURE__ */
|
|
27
|
+
children: [/* @__PURE__ */ e(n, {
|
|
28
28
|
sx: {
|
|
29
29
|
alignItems: "center",
|
|
30
30
|
flexDirection: "row",
|
|
31
31
|
gap: 12
|
|
32
32
|
},
|
|
33
|
-
children: [/* @__PURE__ */
|
|
34
|
-
sx: {
|
|
35
|
-
alignItems: "center",
|
|
36
|
-
bgcolor: (i) => m(i.palette.primary.main, 0.15),
|
|
37
|
-
borderRadius: "4px",
|
|
38
|
-
color: "primary.main",
|
|
39
|
-
display: "flex",
|
|
40
|
-
height: 56,
|
|
41
|
-
justifyContent: "center",
|
|
42
|
-
width: 56
|
|
43
|
-
},
|
|
44
|
-
children: /* @__PURE__ */ r(u, {
|
|
45
|
-
"aria-hidden": !0,
|
|
46
|
-
fill: !0,
|
|
47
|
-
name: "savings",
|
|
48
|
-
size: 32
|
|
49
|
-
})
|
|
50
|
-
}), /* @__PURE__ */ c(n, { children: [l && /* @__PURE__ */ r(e, {
|
|
33
|
+
children: [/* @__PURE__ */ o(g, { name: "savings" }), /* @__PURE__ */ e(n, { children: [c && /* @__PURE__ */ o(i, {
|
|
51
34
|
color: "text.secondary",
|
|
52
35
|
variant: "caption",
|
|
53
|
-
children:
|
|
54
|
-
}), /* @__PURE__ */
|
|
36
|
+
children: c
|
|
37
|
+
}), /* @__PURE__ */ o(i, {
|
|
55
38
|
bold: !0,
|
|
56
39
|
component: "p",
|
|
57
40
|
variant: "h1",
|
|
58
|
-
children:
|
|
41
|
+
children: x(t.amount, f.cents)
|
|
59
42
|
})] })]
|
|
60
|
-
}), /* @__PURE__ */
|
|
43
|
+
}), /* @__PURE__ */ o(p, {
|
|
61
44
|
sx: {
|
|
62
45
|
alignItems: "center",
|
|
63
|
-
bgcolor: (
|
|
46
|
+
bgcolor: (m) => T(m.palette.primary.main, 0.15),
|
|
64
47
|
borderRadius: "999px",
|
|
65
48
|
display: "flex",
|
|
66
49
|
px: 12,
|
|
67
50
|
py: 2
|
|
68
51
|
},
|
|
69
|
-
children: /* @__PURE__ */
|
|
52
|
+
children: /* @__PURE__ */ o(i, {
|
|
70
53
|
color: "primary.dark",
|
|
71
54
|
variant: "caption",
|
|
72
|
-
children:
|
|
55
|
+
children: l(r.transaction_count_one ?? h, r.transaction_count ?? u, a, String(a))
|
|
73
56
|
})
|
|
74
57
|
})]
|
|
75
58
|
})
|
|
76
59
|
});
|
|
77
60
|
};
|
|
78
61
|
export {
|
|
79
|
-
|
|
80
|
-
|
|
62
|
+
S as TransactionListSummaryCard,
|
|
63
|
+
S as default
|
|
81
64
|
};
|
|
82
65
|
|
|
83
66
|
//# sourceMappingURL=TransactionListSummaryCard.es.js.map
|
package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListSummaryCard.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionListSummaryCard.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionListBlock/TransactionListSummaryCard.tsx"],"sourcesContent":["import Box from '@mui/material/Box'\nimport Stack from '@mui/material/Stack'\nimport { alpha } from '@mui/material/styles'\n\nimport {
|
|
1
|
+
{"version":3,"file":"TransactionListSummaryCard.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionListBlock/TransactionListSummaryCard.tsx"],"sourcesContent":["import Box from '@mui/material/Box'\nimport Stack from '@mui/material/Stack'\nimport { alpha } from '@mui/material/styles'\n\nimport { Text } from '@mxenabled/mxui'\n\nimport { DATE_FORMATS_INTL, formatDate } from '../../../core/constants'\nimport type { InsightsFeedCopy } from '../../../core/types/localization'\nimport { buildPluralCopy } from '../../../core/utils/Localization'\nimport { CURRENCY_FORMAT, formatCurrency } from '../../../core/utils/NumberFormatting'\nimport { getLogoElevation } from '../../components/logoShadow'\n\nimport { TransactionListHeaderIconTile } from './TransactionListHeaderIconTile'\nimport type { TransactionListSummary } from './layout'\n\nexport interface TransactionListSummaryCardProps {\n summary: TransactionListSummary\n /** Pill count: the CTA's `drilldown_data.count`, else the number of guids the beat names. */\n count: number\n /** Only the two pill-copy keys the card reads. */\n copy: Pick<InsightsFeedCopy['general'], 'transaction_count' | 'transaction_count_one'>\n}\n\n// English default until the localized-content service ships the pill copy in every locale.\nconst DEFAULT_COUNT_COPY = '_1{count} transactions'\nconst DEFAULT_COUNT_ONE_COPY = '_1{count} transaction'\n\n// Endpoints are already validated `Date`s from `readSummary` (invalid/junk omitted there).\nconst formatRange = (start?: Date, end?: Date): string =>\n [start, end]\n .filter((d): d is Date => d !== undefined)\n .map((d) => formatDate(d, DATE_FORMATS_INTL.MONTH_DAY))\n .join(' – ')\n\n/**\n * Summary header for the Transaction List drawer: a white card with a themed icon tile, the date\n * range, the headline amount, and a `{count} transactions` pill. Driven by the beat's summary\n * figures (see `readSummary` in layout.ts). Theme-aware tokens keep it correct in dark mode.\n *\n * Figma: Drilldown | Replenish Savings (\"Savings Withdrawal\"). Currently only Replenish Savings\n * declares the `summary_header` variant, so the tile carries its `savings` icon.\n */\nexport const TransactionListSummaryCard = ({\n summary,\n count,\n copy,\n}: TransactionListSummaryCardProps) => {\n const dateRange = formatRange(summary.startDate, summary.endDate)\n\n return (\n <Box sx={{ px: 24, pt: 24, pb: 12 }}>\n <Stack\n sx={{\n bgcolor: 'background.paper',\n borderRadius: '8px',\n boxShadow: getLogoElevation,\n gap: 11,\n p: 16,\n }}\n >\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 12 }}>\n <TransactionListHeaderIconTile name=\"savings\" />\n <Stack>\n {dateRange && (\n <Text color=\"text.secondary\" variant=\"caption\">\n {dateRange}\n </Text>\n )}\n <Text bold={true} component=\"p\" variant=\"h1\">\n {formatCurrency(summary.amount, CURRENCY_FORMAT.cents)}\n </Text>\n </Stack>\n </Stack>\n\n {/* Figma Tag: a 20px pill. As a flex container the inline caption becomes a flex item, so its own\n 16px line box (not the pill's inherited line height) sets 2 + 16 + 2, centered. */}\n <Box\n sx={{\n alignItems: 'center',\n bgcolor: (theme) => alpha(theme.palette.primary.main, 0.15),\n borderRadius: '999px',\n display: 'flex',\n px: 12,\n py: 2,\n }}\n >\n <Text color=\"primary.dark\" variant=\"caption\">\n {\n buildPluralCopy(\n copy.transaction_count_one ?? DEFAULT_COUNT_ONE_COPY,\n copy.transaction_count ?? DEFAULT_COUNT_COPY,\n count,\n String(count),\n ) as string\n }\n </Text>\n </Box>\n </Stack>\n </Box>\n )\n}\n\nexport default TransactionListSummaryCard\n"],"mappings":";;;;;;;;;;AAwBA,IAAM,IAAqB,0BACrB,IAAyB,yBAGzB,IAAA,CAAe,GAAc,MACjC,CAAC,GAAO,CAAG,EACR,OAAA,CAAQ,MAAiB,MAAM,MAAS,EACxC,IAAA,CAAK,MAAM,EAAW,GAAG,EAAkB,SAAS,CAAC,EACrD,KAAK,KAAK,GAUF,IAAA,CAA8B,EACzC,SAAA,GACA,OAAA,GACA,MAAA,EAAA,MACqC;AACrC,QAAM,IAAY,EAAY,EAAQ,WAAW,EAAQ,OAAO;AAEhE,SACE,gBAAA,EAAC,GAAD;AAAA,IAAK,IAAI;AAAA,MAAE,IAAI;AAAA,MAAI,IAAI;AAAA,MAAI,IAAI;AAAA,IAAG;AAAA,IAChC,UAAA,gBAAA,EAAC,GAAD;AAAA,MACE,IAAI;AAAA,QACF,SAAS;AAAA,QACT,cAAc;AAAA,QACd,WAAW;AAAA,QACX,KAAK;AAAA,QACL,GAAG;AAAA,MACL;AAAA,MAPF,UAAA,CASE,gBAAA,EAAC,GAAD;AAAA,QAAO,IAAI;AAAA,UAAE,YAAY;AAAA,UAAU,eAAe;AAAA,UAAO,KAAK;AAAA,QAAG;AAAA,QAAjE,UAAA,CACE,gBAAA,EAAC,GAAD,EAA+B,MAAK,UAAW,CAAA,GAC/C,gBAAA,EAAC,GAAD,EAAA,UAAA,CACG,KACC,gBAAA,EAAC,GAAD;AAAA,UAAM,OAAM;AAAA,UAAiB,SAAQ;AAAA,UAClC,UAAA;AAAA,QACG,CAAA,GAER,gBAAA,EAAC,GAAD;AAAA,UAAM,MAAM;AAAA,UAAM,WAAU;AAAA,UAAI,SAAQ;AAAA,UACrC,UAAA,EAAe,EAAQ,QAAQ,EAAgB,KAAK;AAAA,QACjD,CAAA,CACD,EAAA,CAAA,CACF;AAAA,MAIP,CAAA,GAAA,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,SAAS;AAAA,UACT,IAAI;AAAA,UACJ,IAAI;AAAA,QACN;AAAA,QAEA,UAAA,gBAAA,EAAC,GAAD;AAAA,UAAM,OAAM;AAAA,UAAe,SAAQ;AAAA,UAE/B,UAAA,EACE,EAAK,yBAAyB,GAC9B,EAAK,qBAAqB,GAC1B,GACA,OAAO,CAAK,CACd;AAAA,QAEE,CAAA;AAAA,MACH,CAAA,CACA;AAAA;EACJ,CAAA;AAET"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Beat } from '../../core';
|
|
2
|
+
import { OpenedCta } from './util';
|
|
3
|
+
/**
|
|
4
|
+
* The CTA that opened the beat's drawer, re-read from the store's trigger on every render, so a
|
|
5
|
+
* block follows a beat its own edit refreshes. ActionBlockLayer pins its own copy to pick the block
|
|
6
|
+
* and title. Call it from an observer component; the result can be a new object each render, so
|
|
7
|
+
* keep it out of effect and memo dependency lists.
|
|
8
|
+
*/
|
|
9
|
+
export declare const useOpenedCta: (beat: Beat) => OpenedCta;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useInsightsV2Store as n } from "../../common/context/hooks.es.js";
|
|
2
|
+
import { getDynamicCtaBasedOnTriggers as o } from "./util.es.js";
|
|
3
|
+
var p = (r) => {
|
|
4
|
+
const { actionDrawer: t } = n(), { primary_cta: a, secondary_cta: e, in_description_cta: i } = r.insights_payload ?? {};
|
|
5
|
+
return o(t, a, e, i);
|
|
6
|
+
};
|
|
7
|
+
export {
|
|
8
|
+
p as useOpenedCta
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=useOpenedCta.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOpenedCta.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/useOpenedCta.ts"],"sourcesContent":["import { useInsightsV2Store } from '../../common'\nimport type { Beat } from '../../core'\nimport { getDynamicCtaBasedOnTriggers, type OpenedCta } from './util'\n\n/**\n * The CTA that opened the beat's drawer, re-read from the store's trigger on every render, so a\n * block follows a beat its own edit refreshes. ActionBlockLayer pins its own copy to pick the block\n * and title. Call it from an observer component; the result can be a new object each render, so\n * keep it out of effect and memo dependency lists.\n */\nexport const useOpenedCta = (beat: Beat): OpenedCta => {\n const { actionDrawer } = useInsightsV2Store()\n const { primary_cta, secondary_cta, in_description_cta } = beat.insights_payload ?? {}\n\n return getDynamicCtaBasedOnTriggers(actionDrawer, primary_cta, secondary_cta, in_description_cta)\n}\n"],"mappings":";;AAUA,IAAa,IAAA,CAAgB,MAA0B;AACrD,QAAM,EAAE,cAAA,EAAA,IAAiB,EAAmB,GACtC,EAAE,aAAA,GAAa,eAAA,GAAe,oBAAA,EAAA,IAAuB,EAAK,oBAAoB,CAAC;AAErF,SAAO,EAA6B,GAAc,GAAa,GAAe,CAAkB;AAClG"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ActionDrawerState, InDescriptionCTA, PrimaryCTA, SecondaryCTA } from '../../core';
|
|
2
2
|
/** A CTA naming the bar's block wins; else that block with the card's CTA variant; else the secondary CTA. */
|
|
3
3
|
export declare const getCtaForChartBarClick: (actionDrawer: ActionDrawerState, primary_cta: PrimaryCTA | undefined, secondary_cta: SecondaryCTA | undefined) => PrimaryCTA | SecondaryCTA | undefined;
|
|
4
|
+
export type OpenedCta = PrimaryCTA | SecondaryCTA | InDescriptionCTA | undefined;
|
|
4
5
|
/** The CTA driving the open drawer, by trigger; falls back to `primary_cta`. */
|
|
5
|
-
export declare const getDynamicCtaBasedOnTriggers: (actionDrawer: ActionDrawerState, primary_cta: PrimaryCTA | undefined, secondary_cta: SecondaryCTA | undefined, in_description_cta?: InDescriptionCTA) =>
|
|
6
|
+
export declare const getDynamicCtaBasedOnTriggers: (actionDrawer: ActionDrawerState, primary_cta: PrimaryCTA | undefined, secondary_cta: SecondaryCTA | undefined, in_description_cta?: InDescriptionCTA) => OpenedCta;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/util.ts"],"sourcesContent":["import type {\n ActionDrawerState,\n DrilldownPayload,\n InDescriptionCTA,\n PrimaryCTA,\n SecondaryCTA,\n} from '../../core'\nimport { layout as drillDownLayout } from './TransactionHistoryBlock/layout'\n\n/** A CTA naming the bar's block wins; else that block with the card's CTA variant; else the secondary CTA. */\nexport const getCtaForChartBarClick = (\n actionDrawer: ActionDrawerState,\n primary_cta: PrimaryCTA | undefined,\n secondary_cta: SecondaryCTA | undefined,\n): PrimaryCTA | SecondaryCTA | undefined => {\n const context = actionDrawer.context as DrilldownPayload | undefined\n const blockName = context?.block\n\n if (blockName === primary_cta?.block) {\n return primary_cta\n }\n // Category Spending with a budget: no CTA names Spending History, so the bar opens it with the\n // primary CTA's variant when that is a Spending History view (`category_spend`).\n const variant = primary_cta?.variant\n if (\n blockName &&\n blockName !== secondary_cta?.block &&\n variant &&\n Object.hasOwn(drillDownLayout, variant)\n ) {\n return { label: '', block: blockName, variant }\n }\n return secondary_cta\n}\n\n/** The CTA driving the open drawer, by trigger; falls back to `primary_cta`. */\nexport const getDynamicCtaBasedOnTriggers = (\n actionDrawer: ActionDrawerState,\n primary_cta: PrimaryCTA | undefined,\n secondary_cta: SecondaryCTA | undefined,\n in_description_cta?: InDescriptionCTA,\n):
|
|
1
|
+
{"version":3,"file":"util.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/util.ts"],"sourcesContent":["import type {\n ActionDrawerState,\n DrilldownPayload,\n InDescriptionCTA,\n PrimaryCTA,\n SecondaryCTA,\n} from '../../core'\nimport { layout as drillDownLayout } from './TransactionHistoryBlock/layout'\n\n/** A CTA naming the bar's block wins; else that block with the card's CTA variant; else the secondary CTA. */\nexport const getCtaForChartBarClick = (\n actionDrawer: ActionDrawerState,\n primary_cta: PrimaryCTA | undefined,\n secondary_cta: SecondaryCTA | undefined,\n): PrimaryCTA | SecondaryCTA | undefined => {\n const context = actionDrawer.context as DrilldownPayload | undefined\n const blockName = context?.block\n\n if (blockName === primary_cta?.block) {\n return primary_cta\n }\n // Category Spending with a budget: no CTA names Spending History, so the bar opens it with the\n // primary CTA's variant when that is a Spending History view (`category_spend`).\n const variant = primary_cta?.variant\n if (\n blockName &&\n blockName !== secondary_cta?.block &&\n variant &&\n Object.hasOwn(drillDownLayout, variant)\n ) {\n return { label: '', block: blockName, variant }\n }\n return secondary_cta\n}\n\nexport type OpenedCta = PrimaryCTA | SecondaryCTA | InDescriptionCTA | undefined\n\n/** The CTA driving the open drawer, by trigger; falls back to `primary_cta`. */\nexport const getDynamicCtaBasedOnTriggers = (\n actionDrawer: ActionDrawerState,\n primary_cta: PrimaryCTA | undefined,\n secondary_cta: SecondaryCTA | undefined,\n in_description_cta?: InDescriptionCTA,\n): OpenedCta => {\n // The opener's block and variant, else the beat's link.\n if (actionDrawer.trigger === 'inDescriptionCta') {\n if (!actionDrawer.cta) return in_description_cta\n const { drilldown_data } = in_description_cta ?? {}\n return { label: '', ...(drilldown_data && { drilldown_data }), ...actionDrawer.cta }\n }\n if (actionDrawer.trigger === 'secondaryCta') {\n return secondary_cta ?? primary_cta\n }\n if (actionDrawer.trigger === 'primaryCta') {\n return primary_cta\n }\n return getCtaForChartBarClick(actionDrawer, primary_cta, secondary_cta) ?? primary_cta\n}\n"],"mappings":";AAUA,IAAa,IAAA,CACX,GACA,GACA,MAC0C;AAE1C,QAAM,IADU,EAAa,SACF;AAE3B,MAAI,MAAc,GAAa,MAC7B,QAAO;AAIT,QAAM,IAAU,GAAa;AAC7B,SACE,KACA,MAAc,GAAe,SAC7B,KACA,OAAO,OAAO,GAAiB,CAAO,IAE/B;AAAA,IAAE,OAAO;AAAA,IAAI,OAAO;AAAA,IAAW,SAAA;AAAA,EAAQ,IAEzC;AACT,GAKa,IAAA,CACX,GACA,GACA,GACA,MACc;AAEd,MAAI,EAAa,YAAY,oBAAoB;AAC/C,QAAI,CAAC,EAAa,IAAK,QAAO;AAC9B,UAAM,EAAE,gBAAA,EAAA,IAAmB,KAAsB,CAAC;AAClD,WAAO;AAAA,MAAE,OAAO;AAAA,MAAI,GAAI,KAAkB,EAAE,gBAAA,EAAe;AAAA,MAAI,GAAG,EAAa;AAAA,IAAI;AAAA,EACrF;AACA,SAAI,EAAa,YAAY,iBACpB,KAAiB,IAEtB,EAAa,YAAY,eACpB,IAEF,EAAuB,GAAc,GAAa,CAAa,KAAK;AAC7E"}
|
|
@@ -7,18 +7,18 @@ import b, { isLogoGuid as y } from "../../../components/LogoFromGuid.es.js";
|
|
|
7
7
|
import B from "../../../components/LogoClusterCard.es.js";
|
|
8
8
|
import M from "../../../components/MerchantHighlightCard.es.js";
|
|
9
9
|
import N from "../../../components/P2PLogoStack.es.js";
|
|
10
|
-
import { MERCHANT_LAYOUT as
|
|
11
|
-
import
|
|
10
|
+
import { MERCHANT_LAYOUT as P, merchantBlockVariant as T } from "./layout.es.js";
|
|
11
|
+
import V from "@mui/material/Stack";
|
|
12
12
|
import { Icon as _ } from "@mxenabled/mx-icons";
|
|
13
13
|
import { jsx as e } from "react/jsx-runtime";
|
|
14
|
-
var u = 64,
|
|
14
|
+
var u = 64, p = 6, w = 72, z = 3, F = [
|
|
15
15
|
10,
|
|
16
16
|
20,
|
|
17
17
|
35
|
|
18
|
-
],
|
|
18
|
+
], G = 32, g = (a) => {
|
|
19
19
|
const r = E(a);
|
|
20
20
|
return r?.guid && y(r.guid) ? r : void 0;
|
|
21
|
-
},
|
|
21
|
+
}, I = (a) => {
|
|
22
22
|
if (!Array.isArray(a)) return [];
|
|
23
23
|
const r = /* @__PURE__ */ new Map();
|
|
24
24
|
for (const t of a.map(g)) t?.guid && !r.has(t.guid) && r.set(t.guid, t);
|
|
@@ -27,13 +27,13 @@ var u = 64, k = 6, F = 72, G = 3, I = [
|
|
|
27
27
|
"aria-hidden": !0,
|
|
28
28
|
"data-icon": "storefront",
|
|
29
29
|
name: "storefront",
|
|
30
|
-
size:
|
|
30
|
+
size: G,
|
|
31
31
|
sx: { color: "text.secondary" }
|
|
32
|
-
}),
|
|
32
|
+
}), k = (a, r) => a.length ? a.map((t) => /* @__PURE__ */ e(b, {
|
|
33
33
|
logo: t,
|
|
34
34
|
size: r
|
|
35
35
|
}, t.guid)) : [C], oo = ({ payload: a }) => {
|
|
36
|
-
const { instance_slot: r } = a, { data: t } = r, o = A(
|
|
36
|
+
const { instance_slot: r } = a, { data: t } = r, o = A(P, r.variant, T.SingleStandard, "MerchantBlock"), m = i(d(r, "status_text")), f = o.status && m ? /* @__PURE__ */ e(x, {
|
|
37
37
|
icon: /* @__PURE__ */ e(_, {
|
|
38
38
|
"aria-hidden": !0,
|
|
39
39
|
"data-icon": "check_circle",
|
|
@@ -49,15 +49,15 @@ var u = 64, k = 6, F = 72, G = 3, I = [
|
|
|
49
49
|
}
|
|
50
50
|
}) : void 0;
|
|
51
51
|
if (o.kind !== "single") {
|
|
52
|
-
const c =
|
|
52
|
+
const c = I(n(t, "logos"));
|
|
53
53
|
return o.kind === "ranked" && c.length ? /* @__PURE__ */ e(B, {
|
|
54
54
|
background: o.background,
|
|
55
55
|
fullBleed: !0,
|
|
56
|
-
logos:
|
|
57
|
-
overlap:
|
|
58
|
-
rankOffsets:
|
|
56
|
+
logos: k(c.slice(0, z), w),
|
|
57
|
+
overlap: p,
|
|
58
|
+
rankOffsets: F,
|
|
59
59
|
ranked: !0
|
|
60
|
-
}) : /* @__PURE__ */ e(
|
|
60
|
+
}) : /* @__PURE__ */ e(V, {
|
|
61
61
|
sx: {
|
|
62
62
|
background: o.background,
|
|
63
63
|
bgcolor: o.background ? void 0 : o.bgcolor,
|
|
@@ -66,8 +66,8 @@ var u = 64, k = 6, F = 72, G = 3, I = [
|
|
|
66
66
|
},
|
|
67
67
|
children: /* @__PURE__ */ e(N, {
|
|
68
68
|
borderColor: null,
|
|
69
|
-
logos:
|
|
70
|
-
overlap:
|
|
69
|
+
logos: k(c, u),
|
|
70
|
+
overlap: p,
|
|
71
71
|
shadow: "elevation",
|
|
72
72
|
size: u,
|
|
73
73
|
status: f
|
|
@@ -83,12 +83,14 @@ var u = 64, k = 6, F = 72, G = 3, I = [
|
|
|
83
83
|
}), v = o.logo?.size ?? u;
|
|
84
84
|
return /* @__PURE__ */ e(M, {
|
|
85
85
|
amount: s !== void 0 && s !== 0 ? S(s, O.cents) : void 0,
|
|
86
|
+
amountPill: o.amountPill,
|
|
86
87
|
amountVariant: o.amountVariant,
|
|
87
88
|
background: o.background,
|
|
88
89
|
bgcolor: o.bgcolor,
|
|
89
90
|
borderColor: o.borderColor,
|
|
90
91
|
eyebrow: o.hideDate ? void 0 : L,
|
|
91
92
|
fullBleed: o.fullBleed,
|
|
93
|
+
gap: o.gap,
|
|
92
94
|
logo: h ? /* @__PURE__ */ e(b, {
|
|
93
95
|
logo: h,
|
|
94
96
|
size: v
|
|
@@ -98,6 +100,7 @@ var u = 64, k = 6, F = 72, G = 3, I = [
|
|
|
98
100
|
logoShadow: o.logo?.shadow,
|
|
99
101
|
logoSize: v,
|
|
100
102
|
name: l,
|
|
103
|
+
nameVariant: o.nameVariant,
|
|
101
104
|
trailing: f
|
|
102
105
|
});
|
|
103
106
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MerchantBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.tsx"],"sourcesContent":["import Stack from '@mui/material/Stack'\n\nimport { Icon } from '@mxenabled/mx-icons'\n\nimport { slot, type InsightsPayload, type LogoRef } from '../../../../core'\nimport type { MerchantBlockData } from '../../../../core/types/InsightsInstanceSlotData'\nimport { CURRENCY_FORMAT, formatCurrency } from '../../../../core/utils/NumberFormatting'\n\nimport LogoClusterCard from '../../../components/LogoClusterCard'\nimport LogoFromGuid, { isLogoGuid } from '../../../components/LogoFromGuid'\nimport MerchantHighlightCard from '../../../components/MerchantHighlightCard'\nimport P2PLogoStack from '../../../components/P2PLogoStack'\nimport StatusPill from '../../../components/StatusPill'\nimport { resolveVariantConfig } from '../../resolveVariantConfig'\nimport { asLogoRef, asNumber, asText, slotOrFlat } from '../../slotReaders'\n\nimport { MERCHANT_LAYOUT, merchantBlockVariant } from './layout'\n\ninterface MerchantBlockProps {\n payload: InsightsPayload\n}\n\nconst LOGO_SIZE = 64\nconst LOGO_OVERLAP = 6\nconst RANKED_LOGO_SIZE = 72\nconst RANKED_MAX = 3\nconst RANKED_OFFSETS = [10, 20, 35] as const\nconst FALLBACK_ICON_SIZE = 32\n\n/** A logo ref naming a known logo guid, else undefined, so an unusable one falls through. */\nconst asMerchantLogo = (value: unknown): LogoRef | undefined => {\n const ref = asLogoRef(value)\n return ref?.guid && isLogoGuid(ref.guid) ? ref : undefined\n}\n\nconst uniqueLogos = (refs: unknown): LogoRef[] => {\n if (!Array.isArray(refs)) return []\n const byGuid = new Map<string, LogoRef>()\n for (const ref of refs.map(asMerchantLogo)) {\n if (ref?.guid && !byGuid.has(ref.guid)) byGuid.set(ref.guid, ref)\n }\n return [...byGuid.values()]\n}\n\nconst storefront = (\n <Icon\n aria-hidden={true}\n data-icon=\"storefront\"\n name=\"storefront\"\n size={FALLBACK_ICON_SIZE}\n sx={{ color: 'text.secondary' }}\n />\n)\n\nconst logoTiles = (refs: LogoRef[], size: number) =>\n refs.length\n ? refs.map((ref) => <LogoFromGuid key={ref.guid} logo={ref} size={size} />)\n : [storefront]\n\nconst MerchantBlock = ({ payload }: MerchantBlockProps) => {\n const { instance_slot } = payload\n const { data } = instance_slot\n const config = resolveVariantConfig(\n MERCHANT_LAYOUT,\n instance_slot.variant,\n merchantBlockVariant.SingleStandard,\n 'MerchantBlock',\n )\n const statusText = asText(slotOrFlat(instance_slot, 'status_text'))\n const statusPill =\n config.status && statusText ? (\n <StatusPill\n icon={\n <Icon\n aria-hidden={true}\n data-icon=\"check_circle\"\n fill={true}\n name=\"check_circle\"\n size={16}\n sx={{ color: 'success.700' }}\n />\n }\n label={statusText}\n sx={\n config.kind === 'single' ? undefined : { alignSelf: 'stretch', justifyContent: 'center' }\n }\n />\n ) : undefined\n\n if (config.kind !== 'single') {\n const logos = uniqueLogos(slot<MerchantBlockData['logos']>(data, 'logos'))\n\n if (config.kind === 'ranked' && logos.length) {\n return (\n <LogoClusterCard\n background={config.background}\n fullBleed={true}\n logos={logoTiles(logos.slice(0, RANKED_MAX), RANKED_LOGO_SIZE)}\n overlap={LOGO_OVERLAP}\n rankOffsets={RANKED_OFFSETS}\n ranked={true}\n />\n )\n }\n\n return (\n <Stack\n sx={{\n background: config.background,\n bgcolor: config.background ? undefined : config.bgcolor,\n p: 16,\n width: '100%',\n }}\n >\n <P2PLogoStack\n borderColor={null}\n logos={logoTiles(logos, LOGO_SIZE)}\n overlap={LOGO_OVERLAP}\n shadow=\"elevation\"\n size={LOGO_SIZE}\n status={statusPill}\n />\n </Stack>\n )\n }\n\n // ditto's slot names first.\n const merchantName =\n asText(slot(data, 'primary_text')) || asText(slotOrFlat(instance_slot, 'merchant_name'))\n if (!merchantName) return null\n\n const amount = asNumber(slotOrFlat(instance_slot, 'amount'))\n const date = asText(slot(data, 'header_text')) || asText(slot(data, 'date'))\n const logo =\n asMerchantLogo(slot<unknown>(data, 'logo')) ??\n asMerchantLogo({\n alt: merchantName,\n fallback_guid: instance_slot.category_guid,\n guid: instance_slot.merchant_guid,\n })\n const logoSize = config.logo?.size ?? LOGO_SIZE\n\n return (\n <MerchantHighlightCard\n amount={\n amount !== undefined && amount !== 0\n ? formatCurrency(amount, CURRENCY_FORMAT.cents)\n : undefined\n }\n amountVariant={config.amountVariant}\n background={config.background}\n bgcolor={config.bgcolor}\n borderColor={config.borderColor}\n eyebrow={config.hideDate ? undefined : date}\n fullBleed={config.fullBleed}\n logo={logo ? <LogoFromGuid logo={logo} size={logoSize} /> : storefront}\n logoBorderColor={config.logo?.borderColor}\n logoRadius={config.logo?.radius}\n logoShadow={config.logo?.shadow}\n logoSize={logoSize}\n name={merchantName}\n trailing={statusPill}\n />\n )\n}\n\nexport default MerchantBlock\n"],"mappings":";;;;;;;;;;;;;AAsBA,IAAM,IAAY,IACZ,IAAe,GACf,IAAmB,IACnB,IAAa,GACb,IAAiB;AAAA,EAAC;AAAA,EAAI;AAAA,EAAI;AAAE,GAC5B,IAAqB,IAGrB,IAAA,CAAkB,MAAwC;AAC9D,QAAM,IAAM,EAAU,CAAK;AAC3B,SAAO,GAAK,QAAQ,EAAW,EAAI,IAAI,IAAI,IAAM;AACnD,GAEM,IAAA,CAAe,MAA6B;AAChD,MAAI,CAAC,MAAM,QAAQ,CAAI,EAAG,QAAO,CAAC;AAClC,QAAM,IAAS,oBAAI,IAAqB;AACxC,aAAW,KAAO,EAAK,IAAI,CAAc,EACvC,CAAI,GAAK,QAAQ,CAAC,EAAO,IAAI,EAAI,IAAI,KAAG,EAAO,IAAI,EAAI,MAAM,CAAG;AAElE,SAAO,CAAC,GAAG,EAAO,OAAO,CAAC;AAC5B,GAEM,IACJ,gBAAA,EAAC,GAAD;AAAA,EACE,eAAa;AAAA,EACb,aAAU;AAAA,EACV,MAAK;AAAA,EACL,MAAM;AAAA,EACN,IAAI,EAAE,OAAO,iBAAiB;AAC/B,CAAA,GAGG,IAAA,CAAa,GAAiB,MAClC,EAAK,SACD,EAAK,IAAA,CAAK,MAAQ,gBAAA,EAAC,GAAD;AAAA,EAA6B,MAAM;AAAA,EAAW,MAAA;AAAO,GAAlC,EAAI,IAA8B,CAAC,IACxE,CAAC,CAAU,GAEX,KAAA,CAAiB,EAAE,SAAA,EAAA,MAAkC;AACzD,QAAM,EAAE,eAAA,EAAA,IAAkB,GACpB,EAAE,MAAA,EAAA,IAAS,GACX,IAAS,EACb,GACA,EAAc,SACd,EAAqB,gBACrB,eACF,GACM,IAAa,EAAO,EAAW,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AK,GAAM,aAAa,CAAC,KAAK,EAAO,EAAK,GAAM,MAAM,CAAC,GACrE,IACJ,EAAe,EAAc,GAAM,MAAM,CAAC,KAC1C,EAAe;AAAA,IACb,KAAK;AAAA,IACL,eAAe,EAAc;AAAA,IAC7B,MAAM,EAAc;AAAA,EACtB,CAAC,GACG,IAAW,EAAO,MAAM,QAAQ;AAEtC,SACE,gBAAA,EAAC,GAAD;AAAA,IACE,QACE,MAAW,UAAa,MAAW,IAC/B,EAAe,GAAQ,EAAgB,KAAK,IAC5C;AAAA,IAEN,eAAe,EAAO;AAAA,IACtB,YAAY,EAAO;AAAA,IACnB,SAAS,EAAO;AAAA,IAChB,aAAa,EAAO;AAAA,IACpB,SAAS,EAAO,WAAW,SAAY;AAAA,IACvC,WAAW,EAAO;AAAA,IAClB,MAAM,IAAO,gBAAA,EAAC,GAAD;AAAA,MAAoB,MAAA;AAAA,MAAM,MAAM;AAAA,IAAW,CAAA,IAAI;AAAA,IAC5D,iBAAiB,EAAO,MAAM;AAAA,IAC9B,YAAY,EAAO,MAAM;AAAA,IACzB,YAAY,EAAO,MAAM;AAAA,IACf,UAAA;AAAA,IACV,MAAM;AAAA,IACN,UAAU;AAAA,EACX,CAAA;AAEL"}
|
|
1
|
+
{"version":3,"file":"MerchantBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.tsx"],"sourcesContent":["import Stack from '@mui/material/Stack'\n\nimport { Icon } from '@mxenabled/mx-icons'\n\nimport { slot, type InsightsPayload, type LogoRef } from '../../../../core'\nimport type { MerchantBlockData } from '../../../../core/types/InsightsInstanceSlotData'\nimport { CURRENCY_FORMAT, formatCurrency } from '../../../../core/utils/NumberFormatting'\n\nimport LogoClusterCard from '../../../components/LogoClusterCard'\nimport LogoFromGuid, { isLogoGuid } from '../../../components/LogoFromGuid'\nimport MerchantHighlightCard from '../../../components/MerchantHighlightCard'\nimport P2PLogoStack from '../../../components/P2PLogoStack'\nimport StatusPill from '../../../components/StatusPill'\nimport { resolveVariantConfig } from '../../resolveVariantConfig'\nimport { asLogoRef, asNumber, asText, slotOrFlat } from '../../slotReaders'\n\nimport { MERCHANT_LAYOUT, merchantBlockVariant } from './layout'\n\ninterface MerchantBlockProps {\n payload: InsightsPayload\n}\n\nconst LOGO_SIZE = 64\nconst LOGO_OVERLAP = 6\nconst RANKED_LOGO_SIZE = 72\nconst RANKED_MAX = 3\nconst RANKED_OFFSETS = [10, 20, 35] as const\nconst FALLBACK_ICON_SIZE = 32\n\n/** A logo ref naming a known logo guid, else undefined, so an unusable one falls through. */\nconst asMerchantLogo = (value: unknown): LogoRef | undefined => {\n const ref = asLogoRef(value)\n return ref?.guid && isLogoGuid(ref.guid) ? ref : undefined\n}\n\nconst uniqueLogos = (refs: unknown): LogoRef[] => {\n if (!Array.isArray(refs)) return []\n const byGuid = new Map<string, LogoRef>()\n for (const ref of refs.map(asMerchantLogo)) {\n if (ref?.guid && !byGuid.has(ref.guid)) byGuid.set(ref.guid, ref)\n }\n return [...byGuid.values()]\n}\n\nconst storefront = (\n <Icon\n aria-hidden={true}\n data-icon=\"storefront\"\n name=\"storefront\"\n size={FALLBACK_ICON_SIZE}\n sx={{ color: 'text.secondary' }}\n />\n)\n\nconst logoTiles = (refs: LogoRef[], size: number) =>\n refs.length\n ? refs.map((ref) => <LogoFromGuid key={ref.guid} logo={ref} size={size} />)\n : [storefront]\n\nconst MerchantBlock = ({ payload }: MerchantBlockProps) => {\n const { instance_slot } = payload\n const { data } = instance_slot\n const config = resolveVariantConfig(\n MERCHANT_LAYOUT,\n instance_slot.variant,\n merchantBlockVariant.SingleStandard,\n 'MerchantBlock',\n )\n const statusText = asText(slotOrFlat(instance_slot, 'status_text'))\n const statusPill =\n config.status && statusText ? (\n <StatusPill\n icon={\n <Icon\n aria-hidden={true}\n data-icon=\"check_circle\"\n fill={true}\n name=\"check_circle\"\n size={16}\n sx={{ color: 'success.700' }}\n />\n }\n label={statusText}\n sx={\n config.kind === 'single' ? undefined : { alignSelf: 'stretch', justifyContent: 'center' }\n }\n />\n ) : undefined\n\n if (config.kind !== 'single') {\n const logos = uniqueLogos(slot<MerchantBlockData['logos']>(data, 'logos'))\n\n if (config.kind === 'ranked' && logos.length) {\n return (\n <LogoClusterCard\n background={config.background}\n fullBleed={true}\n logos={logoTiles(logos.slice(0, RANKED_MAX), RANKED_LOGO_SIZE)}\n overlap={LOGO_OVERLAP}\n rankOffsets={RANKED_OFFSETS}\n ranked={true}\n />\n )\n }\n\n return (\n <Stack\n sx={{\n background: config.background,\n bgcolor: config.background ? undefined : config.bgcolor,\n p: 16,\n width: '100%',\n }}\n >\n <P2PLogoStack\n borderColor={null}\n logos={logoTiles(logos, LOGO_SIZE)}\n overlap={LOGO_OVERLAP}\n shadow=\"elevation\"\n size={LOGO_SIZE}\n status={statusPill}\n />\n </Stack>\n )\n }\n\n // ditto's slot names first.\n const merchantName =\n asText(slot(data, 'primary_text')) || asText(slotOrFlat(instance_slot, 'merchant_name'))\n if (!merchantName) return null\n\n const amount = asNumber(slotOrFlat(instance_slot, 'amount'))\n const date = asText(slot(data, 'header_text')) || asText(slot(data, 'date'))\n const logo =\n asMerchantLogo(slot<unknown>(data, 'logo')) ??\n asMerchantLogo({\n alt: merchantName,\n fallback_guid: instance_slot.category_guid,\n guid: instance_slot.merchant_guid,\n })\n const logoSize = config.logo?.size ?? LOGO_SIZE\n\n return (\n <MerchantHighlightCard\n amount={\n amount !== undefined && amount !== 0\n ? formatCurrency(amount, CURRENCY_FORMAT.cents)\n : undefined\n }\n amountPill={config.amountPill}\n amountVariant={config.amountVariant}\n background={config.background}\n bgcolor={config.bgcolor}\n borderColor={config.borderColor}\n eyebrow={config.hideDate ? undefined : date}\n fullBleed={config.fullBleed}\n gap={config.gap}\n logo={logo ? <LogoFromGuid logo={logo} size={logoSize} /> : storefront}\n logoBorderColor={config.logo?.borderColor}\n logoRadius={config.logo?.radius}\n logoShadow={config.logo?.shadow}\n logoSize={logoSize}\n name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CAAC,KAC1C,EAAe;AAAA,IACb,KAAK;AAAA,IACL,eAAe,EAAc;AAAA,IAC7B,MAAM,EAAc;AAAA,EACtB,CAAC,GACG,IAAW,EAAO,MAAM,QAAQ;AAEtC,SACE,gBAAA,EAAC,GAAD;AAAA,IACE,QACE,MAAW,UAAa,MAAW,IAC/B,EAAe,GAAQ,EAAgB,KAAK,IAC5C;AAAA,IAEN,YAAY,EAAO;AAAA,IACnB,eAAe,EAAO;AAAA,IACtB,YAAY,EAAO;AAAA,IACnB,SAAS,EAAO;AAAA,IAChB,aAAa,EAAO;AAAA,IACpB,SAAS,EAAO,WAAW,SAAY;AAAA,IACvC,WAAW,EAAO;AAAA,IAClB,KAAK,EAAO;AAAA,IACZ,MAAM,IAAO,gBAAA,EAAC,GAAD;AAAA,MAAoB,MAAA;AAAA,MAAM,MAAM;AAAA,IAAW,CAAA,IAAI;AAAA,IAC5D,iBAAiB,EAAO,MAAM;AAAA,IAC9B,YAAY,EAAO,MAAM;AAAA,IACzB,YAAY,EAAO,MAAM;AAAA,IACf,UAAA;AAAA,IACV,MAAM;AAAA,IACN,aAAa,EAAO;AAAA,IACpB,UAAU;AAAA,EACX,CAAA;AAEL"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AmountPillProps } from '../../../components/AmountPill';
|
|
1
2
|
/** ditto declares only `highlight` today. */
|
|
2
3
|
export declare const merchantBlockVariant: {
|
|
3
4
|
readonly Highlight: "highlight";
|
|
@@ -14,6 +15,12 @@ export interface MerchantBlockLayoutConfig {
|
|
|
14
15
|
/** Merchant card, logo cascade, or ranked logos. */
|
|
15
16
|
kind: 'single' | 'cascade' | 'ranked';
|
|
16
17
|
amountVariant?: 'pill' | 'text';
|
|
18
|
+
/** The amount pill's horizontal padding and text weight. */
|
|
19
|
+
amountPill?: Pick<AmountPillProps, 'px' | 'fontWeight'>;
|
|
20
|
+
/** Gap between the logo and the text column. */
|
|
21
|
+
gap?: number;
|
|
22
|
+
/** The merchant name's type; the card defaults to h2 beside a pill. */
|
|
23
|
+
nameVariant?: 'h2' | 'h3';
|
|
17
24
|
/** A wash; replaces `bgcolor`. */
|
|
18
25
|
background?: string;
|
|
19
26
|
bgcolor?: string;
|