@burdenoff/microfe-subscriberbot 2026.1103.1 → 2026.1105.1
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/dist/index.js +3 -3
- package/dist/stories/Accessibility.stories.d.ts +13 -0
- package/dist/stories/Accessibility.stories.d.ts.map +1 -0
- package/dist/stories/pages/AgentDetailPage.stories.d.ts.map +1 -1
- package/dist/stories/pages/AgentNewPage.stories.d.ts.map +1 -1
- package/dist/stories/pages/AgentsListPage.stories.d.ts.map +1 -1
- package/dist/stories/pages/BankConnectionsPage.stories.d.ts +1 -0
- package/dist/stories/pages/BankConnectionsPage.stories.d.ts.map +1 -1
- package/dist/stories/pages/EnterpriseSpendPage.stories.d.ts.map +1 -1
- package/dist/stories/pages/InboxPage.stories.d.ts.map +1 -1
- package/dist/subscriberbot/admin/AdminDashboardPage.d.ts.map +1 -1
- package/dist/subscriberbot/admin/AdminDashboardPage.js +168 -168
- package/dist/subscriberbot/admin/AdminDashboardPage.js.map +1 -1
- package/dist/subscriberbot/admin/NegotiationDeskPanel.d.ts.map +1 -1
- package/dist/subscriberbot/admin/NegotiationDeskPanel.js +116 -116
- package/dist/subscriberbot/admin/NegotiationDeskPanel.js.map +1 -1
- package/dist/subscriberbot/admin/ProcurementDeskPanel.d.ts.map +1 -1
- package/dist/subscriberbot/admin/ProcurementDeskPanel.js +211 -211
- package/dist/subscriberbot/admin/ProcurementDeskPanel.js.map +1 -1
- package/dist/subscriberbot/components/Modal.d.ts.map +1 -1
- package/dist/subscriberbot/components/Modal.js +43 -33
- package/dist/subscriberbot/components/Modal.js.map +1 -1
- package/dist/subscriberbot/components/PostureOptions.d.ts.map +1 -1
- package/dist/subscriberbot/components/PostureOptions.js +10 -10
- package/dist/subscriberbot/components/PostureOptions.js.map +1 -1
- package/dist/subscriberbot/components/StateViews.d.ts.map +1 -1
- package/dist/subscriberbot/components/StateViews.js +45 -37
- package/dist/subscriberbot/components/StateViews.js.map +1 -1
- package/dist/subscriberbot/components/StatusBadge.d.ts.map +1 -1
- package/dist/subscriberbot/components/StatusBadge.js +6 -6
- package/dist/subscriberbot/components/StatusBadge.js.map +1 -1
- package/dist/subscriberbot/components/decisions/DecisionBanners.js +6 -6
- package/dist/subscriberbot/components/decisions/DecisionCard.d.ts.map +1 -1
- package/dist/subscriberbot/components/decisions/DecisionCard.js +149 -147
- package/dist/subscriberbot/components/decisions/DecisionCard.js.map +1 -1
- package/dist/subscriberbot/components/mobile/MobileDashboard.d.ts.map +1 -1
- package/dist/subscriberbot/components/mobile/MobileDashboard.js +127 -127
- package/dist/subscriberbot/components/mobile/MobileDashboard.js.map +1 -1
- package/dist/subscriberbot/components/mobile/MobileRelationshipList.d.ts.map +1 -1
- package/dist/subscriberbot/components/mobile/MobileRelationshipList.js +114 -114
- package/dist/subscriberbot/components/mobile/MobileRelationshipList.js.map +1 -1
- package/dist/subscriberbot/components/mobile/MobileScreen.js +1 -1
- package/dist/subscriberbot/components/mobile/MobileScreen.js.map +1 -1
- package/dist/subscriberbot/components/negotiations/NegotiationStatusPill.js +4 -4
- package/dist/subscriberbot/components/negotiations/NegotiationTimeline.d.ts.map +1 -1
- package/dist/subscriberbot/components/negotiations/NegotiationTimeline.js +11 -11
- package/dist/subscriberbot/components/negotiations/NegotiationTimeline.js.map +1 -1
- package/dist/subscriberbot/components/negotiations/OutcomeForm.d.ts.map +1 -1
- package/dist/subscriberbot/components/negotiations/OutcomeForm.js +29 -29
- package/dist/subscriberbot/components/negotiations/OutcomeForm.js.map +1 -1
- package/dist/subscriberbot/components/procurement/ProcurementOutcomeForm.d.ts.map +1 -1
- package/dist/subscriberbot/components/procurement/ProcurementOutcomeForm.js +43 -43
- package/dist/subscriberbot/components/procurement/ProcurementOutcomeForm.js.map +1 -1
- package/dist/subscriberbot/components/procurement/ProcurementStatusPill.js +4 -4
- package/dist/subscriberbot/components/procurement/ProcurementThread.d.ts.map +1 -1
- package/dist/subscriberbot/components/procurement/ProcurementThread.js +14 -14
- package/dist/subscriberbot/components/procurement/ProcurementThread.js.map +1 -1
- package/dist/subscriberbot/components/savings/SavingsCards.d.ts.map +1 -1
- package/dist/subscriberbot/components/savings/SavingsCards.js +242 -237
- package/dist/subscriberbot/components/savings/SavingsCards.js.map +1 -1
- package/dist/subscriberbot/components/viz.d.ts +1 -0
- package/dist/subscriberbot/components/viz.d.ts.map +1 -1
- package/dist/subscriberbot/components/viz.js +100 -101
- package/dist/subscriberbot/components/viz.js.map +1 -1
- package/dist/subscriberbot/hooks/index.js +1 -1
- package/dist/subscriberbot/hooks/useFormError.d.ts +7 -0
- package/dist/subscriberbot/hooks/useFormError.d.ts.map +1 -0
- package/dist/subscriberbot/hooks/useFormError.js +28 -0
- package/dist/subscriberbot/hooks/useFormError.js.map +1 -0
- package/dist/subscriberbot/hooks/useFormatters.d.ts +11 -0
- package/dist/subscriberbot/hooks/useFormatters.d.ts.map +1 -0
- package/dist/subscriberbot/hooks/useFormatters.js +13 -0
- package/dist/subscriberbot/hooks/useFormatters.js.map +1 -0
- package/dist/subscriberbot/hooks/useSubscriberBotApi.d.ts.map +1 -1
- package/dist/subscriberbot/hooks/useSubscriberBotApi.js +371 -370
- package/dist/subscriberbot/hooks/useSubscriberBotApi.js.map +1 -1
- package/dist/subscriberbot/hooks/useTr.d.ts.map +1 -1
- package/dist/subscriberbot/hooks/useTr.js +1 -1
- package/dist/subscriberbot/hooks/useTr.js.map +1 -1
- package/dist/subscriberbot/index.js +1 -1
- package/dist/subscriberbot/pages/AssetVaultPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/AssetVaultPage.js +124 -124
- package/dist/subscriberbot/pages/AssetVaultPage.js.map +1 -1
- package/dist/subscriberbot/pages/DashboardPage.d.ts +0 -10
- package/dist/subscriberbot/pages/DashboardPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/DashboardPage.js +107 -98
- package/dist/subscriberbot/pages/DashboardPage.js.map +1 -1
- package/dist/subscriberbot/pages/InboxPage.d.ts +0 -10
- package/dist/subscriberbot/pages/InboxPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/InboxPage.js +421 -402
- package/dist/subscriberbot/pages/InboxPage.js.map +1 -1
- package/dist/subscriberbot/pages/InsightsPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/InsightsPage.js +130 -121
- package/dist/subscriberbot/pages/InsightsPage.js.map +1 -1
- package/dist/subscriberbot/pages/InvoicesPage.d.ts +0 -12
- package/dist/subscriberbot/pages/InvoicesPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/InvoicesPage.js +237 -215
- package/dist/subscriberbot/pages/InvoicesPage.js.map +1 -1
- package/dist/subscriberbot/pages/RenewalsPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/RenewalsPage.js +303 -295
- package/dist/subscriberbot/pages/RenewalsPage.js.map +1 -1
- package/dist/subscriberbot/pages/SavingsPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/SavingsPage.js +57 -57
- package/dist/subscriberbot/pages/SavingsPage.js.map +1 -1
- package/dist/subscriberbot/pages/WorkflowsPage.d.ts +0 -13
- package/dist/subscriberbot/pages/WorkflowsPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/WorkflowsPage.js +202 -196
- package/dist/subscriberbot/pages/WorkflowsPage.js.map +1 -1
- package/dist/subscriberbot/pages/agents/AgentDetailPage.d.ts +0 -18
- package/dist/subscriberbot/pages/agents/AgentDetailPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/agents/AgentDetailPage.js +283 -275
- package/dist/subscriberbot/pages/agents/AgentDetailPage.js.map +1 -1
- package/dist/subscriberbot/pages/agents/AgentNewPage.d.ts +0 -6
- package/dist/subscriberbot/pages/agents/AgentNewPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/agents/AgentNewPage.js +85 -77
- package/dist/subscriberbot/pages/agents/AgentNewPage.js.map +1 -1
- package/dist/subscriberbot/pages/agents/AgentsListPage.d.ts +0 -9
- package/dist/subscriberbot/pages/agents/AgentsListPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/agents/AgentsListPage.js +136 -136
- package/dist/subscriberbot/pages/agents/AgentsListPage.js.map +1 -1
- package/dist/subscriberbot/pages/banking/BankConnectionsPage.d.ts +0 -9
- package/dist/subscriberbot/pages/banking/BankConnectionsPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/banking/BankConnectionsPage.js +267 -260
- package/dist/subscriberbot/pages/banking/BankConnectionsPage.js.map +1 -1
- package/dist/subscriberbot/pages/decisions/DecisionDetailPage.d.ts +0 -10
- package/dist/subscriberbot/pages/decisions/DecisionDetailPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/decisions/DecisionDetailPage.js +96 -96
- package/dist/subscriberbot/pages/decisions/DecisionDetailPage.js.map +1 -1
- package/dist/subscriberbot/pages/decisions/DecisionsPage.d.ts +0 -11
- package/dist/subscriberbot/pages/decisions/DecisionsPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/decisions/DecisionsPage.js +46 -46
- package/dist/subscriberbot/pages/decisions/DecisionsPage.js.map +1 -1
- package/dist/subscriberbot/pages/enterprise/EnterpriseSpendPage.d.ts +0 -11
- package/dist/subscriberbot/pages/enterprise/EnterpriseSpendPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/enterprise/EnterpriseSpendPage.js +181 -171
- package/dist/subscriberbot/pages/enterprise/EnterpriseSpendPage.js.map +1 -1
- package/dist/subscriberbot/pages/negotiations/NegotiationDetailPage.d.ts +0 -9
- package/dist/subscriberbot/pages/negotiations/NegotiationDetailPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/negotiations/NegotiationDetailPage.js +164 -164
- package/dist/subscriberbot/pages/negotiations/NegotiationDetailPage.js.map +1 -1
- package/dist/subscriberbot/pages/negotiations/NegotiationNewPage.d.ts +0 -9
- package/dist/subscriberbot/pages/negotiations/NegotiationNewPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/negotiations/NegotiationNewPage.js +197 -181
- package/dist/subscriberbot/pages/negotiations/NegotiationNewPage.js.map +1 -1
- package/dist/subscriberbot/pages/negotiations/NegotiationsPage.d.ts +0 -8
- package/dist/subscriberbot/pages/negotiations/NegotiationsPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/negotiations/NegotiationsPage.js +79 -79
- package/dist/subscriberbot/pages/negotiations/NegotiationsPage.js.map +1 -1
- package/dist/subscriberbot/pages/procurement/ProcurementDetailPage.d.ts +0 -9
- package/dist/subscriberbot/pages/procurement/ProcurementDetailPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/procurement/ProcurementDetailPage.js +147 -147
- package/dist/subscriberbot/pages/procurement/ProcurementDetailPage.js.map +1 -1
- package/dist/subscriberbot/pages/procurement/ProcurementNewPage.d.ts +0 -10
- package/dist/subscriberbot/pages/procurement/ProcurementNewPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/procurement/ProcurementNewPage.js +204 -188
- package/dist/subscriberbot/pages/procurement/ProcurementNewPage.js.map +1 -1
- package/dist/subscriberbot/pages/procurement/ProcurementPage.d.ts +0 -9
- package/dist/subscriberbot/pages/procurement/ProcurementPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/procurement/ProcurementPage.js +80 -80
- package/dist/subscriberbot/pages/procurement/ProcurementPage.js.map +1 -1
- package/dist/subscriberbot/pages/providers/ProviderDetailPage.d.ts +0 -10
- package/dist/subscriberbot/pages/providers/ProviderDetailPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/providers/ProviderDetailPage.js +484 -458
- package/dist/subscriberbot/pages/providers/ProviderDetailPage.js.map +1 -1
- package/dist/subscriberbot/pages/providers/ProviderNewPage.d.ts +0 -8
- package/dist/subscriberbot/pages/providers/ProviderNewPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/providers/ProviderNewPage.js +146 -136
- package/dist/subscriberbot/pages/providers/ProviderNewPage.js.map +1 -1
- package/dist/subscriberbot/pages/providers/ProvidersListPage.d.ts +0 -10
- package/dist/subscriberbot/pages/providers/ProvidersListPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/providers/ProvidersListPage.js +88 -87
- package/dist/subscriberbot/pages/providers/ProvidersListPage.js.map +1 -1
- package/dist/subscriberbot/pages/relationships/RelationshipDetailPage.d.ts +0 -11
- package/dist/subscriberbot/pages/relationships/RelationshipDetailPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/relationships/RelationshipDetailPage.js +520 -490
- package/dist/subscriberbot/pages/relationships/RelationshipDetailPage.js.map +1 -1
- package/dist/subscriberbot/pages/relationships/RelationshipNewPage.d.ts +0 -8
- package/dist/subscriberbot/pages/relationships/RelationshipNewPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/relationships/RelationshipNewPage.js +104 -90
- package/dist/subscriberbot/pages/relationships/RelationshipNewPage.js.map +1 -1
- package/dist/subscriberbot/pages/relationships/RelationshipsListPage.d.ts +0 -8
- package/dist/subscriberbot/pages/relationships/RelationshipsListPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/relationships/RelationshipsListPage.js +97 -96
- package/dist/subscriberbot/pages/relationships/RelationshipsListPage.js.map +1 -1
- package/dist/subscriberbot/pages/workflows/WorkflowBuilderPage.d.ts.map +1 -1
- package/dist/subscriberbot/pages/workflows/WorkflowBuilderPage.js +76 -74
- package/dist/subscriberbot/pages/workflows/WorkflowBuilderPage.js.map +1 -1
- package/dist/subscriberbot/pages/workflows/workflowBuilderGraph.d.ts +5 -3
- package/dist/subscriberbot/pages/workflows/workflowBuilderGraph.d.ts.map +1 -1
- package/dist/subscriberbot/pages/workflows/workflowBuilderGraph.js +26 -25
- package/dist/subscriberbot/pages/workflows/workflowBuilderGraph.js.map +1 -1
- package/dist/subscriberbot/utils/formatters.d.ts +16 -5
- package/dist/subscriberbot/utils/formatters.d.ts.map +1 -1
- package/dist/subscriberbot/utils/formatters.js +57 -25
- package/dist/subscriberbot/utils/formatters.js.map +1 -1
- package/dist/subscriberbot/utils/plaidLink.d.ts +2 -1
- package/dist/subscriberbot/utils/plaidLink.d.ts.map +1 -1
- package/dist/subscriberbot/utils/plaidLink.js +21 -21
- package/dist/subscriberbot/utils/plaidLink.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SavingsCards.js","names":[],"sources":["../../../../src/subscriberbot/components/savings/SavingsCards.tsx"],"sourcesContent":["/**\n * Savings cards (BOFF-4001)\n * @module subscriberbot/components/savings\n *\n * `SavingsCard` is the compact action card on `/subscriberbot/savings`: one\n * open decision with the subscription, its current price, the recommended\n * action, the yearly saving, rationale, confidence and the rows it used.\n * Apply and Dismiss reuse the decision dialogs, so a cancel still needs the\n * named acknowledgement before it can run.\n *\n * `BundleCard` is a bundle (consolidation) suggestion, one duplicate/overlap\n * group from BOFF-3703: the overlapping subscriptions with links to each, the\n * cost today and after, and a Consolidate flow that keeps the recommended\n * subscription (optionally on a bundled plan) and cancels the ones it fully\n * covers through `subConsolidateRelationships`.\n */\n\nimport { useState, type FC, type FormEvent } from 'react';\nimport {\n ArrowDownRight,\n CalendarRange,\n CheckCircle2,\n Combine,\n ExternalLink,\n Gauge,\n Layers,\n ShieldAlert,\n Trash2,\n XCircle,\n} from 'lucide-react';\nimport { GlassCard } from '@burdenoff/fe-libs/ui';\nimport { Modal } from '../Modal';\nimport {\n ApplyDecisionDialog,\n DecisionSources,\n DismissDecisionDialog,\n RECOMMENDATION_LABEL,\n confidencePercent,\n isDestructive,\n relationshipSnapshot,\n} from '../decisions';\nimport { useTr } from '../../hooks/useTr';\nimport { useSubscriberBot } from '../../context/SubscriberBotContext';\nimport { useConsolidateRelationships, useDismissBundle } from '../../hooks/useSubscriberBotApi';\nimport { formatCurrency, formatEnumLabel } from '../../utils/formatters';\nimport { cn } from '../../utils/cn';\nimport type {\n SubBillingInterval,\n SubOverlap,\n SubOverlapMember,\n SubConsolidationResult,\n SubDecision,\n} from '../../types';\nimport {\n bundleMembers,\n parseBundledAmount,\n projectedConsolidationSavings,\n sectionOf,\n type SavingsSectionId,\n} from './savingsModel';\n\nconst SECTION_ICON: Record<SavingsSectionId, typeof Trash2> = {\n cancel: Trash2,\n downgrade: ArrowDownRight,\n annual: CalendarRange,\n other: Layers,\n};\n\nconst BUNDLED_INTERVALS: SubBillingInterval[] = ['MONTHLY', 'QUARTERLY', 'YEARLY'];\n\nfunction errorText(err: unknown, fallback: string): string {\n return err instanceof Error && err.message ? err.message : fallback;\n}\n\nfunction priceText(amount: number, currency: string, interval: string): string {\n return `${formatCurrency(amount, currency)} / ${formatEnumLabel(interval).toLowerCase()}`;\n}\n\n// ---------------------------------------------------------------------------\n// Decision savings card\n// ---------------------------------------------------------------------------\n\nexport const SavingsCard: FC<{ decision: SubDecision }> = ({ decision }) => {\n const tr = useTr();\n const { navigateTo } = useSubscriberBot();\n const [dialog, setDialog] = useState<'apply' | 'dismiss' | null>(null);\n const rec = RECOMMENDATION_LABEL[decision.recommendation];\n const destructive = isDestructive(decision.recommendation);\n const snap = relationshipSnapshot(decision);\n const Icon = SECTION_ICON[sectionOf(decision.recommendation)];\n const label = snap.label ?? decision.relationshipId;\n\n return (\n <GlassCard\n treatment=\"metric\"\n className=\"flex flex-col gap-3 p-4\"\n data-testid=\"savings-card\"\n data-decision-id={decision.id}\n data-recommendation={decision.recommendation}\n >\n <div className=\"flex items-start gap-3\">\n <span\n className={cn(\n 'flex size-9 shrink-0 items-center justify-center rounded-lg',\n destructive\n ? 'bg-status-error-bg-subtle text-status-error-text'\n : 'bg-bg-sunken text-text-secondary'\n )}\n aria-hidden\n >\n <Icon className=\"h-4 w-4\" />\n </span>\n <div className=\"min-w-0 flex-1\">\n <p className=\"text-sm font-semibold text-text-primary\">{tr(rec.key, rec.fallback)}</p>\n <button\n type=\"button\"\n onClick={() => navigateTo(`/relationships/${decision.relationshipId}`)}\n className=\"block max-w-full truncate text-left text-sm text-text-primary hover:underline\"\n data-testid=\"savings-card-relationship\"\n >\n {label}\n </button>\n {snap.amount !== null && (\n <p className=\"text-xs tabular-nums text-text-secondary\">\n {tr('savings.card.current', 'Now {{price}}', {\n price: priceText(\n snap.amount,\n snap.currency ?? decision.currency,\n snap.interval ?? 'MONTHLY'\n ),\n })}\n </p>\n )}\n </div>\n {decision.estimatedSavings > 0 && (\n <p\n className=\"shrink-0 text-right text-sm font-semibold tabular-nums text-status-success-text\"\n data-testid=\"savings-card-amount\"\n >\n {tr('savings.card.save', 'Save {{amount}}', {\n amount: formatCurrency(decision.estimatedSavings, decision.currency),\n })}\n <span className=\"block text-[11px] font-normal text-text-secondary\">\n {tr('savings.card.perYear', 'per year')}\n </span>\n </p>\n )}\n </div>\n\n <p className=\"text-sm text-text-secondary\">{decision.rationale}</p>\n\n <div className=\"flex flex-wrap items-center gap-2 text-xs\">\n <span className=\"inline-flex items-center gap-1.5 rounded-md bg-bg-sunken px-2 py-0.5 text-text-secondary\">\n <Gauge className=\"h-3.5 w-3.5\" aria-hidden />\n {tr('decisions.card.confidence', 'Confidence {{pct}}%', {\n pct: confidencePercent(decision.confidence),\n })}\n </span>\n <button\n type=\"button\"\n onClick={() => navigateTo(`/decisions/${decision.id}`)}\n className=\"inline-flex items-center gap-1 rounded-md px-1 text-text-secondary hover:text-text-primary\"\n >\n {tr('savings.card.details', 'Details')}\n <ExternalLink className=\"h-3 w-3\" aria-hidden />\n </button>\n </div>\n\n <DecisionSources decision={decision} limit={3} />\n\n <div className=\"flex flex-wrap justify-end gap-2 border-t border-border-subtle pt-3\">\n <button\n type=\"button\"\n onClick={() => setDialog('dismiss')}\n data-testid=\"savings-dismiss\"\n className=\"inline-flex items-center gap-1.5 rounded-lg border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <XCircle className=\"h-3.5 w-3.5\" aria-hidden />\n {tr('decisions.card.dismiss', 'Dismiss')}\n </button>\n <button\n type=\"button\"\n onClick={() => setDialog('apply')}\n data-testid=\"savings-apply\"\n className={cn(\n 'inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-medium hover:opacity-90',\n destructive\n ? 'border border-status-error-text/40 bg-status-error-bg-subtle text-status-error-text'\n : 'bg-action-primary-bg text-action-primary-text'\n )}\n >\n <CheckCircle2 className=\"h-3.5 w-3.5\" aria-hidden />\n {tr('savings.card.apply', 'Apply')}\n </button>\n </div>\n\n {dialog === 'apply' && (\n <ApplyDecisionDialog decision={decision} onClose={() => setDialog(null)} />\n )}\n {dialog === 'dismiss' && (\n <DismissDecisionDialog decision={decision} onClose={() => setDialog(null)} />\n )}\n </GlassCard>\n );\n};\n\n// ---------------------------------------------------------------------------\n// Bundle consolidation dialog\n// ---------------------------------------------------------------------------\n\nconst ROLE_STYLE: Record<'keep' | 'cancel' | 'untouched', string> = {\n keep: 'bg-status-success-bg-subtle text-status-success-text',\n cancel: 'bg-status-error-bg-subtle text-status-error-text',\n untouched: 'bg-bg-sunken text-text-secondary',\n};\n\nconst RoleBadge: FC<{ role: 'keep' | 'cancel' | 'untouched' }> = ({ role }) => {\n const tr = useTr();\n const label = {\n keep: tr('savings.bundle.keep', 'Keep'),\n cancel: tr('savings.bundle.cancel', 'Cancel'),\n untouched: tr('savings.bundle.leftAlone', 'Left alone'),\n }[role];\n return (\n <span\n className={cn(\n 'shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium uppercase',\n ROLE_STYLE[role]\n )}\n >\n {label}\n </span>\n );\n};\n\nconst ConsolidateMemberRow: FC<{\n member: SubOverlapMember;\n role: 'keep' | 'cancel' | 'untouched';\n}> = ({ member, role }) => (\n <li\n className=\"flex items-center gap-2.5 rounded-lg border border-border-subtle px-3 py-2 text-sm\"\n data-role={role}\n >\n <RoleBadge role={role} />\n <span className=\"min-w-0 flex-1 truncate text-text-primary\">{member.label}</span>\n <span className=\"shrink-0 tabular-nums text-text-secondary\">\n {priceText(member.amount, member.currency, member.interval)}\n </span>\n </li>\n);\n\nconst ConsolidateDialog: FC<{\n bundle: SubOverlap;\n onClose: () => void;\n onDone: (result: SubConsolidationResult) => void;\n}> = ({ bundle, onClose, onDone }) => {\n const tr = useTr();\n const consolidate = useConsolidateRelationships();\n const [priceRaw, setPriceRaw] = useState('');\n const [bundledInterval, setBundledInterval] = useState<SubBillingInterval>('MONTHLY');\n const [acknowledged, setAcknowledged] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n const { keep, cancel, untouched } = bundleMembers(bundle);\n const bundledAmount = parseBundledAmount(priceRaw);\n const priceInvalid = Number.isNaN(bundledAmount);\n const bundledPlan =\n bundledAmount !== null && !priceInvalid\n ? { amount: bundledAmount, interval: bundledInterval }\n : null;\n const projected = projectedConsolidationSavings(bundle, bundledPlan);\n const cancelNames = cancel.map((m) => `\"${m.label}\"`).join(', ');\n const canSubmit = acknowledged && !priceInvalid && !consolidate.isPending && keep !== null;\n\n const submit = (e: FormEvent) => {\n e.preventDefault();\n if (!canSubmit) return;\n setError(null);\n consolidate.mutate(\n {\n keepRelationshipId: bundle.keepRelationshipId,\n cancelRelationshipIds: cancel.map((m) => m.relationshipId),\n ...(bundledPlan ? { amount: bundledPlan.amount, interval: bundledPlan.interval } : {}),\n },\n {\n onSuccess: (result) => {\n onDone(result);\n onClose();\n },\n onError: (err) =>\n setError(errorText(err, tr('savings.bundle.consolidateError', 'Could not consolidate.'))),\n }\n );\n };\n\n return (\n <Modal\n title={tr('savings.bundle.consolidateTitle', 'Consolidate subscriptions')}\n description={tr(\n 'savings.bundle.consolidateDescription',\n 'Keep one subscription and cancel the others. Each cancel is the same change you could make by hand.'\n )}\n onClose={onClose}\n >\n <form onSubmit={submit} className=\"space-y-4\" data-testid=\"consolidate-dialog\">\n <ul className=\"space-y-1.5\" data-testid=\"consolidate-members\">\n {keep && <ConsolidateMemberRow member={keep} role=\"keep\" />}\n {cancel.map((m) => (\n <ConsolidateMemberRow key={m.relationshipId} member={m} role=\"cancel\" />\n ))}\n {untouched.map((m) => (\n <ConsolidateMemberRow key={m.relationshipId} member={m} role=\"untouched\" />\n ))}\n </ul>\n {untouched.length > 0 && (\n <p className=\"text-xs text-text-secondary\">\n {tr(\n 'savings.bundle.untouched',\n 'Subscriptions marked \"Left alone\" cover something the kept one does not, so they are not cancelled.'\n )}\n </p>\n )}\n\n <div>\n <p className=\"mb-1.5 text-xs font-medium text-text-secondary\">\n {tr(\n 'savings.bundle.planLabel',\n 'Bundled plan price for the kept subscription (optional)'\n )}\n </p>\n <div className=\"flex gap-2\">\n <input\n type=\"number\"\n inputMode=\"decimal\"\n min=\"0\"\n step=\"0.01\"\n value={priceRaw}\n onChange={(e) => setPriceRaw(e.target.value)}\n placeholder={\n keep ? String(keep.amount) : tr('savings.bundle.planPlaceholder', 'Same price')\n }\n aria-label={tr('savings.bundle.planAmount', 'Bundled plan amount')}\n aria-invalid={priceInvalid}\n data-testid=\"consolidate-amount\"\n className=\"w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n />\n <select\n value={bundledInterval}\n onChange={(e) => setBundledInterval(e.target.value as SubBillingInterval)}\n aria-label={tr('savings.bundle.planInterval', 'Billing interval')}\n className=\"rounded-lg border border-border-subtle bg-bg-surface px-2 py-2 text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n >\n {BUNDLED_INTERVALS.map((i) => (\n <option key={i} value={i}>\n {formatEnumLabel(i)}\n </option>\n ))}\n </select>\n </div>\n {priceInvalid && (\n <p className=\"mt-1 text-xs text-status-error-text\">\n {tr('savings.bundle.planInvalid', 'Enter zero or a positive amount.')}\n </p>\n )}\n </div>\n\n <p className=\"text-sm text-text-primary\" data-testid=\"consolidate-projected\">\n {tr('savings.bundle.projected', 'Estimated saving: {{amount}} a year', {\n amount: formatCurrency(Math.max(projected, 0), bundle.currency),\n })}\n </p>\n\n <label className=\"flex items-start gap-2.5 rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-3 text-sm text-status-error-text\">\n <input\n type=\"checkbox\"\n checked={acknowledged}\n onChange={(e) => setAcknowledged(e.target.checked)}\n className=\"mt-0.5 size-4 shrink-0 rounded border-border-subtle\"\n data-testid=\"consolidate-acknowledge\"\n />\n <span>\n {tr(\n 'savings.bundle.acknowledge',\n 'I want to cancel {{names}} and keep \"{{keep}}\". I understand the cancelled subscriptions will stop.',\n { names: cancelNames, keep: keep?.label ?? '' }\n )}\n </span>\n </label>\n\n {error && (\n <div className=\"rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text\">\n {error}\n </div>\n )}\n\n <div className=\"flex justify-end gap-3\">\n <button\n type=\"button\"\n onClick={onClose}\n className=\"rounded-lg border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n {tr('decisions.apply.back', 'Not now')}\n </button>\n <button\n type=\"submit\"\n disabled={!canSubmit}\n data-testid=\"confirm-consolidate\"\n className=\"rounded-lg bg-action-danger-bg px-4 py-2 text-sm font-medium text-action-danger-text hover:bg-action-danger-bg-hover disabled:cursor-not-allowed disabled:opacity-50\"\n >\n {consolidate.isPending\n ? tr('savings.bundle.consolidating', 'Consolidating…')\n : tr('savings.bundle.consolidateSubmit', 'Consolidate')}\n </button>\n </div>\n </form>\n </Modal>\n );\n};\n\nconst DismissBundleDialog: FC<{ bundle: SubOverlap; onClose: () => void }> = ({\n bundle,\n onClose,\n}) => {\n const tr = useTr();\n const dismiss = useDismissBundle();\n const [reason, setReason] = useState('');\n const [error, setError] = useState<string | null>(null);\n\n const submit = (e: FormEvent) => {\n e.preventDefault();\n setError(null);\n dismiss.mutate(\n { id: bundle.id, reason },\n {\n onSuccess: () => onClose(),\n onError: (err) =>\n setError(errorText(err, tr('savings.bundle.dismissError', 'Could not dismiss.'))),\n }\n );\n };\n\n return (\n <Modal\n title={tr('savings.bundle.dismissTitle', 'Dismiss bundle suggestion')}\n description={tr(\n 'savings.bundle.dismissDescription',\n 'It stays hidden until one of these subscriptions changes.'\n )}\n onClose={onClose}\n >\n <form onSubmit={submit} className=\"space-y-4\" data-testid=\"dismiss-bundle-dialog\">\n <div>\n <label\n htmlFor={`dismiss-bundle-${bundle.id}`}\n className=\"mb-1 block text-xs font-medium text-text-secondary\"\n >\n {tr('decisions.dismiss.reason', 'Reason (optional)')}\n </label>\n <textarea\n id={`dismiss-bundle-${bundle.id}`}\n value={reason}\n onChange={(e) => setReason(e.target.value)}\n rows={3}\n maxLength={500}\n placeholder={tr('savings.bundle.dismissPlaceholder', 'e.g. They cover different needs')}\n className=\"w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n />\n </div>\n {error && (\n <div className=\"rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text\">\n {error}\n </div>\n )}\n <div className=\"flex justify-end gap-3\">\n <button\n type=\"button\"\n onClick={onClose}\n className=\"rounded-lg border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n {tr('decisions.dismiss.back', 'Back')}\n </button>\n <button\n type=\"submit\"\n disabled={dismiss.isPending}\n data-testid=\"confirm-dismiss-bundle\"\n className=\"rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50\"\n >\n {dismiss.isPending\n ? tr('decisions.dismiss.dismissing', 'Dismissing…')\n : tr('decisions.dismiss.submit', 'Dismiss')}\n </button>\n </div>\n </form>\n </Modal>\n );\n};\n\n// ---------------------------------------------------------------------------\n// Bundle card\n// ---------------------------------------------------------------------------\n\nexport const BundleCard: FC<{\n bundle: SubOverlap;\n onConsolidated?: (result: SubConsolidationResult) => void;\n}> = ({ bundle, onConsolidated }) => {\n const tr = useTr();\n const { navigateTo } = useSubscriberBot();\n const [dialog, setDialog] = useState<'consolidate' | 'dismiss' | null>(null);\n const { keep, cancel } = bundleMembers(bundle);\n const drop = new Set(bundle.dropRelationshipIds);\n const heading = {\n EXACT_DUPLICATE: tr('savings.bundle.exactDuplicate', 'Merge duplicate subscriptions'),\n CAPABILITY: tr('savings.bundle.capability', 'Several services for {{capability}}', {\n capability: bundle.title,\n }),\n ENTITLEMENT: tr('savings.bundle.entitlement', 'Covered by a subscription you keep'),\n }[bundle.type];\n const afterCost = bundle.annualSpend - bundle.annualSavings;\n\n return (\n <GlassCard\n treatment=\"metric\"\n className=\"flex flex-col gap-3 border border-status-warning-text/30 p-4\"\n data-testid=\"bundle-card\"\n data-bundle-id={bundle.id}\n data-type={bundle.type}\n >\n <div className=\"flex items-start gap-3\">\n <span\n className=\"flex size-9 shrink-0 items-center justify-center rounded-lg bg-status-warning-bg-subtle text-status-warning-text\"\n aria-hidden\n >\n <Combine className=\"h-4 w-4\" />\n </span>\n <div className=\"min-w-0 flex-1\">\n <p className=\"text-[11px] font-medium uppercase tracking-wide text-text-secondary\">\n {tr('savings.bundle.label', 'Bundle suggestion')}\n {bundle.type === 'EXACT_DUPLICATE' && bundle.title ? ` · ${bundle.title}` : ''}\n </p>\n <p className=\"text-sm font-semibold text-text-primary\">{heading}</p>\n </div>\n <p\n className=\"shrink-0 text-right text-sm font-semibold tabular-nums text-status-success-text\"\n data-testid=\"bundle-card-amount\"\n >\n {tr('savings.card.save', 'Save {{amount}}', {\n amount: formatCurrency(bundle.annualSavings, bundle.currency),\n })}\n <span className=\"block text-[11px] font-normal text-text-secondary\">\n {tr('savings.card.perYear', 'per year')}\n </span>\n </p>\n </div>\n\n <p className=\"text-sm text-text-secondary\">{bundle.rationale}</p>\n\n <ul className=\"space-y-1\" data-testid=\"bundle-relationships\">\n {bundle.members.map((m) => {\n const role =\n m.relationshipId === bundle.keepRelationshipId\n ? 'keep'\n : drop.has(m.relationshipId)\n ? 'cancel'\n : 'untouched';\n return (\n <li key={m.relationshipId}>\n <button\n type=\"button\"\n onClick={() => navigateTo(`/relationships/${m.relationshipId}`)}\n data-relationship-id={m.relationshipId}\n data-role={role}\n className=\"flex w-full items-center gap-2 rounded-md border border-border-subtle bg-bg-sunken px-2.5 py-1.5 text-left text-xs hover:bg-bg-surface\"\n >\n <RoleBadge role={role} />\n <span className=\"min-w-0 flex-1 truncate font-medium text-text-primary\">\n {m.label}\n </span>\n <span className=\"shrink-0 tabular-nums text-text-secondary\">\n {priceText(m.amount, m.currency, m.interval)}\n </span>\n <ExternalLink className=\"h-3 w-3 shrink-0 text-text-secondary\" aria-hidden />\n </button>\n </li>\n );\n })}\n </ul>\n\n <div className=\"flex flex-wrap gap-2 text-xs\">\n <span className=\"inline-flex items-center rounded-md bg-bg-sunken px-2 py-0.5 tabular-nums text-text-secondary\">\n {tr('savings.bundle.costChange', '{{before}} → {{after}} a year', {\n before: formatCurrency(bundle.annualSpend, bundle.currency),\n after: formatCurrency(afterCost, bundle.currency),\n })}\n </span>\n <span className=\"inline-flex items-center gap-1.5 rounded-md bg-bg-sunken px-2 py-0.5 text-text-secondary\">\n <Gauge className=\"h-3.5 w-3.5\" aria-hidden />\n {tr('decisions.card.confidence', 'Confidence {{pct}}%', {\n pct: confidencePercent(bundle.confidence),\n })}\n </span>\n </div>\n\n <div className=\"flex flex-wrap justify-end gap-2 border-t border-border-subtle pt-3\">\n <button\n type=\"button\"\n onClick={() => setDialog('dismiss')}\n data-testid=\"bundle-dismiss\"\n className=\"inline-flex items-center gap-1.5 rounded-lg border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <XCircle className=\"h-3.5 w-3.5\" aria-hidden />\n {tr('decisions.card.dismiss', 'Dismiss')}\n </button>\n <button\n type=\"button\"\n onClick={() => setDialog('consolidate')}\n disabled={!keep || cancel.length === 0}\n data-testid=\"bundle-consolidate\"\n className=\"inline-flex items-center gap-1.5 rounded-lg border border-status-error-text/40 bg-status-error-bg-subtle px-3 py-1.5 text-xs font-medium text-status-error-text hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50\"\n >\n <ShieldAlert className=\"h-3.5 w-3.5\" aria-hidden />\n {tr('savings.bundle.consolidate', 'Review and consolidate')}\n </button>\n </div>\n\n {dialog === 'consolidate' && (\n <ConsolidateDialog\n bundle={bundle}\n onClose={() => setDialog(null)}\n onDone={(result) => onConsolidated?.(result)}\n />\n )}\n {dialog === 'dismiss' && (\n <DismissBundleDialog bundle={bundle} onClose={() => setDialog(null)} />\n )}\n </GlassCard>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;AA6DA,IAAM,IAAwD;CAC5D,QAAQ;CACR,WAAW;CACX,QAAQ;CACR,OAAO;AACT,GAEM,IAA0C;CAAC;CAAW;CAAa;AAAQ;AAEjF,SAAS,EAAU,GAAc,GAA0B;CACzD,OAAO,aAAe,SAAS,EAAI,UAAU,EAAI,UAAU;AAC7D;AAEA,SAAS,EAAU,GAAgB,GAAkB,GAA0B;CAC7E,OAAO,GAAG,EAAe,GAAQ,CAAQ,EAAE,KAAK,EAAgB,CAAQ,EAAE,YAAY;AACxF;AAMA,IAAa,KAA8C,EAAE,kBAAe;CAC1E,IAAM,IAAK,EAAM,GACX,EAAE,kBAAe,EAAiB,GAClC,CAAC,GAAQ,KAAa,EAAqC,IAAI,GAC/D,IAAM,EAAqB,EAAS,iBACpC,IAAc,EAAc,EAAS,cAAc,GACnD,IAAO,EAAqB,CAAQ,GACpC,IAAO,EAAa,EAAU,EAAS,cAAc,IACrD,IAAQ,EAAK,SAAS,EAAS;CAErC,OACE,kBAAC,GAAD;EACE,WAAU;EACV,WAAU;EACV,eAAY;EACZ,oBAAkB,EAAS;EAC3B,uBAAqB,EAAS;YALhC;GAOE,kBAAC,OAAD;IAAK,WAAU;cAAf;KACE,kBAAC,QAAD;MACE,WAAW,EACT,+DACA,IACI,qDACA,kCACN;MACA,eAAA;gBAEA,kBAAC,GAAD,EAAM,WAAU,UAAW,CAAA;KACvB,CAAA;KACN,kBAAC,OAAD;MAAK,WAAU;gBAAf;OACE,kBAAC,KAAD;QAAG,WAAU;kBAA2C,EAAG,EAAI,KAAK,EAAI,QAAQ;OAAK,CAAA;OACrF,kBAAC,UAAD;QAC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S,CACjC;QACR,kBAAC,UAAD;KACE,MAAK;KACL,eAAe,EAAU,aAAa;KACtC,UAAU,CAAC,KAAQ,EAAO,WAAW;KACrC,eAAY;KACZ,WAAU;eALZ,CAOE,kBAAC,GAAD;MAAa,WAAU;MAAc,eAAA;KAAa,CAAA,GACjD,EAAG,8BAA8B,wBAAwB,CACpD;MACL;;GAEJ,MAAW,iBACV,kBAAC,GAAD;IACU;IACR,eAAe,EAAU,IAAI;IAC7B,SAAS,MAAW,IAAiB,CAAM;GAC5C,CAAA;GAEF,MAAW,aACV,kBAAC,GAAD;IAA6B;IAAQ,eAAe,EAAU,IAAI;GAAI,CAAA;EAE/D;;AAEf"}
|
|
1
|
+
{"version":3,"file":"SavingsCards.js","names":[],"sources":["../../../../src/subscriberbot/components/savings/SavingsCards.tsx"],"sourcesContent":["import { useFormatters } from '../../hooks/useFormatters';\n/**\n * Savings cards (BOFF-4001)\n * @module subscriberbot/components/savings\n *\n * `SavingsCard` is the compact action card on `/subscriberbot/savings`: one\n * open decision with the subscription, its current price, the recommended\n * action, the yearly saving, rationale, confidence and the rows it used.\n * Apply and Dismiss reuse the decision dialogs, so a cancel still needs the\n * named acknowledgement before it can run.\n *\n * `BundleCard` is a bundle (consolidation) suggestion, one duplicate/overlap\n * group from BOFF-3703: the overlapping subscriptions with links to each, the\n * cost today and after, and a Consolidate flow that keeps the recommended\n * subscription (optionally on a bundled plan) and cancels the ones it fully\n * covers through `subConsolidateRelationships`.\n */\n\nimport { useState, type FC, type FormEvent } from 'react';\nimport {\n ArrowDownRight,\n CalendarRange,\n CheckCircle2,\n Combine,\n ExternalLink,\n Gauge,\n Layers,\n ShieldAlert,\n Trash2,\n XCircle,\n} from 'lucide-react';\nimport { GlassCard } from '@burdenoff/fe-libs/ui';\nimport { Modal } from '../Modal';\nimport {\n ApplyDecisionDialog,\n DecisionSources,\n DismissDecisionDialog,\n RECOMMENDATION_LABEL,\n confidencePercent,\n isDestructive,\n relationshipSnapshot,\n} from '../decisions';\nimport { useTr } from '../../hooks/useTr';\nimport { useSubscriberBot } from '../../context/SubscriberBotContext';\nimport { useConsolidateRelationships, useDismissBundle } from '../../hooks/useSubscriberBotApi';\n\nimport { cn } from '../../utils/cn';\nimport type {\n SubBillingInterval,\n SubOverlap,\n SubOverlapMember,\n SubConsolidationResult,\n SubDecision,\n} from '../../types';\nimport {\n bundleMembers,\n parseBundledAmount,\n projectedConsolidationSavings,\n sectionOf,\n type SavingsSectionId,\n} from './savingsModel';\n\nconst SECTION_ICON: Record<SavingsSectionId, typeof Trash2> = {\n cancel: Trash2,\n downgrade: ArrowDownRight,\n annual: CalendarRange,\n other: Layers,\n};\n\nconst BUNDLED_INTERVALS: SubBillingInterval[] = ['MONTHLY', 'QUARTERLY', 'YEARLY'];\n\nfunction errorText(err: unknown, fallback: string): string {\n return err instanceof Error && err.message ? err.message : fallback;\n}\n\n// ---------------------------------------------------------------------------\n// Decision savings card\n// ---------------------------------------------------------------------------\n\nexport const SavingsCard: FC<{ decision: SubDecision }> = ({ decision }) => {\n const { formatCurrency, formatPrice } = useFormatters();\n\n const tr = useTr();\n const { navigateTo } = useSubscriberBot();\n const [dialog, setDialog] = useState<'apply' | 'dismiss' | null>(null);\n const rec = RECOMMENDATION_LABEL[decision.recommendation];\n const destructive = isDestructive(decision.recommendation);\n const snap = relationshipSnapshot(decision);\n const Icon = SECTION_ICON[sectionOf(decision.recommendation)];\n const label = snap.label ?? decision.relationshipId;\n\n return (\n <GlassCard\n treatment=\"metric\"\n className=\"flex flex-col gap-3 p-4\"\n data-testid=\"savings-card\"\n data-decision-id={decision.id}\n data-recommendation={decision.recommendation}\n >\n <div className=\"flex items-start gap-3\">\n <span\n className={cn(\n 'flex size-9 shrink-0 items-center justify-center rounded-lg',\n destructive\n ? 'bg-status-error-bg-subtle text-status-error-text'\n : 'bg-bg-sunken text-text-secondary'\n )}\n aria-hidden\n >\n <Icon className=\"h-4 w-4\" />\n </span>\n <div className=\"min-w-0 flex-1\">\n <p className=\"text-sm font-semibold text-text-primary\">{tr(rec.key, rec.fallback)}</p>\n <button\n type=\"button\"\n onClick={() => navigateTo(`/relationships/${decision.relationshipId}`)}\n className=\"block max-w-full truncate text-start text-sm text-text-primary hover:underline\"\n data-testid=\"savings-card-relationship\"\n >\n {label}\n </button>\n {snap.amount !== null && (\n <p className=\"text-xs tabular-nums text-text-secondary\">\n {tr('savings.card.current', 'Now {{price}}', {\n price: formatPrice(\n snap.amount,\n snap.currency ?? decision.currency,\n snap.interval ?? 'MONTHLY'\n ),\n })}\n </p>\n )}\n </div>\n {decision.estimatedSavings > 0 && (\n <p\n className=\"shrink-0 text-end text-sm font-semibold tabular-nums text-status-success-text\"\n data-testid=\"savings-card-amount\"\n >\n {tr('savings.card.save', 'Save {{amount}}', {\n amount: formatCurrency(decision.estimatedSavings, decision.currency),\n })}\n <span className=\"block text-[11px] font-normal text-text-secondary\">\n {tr('savings.card.perYear', 'per year')}\n </span>\n </p>\n )}\n </div>\n\n <p className=\"text-sm text-text-secondary\">{decision.rationale}</p>\n\n <div className=\"flex flex-wrap items-center gap-2 text-xs\">\n <span className=\"inline-flex items-center gap-1.5 rounded-md bg-bg-sunken px-2 py-0.5 text-text-secondary\">\n <Gauge className=\"h-3.5 w-3.5\" aria-hidden />\n {tr('decisions.card.confidence', 'Confidence {{pct}}%', {\n pct: confidencePercent(decision.confidence),\n })}\n </span>\n <button\n type=\"button\"\n onClick={() => navigateTo(`/decisions/${decision.id}`)}\n className=\"inline-flex items-center gap-1 rounded-md px-1 text-text-secondary hover:text-text-primary\"\n >\n {tr('savings.card.details', 'Details')}\n <ExternalLink className=\"h-3 w-3\" aria-hidden />\n </button>\n </div>\n\n <DecisionSources decision={decision} limit={3} />\n\n <div className=\"flex flex-wrap justify-end gap-2 border-t border-border-subtle pt-3\">\n <button\n type=\"button\"\n onClick={() => setDialog('dismiss')}\n data-testid=\"savings-dismiss\"\n className=\"inline-flex items-center gap-1.5 rounded-lg border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <XCircle className=\"h-3.5 w-3.5\" aria-hidden />\n {tr('decisions.card.dismiss', 'Dismiss')}\n </button>\n <button\n type=\"button\"\n onClick={() => setDialog('apply')}\n data-testid=\"savings-apply\"\n className={cn(\n 'inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-medium hover:opacity-90',\n destructive\n ? 'border border-status-error-text/40 bg-status-error-bg-subtle text-status-error-text'\n : 'bg-action-primary-bg text-action-primary-text'\n )}\n >\n <CheckCircle2 className=\"h-3.5 w-3.5\" aria-hidden />\n {tr('savings.card.apply', 'Apply')}\n </button>\n </div>\n\n {dialog === 'apply' && (\n <ApplyDecisionDialog decision={decision} onClose={() => setDialog(null)} />\n )}\n {dialog === 'dismiss' && (\n <DismissDecisionDialog decision={decision} onClose={() => setDialog(null)} />\n )}\n </GlassCard>\n );\n};\n\n// ---------------------------------------------------------------------------\n// Bundle consolidation dialog\n// ---------------------------------------------------------------------------\n\nconst ROLE_STYLE: Record<'keep' | 'cancel' | 'untouched', string> = {\n keep: 'bg-status-success-bg-subtle text-status-success-text',\n cancel: 'bg-status-error-bg-subtle text-status-error-text',\n untouched: 'bg-bg-sunken text-text-secondary',\n};\n\nconst RoleBadge: FC<{ role: 'keep' | 'cancel' | 'untouched' }> = ({ role }) => {\n const tr = useTr();\n const label = {\n keep: tr('savings.bundle.keep', 'Keep'),\n cancel: tr('savings.bundle.cancel', 'Cancel'),\n untouched: tr('savings.bundle.leftAlone', 'Left alone'),\n }[role];\n return (\n <span\n className={cn(\n 'shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium uppercase',\n ROLE_STYLE[role]\n )}\n >\n {label}\n </span>\n );\n};\n\nconst ConsolidateMemberRow: FC<{\n member: SubOverlapMember;\n role: 'keep' | 'cancel' | 'untouched';\n}> = ({ member, role }) => {\n const { formatPrice } = useFormatters();\n return (\n <li\n className=\"flex items-center gap-2.5 rounded-lg border border-border-subtle px-3 py-2 text-sm\"\n data-role={role}\n >\n <RoleBadge role={role} />\n <span className=\"min-w-0 flex-1 truncate text-text-primary\">{member.label}</span>\n <span className=\"shrink-0 tabular-nums text-text-secondary\">\n {formatPrice(member.amount, member.currency, member.interval)}\n </span>\n </li>\n );\n};\n\nconst ConsolidateDialog: FC<{\n bundle: SubOverlap;\n onClose: () => void;\n onDone: (result: SubConsolidationResult) => void;\n}> = ({ bundle, onClose, onDone }) => {\n const { formatCurrency, formatEnumLabel } = useFormatters();\n\n const tr = useTr();\n const consolidate = useConsolidateRelationships();\n const [priceRaw, setPriceRaw] = useState('');\n const [bundledInterval, setBundledInterval] = useState<SubBillingInterval>('MONTHLY');\n const [acknowledged, setAcknowledged] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n const { keep, cancel, untouched } = bundleMembers(bundle);\n const bundledAmount = parseBundledAmount(priceRaw);\n const priceInvalid = Number.isNaN(bundledAmount);\n const bundledPlan =\n bundledAmount !== null && !priceInvalid\n ? { amount: bundledAmount, interval: bundledInterval }\n : null;\n const projected = projectedConsolidationSavings(bundle, bundledPlan);\n const cancelNames = cancel.map((m) => `\"${m.label}\"`).join(', ');\n const canSubmit = acknowledged && !priceInvalid && !consolidate.isPending && keep !== null;\n\n const submit = (e: FormEvent) => {\n e.preventDefault();\n if (!canSubmit) return;\n setError(null);\n consolidate.mutate(\n {\n keepRelationshipId: bundle.keepRelationshipId,\n cancelRelationshipIds: cancel.map((m) => m.relationshipId),\n ...(bundledPlan ? { amount: bundledPlan.amount, interval: bundledPlan.interval } : {}),\n },\n {\n onSuccess: (result) => {\n onDone(result);\n onClose();\n },\n onError: (err) =>\n setError(errorText(err, tr('savings.bundle.consolidateError', 'Could not consolidate.'))),\n }\n );\n };\n\n return (\n <Modal\n title={tr('savings.bundle.consolidateTitle', 'Consolidate subscriptions')}\n description={tr(\n 'savings.bundle.consolidateDescription',\n 'Keep one subscription and cancel the others. Each cancel is the same change you could make by hand.'\n )}\n onClose={onClose}\n >\n <form onSubmit={submit} className=\"space-y-4\" data-testid=\"consolidate-dialog\">\n <ul className=\"space-y-1.5\" data-testid=\"consolidate-members\">\n {keep && <ConsolidateMemberRow member={keep} role=\"keep\" />}\n {cancel.map((m) => (\n <ConsolidateMemberRow key={m.relationshipId} member={m} role=\"cancel\" />\n ))}\n {untouched.map((m) => (\n <ConsolidateMemberRow key={m.relationshipId} member={m} role=\"untouched\" />\n ))}\n </ul>\n {untouched.length > 0 && (\n <p className=\"text-xs text-text-secondary\">\n {tr(\n 'savings.bundle.untouched',\n 'Subscriptions marked \"Left alone\" cover something the kept one does not, so they are not cancelled.'\n )}\n </p>\n )}\n\n <div>\n <p className=\"mb-1.5 text-xs font-medium text-text-secondary\">\n {tr(\n 'savings.bundle.planLabel',\n 'Bundled plan price for the kept subscription (optional)'\n )}\n </p>\n <div className=\"flex gap-2\">\n <input\n type=\"number\"\n inputMode=\"decimal\"\n min=\"0\"\n step=\"0.01\"\n value={priceRaw}\n onChange={(e) => setPriceRaw(e.target.value)}\n placeholder={\n keep ? String(keep.amount) : tr('savings.bundle.planPlaceholder', 'Same price')\n }\n aria-label={tr('savings.bundle.planAmount', 'Bundled plan amount')}\n aria-invalid={priceInvalid}\n aria-describedby={priceInvalid ? 'consolidate-price-error' : undefined}\n data-testid=\"consolidate-amount\"\n className=\"w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n />\n <select\n value={bundledInterval}\n onChange={(e) => setBundledInterval(e.target.value as SubBillingInterval)}\n aria-label={tr('savings.bundle.planInterval', 'Billing interval')}\n className=\"rounded-lg border border-border-subtle bg-bg-surface px-2 py-2 text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n >\n {BUNDLED_INTERVALS.map((i) => (\n <option key={i} value={i}>\n {formatEnumLabel(i)}\n </option>\n ))}\n </select>\n </div>\n {priceInvalid && (\n <p\n id=\"consolidate-price-error\"\n role=\"alert\"\n className=\"mt-1 text-xs text-status-error-text\"\n >\n {tr('savings.bundle.planInvalid', 'Enter zero or a positive amount.')}\n </p>\n )}\n </div>\n\n <p className=\"text-sm text-text-primary\" data-testid=\"consolidate-projected\">\n {tr('savings.bundle.projected', 'Estimated saving: {{amount}} a year', {\n amount: formatCurrency(Math.max(projected, 0), bundle.currency),\n })}\n </p>\n\n <label className=\"flex items-start gap-2.5 rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-3 text-sm text-status-error-text\">\n <input\n type=\"checkbox\"\n checked={acknowledged}\n onChange={(e) => setAcknowledged(e.target.checked)}\n className=\"mt-0.5 size-4 shrink-0 rounded border-border-subtle\"\n data-testid=\"consolidate-acknowledge\"\n />\n <span>\n {tr(\n 'savings.bundle.acknowledge',\n 'I want to cancel {{names}} and keep \"{{keep}}\". I understand the cancelled subscriptions will stop.',\n { names: cancelNames, keep: keep?.label ?? '' }\n )}\n </span>\n </label>\n\n {error && (\n <div\n role=\"alert\"\n className=\"rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text\"\n >\n {error}\n </div>\n )}\n\n <div className=\"flex justify-end gap-3\">\n <button\n type=\"button\"\n onClick={onClose}\n className=\"rounded-lg border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n {tr('decisions.apply.back', 'Not now')}\n </button>\n <button\n type=\"submit\"\n disabled={!canSubmit}\n data-testid=\"confirm-consolidate\"\n className=\"rounded-lg bg-action-danger-bg px-4 py-2 text-sm font-medium text-action-danger-text hover:bg-action-danger-bg-hover disabled:cursor-not-allowed disabled:opacity-50\"\n >\n {consolidate.isPending\n ? tr('savings.bundle.consolidating', 'Consolidating…')\n : tr('savings.bundle.consolidateSubmit', 'Consolidate')}\n </button>\n </div>\n </form>\n </Modal>\n );\n};\n\nconst DismissBundleDialog: FC<{ bundle: SubOverlap; onClose: () => void }> = ({\n bundle,\n onClose,\n}) => {\n const tr = useTr();\n const dismiss = useDismissBundle();\n const [reason, setReason] = useState('');\n const [error, setError] = useState<string | null>(null);\n\n const submit = (e: FormEvent) => {\n e.preventDefault();\n setError(null);\n dismiss.mutate(\n { id: bundle.id, reason },\n {\n onSuccess: () => onClose(),\n onError: (err) =>\n setError(errorText(err, tr('savings.bundle.dismissError', 'Could not dismiss.'))),\n }\n );\n };\n\n return (\n <Modal\n title={tr('savings.bundle.dismissTitle', 'Dismiss bundle suggestion')}\n description={tr(\n 'savings.bundle.dismissDescription',\n 'It stays hidden until one of these subscriptions changes.'\n )}\n onClose={onClose}\n >\n <form onSubmit={submit} className=\"space-y-4\" data-testid=\"dismiss-bundle-dialog\">\n <div>\n <label\n htmlFor={`dismiss-bundle-${bundle.id}`}\n className=\"mb-1 block text-xs font-medium text-text-secondary\"\n >\n {tr('decisions.dismiss.reason', 'Reason (optional)')}\n </label>\n <textarea\n id={`dismiss-bundle-${bundle.id}`}\n value={reason}\n onChange={(e) => setReason(e.target.value)}\n rows={3}\n maxLength={500}\n placeholder={tr('savings.bundle.dismissPlaceholder', 'e.g. They cover different needs')}\n className=\"w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n />\n </div>\n {error && (\n <div\n role=\"alert\"\n className=\"rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text\"\n >\n {error}\n </div>\n )}\n <div className=\"flex justify-end gap-3\">\n <button\n type=\"button\"\n onClick={onClose}\n className=\"rounded-lg border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n {tr('decisions.dismiss.back', 'Back')}\n </button>\n <button\n type=\"submit\"\n disabled={dismiss.isPending}\n data-testid=\"confirm-dismiss-bundle\"\n className=\"rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50\"\n >\n {dismiss.isPending\n ? tr('decisions.dismiss.dismissing', 'Dismissing…')\n : tr('decisions.dismiss.submit', 'Dismiss')}\n </button>\n </div>\n </form>\n </Modal>\n );\n};\n\n// ---------------------------------------------------------------------------\n// Bundle card\n// ---------------------------------------------------------------------------\n\nexport const BundleCard: FC<{\n bundle: SubOverlap;\n onConsolidated?: (result: SubConsolidationResult) => void;\n}> = ({ bundle, onConsolidated }) => {\n const { formatCurrency, formatPrice } = useFormatters();\n\n const tr = useTr();\n const { navigateTo } = useSubscriberBot();\n const [dialog, setDialog] = useState<'consolidate' | 'dismiss' | null>(null);\n const { keep, cancel } = bundleMembers(bundle);\n const drop = new Set(bundle.dropRelationshipIds);\n const heading = {\n EXACT_DUPLICATE: tr('savings.bundle.exactDuplicate', 'Merge duplicate subscriptions'),\n CAPABILITY: tr('savings.bundle.capability', 'Several services for {{capability}}', {\n capability: bundle.title,\n }),\n ENTITLEMENT: tr('savings.bundle.entitlement', 'Covered by a subscription you keep'),\n }[bundle.type];\n const afterCost = bundle.annualSpend - bundle.annualSavings;\n\n return (\n <GlassCard\n treatment=\"metric\"\n className=\"flex flex-col gap-3 border border-status-warning-text/30 p-4\"\n data-testid=\"bundle-card\"\n data-bundle-id={bundle.id}\n data-type={bundle.type}\n >\n <div className=\"flex items-start gap-3\">\n <span\n className=\"flex size-9 shrink-0 items-center justify-center rounded-lg bg-status-warning-bg-subtle text-status-warning-text\"\n aria-hidden\n >\n <Combine className=\"h-4 w-4\" />\n </span>\n <div className=\"min-w-0 flex-1\">\n <p className=\"text-[11px] font-medium uppercase tracking-wide text-text-secondary\">\n {tr('savings.bundle.label', 'Bundle suggestion')}\n {bundle.type === 'EXACT_DUPLICATE' && bundle.title ? ` · ${bundle.title}` : ''}\n </p>\n <p className=\"text-sm font-semibold text-text-primary\">{heading}</p>\n </div>\n <p\n className=\"shrink-0 text-end text-sm font-semibold tabular-nums text-status-success-text\"\n data-testid=\"bundle-card-amount\"\n >\n {tr('savings.card.save', 'Save {{amount}}', {\n amount: formatCurrency(bundle.annualSavings, bundle.currency),\n })}\n <span className=\"block text-[11px] font-normal text-text-secondary\">\n {tr('savings.card.perYear', 'per year')}\n </span>\n </p>\n </div>\n\n <p className=\"text-sm text-text-secondary\">{bundle.rationale}</p>\n\n <ul className=\"space-y-1\" data-testid=\"bundle-relationships\">\n {bundle.members.map((m) => {\n const role =\n m.relationshipId === bundle.keepRelationshipId\n ? 'keep'\n : drop.has(m.relationshipId)\n ? 'cancel'\n : 'untouched';\n return (\n <li key={m.relationshipId}>\n <button\n type=\"button\"\n onClick={() => navigateTo(`/relationships/${m.relationshipId}`)}\n data-relationship-id={m.relationshipId}\n data-role={role}\n className=\"flex w-full items-center gap-2 rounded-md border border-border-subtle bg-bg-sunken px-2.5 py-1.5 text-start text-xs hover:bg-bg-surface\"\n >\n <RoleBadge role={role} />\n <span className=\"min-w-0 flex-1 truncate font-medium text-text-primary\">\n {m.label}\n </span>\n <span className=\"shrink-0 tabular-nums text-text-secondary\">\n {formatPrice(m.amount, m.currency, m.interval)}\n </span>\n <ExternalLink className=\"h-3 w-3 shrink-0 text-text-secondary\" aria-hidden />\n </button>\n </li>\n );\n })}\n </ul>\n\n <div className=\"flex flex-wrap gap-2 text-xs\">\n <span className=\"inline-flex items-center rounded-md bg-bg-sunken px-2 py-0.5 tabular-nums text-text-secondary\">\n {tr('savings.bundle.costChange', '{{before}} → {{after}} a year', {\n before: formatCurrency(bundle.annualSpend, bundle.currency),\n after: formatCurrency(afterCost, bundle.currency),\n })}\n </span>\n <span className=\"inline-flex items-center gap-1.5 rounded-md bg-bg-sunken px-2 py-0.5 text-text-secondary\">\n <Gauge className=\"h-3.5 w-3.5\" aria-hidden />\n {tr('decisions.card.confidence', 'Confidence {{pct}}%', {\n pct: confidencePercent(bundle.confidence),\n })}\n </span>\n </div>\n\n <div className=\"flex flex-wrap justify-end gap-2 border-t border-border-subtle pt-3\">\n <button\n type=\"button\"\n onClick={() => setDialog('dismiss')}\n data-testid=\"bundle-dismiss\"\n className=\"inline-flex items-center gap-1.5 rounded-lg border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <XCircle className=\"h-3.5 w-3.5\" aria-hidden />\n {tr('decisions.card.dismiss', 'Dismiss')}\n </button>\n <button\n type=\"button\"\n onClick={() => setDialog('consolidate')}\n disabled={!keep || cancel.length === 0}\n data-testid=\"bundle-consolidate\"\n className=\"inline-flex items-center gap-1.5 rounded-lg border border-status-error-text/40 bg-status-error-bg-subtle px-3 py-1.5 text-xs font-medium text-status-error-text hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50\"\n >\n <ShieldAlert className=\"h-3.5 w-3.5\" aria-hidden />\n {tr('savings.bundle.consolidate', 'Review and consolidate')}\n </button>\n </div>\n\n {dialog === 'consolidate' && (\n <ConsolidateDialog\n bundle={bundle}\n onClose={() => setDialog(null)}\n onDone={(result) => onConsolidated?.(result)}\n />\n )}\n {dialog === 'dismiss' && (\n <DismissBundleDialog bundle={bundle} onClose={() => setDialog(null)} />\n )}\n </GlassCard>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;AA8DA,IAAM,IAAwD;CAC5D,QAAQ;CACR,WAAW;CACX,QAAQ;CACR,OAAO;AACT,GAEM,IAA0C;CAAC;CAAW;CAAa;AAAQ;AAEjF,SAAS,EAAU,GAAc,GAA0B;CACzD,OAAO,aAAe,SAAS,EAAI,UAAU,EAAI,UAAU;AAC7D;AAMA,IAAa,KAA8C,EAAE,kBAAe;CAC1E,IAAM,EAAE,mBAAgB,mBAAgB,EAAc,GAEhD,IAAK,EAAM,GACX,EAAE,kBAAe,EAAiB,GAClC,CAAC,GAAQ,KAAa,EAAqC,IAAI,GAC/D,IAAM,EAAqB,EAAS,iBACpC,IAAc,EAAc,EAAS,cAAc,GACnD,IAAO,EAAqB,CAAQ,GACpC,IAAO,EAAa,EAAU,EAAS,cAAc,IACrD,IAAQ,EAAK,SAAS,EAAS;CAErC,OACE,kBAAC,GAAD;EACE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J,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,QAAD;KAAM,WAAU;eACb,EAAG,6BAA6B,iCAAiC;MAChE,QAAQ,EAAe,EAAO,aAAa,EAAO,QAAQ;MAC1D,OAAO,EAAe,GAAW,EAAO,QAAQ;KAClD,CAAC;IACG,CAAA,GACN,kBAAC,QAAD;KAAM,WAAU;eAAhB,CACE,kBAAC,GAAD;MAAO,WAAU;MAAc,eAAA;KAAa,CAAA,GAC3C,EAAG,6BAA6B,uBAAuB,EACtD,KAAK,EAAkB,EAAO,UAAU,EAC1C,CAAC,CACG;MACH;;GAEL,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,UAAD;KACE,MAAK;KACL,eAAe,EAAU,SAAS;KAClC,eAAY;KACZ,WAAU;eAJZ,CAME,kBAAC,GAAD;MAAS,WAAU;MAAc,eAAA;KAAa,CAAA,GAC7C,EAAG,0BAA0B,SAAS,CACjC;QACR,kBAAC,UAAD;KACE,MAAK;KACL,eAAe,EAAU,aAAa;KACtC,UAAU,CAAC,KAAQ,EAAO,WAAW;KACrC,eAAY;KACZ,WAAU;eALZ,CAOE,kBAAC,GAAD;MAAa,WAAU;MAAc,eAAA;KAAa,CAAA,GACjD,EAAG,8BAA8B,wBAAwB,CACpD;MACL;;GAEJ,MAAW,iBACV,kBAAC,GAAD;IACU;IACR,eAAe,EAAU,IAAI;IAC7B,SAAS,MAAW,IAAiB,CAAM;GAC5C,CAAA;GAEF,MAAW,aACV,kBAAC,GAAD;IAA6B;IAAQ,eAAe,EAAU,IAAI;GAAI,CAAA;EAE/D;;AAEf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viz.d.ts","sourceRoot":"","sources":["../../../src/subscriberbot/components/viz.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"viz.d.ts","sourceRo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,eAAO,MAAM,KAAK,EAAE,EAAE,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAwCA,CAAC;AAKF,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,IAAI,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC;CACrD;AAOD,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC;IAAE,KAAK,EAAE,YAAY,EAAE,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAyBtE,CAAC;AAKF,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,CAAC;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CA0BA,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useTr as e } from "../hooks/useTr.js";
|
|
2
|
+
import { cn as t } from "../utils/cn.js";
|
|
3
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
3
4
|
//#region src/subscriberbot/components/viz.tsx
|
|
4
|
-
var
|
|
5
|
+
var i = [
|
|
5
6
|
"var(--color-chart-1)",
|
|
6
7
|
"var(--color-chart-2)",
|
|
7
8
|
"var(--color-chart-3)",
|
|
@@ -10,211 +11,209 @@ var r = [
|
|
|
10
11
|
"var(--color-chart-6)",
|
|
11
12
|
"var(--color-chart-7)",
|
|
12
13
|
"var(--color-chart-8)"
|
|
13
|
-
],
|
|
14
|
-
let d =
|
|
15
|
-
return /* @__PURE__ */
|
|
16
|
-
className:
|
|
17
|
-
children: [/* @__PURE__ */
|
|
14
|
+
], a = "var(--color-chart-positive)", o = "var(--color-chart-negative)", s = "var(--color-chart-grid)", c = "var(--color-status-warning-text)", l = "var(--color-status-success-text)", u = (e, t) => t ?? i[e % i.length], d = ({ data: e, size: i = 160, thickness: a = 18, centerLabel: o, centerSub: c, className: l }) => {
|
|
15
|
+
let d = e.reduce((e, t) => e + Math.max(0, t.value), 0), f = (i - a) / 2, p = 2 * Math.PI * f, m = i / 2, h = 0, g = e.map((e) => `${e.label}: ${e.value}`).join(", ");
|
|
16
|
+
return /* @__PURE__ */ r("div", {
|
|
17
|
+
className: t("relative inline-flex items-center justify-center", l),
|
|
18
|
+
children: [/* @__PURE__ */ r("svg", {
|
|
18
19
|
width: i,
|
|
19
20
|
height: i,
|
|
20
21
|
viewBox: `0 0 ${i} ${i}`,
|
|
21
22
|
role: "img",
|
|
22
23
|
"aria-label": `Donut chart. ${g}`,
|
|
23
24
|
className: "max-w-full",
|
|
24
|
-
children: [/* @__PURE__ */
|
|
25
|
+
children: [/* @__PURE__ */ n("circle", {
|
|
25
26
|
cx: m,
|
|
26
27
|
cy: m,
|
|
27
28
|
r: f,
|
|
28
29
|
fill: "none",
|
|
29
|
-
stroke:
|
|
30
|
+
stroke: s,
|
|
30
31
|
strokeWidth: a,
|
|
31
32
|
opacity: .4
|
|
32
|
-
}), d > 0 &&
|
|
33
|
-
let r = Math.max(0, e.value) / d * p, i = /* @__PURE__ */
|
|
33
|
+
}), d > 0 && e.map((e, t) => {
|
|
34
|
+
let r = Math.max(0, e.value) / d * p, i = /* @__PURE__ */ n("circle", {
|
|
34
35
|
cx: m,
|
|
35
36
|
cy: m,
|
|
36
37
|
r: f,
|
|
37
38
|
fill: "none",
|
|
38
|
-
stroke:
|
|
39
|
+
stroke: u(t, e.color),
|
|
39
40
|
strokeWidth: a,
|
|
40
41
|
strokeDasharray: `${r} ${p - r}`,
|
|
41
42
|
strokeDashoffset: -h,
|
|
42
43
|
strokeLinecap: "butt",
|
|
43
44
|
transform: `rotate(-90 ${m} ${m})`
|
|
44
|
-
},
|
|
45
|
+
}, t);
|
|
45
46
|
return h += r, i;
|
|
46
47
|
})]
|
|
47
|
-
}), (
|
|
48
|
+
}), (o || c) && /* @__PURE__ */ r("div", {
|
|
48
49
|
className: "absolute inset-0 flex flex-col items-center justify-center text-center",
|
|
49
|
-
children: [
|
|
50
|
+
children: [o && /* @__PURE__ */ n("span", {
|
|
50
51
|
className: "text-xl font-bold text-text-primary tabular-nums leading-none",
|
|
51
|
-
children:
|
|
52
|
-
}), c && /* @__PURE__ */
|
|
52
|
+
children: o
|
|
53
|
+
}), c && /* @__PURE__ */ n("span", {
|
|
53
54
|
className: "mt-1 text-xs text-text-secondary",
|
|
54
55
|
children: c
|
|
55
56
|
})]
|
|
56
57
|
})]
|
|
57
58
|
});
|
|
58
|
-
},
|
|
59
|
-
className:
|
|
60
|
-
children:
|
|
59
|
+
}, f = ({ data: e, valueFormat: i, className: a }) => /* @__PURE__ */ n("ul", {
|
|
60
|
+
className: t("space-y-2", a),
|
|
61
|
+
children: e.map((e, t) => /* @__PURE__ */ r("li", {
|
|
61
62
|
className: "flex items-center gap-2 text-sm",
|
|
62
63
|
children: [
|
|
63
|
-
/* @__PURE__ */
|
|
64
|
+
/* @__PURE__ */ n("span", {
|
|
64
65
|
className: "h-2.5 w-2.5 shrink-0 rounded-full",
|
|
65
|
-
style: { backgroundColor:
|
|
66
|
+
style: { backgroundColor: u(t, e.color) },
|
|
66
67
|
"aria-hidden": !0
|
|
67
68
|
}),
|
|
68
|
-
/* @__PURE__ */
|
|
69
|
+
/* @__PURE__ */ n("span", {
|
|
69
70
|
className: "flex-1 truncate text-text-secondary",
|
|
70
71
|
children: e.label
|
|
71
72
|
}),
|
|
72
|
-
/* @__PURE__ */
|
|
73
|
+
/* @__PURE__ */ n("span", {
|
|
73
74
|
className: "font-medium text-text-primary tabular-nums",
|
|
74
75
|
children: i ? i(e.value) : e.value
|
|
75
76
|
})
|
|
76
77
|
]
|
|
77
|
-
},
|
|
78
|
-
}),
|
|
79
|
-
let
|
|
80
|
-
return /* @__PURE__ */
|
|
81
|
-
className:
|
|
82
|
-
|
|
83
|
-
"
|
|
84
|
-
children: r.map((e, r) => /* @__PURE__ */ n("li", { children: [/* @__PURE__ */ n("div", {
|
|
78
|
+
}, t))
|
|
79
|
+
}), p = ({ data: i, valueFormat: a, className: o }) => {
|
|
80
|
+
let c = e(), l = Math.max(1, ...i.map((e) => e.value));
|
|
81
|
+
return /* @__PURE__ */ n("ul", {
|
|
82
|
+
className: t("space-y-3", o),
|
|
83
|
+
"aria-label": c("charts.barLabel", "Bar chart"),
|
|
84
|
+
children: i.map((e, t) => /* @__PURE__ */ r("li", { children: [/* @__PURE__ */ r("div", {
|
|
85
85
|
className: "flex items-center justify-between text-sm",
|
|
86
|
-
children: [/* @__PURE__ */
|
|
86
|
+
children: [/* @__PURE__ */ n("span", {
|
|
87
87
|
className: "truncate text-text-secondary",
|
|
88
88
|
children: e.label
|
|
89
|
-
}), /* @__PURE__ */
|
|
89
|
+
}), /* @__PURE__ */ n("span", {
|
|
90
90
|
className: "font-medium text-text-primary tabular-nums",
|
|
91
|
-
children:
|
|
91
|
+
children: a ? a(e.value) : e.value
|
|
92
92
|
})]
|
|
93
|
-
}), /* @__PURE__ */
|
|
93
|
+
}), /* @__PURE__ */ n("div", {
|
|
94
94
|
className: "mt-1.5 h-2 w-full overflow-hidden rounded-full",
|
|
95
|
-
style: { backgroundColor:
|
|
96
|
-
children: /* @__PURE__ */
|
|
95
|
+
style: { backgroundColor: s },
|
|
96
|
+
children: /* @__PURE__ */ n("div", {
|
|
97
97
|
className: "h-full rounded-full transition-all",
|
|
98
98
|
style: {
|
|
99
|
-
width: `${e.value /
|
|
100
|
-
backgroundColor:
|
|
99
|
+
width: `${e.value / l * 100}%`,
|
|
100
|
+
backgroundColor: u(t, e.color)
|
|
101
101
|
}
|
|
102
102
|
})
|
|
103
|
-
})] },
|
|
103
|
+
})] }, t))
|
|
104
104
|
});
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
105
|
+
}, m = ({ points: i, width: s = 220, height: c = 56, positive: l = !0, className: u }) => {
|
|
106
|
+
let d = e();
|
|
107
|
+
if (i.length < 2) return null;
|
|
108
|
+
let f = Math.max(...i), p = Math.min(...i), m = f - p || 1, h = l ? a : o, g = s / (i.length - 1), _ = i.map((e, t) => [t * g, c - (e - p) / m * (c - 8) - 4]).map(([e, t], n) => `${n === 0 ? "M" : "L"}${e.toFixed(1)},${t.toFixed(1)}`).join(" "), v = `${_} L${s},${c} L0,${c} Z`;
|
|
109
|
+
return /* @__PURE__ */ r("svg", {
|
|
110
|
+
width: s,
|
|
111
|
+
height: c,
|
|
112
|
+
viewBox: `0 0 ${s} ${c}`,
|
|
112
113
|
role: "img",
|
|
113
|
-
"aria-label": "Trend sparkline",
|
|
114
|
-
className:
|
|
114
|
+
"aria-label": d("charts.trendLabel", "Trend sparkline"),
|
|
115
|
+
className: t("max-w-full", u),
|
|
115
116
|
preserveAspectRatio: "none",
|
|
116
|
-
children: [/* @__PURE__ */
|
|
117
|
-
d:
|
|
118
|
-
fill:
|
|
117
|
+
children: [/* @__PURE__ */ n("path", {
|
|
118
|
+
d: v,
|
|
119
|
+
fill: h,
|
|
119
120
|
opacity: .12
|
|
120
|
-
}), /* @__PURE__ */
|
|
121
|
-
d:
|
|
121
|
+
}), /* @__PURE__ */ n("path", {
|
|
122
|
+
d: _,
|
|
122
123
|
fill: "none",
|
|
123
|
-
stroke:
|
|
124
|
+
stroke: h,
|
|
124
125
|
strokeWidth: 2,
|
|
125
126
|
strokeLinejoin: "round",
|
|
126
127
|
strokeLinecap: "round"
|
|
127
128
|
})]
|
|
128
129
|
});
|
|
129
|
-
},
|
|
130
|
-
let f = Math.max(0, Math.min(1,
|
|
131
|
-
return /* @__PURE__ */
|
|
132
|
-
className:
|
|
133
|
-
children: [/* @__PURE__ */
|
|
134
|
-
width:
|
|
135
|
-
height:
|
|
136
|
-
viewBox: `0 0 ${
|
|
130
|
+
}, h = ({ value: e, max: i = 100, size: a = 120, label: u, className: d }) => {
|
|
131
|
+
let f = Math.max(0, Math.min(1, e / i)), p = a / 2 - 10, m = a / 2, h = Math.PI * p, g = f >= .66 ? l : f >= .33 ? c : o;
|
|
132
|
+
return /* @__PURE__ */ r("div", {
|
|
133
|
+
className: t("inline-flex flex-col items-center", d),
|
|
134
|
+
children: [/* @__PURE__ */ r("svg", {
|
|
135
|
+
width: a,
|
|
136
|
+
height: a / 2 + 8,
|
|
137
|
+
viewBox: `0 0 ${a} ${a / 2 + 8}`,
|
|
137
138
|
role: "img",
|
|
138
139
|
"aria-label": `Gauge: ${Math.round(f * 100)} percent`,
|
|
139
140
|
className: "max-w-full",
|
|
140
|
-
children: [/* @__PURE__ */
|
|
141
|
-
d: `M10 ${m} A ${p} ${p} 0 0 1 ${
|
|
141
|
+
children: [/* @__PURE__ */ n("path", {
|
|
142
|
+
d: `M10 ${m} A ${p} ${p} 0 0 1 ${a - 10} ${m}`,
|
|
142
143
|
fill: "none",
|
|
143
|
-
stroke:
|
|
144
|
+
stroke: s,
|
|
144
145
|
strokeWidth: 10,
|
|
145
146
|
strokeLinecap: "round"
|
|
146
|
-
}), /* @__PURE__ */
|
|
147
|
-
d: `M10 ${m} A ${p} ${p} 0 0 1 ${
|
|
147
|
+
}), /* @__PURE__ */ n("path", {
|
|
148
|
+
d: `M10 ${m} A ${p} ${p} 0 0 1 ${a - 10} ${m}`,
|
|
148
149
|
fill: "none",
|
|
149
150
|
stroke: g,
|
|
150
151
|
strokeWidth: 10,
|
|
151
152
|
strokeLinecap: "round",
|
|
152
153
|
strokeDasharray: `${f * h} ${h}`
|
|
153
154
|
})]
|
|
154
|
-
}), /* @__PURE__ */
|
|
155
|
+
}), /* @__PURE__ */ r("div", {
|
|
155
156
|
className: "-mt-4 text-center",
|
|
156
|
-
children: [/* @__PURE__ */
|
|
157
|
+
children: [/* @__PURE__ */ n("span", {
|
|
157
158
|
className: "text-lg font-bold text-text-primary tabular-nums",
|
|
158
|
-
children: Math.round(
|
|
159
|
-
}), u && /* @__PURE__ */
|
|
159
|
+
children: Math.round(e)
|
|
160
|
+
}), u && /* @__PURE__ */ n("p", {
|
|
160
161
|
className: "text-xs text-text-secondary",
|
|
161
162
|
children: u
|
|
162
163
|
})]
|
|
163
164
|
})]
|
|
164
165
|
});
|
|
165
|
-
},
|
|
166
|
+
}, g = {
|
|
166
167
|
default: "var(--color-accent-indigo)",
|
|
167
|
-
positive:
|
|
168
|
-
warning:
|
|
168
|
+
positive: l,
|
|
169
|
+
warning: c,
|
|
169
170
|
muted: "var(--color-text-secondary)"
|
|
170
|
-
},
|
|
171
|
-
className:
|
|
172
|
-
children:
|
|
173
|
-
className: "absolute left-[7px] top-1 bottom-1 w-px bg-border-subtle",
|
|
174
|
-
"aria-hidden": !0
|
|
175
|
-
}), r.map((e, r) => /* @__PURE__ */ n("li", {
|
|
171
|
+
}, _ = ({ items: e, className: i }) => /* @__PURE__ */ n("ol", {
|
|
172
|
+
className: t("relative space-y-5 ps-6 before:absolute before:start-[7px] before:top-1 before:bottom-1 before:w-px before:bg-border-subtle", i),
|
|
173
|
+
children: e.map((e, t) => /* @__PURE__ */ r("li", {
|
|
176
174
|
className: "relative",
|
|
177
175
|
children: [
|
|
178
|
-
/* @__PURE__ */
|
|
179
|
-
className: "absolute -
|
|
180
|
-
style: { backgroundColor:
|
|
176
|
+
/* @__PURE__ */ n("span", {
|
|
177
|
+
className: "absolute -start-[22px] top-1 h-3 w-3 rounded-full ring-4 ring-bg-surface",
|
|
178
|
+
style: { backgroundColor: g[e.tone ?? "default"] },
|
|
181
179
|
"aria-hidden": !0
|
|
182
180
|
}),
|
|
183
|
-
/* @__PURE__ */
|
|
181
|
+
/* @__PURE__ */ r("div", {
|
|
184
182
|
className: "flex items-baseline justify-between gap-2",
|
|
185
|
-
children: [/* @__PURE__ */
|
|
183
|
+
children: [/* @__PURE__ */ n("p", {
|
|
186
184
|
className: "text-sm font-medium text-text-primary",
|
|
187
185
|
children: e.title
|
|
188
|
-
}), e.meta && /* @__PURE__ */
|
|
186
|
+
}), e.meta && /* @__PURE__ */ n("span", {
|
|
189
187
|
className: "text-sm tabular-nums text-text-primary",
|
|
190
188
|
children: e.meta
|
|
191
189
|
})]
|
|
192
190
|
}),
|
|
193
|
-
e.sub && /* @__PURE__ */
|
|
191
|
+
e.sub && /* @__PURE__ */ n("p", {
|
|
194
192
|
className: "text-xs text-text-secondary",
|
|
195
193
|
children: e.sub
|
|
196
194
|
})
|
|
197
195
|
]
|
|
198
|
-
},
|
|
199
|
-
}),
|
|
200
|
-
let
|
|
201
|
-
return /* @__PURE__ */
|
|
202
|
-
className:
|
|
203
|
-
style: { backgroundColor:
|
|
196
|
+
}, t))
|
|
197
|
+
}), v = ({ value: e, max: r = 100, label: i, tone: a = "accent", className: u }) => {
|
|
198
|
+
let d = Math.max(0, Math.min(1, r ? e / r : 0)), f = a === "positive" ? l : a === "warning" ? c : a === "negative" ? o : "var(--color-accent-indigo)";
|
|
199
|
+
return /* @__PURE__ */ n("div", {
|
|
200
|
+
className: t("h-2 w-full overflow-hidden rounded-full", u),
|
|
201
|
+
style: { backgroundColor: s },
|
|
204
202
|
role: "progressbar",
|
|
205
|
-
"aria-
|
|
203
|
+
"aria-label": i,
|
|
204
|
+
"aria-valuenow": Math.round(d * 100),
|
|
206
205
|
"aria-valuemin": 0,
|
|
207
206
|
"aria-valuemax": 100,
|
|
208
|
-
children: /* @__PURE__ */
|
|
207
|
+
children: /* @__PURE__ */ n("div", {
|
|
209
208
|
className: "h-full rounded-full transition-all",
|
|
210
209
|
style: {
|
|
211
|
-
width: `${
|
|
212
|
-
backgroundColor:
|
|
210
|
+
width: `${d * 100}%`,
|
|
211
|
+
backgroundColor: f
|
|
213
212
|
}
|
|
214
213
|
})
|
|
215
214
|
});
|
|
216
215
|
};
|
|
217
216
|
//#endregion
|
|
218
|
-
export {
|
|
217
|
+
export { p as BarList, i as CHART_COLORS, d as Donut, h as Gauge, f as Legend, v as MiniProgress, m as Sparkline, _ as Timeline };
|
|
219
218
|
|
|
220
219
|
//# sourceMappingURL=viz.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viz.js","names":[],"sources":["../../../src/subscriberbot/components/viz.tsx"],"sourcesContent":["/**\n * Tokenized, responsive SVG visualization primitives.\n * @module subscriberbot/components/viz\n *\n * Every color is a fe-libs semantic CSS variable (never a raw hex), so charts\n * theme automatically in light/dark and per-product themes. All charts scale to\n * their container (SVG viewBox) and carry an accessible role/label.\n */\nimport type { FC, ReactNode } from 'react';\nimport { cn } from '../utils/cn';\n\n/** Categorical palette — fe-libs chart tokens. */\nexport const CHART_COLORS = [\n 'var(--color-chart-1)',\n 'var(--color-chart-2)',\n 'var(--color-chart-3)',\n 'var(--color-chart-4)',\n 'var(--color-chart-5)',\n 'var(--color-chart-6)',\n 'var(--color-chart-7)',\n 'var(--color-chart-8)',\n] as const;\n\nconst POSITIVE = 'var(--color-chart-positive)';\nconst NEGATIVE = 'var(--color-chart-negative)';\nconst GRID = 'var(--color-chart-grid)';\nconst WARN = 'var(--color-status-warning-text)';\nconst SUCCESS = 'var(--color-status-success-text)';\n\nexport interface Segment {\n label: string;\n value: number;\n color?: string;\n}\n\nconst colorAt = (i: number, override?: string) => override ?? CHART_COLORS[i % CHART_COLORS.length];\n\n// ---------------------------------------------------------------------------\n// Donut — proportional ring with an optional center label.\n// ---------------------------------------------------------------------------\nexport const Donut: FC<{\n data: Segment[];\n size?: number;\n thickness?: number;\n centerLabel?: string;\n centerSub?: string;\n className?: string;\n}> = ({ data, size = 160, thickness = 18, centerLabel, centerSub, className }) => {\n const total = data.reduce((s, d) => s + Math.max(0, d.value), 0);\n const r = (size - thickness) / 2;\n const c = 2 * Math.PI * r;\n const cx = size / 2;\n let offset = 0;\n const label = data.map((d) => `${d.label}: ${d.value}`).join(', ');\n\n return (\n <div className={cn('relative inline-flex items-center justify-center', className)}>\n <svg\n width={size}\n height={size}\n viewBox={`0 0 ${size} ${size}`}\n role=\"img\"\n aria-label={`Donut chart. ${label}`}\n className=\"max-w-full\"\n >\n <circle\n cx={cx}\n cy={cx}\n r={r}\n fill=\"none\"\n stroke={GRID}\n strokeWidth={thickness}\n opacity={0.4}\n />\n {total > 0 &&\n data.map((d, i) => {\n const frac = Math.max(0, d.value) / total;\n const len = frac * c;\n const seg = (\n <circle\n key={i}\n cx={cx}\n cy={cx}\n r={r}\n fill=\"none\"\n stroke={colorAt(i, d.color)}\n strokeWidth={thickness}\n strokeDasharray={`${len} ${c - len}`}\n strokeDashoffset={-offset}\n strokeLinecap=\"butt\"\n transform={`rotate(-90 ${cx} ${cx})`}\n />\n );\n offset += len;\n return seg;\n })}\n </svg>\n {(centerLabel || centerSub) && (\n <div className=\"absolute inset-0 flex flex-col items-center justify-center text-center\">\n {centerLabel && (\n <span className=\"text-xl font-bold text-text-primary tabular-nums leading-none\">\n {centerLabel}\n </span>\n )}\n {centerSub && <span className=\"mt-1 text-xs text-text-secondary\">{centerSub}</span>}\n </div>\n )}\n </div>\n );\n};\n\n// ---------------------------------------------------------------------------\n// Legend — pairs with Donut / charts.\n// ---------------------------------------------------------------------------\nexport const Legend: FC<{\n data: Segment[];\n valueFormat?: (n: number) => string;\n className?: string;\n}> = ({ data, valueFormat, className }) => (\n <ul className={cn('space-y-2', className)}>\n {data.map((d, i) => (\n <li key={i} className=\"flex items-center gap-2 text-sm\">\n <span\n className=\"h-2.5 w-2.5 shrink-0 rounded-full\"\n style={{ backgroundColor: colorAt(i, d.color) }}\n aria-hidden\n />\n <span className=\"flex-1 truncate text-text-secondary\">{d.label}</span>\n <span className=\"font-medium text-text-primary tabular-nums\">\n {valueFormat ? valueFormat(d.value) : d.value}\n </span>\n </li>\n ))}\n </ul>\n);\n\n// ---------------------------------------------------------------------------\n// BarList — horizontal labelled bars (e.g. spend by category).\n// ---------------------------------------------------------------------------\nexport const BarList: FC<{\n data: Segment[];\n valueFormat?: (n: number) => string;\n className?: string;\n}> = ({ data, valueFormat, className }) => {\n const max = Math.max(1, ...data.map((d) => d.value));\n return (\n <ul className={cn('space-y-3', className)} role=\"img\" aria-label=\"Bar chart\">\n {data.map((d, i) => (\n <li key={i}>\n <div className=\"flex items-center justify-between text-sm\">\n <span className=\"truncate text-text-secondary\">{d.label}</span>\n <span className=\"font-medium text-text-primary tabular-nums\">\n {valueFormat ? valueFormat(d.value) : d.value}\n </span>\n </div>\n <div\n className=\"mt-1.5 h-2 w-full overflow-hidden rounded-full\"\n style={{ backgroundColor: GRID }}\n >\n <div\n className=\"h-full rounded-full transition-all\"\n style={{ width: `${(d.value / max) * 100}%`, backgroundColor: colorAt(i, d.color) }}\n />\n </div>\n </li>\n ))}\n </ul>\n );\n};\n\n// ---------------------------------------------------------------------------\n// Sparkline / area — small trend line.\n// ---------------------------------------------------------------------------\nexport const Sparkline: FC<{\n points: number[];\n width?: number;\n height?: number;\n positive?: boolean;\n className?: string;\n}> = ({ points, width = 220, height = 56, positive = true, className }) => {\n if (points.length < 2) return null;\n const max = Math.max(...points);\n const min = Math.min(...points);\n const span = max - min || 1;\n const stroke = positive ? POSITIVE : NEGATIVE;\n const step = width / (points.length - 1);\n const coords = points.map((p, i) => [i * step, height - ((p - min) / span) * (height - 8) - 4]);\n const line = coords\n .map(([x, y], i) => `${i === 0 ? 'M' : 'L'}${x.toFixed(1)},${y.toFixed(1)}`)\n .join(' ');\n const area = `${line} L${width},${height} L0,${height} Z`;\n return (\n <svg\n width={width}\n height={height}\n viewBox={`0 0 ${width} ${height}`}\n role=\"img\"\n aria-label=\"Trend sparkline\"\n className={cn('max-w-full', className)}\n preserveAspectRatio=\"none\"\n >\n <path d={area} fill={stroke} opacity={0.12} />\n <path\n d={line}\n fill=\"none\"\n stroke={stroke}\n strokeWidth={2}\n strokeLinejoin=\"round\"\n strokeLinecap=\"round\"\n />\n </svg>\n );\n};\n\n// ---------------------------------------------------------------------------\n// Gauge — 0..max semicircle (e.g. health score).\n// ---------------------------------------------------------------------------\nexport const Gauge: FC<{\n value: number;\n max?: number;\n size?: number;\n label?: string;\n className?: string;\n}> = ({ value, max = 100, size = 120, label, className }) => {\n const pct = Math.max(0, Math.min(1, value / max));\n const r = size / 2 - 10;\n const cy = size / 2;\n const circ = Math.PI * r; // half circle\n const tone = pct >= 0.66 ? SUCCESS : pct >= 0.33 ? WARN : NEGATIVE;\n return (\n <div className={cn('inline-flex flex-col items-center', className)}>\n <svg\n width={size}\n height={size / 2 + 8}\n viewBox={`0 0 ${size} ${size / 2 + 8}`}\n role=\"img\"\n aria-label={`Gauge: ${Math.round(pct * 100)} percent`}\n className=\"max-w-full\"\n >\n <path\n d={`M10 ${cy} A ${r} ${r} 0 0 1 ${size - 10} ${cy}`}\n fill=\"none\"\n stroke={GRID}\n strokeWidth={10}\n strokeLinecap=\"round\"\n />\n <path\n d={`M10 ${cy} A ${r} ${r} 0 0 1 ${size - 10} ${cy}`}\n fill=\"none\"\n stroke={tone}\n strokeWidth={10}\n strokeLinecap=\"round\"\n strokeDasharray={`${pct * circ} ${circ}`}\n />\n </svg>\n <div className=\"-mt-4 text-center\">\n <span className=\"text-lg font-bold text-text-primary tabular-nums\">\n {Math.round(value)}\n </span>\n {label && <p className=\"text-xs text-text-secondary\">{label}</p>}\n </div>\n </div>\n );\n};\n\n// ---------------------------------------------------------------------------\n// Timeline — vertical events with a connector rail (e.g. renewals).\n// ---------------------------------------------------------------------------\nexport interface TimelineItem {\n title: string;\n sub?: string;\n meta?: ReactNode;\n tone?: 'default' | 'positive' | 'warning' | 'muted';\n}\nconst dotTone: Record<NonNullable<TimelineItem['tone']>, string> = {\n default: 'var(--color-accent-indigo)',\n positive: SUCCESS,\n warning: WARN,\n muted: 'var(--color-text-secondary)',\n};\nexport const Timeline: FC<{ items: TimelineItem[]; className?: string }> = ({\n items,\n className,\n}) => (\n <ol className={cn('relative space-y-5 pl-6', className)}>\n <span className=\"absolute left-[7px] top-1 bottom-1 w-px bg-border-subtle\" aria-hidden />\n {items.map((it, i) => (\n <li key={i} className=\"relative\">\n <span\n className=\"absolute -left-[22px] top-1 h-3 w-3 rounded-full ring-4 ring-bg-surface\"\n style={{ backgroundColor: dotTone[it.tone ?? 'default'] }}\n aria-hidden\n />\n <div className=\"flex items-baseline justify-between gap-2\">\n <p className=\"text-sm font-medium text-text-primary\">{it.title}</p>\n {it.meta && <span className=\"text-sm tabular-nums text-text-primary\">{it.meta}</span>}\n </div>\n {it.sub && <p className=\"text-xs text-text-secondary\">{it.sub}</p>}\n </li>\n ))}\n </ol>\n);\n\n// ---------------------------------------------------------------------------\n// MiniProgress — inline utilization bar (e.g. seats used).\n// ---------------------------------------------------------------------------\nexport const MiniProgress: FC<{\n value: number;\n max?: number;\n tone?: 'accent' | 'positive' | 'warning' | 'negative';\n className?: string;\n}> = ({ value, max = 100, tone = 'accent', className }) => {\n const pct = Math.max(0, Math.min(1, max ? value / max : 0));\n const color =\n tone === 'positive'\n ? SUCCESS\n : tone === 'warning'\n ? WARN\n : tone === 'negative'\n ? NEGATIVE\n : 'var(--color-accent-indigo)';\n return (\n <div\n className={cn('h-2 w-full overflow-hidden rounded-full', className)}\n style={{ backgroundColor: GRID }}\n role=\"progressbar\"\n aria-valuenow={Math.round(pct * 100)}\n aria-valuemin={0}\n aria-valuemax={100}\n >\n <div\n className=\"h-full rounded-full transition-all\"\n style={{ width: `${pct * 100}%`, backgroundColor: color }}\n />\n </div>\n );\n};\n"],"mappings":";;;AAYA,IAAa,IAAe;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GAEM,IAAW,+BACX,IAAW,+BACX,IAAO,2BACP,IAAO,oCACP,IAAU,oCAQV,KAAW,GAAW,MAAsB,KA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AQ,IAAM,CAAC,CAAC,GACpD,IACJ,MAAS,aACL,IACA,MAAS,YACP,IACA,MAAS,aACP,IACA;CACV,OACE,kBAAC,OAAD;EACE,WAAW,EAAG,2CAA2C,CAAS;EAClE,OAAO,EAAE,iBAAiB,EAAK;EAC/B,MAAK;EACL,iBAAe,KAAK,MAAM,IAAM,GAAG;EACnC,iBAAe;EACf,iBAAe;YAEf,kBAAC,OAAD;GACE,WAAU;GACV,OAAO;IAAE,OAAO,GAAG,IAAM,IAAI;IAAI,iBAAiB;GAAM;EACzD,CAAA;CACE,CAAA;AAET"}
|
|
1
|
+
{"version":3,"file":"viz.js","names":[],"sources":["../../../src/subscriberbot/components/viz.tsx"],"sourcesContent":["/**\n * Tokenized, responsive SVG visualization primitives.\n * @module subscriberbot/components/viz\n *\n * Every color is a fe-libs semantic CSS variable (never a raw hex), so charts\n * theme automatically in light/dark and per-product themes. All charts scale to\n * their container (SVG viewBox) and carry an accessible role/label.\n */\nimport type { FC, ReactNode } from 'react';\nimport { useTr } from '../hooks/useTr';\nimport { cn } from '../utils/cn';\n\n/** Categorical palette — fe-libs chart tokens. */\nexport const CHART_COLORS = [\n 'var(--color-chart-1)',\n 'var(--color-chart-2)',\n 'var(--color-chart-3)',\n 'var(--color-chart-4)',\n 'var(--color-chart-5)',\n 'var(--color-chart-6)',\n 'var(--color-chart-7)',\n 'var(--color-chart-8)',\n] as const;\n\nconst POSITIVE = 'var(--color-chart-positive)';\nconst NEGATIVE = 'var(--color-chart-negative)';\nconst GRID = 'var(--color-chart-grid)';\nconst WARN = 'var(--color-status-warning-text)';\nconst SUCCESS = 'var(--color-status-success-text)';\n\nexport interface Segment {\n label: string;\n value: number;\n color?: string;\n}\n\nconst colorAt = (i: number, override?: string) => override ?? CHART_COLORS[i % CHART_COLORS.length];\n\n// ---------------------------------------------------------------------------\n// Donut — proportional ring with an optional center label.\n// ---------------------------------------------------------------------------\nexport const Donut: FC<{\n data: Segment[];\n size?: number;\n thickness?: number;\n centerLabel?: string;\n centerSub?: string;\n className?: string;\n}> = ({ data, size = 160, thickness = 18, centerLabel, centerSub, className }) => {\n const total = data.reduce((s, d) => s + Math.max(0, d.value), 0);\n const r = (size - thickness) / 2;\n const c = 2 * Math.PI * r;\n const cx = size / 2;\n let offset = 0;\n const label = data.map((d) => `${d.label}: ${d.value}`).join(', ');\n\n return (\n <div className={cn('relative inline-flex items-center justify-center', className)}>\n <svg\n width={size}\n height={size}\n viewBox={`0 0 ${size} ${size}`}\n role=\"img\"\n aria-label={`Donut chart. ${label}`}\n className=\"max-w-full\"\n >\n <circle\n cx={cx}\n cy={cx}\n r={r}\n fill=\"none\"\n stroke={GRID}\n strokeWidth={thickness}\n opacity={0.4}\n />\n {total > 0 &&\n data.map((d, i) => {\n const frac = Math.max(0, d.value) / total;\n const len = frac * c;\n const seg = (\n <circle\n key={i}\n cx={cx}\n cy={cx}\n r={r}\n fill=\"none\"\n stroke={colorAt(i, d.color)}\n strokeWidth={thickness}\n strokeDasharray={`${len} ${c - len}`}\n strokeDashoffset={-offset}\n strokeLinecap=\"butt\"\n transform={`rotate(-90 ${cx} ${cx})`}\n />\n );\n offset += len;\n return seg;\n })}\n </svg>\n {(centerLabel || centerSub) && (\n <div className=\"absolute inset-0 flex flex-col items-center justify-center text-center\">\n {centerLabel && (\n <span className=\"text-xl font-bold text-text-primary tabular-nums leading-none\">\n {centerLabel}\n </span>\n )}\n {centerSub && <span className=\"mt-1 text-xs text-text-secondary\">{centerSub}</span>}\n </div>\n )}\n </div>\n );\n};\n\n// ---------------------------------------------------------------------------\n// Legend — pairs with Donut / charts.\n// ---------------------------------------------------------------------------\nexport const Legend: FC<{\n data: Segment[];\n valueFormat?: (n: number) => string;\n className?: string;\n}> = ({ data, valueFormat, className }) => (\n <ul className={cn('space-y-2', className)}>\n {data.map((d, i) => (\n <li key={i} className=\"flex items-center gap-2 text-sm\">\n <span\n className=\"h-2.5 w-2.5 shrink-0 rounded-full\"\n style={{ backgroundColor: colorAt(i, d.color) }}\n aria-hidden\n />\n <span className=\"flex-1 truncate text-text-secondary\">{d.label}</span>\n <span className=\"font-medium text-text-primary tabular-nums\">\n {valueFormat ? valueFormat(d.value) : d.value}\n </span>\n </li>\n ))}\n </ul>\n);\n\n// ---------------------------------------------------------------------------\n// BarList — horizontal labelled bars (e.g. spend by category).\n// ---------------------------------------------------------------------------\nexport const BarList: FC<{\n data: Segment[];\n valueFormat?: (n: number) => string;\n className?: string;\n}> = ({ data, valueFormat, className }) => {\n const tr = useTr();\n const max = Math.max(1, ...data.map((d) => d.value));\n return (\n <ul className={cn('space-y-3', className)} aria-label={tr('charts.barLabel', 'Bar chart')}>\n {data.map((d, i) => (\n <li key={i}>\n <div className=\"flex items-center justify-between text-sm\">\n <span className=\"truncate text-text-secondary\">{d.label}</span>\n <span className=\"font-medium text-text-primary tabular-nums\">\n {valueFormat ? valueFormat(d.value) : d.value}\n </span>\n </div>\n <div\n className=\"mt-1.5 h-2 w-full overflow-hidden rounded-full\"\n style={{ backgroundColor: GRID }}\n >\n <div\n className=\"h-full rounded-full transition-all\"\n style={{ width: `${(d.value / max) * 100}%`, backgroundColor: colorAt(i, d.color) }}\n />\n </div>\n </li>\n ))}\n </ul>\n );\n};\n\n// ---------------------------------------------------------------------------\n// Sparkline / area — small trend line.\n// ---------------------------------------------------------------------------\nexport const Sparkline: FC<{\n points: number[];\n width?: number;\n height?: number;\n positive?: boolean;\n className?: string;\n}> = ({ points, width = 220, height = 56, positive = true, className }) => {\n const tr = useTr();\n if (points.length < 2) return null;\n const max = Math.max(...points);\n const min = Math.min(...points);\n const span = max - min || 1;\n const stroke = positive ? POSITIVE : NEGATIVE;\n const step = width / (points.length - 1);\n const coords = points.map((p, i) => [i * step, height - ((p - min) / span) * (height - 8) - 4]);\n const line = coords\n .map(([x, y], i) => `${i === 0 ? 'M' : 'L'}${x.toFixed(1)},${y.toFixed(1)}`)\n .join(' ');\n const area = `${line} L${width},${height} L0,${height} Z`;\n return (\n <svg\n width={width}\n height={height}\n viewBox={`0 0 ${width} ${height}`}\n role=\"img\"\n aria-label={tr('charts.trendLabel', 'Trend sparkline')}\n className={cn('max-w-full', className)}\n preserveAspectRatio=\"none\"\n >\n <path d={area} fill={stroke} opacity={0.12} />\n <path\n d={line}\n fill=\"none\"\n stroke={stroke}\n strokeWidth={2}\n strokeLinejoin=\"round\"\n strokeLinecap=\"round\"\n />\n </svg>\n );\n};\n\n// ---------------------------------------------------------------------------\n// Gauge — 0..max semicircle (e.g. health score).\n// ---------------------------------------------------------------------------\nexport const Gauge: FC<{\n value: number;\n max?: number;\n size?: number;\n label?: string;\n className?: string;\n}> = ({ value, max = 100, size = 120, label, className }) => {\n const pct = Math.max(0, Math.min(1, value / max));\n const r = size / 2 - 10;\n const cy = size / 2;\n const circ = Math.PI * r; // half circle\n const tone = pct >= 0.66 ? SUCCESS : pct >= 0.33 ? WARN : NEGATIVE;\n return (\n <div className={cn('inline-flex flex-col items-center', className)}>\n <svg\n width={size}\n height={size / 2 + 8}\n viewBox={`0 0 ${size} ${size / 2 + 8}`}\n role=\"img\"\n aria-label={`Gauge: ${Math.round(pct * 100)} percent`}\n className=\"max-w-full\"\n >\n <path\n d={`M10 ${cy} A ${r} ${r} 0 0 1 ${size - 10} ${cy}`}\n fill=\"none\"\n stroke={GRID}\n strokeWidth={10}\n strokeLinecap=\"round\"\n />\n <path\n d={`M10 ${cy} A ${r} ${r} 0 0 1 ${size - 10} ${cy}`}\n fill=\"none\"\n stroke={tone}\n strokeWidth={10}\n strokeLinecap=\"round\"\n strokeDasharray={`${pct * circ} ${circ}`}\n />\n </svg>\n <div className=\"-mt-4 text-center\">\n <span className=\"text-lg font-bold text-text-primary tabular-nums\">\n {Math.round(value)}\n </span>\n {label && <p className=\"text-xs text-text-secondary\">{label}</p>}\n </div>\n </div>\n );\n};\n\n// ---------------------------------------------------------------------------\n// Timeline — vertical events with a connector rail (e.g. renewals).\n// ---------------------------------------------------------------------------\nexport interface TimelineItem {\n title: string;\n sub?: string;\n meta?: ReactNode;\n tone?: 'default' | 'positive' | 'warning' | 'muted';\n}\nconst dotTone: Record<NonNullable<TimelineItem['tone']>, string> = {\n default: 'var(--color-accent-indigo)',\n positive: SUCCESS,\n warning: WARN,\n muted: 'var(--color-text-secondary)',\n};\nexport const Timeline: FC<{ items: TimelineItem[]; className?: string }> = ({\n items,\n className,\n}) => (\n <ol\n className={cn(\n 'relative space-y-5 ps-6 before:absolute before:start-[7px] before:top-1 before:bottom-1 before:w-px before:bg-border-subtle',\n className\n )}\n >\n {items.map((it, i) => (\n <li key={i} className=\"relative\">\n <span\n className=\"absolute -start-[22px] top-1 h-3 w-3 rounded-full ring-4 ring-bg-surface\"\n style={{ backgroundColor: dotTone[it.tone ?? 'default'] }}\n aria-hidden\n />\n <div className=\"flex items-baseline justify-between gap-2\">\n <p className=\"text-sm font-medium text-text-primary\">{it.title}</p>\n {it.meta && <span className=\"text-sm tabular-nums text-text-primary\">{it.meta}</span>}\n </div>\n {it.sub && <p className=\"text-xs text-text-secondary\">{it.sub}</p>}\n </li>\n ))}\n </ol>\n);\n\n// ---------------------------------------------------------------------------\n// MiniProgress — inline utilization bar (e.g. seats used).\n// ---------------------------------------------------------------------------\nexport const MiniProgress: FC<{\n value: number;\n max?: number;\n label: string;\n tone?: 'accent' | 'positive' | 'warning' | 'negative';\n className?: string;\n}> = ({ value, max = 100, label, tone = 'accent', className }) => {\n const pct = Math.max(0, Math.min(1, max ? value / max : 0));\n const color =\n tone === 'positive'\n ? SUCCESS\n : tone === 'warning'\n ? WARN\n : tone === 'negative'\n ? NEGATIVE\n : 'var(--color-accent-indigo)';\n return (\n <div\n className={cn('h-2 w-full overflow-hidden rounded-full', className)}\n style={{ backgroundColor: GRID }}\n role=\"progressbar\"\n aria-label={label}\n aria-valuenow={Math.round(pct * 100)}\n aria-valuemin={0}\n aria-valuemax={100}\n >\n <div\n className=\"h-full rounded-full transition-all\"\n style={{ width: `${pct * 100}%`, backgroundColor: color }}\n />\n </div>\n );\n};\n"],"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