@mx-cartographer/experiences 9.7.204 → 9.7.206-alpha-harini-des
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/core/types/Insights.d.ts +9 -1
- package/dist/core/types/Insights.es.js.map +1 -1
- package/dist/core/types/localization/InsightsFeedCopy.d.ts +8 -0
- package/dist/core/types/localization/index.d.ts +1 -1
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js +10 -10
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.es.js +24 -23
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsV2.es.js +17 -17
- package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsV2.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/BalanceStepper.es.js +9 -10
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/BalanceStepper.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/SaveEnoughToLiveOnBottomSection.es.js +21 -22
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/SaveEnoughToLiveOnBottomSection.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffCalculatorBlock.es.js +35 -35
- package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffCalculatorBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffResults.d.ts +1 -1
- package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffResults.es.js +44 -49
- package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffResults.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TopMerchantsBlock/TopMerchantsBlock.d.ts +1 -5
- package/dist/insights-v2/actionBlocks/TopMerchantsBlock/TopMerchantsBlock.es.js +37 -36
- package/dist/insights-v2/actionBlocks/TopMerchantsBlock/TopMerchantsBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionDetailsBlock/layout.d.ts +9 -11
- package/dist/insights-v2/actionBlocks/TransactionDetailsBlock/layout.es.js +12 -6
- package/dist/insights-v2/actionBlocks/TransactionDetailsBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +119 -108
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.d.ts +8 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js +161 -126
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.d.ts +2 -0
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListBlock.es.js +54 -53
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListHeaderIconTile.d.ts +6 -1
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListHeaderIconTile.es.js +14 -13
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListHeaderIconTile.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListSummaryCard.d.ts +4 -3
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListSummaryCard.es.js +24 -21
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListSummaryCard.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionListBlock/layout.d.ts +12 -4
- package/dist/insights-v2/actionBlocks/TransactionListBlock/layout.es.js +80 -70
- package/dist/insights-v2/actionBlocks/TransactionListBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChart.d.ts +3 -1
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChart.es.js +48 -32
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChart.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/layout.d.ts +4 -0
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/layout.es.js +19 -15
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/StepChartBlock/variants/MilestoneProgress.d.ts +2 -4
- package/dist/insights-v2/blocks/ChartBlocks/StepChartBlock/variants/MilestoneProgress.es.js +78 -82
- package/dist/insights-v2/blocks/ChartBlocks/StepChartBlock/variants/MilestoneProgress.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/layout.es.js +27 -22
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/CompactDirectDepositBlock/CompactDirectDepositBlock.d.ts +7 -0
- package/dist/insights-v2/blocks/ComponentBlocks/CompactDirectDepositBlock/CompactDirectDepositBlock.es.js +46 -0
- package/dist/insights-v2/blocks/ComponentBlocks/CompactDirectDepositBlock/CompactDirectDepositBlock.es.js.map +1 -0
- package/dist/insights-v2/blocks/ComponentBlocks/CompactDirectDepositBlock/index.d.ts +3 -0
- package/dist/insights-v2/blocks/ComponentBlocks/CompactDirectDepositBlock/layout.d.ts +13 -0
- package/dist/insights-v2/blocks/ComponentBlocks/CompactDirectDepositBlock/layout.es.js +22 -0
- package/dist/insights-v2/blocks/ComponentBlocks/CompactDirectDepositBlock/layout.es.js.map +1 -0
- package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/DetailedAccountBlock.es.js +29 -21
- package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/DetailedAccountBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/layout.d.ts +0 -2
- package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/layout.es.js +17 -21
- package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.es.js +46 -63
- package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/layout.d.ts +3 -3
- package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/layout.es.js +44 -53
- package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/QuarterlySummaryBlock/QuarterlySummaryBlock.d.ts +3 -1
- package/dist/insights-v2/blocks/ComponentBlocks/QuarterlySummaryBlock/QuarterlySummaryBlock.es.js +50 -38
- package/dist/insights-v2/blocks/ComponentBlocks/QuarterlySummaryBlock/QuarterlySummaryBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/QuizBlock/QuizBlock.d.ts +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/QuizBlock/QuizBlock.es.js +26 -27
- package/dist/insights-v2/blocks/ComponentBlocks/QuizBlock/QuizBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/SaveExtraBlock/SaveExtraBlock.es.js +25 -20
- package/dist/insights-v2/blocks/ComponentBlocks/SaveExtraBlock/SaveExtraBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/SaveExtraBlock/layout.d.ts +22 -0
- package/dist/insights-v2/blocks/ComponentBlocks/SaveExtraBlock/layout.es.js +24 -0
- package/dist/insights-v2/blocks/ComponentBlocks/SaveExtraBlock/layout.es.js.map +1 -0
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js +54 -53
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/layout.d.ts +5 -3
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/layout.es.js +11 -9
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/WeeklySmallPurchasesBlock/WeeklySmallPurchasesBlock.es.js +29 -28
- package/dist/insights-v2/blocks/ComponentBlocks/WeeklySmallPurchasesBlock/WeeklySmallPurchasesBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/index.d.ts +1 -0
- package/dist/insights-v2/blocks/ImageBlocks/ImageBlock.es.js +6 -5
- package/dist/insights-v2/blocks/ImageBlocks/ImageBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/layout.es.js +1 -1
- package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/components/AccountHeroCard.d.ts +3 -1
- package/dist/insights-v2/components/AccountHeroCard.es.js.map +1 -1
- package/dist/insights-v2/components/BaseLayout.d.ts +3 -1
- package/dist/insights-v2/components/BaseLayout.es.js +76 -76
- package/dist/insights-v2/components/BaseLayout.es.js.map +1 -1
- package/dist/insights-v2/components/CompactDirectDepositCard.d.ts +28 -0
- package/dist/insights-v2/components/CompactDirectDepositCard.es.js +78 -0
- package/dist/insights-v2/components/CompactDirectDepositCard.es.js.map +1 -0
- package/dist/insights-v2/components/CompactInsightCard.es.js +122 -118
- package/dist/insights-v2/components/CompactInsightCard.es.js.map +1 -1
- package/dist/insights-v2/components/DirectDepositCard.d.ts +6 -1
- package/dist/insights-v2/components/DirectDepositCard.es.js +22 -20
- package/dist/insights-v2/components/DirectDepositCard.es.js.map +1 -1
- package/dist/insights-v2/components/LoadingCard.es.js +13 -9
- package/dist/insights-v2/components/LoadingCard.es.js.map +1 -1
- package/dist/insights-v2/components/LogoFromGuid.d.ts +1 -1
- package/dist/insights-v2/components/LogoFromGuid.es.js.map +1 -1
- package/dist/insights-v2/components/MerchantHighlightCard.es.js +4 -4
- package/dist/insights-v2/components/SaveAnExtraCard.d.ts +4 -1
- package/dist/insights-v2/components/SaveAnExtraCard.es.js +32 -20
- package/dist/insights-v2/components/SaveAnExtraCard.es.js.map +1 -1
- package/dist/insights-v2/components/TransactionListCard.d.ts +3 -1
- package/dist/insights-v2/components/TransactionListCard.es.js +25 -25
- package/dist/insights-v2/components/TransactionListCard.es.js.map +1 -1
- package/dist/insights-v2/components/TransferLogoCard.es.js +1 -0
- package/dist/insights-v2/components/TransferLogoCard.es.js.map +1 -1
- package/dist/insights-v2/components/UpcomingBillCard.es.js +39 -35
- package/dist/insights-v2/components/UpcomingBillCard.es.js.map +1 -1
- package/dist/insights-v2/components/celebrationGradients.d.ts +17 -8
- package/dist/insights-v2/components/celebrationGradients.es.js +14 -14
- package/dist/insights-v2/components/celebrationGradients.es.js.map +1 -1
- package/dist/insights-v2/components/shared/images/DesignateEmergencySavings.es.js +2 -3
- package/dist/insights-v2/components/shared/images/DesignateEmergencySavings.es.js.map +1 -1
- package/dist/insights-v2/ctaActions/ctaHandlers.d.ts +4 -1
- package/dist/insights-v2/ctaActions/ctaHandlers.es.js +69 -54
- package/dist/insights-v2/ctaActions/ctaHandlers.es.js.map +1 -1
- package/dist/insights-v2/ctaActions/ctaPostMessages.es.js +31 -21
- package/dist/insights-v2/ctaActions/ctaPostMessages.es.js.map +1 -1
- package/dist/insights-v2/index.es.js +127 -123
- package/dist/insights-v2/mappings/blocks.es.js +119 -117
- package/dist/insights-v2/mappings/blocks.es.js.map +1 -1
- package/dist/microinsights/MicroCardTemplate.es.js +1 -1
- package/dist/microinsights/MicroCardTemplate.es.js.map +1 -1
- package/dist/microinsights/cards/InsightCard.es.js +53 -53
- package/dist/microinsights/cards/InsightCard.es.js.map +1 -1
- package/package.json +1 -1
- package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/images/DesignateEmergencySavingsAccount.es.js +0 -296
- package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/images/DesignateEmergencySavingsAccount.es.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## [9.7.206] - 11-25-2026
|
|
2
|
+
|
|
3
|
+
- **ADDED** - QuarterlySummaryBlock component block, copy types, mock fixtures, and contract test (WEC-2363)
|
|
4
|
+
|
|
5
|
+
## [9.7.205] - 11-24-2026
|
|
6
|
+
|
|
7
|
+
- **ADDED** - Monthly Non-Essential Category Summary V2 drilldown support and guidance tip for essential vs flexible categories (WEC-2448)
|
|
8
|
+
|
|
1
9
|
## [9.7.204] - 11-24-2026
|
|
2
10
|
|
|
3
11
|
- **FIXED** - Debt Payment Reminder, P2P and Category Budget beats match Figma design QA (WEC-2440)
|
|
@@ -42,7 +42,7 @@ export type DrilldownRow = Record<string, string | number | boolean | null>;
|
|
|
42
42
|
* (memo, tags, hide, flag come from the transaction store). Values come from the server, so a reader
|
|
43
43
|
* still checks each value's runtime shape.
|
|
44
44
|
*/
|
|
45
|
-
export type DrilldownData = Record<string, string | number | boolean | null | string[] | DataSeries | DrilldownRow[]>;
|
|
45
|
+
export type DrilldownData = Record<string, string | number | boolean | null | string[] | DataSeries | DrilldownRow[] | LogoRef>;
|
|
46
46
|
export interface InsightsPayload {
|
|
47
47
|
widget_type: WidgetType;
|
|
48
48
|
instance_slot: InstanceSlot;
|
|
@@ -206,6 +206,10 @@ export interface PrimaryCTA {
|
|
|
206
206
|
*/
|
|
207
207
|
action_key?: string | null;
|
|
208
208
|
metadata?: CtaPostMessageMetadata | null;
|
|
209
|
+
/** tupac's flat host message for the CTA (`action` plus fields); see `InDescriptionCTA`. */
|
|
210
|
+
post_message_metadata?: ({
|
|
211
|
+
action?: string | null;
|
|
212
|
+
} & Record<string, unknown>) | null;
|
|
209
213
|
/** Figures this CTA's drilldown renders (e.g. a summary header's amount/dates/count). */
|
|
210
214
|
drilldown_data?: DrilldownData;
|
|
211
215
|
}
|
|
@@ -220,6 +224,10 @@ export interface SecondaryCTA {
|
|
|
220
224
|
/** See `PrimaryCTA.action_key` (ditto `secondary_cta_action`). */
|
|
221
225
|
action_key?: string | null;
|
|
222
226
|
metadata?: CtaPostMessageMetadata | null;
|
|
227
|
+
/** tupac's flat host message for the CTA (`action` plus fields); see `InDescriptionCTA`. */
|
|
228
|
+
post_message_metadata?: ({
|
|
229
|
+
action?: string | null;
|
|
230
|
+
} & Record<string, unknown>) | null;
|
|
223
231
|
/** Figures this CTA's drilldown renders (e.g. a summary header's amount/dates/count). */
|
|
224
232
|
drilldown_data?: DrilldownData;
|
|
225
233
|
}
|
|
@@ -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/** A row in a drilldown list fact (e.g. the Subscriptions drawer's per-transaction schedule). */\nexport type DrilldownRow = Record<string, string | number | boolean | null>\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, a `data_series` (the months a history drawer charts), or rows of scalars\n * (`transaction_frequencies`), omitted when the insight has none. Never carries copy or user actions\n * (memo, tags, hide, flag come from the transaction store). Values come from the server, so a reader\n * still checks each value's runtime shape.\n */\nexport type DrilldownData = Record<\n string,\n string | number | boolean | null | string[] | DataSeries | DrilldownRow[]\n>\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 QuarterlySummaryBlock: 'quarterly_summary_block',\n QuizBlock: 'quiz_block',\n FeedbackBlock: 'feedback_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 FeeChargedBlock: 'fee_charged_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":"AA0VA,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/** A row in a drilldown list fact (e.g. the Subscriptions drawer's per-transaction schedule). */\nexport type DrilldownRow = Record<string, string | number | boolean | null>\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, a `data_series` (the months a history drawer charts), or rows of scalars\n * (`transaction_frequencies`), omitted when the insight has none. Never carries copy or user actions\n * (memo, tags, hide, flag come from the transaction store). Values come from the server, so a reader\n * still checks each value's runtime shape.\n */\nexport type DrilldownData = Record<\n string,\n string | number | boolean | null | string[] | DataSeries | DrilldownRow[] | LogoRef\n>\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 /** tupac's flat host message for the CTA (`action` plus fields); see `InDescriptionCTA`. */\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 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 /** tupac's flat host message for the CTA (`action` plus fields); see `InDescriptionCTA`. */\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\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 QuarterlySummaryBlock: 'quarterly_summary_block',\n QuizBlock: 'quiz_block',\n FeedbackBlock: 'feedback_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 FeeChargedBlock: 'fee_charged_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":"AA8VA,IAAa,IAAA,CACX,GACA,MACkB,IAAO,CAAA"}
|
|
@@ -6,6 +6,8 @@ export interface GeneralInsightsFeedCopy {
|
|
|
6
6
|
decreased_text: string;
|
|
7
7
|
/** "Deposit": the deposit summary drawer's bar legend. */
|
|
8
8
|
deposit?: string;
|
|
9
|
+
/** "Deposit Details": the transaction-details drawer title for the `deposit_details` variant. */
|
|
10
|
+
deposit_details_title?: string;
|
|
9
11
|
dismiss: string;
|
|
10
12
|
embedded_description: string;
|
|
11
13
|
error_heading: string;
|
|
@@ -172,12 +174,18 @@ export interface TransactionHistoryBlock {
|
|
|
172
174
|
*/
|
|
173
175
|
monthly_debt_to_income_tip_message?: string;
|
|
174
176
|
monthly_debt_to_income_tip_limit?: string;
|
|
177
|
+
/**
|
|
178
|
+
* The Essentials vs. Flexible drawer's tip: `_1{tip}` the bold tip title. Optional: without it, no tip.
|
|
179
|
+
*/
|
|
180
|
+
non_essential_tip_message?: string;
|
|
175
181
|
/**
|
|
176
182
|
* The Savings vs. Income drawer's tip: `_1{tip}` the bold tip title and `_2{percentage}` the bold
|
|
177
183
|
* percentage (`savings_to_income_tip_percentage`, "20%"). Optional: without both, no tip.
|
|
178
184
|
*/
|
|
179
185
|
savings_to_income_tip_message?: string;
|
|
180
186
|
savings_to_income_tip_percentage?: string;
|
|
187
|
+
/** Cost of Living drawer tip: `_1{tip}` title, `_2{category}` name, `_3{percentage}` threshold. Optional: no tip without it. */
|
|
188
|
+
cost_living_to_income_tip_message?: string;
|
|
181
189
|
}
|
|
182
190
|
export interface TransactionListBlockCopy {
|
|
183
191
|
deposit_history_drawer_title?: string;
|
|
@@ -13,7 +13,7 @@ export type { DebtsCopy } from './DebtsCopy';
|
|
|
13
13
|
export type { FinstrongCopy } from './FinstrongCopy';
|
|
14
14
|
export type { GoalsCopy } from './GoalsCopy';
|
|
15
15
|
export type { HelpCopy, HelpByCategoryList } from './HelpCopy';
|
|
16
|
-
export type { AmountInputModalCopy, AmountInputModalVariantCopy, EmergencySavingsCopy, InsightsFeedCopy, MakeTransferCopy, PayoffCalculatorCopy,
|
|
16
|
+
export type { AmountInputModalCopy, AmountInputModalVariantCopy, EmergencySavingsCopy, InsightsFeedCopy, MakeTransferCopy, PayoffCalculatorCopy, RemainingCashCopy, OverdraftCopy, CreditUtilizationCopy, AccountListCopy, OverflowMenuCopy, DismissInsightCopy, DismissInsightOptionCopy, HiddenConfirmationCopy, HideFeedbackCopy, FeedbackCopy, FeedbackBarCopy, TopMerchantsCopy, TransactionHistoryBlock, QuarterlySummaryBlockCopy, } from './InsightsFeedCopy';
|
|
17
17
|
export type { InvestmentsCopy } from './InvestmentsCopy';
|
|
18
18
|
export type { MicroInsightsCopy } from './MicroInsightsCopy';
|
|
19
19
|
export type { NetWorthCopy } from './NetWorthCopy';
|
|
@@ -6,10 +6,10 @@ import eo from "../../../common/components/CurrencyDialog.es.js";
|
|
|
6
6
|
import { useBeatActions as to } from "../../beatActions.es.js";
|
|
7
7
|
import { useCtaHandler as io } from "../../ctaActions/useCtaAction.es.js";
|
|
8
8
|
import { useAnalyticsEvent as no } from "../../analytics/useAnalyticsEvent.es.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
9
|
+
import { AMOUNT_SETTINGS as ro, CREATE_BUDGET_VARIANT as so, findLowBalanceProfile as ao, isAmountInputVariant as L, resolveAmountInputVariant as co, toInputValue as lo } from "./layout.es.js";
|
|
10
|
+
import { useOpenedCta as uo } from "../useOpenedCta.es.js";
|
|
11
|
+
import { useBlockSave as mo } from "../useBlockSave.es.js";
|
|
12
|
+
import { CreateBudgetDialog as po } from "./CreateBudgetDialog.es.js";
|
|
13
13
|
import c from "react";
|
|
14
14
|
import { observer as k } from "mobx-react-lite";
|
|
15
15
|
import N from "@mui/material/Stack";
|
|
@@ -55,10 +55,10 @@ var _ = ({ children: y, closeAriaLabel: i, heading: n, onClose: t }) => {
|
|
|
55
55
|
})
|
|
56
56
|
});
|
|
57
57
|
}, Fo = k(function({ beat: i }) {
|
|
58
|
-
const { common: n } = w(), { closeActionDrawer: t } = B(), r = Y(), a =
|
|
58
|
+
const { common: n } = w(), { closeActionDrawer: t } = B(), r = Y(), a = uo(i), [l] = c.useState(() => co(a)), d = l === so;
|
|
59
59
|
return c.useEffect(() => {
|
|
60
60
|
d && !r.categoriesLoaded && r.loadCategories();
|
|
61
|
-
}, [r, d]), d ? r.categoriesLoaded ? /* @__PURE__ */ e(
|
|
61
|
+
}, [r, d]), d ? r.categoriesLoaded ? /* @__PURE__ */ e(po, { beat: i }) : /* @__PURE__ */ e(_, {
|
|
62
62
|
closeAriaLabel: n?.close_aria,
|
|
63
63
|
onClose: t,
|
|
64
64
|
children: /* @__PURE__ */ e(E, {})
|
|
@@ -67,16 +67,16 @@ var _ = ({ children: y, closeAriaLabel: i, heading: n, onClose: t }) => {
|
|
|
67
67
|
variant: l
|
|
68
68
|
});
|
|
69
69
|
}), _o = k(function({ beat: i, variant: n }) {
|
|
70
|
-
const { common: t, insights_feed: r } = w(), { closeActionDrawer: a } = B(), l = Z(), { userInsightProfile: d } = oo(), M = io(i, to()), C = no(), u = r?.amount_input_modal, o = L(n) ?
|
|
70
|
+
const { common: t, insights_feed: r } = w(), { closeActionDrawer: a } = B(), l = Z(), { userInsightProfile: d } = oo(), M = io(i, to()), C = no(), u = r?.amount_input_modal, o = L(n) ? ro[n] : void 0, m = !!o?.needsNotificationProfiles, g = {
|
|
71
71
|
insightProfile: d,
|
|
72
|
-
lowBalanceProfile: m ?
|
|
73
|
-
}, S = o?.read(g), [R, $] = c.useState(m), { isMounted: G, isSaving: F, save: H } =
|
|
72
|
+
lowBalanceProfile: m ? ao(l.notificationProfiles, i.primary_account_guid) : void 0
|
|
73
|
+
}, S = o?.read(g), [R, $] = c.useState(m), { isMounted: G, isSaving: F, save: H } = mo();
|
|
74
74
|
c.useEffect(() => {
|
|
75
75
|
m && l.loadNotificationProfiles().finally(() => {
|
|
76
76
|
G.current && $(!1);
|
|
77
77
|
});
|
|
78
78
|
}, [m, l]);
|
|
79
|
-
const [O, U] = c.useState(null), [j, h] = c.useState(!1), p = O ??
|
|
79
|
+
const [O, U] = c.useState(null), [j, h] = c.useState(!1), p = O ?? lo(S);
|
|
80
80
|
if (R) return /* @__PURE__ */ e(_, {
|
|
81
81
|
closeAriaLabel: t?.close_aria,
|
|
82
82
|
onClose: a,
|
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
import { buildDynamicCopy as
|
|
1
|
+
import { buildDynamicCopy as _ } from "../../../core/utils/Localization.es.js";
|
|
2
2
|
import { useCategoryStore as F, useGlobalCopyStore as L, useInsightsV2Store as R } from "../../../common/context/hooks.es.js";
|
|
3
|
-
import { slot as
|
|
4
|
-
import { CURRENCY_FORMAT as w, formatCurrency as
|
|
5
|
-
import { getLocalizedCategoryName as
|
|
6
|
-
import
|
|
7
|
-
import { useBeatActions as
|
|
8
|
-
import {
|
|
3
|
+
import { slot as f } from "../../../core/types/Insights.es.js";
|
|
4
|
+
import { CURRENCY_FORMAT as w, formatCurrency as G } from "../../../core/utils/NumberFormatting.es.js";
|
|
5
|
+
import { getLocalizedCategoryName as I } from "../../../core/utils/CategoryUtil.es.js";
|
|
6
|
+
import O from "../../../common/components/CurrencyDialog.es.js";
|
|
7
|
+
import { useBeatActions as P } from "../../beatActions.es.js";
|
|
8
|
+
import { asNonEmptyText as j } from "../../blocks/slotReaders.es.js";
|
|
9
|
+
import { isPositiveAmount as C, resolveBudgetFacts as E } from "../BudgetDetailsBlock/layout.es.js";
|
|
9
10
|
import { useCtaHandler as H } from "../../ctaActions/useCtaAction.es.js";
|
|
10
11
|
import M from "../../components/shared/StatusSnackbar.es.js";
|
|
11
12
|
import { useBlockSave as V } from "../useBlockSave.es.js";
|
|
12
13
|
import n from "react";
|
|
13
14
|
import { observer as z } from "mobx-react-lite";
|
|
14
|
-
import { jsx as l, jsxs as
|
|
15
|
-
var
|
|
16
|
-
const { budgets: t, categories:
|
|
17
|
-
if (!
|
|
18
|
-
const e = await
|
|
19
|
-
categoryGuid:
|
|
15
|
+
import { jsx as l, jsxs as U } from "react/jsx-runtime";
|
|
16
|
+
var ie = z(function({ beat: s }) {
|
|
17
|
+
const { budgets: t, categories: b, common: o, insights_feed: h } = L(), v = F(), { closeActionDrawer: i } = R(), S = H(s, P()), m = s.insights_payload, u = j(f(m?.instance_slot?.data, "budget_category_guid")) ?? E(s).categoryGuid ?? "", A = f(m?.instance_slot?.data, "average_amount") ?? 0, d = v.categories.find(({ guid: e }) => e === u), g = d ? I(d, b) : "", [r, x] = n.useState(""), [B, p] = n.useState(!0), [a, c] = n.useState(null), { isSaving: D, save: N } = V(), y = (e) => _(e, g), T = C(r) && !D, k = async () => {
|
|
18
|
+
if (!C(r)) return;
|
|
19
|
+
const e = await N(() => S("createBudget", {
|
|
20
|
+
categoryGuid: u,
|
|
20
21
|
amount: Number(r)
|
|
21
22
|
}, { onSuccess: ["refreshBeat"] }));
|
|
22
|
-
e !== void 0 && (
|
|
23
|
+
e !== void 0 && (p(!1), c(e ? "created" : "failed"));
|
|
23
24
|
};
|
|
24
|
-
return /* @__PURE__ */
|
|
25
|
+
return /* @__PURE__ */ U(n.Fragment, { children: [/* @__PURE__ */ l(O, {
|
|
25
26
|
closeAriaLabel: o.close_aria,
|
|
26
|
-
content:
|
|
27
|
-
handleInputChange:
|
|
27
|
+
content: _(t.create_budget_content, /* @__PURE__ */ l("strong", { children: g }, "category"), G(A, w.whole)),
|
|
28
|
+
handleInputChange: x,
|
|
28
29
|
handleModalClose: i,
|
|
29
30
|
handlePrimaryAction: () => {
|
|
30
31
|
k();
|
|
@@ -32,17 +33,17 @@ var ne = z(function({ beat: s }) {
|
|
|
32
33
|
handleSecondaryAction: i,
|
|
33
34
|
inputLabel: o.amount_text,
|
|
34
35
|
inputValue: r,
|
|
35
|
-
isOpen:
|
|
36
|
-
isPrimaryDisabled: !
|
|
36
|
+
isOpen: B,
|
|
37
|
+
isPrimaryDisabled: !T,
|
|
37
38
|
primaryText: t.dialog_primary_button_text,
|
|
38
39
|
secondaryText: o.cancel_button,
|
|
39
40
|
title: t.dialog_create_budget_title
|
|
40
41
|
}), /* @__PURE__ */ l(M, {
|
|
41
|
-
actionText: a === "failed" ?
|
|
42
|
+
actionText: a === "failed" ? h?.general?.try_again : void 0,
|
|
42
43
|
closeAriaLabel: o.close_aria,
|
|
43
|
-
message:
|
|
44
|
+
message: y(a === "created" ? t.alert_budget_created : t.alert_merchant_budget_not_created),
|
|
44
45
|
onActionClick: () => {
|
|
45
|
-
c(null),
|
|
46
|
+
c(null), p(!0);
|
|
46
47
|
},
|
|
47
48
|
onClose: () => {
|
|
48
49
|
c(null), i();
|
|
@@ -52,7 +53,7 @@ var ne = z(function({ beat: s }) {
|
|
|
52
53
|
})] });
|
|
53
54
|
});
|
|
54
55
|
export {
|
|
55
|
-
|
|
56
|
+
ie as CreateBudgetDialog
|
|
56
57
|
};
|
|
57
58
|
|
|
58
59
|
//# sourceMappingURL=CreateBudgetDialog.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateBudgetDialog.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.tsx"],"sourcesContent":["import React from 'react'\n\nimport { observer } from 'mobx-react-lite'\n\nimport {\n CurrencyDialog,\n buildDynamicCopy,\n useCategoryStore,\n useGlobalCopyStore,\n useInsightsV2Store,\n} from '../../../common'\nimport { slot } from '../../../core/types/Insights'\nimport { getLocalizedCategoryName } from '../../../core/utils/CategoryUtil'\nimport { CURRENCY_FORMAT, formatCurrency } from '../../../core/utils/NumberFormatting'\nimport StatusSnackbar from '../../components/shared/StatusSnackbar'\nimport { useBeatActions } from '../../beatActions'\nimport { useCtaHandler } from '../../ctaActions'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { isPositiveAmount, resolveBudgetFacts } from '../BudgetDetailsBlock/layout'\nimport { useBlockSave } from '../useBlockSave'\n\ntype Notice = 'created' | 'failed'\n\n/** The \"Create a Budget\" dialog (mounted once categories load): creates the budget, refreshes the beat, shows the result. */\nexport const CreateBudgetDialog = observer(function CreateBudgetDialog({ beat }: ActionBlockProps) {\n const {\n budgets: budgetsCopy,\n categories: categoriesCopy,\n common: commonCopy,\n insights_feed: insightsFeedCopy,\n } = useGlobalCopyStore()\n const categoryStore = useCategoryStore()\n const { closeActionDrawer } = useInsightsV2Store()\n const runHandler = useCtaHandler(beat, useBeatActions())\n\n const payload = beat.insights_payload\n const
|
|
1
|
+
{"version":3,"file":"CreateBudgetDialog.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.tsx"],"sourcesContent":["import React from 'react'\n\nimport { observer } from 'mobx-react-lite'\n\nimport {\n CurrencyDialog,\n buildDynamicCopy,\n useCategoryStore,\n useGlobalCopyStore,\n useInsightsV2Store,\n} from '../../../common'\nimport { slot } from '../../../core/types/Insights'\nimport { getLocalizedCategoryName } from '../../../core/utils/CategoryUtil'\nimport { CURRENCY_FORMAT, formatCurrency } from '../../../core/utils/NumberFormatting'\nimport StatusSnackbar from '../../components/shared/StatusSnackbar'\nimport { useBeatActions } from '../../beatActions'\nimport { useCtaHandler } from '../../ctaActions'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { isPositiveAmount, resolveBudgetFacts } from '../BudgetDetailsBlock/layout'\nimport { asNonEmptyText } from '../../blocks/slotReaders'\nimport { useBlockSave } from '../useBlockSave'\n\ntype Notice = 'created' | 'failed'\n\n/** The \"Create a Budget\" dialog (mounted once categories load): creates the budget, refreshes the beat, shows the result. */\nexport const CreateBudgetDialog = observer(function CreateBudgetDialog({ beat }: ActionBlockProps) {\n const {\n budgets: budgetsCopy,\n categories: categoriesCopy,\n common: commonCopy,\n insights_feed: insightsFeedCopy,\n } = useGlobalCopyStore()\n const categoryStore = useCategoryStore()\n const { closeActionDrawer } = useInsightsV2Store()\n const runHandler = useCtaHandler(beat, useBeatActions())\n\n const payload = beat.insights_payload\n // A beat that colours by a parent category budgets its own (Cost of Living's budget_category_guid).\n const categoryGuid =\n asNonEmptyText(slot<string>(payload?.instance_slot?.data, 'budget_category_guid')) ??\n resolveBudgetFacts(beat).categoryGuid ??\n ''\n const averageAmount = slot<number>(payload?.instance_slot?.data, 'average_amount') ?? 0\n const category = categoryStore.categories.find(({ guid }) => guid === categoryGuid)\n const categoryName = category ? getLocalizedCategoryName(category, categoriesCopy) : ''\n\n const [amount, setAmount] = React.useState('')\n const [isOpen, setIsOpen] = React.useState(true)\n const [notice, setNotice] = React.useState<Notice | null>(null)\n const { isSaving, save } = useBlockSave()\n\n const named = (copy: string) => buildDynamicCopy(copy, categoryName) as string\n\n const canCreate = isPositiveAmount(amount) && !isSaving\n\n const handleCreate = async () => {\n if (!isPositiveAmount(amount)) return\n\n const ok = await save(() =>\n runHandler(\n 'createBudget',\n { categoryGuid, amount: Number(amount) },\n { onSuccess: ['refreshBeat'] },\n ),\n )\n if (ok === undefined) return\n\n setIsOpen(false)\n setNotice(ok ? 'created' : 'failed')\n }\n\n return (\n <React.Fragment>\n <CurrencyDialog\n closeAriaLabel={commonCopy.close_aria}\n content={\n buildDynamicCopy(\n budgetsCopy.create_budget_content,\n <strong key=\"category\">{categoryName}</strong>,\n formatCurrency(averageAmount, CURRENCY_FORMAT.whole),\n ) as React.ReactNode\n }\n handleInputChange={setAmount}\n handleModalClose={closeActionDrawer}\n handlePrimaryAction={() => void handleCreate()}\n handleSecondaryAction={closeActionDrawer}\n inputLabel={commonCopy.amount_text}\n inputValue={amount}\n isOpen={isOpen}\n isPrimaryDisabled={!canCreate}\n primaryText={budgetsCopy.dialog_primary_button_text}\n secondaryText={commonCopy.cancel_button}\n title={budgetsCopy.dialog_create_budget_title}\n />\n <StatusSnackbar\n actionText={notice === 'failed' ? insightsFeedCopy?.general?.try_again : undefined}\n closeAriaLabel={commonCopy.close_aria}\n message={\n notice === 'created'\n ? named(budgetsCopy.alert_budget_created)\n : named(budgetsCopy.alert_merchant_budget_not_created)\n }\n onActionClick={() => {\n setNotice(null)\n setIsOpen(true)\n }}\n onClose={() => {\n setNotice(null)\n closeActionDrawer()\n }}\n open={Boolean(notice)}\n severity={notice === 'created' ? 'success' : 'error'}\n />\n </React.Fragment>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;AAyBA,IAAa,KAAqB,EAAS,SAA4B,EAAE,MAAA,EAAA,GAA0B;AACjG,QAAM,EACJ,SAAS,GACT,YAAY,GACZ,QAAQ,GACR,eAAe,EAAA,IACb,EAAmB,GACjB,IAAgB,EAAiB,GACjC,EAAE,mBAAA,EAAA,IAAsB,EAAmB,GAC3C,IAAa,EAAc,GAAM,EAAe,CAAC,GAEjD,IAAU,EAAK,kBAEf,IACJ,EAAe,EAAa,GAAS,eAAe,MAAM,sBAAsB,CAAC,KACjF,EAAmB,CAAI,EAAE,gBACzB,IACI,IAAgB,EAAa,GAAS,eAAe,MAAM,gBAAgB,KAAK,GAChF,IAAW,EAAc,WAAW,KAAA,CAAM,EAAE,MAAA,EAAA,MAAW,MAAS,CAAY,GAC5E,IAAe,IAAW,EAAyB,GAA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,YACD,EAAY,uBACZ,EAAY,iCADoB;AAAA,IAG5C,eAAA,MAAqB;AACnB,MAAA,EAAU,IAAI,GACd,EAAU,EAAI;AAAA,IAChB;AAAA,IACA,SAAA,MAAe;AACb,MAAA,EAAU,IAAI,GACd,EAAkB;AAAA,IACpB;AAAA,IACA,MAAM,EAAQ;AAAA,IACd,UAAU,MAAW,YAAY,YAAY;AAAA,EAC9C,CAAA,CACa,EAAA,CAAA;AAEpB,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { buildDynamicCopy as W } from "../../../core/utils/Localization.es.js";
|
|
2
|
-
import { CURRENCY_FORMAT as
|
|
2
|
+
import { CURRENCY_FORMAT as T, formatCurrency as I } from "../../../core/utils/NumberFormatting.es.js";
|
|
3
3
|
import { Select as S } from "../../../common/components/Select.es.js";
|
|
4
4
|
import { SMALL_CARD_SHADOW as H } from "../../components/shared/elevation.es.js";
|
|
5
|
-
import { CADENCES as V, DEADLINE_UNITS as
|
|
5
|
+
import { CADENCES as V, DEADLINE_UNITS as f, calculateContribution as q } from "./layout.es.js";
|
|
6
6
|
import g from "react";
|
|
7
7
|
import { observer as F } from "mobx-react-lite";
|
|
8
8
|
import o from "@mui/material/Stack";
|
|
@@ -30,7 +30,7 @@ var z = [
|
|
|
30
30
|
"add_timeline",
|
|
31
31
|
"weekly",
|
|
32
32
|
"monthly"
|
|
33
|
-
],
|
|
33
|
+
], fe = (n) => z.every((e) => typeof n[e] == "string"), [$, Q, Z] = V, x = [
|
|
34
34
|
{
|
|
35
35
|
cadence: $,
|
|
36
36
|
labelKey: "weekly",
|
|
@@ -46,17 +46,17 @@ var z = [
|
|
|
46
46
|
labelKey: "monthly",
|
|
47
47
|
suffixKey: "per_month"
|
|
48
48
|
}
|
|
49
|
-
], G =
|
|
49
|
+
], G = x.findIndex(({ labelKey: n }) => n === "monthly"), J = f.findIndex(({ labelKey: n }) => n === "months"), X = "6", u = (n, ...e) => W(n, ...e), ee = (n) => n.replace(/[^0-9]/g, ""), m = (n) => I(n, T.whole), R = (n) => I(n, T.cents), xe = F(function({ copy: e, facts: k }) {
|
|
50
50
|
const { balance: s, goal: d, monthContribution: _, monthlyContribution: D, remaining: M } = k, v = s <= 0, y = d > 0 ? Math.round(Math.min(100, Math.max(0, s / d * 100))) : 0, [h, N] = g.useState(v ? "" : G), [p, K] = g.useState(v ? "" : X), [b, L] = g.useState(J), [w, O] = g.useState({
|
|
51
51
|
amount: D,
|
|
52
52
|
suffix: e.per_month
|
|
53
53
|
}), A = h !== "" && p !== "" && Number(p) > 0, B = (a) => {
|
|
54
54
|
if (a.preventDefault(), h === "") return;
|
|
55
|
-
const { cadence: c, suffixKey: Y } =
|
|
55
|
+
const { cadence: c, suffixKey: Y } = x[h], E = q({
|
|
56
56
|
balance: s,
|
|
57
57
|
goal: d,
|
|
58
58
|
cadence: c,
|
|
59
|
-
deadline:
|
|
59
|
+
deadline: f[b],
|
|
60
60
|
deadlineQuantity: Number(p)
|
|
61
61
|
});
|
|
62
62
|
E !== void 0 && O({
|
|
@@ -198,8 +198,8 @@ var z = [
|
|
|
198
198
|
onSubmit: B,
|
|
199
199
|
sx: {
|
|
200
200
|
bgcolor: "background.paper",
|
|
201
|
-
borderColor: "divider",
|
|
202
201
|
borderTop: "1px solid",
|
|
202
|
+
borderTopColor: "divider",
|
|
203
203
|
gap: 32,
|
|
204
204
|
p: 24
|
|
205
205
|
},
|
|
@@ -221,16 +221,16 @@ var z = [
|
|
|
221
221
|
children: /* @__PURE__ */ r(i, {
|
|
222
222
|
color: "text.secondary",
|
|
223
223
|
sx: {
|
|
224
|
-
letterSpacing: "0.
|
|
224
|
+
letterSpacing: "0.33px",
|
|
225
225
|
textTransform: "uppercase"
|
|
226
226
|
},
|
|
227
227
|
variant: "caption",
|
|
228
228
|
children: u(e.next_savings_goal, /* @__PURE__ */ r(i, {
|
|
229
|
-
bold: !0,
|
|
230
229
|
component: "span",
|
|
231
230
|
sx: {
|
|
232
231
|
color: "text.primary",
|
|
233
|
-
fontSize: "inherit"
|
|
232
|
+
fontSize: "inherit",
|
|
233
|
+
fontWeight: "fontWeightBold"
|
|
234
234
|
},
|
|
235
235
|
children: m(d)
|
|
236
236
|
}, "goal"))
|
|
@@ -239,8 +239,8 @@ var z = [
|
|
|
239
239
|
sx: {
|
|
240
240
|
alignItems: "center",
|
|
241
241
|
bgcolor: "background.default",
|
|
242
|
-
borderColor: "divider",
|
|
243
242
|
borderTop: "1px solid",
|
|
243
|
+
borderTopColor: "divider",
|
|
244
244
|
p: 12
|
|
245
245
|
},
|
|
246
246
|
children: [/* @__PURE__ */ t(o, {
|
|
@@ -279,7 +279,7 @@ var z = [
|
|
|
279
279
|
/* @__PURE__ */ r(S, {
|
|
280
280
|
label: e.how_often_will_you_contribute,
|
|
281
281
|
onChange: N,
|
|
282
|
-
options:
|
|
282
|
+
options: x.map(({ labelKey: a }, c) => ({
|
|
283
283
|
id: c,
|
|
284
284
|
label: e[a]
|
|
285
285
|
})),
|
|
@@ -288,7 +288,7 @@ var z = [
|
|
|
288
288
|
inputLabel: { shrink: !0 },
|
|
289
289
|
select: {
|
|
290
290
|
displayEmpty: !0,
|
|
291
|
-
renderValue: (a) => a === "" ? e.select_frequency : e[
|
|
291
|
+
renderValue: (a) => a === "" ? e.select_frequency : e[x[a].labelKey]
|
|
292
292
|
}
|
|
293
293
|
},
|
|
294
294
|
value: h
|
|
@@ -317,8 +317,8 @@ var z = [
|
|
|
317
317
|
}), /* @__PURE__ */ r(S, {
|
|
318
318
|
label: "",
|
|
319
319
|
onChange: L,
|
|
320
|
-
slotProps: { select: { SelectDisplayProps: { "aria-label": e[
|
|
321
|
-
options:
|
|
320
|
+
slotProps: { select: { SelectDisplayProps: { "aria-label": e[f[b].labelKey] } } },
|
|
321
|
+
options: f.map(({ labelKey: a }, c) => ({
|
|
322
322
|
id: c,
|
|
323
323
|
label: e[a]
|
|
324
324
|
})),
|
|
@@ -345,8 +345,8 @@ var z = [
|
|
|
345
345
|
});
|
|
346
346
|
});
|
|
347
347
|
export {
|
|
348
|
-
|
|
349
|
-
|
|
348
|
+
xe as EmergencySavingsV2,
|
|
349
|
+
fe as hasV2Copy
|
|
350
350
|
};
|
|
351
351
|
|
|
352
352
|
//# sourceMappingURL=EmergencySavingsV2.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmergencySavingsV2.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsV2.tsx"],"sourcesContent":["import React, { type ReactNode } from 'react'\nimport { observer } from 'mobx-react-lite'\n\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Stack from '@mui/material/Stack'\nimport TextField from '@mui/material/TextField'\nimport { alpha } from '@mui/material/styles'\n\nimport { Text } from '@mxenabled/mxui'\nimport { Icon } from '@mxenabled/mx-icons'\n\nimport { Select } from '../../../common'\nimport { buildDynamicCopy } from '../../../core'\nimport type { EmergencySavingsCopy } from '../../../core'\nimport { CURRENCY_FORMAT, formatCurrency } from '../../../core/utils/NumberFormatting'\nimport { SMALL_CARD_SHADOW } from '../../components/shared/elevation'\n\nimport { CADENCES, calculateContribution, DEADLINE_UNITS } from './layout'\n\nconst V2_COPY_KEYS = [\n 'your_progress',\n 'more_to_go',\n 'saved_amount',\n 'goal_amount',\n 'contributed_this_month',\n 'increase_your_transfer',\n 'next_savings_goal',\n 'per_month',\n 'per_week',\n 'per_two_weeks',\n 'use_the_calculator',\n 'how_often_will_you_contribute',\n 'select_frequency',\n 'add_timeline',\n 'weekly',\n 'monthly',\n] as const\n\n/** The drawer's copy with every V2 key present. */\nexport type EmergencySavingsV2Copy = EmergencySavingsCopy &\n Required<Pick<EmergencySavingsCopy, (typeof V2_COPY_KEYS)[number]>>\n\n/** True once mrs_content ships the V2 drawer's words; otherwise the legacy drawer opens. */\nexport const hasV2Copy = (copy: EmergencySavingsCopy): copy is EmergencySavingsV2Copy =>\n V2_COPY_KEYS.every((key) => typeof copy[key] === 'string')\n\n/** The figures the V2 card's CTA carries (ditto monthly_emergency_savings_reminder_v2.yml). */\nexport interface EmergencySavingsFacts {\n balance: number\n goal: number\n remaining: number\n monthlyContribution: number\n monthContribution: number\n}\n\nconst [WEEKLY, EVERY_OTHER_WEEK, MONTHLY_CADENCE] = CADENCES\n\n// Figma 1152:27224: the frequency select (weekly / every other week / monthly).\nconst FREQUENCIES = [\n { cadence: WEEKLY, labelKey: 'weekly', suffixKey: 'per_week' },\n { cadence: EVERY_OTHER_WEEK, labelKey: 'every_other_week', suffixKey: 'per_two_weeks' },\n { cadence: MONTHLY_CADENCE, labelKey: 'monthly', suffixKey: 'per_month' },\n] as const\nconst MONTHLY = FREQUENCIES.findIndex(({ labelKey }) => labelKey === 'monthly')\nconst MONTHS = DEADLINE_UNITS.findIndex(({ labelKey }) => labelKey === 'months')\n// The card's monthly_contribution spreads what's left over six months, so the form starts there.\nconst DEFAULT_TIMELINE_MONTHS = '6'\n\n/** Rich copy (`_1{amount}` with an element) as a node. */\nconst rich = (copy: string, ...args: Parameters<typeof buildDynamicCopy>[1][]) =>\n buildDynamicCopy(copy, ...args) as ReactNode\n\nconst toDigits = (value: string) => value.replace(/[^0-9]/g, '')\nconst whole = (amount: number) => formatCurrency(amount, CURRENCY_FORMAT.whole)\nconst cents = (amount: number) => formatCurrency(amount, CURRENCY_FORMAT.cents)\n\ninterface Props {\n copy: EmergencySavingsV2Copy\n facts: EmergencySavingsFacts\n}\n\n/** The Build Emergency Savings drawer (Figma 1152:27224): progress, the month banner, the estimate and calculator. */\nexport const EmergencySavingsV2 = observer(function EmergencySavingsV2({ copy, facts }: Props) {\n const { balance, goal, monthContribution, monthlyContribution, remaining } = facts\n const isZeroState = balance <= 0\n const percent = goal > 0 ? Math.round(Math.min(100, Math.max(0, (balance / goal) * 100))) : 0\n\n // The zero state opens empty (Select frequency / Add timeline).\n const [frequency, setFrequency] = React.useState<number | ''>(isZeroState ? '' : MONTHLY)\n const [timeline, setTimeline] = React.useState(isZeroState ? '' : DEFAULT_TIMELINE_MONTHS)\n const [unit, setUnit] = React.useState(MONTHS)\n const [estimate, setEstimate] = React.useState({\n amount: monthlyContribution,\n suffix: copy.per_month,\n })\n\n const canCalculate = frequency !== '' && timeline !== '' && Number(timeline) > 0\n\n const handleSubmit = (event: React.FormEvent) => {\n event.preventDefault()\n if (frequency === '') return\n\n const { cadence, suffixKey } = FREQUENCIES[frequency]\n const amount = calculateContribution({\n balance,\n goal,\n cadence,\n deadline: DEADLINE_UNITS[unit],\n deadlineQuantity: Number(timeline),\n })\n if (amount !== undefined) setEstimate({ amount, suffix: copy[suffixKey] })\n }\n\n return (\n <Stack sx={{ bgcolor: 'background.default' }}>\n <Box sx={{ p: 24 }}>\n <Stack\n aria-label={copy.your_progress}\n role=\"region\"\n sx={{\n bgcolor: 'background.paper',\n borderRadius: '8px',\n boxShadow: SMALL_CARD_SHADOW,\n gap: 16,\n p: 16,\n }}\n >\n <Stack sx={{ gap: 12 }}>\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 8 }}>\n <Box\n aria-hidden={true}\n sx={(theme) => ({\n alignItems: 'center',\n bgcolor: alpha(theme.palette.primary.main, 0.15),\n borderRadius: '4px',\n display: 'flex',\n flexShrink: 0,\n height: 40,\n justifyContent: 'center',\n width: 40,\n })}\n >\n <Icon color=\"primary\" name=\"savings\" size={20} />\n </Box>\n <Stack>\n <Text variant=\"caption\">{copy.your_progress}</Text>\n <Text component=\"p\" variant=\"body2\">\n {rich(\n copy.more_to_go,\n <Text\n component=\"span\"\n key=\"amount\"\n sx={{ fontWeight: 'fontWeightBold' }}\n variant=\"h2\"\n >\n {whole(remaining)}\n </Text>,\n )}\n </Text>\n </Stack>\n </Stack>\n <Stack sx={{ gap: 4 }}>\n <Box\n aria-label={buildDynamicCopy(copy.saved_amount, whole(balance)) as string}\n aria-valuemax={100}\n aria-valuemin={0}\n aria-valuenow={percent}\n role=\"progressbar\"\n sx={{ bgcolor: 'divider', borderRadius: '6px', height: 8, overflow: 'hidden' }}\n >\n <Box\n sx={{\n bgcolor: 'primary.main',\n borderRadius: '6px',\n height: '100%',\n width: `${percent}%`,\n }}\n />\n </Box>\n <Stack sx={{ flexDirection: 'row', justifyContent: 'space-between' }}>\n <Text color=\"text.secondary\" variant=\"caption\">\n {rich(copy.saved_amount, whole(balance))}\n </Text>\n <Text color=\"text.secondary\" variant=\"caption\">\n {rich(copy.goal_amount, whole(goal))}\n </Text>\n </Stack>\n </Stack>\n </Stack>\n {monthContribution > 0 && (\n <Stack\n role=\"note\"\n sx={{\n alignItems: 'flex-start',\n bgcolor: 'primary.lighter',\n borderRadius: '8px',\n flexDirection: 'row',\n gap: 8,\n p: 12,\n }}\n >\n <Box sx={{ pt: 2, px: 4 }}>\n <Icon aria-hidden={true} color=\"primary\" name=\"celebration\" size={20} />\n </Box>\n <Text\n color=\"primary.dark\"\n component=\"p\"\n sx={{ fontWeight: 'fontWeightRegular' }}\n variant=\"subtitle2\"\n >\n {rich(\n copy.contributed_this_month,\n <Text\n component=\"span\"\n key=\"amount\"\n sx={{ fontSize: 'inherit', fontWeight: 'fontWeightBold' }}\n >\n {cents(monthContribution)}\n </Text>,\n )}{' '}\n {copy.increase_your_transfer}\n </Text>\n </Stack>\n )}\n </Stack>\n </Box>\n <Stack\n component=\"form\"\n onSubmit={handleSubmit}\n sx={{\n bgcolor: 'background.paper',\n borderColor: 'divider',\n borderTop: '1px solid',\n gap: 32,\n p: 24,\n }}\n >\n <Stack sx={{ gap: 8 }}>\n <Stack\n aria-label={copy.estimated_contribution}\n role=\"group\"\n sx={{ border: '1px solid', borderColor: 'divider', borderRadius: '4px' }}\n >\n <Box sx={{ px: 8, py: 4 }}>\n <Text\n color=\"text.secondary\"\n sx={{ letterSpacing: '0.4px', textTransform: 'uppercase' }}\n variant=\"caption\"\n >\n {rich(\n copy.next_savings_goal,\n <Text\n bold={true}\n component=\"span\"\n key=\"goal\"\n sx={{ color: 'text.primary', fontSize: 'inherit' }}\n >\n {whole(goal)}\n </Text>,\n )}\n </Text>\n </Box>\n <Stack\n sx={{\n alignItems: 'center',\n bgcolor: 'background.default',\n borderColor: 'divider',\n borderTop: '1px solid',\n p: 12,\n }}\n >\n <Stack sx={{ alignItems: 'flex-end', flexDirection: 'row', gap: 4 }}>\n <Text component=\"p\" sx={{ fontWeight: 'fontWeightBold' }} variant=\"h2\">\n {cents(estimate.amount)}\n </Text>\n <Text sx={{ fontWeight: 'fontWeightRegular' }} variant=\"subtitle2\">\n {estimate.suffix}\n </Text>\n </Stack>\n <Text\n color=\"text.secondary\"\n sx={{ fontWeight: 'fontWeightRegular' }}\n variant=\"subtitle2\"\n >\n {copy.estimated_contribution}\n </Text>\n </Stack>\n </Stack>\n <Text\n color=\"text.secondary\"\n sx={{ textAlign: 'center' }}\n truncate={false}\n variant=\"caption\"\n >\n {copy.use_the_calculator}\n </Text>\n </Stack>\n <Stack sx={{ gap: 16 }}>\n <Select\n label={copy.how_often_will_you_contribute}\n onChange={setFrequency}\n options={FREQUENCIES.map(({ labelKey }, id) => ({ id, label: copy[labelKey] }))}\n required={true}\n slotProps={{\n inputLabel: { shrink: true },\n select: {\n displayEmpty: true,\n renderValue: (v: unknown) =>\n v === '' ? copy.select_frequency : copy[FREQUENCIES[v as number].labelKey],\n },\n }}\n value={frequency}\n />\n <Stack aria-label={copy.meet_your_goal_within} role=\"group\" sx={{ flexDirection: 'row' }}>\n <TextField\n fullWidth={true}\n label={copy.meet_your_goal_within}\n onChange={(event) => setTimeline(toDigits(event.target.value))}\n placeholder={copy.add_timeline}\n slotProps={{\n htmlInput: { inputMode: 'numeric', pattern: '[0-9]*' },\n inputLabel: { shrink: true },\n }}\n sx={{\n '& .MuiOutlinedInput-root': { borderBottomRightRadius: 0, borderTopRightRadius: 0 },\n }}\n value={timeline}\n />\n <Select\n label=\"\"\n onChange={setUnit}\n slotProps={{\n select: {\n SelectDisplayProps: { 'aria-label': copy[DEADLINE_UNITS[unit].labelKey] },\n },\n }}\n options={DEADLINE_UNITS.map(({ labelKey }, id) => ({ id, label: copy[labelKey] }))}\n sx={{\n minWidth: 120,\n '& .MuiOutlinedInput-root': { borderBottomLeftRadius: 0, borderTopLeftRadius: 0 },\n }}\n value={unit}\n />\n </Stack>\n <Button disabled={!canCalculate} fullWidth={true} type=\"submit\" variant=\"contained\">\n {copy.calculate}\n </Button>\n </Stack>\n </Stack>\n </Stack>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;AAoBA,IAAM,IAAe;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAOa,KAAA,CAAa,MACxB,EAAa,MAAA,CAAO,MAAQ,OAAO,EAAK,CAAA,KAAS,QAAQ,GAWrD,CAAC,GAAQ,GAAkB,CAAA,IAAmB,GAG9C,IAAc;AAAA,EAClB;AAAA,IAAE,SAAS;AAAA,IAAQ,UAAU;AAAA,IAAU,WAAW;AAAA,EAAW;AAAA,EAC7D;AAAA,IAAE,SAAS;AAAA,IAAkB,UAAU;AAAA,IAAoB,WAAW;AAAA,EAAgB;AAAA,EACtF;AAAA,IAAE,SAAS;AAAA,IAAiB,UAAU;AAAA,IAAW,WAAW;AAAA,EAAY;AAC1E,GACM,IAAU,EAAY,UAAA,CAAW,EAAE,UAAA,EAAA,MAAe,MAAa,SAAS,GACxE,IAAS,EAAe,UAAA,CAAW,EAAE,UAAA,EAAA,MAAe,MAAa,QAAQ,GAEzE,IAA0B,KAG1B,IAAA,CAAQ,MAAiB,MAC7B,EAAiB,GAAM,GAAG,CAAI,GAE1B,KAAA,CAAY,MAAkB,EAAM,QAAQ,WAAW,EAAE,GACzD,IAAA,CAAS,MAAmB,EAAe,GAAQ,EAAgB,KAAK,GACxE,IAAA,CAAS,MAAmB,EAAe,GAAQ,EAAgB,KAAK,GAQjE,KAAqB,E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A,CAAK,EAAE,UAAA,EAAA,GAAY,OAAQ;AAAA,gBAAE,IAAA;AAAA,gBAAI,OAAO,EAAK,CAAA;AAAA,cAAU,EAAE;AAAA,cACjF,IAAI;AAAA,gBACF,UAAU;AAAA,gBACV,4BAA4B;AAAA,kBAAE,wBAAwB;AAAA,kBAAG,qBAAqB;AAAA,gBAAE;AAAA,cAClF;AAAA,cACA,OAAO;AAAA,YACR,CAAA,CACI;AAAA;UACP,gBAAA,EAAC,GAAD;AAAA,YAAQ,UAAU,CAAC;AAAA,YAAc,WAAW;AAAA,YAAM,MAAK;AAAA,YAAS,SAAQ;AAAA,YACrE,UAAA,EAAK;AAAA,UACA,CAAA;AAAA,QACH;AAAA,MACF,CAAA,CAAA;AAAA,IACF,CAAA,CAAA;AAAA;AAEX,CAAC"}
|
|
1
|
+
{"version":3,"file":"EmergencySavingsV2.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsV2.tsx"],"sourcesContent":["import React, { type ReactNode } from 'react'\nimport { observer } from 'mobx-react-lite'\n\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Stack from '@mui/material/Stack'\nimport TextField from '@mui/material/TextField'\nimport { alpha } from '@mui/material/styles'\n\nimport { Text } from '@mxenabled/mxui'\nimport { Icon } from '@mxenabled/mx-icons'\n\nimport { Select } from '../../../common'\nimport { buildDynamicCopy } from '../../../core'\nimport type { EmergencySavingsCopy } from '../../../core'\nimport { CURRENCY_FORMAT, formatCurrency } from '../../../core/utils/NumberFormatting'\nimport { SMALL_CARD_SHADOW } from '../../components/shared/elevation'\n\nimport { CADENCES, calculateContribution, DEADLINE_UNITS } from './layout'\n\nconst V2_COPY_KEYS = [\n 'your_progress',\n 'more_to_go',\n 'saved_amount',\n 'goal_amount',\n 'contributed_this_month',\n 'increase_your_transfer',\n 'next_savings_goal',\n 'per_month',\n 'per_week',\n 'per_two_weeks',\n 'use_the_calculator',\n 'how_often_will_you_contribute',\n 'select_frequency',\n 'add_timeline',\n 'weekly',\n 'monthly',\n] as const\n\n/** The drawer's copy with every V2 key present. */\nexport type EmergencySavingsV2Copy = EmergencySavingsCopy &\n Required<Pick<EmergencySavingsCopy, (typeof V2_COPY_KEYS)[number]>>\n\n/** True once mrs_content ships the V2 drawer's words; otherwise the legacy drawer opens. */\nexport const hasV2Copy = (copy: EmergencySavingsCopy): copy is EmergencySavingsV2Copy =>\n V2_COPY_KEYS.every((key) => typeof copy[key] === 'string')\n\n/** The figures the V2 card's CTA carries (ditto monthly_emergency_savings_reminder_v2.yml). */\nexport interface EmergencySavingsFacts {\n balance: number\n goal: number\n remaining: number\n monthlyContribution: number\n monthContribution: number\n}\n\nconst [WEEKLY, EVERY_OTHER_WEEK, MONTHLY_CADENCE] = CADENCES\n\n// Figma 1152:27224: the frequency select (weekly / every other week / monthly).\nconst FREQUENCIES = [\n { cadence: WEEKLY, labelKey: 'weekly', suffixKey: 'per_week' },\n { cadence: EVERY_OTHER_WEEK, labelKey: 'every_other_week', suffixKey: 'per_two_weeks' },\n { cadence: MONTHLY_CADENCE, labelKey: 'monthly', suffixKey: 'per_month' },\n] as const\nconst MONTHLY = FREQUENCIES.findIndex(({ labelKey }) => labelKey === 'monthly')\nconst MONTHS = DEADLINE_UNITS.findIndex(({ labelKey }) => labelKey === 'months')\n// The card's monthly_contribution spreads what's left over six months, so the form starts there.\nconst DEFAULT_TIMELINE_MONTHS = '6'\n\n/** Rich copy (`_1{amount}` with an element) as a node. */\nconst rich = (copy: string, ...args: Parameters<typeof buildDynamicCopy>[1][]) =>\n buildDynamicCopy(copy, ...args) as ReactNode\n\nconst toDigits = (value: string) => value.replace(/[^0-9]/g, '')\nconst whole = (amount: number) => formatCurrency(amount, CURRENCY_FORMAT.whole)\nconst cents = (amount: number) => formatCurrency(amount, CURRENCY_FORMAT.cents)\n\ninterface Props {\n copy: EmergencySavingsV2Copy\n facts: EmergencySavingsFacts\n}\n\n/** The Build Emergency Savings drawer (Figma 1152:27224): progress, the month banner, the estimate and calculator. */\nexport const EmergencySavingsV2 = observer(function EmergencySavingsV2({ copy, facts }: Props) {\n const { balance, goal, monthContribution, monthlyContribution, remaining } = facts\n const isZeroState = balance <= 0\n const percent = goal > 0 ? Math.round(Math.min(100, Math.max(0, (balance / goal) * 100))) : 0\n\n // The zero state opens empty (Select frequency / Add timeline).\n const [frequency, setFrequency] = React.useState<number | ''>(isZeroState ? '' : MONTHLY)\n const [timeline, setTimeline] = React.useState(isZeroState ? '' : DEFAULT_TIMELINE_MONTHS)\n const [unit, setUnit] = React.useState(MONTHS)\n const [estimate, setEstimate] = React.useState({\n amount: monthlyContribution,\n suffix: copy.per_month,\n })\n\n const canCalculate = frequency !== '' && timeline !== '' && Number(timeline) > 0\n\n const handleSubmit = (event: React.FormEvent) => {\n event.preventDefault()\n if (frequency === '') return\n\n const { cadence, suffixKey } = FREQUENCIES[frequency]\n const amount = calculateContribution({\n balance,\n goal,\n cadence,\n deadline: DEADLINE_UNITS[unit],\n deadlineQuantity: Number(timeline),\n })\n if (amount !== undefined) setEstimate({ amount, suffix: copy[suffixKey] })\n }\n\n return (\n <Stack sx={{ bgcolor: 'background.default' }}>\n <Box sx={{ p: 24 }}>\n <Stack\n aria-label={copy.your_progress}\n role=\"region\"\n sx={{\n bgcolor: 'background.paper',\n borderRadius: '8px',\n boxShadow: SMALL_CARD_SHADOW,\n gap: 16,\n p: 16,\n }}\n >\n <Stack sx={{ gap: 12 }}>\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 8 }}>\n <Box\n aria-hidden={true}\n sx={(theme) => ({\n alignItems: 'center',\n bgcolor: alpha(theme.palette.primary.main, 0.15),\n borderRadius: '4px',\n display: 'flex',\n flexShrink: 0,\n height: 40,\n justifyContent: 'center',\n width: 40,\n })}\n >\n <Icon color=\"primary\" name=\"savings\" size={20} />\n </Box>\n <Stack>\n <Text variant=\"caption\">{copy.your_progress}</Text>\n <Text component=\"p\" variant=\"body2\">\n {rich(\n copy.more_to_go,\n <Text\n component=\"span\"\n key=\"amount\"\n sx={{ fontWeight: 'fontWeightBold' }}\n variant=\"h2\"\n >\n {whole(remaining)}\n </Text>,\n )}\n </Text>\n </Stack>\n </Stack>\n <Stack sx={{ gap: 4 }}>\n <Box\n aria-label={buildDynamicCopy(copy.saved_amount, whole(balance)) as string}\n aria-valuemax={100}\n aria-valuemin={0}\n aria-valuenow={percent}\n role=\"progressbar\"\n sx={{ bgcolor: 'divider', borderRadius: '6px', height: 8, overflow: 'hidden' }}\n >\n <Box\n sx={{\n bgcolor: 'primary.main',\n borderRadius: '6px',\n height: '100%',\n width: `${percent}%`,\n }}\n />\n </Box>\n <Stack sx={{ flexDirection: 'row', justifyContent: 'space-between' }}>\n <Text color=\"text.secondary\" variant=\"caption\">\n {rich(copy.saved_amount, whole(balance))}\n </Text>\n <Text color=\"text.secondary\" variant=\"caption\">\n {rich(copy.goal_amount, whole(goal))}\n </Text>\n </Stack>\n </Stack>\n </Stack>\n {monthContribution > 0 && (\n <Stack\n role=\"note\"\n sx={{\n alignItems: 'flex-start',\n bgcolor: 'primary.lighter',\n borderRadius: '8px',\n flexDirection: 'row',\n gap: 8,\n p: 12,\n }}\n >\n <Box sx={{ pt: 2, px: 4 }}>\n <Icon aria-hidden={true} color=\"primary\" name=\"celebration\" size={20} />\n </Box>\n <Text\n color=\"primary.dark\"\n component=\"p\"\n sx={{ fontWeight: 'fontWeightRegular' }}\n variant=\"subtitle2\"\n >\n {rich(\n copy.contributed_this_month,\n <Text\n component=\"span\"\n key=\"amount\"\n sx={{ fontSize: 'inherit', fontWeight: 'fontWeightBold' }}\n >\n {cents(monthContribution)}\n </Text>,\n )}{' '}\n {copy.increase_your_transfer}\n </Text>\n </Stack>\n )}\n </Stack>\n </Box>\n <Stack\n component=\"form\"\n onSubmit={handleSubmit}\n sx={{\n bgcolor: 'background.paper',\n borderTop: '1px solid',\n borderTopColor: 'divider',\n gap: 32,\n p: 24,\n }}\n >\n <Stack sx={{ gap: 8 }}>\n <Stack\n aria-label={copy.estimated_contribution}\n role=\"group\"\n sx={{ border: '1px solid', borderColor: 'divider', borderRadius: '4px' }}\n >\n <Box sx={{ px: 8, py: 4 }}>\n <Text\n color=\"text.secondary\"\n sx={{ letterSpacing: '0.33px', textTransform: 'uppercase' }}\n variant=\"caption\"\n >\n {rich(\n copy.next_savings_goal,\n <Text\n component=\"span\"\n key=\"goal\"\n sx={{\n color: 'text.primary',\n fontSize: 'inherit',\n fontWeight: 'fontWeightBold',\n }}\n >\n {whole(goal)}\n </Text>,\n )}\n </Text>\n </Box>\n <Stack\n sx={{\n alignItems: 'center',\n bgcolor: 'background.default',\n borderTop: '1px solid',\n borderTopColor: 'divider',\n p: 12,\n }}\n >\n <Stack sx={{ alignItems: 'flex-end', flexDirection: 'row', gap: 4 }}>\n <Text component=\"p\" sx={{ fontWeight: 'fontWeightBold' }} variant=\"h2\">\n {cents(estimate.amount)}\n </Text>\n <Text sx={{ fontWeight: 'fontWeightRegular' }} variant=\"subtitle2\">\n {estimate.suffix}\n </Text>\n </Stack>\n <Text\n color=\"text.secondary\"\n sx={{ fontWeight: 'fontWeightRegular' }}\n variant=\"subtitle2\"\n >\n {copy.estimated_contribution}\n </Text>\n </Stack>\n </Stack>\n <Text\n color=\"text.secondary\"\n sx={{ textAlign: 'center' }}\n truncate={false}\n variant=\"caption\"\n >\n {copy.use_the_calculator}\n </Text>\n </Stack>\n <Stack sx={{ gap: 16 }}>\n <Select\n label={copy.how_often_will_you_contribute}\n onChange={setFrequency}\n options={FREQUENCIES.map(({ labelKey }, id) => ({ id, label: copy[labelKey] }))}\n required={true}\n slotProps={{\n inputLabel: { shrink: true },\n select: {\n displayEmpty: true,\n renderValue: (v: unknown) =>\n v === '' ? copy.select_frequency : copy[FREQUENCIES[v as number].labelKey],\n },\n }}\n value={frequency}\n />\n <Stack aria-label={copy.meet_your_goal_within} role=\"group\" sx={{ flexDirection: 'row' }}>\n <TextField\n fullWidth={true}\n label={copy.meet_your_goal_within}\n onChange={(event) => setTimeline(toDigits(event.target.value))}\n placeholder={copy.add_timeline}\n slotProps={{\n htmlInput: { inputMode: 'numeric', pattern: '[0-9]*' },\n inputLabel: { shrink: true },\n }}\n sx={{\n '& .MuiOutlinedInput-root': { borderBottomRightRadius: 0, borderTopRightRadius: 0 },\n }}\n value={timeline}\n />\n <Select\n label=\"\"\n onChange={setUnit}\n slotProps={{\n select: {\n SelectDisplayProps: { 'aria-label': copy[DEADLINE_UNITS[unit].labelKey] },\n },\n }}\n options={DEADLINE_UNITS.map(({ labelKey }, id) => ({ id, label: copy[labelKey] }))}\n sx={{\n minWidth: 120,\n '& .MuiOutlinedInput-root': { borderBottomLeftRadius: 0, borderTopLeftRadius: 0 },\n }}\n value={unit}\n />\n </Stack>\n <Button disabled={!canCalculate} fullWidth={true} type=\"submit\" variant=\"contained\">\n {copy.calculate}\n </Button>\n </Stack>\n </Stack>\n </Stack>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;AAoBA,IAAM,IAAe;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAOa,KAAA,CAAa,MACxB,EAAa,MAAA,CAAO,MAAQ,OAAO,EAAK,CAAA,KAAS,QAAQ,GAWrD,CAAC,GAAQ,GAAkB,CAAA,IAAmB,GAG9C,IAAc;AAAA,EAClB;AAAA,IAAE,SAAS;AAAA,IAAQ,UAAU;AAAA,IAAU,WAAW;AAAA,EAAW;AAAA,EAC7D;AAAA,IAAE,SAAS;AAAA,IAAkB,UAAU;AAAA,IAAoB,WAAW;AAAA,EAAgB;AAAA,EACtF;AAAA,IAAE,SAAS;AAAA,IAAiB,UAAU;AAAA,IAAW,WAAW;AAAA,EAAY;AAC1E,GACM,IAAU,EAAY,UAAA,CAAW,EAAE,UAAA,EAAA,MAA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