@bpinternal/billing-ui 0.0.2 → 0.2.0
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.d.ts +93 -30
- package/dist/index.js +2244 -1934
- package/dist/index.umd.cjs +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -58,6 +58,8 @@ export declare type AddonsSummaryCardProps = {
|
|
|
58
58
|
className?: string;
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
+
export declare const ArrowRightIcon: ({ size, ...props }: IconProps) => JSX.Element;
|
|
62
|
+
|
|
61
63
|
export declare const Badge: ({ variant, children, className }: BadgeProps) => JSX.Element;
|
|
62
64
|
|
|
63
65
|
export declare type BadgeProps = {
|
|
@@ -68,6 +70,24 @@ export declare type BadgeProps = {
|
|
|
68
70
|
|
|
69
71
|
export declare const BankIcon: ({ size, ...props }: IconProps) => JSX.Element;
|
|
70
72
|
|
|
73
|
+
export declare const BILLING_EVENTS: {
|
|
74
|
+
readonly PLAN_PICKER_VIEWED: "billing_plan_picker_viewed";
|
|
75
|
+
readonly PLAN_INTERVAL_TOGGLED: "billing_plan_interval_toggled";
|
|
76
|
+
readonly PLAN_UPGRADE_INITIATED: "billing_plan_upgrade_initiated";
|
|
77
|
+
readonly PLAN_DOWNGRADED: "billing_plan_downgraded";
|
|
78
|
+
readonly PLAN_DOWNGRADE_CANCELLED: "billing_plan_downgrade_cancelled";
|
|
79
|
+
readonly CHECKOUT_STEP_VIEWED: "billing_checkout_step_viewed";
|
|
80
|
+
readonly CHECKOUT_INTERVAL_CHANGED: "billing_checkout_interval_changed";
|
|
81
|
+
readonly PAYMENT_METHOD_SELECTED: "billing_payment_method_selected";
|
|
82
|
+
readonly PAYMENT_DETAILS_CONFIRMED: "billing_payment_details_confirmed";
|
|
83
|
+
readonly PLAN_UPGRADED: "billing_plan_upgraded";
|
|
84
|
+
readonly CHECKOUT_ERROR: "billing_checkout_error";
|
|
85
|
+
readonly PAYMENT_METHOD_UPDATED: "billing_payment_method_updated";
|
|
86
|
+
readonly BILLING_ADDRESS_UPDATED: "billing_address_updated";
|
|
87
|
+
readonly INVOICE_DOWNLOADED: "billing_invoice_downloaded";
|
|
88
|
+
readonly UPGRADE_CTA_CLICKED: "billing_upgrade_cta_clicked";
|
|
89
|
+
};
|
|
90
|
+
|
|
71
91
|
export declare type BillingAddress = {
|
|
72
92
|
lineOne: string;
|
|
73
93
|
lineTwo?: string;
|
|
@@ -77,32 +97,17 @@ export declare type BillingAddress = {
|
|
|
77
97
|
country: string;
|
|
78
98
|
};
|
|
79
99
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
plan_name: string;
|
|
92
|
-
interval: BillingInterval;
|
|
93
|
-
amount_paid: number;
|
|
94
|
-
next_cycle_amount: number;
|
|
95
|
-
previous_plan_name?: string;
|
|
96
|
-
previous_interval?: BillingInterval;
|
|
97
|
-
}) => void;
|
|
98
|
-
trackPlanDowngraded?: (props: {
|
|
99
|
-
plan_name: string;
|
|
100
|
-
interval: BillingInterval;
|
|
101
|
-
previous_plan_name?: string;
|
|
102
|
-
}) => void;
|
|
103
|
-
trackPlanDowngradeCancelled?: (props: {
|
|
104
|
-
plan_name: string;
|
|
105
|
-
}) => void;
|
|
100
|
+
/**
|
|
101
|
+
* Analytics sink the library captures billing events into. Structurally a subset
|
|
102
|
+
* of a `posthog-js` instance — pass `posthog` straight in (no adapter), or any
|
|
103
|
+
* object with a matching `capture`. The library never imports an analytics SDK,
|
|
104
|
+
* so it stays publishable and provider-agnostic. Omit it and every event no-ops.
|
|
105
|
+
*
|
|
106
|
+
* Event names + property shapes the library emits live in `BILLING_EVENTS`
|
|
107
|
+
* (./analytics) — that's the source of truth for what lands in your project.
|
|
108
|
+
*/
|
|
109
|
+
export declare type BillingAnalyticsClient = {
|
|
110
|
+
capture: (event: string, properties?: Record<string, unknown>) => void;
|
|
106
111
|
};
|
|
107
112
|
|
|
108
113
|
export declare type BillingChangeEvent = {
|
|
@@ -137,7 +142,7 @@ declare type BillingContextValue = {
|
|
|
137
142
|
locale: string;
|
|
138
143
|
isDark: boolean;
|
|
139
144
|
toast: (toast: BillingToast) => void;
|
|
140
|
-
analytics:
|
|
145
|
+
analytics: BillingAnalyticsClient;
|
|
141
146
|
featureLabels?: Record<string, (quantity: number) => string>;
|
|
142
147
|
isOutdatedBilling: boolean;
|
|
143
148
|
manageBillingUrl?: string;
|
|
@@ -149,6 +154,8 @@ declare type BillingContextValue = {
|
|
|
149
154
|
notifyBillingChange: (event: BillingChangeEvent) => void;
|
|
150
155
|
};
|
|
151
156
|
|
|
157
|
+
export declare type BillingEventName = (typeof BILLING_EVENTS)[keyof typeof BILLING_EVENTS];
|
|
158
|
+
|
|
152
159
|
export declare type BillingInterval = 'month' | 'year';
|
|
153
160
|
|
|
154
161
|
export declare const billingKeys: {
|
|
@@ -180,7 +187,13 @@ export declare type BillingProviderProps = {
|
|
|
180
187
|
locale?: string;
|
|
181
188
|
theme?: BillingTheme;
|
|
182
189
|
onToast?: (toast: BillingToast) => void;
|
|
183
|
-
|
|
190
|
+
/**
|
|
191
|
+
* Analytics sink the library captures billing-funnel events into. Pass a
|
|
192
|
+
* `posthog-js` instance directly (it satisfies the shape), or any object with
|
|
193
|
+
* a matching `capture`. Omit and every event no-ops. The event names + props
|
|
194
|
+
* the library emits are listed in `BILLING_EVENTS`.
|
|
195
|
+
*/
|
|
196
|
+
analytics?: BillingAnalyticsClient;
|
|
184
197
|
/** Override the human label shown for a plan feature key (e.g. bot_count) */
|
|
185
198
|
featureLabels?: Record<string, (quantity: number) => string>;
|
|
186
199
|
/**
|
|
@@ -469,6 +482,44 @@ export declare const NANO_DOLLARS_PER_DOLLAR = 1000000000;
|
|
|
469
482
|
*/
|
|
470
483
|
export declare const OutdatedBillingGate: () => JSX.Element;
|
|
471
484
|
|
|
485
|
+
/**
|
|
486
|
+
* Free-plan upgrade modal — the proactive nudge shown when a Free workspace is
|
|
487
|
+
* about to run out of its one-time conversation allowance. Frames the upgrade
|
|
488
|
+
* (monthly allowance + packs + more channels) and offers the two self-serve
|
|
489
|
+
* paid tiers (Plus / Team) with the same plan-card language as the pricing
|
|
490
|
+
* table. Mount it once near the app root.
|
|
491
|
+
*
|
|
492
|
+
* Two modes:
|
|
493
|
+
* - **controlled** — pass `open` / `onOpenChange` and drive it yourself.
|
|
494
|
+
* - **auto** (omit `open`) — it opens itself when the workspace is on Free and
|
|
495
|
+
* ≥75% through its conversations, at most once per day per workspace
|
|
496
|
+
* (dismissed via localStorage, same as the usage banner). Returns the next day.
|
|
497
|
+
*/
|
|
498
|
+
export declare const OutgrowFreeDialog: ({ open, onOpenChange, onSelectPlan, recommendedPlanId, interval, planFeatures, featureDescriptions, period, }: OutgrowFreeDialogProps) => JSX.Element | null;
|
|
499
|
+
|
|
500
|
+
export declare type OutgrowFreeDialogProps = {
|
|
501
|
+
/**
|
|
502
|
+
* Controlled visibility. Omit to let the dialog manage itself in `auto` mode:
|
|
503
|
+
* it opens on its own when the workspace is on the Free plan and has used
|
|
504
|
+
* ≥75% of its conversation allowance — at most once per day per workspace.
|
|
505
|
+
*/
|
|
506
|
+
open?: boolean;
|
|
507
|
+
/** Required in controlled mode; also called when the dialog closes in auto mode. */
|
|
508
|
+
onOpenChange?: (open: boolean) => void;
|
|
509
|
+
/** Called when the user picks a plan — open your CheckoutDialog with these values. */
|
|
510
|
+
onSelectPlan: (planId: string, interval: BillingInterval) => void;
|
|
511
|
+
/** Plan kind (or exact id) to mark Recommended. Default 'team'. */
|
|
512
|
+
recommendedPlanId?: string;
|
|
513
|
+
/** Billing interval the prices are shown at. Default 'year' (annual). */
|
|
514
|
+
interval?: BillingInterval;
|
|
515
|
+
/** Per-kind marketing feature strings; defaults to DEFAULT_PLAN_FEATURES. */
|
|
516
|
+
planFeatures?: Partial<Record<PlanKind, string[]>>;
|
|
517
|
+
/** Feature label → tooltip description; merged over DEFAULT_FEATURE_DESCRIPTIONS. */
|
|
518
|
+
featureDescriptions?: Record<string, string>;
|
|
519
|
+
/** Period (any datetime in the billing month) to evaluate usage; defaults to current month. */
|
|
520
|
+
period?: string;
|
|
521
|
+
};
|
|
522
|
+
|
|
472
523
|
export declare const PaintIcon: ({ size, ...props }: IconProps) => JSX.Element;
|
|
473
524
|
|
|
474
525
|
export declare type PaymentMethod = NonNullable<Awaited<ReturnType<BillingClient['getPaymentMethod']>>['paymentMethod']>;
|
|
@@ -712,7 +763,11 @@ export declare type UsageBannerProps = {
|
|
|
712
763
|
* checkout so it works with zero host wiring.
|
|
713
764
|
*/
|
|
714
765
|
onUpgrade?: () => void;
|
|
715
|
-
/**
|
|
766
|
+
/**
|
|
767
|
+
* Show a dismiss (×) button. Dismissing hides the banner (for that metric) for
|
|
768
|
+
* the rest of the day via localStorage; it returns the next day or if a
|
|
769
|
+
* different metric crosses the threshold. Default true.
|
|
770
|
+
*/
|
|
716
771
|
dismissible?: boolean;
|
|
717
772
|
/** CTA label. Default "Upgrade plan". */
|
|
718
773
|
ctaLabel?: string;
|
|
@@ -766,7 +821,7 @@ export declare function usageItems(quotas: WorkspaceUsages | undefined): UsageIt
|
|
|
766
821
|
* hover/focus after `delay`. Renders the children plainly on legacy billing
|
|
767
822
|
* or when there's no usage to show (the popover just never opens).
|
|
768
823
|
*/
|
|
769
|
-
export declare const UsagePopover: ({ children, delay, placement, period, className }: UsagePopoverProps) => JSX.Element;
|
|
824
|
+
export declare const UsagePopover: ({ children, delay, placement, period, onUpgrade, block, className, }: UsagePopoverProps) => JSX.Element;
|
|
770
825
|
|
|
771
826
|
export declare type UsagePopoverProps = {
|
|
772
827
|
/** The trigger — hovering/focusing it reveals the usage popover. */
|
|
@@ -777,6 +832,14 @@ export declare type UsagePopoverProps = {
|
|
|
777
832
|
placement?: 'top' | 'bottom';
|
|
778
833
|
/** Period (any datetime in the billing month); defaults to current month. */
|
|
779
834
|
period?: string;
|
|
835
|
+
/**
|
|
836
|
+
* Upgrade handler. When set, the popover shows a "Need more room?" nudge with a
|
|
837
|
+
* CTA on plans that can move up (e.g. Free). Wire it to your plan picker /
|
|
838
|
+
* billing route — same target as the widget's `onManage`.
|
|
839
|
+
*/
|
|
840
|
+
onUpgrade?: () => void;
|
|
841
|
+
/** Stretch the trigger to fill its container (e.g. a full-width sidebar widget). */
|
|
842
|
+
block?: boolean;
|
|
780
843
|
className?: string;
|
|
781
844
|
};
|
|
782
845
|
|