@mx-cartographer/experiences 9.7.149 → 9.7.151
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 +13 -0
- package/dist/core/types/Insights.d.ts +0 -6
- package/dist/core/types/Insights.es.js.map +1 -1
- package/dist/core/types/localization/InsightsFeedCopy.d.ts +10 -7
- package/dist/core/utils/NumberFormatting.d.ts +2 -0
- package/dist/core/utils/NumberFormatting.es.js +18 -17
- package/dist/core/utils/NumberFormatting.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/MakeTransferActionBlock.es.js +57 -57
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/MakeTransferActionBlock.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/SavingsSummaryBlock/SavingsSummaryBlock.es.js +24 -25
- package/dist/insights-v2/blocks/ComponentBlocks/SavingsSummaryBlock/SavingsSummaryBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js +4 -4
- package/dist/insights-v2/index.d.ts +0 -1
- package/dist/insights-v2/index.es.js +104 -106
- package/dist/insights-v2/mappings/blocks.es.js +1 -0
- package/dist/insights-v2/mappings/blocks.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
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
## [9.7.151] - 11-13-2026
|
|
2
|
+
|
|
3
|
+
- Debt Payment Reminder | DebtsBlock is the payment reminder card only (WEC-2307)
|
|
4
|
+
|
|
5
|
+
## [9.7.150] - 11-13-2026
|
|
6
|
+
|
|
7
|
+
- **ADDED** - `formatWholeCurrency` in core utils: whole-dollar currency that rounds first, so a small negative shows "$0" (WEC-2273)
|
|
8
|
+
- **CHANGED** - `MakeTransferCopy` requires `available_balance_text` and `avg_monthly_spend_text` (WEC-2273)
|
|
9
|
+
- **FIXED** - Save Enough to Live On and Save an Extra $100 drawers show a close button on the right, as in Figma (WEC-2273)
|
|
10
|
+
- **FIXED** - Save Enough to Live On and Save an Extra $100 drawers show whole-dollar amounts, and the months rows match the stepper amount shown (WEC-2273)
|
|
11
|
+
- **FIXED** - Save Enough to Live On card and drawer spacing match Figma: the card's table and content height, and the months rows in the Save Enough and Save an Extra $100 drawers (WEC-2273)
|
|
12
|
+
- **FIXED** - Save Enough to Live On card and drawer label the table "Available Balance" and "Avg. Monthly Spend"; they need firefly to serve the new copy (mrs_content !521), so pulse bumps only after that (WEC-2273)
|
|
13
|
+
|
|
1
14
|
## [9.7.149] - 11-13-2026
|
|
2
15
|
|
|
3
16
|
- **FIXED** - `SVGImageBlock` keys the Upcoming Tax Deadline Alert illustration under `reminder` (was `remainder`), the variant ditto emits, so the card shows its own art instead of the savings illustration; this reverses the key named in 9.7.33 (WEC-2044, WEC-2067)
|
|
@@ -361,12 +361,6 @@ export interface InstanceSlot {
|
|
|
361
361
|
icon_name?: string;
|
|
362
362
|
/** Category guid used to render the deposit-card logo fallback. */
|
|
363
363
|
category_guid?: string;
|
|
364
|
-
/** Projected payoff date in ISO form (e.g. `2027-03-01`); the block formats it as month + year. */
|
|
365
|
-
payoff_date?: string;
|
|
366
|
-
/** Monthly payment toward the debt (unformatted); the block formats it as currency. */
|
|
367
|
-
monthly_payment?: number;
|
|
368
|
-
/** Annual interest rate as a percentage (e.g. `19.99`); the block formats it as a percent. */
|
|
369
|
-
interest_rate?: number;
|
|
370
364
|
start_date?: string;
|
|
371
365
|
no_spend_days?: string[];
|
|
372
366
|
/** First day of the month a monthly summary covers, in ISO form (e.g. `2026-09-01`). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Insights.es.js","names":[],"sources":["../../../src/core/types/Insights.ts"],"sourcesContent":["// ============ Core InsightsV2 Types ============\n\nimport type { DataSeries } from './Beat'\nimport { InsightsInstanceSlotData } from './InsightsInstanceSlotData'\n\nexport interface ThemedSVGImageProps {\n divProps?: React.HTMLAttributes<HTMLDivElement>\n image: React.ComponentType<React.SVGProps<SVGSVGElement>>\n isMini?: boolean\n}\n\n/**\n * Emitted by a block when the user drills into a specific datum (e.g. clicks a\n * chart bar). Named fields rather than positional args so blocks with differing\n * shapes can extend this without the call sites transposing values.\n */\nexport interface DrilldownPayload {\n chartBarIndex: number\n tabIndex?: number\n transaction_guid?: string\n block?: string\n}\n\n/**\n * Which envelope a beat was fetched with. `embedded` (the transaction-row pill + details-drawer\n * card) and `notification` are V2 additions; a surface asks for one with `widget_type=` on the fetch.\n */\nexport type WidgetType = 'full' | 'mini' | 'micro' | 'embedded' | 'notification'\n\n/**\n * V2: the transaction-row tag, its own small section of the `embedded` envelope (the same grammar\n * as `description` / `footer`, with room for a tone or an icon later). Omitted for an insight that\n * tags no transaction row. It deliberately is *not* `short_title`, which stays a per-variant\n * attribute with a second consumer (the bank-holiday sub-header).\n */\nexport interface Pill {\n text: string\n}\n\n/**\n * V2: facts a drilldown shows that the card does not. On the payload: what every CTA of the card\n * shares (e.g. the account number for the Transaction Details drawer, or the guid list a list drawer\n * shows, `transaction_guids`). On a CTA: the figures that CTA's own drilldown renders (the Transaction\n * List summary header's `amount`, `start_date` / `end_date` and `count`, see `readSummary`). Scalars,\n * string lists or a `data_series` (the months a history drawer charts), omitted when the insight has\n * none. Never carries copy or user actions (memo, tags, hide, flag come from the transaction store).\n * Values come from the server, so a reader still checks each value's runtime shape.\n */\nexport type DrilldownData = Record<string, string | number | boolean | null | string[] | DataSeries>\n\nexport interface InsightsPayload {\n widget_type: WidgetType\n instance_slot: InstanceSlot\n /**\n * V1 only. The v2 contract carries everything a block needs on `instance_slot.data`,\n * and omits this key entirely (see the LargeTransactionV2 payload). Blocks that still require it\n * get it as a required field through `BlockProps`, which re-declares it.\n */\n instance_slot_data?: InsightsInstanceSlotData\n description: Description\n primary_cta?: PrimaryCTA\n secondary_cta?: SecondaryCTA\n title?: string\n sub_title?: Subtitle\n /**\n * V2 rename of `sub_title`: a flat string, with the logo promoted to the payload-level `logo`\n * field below. `sub_title` wins when both are present.\n */\n subtitle?: string\n /** V2: header logo paired with the flat `subtitle`: an entity guid or a status icon (`LogoRef`). */\n logo?: LogoRef\n /** V2: which design branch the backend picked (e.g. `no_merchant`). */\n variant?: string\n /** V2, `embedded` envelope only: the transaction-row pill. */\n pill?: Pill\n /**\n * V2: drilldown-only facts, e.g. `{ account_number: 'XXXXXXXX043' }`, or the guid list a list\n * drawer shows (`{ transaction_guids: [...] }`).\n */\n drilldown_data?: DrilldownData\n footer?: Footer\n /**\n * V2: the link inside the description: on the full card a drawer of its own (Low Account\n * Balance's \"Transactions ›\"); on mini and micro the card's action, sent instead of `primary_cta`.\n * Absent when the beat has no link.\n */\n in_description_cta?: InDescriptionCTA\n guid: string\n user_guid: string\n client_guid?: string\n /** Template name, e.g. `LargeTransactionV2`. */\n template?: string\n revision?: number\n /** Unix seconds. */\n created_at?: number\n /** Unix seconds. */\n updated_at?: number\n /** Unix seconds. */\n active_at?: number\n displayed_at?: number | null\n dismissed_at: number | null\n cta_clicked_at?: number | null\n has_been_displayed?: boolean\n is_dismissed: boolean\n is_deleted?: boolean\n is_hidden_by_system?: boolean\n is_obsolete?: boolean\n is_refreshable?: boolean\n is_sampled?: boolean\n is_zero_state?: boolean\n status?: string | null\n /**\n * V2 (LargeTransactionV2 onward): the entities the beat is about, carried on the payload so\n * action blocks do not have to reach back out to the beat envelope.\n */\n primary_account_guid?: string | null\n primary_transaction_guid?: string | null\n primary_category_guid?: string | null\n primary_merchant_guid?: string | null\n /**\n * V2: the repeating transaction a subscription beat is about (Upcoming Subscription, Subscription\n * Price Increase). Read by `recurring_transaction_block`, see\n * `actionBlocks/RecurringTransactionBlock/subscriptionBeats.ts`.\n */\n primary_repeating_transaction_guid?: string | null\n}\n\nexport interface Legends {\n label: string\n value: number\n additional_value?: number\n additional_value_type?: string\n value_type?: string\n}\n\nexport interface Logo {\n category_guid?: string\n category_name?: string\n institution_guid?: string\n institution_name?: string\n logo_color?: string\n /** Draw the `logo_name` icon filled (V2 `ICO-` logos). */\n logo_fill?: boolean\n logo_name?: string\n merchant_guid?: string\n merchant_name?: string\n}\n\nexport interface Subtitle {\n logo?: Logo\n text: string\n}\n\n/**\n * A V2 logo, shared by the header (`InsightsPayload.logo`) and every instance-slot row. It takes\n * one of two shapes:\n *\n * - **Entity**: `guid`, whose prefix (`INS-` / `MCH-` / `CAT-`) picks the logo component, plus an\n * optional `fallback_guid` for when that component's asset cannot load. Today that is the\n * category behind an `MCH-` guid, which `MerchantLogo` shows as a tile when the merchant image\n * is missing.\n * - **Status icon**: `icon` (an mx-icons name, e.g. `warning`) and `color` (a theme palette path,\n * e.g. `error.main`), for subheaders that show a state rather than an entity (V1's\n * `logo_name` / `logo_color`).\n *\n * `alt` is the accessible name for either shape. A logo sends one shape; if it sends both, `icon`\n * wins, as `logo_name` does in V1's `SubHeader`.\n */\nexport interface LogoRef {\n alt?: string\n color?: string\n fallback_guid?: string\n guid?: string\n icon?: string\n}\n\nexport interface CategoryLogo {\n category_guid: string\n category_name: string\n}\n\nexport interface MerchantLogo {\n merchant_guid: string\n merchant_name: string\n}\n\nexport interface InstitutionLogo {\n institution_guid: string\n institution_name: string\n}\n\nexport interface Description {\n text: string\n html_text: string\n}\n\n/**\n * Post message a CTA press sends to the host, resolved by the backend for the beat's current\n * state. Absent/null = the backend has not described one: the frontend uses the template's\n * interim `ctaPostMessages` entry if there is one, else sends no message. `payload` carries only\n * beat-specific extras; the frontend always adds `beat_guid`, `beat_template`, `user_guid` and\n * `action_string`.\n */\nexport interface CtaPostMessageMetadata {\n /** Post message event; defaults to `beat/cta`. */\n event?: string | null\n /** Operation the host should perform, e.g. `op_1`, `op_2`, `op_3`. Defaults to `op_1`. */\n action?: string | null\n /** Beat-specific fields merged into the message metadata (account ids, amounts, ...). */\n payload?: Record<string, unknown> | null\n}\n\nexport interface PrimaryCTA {\n label: string\n block: string\n variant?: string | null\n /**\n * What pressing the CTA does beyond opening its block, named by the backend (ditto\n * `primary_cta_action`, passed through by tupac). Looked up in `insights-v2/ctaActions`;\n * null / absent / unknown means the CTA only opens its block or posts its message.\n */\n action_key?: string | null\n metadata?: CtaPostMessageMetadata | null\n /** Figures this CTA's drilldown renders (e.g. a summary header's amount/dates/count). */\n drilldown_data?: DrilldownData\n}\n\nexport interface SecondaryCTA {\n label: string\n /**\n * Drawer block to open. `null` when the CTA opens nothing (ditto `secondary_cta_block: null`,\n * e.g. Fee Detected's \"Contact Support\"): the press posts its message to the host instead.\n */\n block: string | null\n variant?: string | null\n /** See `PrimaryCTA.action_key` (ditto `secondary_cta_action`). */\n action_key?: string | null\n metadata?: CtaPostMessageMetadata | null\n /** Figures this CTA's drilldown renders (e.g. a summary header's amount/dates/count). */\n drilldown_data?: DrilldownData\n}\n\n/**\n * The description link: its label, the action block it opens and, like a CTA's, the variant that\n * tells that block what to show (ditto's `in_description_cta_variant`, e.g. `low_balance`). On mini\n * and micro it words the card's action; `block` is empty when that action opens no drawer.\n */\nexport interface InDescriptionCTA {\n label: string\n block?: string\n variant?: string | null\n action_key?: string | null\n /** tupac's flat host message for the link (`action` plus fields), e.g. Switch's op_1. */\n post_message_metadata?: ({ action?: string | null } & Record<string, unknown>) | null\n /** Figures this CTA's drilldown renders (e.g. a summary header's amount/dates/count). */\n drilldown_data?: DrilldownData\n}\n\nexport interface Footer {\n /** V1: a pre-formatted date string. */\n date?: string\n /**\n * The account label, on both V1 and V2. The backend resolves the plurality: one account sends\n * its name (e.g. `Epic Bank`), several send a localized count (e.g. `2 Accounts`), none sends\n * `null` (tupac's `footer_account_label` returns nil for a beat with no accounts, as Payday Cash\n * Left Over Status does). There is deliberately no separate `accounts` key.\n */\n account?: string | null\n /**\n * V2 (LargeTransactionV2 onward): unix seconds, formatted by `Footer` for display.\n * Replaces `date`; `date` wins when a beat somehow sends both.\n */\n timestamp?: number\n}\n\n// ============ Instance Slot Types ============\n// Values are the snake_case block names the backend sends on a beat's instance slot; the PascalCase\n// keys stay as friendly references (e.g. BlockType.BarChartBlock === 'bar_chart_block').\nexport const BlockType = {\n AccountBlock: 'account_block',\n AccountSwitchBlock: 'account_switch_block',\n BarChartBlock: 'bar_chart_block',\n BudgetBlock: 'budget_block',\n DirectDepositBlock: 'direct_deposit_block',\n ImageBlock: 'image_block',\n MerchantBlock: 'merchant_block',\n TransactionBlock: 'transaction_block',\n DonutChartBlock: 'donut_chart_block',\n DoubleBarChartBlock: 'double_bar_chart_block',\n DoubleProgressBarBlock: 'double_progress_bar_block',\n DebtsBlock: 'debts_block',\n GasPurchaseBlock: 'gas_purchase_block',\n GoalsBlock: 'goals_block',\n NoSpendDaysBlock: 'no_spend_days_block',\n QuizBlock: 'quiz_block',\n RepeatingTransactionBlock: 'repeating_transaction_block',\n SaveExtraBlock: 'save_extra_block',\n SavingsAmountBlock: 'savings_amount_block',\n SavingsSummaryBlock: 'savings_summary_block',\n StepChartBlock: 'step_chart_block',\n SVGImageBlock: 'svg_image_block',\n UpcomingBillBlock: 'upcoming_bill_block',\n UpcomingSubscriptionBlock: 'upcoming_subscription_block',\n WeeklySmallPurchasesBlock: 'weekly_small_purchases_block',\n WithdrawalBlock: 'withdrawal_block',\n} as const\n\nexport type BlockType = (typeof BlockType)[keyof typeof BlockType]\n\n/**\n * A pre-localized row on a V2 instance slot. The backend resolves the copy and formatting; the\n * logo is a `LogoRef` (an entity guid or a status icon, see `logoFromRef`).\n */\nexport interface InstanceSlotRow {\n amount?: number\n logo?: LogoRef\n primary_text?: string\n secondary_text?: string\n}\n\n/**\n * V2: the slots a block's variant filled, keyed by slot name; ditto owns the names and omits any\n * slot it has no value for (`lib/ditto/blocks/<block>.yml`). Read with `slot()`, which names the\n * kind the caller expects.\n */\nexport interface InstanceSlotData {\n [slot: string]: unknown\n}\n\n/**\n * Reads one slot off a block's `data`; undefined when ditto did not fill it.\n *\n * The caller names the kind, because the slot's kind lives in the block's ditto schema and not\n * here — a block fills slots with whatever its card needs, so no fixed list of kinds would hold\n * (`account_switch_block` alone carries a boolean and `budget_block` a nested object).\n */\nexport const slot = <T = unknown>(\n data: InstanceSlotData | undefined,\n name: string,\n): T | undefined => data?.[name] as T | undefined\n\n/**\n * V2: which block renders this beat's content, and what it renders.\n *\n * `block` is optional: a beat whose template has no ditto config arrives as an empty `{}` and the\n * card renders its copy and CTAs alone, so a reader cannot assume a block is named. One interface\n * with `block` optional rather than a union with `Record<string, never>`, which TypeScript absorbs\n * — that union left `block` reading as required and typed a promise it did not keep.\n *\n * `variant` is optional for the same reason — the empty `{}` carries neither. Every ditto beat\n * file that names a block also names a variant, so a *filled* slot always has one; ditto drops a\n * nil variant rather than sending null, which is why the type is `string | null | undefined`.\n */\nexport interface InstanceSlot {\n block?: BlockType\n variant?: string | null\n /** The slots this block's variant declares in ditto. */\n data?: InstanceSlotData\n // Direct Deposit block (Set Up Direct Deposit, Switch Direct Deposit, Missing\n // Interest Rate): account facts carried flat on the slot, beside `data`.\n /** Primary line on the hero card, e.g. \"Epic Bank Checking, *1234\". */\n account_name?: string\n /** Secondary line beneath the name, e.g. \"Checking Account\" / \"Credit Card\". */\n account_type?: string\n /** Status pill label, e.g. \"Direct Deposit Not Set Up\" / \"Interest Rate: 19.99% APR\". */\n status_text?: string\n institution_guid?: string\n institution_name?: string\n // Shared across multiple V2 component blocks:\n // `amount` — UpcomingBillBlock (projected bill), UpcomingSubscriptionBlock (price per cadence).\n // (SavingsOpportunityBlock now reads `amount` off `instance_slot.data`, not this flat field.)\n // `merchant_guid` / `merchant_name` — UpcomingBillBlock (bill row logo + name),\n // UpcomingSubscriptionBlock (hero logo + name).\n /** Dollar amount (unformatted); the block formats it as currency. */\n amount?: number\n // Withdrawal block (Emergency Fund Withdrawal): one row flat on the slot - `amount` above is the\n // withdrawal, shown with its date line \"{amount_label} {withdrawal_date}\" over the balance row.\n /** Pre-localized lead-in for the date line, e.g. \"Withdrawn on\". */\n amount_label?: string\n /** The withdrawal's calendar day, `YYYY-MM-DD` (e.g. `2026-10-20`); the card formats it. */\n withdrawal_date?: string\n /** Account balance after the withdrawal (unformatted); the card formats it as currency. */\n balance?: number\n /** Pre-localized label for the balance row, e.g. \"Balance\". */\n balance_label?: string\n /** Merchant guid used to render the inline / hero logo via `LogoFromGuid` (`MCH-...`). */\n merchant_guid?: string\n /** Merchant display name — shown as logo alt text and as the merchant/hero label. */\n merchant_name?: string\n // Upcoming Bill block (Projected Bill Payment): the block derives the Sun→Sat week strip\n // around `due_date` at render time.\n /** Due date of the projected bill in ISO form (e.g. `2025-10-30`). */\n due_date?: string\n // Account block (confetti tile): V1 flat fallback for the label line when `instance_slot.data` is\n // absent — `AccountBlock` reads `data.sub_text` first, then this. (The Savings Opportunity coupon\n // now reads `primary_text`/`amount` off `data`, so it no longer reads this flat field.)\n /** Caption/label line for the confetti tile (V1 fallback). */\n label?: string\n // Upcoming Subscription block: billing cadence for the price pill (`${amount} / ${cadence}`).\n /** Billing cadence word that trails the price, e.g. `month` or `year`. */\n cadence?: string\n // Account block (status on/off-track, deposit, payoff variants): card content carried flat on\n // the slot (the V2 contract drops `instance_slot_data`). `amount`, `label`, `merchant_guid`,\n // `merchant_name`, `institution_guid`, `institution_name` are shared fields declared above.\n /** Secondary line beneath the amount on the standard card, e.g. \"Remaining after expenses\". */\n sub_text?: string\n /** Header bar text (standard card) or the colored category strip label (deposit cards). */\n header_text?: string\n /** Generic-tile icon name used when no merchant/institution logo is available. */\n icon_name?: string\n /** Category guid used to render the deposit-card logo fallback. */\n category_guid?: string\n // Debts block: `amount` is the current balance; the shared account/institution fields above.\n /** Projected payoff date in ISO form (e.g. `2027-03-01`); the block formats it as month + year. */\n payoff_date?: string\n /** Monthly payment toward the debt (unformatted); the block formats it as currency. */\n monthly_payment?: number\n /** Annual interest rate as a percentage (e.g. `19.99`); the block formats it as a percent. */\n interest_rate?: number\n start_date?: string\n no_spend_days?: string[]\n /** First day of the month a monthly summary covers, in ISO form (e.g. `2026-09-01`). */\n date?: string\n /** Number of gas station visits in the month. */\n total_fill_up_visits?: number\n /** Amount spent at gas stations in the month, unformatted. */\n total_spend?: number\n /** V1 name for `total_spend`, read when `total_spend` is absent. */\n total_debt_for_fill_up_visits_in_prev_month?: number\n /** Total available balance across the user's accounts, unformatted. */\n available_balance?: number\n /** Average monthly spend, unformatted. */\n avg_monthly_spend?: number\n /** How long the balance lasts, e.g. \"2 months, 11 days\". */\n time_period?: string\n /** One row per unique merchant in the period, in the order sent. */\n data_series?: InstanceSlotRow[]\n}\n"],"mappings":"AAgVA,IAAa,IAAA,CACX,GACA,MACkB,IAAO,CAAA"}
|
|
1
|
+
{"version":3,"file":"Insights.es.js","names":[],"sources":["../../../src/core/types/Insights.ts"],"sourcesContent":["// ============ Core InsightsV2 Types ============\n\nimport type { DataSeries } from './Beat'\nimport { InsightsInstanceSlotData } from './InsightsInstanceSlotData'\n\nexport interface ThemedSVGImageProps {\n divProps?: React.HTMLAttributes<HTMLDivElement>\n image: React.ComponentType<React.SVGProps<SVGSVGElement>>\n isMini?: boolean\n}\n\n/**\n * Emitted by a block when the user drills into a specific datum (e.g. clicks a\n * chart bar). Named fields rather than positional args so blocks with differing\n * shapes can extend this without the call sites transposing values.\n */\nexport interface DrilldownPayload {\n chartBarIndex: number\n tabIndex?: number\n transaction_guid?: string\n block?: string\n}\n\n/**\n * Which envelope a beat was fetched with. `embedded` (the transaction-row pill + details-drawer\n * card) and `notification` are V2 additions; a surface asks for one with `widget_type=` on the fetch.\n */\nexport type WidgetType = 'full' | 'mini' | 'micro' | 'embedded' | 'notification'\n\n/**\n * V2: the transaction-row tag, its own small section of the `embedded` envelope (the same grammar\n * as `description` / `footer`, with room for a tone or an icon later). Omitted for an insight that\n * tags no transaction row. It deliberately is *not* `short_title`, which stays a per-variant\n * attribute with a second consumer (the bank-holiday sub-header).\n */\nexport interface Pill {\n text: string\n}\n\n/**\n * V2: facts a drilldown shows that the card does not. On the payload: what every CTA of the card\n * shares (e.g. the account number for the Transaction Details drawer, or the guid list a list drawer\n * shows, `transaction_guids`). On a CTA: the figures that CTA's own drilldown renders (the Transaction\n * List summary header's `amount`, `start_date` / `end_date` and `count`, see `readSummary`). Scalars,\n * string lists or a `data_series` (the months a history drawer charts), omitted when the insight has\n * none. Never carries copy or user actions (memo, tags, hide, flag come from the transaction store).\n * Values come from the server, so a reader still checks each value's runtime shape.\n */\nexport type DrilldownData = Record<string, string | number | boolean | null | string[] | DataSeries>\n\nexport interface InsightsPayload {\n widget_type: WidgetType\n instance_slot: InstanceSlot\n /**\n * V1 only. The v2 contract carries everything a block needs on `instance_slot.data`,\n * and omits this key entirely (see the LargeTransactionV2 payload). Blocks that still require it\n * get it as a required field through `BlockProps`, which re-declares it.\n */\n instance_slot_data?: InsightsInstanceSlotData\n description: Description\n primary_cta?: PrimaryCTA\n secondary_cta?: SecondaryCTA\n title?: string\n sub_title?: Subtitle\n /**\n * V2 rename of `sub_title`: a flat string, with the logo promoted to the payload-level `logo`\n * field below. `sub_title` wins when both are present.\n */\n subtitle?: string\n /** V2: header logo paired with the flat `subtitle`: an entity guid or a status icon (`LogoRef`). */\n logo?: LogoRef\n /** V2: which design branch the backend picked (e.g. `no_merchant`). */\n variant?: string\n /** V2, `embedded` envelope only: the transaction-row pill. */\n pill?: Pill\n /**\n * V2: drilldown-only facts, e.g. `{ account_number: 'XXXXXXXX043' }`, or the guid list a list\n * drawer shows (`{ transaction_guids: [...] }`).\n */\n drilldown_data?: DrilldownData\n footer?: Footer\n /**\n * V2: the link inside the description: on the full card a drawer of its own (Low Account\n * Balance's \"Transactions ›\"); on mini and micro the card's action, sent instead of `primary_cta`.\n * Absent when the beat has no link.\n */\n in_description_cta?: InDescriptionCTA\n guid: string\n user_guid: string\n client_guid?: string\n /** Template name, e.g. `LargeTransactionV2`. */\n template?: string\n revision?: number\n /** Unix seconds. */\n created_at?: number\n /** Unix seconds. */\n updated_at?: number\n /** Unix seconds. */\n active_at?: number\n displayed_at?: number | null\n dismissed_at: number | null\n cta_clicked_at?: number | null\n has_been_displayed?: boolean\n is_dismissed: boolean\n is_deleted?: boolean\n is_hidden_by_system?: boolean\n is_obsolete?: boolean\n is_refreshable?: boolean\n is_sampled?: boolean\n is_zero_state?: boolean\n status?: string | null\n /**\n * V2 (LargeTransactionV2 onward): the entities the beat is about, carried on the payload so\n * action blocks do not have to reach back out to the beat envelope.\n */\n primary_account_guid?: string | null\n primary_transaction_guid?: string | null\n primary_category_guid?: string | null\n primary_merchant_guid?: string | null\n /**\n * V2: the repeating transaction a subscription beat is about (Upcoming Subscription, Subscription\n * Price Increase). Read by `recurring_transaction_block`, see\n * `actionBlocks/RecurringTransactionBlock/subscriptionBeats.ts`.\n */\n primary_repeating_transaction_guid?: string | null\n}\n\nexport interface Legends {\n label: string\n value: number\n additional_value?: number\n additional_value_type?: string\n value_type?: string\n}\n\nexport interface Logo {\n category_guid?: string\n category_name?: string\n institution_guid?: string\n institution_name?: string\n logo_color?: string\n /** Draw the `logo_name` icon filled (V2 `ICO-` logos). */\n logo_fill?: boolean\n logo_name?: string\n merchant_guid?: string\n merchant_name?: string\n}\n\nexport interface Subtitle {\n logo?: Logo\n text: string\n}\n\n/**\n * A V2 logo, shared by the header (`InsightsPayload.logo`) and every instance-slot row. It takes\n * one of two shapes:\n *\n * - **Entity**: `guid`, whose prefix (`INS-` / `MCH-` / `CAT-`) picks the logo component, plus an\n * optional `fallback_guid` for when that component's asset cannot load. Today that is the\n * category behind an `MCH-` guid, which `MerchantLogo` shows as a tile when the merchant image\n * is missing.\n * - **Status icon**: `icon` (an mx-icons name, e.g. `warning`) and `color` (a theme palette path,\n * e.g. `error.main`), for subheaders that show a state rather than an entity (V1's\n * `logo_name` / `logo_color`).\n *\n * `alt` is the accessible name for either shape. A logo sends one shape; if it sends both, `icon`\n * wins, as `logo_name` does in V1's `SubHeader`.\n */\nexport interface LogoRef {\n alt?: string\n color?: string\n fallback_guid?: string\n guid?: string\n icon?: string\n}\n\nexport interface CategoryLogo {\n category_guid: string\n category_name: string\n}\n\nexport interface MerchantLogo {\n merchant_guid: string\n merchant_name: string\n}\n\nexport interface InstitutionLogo {\n institution_guid: string\n institution_name: string\n}\n\nexport interface Description {\n text: string\n html_text: string\n}\n\n/**\n * Post message a CTA press sends to the host, resolved by the backend for the beat's current\n * state. Absent/null = the backend has not described one: the frontend uses the template's\n * interim `ctaPostMessages` entry if there is one, else sends no message. `payload` carries only\n * beat-specific extras; the frontend always adds `beat_guid`, `beat_template`, `user_guid` and\n * `action_string`.\n */\nexport interface CtaPostMessageMetadata {\n /** Post message event; defaults to `beat/cta`. */\n event?: string | null\n /** Operation the host should perform, e.g. `op_1`, `op_2`, `op_3`. Defaults to `op_1`. */\n action?: string | null\n /** Beat-specific fields merged into the message metadata (account ids, amounts, ...). */\n payload?: Record<string, unknown> | null\n}\n\nexport interface PrimaryCTA {\n label: string\n block: string\n variant?: string | null\n /**\n * What pressing the CTA does beyond opening its block, named by the backend (ditto\n * `primary_cta_action`, passed through by tupac). Looked up in `insights-v2/ctaActions`;\n * null / absent / unknown means the CTA only opens its block or posts its message.\n */\n action_key?: string | null\n metadata?: CtaPostMessageMetadata | null\n /** Figures this CTA's drilldown renders (e.g. a summary header's amount/dates/count). */\n drilldown_data?: DrilldownData\n}\n\nexport interface SecondaryCTA {\n label: string\n /**\n * Drawer block to open. `null` when the CTA opens nothing (ditto `secondary_cta_block: null`,\n * e.g. Fee Detected's \"Contact Support\"): the press posts its message to the host instead.\n */\n block: string | null\n variant?: string | null\n /** See `PrimaryCTA.action_key` (ditto `secondary_cta_action`). */\n action_key?: string | null\n metadata?: CtaPostMessageMetadata | null\n /** Figures this CTA's drilldown renders (e.g. a summary header's amount/dates/count). */\n drilldown_data?: DrilldownData\n}\n\n/**\n * The description link: its label, the action block it opens and, like a CTA's, the variant that\n * tells that block what to show (ditto's `in_description_cta_variant`, e.g. `low_balance`). On mini\n * and micro it words the card's action; `block` is empty when that action opens no drawer.\n */\nexport interface InDescriptionCTA {\n label: string\n block?: string\n variant?: string | null\n action_key?: string | null\n /** tupac's flat host message for the link (`action` plus fields), e.g. Switch's op_1. */\n post_message_metadata?: ({ action?: string | null } & Record<string, unknown>) | null\n /** Figures this CTA's drilldown renders (e.g. a summary header's amount/dates/count). */\n drilldown_data?: DrilldownData\n}\n\nexport interface Footer {\n /** V1: a pre-formatted date string. */\n date?: string\n /**\n * The account label, on both V1 and V2. The backend resolves the plurality: one account sends\n * its name (e.g. `Epic Bank`), several send a localized count (e.g. `2 Accounts`), none sends\n * `null` (tupac's `footer_account_label` returns nil for a beat with no accounts, as Payday Cash\n * Left Over Status does). There is deliberately no separate `accounts` key.\n */\n account?: string | null\n /**\n * V2 (LargeTransactionV2 onward): unix seconds, formatted by `Footer` for display.\n * Replaces `date`; `date` wins when a beat somehow sends both.\n */\n timestamp?: number\n}\n\n// ============ Instance Slot Types ============\n// Values are the snake_case block names the backend sends on a beat's instance slot; the PascalCase\n// keys stay as friendly references (e.g. BlockType.BarChartBlock === 'bar_chart_block').\nexport const BlockType = {\n AccountBlock: 'account_block',\n AccountSwitchBlock: 'account_switch_block',\n BarChartBlock: 'bar_chart_block',\n BudgetBlock: 'budget_block',\n DirectDepositBlock: 'direct_deposit_block',\n ImageBlock: 'image_block',\n MerchantBlock: 'merchant_block',\n TransactionBlock: 'transaction_block',\n DonutChartBlock: 'donut_chart_block',\n DoubleBarChartBlock: 'double_bar_chart_block',\n DoubleProgressBarBlock: 'double_progress_bar_block',\n DebtsBlock: 'debts_block',\n GasPurchaseBlock: 'gas_purchase_block',\n GoalsBlock: 'goals_block',\n NoSpendDaysBlock: 'no_spend_days_block',\n QuizBlock: 'quiz_block',\n RepeatingTransactionBlock: 'repeating_transaction_block',\n SaveExtraBlock: 'save_extra_block',\n SavingsAmountBlock: 'savings_amount_block',\n SavingsSummaryBlock: 'savings_summary_block',\n StepChartBlock: 'step_chart_block',\n SVGImageBlock: 'svg_image_block',\n UpcomingBillBlock: 'upcoming_bill_block',\n UpcomingSubscriptionBlock: 'upcoming_subscription_block',\n WeeklySmallPurchasesBlock: 'weekly_small_purchases_block',\n WithdrawalBlock: 'withdrawal_block',\n} as const\n\nexport type BlockType = (typeof BlockType)[keyof typeof BlockType]\n\n/**\n * A pre-localized row on a V2 instance slot. The backend resolves the copy and formatting; the\n * logo is a `LogoRef` (an entity guid or a status icon, see `logoFromRef`).\n */\nexport interface InstanceSlotRow {\n amount?: number\n logo?: LogoRef\n primary_text?: string\n secondary_text?: string\n}\n\n/**\n * V2: the slots a block's variant filled, keyed by slot name; ditto owns the names and omits any\n * slot it has no value for (`lib/ditto/blocks/<block>.yml`). Read with `slot()`, which names the\n * kind the caller expects.\n */\nexport interface InstanceSlotData {\n [slot: string]: unknown\n}\n\n/**\n * Reads one slot off a block's `data`; undefined when ditto did not fill it.\n *\n * The caller names the kind, because the slot's kind lives in the block's ditto schema and not\n * here — a block fills slots with whatever its card needs, so no fixed list of kinds would hold\n * (`account_switch_block` alone carries a boolean and `budget_block` a nested object).\n */\nexport const slot = <T = unknown>(\n data: InstanceSlotData | undefined,\n name: string,\n): T | undefined => data?.[name] as T | undefined\n\n/**\n * V2: which block renders this beat's content, and what it renders.\n *\n * `block` is optional: a beat whose template has no ditto config arrives as an empty `{}` and the\n * card renders its copy and CTAs alone, so a reader cannot assume a block is named. One interface\n * with `block` optional rather than a union with `Record<string, never>`, which TypeScript absorbs\n * — that union left `block` reading as required and typed a promise it did not keep.\n *\n * `variant` is optional for the same reason — the empty `{}` carries neither. Every ditto beat\n * file that names a block also names a variant, so a *filled* slot always has one; ditto drops a\n * nil variant rather than sending null, which is why the type is `string | null | undefined`.\n */\nexport interface InstanceSlot {\n block?: BlockType\n variant?: string | null\n /** The slots this block's variant declares in ditto. */\n data?: InstanceSlotData\n // Direct Deposit block (Set Up Direct Deposit, Switch Direct Deposit, Missing\n // Interest Rate): account facts carried flat on the slot, beside `data`.\n /** Primary line on the hero card, e.g. \"Epic Bank Checking, *1234\". */\n account_name?: string\n /** Secondary line beneath the name, e.g. \"Checking Account\" / \"Credit Card\". */\n account_type?: string\n /** Status pill label, e.g. \"Direct Deposit Not Set Up\" / \"Interest Rate: 19.99% APR\". */\n status_text?: string\n institution_guid?: string\n institution_name?: string\n // Shared across multiple V2 component blocks:\n // `amount` — UpcomingBillBlock (projected bill), UpcomingSubscriptionBlock (price per cadence).\n // (SavingsOpportunityBlock now reads `amount` off `instance_slot.data`, not this flat field.)\n // `merchant_guid` / `merchant_name` — UpcomingBillBlock (bill row logo + name),\n // UpcomingSubscriptionBlock (hero logo + name).\n /** Dollar amount (unformatted); the block formats it as currency. */\n amount?: number\n // Withdrawal block (Emergency Fund Withdrawal): one row flat on the slot - `amount` above is the\n // withdrawal, shown with its date line \"{amount_label} {withdrawal_date}\" over the balance row.\n /** Pre-localized lead-in for the date line, e.g. \"Withdrawn on\". */\n amount_label?: string\n /** The withdrawal's calendar day, `YYYY-MM-DD` (e.g. `2026-10-20`); the card formats it. */\n withdrawal_date?: string\n /** Account balance after the withdrawal (unformatted); the card formats it as currency. */\n balance?: number\n /** Pre-localized label for the balance row, e.g. \"Balance\". */\n balance_label?: string\n /** Merchant guid used to render the inline / hero logo via `LogoFromGuid` (`MCH-...`). */\n merchant_guid?: string\n /** Merchant display name — shown as logo alt text and as the merchant/hero label. */\n merchant_name?: string\n // Upcoming Bill block (Projected Bill Payment): the block derives the Sun→Sat week strip\n // around `due_date` at render time.\n /** Due date of the projected bill in ISO form (e.g. `2025-10-30`). */\n due_date?: string\n // Account block (confetti tile): V1 flat fallback for the label line when `instance_slot.data` is\n // absent — `AccountBlock` reads `data.sub_text` first, then this. (The Savings Opportunity coupon\n // now reads `primary_text`/`amount` off `data`, so it no longer reads this flat field.)\n /** Caption/label line for the confetti tile (V1 fallback). */\n label?: string\n // Upcoming Subscription block: billing cadence for the price pill (`${amount} / ${cadence}`).\n /** Billing cadence word that trails the price, e.g. `month` or `year`. */\n cadence?: string\n // Account block (status on/off-track, deposit, payoff variants): card content carried flat on\n // the slot (the V2 contract drops `instance_slot_data`). `amount`, `label`, `merchant_guid`,\n // `merchant_name`, `institution_guid`, `institution_name` are shared fields declared above.\n /** Secondary line beneath the amount on the standard card, e.g. \"Remaining after expenses\". */\n sub_text?: string\n /** Header bar text (standard card) or the colored category strip label (deposit cards). */\n header_text?: string\n /** Generic-tile icon name used when no merchant/institution logo is available. */\n icon_name?: string\n /** Category guid used to render the deposit-card logo fallback. */\n category_guid?: string\n start_date?: string\n no_spend_days?: string[]\n /** First day of the month a monthly summary covers, in ISO form (e.g. `2026-09-01`). */\n date?: string\n /** Number of gas station visits in the month. */\n total_fill_up_visits?: number\n /** Amount spent at gas stations in the month, unformatted. */\n total_spend?: number\n /** V1 name for `total_spend`, read when `total_spend` is absent. */\n total_debt_for_fill_up_visits_in_prev_month?: number\n /** Total available balance across the user's accounts, unformatted. */\n available_balance?: number\n /** Average monthly spend, unformatted. */\n avg_monthly_spend?: number\n /** How long the balance lasts, e.g. \"2 months, 11 days\". */\n time_period?: string\n /** One row per unique merchant in the period, in the order sent. */\n data_series?: InstanceSlotRow[]\n}\n"],"mappings":"AAgVA,IAAa,IAAA,CACX,GACA,MACkB,IAAO,CAAA"}
|
|
@@ -118,6 +118,9 @@ export interface MakeTransferCopy {
|
|
|
118
118
|
expenses_text: string;
|
|
119
119
|
available_balances_text: string;
|
|
120
120
|
average_monthly_spend_text: string;
|
|
121
|
+
/** Insights 2.0 table labels; V1 keeps the two above. */
|
|
122
|
+
available_balance_text: string;
|
|
123
|
+
avg_monthly_spend_text: string;
|
|
121
124
|
your_available_balances_text: string;
|
|
122
125
|
increment_aria_label: string;
|
|
123
126
|
decrement_aria_label: string;
|
|
@@ -372,14 +375,14 @@ export interface EmergencySavingsCopy {
|
|
|
372
375
|
step_two: string;
|
|
373
376
|
final_step: string;
|
|
374
377
|
}
|
|
375
|
-
/** Labels for the Debts component block
|
|
378
|
+
/** Labels for the Debts component block (Debt Payment Reminder). Optional until the service ships them. */
|
|
376
379
|
export interface DebtsBlockCopy {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
/**
|
|
382
|
-
|
|
380
|
+
/** Grey footer row caption for the account balance, e.g. "Current balance". */
|
|
381
|
+
balance_label?: string;
|
|
382
|
+
/** Due-date row caption, e.g. "Payment due on". */
|
|
383
|
+
payment_due_label?: string;
|
|
384
|
+
/** Minimum payment row caption, e.g. "Minimum payment"; drawn only when the beat sends one. */
|
|
385
|
+
minimum_payment_label?: string;
|
|
383
386
|
}
|
|
384
387
|
/** Labels for the Goals component block. */
|
|
385
388
|
export interface GoalsBlockCopy {
|
|
@@ -9,6 +9,8 @@ export declare const CURRENCY_FORMAT: {
|
|
|
9
9
|
};
|
|
10
10
|
export type CurrencyFormat = (typeof CURRENCY_FORMAT)[keyof typeof CURRENCY_FORMAT];
|
|
11
11
|
export declare const formatCurrency: (amount: number | undefined, formatting: string, roundingFunction?: RoundingFunction) => string;
|
|
12
|
+
/** Whole dollars, rounded first so a small negative shows "$0", not numeral's "0$". */
|
|
13
|
+
export declare const formatWholeCurrency: (amount: number | undefined) => string;
|
|
12
14
|
export declare const getCurrencyCodes: () => CurrencyCodes;
|
|
13
15
|
export declare const isValidNumber: (value: any) => boolean;
|
|
14
16
|
export declare const formatPercentage: (amount: number | string | undefined, options?: Intl.NumberFormatOptions) => string | number | undefined;
|
|
@@ -1,39 +1,40 @@
|
|
|
1
1
|
import { getLocale as a } from "./Localization.es.js";
|
|
2
|
-
import { CurrencyCodes as
|
|
3
|
-
import
|
|
2
|
+
import { CurrencyCodes as c } from "../constants/Numbers.es.js";
|
|
3
|
+
import s from "numeral";
|
|
4
4
|
var w = (r, e, t) => {
|
|
5
|
-
const n = [],
|
|
5
|
+
const n = [], d = (e - r) / (t - 1);
|
|
6
6
|
for (let o = 0; o < t; o++) {
|
|
7
|
-
const
|
|
8
|
-
n.push(
|
|
7
|
+
const m = r + o * d;
|
|
8
|
+
n.push(m);
|
|
9
9
|
}
|
|
10
10
|
return n[t - 1] = e, n.map(Math.round);
|
|
11
|
-
}, y = (r) => r.length ? Math.round(r.reduce((e, t) => e + t, 0) / r.length) : 0,
|
|
11
|
+
}, y = (r) => r.length ? Math.round(r.reduce((e, t) => e + t, 0) / r.length) : 0, l = {
|
|
12
12
|
cents: "0,0.00",
|
|
13
13
|
whole: "0,0"
|
|
14
|
-
},
|
|
14
|
+
}, i = (r, e, t) => a() === "fr-ca" ? s(r).format(`${e} $`, t) : s(r).format(`$${e}`, t), C = (r) => i(Math.round(r ?? 0), l.whole), $ = () => a() === "fr-ca" ? c.CAD : c.USD, u = (r) => r != null && r !== "" && isFinite(r), f = {
|
|
15
15
|
style: "percent",
|
|
16
16
|
minimumFractionDigits: 2,
|
|
17
17
|
maximumFractionDigits: 2
|
|
18
|
-
},
|
|
18
|
+
}, M = (r, e = f) => u(r) ? new Intl.NumberFormat(a(), e).format(Number(r)) : r, h = (r) => new Intl.PluralRules(a(), r), R = (r, e = { type: "ordinal" }, t = {
|
|
19
19
|
one: "st",
|
|
20
20
|
two: "nd",
|
|
21
21
|
few: "rd",
|
|
22
22
|
other: "th"
|
|
23
|
-
}) => `${r}${t[h(e).select(r)]}`,
|
|
24
|
-
const e = Math.round(Math.abs(r) * 100), t =
|
|
23
|
+
}) => `${r}${t[h(e).select(r)]}`, D = (r) => {
|
|
24
|
+
const e = Math.round(Math.abs(r) * 100), t = i(e / 100, l.cents);
|
|
25
25
|
return r < 0 && e > 0 ? `-${t}` : t;
|
|
26
26
|
};
|
|
27
27
|
export {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
l as CURRENCY_FORMAT,
|
|
29
|
+
i as formatCurrency,
|
|
30
|
+
R as formatOrdinal,
|
|
31
|
+
M as formatPercentage,
|
|
32
|
+
D as formatSignedCurrency,
|
|
33
|
+
C as formatWholeCurrency,
|
|
33
34
|
w as generateEqualIntervals,
|
|
34
|
-
|
|
35
|
+
$ as getCurrencyCodes,
|
|
35
36
|
h as getPluralRules,
|
|
36
|
-
|
|
37
|
+
u as isValidNumber,
|
|
37
38
|
y as roundedAverage
|
|
38
39
|
};
|
|
39
40
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberFormatting.es.js","names":[],"sources":["../../../src/core/utils/NumberFormatting.ts"],"sourcesContent":["import numeral from 'numeral'\nimport type { RoundingFunction } from 'numeral'\n\nimport { CurrencyCodes } from '../constants/Numbers'\nimport { getLocale } from './Localization'\n\nexport const generateEqualIntervals = (\n minValue: number,\n maxValue: number,\n tickCount: number,\n): number[] => {\n const ticks: number[] = []\n const range = maxValue - minValue\n const step = range / (tickCount - 1) // The space between each tick\n\n for (let i = 0; i < tickCount; i++) {\n const tickValue = minValue + i * step\n ticks.push(tickValue)\n }\n\n ticks[tickCount - 1] = maxValue\n\n return ticks.map(Math.round)\n}\n\nexport const roundedAverage = (values: number[]) =>\n values.length ? Math.round(values.reduce((sum, value) => sum + value, 0) / values.length) : 0\n\n/** The shared currency formats: with cents, and whole dollars. */\nexport const CURRENCY_FORMAT = { cents: '0,0.00', whole: '0,0' } as const\nexport type CurrencyFormat = (typeof CURRENCY_FORMAT)[keyof typeof CURRENCY_FORMAT]\n\n// enhances numeral's localization functionality by puting the $ in the correct place\nexport const formatCurrency = (\n amount: number | undefined,\n formatting: string,\n roundingFunction?: RoundingFunction,\n) => {\n switch (getLocale()) {\n case 'fr-ca': {\n return numeral(amount).format(`${formatting} $`, roundingFunction)\n }\n default: {\n return numeral(amount).format(`$${formatting}`, roundingFunction)\n }\n }\n}\n\nexport const getCurrencyCodes = () => {\n switch (getLocale()) {\n case 'fr-ca':\n return CurrencyCodes.CAD\n default:\n return CurrencyCodes.USD\n }\n}\n\n// will return `true` if value is a string number, like '99', which matches Serenity logic\nexport const isValidNumber = (value: any) =>\n value !== undefined && value !== null && value !== '' && isFinite(value)\n\nconst defaultPercentStyle = {\n style: 'percent',\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n} as Intl.NumberFormatOptions\n\nexport const formatPercentage = (\n amount: number | string | undefined,\n options: Intl.NumberFormatOptions = defaultPercentStyle,\n) =>\n isValidNumber(amount)\n ? new Intl.NumberFormat(getLocale(), options).format(Number(amount))\n : amount\n\nexport const getPluralRules = (options: Intl.PluralRulesOptions) =>\n new Intl.PluralRules(getLocale(), options)\n\nexport const formatOrdinal = (\n number: number,\n options: Intl.PluralRulesOptions = { type: 'ordinal' },\n copy = {\n one: 'st',\n two: 'nd',\n few: 'rd',\n other: 'th',\n } as const,\n) => {\n const rule = getPluralRules(options).select(number)\n\n return `${number}${copy[rule as keyof typeof copy]}`\n}\n\n/**\n * `-$220.00`, not `$-220.00`: the sign goes before the currency symbol. Rounded to cents first so a\n * sub-cent negative (or `-0`) reads `$0.00`, never `-$0.00`.\n */\nexport const formatSignedCurrency = (amount: number): string => {\n const cents = Math.round(Math.abs(amount) * 100)\n const formatted = formatCurrency(cents / 100, CURRENCY_FORMAT.cents)\n\n return amount < 0 && cents > 0 ? `-${formatted}` : formatted\n}\n"],"mappings":";;;AAMA,IAAa,IAAA,CACX,GACA,GACA,MACa;AACb,QAAM,IAAkB,CAAC,GAEnB,KADQ,IAAW,MACH,IAAY;AAElC,WAAS,IAAI,GAAG,IAAI,GAAW,KAAK;AAClC,UAAM,IAAY,IAAW,IAAI;AACjC,IAAA,EAAM,KAAK,CAAS;AAAA,EACtB;AAEA,SAAA,EAAM,IAAY,CAAA,IAAK,GAEhB,EAAM,IAAI,KAAK,KAAK;AAC7B,GAEa,IAAA,CAAkB,MAC7B,EAAO,SAAS,KAAK,MAAM,EAAO,OAAA,CAAQ,GAAK,MAAU,IAAM,GAAO,CAAC,IAAI,EAAO,MAAM,IAAI,GAGjF,IAAkB;AAAA,EAAE,OAAO;AAAA,EAAU,OAAO;AAAM,GAIlD,IAAA,CACX,GACA,GACA,MAEQ,EAAU,MACX,UACI,EAAQ,CAAM,EAAE,OAAO,GAAG,CAAA,MAAgB,CAAgB,IAG1D,EAAQ,CAAM,EAAE,OAAO,IAAI,CAAA,IAAc,CAAgB,
|
|
1
|
+
{"version":3,"file":"NumberFormatting.es.js","names":[],"sources":["../../../src/core/utils/NumberFormatting.ts"],"sourcesContent":["import numeral from 'numeral'\nimport type { RoundingFunction } from 'numeral'\n\nimport { CurrencyCodes } from '../constants/Numbers'\nimport { getLocale } from './Localization'\n\nexport const generateEqualIntervals = (\n minValue: number,\n maxValue: number,\n tickCount: number,\n): number[] => {\n const ticks: number[] = []\n const range = maxValue - minValue\n const step = range / (tickCount - 1) // The space between each tick\n\n for (let i = 0; i < tickCount; i++) {\n const tickValue = minValue + i * step\n ticks.push(tickValue)\n }\n\n ticks[tickCount - 1] = maxValue\n\n return ticks.map(Math.round)\n}\n\nexport const roundedAverage = (values: number[]) =>\n values.length ? Math.round(values.reduce((sum, value) => sum + value, 0) / values.length) : 0\n\n/** The shared currency formats: with cents, and whole dollars. */\nexport const CURRENCY_FORMAT = { cents: '0,0.00', whole: '0,0' } as const\nexport type CurrencyFormat = (typeof CURRENCY_FORMAT)[keyof typeof CURRENCY_FORMAT]\n\n// enhances numeral's localization functionality by puting the $ in the correct place\nexport const formatCurrency = (\n amount: number | undefined,\n formatting: string,\n roundingFunction?: RoundingFunction,\n) => {\n switch (getLocale()) {\n case 'fr-ca': {\n return numeral(amount).format(`${formatting} $`, roundingFunction)\n }\n default: {\n return numeral(amount).format(`$${formatting}`, roundingFunction)\n }\n }\n}\n\n/** Whole dollars, rounded first so a small negative shows \"$0\", not numeral's \"0$\". */\nexport const formatWholeCurrency = (amount: number | undefined) =>\n formatCurrency(Math.round(amount ?? 0), CURRENCY_FORMAT.whole)\n\nexport const getCurrencyCodes = () => {\n switch (getLocale()) {\n case 'fr-ca':\n return CurrencyCodes.CAD\n default:\n return CurrencyCodes.USD\n }\n}\n\n// will return `true` if value is a string number, like '99', which matches Serenity logic\nexport const isValidNumber = (value: any) =>\n value !== undefined && value !== null && value !== '' && isFinite(value)\n\nconst defaultPercentStyle = {\n style: 'percent',\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n} as Intl.NumberFormatOptions\n\nexport const formatPercentage = (\n amount: number | string | undefined,\n options: Intl.NumberFormatOptions = defaultPercentStyle,\n) =>\n isValidNumber(amount)\n ? new Intl.NumberFormat(getLocale(), options).format(Number(amount))\n : amount\n\nexport const getPluralRules = (options: Intl.PluralRulesOptions) =>\n new Intl.PluralRules(getLocale(), options)\n\nexport const formatOrdinal = (\n number: number,\n options: Intl.PluralRulesOptions = { type: 'ordinal' },\n copy = {\n one: 'st',\n two: 'nd',\n few: 'rd',\n other: 'th',\n } as const,\n) => {\n const rule = getPluralRules(options).select(number)\n\n return `${number}${copy[rule as keyof typeof copy]}`\n}\n\n/**\n * `-$220.00`, not `$-220.00`: the sign goes before the currency symbol. Rounded to cents first so a\n * sub-cent negative (or `-0`) reads `$0.00`, never `-$0.00`.\n */\nexport const formatSignedCurrency = (amount: number): string => {\n const cents = Math.round(Math.abs(amount) * 100)\n const formatted = formatCurrency(cents / 100, CURRENCY_FORMAT.cents)\n\n return amount < 0 && cents > 0 ? `-${formatted}` : formatted\n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AAG,CAAA,GAAS,EAFN,EAAe,CAAO,EAAE,OAAO,CAEpB,CAAA,CAAA,IAOb,IAAA,CAAwB,MAA2B;AAC9D,QAAM,IAAQ,KAAK,MAAM,KAAK,IAAI,CAAM,IAAI,GAAG,GACzC,IAAY,EAAe,IAAQ,KAAK,EAAgB,KAAK;AAEnE,SAAO,IAAS,KAAK,IAAQ,IAAI,IAAI,CAAA,KAAc;AACrD"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { buildDynamicCopy as
|
|
2
|
-
import {
|
|
3
|
-
import { BalanceStepper as
|
|
1
|
+
import { buildDynamicCopy as w } from "../../../core/utils/Localization.es.js";
|
|
2
|
+
import { formatWholeCurrency as d } from "../../../core/utils/NumberFormatting.es.js";
|
|
3
|
+
import { BalanceStepper as C } from "./BalanceStepper.es.js";
|
|
4
4
|
import I from "./SaveEnoughToLiveOnBottomSection.es.js";
|
|
5
|
-
import { PROJECTIONS as S, toNumber as
|
|
5
|
+
import { PROJECTIONS as S, toNumber as b, variants as A } from "./layout.es.js";
|
|
6
6
|
import f from "react";
|
|
7
7
|
import { Text as i } from "@mxenabled/mxui";
|
|
8
|
-
import { Icon as
|
|
8
|
+
import { Icon as W } from "@mxenabled/mx-icons";
|
|
9
9
|
import { Fragment as _, jsx as e, jsxs as r } from "react/jsx-runtime";
|
|
10
|
-
import { Card as
|
|
11
|
-
var
|
|
10
|
+
import { Card as j, Divider as E, List as k, ListItem as L, Stack as a } from "@mui/material";
|
|
11
|
+
var O = ({ copy: o, leading: t }) => /* @__PURE__ */ r(a, {
|
|
12
12
|
sx: {
|
|
13
13
|
bgcolor: "background.paper",
|
|
14
14
|
p: 24,
|
|
@@ -27,12 +27,12 @@ var W = ({ copy: o, leading: t }) => /* @__PURE__ */ r(a, {
|
|
|
27
27
|
children: o.description
|
|
28
28
|
})]
|
|
29
29
|
})]
|
|
30
|
-
}),
|
|
30
|
+
}), R = ({ availableBalances: o, expenses: t, totalRemaining: n, copy: l }) => /* @__PURE__ */ e(a, {
|
|
31
31
|
sx: {
|
|
32
32
|
pt: 24,
|
|
33
33
|
px: 24
|
|
34
34
|
},
|
|
35
|
-
children: /* @__PURE__ */ r(
|
|
35
|
+
children: /* @__PURE__ */ r(j, {
|
|
36
36
|
sx: {
|
|
37
37
|
px: 16,
|
|
38
38
|
pt: 16,
|
|
@@ -59,14 +59,14 @@ var W = ({ copy: o, leading: t }) => /* @__PURE__ */ r(a, {
|
|
|
59
59
|
children: [/* @__PURE__ */ e(i, {
|
|
60
60
|
sx: { fontWeight: 600 },
|
|
61
61
|
variant: "body1",
|
|
62
|
-
children:
|
|
62
|
+
children: d(o)
|
|
63
63
|
}), /* @__PURE__ */ e(i, {
|
|
64
64
|
sx: { color: "text.secondary" },
|
|
65
65
|
variant: "caption",
|
|
66
|
-
children:
|
|
66
|
+
children: l.available_text
|
|
67
67
|
})]
|
|
68
68
|
}),
|
|
69
|
-
/* @__PURE__ */ e(
|
|
69
|
+
/* @__PURE__ */ e(W, {
|
|
70
70
|
name: "remove",
|
|
71
71
|
size: 20
|
|
72
72
|
}),
|
|
@@ -78,11 +78,11 @@ var W = ({ copy: o, leading: t }) => /* @__PURE__ */ r(a, {
|
|
|
78
78
|
children: [/* @__PURE__ */ e(i, {
|
|
79
79
|
sx: { fontWeight: 600 },
|
|
80
80
|
variant: "body1",
|
|
81
|
-
children:
|
|
81
|
+
children: d(t)
|
|
82
82
|
}), /* @__PURE__ */ e(i, {
|
|
83
83
|
sx: { color: "text.secondary" },
|
|
84
84
|
variant: "caption",
|
|
85
|
-
children:
|
|
85
|
+
children: l.expenses_text
|
|
86
86
|
})]
|
|
87
87
|
})
|
|
88
88
|
]
|
|
@@ -97,15 +97,15 @@ var W = ({ copy: o, leading: t }) => /* @__PURE__ */ r(a, {
|
|
|
97
97
|
children: [/* @__PURE__ */ r(i, {
|
|
98
98
|
sx: { color: "text.secondary" },
|
|
99
99
|
variant: "body2",
|
|
100
|
-
children: [
|
|
100
|
+
children: [l.total_remaining_text, ":"]
|
|
101
101
|
}), /* @__PURE__ */ e(i, {
|
|
102
102
|
sx: { fontWeight: 600 },
|
|
103
103
|
variant: "body2",
|
|
104
|
-
children:
|
|
104
|
+
children: d(n)
|
|
105
105
|
})]
|
|
106
106
|
})]
|
|
107
107
|
})
|
|
108
|
-
}),
|
|
108
|
+
}), T = ({ availableBalances: o, date: t, copy: n }) => /* @__PURE__ */ r(a, {
|
|
109
109
|
sx: {
|
|
110
110
|
px: 24,
|
|
111
111
|
py: 14,
|
|
@@ -115,7 +115,7 @@ var W = ({ copy: o, leading: t }) => /* @__PURE__ */ r(a, {
|
|
|
115
115
|
children: [/* @__PURE__ */ e(i, {
|
|
116
116
|
truncate: !1,
|
|
117
117
|
variant: "h3",
|
|
118
|
-
children:
|
|
118
|
+
children: d(o)
|
|
119
119
|
}), t && /* @__PURE__ */ e(i, {
|
|
120
120
|
sx: {
|
|
121
121
|
color: "text.secondary",
|
|
@@ -123,14 +123,14 @@ var W = ({ copy: o, leading: t }) => /* @__PURE__ */ r(a, {
|
|
|
123
123
|
},
|
|
124
124
|
truncate: !1,
|
|
125
125
|
variant: "subtitle2",
|
|
126
|
-
children:
|
|
126
|
+
children: w(n.your_available_balances_text, t)
|
|
127
127
|
})]
|
|
128
|
-
}), B = ({ bodyContent: o, bodyDescription: t, monthsTable: n, deltaAmount:
|
|
129
|
-
const [
|
|
128
|
+
}), B = ({ bodyContent: o, bodyDescription: t, monthsTable: n, deltaAmount: l, initialAmount: c, seedAmount: s, copy: m }) => {
|
|
129
|
+
const h = s == null ? void 0 : Math.round(s), [p, x] = f.useState(c ?? h ?? 0);
|
|
130
130
|
f.useEffect(() => {
|
|
131
|
-
|
|
132
|
-
}, [
|
|
133
|
-
const
|
|
131
|
+
c == null && h != null && x(h);
|
|
132
|
+
}, [c, h]);
|
|
133
|
+
const u = n.length - 1;
|
|
134
134
|
return /* @__PURE__ */ r(_, { children: [/* @__PURE__ */ r(a, {
|
|
135
135
|
sx: {
|
|
136
136
|
p: 24,
|
|
@@ -141,11 +141,11 @@ var W = ({ copy: o, leading: t }) => /* @__PURE__ */ r(a, {
|
|
|
141
141
|
truncate: !1,
|
|
142
142
|
variant: "body1",
|
|
143
143
|
children: o
|
|
144
|
-
}), /* @__PURE__ */ e(
|
|
145
|
-
amount:
|
|
144
|
+
}), /* @__PURE__ */ e(C, {
|
|
145
|
+
amount: d(p),
|
|
146
146
|
copy: m,
|
|
147
|
-
onDecrement: () =>
|
|
148
|
-
onIncrement: () =>
|
|
147
|
+
onDecrement: () => x((g) => Math.max(0, g - l)),
|
|
148
|
+
onIncrement: () => x((g) => g + l)
|
|
149
149
|
})]
|
|
150
150
|
}), /* @__PURE__ */ r(a, {
|
|
151
151
|
sx: { gap: 8 },
|
|
@@ -157,16 +157,16 @@ var W = ({ copy: o, leading: t }) => /* @__PURE__ */ r(a, {
|
|
|
157
157
|
truncate: !1,
|
|
158
158
|
variant: "body1",
|
|
159
159
|
children: t
|
|
160
|
-
}), /* @__PURE__ */ e(
|
|
160
|
+
}), /* @__PURE__ */ e(k, {
|
|
161
161
|
sx: {
|
|
162
162
|
bgcolor: "background.paper",
|
|
163
163
|
width: "100%"
|
|
164
164
|
},
|
|
165
|
-
children: n.map(({ label:
|
|
165
|
+
children: n.map(({ label: g, value: v }, y) => /* @__PURE__ */ r(f.Fragment, { children: [/* @__PURE__ */ e(L, {
|
|
166
166
|
disableGutters: !0,
|
|
167
167
|
disablePadding: !0,
|
|
168
168
|
sx: {
|
|
169
|
-
minHeight:
|
|
169
|
+
minHeight: 51,
|
|
170
170
|
bgcolor: "background.paper"
|
|
171
171
|
},
|
|
172
172
|
children: /* @__PURE__ */ e(a, {
|
|
@@ -183,62 +183,62 @@ var W = ({ copy: o, leading: t }) => /* @__PURE__ */ r(a, {
|
|
|
183
183
|
children: [/* @__PURE__ */ e(i, {
|
|
184
184
|
truncate: !1,
|
|
185
185
|
variant: "body1",
|
|
186
|
-
children:
|
|
186
|
+
children: g
|
|
187
187
|
}), /* @__PURE__ */ e(i, {
|
|
188
188
|
sx: { fontWeight: 600 },
|
|
189
189
|
truncate: !1,
|
|
190
190
|
variant: "body1",
|
|
191
|
-
children:
|
|
191
|
+
children: d(v * p)
|
|
192
192
|
})]
|
|
193
193
|
})
|
|
194
194
|
})
|
|
195
|
-
}), /* @__PURE__ */ e(
|
|
195
|
+
}), /* @__PURE__ */ e(E, {
|
|
196
196
|
component: "li",
|
|
197
|
-
sx: { ml: y ===
|
|
197
|
+
sx: { ml: y === u ? 0 : 24 }
|
|
198
198
|
})] }, v))
|
|
199
199
|
})]
|
|
200
200
|
})] });
|
|
201
|
-
},
|
|
202
|
-
const
|
|
201
|
+
}, z = ({ variant: o, slotData: t, copy: n }) => {
|
|
202
|
+
const l = o === A.SAVE_ENOUGH_TO_LIVE_ON, c = S[o], s = t?.available_balance, m = b(t?.avg_monthly_spend), h = b(t?.upcoming_expenses), p = b(t?.total_remaining), x = t?.time_period, u = t?.date;
|
|
203
203
|
return /* @__PURE__ */ r(_, { children: [
|
|
204
|
-
/* @__PURE__ */ e(
|
|
204
|
+
/* @__PURE__ */ e(O, {
|
|
205
205
|
copy: n,
|
|
206
|
-
leading:
|
|
207
|
-
content:
|
|
208
|
-
leftLabel: n.
|
|
209
|
-
leftValue:
|
|
210
|
-
rightLabel: n.
|
|
211
|
-
rightValue:
|
|
206
|
+
leading: l && s != null && m != null && x ? /* @__PURE__ */ e(I, {
|
|
207
|
+
content: x,
|
|
208
|
+
leftLabel: n.available_balance_text,
|
|
209
|
+
leftValue: d(s),
|
|
210
|
+
rightLabel: n.avg_monthly_spend_text,
|
|
211
|
+
rightValue: d(m),
|
|
212
212
|
sx: {
|
|
213
213
|
width: "100%",
|
|
214
214
|
mb: 24
|
|
215
215
|
}
|
|
216
216
|
}) : null
|
|
217
217
|
}),
|
|
218
|
-
!
|
|
219
|
-
availableBalances:
|
|
218
|
+
!l && s != null && h != null && /* @__PURE__ */ e(R, {
|
|
219
|
+
availableBalances: s,
|
|
220
220
|
copy: n,
|
|
221
|
-
expenses:
|
|
221
|
+
expenses: h,
|
|
222
222
|
totalRemaining: p
|
|
223
223
|
}),
|
|
224
224
|
/* @__PURE__ */ e(B, {
|
|
225
|
-
bodyContent: n[
|
|
226
|
-
bodyDescription: n[
|
|
225
|
+
bodyContent: n[c.contentKey],
|
|
226
|
+
bodyDescription: n[c.descriptionKey],
|
|
227
227
|
copy: n,
|
|
228
|
-
deltaAmount:
|
|
229
|
-
initialAmount:
|
|
230
|
-
monthsTable:
|
|
231
|
-
seedAmount:
|
|
228
|
+
deltaAmount: c.deltaAmount,
|
|
229
|
+
initialAmount: c.initialAmount,
|
|
230
|
+
monthsTable: c.months,
|
|
231
|
+
seedAmount: c.initialAmount == null ? m : void 0
|
|
232
232
|
}),
|
|
233
|
-
|
|
234
|
-
availableBalances:
|
|
233
|
+
l && s != null && /* @__PURE__ */ e(T, {
|
|
234
|
+
availableBalances: s,
|
|
235
235
|
copy: n,
|
|
236
|
-
date:
|
|
236
|
+
date: u
|
|
237
237
|
})
|
|
238
238
|
] });
|
|
239
239
|
};
|
|
240
240
|
export {
|
|
241
|
-
|
|
241
|
+
z as MakeTransferActionBlock
|
|
242
242
|
};
|
|
243
243
|
|
|
244
244
|
//# sourceMappingURL=MakeTransferActionBlock.es.js.map
|
package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/MakeTransferActionBlock.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MakeTransferActionBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/MakeTransferActionBlock/MakeTransferActionBlock.tsx"],"sourcesContent":["import React, { type ReactNode } from 'react'\nimport { Card, Divider, List, ListItem, Stack } from '@mui/material'\nimport { Icon } from '@mxenabled/mx-icons'\n\nimport { Text } from '@mxenabled/mxui'\n\nimport { buildDynamicCopy, type MakeTransferCopy } from '../../../core'\nimport { CURRENCY_FORMAT, formatCurrency } from '../../../core/utils/NumberFormatting'\n\nimport { BalanceStepper } from './BalanceStepper'\nimport SaveEnoughToLiveOnBottomSection from './SaveEnoughToLiveOnBottomSection'\nimport {\n PROJECTIONS,\n toNumber,\n variants,\n type MakeTransferVariant,\n type MakeTransferVariantProps,\n type MonthRow,\n} from './layout'\n\n// ============================================================================\n// Section building blocks (block-local)\n// ============================================================================\n\n/** Bordered title + description, with an optional `leading` slot. */\nconst Header = ({ copy, leading }: { copy: MakeTransferCopy; leading?: ReactNode }) => (\n <Stack\n sx={{ bgcolor: 'background.paper', p: 24, borderBottom: '1px solid', borderColor: 'divider' }}\n >\n {leading}\n <Stack sx={{ gap: 8 }}>\n <Text variant=\"h3\">{copy.header_content}</Text>\n <Text sx={{ lineHeight: '24px' }} truncate={false} variant=\"body1\">\n {copy.description}\n </Text>\n </Stack>\n </Stack>\n)\n\n/** Save-extra only: available − expenses = total remaining. */\nconst RemainingCard = ({\n availableBalances,\n expenses,\n totalRemaining,\n copy,\n}: {\n availableBalances: number\n expenses: number\n totalRemaining?: number\n copy: MakeTransferCopy\n}) => (\n <Stack sx={{ pt: 24, px: 24 }}>\n <Card sx={{ px: 16, pt: 16, pb: 12 }}>\n <Stack\n sx={{\n border: 1,\n borderColor: 'divider',\n borderRadius: '4px',\n gap: 12,\n flexDirection: 'row',\n justifyContent: 'space-between',\n alignItems: 'center',\n p: 8,\n mb: 12,\n }}\n >\n <Stack sx={{ width: 155, textAlign: 'center' }}>\n <Text sx={{ fontWeight: 600 }} variant=\"body1\">\n {formatCurrency(availableBalances, CURRENCY_FORMAT.cents)}\n </Text>\n <Text sx={{ color: 'text.secondary' }} variant=\"caption\">\n {copy.available_text}\n </Text>\n </Stack>\n <Icon name=\"remove\" size={20} />\n <Stack sx={{ width: 155, textAlign: 'center' }}>\n <Text sx={{ fontWeight: 600 }} variant=\"body1\">\n {formatCurrency(expenses, CURRENCY_FORMAT.cents)}\n </Text>\n <Text sx={{ color: 'text.secondary' }} variant=\"caption\">\n {copy.expenses_text}\n </Text>\n </Stack>\n </Stack>\n <Stack\n sx={{\n textAlign: 'center',\n flexDirection: 'row',\n justifyContent: 'center',\n alignItems: 'center',\n gap: 4,\n }}\n >\n <Text sx={{ color: 'text.secondary' }} variant=\"body2\">\n {copy.total_remaining_text}:\n </Text>\n <Text sx={{ fontWeight: 600 }} variant=\"body2\">\n {formatCurrency(totalRemaining, CURRENCY_FORMAT.cents)}\n </Text>\n </Stack>\n </Card>\n </Stack>\n)\n\n/** Save-enough only: total available balances as of a date. */\nconst TotalsFooter = ({\n availableBalances,\n date,\n copy,\n}: {\n availableBalances: number\n date?: string\n copy: MakeTransferCopy\n}) => (\n <Stack sx={{ px: 24, py: 14, textAlign: 'right', gap: 4 }}>\n <Text truncate={false} variant=\"h3\">\n {formatCurrency(availableBalances, CURRENCY_FORMAT.cents)}\n </Text>\n {date && (\n <Text sx={{ color: 'text.secondary', fontWeight: 400 }} truncate={false} variant=\"subtitle2\">\n {buildDynamicCopy(copy.your_available_balances_text, date) as string}\n </Text>\n )}\n </Stack>\n)\n\n/** Stepper + projected-savings table. Owns the amount state so both stay in sync. */\nconst SavingsProjection = ({\n bodyContent,\n bodyDescription,\n monthsTable,\n deltaAmount,\n initialAmount,\n seedAmount,\n copy,\n}: {\n bodyContent: string\n bodyDescription: string\n monthsTable: readonly MonthRow[]\n deltaAmount: number\n /** Fixed starting amount; when null, seeds from `seedAmount` once it resolves. */\n initialAmount: number | null\n seedAmount?: number\n copy: MakeTransferCopy\n}) => {\n const [amount, setAmount] = React.useState(initialAmount ?? seedAmount ?? 0)\n\n React.useEffect(() => {\n if (initialAmount == null && seedAmount != null) {\n setAmount(seedAmount)\n }\n }, [initialAmount, seedAmount])\n\n const lastRowIndex = monthsTable.length - 1\n\n return (\n <>\n <Stack sx={{ p: 24, gap: 8 }}>\n <Text sx={{ fontWeight: 600 }} truncate={false} variant=\"body1\">\n {bodyContent}\n </Text>\n <BalanceStepper\n amount={formatCurrency(amount, CURRENCY_FORMAT.cents)}\n copy={copy}\n onDecrement={() => setAmount((prev) => Math.max(0, prev - deltaAmount))}\n onIncrement={() => setAmount((prev) => prev + deltaAmount)}\n />\n </Stack>\n <Stack sx={{ gap: 8 }}>\n <Text sx={{ fontWeight: 600, mx: 24 }} truncate={false} variant=\"body1\">\n {bodyDescription}\n </Text>\n <List sx={{ bgcolor: 'background.paper', width: '100%' }}>\n {monthsTable.map(({ label, value }, index) => (\n <React.Fragment key={value}>\n <ListItem\n disableGutters={true}\n disablePadding={true}\n sx={{ minHeight: 52, bgcolor: 'background.paper' }}\n >\n <Stack sx={{ width: '100%' }}>\n <Stack\n sx={{\n flexDirection: 'row',\n justifyContent: 'space-between',\n alignItems: 'center',\n width: '100%',\n px: 24,\n py: 8,\n }}\n >\n <Text truncate={false} variant=\"body1\">\n {label}\n </Text>\n <Text sx={{ fontWeight: 600 }} truncate={false} variant=\"body1\">\n {formatCurrency(value * amount, CURRENCY_FORMAT.whole)}\n </Text>\n </Stack>\n </Stack>\n </ListItem>\n <Divider component=\"li\" sx={{ ml: index === lastRowIndex ? 0 : 24 }} />\n </React.Fragment>\n ))}\n </List>\n </Stack>\n </>\n )\n}\n\n// ============================================================================\n// Block — both variants share the header and the stepper/table (settings from\n// PROJECTIONS in layout.ts); only the sections around them differ.\n// ============================================================================\n\nexport const MakeTransferActionBlock = ({\n variant,\n slotData,\n copy,\n}: MakeTransferVariantProps & { variant: MakeTransferVariant }) => {\n const isSaveEnough = variant === variants.SAVE_ENOUGH_TO_LIVE_ON\n const projection = PROJECTIONS[variant]\n\n const availableBalances = slotData?.available_balance\n const averageMonthlySpend = toNumber(slotData?.avg_monthly_spend)\n const expenses = toNumber(slotData?.upcoming_expenses)\n const totalRemaining = toNumber(slotData?.total_remaining)\n const svgDateContent = slotData?.time_period\n const date = slotData?.date\n\n return (\n <>\n <Header\n copy={copy}\n leading={\n isSaveEnough &&\n availableBalances != null &&\n averageMonthlySpend != null &&\n svgDateContent ? (\n <SaveEnoughToLiveOnBottomSection\n content={svgDateContent}\n leftLabel={copy.available_balances_text}\n leftValue={formatCurrency(availableBalances, CURRENCY_FORMAT.cents)}\n rightLabel={copy.average_monthly_spend_text}\n rightValue={formatCurrency(averageMonthlySpend, CURRENCY_FORMAT.cents)}\n sx={{ width: '100%', mb: 24 }}\n />\n ) : null\n }\n />\n\n {!isSaveEnough && availableBalances != null && expenses != null && (\n <RemainingCard\n availableBalances={availableBalances}\n copy={copy}\n expenses={expenses}\n totalRemaining={totalRemaining}\n />\n )}\n\n <SavingsProjection\n bodyContent={copy[projection.contentKey]}\n bodyDescription={copy[projection.descriptionKey]}\n copy={copy}\n deltaAmount={projection.deltaAmount}\n initialAmount={projection.initialAmount}\n monthsTable={projection.months}\n seedAmount={projection.initialAmount == null ? averageMonthlySpend : undefined}\n />\n\n {isSaveEnough && availableBalances != null && (\n <TotalsFooter availableBalances={availableBalances} copy={copy} date={date} />\n )}\n </>\n )\n}\n"],"mappings":";;;;;;;;;;AAyBA,IAAM,IAAA,CAAU,EAAE,MAAA,GAAM,SAAA,EAAA,MACtB,gBAAA,EAAC,GAAD;AAAA,EACE,IAAI;AAAA,IAAE,SAAS;AAAA,IAAoB,GAAG;AAAA,IAAI,cAAc;AAAA,IAAa,aAAa;AAAA,EAAU;AAAA,EAD9F,UAAA,CAGG,GACD,gBAAA,EAAC,GAAD;AAAA,IAAO,IAAI,EAAE,KAAK,EAAE;AAAA,IAApB,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,MAAM,SAAQ;AAAA,MAAM,UAAA,EAAK;AAAA,IAAqB,CAAA,GAC9C,gBAAA,EAAC,GAAD;AAAA,MAAM,IAAI,EAAE,YAAY,OAAO;AAAA,MAAG,UAAU;AAAA,MAAO,SAAQ;AAAA,MACxD,UAAA,EAAK;AAAA,IACF,CAAA,CACD;AAAA,EACF,CAAA,CAAA;IAIH,IAAA,CAAiB,EACrB,mBAAA,GACA,UAAA,GACA,gBAAA,GACA,MAAA,EAAA,MAOA,gBAAA,EAAC,GAAD;AAAA,EAAO,IAAI;AAAA,IAAE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,MAAA;AAAA,MACN,SACE,KACA,KAAqB,QACrB,KAAuB,QACvB,IACE,gBAAA,EAAC,GAAD;AAAA,QACE,SAAS;AAAA,QACT,WAAW,EAAK;AAAA,QAChB,WAAW,EAAe,GAAmB,EAAgB,KAAK;AAAA,QAClE,YAAY,EAAK;AAAA,QACjB,YAAY,EAAe,GAAqB,EAAgB,KAAK;AAAA,QACrE,IAAI;AAAA,UAAE,OAAO;AAAA,UAAQ,IAAI;AAAA,QAAG;AAAA,MAC7B,CAAA,IACC;AAAA,IAEP,CAAA;AAAA,IAEA,CAAC,KAAgB,KAAqB,QAAQ,KAAY,QACzD,gBAAA,EAAC,GAAD;AAAA,MACqB,mBAAA;AAAA,MACb,MAAA;AAAA,MACI,UAAA;AAAA,MACM,gBAAA;AAAA,IACjB,CAAA;AAAA,IAGH,gBAAA,EAAC,GAAD;AAAA,MACE,aAAa,EAAK,EAAW,UAAA;AAAA,MAC7B,iBAAiB,EAAK,EAAW,cAAA;AAAA,MAC3B,MAAA;AAAA,MACN,aAAa,EAAW;AAAA,MACxB,eAAe,EAAW;AAAA,MAC1B,aAAa,EAAW;AAAA,MACxB,YAAY,EAAW,iBAAiB,OAAO,IAAsB;AAAA,IACtE,CAAA;AAAA,IAEA,KAAgB,KAAqB,QACpC,gBAAA,EAAC,GAAD;AAAA,MAAiC,mBAAA;AAAA,MAAyB,MAAA;AAAA,MAAY,MAAA;AAAA,IAAO,CAAA;AAAA,EAE/E,EAAA,CAAA;AAEN"}
|
|
1
|
+
{"version":3,"file":"MakeTransferActionBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/MakeTransferActionBlock/MakeTransferActionBlock.tsx"],"sourcesContent":["import React, { type ReactNode } from 'react'\nimport { Card, Divider, List, ListItem, Stack } from '@mui/material'\nimport { Icon } from '@mxenabled/mx-icons'\n\nimport { Text } from '@mxenabled/mxui'\n\nimport { buildDynamicCopy, type MakeTransferCopy } from '../../../core'\nimport { formatWholeCurrency } from '../../../core/utils/NumberFormatting'\n\nimport { BalanceStepper } from './BalanceStepper'\nimport SaveEnoughToLiveOnBottomSection from './SaveEnoughToLiveOnBottomSection'\nimport {\n PROJECTIONS,\n toNumber,\n variants,\n type MakeTransferVariant,\n type MakeTransferVariantProps,\n type MonthRow,\n} from './layout'\n\n// ============================================================================\n// Section building blocks (block-local)\n// ============================================================================\n\n/** Bordered title + description, with an optional `leading` slot. */\nconst Header = ({ copy, leading }: { copy: MakeTransferCopy; leading?: ReactNode }) => (\n <Stack\n sx={{ bgcolor: 'background.paper', p: 24, borderBottom: '1px solid', borderColor: 'divider' }}\n >\n {leading}\n <Stack sx={{ gap: 8 }}>\n <Text variant=\"h3\">{copy.header_content}</Text>\n <Text sx={{ lineHeight: '24px' }} truncate={false} variant=\"body1\">\n {copy.description}\n </Text>\n </Stack>\n </Stack>\n)\n\n/** Save-extra only: available − expenses = total remaining. */\nconst RemainingCard = ({\n availableBalances,\n expenses,\n totalRemaining,\n copy,\n}: {\n availableBalances: number\n expenses: number\n totalRemaining?: number\n copy: MakeTransferCopy\n}) => (\n <Stack sx={{ pt: 24, px: 24 }}>\n <Card sx={{ px: 16, pt: 16, pb: 12 }}>\n <Stack\n sx={{\n border: 1,\n borderColor: 'divider',\n borderRadius: '4px',\n gap: 12,\n flexDirection: 'row',\n justifyContent: 'space-between',\n alignItems: 'center',\n p: 8,\n mb: 12,\n }}\n >\n <Stack sx={{ width: 155, textAlign: 'center' }}>\n <Text sx={{ fontWeight: 600 }} variant=\"body1\">\n {formatWholeCurrency(availableBalances)}\n </Text>\n <Text sx={{ color: 'text.secondary' }} variant=\"caption\">\n {copy.available_text}\n </Text>\n </Stack>\n <Icon name=\"remove\" size={20} />\n <Stack sx={{ width: 155, textAlign: 'center' }}>\n <Text sx={{ fontWeight: 600 }} variant=\"body1\">\n {formatWholeCurrency(expenses)}\n </Text>\n <Text sx={{ color: 'text.secondary' }} variant=\"caption\">\n {copy.expenses_text}\n </Text>\n </Stack>\n </Stack>\n <Stack\n sx={{\n textAlign: 'center',\n flexDirection: 'row',\n justifyContent: 'center',\n alignItems: 'center',\n gap: 4,\n }}\n >\n <Text sx={{ color: 'text.secondary' }} variant=\"body2\">\n {copy.total_remaining_text}:\n </Text>\n <Text sx={{ fontWeight: 600 }} variant=\"body2\">\n {formatWholeCurrency(totalRemaining)}\n </Text>\n </Stack>\n </Card>\n </Stack>\n)\n\n/** Save-enough only: total available balances as of a date. */\nconst TotalsFooter = ({\n availableBalances,\n date,\n copy,\n}: {\n availableBalances: number\n date?: string\n copy: MakeTransferCopy\n}) => (\n <Stack sx={{ px: 24, py: 14, textAlign: 'right', gap: 4 }}>\n <Text truncate={false} variant=\"h3\">\n {formatWholeCurrency(availableBalances)}\n </Text>\n {date && (\n <Text sx={{ color: 'text.secondary', fontWeight: 400 }} truncate={false} variant=\"subtitle2\">\n {buildDynamicCopy(copy.your_available_balances_text, date) as string}\n </Text>\n )}\n </Stack>\n)\n\n/** Stepper + projected-savings table. Owns the amount state so both stay in sync. */\nconst SavingsProjection = ({\n bodyContent,\n bodyDescription,\n monthsTable,\n deltaAmount,\n initialAmount,\n seedAmount,\n copy,\n}: {\n bodyContent: string\n bodyDescription: string\n monthsTable: readonly MonthRow[]\n deltaAmount: number\n /** Fixed starting amount; when null, seeds from `seedAmount` once it resolves. */\n initialAmount: number | null\n seedAmount?: number\n copy: MakeTransferCopy\n}) => {\n // Whole dollars, so the stepper times each month equals that row's amount.\n const seed = seedAmount == null ? undefined : Math.round(seedAmount)\n const [amount, setAmount] = React.useState(initialAmount ?? seed ?? 0)\n\n React.useEffect(() => {\n if (initialAmount == null && seed != null) {\n setAmount(seed)\n }\n }, [initialAmount, seed])\n\n const lastRowIndex = monthsTable.length - 1\n\n return (\n <>\n <Stack sx={{ p: 24, gap: 8 }}>\n <Text sx={{ fontWeight: 600 }} truncate={false} variant=\"body1\">\n {bodyContent}\n </Text>\n <BalanceStepper\n amount={formatWholeCurrency(amount)}\n copy={copy}\n onDecrement={() => setAmount((prev) => Math.max(0, prev - deltaAmount))}\n onIncrement={() => setAmount((prev) => prev + deltaAmount)}\n />\n </Stack>\n <Stack sx={{ gap: 8 }}>\n <Text sx={{ fontWeight: 600, mx: 24 }} truncate={false} variant=\"body1\">\n {bodyDescription}\n </Text>\n <List sx={{ bgcolor: 'background.paper', width: '100%' }}>\n {monthsTable.map(({ label, value }, index) => (\n <React.Fragment key={value}>\n <ListItem\n disableGutters={true}\n disablePadding={true}\n // With its 1px divider, each row is Figma's 52px.\n sx={{ minHeight: 51, bgcolor: 'background.paper' }}\n >\n <Stack sx={{ width: '100%' }}>\n <Stack\n sx={{\n flexDirection: 'row',\n justifyContent: 'space-between',\n alignItems: 'center',\n width: '100%',\n px: 24,\n py: 8,\n }}\n >\n <Text truncate={false} variant=\"body1\">\n {label}\n </Text>\n <Text sx={{ fontWeight: 600 }} truncate={false} variant=\"body1\">\n {formatWholeCurrency(value * amount)}\n </Text>\n </Stack>\n </Stack>\n </ListItem>\n <Divider component=\"li\" sx={{ ml: index === lastRowIndex ? 0 : 24 }} />\n </React.Fragment>\n ))}\n </List>\n </Stack>\n </>\n )\n}\n\n// ============================================================================\n// Block — both variants share the header and the stepper/table (settings from\n// PROJECTIONS in layout.ts); only the sections around them differ.\n// ============================================================================\n\nexport const MakeTransferActionBlock = ({\n variant,\n slotData,\n copy,\n}: MakeTransferVariantProps & { variant: MakeTransferVariant }) => {\n const isSaveEnough = variant === variants.SAVE_ENOUGH_TO_LIVE_ON\n const projection = PROJECTIONS[variant]\n\n const availableBalances = slotData?.available_balance\n const averageMonthlySpend = toNumber(slotData?.avg_monthly_spend)\n const expenses = toNumber(slotData?.upcoming_expenses)\n const totalRemaining = toNumber(slotData?.total_remaining)\n const svgDateContent = slotData?.time_period\n const date = slotData?.date\n\n return (\n <>\n <Header\n copy={copy}\n leading={\n isSaveEnough &&\n availableBalances != null &&\n averageMonthlySpend != null &&\n svgDateContent ? (\n <SaveEnoughToLiveOnBottomSection\n content={svgDateContent}\n leftLabel={copy.available_balance_text}\n leftValue={formatWholeCurrency(availableBalances)}\n rightLabel={copy.avg_monthly_spend_text}\n rightValue={formatWholeCurrency(averageMonthlySpend)}\n sx={{ width: '100%', mb: 24 }}\n />\n ) : null\n }\n />\n\n {!isSaveEnough && availableBalances != null && expenses != null && (\n <RemainingCard\n availableBalances={availableBalances}\n copy={copy}\n expenses={expenses}\n totalRemaining={totalRemaining}\n />\n )}\n\n <SavingsProjection\n bodyContent={copy[projection.contentKey]}\n bodyDescription={copy[projection.descriptionKey]}\n copy={copy}\n deltaAmount={projection.deltaAmount}\n initialAmount={projection.initialAmount}\n monthsTable={projection.months}\n seedAmount={projection.initialAmount == null ? averageMonthlySpend : undefined}\n />\n\n {isSaveEnough && availableBalances != null && (\n <TotalsFooter availableBalances={availableBalances} copy={copy} date={date} />\n )}\n </>\n )\n}\n"],"mappings":";;;;;;;;;;AAyBA,IAAM,IAAA,CAAU,EAAE,MAAA,GAAM,SAAA,EAAA,MACtB,gBAAA,EAAC,GAAD;AAAA,EACE,IAAI;AAAA,IAAE,SAAS;AAAA,IAAoB,GAAG;AAAA,IAAI,cAAc;AAAA,IAAa,aAAa;AAAA,EAAU;AAAA,EAD9F,UAAA,CAGG,GACD,gBAAA,EAAC,GAAD;AAAA,IAAO,IAAI,EAAE,KAAK,EAAE;AAAA,IAApB,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,MAAM,SAAQ;AAAA,MAAM,UAAA,EAAK;AAAA,IAAqB,CAAA,GAC9C,gBAAA,EAAC,GAAD;AAAA,MAAM,IAAI,EAAE,YAAY,OAAO;AAAA,MAAG,UAAU;AAAA,MAAO,SAAQ;AAAA,MACxD,UAAA,EAAK;AAAA,IACF,CAAA,CACD;AAAA,EACF,CAAA,CAAA;IAIH,IAAA,CAAiB,EACrB,mBAAA,GACA,UAAA,GACA,gBAAA,GACA,MAAA,EAAA,MAOA,gBAAA,EAAC,GAAD;AAAA,EAAO,IAAI;AAAA,IAAE,IAAI;AAAA,IAAI,IAA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uB,QACvB,IACE,gBAAA,EAAC,GAAD;AAAA,QACE,SAAS;AAAA,QACT,WAAW,EAAK;AAAA,QAChB,WAAW,EAAoB,CAAiB;AAAA,QAChD,YAAY,EAAK;AAAA,QACjB,YAAY,EAAoB,CAAmB;AAAA,QACnD,IAAI;AAAA,UAAE,OAAO;AAAA,UAAQ,IAAI;AAAA,QAAG;AAAA,MAC7B,CAAA,IACC;AAAA,IAEP,CAAA;AAAA,IAEA,CAAC,KAAgB,KAAqB,QAAQ,KAAY,QACzD,gBAAA,EAAC,GAAD;AAAA,MACqB,mBAAA;AAAA,MACb,MAAA;AAAA,MACI,UAAA;AAAA,MACM,gBAAA;AAAA,IACjB,CAAA;AAAA,IAGH,gBAAA,EAAC,GAAD;AAAA,MACE,aAAa,EAAK,EAAW,UAAA;AAAA,MAC7B,iBAAiB,EAAK,EAAW,cAAA;AAAA,MAC3B,MAAA;AAAA,MACN,aAAa,EAAW;AAAA,MACxB,eAAe,EAAW;AAAA,MAC1B,aAAa,EAAW;AAAA,MACxB,YAAY,EAAW,iBAAiB,OAAO,IAAsB;AAAA,IACtE,CAAA;AAAA,IAEA,KAAgB,KAAqB,QACpC,gBAAA,EAAC,GAAD;AAAA,MAAiC,mBAAA;AAAA,MAAyB,MAAA;AAAA,MAAY,MAAA;AAAA,IAAO,CAAA;AAAA,EAE/E,EAAA,CAAA;AAEN"}
|
|
@@ -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;
|