@nozle-js/react 0.10.2 → 0.12.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 CHANGED
@@ -1,5 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import React__default, { ReactNode, CSSProperties } from 'react';
3
+ import { A as Appearance, E as ElementKey } from './tokens-Bm4VWWb0.js';
4
+ export { a as Elements, T as Theme, V as Variables } from './tokens-Bm4VWWb0.js';
5
+ import { QueryClient, UseQueryResult } from '@tanstack/react-query';
6
+ import * as _tanstack_query_core from '@tanstack/query-core';
3
7
 
4
8
  /** A short-lived customer-portal credential issued by the merchant's backend. */
5
9
  interface BillingPortalSession {
@@ -55,6 +59,7 @@ interface CancellationControlProps {
55
59
  locale?: string;
56
60
  timezone?: string;
57
61
  nonce?: string;
62
+ appearance?: Appearance;
58
63
  }
59
64
  /** Customer cancellation UI. All mutations go through the merchant's authenticated callbacks. */
60
65
  declare function CancellationControl(props: CancellationControlProps): React.JSX.Element;
@@ -188,11 +193,24 @@ interface NozleClient {
188
193
  baseUrl: string;
189
194
  catalogFetch(path: string, init?: RequestInit): Promise<Response>;
190
195
  }
196
+ /** A failed request to your billing endpoint. `code` is the error code the endpoint returned. */
197
+ declare class BillingRequestError extends Error {
198
+ readonly status: number;
199
+ readonly code: string | undefined;
200
+ readonly requestId?: string | undefined;
201
+ constructor(status: number, code: string | undefined, requestId?: string | undefined);
202
+ }
203
+ type BillingFetch = <T>(route: string, params?: Record<string, string | number | undefined>) => Promise<T>;
191
204
  interface BillingContextValue {
192
205
  client: NozleClient;
193
206
  createCheckout?: CreateCheckout;
194
207
  verifyCheckout?: VerifyCheckout;
195
208
  getCheckoutStatus?: GetCheckoutStatus;
209
+ /** The query client the billing hooks use: the `queryClient` prop, or one the provider made. */
210
+ queryClient: QueryClient;
211
+ /** Reads a route of your billing endpoint; undefined when `billingEndpoint` is not set. */
212
+ billingFetch?: BillingFetch;
213
+ billingEndpoint?: string;
196
214
  }
197
215
  declare const BillingContext: React__default.Context<BillingContextValue | null>;
198
216
  interface BillingProviderProps {
@@ -201,9 +219,28 @@ interface BillingProviderProps {
201
219
  verifyCheckout?: VerifyCheckout;
202
220
  getCheckoutStatus?: GetCheckoutStatus;
203
221
  baseUrl?: string;
222
+ /**
223
+ * Path of your backend route that serves the customer hooks (`useSubscription`,
224
+ * `useEntitlement`, `useCreditBalance`, `useCreditHistory`, `useUsage`, `useUpgradePreview`),
225
+ * for example `/api/nozle`. Serve it with `createBillingHandler` from `@nozle-js/node`.
226
+ */
227
+ billingEndpoint?: string;
228
+ /** Extra headers for billing endpoint requests, such as a CSRF token. */
229
+ billingHeaders?: () => HeadersInit | Promise<HeadersInit>;
230
+ /**
231
+ * Your app's TanStack Query client, to share its cache and devtools. Without it the provider
232
+ * makes its own. The hooks pass their client explicitly, so they never use or replace a
233
+ * `QueryClientProvider` of your app.
234
+ */
235
+ queryClient?: QueryClient;
236
+ /**
237
+ * Look of every component inside: a predefined theme from `@nozle-js/react/themes`, your own
238
+ * variables, and per-element class names or styles. A component's own `appearance` goes on top.
239
+ */
240
+ appearance?: Appearance;
204
241
  children: ReactNode;
205
242
  }
206
- declare function BillingProvider({ publishableKey, createCheckout, verifyCheckout, getCheckoutStatus, baseUrl, children, }: BillingProviderProps): React__default.ReactElement;
243
+ declare function BillingProvider({ publishableKey, createCheckout, verifyCheckout, getCheckoutStatus, baseUrl, billingEndpoint, billingHeaders, queryClient, appearance, children, }: BillingProviderProps): React__default.ReactElement;
207
244
  declare function useOptionalBillingContext(): BillingContextValue | null;
208
245
  declare function useBillingContext(): BillingContextValue;
209
246
  declare function useNozleClient(): NozleClient;
@@ -288,6 +325,7 @@ interface PlanChangeControlProps {
288
325
  locale?: string;
289
326
  timezone?: string;
290
327
  nonce?: string;
328
+ appearance?: Appearance;
291
329
  }
292
330
  /** Payment-backed upgrades and scheduled downgrades for one external subscription. */
293
331
  declare function PlanChangeControl(props: PlanChangeControlProps): React.JSX.Element;
@@ -306,22 +344,685 @@ interface BillingPortalProps {
306
344
  /** CSP nonce for the component's scoped stylesheet. No Tailwind setup is required. */
307
345
  nonce?: string;
308
346
  onError?: (error: BillingPortalError) => void;
347
+ appearance?: Appearance;
309
348
  }
310
349
  /** Native React customer portal. Uses customer-scoped GraphQL, with no iframe or global auth storage. */
311
- declare function BillingPortal({ createSession, cancellationActions, planChangeActions, locale, className, style, nonce, onError, }: BillingPortalProps): React.JSX.Element;
350
+ declare function BillingPortal({ createSession, cancellationActions, planChangeActions, locale, className, style, nonce, onError, appearance, }: BillingPortalProps): React.JSX.Element;
351
+
352
+ interface ElementProps {
353
+ className?: string;
354
+ style?: CSSProperties;
355
+ }
356
+ interface UseAppearance {
357
+ /** Props for a component's root: its `nozle-<key>` class, the theme's CSS variables and its element overrides. */
358
+ root(key: ElementKey, style?: CSSProperties, className?: string): ElementProps;
359
+ /** Props for an inner element: its `nozle-<key>` class and its element overrides. */
360
+ el(key: ElementKey, style?: CSSProperties, className?: string): ElementProps;
361
+ /** The plan card layout the theme asks for. */
362
+ planCardLayout: "card" | "panel";
363
+ /** The theme's CSS variables, for an element rendered beside the root rather than inside it. */
364
+ vars: CSSProperties;
365
+ }
366
+ /**
367
+ * Resolves the provider's appearance with the component's own on top. Without any appearance no
368
+ * variables are written, so CSS variables an app sets on `:root` keep working.
369
+ */
370
+ declare function useAppearance(appearance?: Appearance): UseAppearance;
312
371
 
313
- interface Plan$1 {
372
+ interface CatalogPrivilege {
373
+ code: string;
374
+ name: string;
375
+ value_type: string;
376
+ value: string | number | boolean | null;
377
+ }
378
+ interface CatalogEntitlement {
379
+ feature_type: string;
314
380
  code: string;
315
381
  name: string;
382
+ description?: string | null;
383
+ usage_limit?: number | null;
384
+ privileges?: CatalogPrivilege[];
385
+ }
386
+ interface CatalogCreditGrantRule {
387
+ credit_system_code: string;
388
+ amount: string;
389
+ interval: string;
390
+ interval_count?: number;
391
+ }
392
+ interface CatalogChargeRange {
393
+ from_value: number;
394
+ to_value: number | null;
395
+ per_unit_amount?: string;
396
+ flat_amount?: string;
397
+ rate?: string;
398
+ }
399
+ /** A usage charge. Amounts inside `properties` are decimal strings in currency units, not cents. */
400
+ interface CatalogCharge {
401
+ code?: string | null;
402
+ feature_code?: string | null;
403
+ charge_model: string;
404
+ properties?: {
405
+ amount?: string;
406
+ package_size?: number;
407
+ free_units?: number;
408
+ rate?: string;
409
+ fixed_amount?: string;
410
+ graduated_ranges?: CatalogChargeRange[];
411
+ volume_ranges?: CatalogChargeRange[];
412
+ graduated_percentage_ranges?: CatalogChargeRange[];
413
+ };
414
+ }
415
+ interface PlanFeatureSource {
416
+ amount_currency: string;
417
+ entitlements?: CatalogEntitlement[];
418
+ credit_grant_rules?: CatalogCreditGrantRule[];
419
+ charges?: CatalogCharge[];
420
+ }
421
+ /**
422
+ * One line per thing a plan gives, built only from the catalog: entitlements, credit grants and usage
423
+ * prices, in the order the catalog returns them. Charges whose price cannot be written as a line
424
+ * (`custom`, `dynamic`) are skipped.
425
+ */
426
+ declare function planFeatures(plan: PlanFeatureSource): string[];
427
+ interface ComparisonPlan extends PlanFeatureSource {
428
+ code: string;
429
+ }
430
+ interface ComparisonRow {
431
+ key: string;
432
+ label: string;
433
+ values: Record<string, string | boolean>;
434
+ }
435
+ /**
436
+ * One row per entitlement and per granted credit system across the plans, in the order they first
437
+ * appear. A plan that does not have the entitlement gets `false`, so the table shows the real gap.
438
+ */
439
+ declare function comparisonRows(plans: ComparisonPlan[]): ComparisonRow[];
440
+ interface SortablePlan {
316
441
  amount_cents: number;
317
442
  amount_currency: string;
318
- interval: string;
319
443
  }
444
+ /**
445
+ * The default plan order: cheapest base price first, so a free plan comes first. Plans in different
446
+ * currencies stay grouped in the order each currency first appears, because their amounts cannot be
447
+ * compared. Plans with the same price keep the order the catalog returned them in.
448
+ */
449
+ declare function sortPlansByPrice<T extends SortablePlan>(plans: T[]): T[];
450
+
451
+ type PricingInterval = "weekly" | "monthly" | "quarterly" | "semiannual" | "yearly";
452
+ type PricingPrivilege = CatalogPrivilege;
453
+ type PricingEntitlement = CatalogEntitlement;
454
+ interface PricingPlan {
455
+ code: string;
456
+ name: string;
457
+ amount_cents: number;
458
+ amount_currency: string;
459
+ interval: PricingInterval | (string & {});
460
+ description?: string | null;
461
+ pending_deletion?: boolean;
462
+ plan_family_code?: string | null;
463
+ /** Present in the public catalog. Absent from an older or reduced response. */
464
+ entitlements?: PricingEntitlement[];
465
+ credit_grant_rules?: CatalogCreditGrantRule[];
466
+ charges?: CatalogCharge[];
467
+ }
468
+ /** Display settings of one feature on a family's pricing card. */
469
+ interface PricingFamilyFeature {
470
+ code: string;
471
+ name?: string | null;
472
+ description?: string | null;
473
+ show_on_pricing?: boolean;
474
+ show_description?: boolean;
475
+ display_position?: number | null;
476
+ }
477
+ interface PricingFamily {
478
+ code: string;
479
+ name: string;
480
+ description?: string | null;
481
+ show_on_pricing?: boolean;
482
+ pricing_position?: number | null;
483
+ pricing_highlighted?: boolean;
484
+ badge_text?: string | null;
485
+ cta_text?: string | null;
486
+ /** Codes of the family's plans, ordered weekly to yearly. */
487
+ plan_codes: string[];
488
+ features?: PricingFamilyFeature[];
489
+ }
490
+ /** The `GET /api/v1/plans` payload. `families` is absent on older APIs. */
491
+ interface PricingCatalog {
492
+ plans: PricingPlan[];
493
+ families?: PricingFamily[] | null;
494
+ }
495
+ interface PricingFeature {
496
+ label: string;
497
+ description?: string | null;
498
+ }
499
+ /**
500
+ * Feature overrides: a record keyed by family code or plan code, or an array
501
+ * aligned to the cards in display order.
502
+ */
503
+ type PricingFeatureOverrides = Record<string, Array<string | PricingFeature>> | Array<Array<string | PricingFeature> | undefined>;
504
+ interface PricingIntervalOption {
505
+ interval: PricingInterval;
506
+ label: string;
507
+ /** Best whole-percent saving of any visible family against its monthly plan. */
508
+ savingsPercent: number | null;
509
+ }
510
+ interface PricingCard {
511
+ /** Family code, or the plan code when the catalog has no families. */
512
+ key: string;
513
+ /** Null when the catalog has no families (older APIs). */
514
+ family: PricingFamily | null;
515
+ /** The family's live plans, ordered weekly to yearly. */
516
+ plans: PricingPlan[];
517
+ /** The plan shown, checked out and passed to `onSelect`. */
518
+ plan: PricingPlan;
519
+ /** True when the family has no plan for the requested interval. */
520
+ isFallbackInterval: boolean;
521
+ name: string;
522
+ description: string | null;
523
+ /**
524
+ * Family cards: the per-month equivalent of the plan's price, for example
525
+ * "$40.83". Without families: the plan's price, for example "$14.99".
526
+ */
527
+ price: string;
528
+ /** "/mo" on family cards; the plan's own interval ("/quarter") without families. */
529
+ pricePeriod: string;
530
+ /**
531
+ * Family cards: for example "Billed $490 yearly · save 17%" or "Billed
532
+ * monthly". Empty without families.
533
+ */
534
+ billing: string;
535
+ /** Whole-percent saving against the family's monthly plan, when positive. */
536
+ savingsPercent: number | null;
537
+ features: PricingFeature[];
538
+ highlighted: boolean;
539
+ /** Badge text when highlighted, otherwise null. */
540
+ badge: string | null;
541
+ /** Call-to-action text (family `cta_text` or "Get {name}"). */
542
+ cta: string;
543
+ /** The family code or one of its plan codes is listed in `contactSales`. */
544
+ enterprise: boolean;
545
+ }
546
+ interface GetPricingCardsOptions {
547
+ /**
548
+ * Interval to show ("annual" is accepted for "yearly"). Defaults to
549
+ * monthly when offered, else the first available interval. Without
550
+ * families, plans of other intervals are left out only when an interval
551
+ * is given.
552
+ */
553
+ interval?: PricingInterval | "annual" | null;
554
+ locale?: string;
555
+ /** Family code or plan code to highlight instead of `pricing_highlighted`. */
556
+ highlight?: string | null;
557
+ /**
558
+ * Badge on the highlighted card, replacing the family's `badge_text`
559
+ * (default "Most Popular"). `null` shows no badge.
560
+ */
561
+ badge?: string | null;
562
+ features?: PricingFeatureOverrides;
563
+ /**
564
+ * Codes of families or plans sold on request. Their card's `enterprise` is
565
+ * true. Without families they also stay visible whatever the interval and
566
+ * come last.
567
+ */
568
+ contactSales?: readonly string[];
569
+ /**
570
+ * Orders the plans of a catalog without families. By default they are
571
+ * sorted by base price, cheapest first, with `contactSales` plans last.
572
+ * Families are ordered by `pricing_position`.
573
+ */
574
+ sort?: (a: PricingPlan, b: PricingPlan) => number;
575
+ }
576
+ /** Intervals offered by the visible cards, ordered weekly to yearly. */
577
+ declare function getAvailableIntervals(catalog: PricingCatalog): PricingInterval[];
578
+ /**
579
+ * Options for an interval switch: each available interval with its label
580
+ * and the best family saving against the family's monthly plan.
581
+ */
582
+ declare function getPricingIntervalOptions(catalog: PricingCatalog): PricingIntervalOption[];
583
+ /**
584
+ * The interval to show first: `preferred` ("annual" means "yearly") when it
585
+ * is available, otherwise monthly when available, otherwise the first one.
586
+ */
587
+ declare function getDefaultInterval(catalog: PricingCatalog, preferred?: string | null): PricingInterval | null;
588
+ /**
589
+ * Pricing cards in display order for one interval: the selected plan of each
590
+ * visible family (or the nearest interval's plan when the family has none for
591
+ * it), its per-month price and billing line, its features, the highlight,
592
+ * badge and call to action. Without families each live plan is a card.
593
+ */
594
+ declare function getPricingCards(catalog: PricingCatalog, options?: GetPricingCardsOptions): PricingCard[];
595
+
596
+ /**
597
+ * A plan from the public catalog (`GET /api/v1/plans`). The catalog also returns entitlements, credit
598
+ * grants and charges; they are absent from an older or reduced response.
599
+ */
600
+ type Plan = PricingPlan;
601
+ /**
602
+ * The public plan catalog, read with the publishable key and cached by TanStack Query. `families` is
603
+ * null when the API returns no `families` key (older APIs); pass `{ plans, families }` to
604
+ * `getPricingCards` either way.
605
+ */
320
606
  declare function usePlans(): {
321
- plans: Plan$1[];
607
+ plans: PricingPlan[];
608
+ families: PricingFamily[] | null;
322
609
  isLoading: boolean;
323
610
  error: Error | null;
611
+ refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<{
612
+ plans: PricingPlan[];
613
+ families: PricingFamily[] | null;
614
+ nozleBranding: boolean;
615
+ }, Error>>;
616
+ };
617
+
618
+ /**
619
+ * Whether the merchant's Nozle plan keeps the "Powered by Nozle" badge. The server decides
620
+ * (`meta.nozle_branding` in the publishable-key plan catalog); without a BillingProvider, or
621
+ * before the answer arrives, there is no badge.
622
+ */
623
+ declare function useNozleBranding(): boolean;
624
+ /** "Powered by" and the Nozle logo, linking to nozle.dev. */
625
+ declare function PoweredByNozle(): React__default.ReactElement;
626
+
627
+ interface CreditBalanceSource {
628
+ id: string;
629
+ type: "subscription_grant" | "top_up" | "manual_grant" | "adjustment" | "allocated_top_up";
630
+ remaining: string;
631
+ expires_at: string | null;
632
+ }
633
+ /** The fields of the SDK's credit balance (`nozle.credits.balance`) that this component reads. */
634
+ interface CreditBalanceData {
635
+ credit_system_name: string;
636
+ unit_name: string;
637
+ available: string;
638
+ as_of: string;
639
+ sources?: CreditBalanceSource[];
640
+ }
641
+ interface CreditBalanceProps {
642
+ /** One balance from your backend. `null` or `undefined` shows the empty message. */
643
+ balance?: CreditBalanceData | null;
644
+ isLoading?: boolean;
645
+ error?: Error | string | null;
646
+ emptyMessage?: string;
647
+ appearance?: Appearance;
648
+ }
649
+ declare function CreditBalance({ balance, isLoading, error, emptyMessage, appearance, }: CreditBalanceProps): React__default.ReactElement;
650
+
651
+ /** The fields of the SDK's credit operation (`nozle.credits.operations`) that this component reads. */
652
+ interface CreditOperationData {
653
+ id: string;
654
+ type: "consume" | "grant" | "adjustment" | "expire" | "revoke" | "refund" | "transfer";
655
+ status: "succeeded" | "denied" | "reversed";
656
+ credit_amount: string;
657
+ feature_code: string | null;
658
+ occurred_at: string;
659
+ }
660
+ interface CreditHistoryProps {
661
+ operations?: CreditOperationData[];
662
+ isLoading?: boolean;
663
+ error?: Error | string | null;
664
+ emptyMessage?: string;
665
+ /** When true a "Load more" button is shown. Fetch the next page with the SDK's `next_cursor`. */
666
+ hasMore?: boolean;
667
+ onLoadMore?: () => void;
668
+ appearance?: Appearance;
669
+ }
670
+ declare function CreditHistory({ operations, isLoading, error, emptyMessage, hasMore, onLoadMore, appearance, }: CreditHistoryProps): React__default.ReactElement;
671
+
672
+ /** One charge's usage in a period, as returned by Core's `current_usage` and `past_usage`. */
673
+ interface ChargeUsageData {
674
+ /** Decimal string, for example `"1200.0"`. */
675
+ units: string;
676
+ amount_cents: number;
677
+ amount_currency: string;
678
+ events_count?: number;
679
+ charge: {
680
+ nozle_id: string;
681
+ charge_model: string;
682
+ invoice_display_name?: string | null;
683
+ };
684
+ feature: {
685
+ nozle_id: string;
686
+ code: string;
687
+ name: string;
688
+ aggregation_type?: string;
689
+ };
690
+ }
691
+ /**
692
+ * A customer's usage for one billing period: the `customer_usage` object of
693
+ * `GET /customers/{external_customer_id}/current_usage`, or one item of `usage_periods` in
694
+ * `GET /customers/{external_customer_id}/past_usage`. Read them on your backend with a secret key.
695
+ */
696
+ interface CustomerUsageData {
697
+ from_datetime: string;
698
+ to_datetime: string;
699
+ currency: string;
700
+ amount_cents: number;
701
+ charges_usage: ChargeUsageData[];
702
+ }
703
+
704
+ /** The customer's subscription with its plan and any scheduled change, or nulls without one. */
705
+ interface BillingSubscription {
706
+ subscription: {
707
+ external_id: string;
708
+ plan_code: string;
709
+ status: string;
710
+ ending_at: string | null;
711
+ plan: {
712
+ code: string;
713
+ name: string;
714
+ amount_cents: number | string;
715
+ currency: string;
716
+ interval: string;
717
+ };
718
+ } | null;
719
+ pending_change: {
720
+ plan_code: string;
721
+ name: string;
722
+ effective_at: string;
723
+ } | null;
724
+ /** The customer has an unpaid invoice past its due date. */
725
+ past_due?: boolean;
726
+ }
727
+ /** An entitlement decision for one feature (`can()` on your backend). */
728
+ interface EntitlementResult {
729
+ allowed: boolean;
730
+ used?: number;
731
+ limit: number | null;
732
+ remaining: number | null;
733
+ reason?: string;
734
+ }
735
+ /** The price of changing to another plan, before the customer confirms. */
736
+ interface UpgradePreview {
737
+ quote_id: string;
738
+ currency: string;
739
+ net_amount_cents: number | string;
740
+ amount_due_now_cents: number | string;
741
+ amount_due_at_effective_cents: number | string;
742
+ transition_direction: "upgrade" | "downgrade";
743
+ timing: "immediate" | "end_of_period";
744
+ effective_at: string;
745
+ renewal_at: string | null;
746
+ }
747
+ interface CreditHistoryPage {
748
+ operations: CreditOperationData[];
749
+ next_cursor: string | null;
750
+ }
751
+ /** The signed-in customer's subscription, plan and scheduled change. */
752
+ declare function useSubscription(): UseQueryResult<BillingSubscription, Error>;
753
+ /** Whether the customer may use a feature now, with used, limit and remaining. */
754
+ declare function useEntitlement(featureCode: string, options?: {
755
+ enabled?: boolean;
756
+ }): UseQueryResult<EntitlementResult, Error>;
757
+ /**
758
+ * One credit balance, ready for `<CreditBalance balance={data} />`: the given credit system,
759
+ * or the first one with credits, or the first one.
760
+ */
761
+ declare function useCreditBalance(creditSystemCode?: string): UseQueryResult<CreditBalanceData | null, Error>;
762
+ /**
763
+ * Credit operations, newest first, a page at a time. `operations` flattens the loaded pages for
764
+ * `<CreditHistory operations={operations} hasMore={hasNextPage} onLoadMore={fetchNextPage} />`.
765
+ */
766
+ declare function useCreditHistory(options?: {
767
+ creditSystemCode?: string;
768
+ limit?: number;
769
+ }): {
770
+ operations: CreditOperationData[];
771
+ data: _tanstack_query_core.InfiniteData<CreditHistoryPage, unknown>;
772
+ error: Error;
773
+ isError: true;
774
+ isPending: false;
775
+ isLoading: false;
776
+ isLoadingError: false;
777
+ isRefetchError: true;
778
+ isSuccess: false;
779
+ isPlaceholderData: false;
780
+ status: "error";
781
+ fetchNextPage: (options?: _tanstack_query_core.FetchNextPageOptions) => Promise<_tanstack_query_core.InfiniteQueryObserverResult<_tanstack_query_core.InfiniteData<CreditHistoryPage, unknown>, Error>>;
782
+ fetchPreviousPage: (options?: _tanstack_query_core.FetchPreviousPageOptions) => Promise<_tanstack_query_core.InfiniteQueryObserverResult<_tanstack_query_core.InfiniteData<CreditHistoryPage, unknown>, Error>>;
783
+ hasNextPage: boolean;
784
+ hasPreviousPage: boolean;
785
+ isFetchNextPageError: boolean;
786
+ isFetchingNextPage: boolean;
787
+ isFetchPreviousPageError: boolean;
788
+ isFetchingPreviousPage: boolean;
789
+ dataUpdatedAt: number;
790
+ errorUpdatedAt: number;
791
+ failureCount: number;
792
+ failureReason: Error | null;
793
+ errorUpdateCount: number;
794
+ isFetched: boolean;
795
+ isFetchedAfterMount: boolean;
796
+ isFetching: boolean;
797
+ isInitialLoading: boolean;
798
+ isPaused: boolean;
799
+ isRefetching: boolean;
800
+ isStale: boolean;
801
+ isEnabled: boolean;
802
+ refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<_tanstack_query_core.InfiniteData<CreditHistoryPage, unknown>, Error>>;
803
+ fetchStatus: _tanstack_query_core.FetchStatus;
804
+ } | {
805
+ operations: CreditOperationData[];
806
+ data: _tanstack_query_core.InfiniteData<CreditHistoryPage, unknown>;
807
+ error: null;
808
+ isError: false;
809
+ isPending: false;
810
+ isLoading: false;
811
+ isLoadingError: false;
812
+ isRefetchError: false;
813
+ isFetchNextPageError: false;
814
+ isFetchPreviousPageError: false;
815
+ isSuccess: true;
816
+ isPlaceholderData: false;
817
+ status: "success";
818
+ fetchNextPage: (options?: _tanstack_query_core.FetchNextPageOptions) => Promise<_tanstack_query_core.InfiniteQueryObserverResult<_tanstack_query_core.InfiniteData<CreditHistoryPage, unknown>, Error>>;
819
+ fetchPreviousPage: (options?: _tanstack_query_core.FetchPreviousPageOptions) => Promise<_tanstack_query_core.InfiniteQueryObserverResult<_tanstack_query_core.InfiniteData<CreditHistoryPage, unknown>, Error>>;
820
+ hasNextPage: boolean;
821
+ hasPreviousPage: boolean;
822
+ isFetchingNextPage: boolean;
823
+ isFetchingPreviousPage: boolean;
824
+ dataUpdatedAt: number;
825
+ errorUpdatedAt: number;
826
+ failureCount: number;
827
+ failureReason: Error | null;
828
+ errorUpdateCount: number;
829
+ isFetched: boolean;
830
+ isFetchedAfterMount: boolean;
831
+ isFetching: boolean;
832
+ isInitialLoading: boolean;
833
+ isPaused: boolean;
834
+ isRefetching: boolean;
835
+ isStale: boolean;
836
+ isEnabled: boolean;
837
+ refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<_tanstack_query_core.InfiniteData<CreditHistoryPage, unknown>, Error>>;
838
+ fetchStatus: _tanstack_query_core.FetchStatus;
839
+ } | {
840
+ operations: CreditOperationData[];
841
+ data: undefined;
842
+ error: Error;
843
+ isError: true;
844
+ isPending: false;
845
+ isLoading: false;
846
+ isLoadingError: true;
847
+ isRefetchError: false;
848
+ isFetchNextPageError: false;
849
+ isFetchPreviousPageError: false;
850
+ isSuccess: false;
851
+ isPlaceholderData: false;
852
+ status: "error";
853
+ fetchNextPage: (options?: _tanstack_query_core.FetchNextPageOptions) => Promise<_tanstack_query_core.InfiniteQueryObserverResult<_tanstack_query_core.InfiniteData<CreditHistoryPage, unknown>, Error>>;
854
+ fetchPreviousPage: (options?: _tanstack_query_core.FetchPreviousPageOptions) => Promise<_tanstack_query_core.InfiniteQueryObserverResult<_tanstack_query_core.InfiniteData<CreditHistoryPage, unknown>, Error>>;
855
+ hasNextPage: boolean;
856
+ hasPreviousPage: boolean;
857
+ isFetchingNextPage: boolean;
858
+ isFetchingPreviousPage: boolean;
859
+ dataUpdatedAt: number;
860
+ errorUpdatedAt: number;
861
+ failureCount: number;
862
+ failureReason: Error | null;
863
+ errorUpdateCount: number;
864
+ isFetched: boolean;
865
+ isFetchedAfterMount: boolean;
866
+ isFetching: boolean;
867
+ isInitialLoading: boolean;
868
+ isPaused: boolean;
869
+ isRefetching: boolean;
870
+ isStale: boolean;
871
+ isEnabled: boolean;
872
+ refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<_tanstack_query_core.InfiniteData<CreditHistoryPage, unknown>, Error>>;
873
+ fetchStatus: _tanstack_query_core.FetchStatus;
874
+ } | {
875
+ operations: CreditOperationData[];
876
+ data: undefined;
877
+ error: null;
878
+ isError: false;
879
+ isPending: true;
880
+ isLoading: true;
881
+ isLoadingError: false;
882
+ isRefetchError: false;
883
+ isFetchNextPageError: false;
884
+ isFetchPreviousPageError: false;
885
+ isSuccess: false;
886
+ isPlaceholderData: false;
887
+ status: "pending";
888
+ fetchNextPage: (options?: _tanstack_query_core.FetchNextPageOptions) => Promise<_tanstack_query_core.InfiniteQueryObserverResult<_tanstack_query_core.InfiniteData<CreditHistoryPage, unknown>, Error>>;
889
+ fetchPreviousPage: (options?: _tanstack_query_core.FetchPreviousPageOptions) => Promise<_tanstack_query_core.InfiniteQueryObserverResult<_tanstack_query_core.InfiniteData<CreditHistoryPage, unknown>, Error>>;
890
+ hasNextPage: boolean;
891
+ hasPreviousPage: boolean;
892
+ isFetchingNextPage: boolean;
893
+ isFetchingPreviousPage: boolean;
894
+ dataUpdatedAt: number;
895
+ errorUpdatedAt: number;
896
+ failureCount: number;
897
+ failureReason: Error | null;
898
+ errorUpdateCount: number;
899
+ isFetched: boolean;
900
+ isFetchedAfterMount: boolean;
901
+ isFetching: boolean;
902
+ isInitialLoading: boolean;
903
+ isPaused: boolean;
904
+ isRefetching: boolean;
905
+ isStale: boolean;
906
+ isEnabled: boolean;
907
+ refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<_tanstack_query_core.InfiniteData<CreditHistoryPage, unknown>, Error>>;
908
+ fetchStatus: _tanstack_query_core.FetchStatus;
909
+ } | {
910
+ operations: CreditOperationData[];
911
+ data: undefined;
912
+ error: null;
913
+ isError: false;
914
+ isPending: true;
915
+ isLoadingError: false;
916
+ isRefetchError: false;
917
+ isFetchNextPageError: false;
918
+ isFetchPreviousPageError: false;
919
+ isSuccess: false;
920
+ isPlaceholderData: false;
921
+ status: "pending";
922
+ fetchNextPage: (options?: _tanstack_query_core.FetchNextPageOptions) => Promise<_tanstack_query_core.InfiniteQueryObserverResult<_tanstack_query_core.InfiniteData<CreditHistoryPage, unknown>, Error>>;
923
+ fetchPreviousPage: (options?: _tanstack_query_core.FetchPreviousPageOptions) => Promise<_tanstack_query_core.InfiniteQueryObserverResult<_tanstack_query_core.InfiniteData<CreditHistoryPage, unknown>, Error>>;
924
+ hasNextPage: boolean;
925
+ hasPreviousPage: boolean;
926
+ isFetchingNextPage: boolean;
927
+ isFetchingPreviousPage: boolean;
928
+ dataUpdatedAt: number;
929
+ errorUpdatedAt: number;
930
+ failureCount: number;
931
+ failureReason: Error | null;
932
+ errorUpdateCount: number;
933
+ isFetched: boolean;
934
+ isFetchedAfterMount: boolean;
935
+ isFetching: boolean;
936
+ isLoading: boolean;
937
+ isInitialLoading: boolean;
938
+ isPaused: boolean;
939
+ isRefetching: boolean;
940
+ isStale: boolean;
941
+ isEnabled: boolean;
942
+ refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<_tanstack_query_core.InfiniteData<CreditHistoryPage, unknown>, Error>>;
943
+ fetchStatus: _tanstack_query_core.FetchStatus;
944
+ } | {
945
+ operations: CreditOperationData[];
946
+ data: _tanstack_query_core.InfiniteData<CreditHistoryPage, unknown>;
947
+ isError: false;
948
+ error: null;
949
+ isPending: false;
950
+ isLoading: false;
951
+ isLoadingError: false;
952
+ isRefetchError: false;
953
+ isSuccess: true;
954
+ isPlaceholderData: true;
955
+ isFetchNextPageError: false;
956
+ isFetchPreviousPageError: false;
957
+ status: "success";
958
+ fetchNextPage: (options?: _tanstack_query_core.FetchNextPageOptions) => Promise<_tanstack_query_core.InfiniteQueryObserverResult<_tanstack_query_core.InfiniteData<CreditHistoryPage, unknown>, Error>>;
959
+ fetchPreviousPage: (options?: _tanstack_query_core.FetchPreviousPageOptions) => Promise<_tanstack_query_core.InfiniteQueryObserverResult<_tanstack_query_core.InfiniteData<CreditHistoryPage, unknown>, Error>>;
960
+ hasNextPage: boolean;
961
+ hasPreviousPage: boolean;
962
+ isFetchingNextPage: boolean;
963
+ isFetchingPreviousPage: boolean;
964
+ dataUpdatedAt: number;
965
+ errorUpdatedAt: number;
966
+ failureCount: number;
967
+ failureReason: Error | null;
968
+ errorUpdateCount: number;
969
+ isFetched: boolean;
970
+ isFetchedAfterMount: boolean;
971
+ isFetching: boolean;
972
+ isInitialLoading: boolean;
973
+ isPaused: boolean;
974
+ isRefetching: boolean;
975
+ isStale: boolean;
976
+ isEnabled: boolean;
977
+ refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<_tanstack_query_core.InfiniteData<CreditHistoryPage, unknown>, Error>>;
978
+ fetchStatus: _tanstack_query_core.FetchStatus;
324
979
  };
980
+ /**
981
+ * The current billing period's usage (`period: "current"`, the default) for `<UsageBreakdown>`,
982
+ * or past periods (`period: "past"`) for `<UsageTrend>`.
983
+ */
984
+ declare function useUsage(options?: {
985
+ period?: "current";
986
+ }): UseQueryResult<CustomerUsageData | null>;
987
+ declare function useUsage(options: {
988
+ period: "past";
989
+ periods?: number;
990
+ }): UseQueryResult<CustomerUsageData[]>;
991
+ /** One of the customer's finalized invoices. */
992
+ interface InvoiceData {
993
+ nozle_id: string;
994
+ number: string;
995
+ issuing_date: string;
996
+ payment_due_date?: string | null;
997
+ payment_status: string;
998
+ payment_overdue?: boolean;
999
+ currency: string;
1000
+ total_amount_cents: number;
1001
+ file_url?: string | null;
1002
+ }
1003
+ interface InvoicePageData {
1004
+ invoices: InvoiceData[];
1005
+ meta: {
1006
+ current_page: number;
1007
+ next_page: number | null;
1008
+ prev_page: number | null;
1009
+ total_pages: number;
1010
+ total_count: number;
1011
+ };
1012
+ }
1013
+ /** The customer's finalized invoices, newest first, 20 per page. */
1014
+ declare function useInvoices(options?: {
1015
+ page?: number;
1016
+ }): UseQueryResult<InvoicePageData, Error>;
1017
+ /**
1018
+ * Returns a function that resolves an invoice's PDF URL, or `null` while Nozle is still generating
1019
+ * the PDF (ask again in a few seconds). Your backend only answers for the customer's own invoices.
1020
+ */
1021
+ declare function useInvoiceDownload(): (invoiceId: string) => Promise<string | null>;
1022
+ /** What changing to `planCode` would cost now and later. Does nothing until a plan is given. */
1023
+ declare function useUpgradePreview(planCode: string | undefined): UseQueryResult<UpgradePreview, Error>;
1024
+ /** Returns a function that reloads every billing hook, for example after checkout or a plan change. */
1025
+ declare function useBillingRefresh(): () => Promise<void>;
325
1026
 
326
1027
  interface UseCheckoutResult$1 {
327
1028
  fetchClientSecret: (planCode: string, returnUrl?: string) => Promise<string | null>;
@@ -331,87 +1032,108 @@ interface UseCheckoutResult$1 {
331
1032
  }
332
1033
  declare function useCheckout$1(): UseCheckoutResult$1;
333
1034
 
334
- interface PricingPlan {
335
- code: string;
336
- name: string;
337
- amount_cents: number;
338
- amount_currency: string;
339
- interval: string;
340
- description?: string;
341
- }
342
1035
  interface PricingTableProps {
343
1036
  currentPlanCode?: string;
1037
+ /** Plans to show instead of fetching the catalog. */
344
1038
  plans?: PricingPlan[];
345
- features?: string[][];
346
- onSelect?: (plan: PricingPlan) => void;
1039
+ /**
1040
+ * Plan families for `plans`. When omitted with `plans`, each plan is its
1041
+ * own card, as with older APIs.
1042
+ */
1043
+ families?: PricingFamily[] | null;
1044
+ /**
1045
+ * Optional. By default each card lists its family's features with values
1046
+ * from the selected plan, or, without families, what the plan gives. Pass
1047
+ * an object keyed by family code or plan code, or an array aligned to the
1048
+ * rendered cards, to replace the lines of a card.
1049
+ */
1050
+ features?: PricingFeatureOverrides;
1051
+ /**
1052
+ * Optional. Orders the plans of a catalog without families. By default
1053
+ * they are sorted by base price, cheapest first, with `contactSalesPlans`
1054
+ * last. Families are ordered by their `pricing_position`.
1055
+ */
1056
+ sort?: (a: PricingPlan, b: PricingPlan) => number;
1057
+ /** Called with the selected interval's plan and its family (null without families). */
1058
+ onSelect?: (plan: PricingPlan, family: PricingFamily | null) => void;
347
1059
  returnUrl?: string;
348
1060
  onStripeClientSecret?: (clientSecret: string) => void;
349
1061
  onCheckoutResult?: (result: CheckoutResult) => void;
350
1062
  onCheckoutError?: (error: Error) => void;
1063
+ /** Show the interval switch when several intervals exist. Defaults to true. */
351
1064
  showToggle?: boolean;
1065
+ /** Interval shown first ("annual" is accepted for "yearly"). Defaults to monthly when offered. */
1066
+ defaultInterval?: PricingInterval | 'annual';
1067
+ /** Family code or plan code to highlight. Overrides the family's `pricing_highlighted`. */
352
1068
  highlightPlan?: string;
1069
+ /**
1070
+ * How the highlighted card stands out: `outline` (default) draws a border in `colorHighlight`;
1071
+ * `filled` paints the card in `colorHighlight` and its text and button in `colorHighlightForeground`.
1072
+ */
1073
+ highlightStyle?: 'outline' | 'filled';
1074
+ /**
1075
+ * Badge on the highlighted card. Replaces the family's `badge_text`; without either it is
1076
+ * "Most Popular". Pass `null` for no badge.
1077
+ */
1078
+ highlightLabel?: string | null;
353
1079
  className?: string;
1080
+ /**
1081
+ * Codes of plans (or plan families) sold on request. Their card shows "Custom" instead of a price
1082
+ * and a "Contact Sales" button, which opens `enterpriseEmail` when set.
1083
+ */
1084
+ contactSalesPlans?: string[];
354
1085
  enterpriseEmail?: string;
1086
+ /** Text next to the Annual option, replacing the computed "Save N%". */
1087
+ annualDiscountLabel?: string;
1088
+ /** Locale for prices and feature values. Defaults to `en-US`. */
1089
+ locale?: string;
1090
+ appearance?: Appearance;
355
1091
  }
356
- declare function PricingTable({ currentPlanCode, plans: propPlans, features, onSelect, returnUrl, onStripeClientSecret, onCheckoutResult, onCheckoutError, showToggle, highlightPlan, className, enterpriseEmail, }: PricingTableProps): React__default.ReactElement;
1092
+ declare function PricingTable({ currentPlanCode, plans: propPlans, families: propFamilies, features, sort, onSelect, returnUrl, onStripeClientSecret, onCheckoutResult, onCheckoutError, showToggle, defaultInterval, highlightPlan, highlightStyle, highlightLabel, className, contactSalesPlans, enterpriseEmail, annualDiscountLabel, locale: localeProp, appearance, }: PricingTableProps): React__default.ReactElement;
357
1093
 
358
1094
  /**
359
1095
  * PlanCard — Individual pricing plan card component.
360
1096
  * UI-01: Shows plan name, price, interval, features list, and CTA button.
361
- * Uses CSS variable theming with --nozle-* namespace.
1097
+ * Themed through `appearance` (see the appearance tokens).
362
1098
  */
363
1099
 
364
- interface Plan {
365
- id: string;
366
- name: string;
367
- monthlyPrice: number;
368
- annualPrice: number;
369
- features: string[];
370
- description?: string;
371
- }
372
- interface PlanCardProps extends Plan {
373
- isAnnual: boolean;
1100
+ interface PlanCardProps {
1101
+ /** A plan from the public catalog. Its price and feature lines are read from it. */
1102
+ plan: PricingPlan;
1103
+ /** Optional. Replaces the lines read from the plan. */
1104
+ features?: string[];
374
1105
  isCurrent: boolean;
375
1106
  returnUrl?: string;
376
1107
  onSelect?: (input: CreateCheckoutInput) => void;
377
- children?: ReactNode;
1108
+ appearance?: Appearance;
378
1109
  }
379
1110
  /**
380
- * PlanCard renders a single pricing plan.
1111
+ * PlanCard renders a single pricing plan from the catalog.
381
1112
  * Highlighted with aria-current="true" when isCurrent=true.
382
1113
  */
383
- declare function PlanCard({ id, name, monthlyPrice, annualPrice, features, description, isAnnual, isCurrent, returnUrl, onSelect, }: PlanCardProps): React__default.ReactElement;
1114
+ declare function PlanCard({ plan, features: featureOverride, isCurrent, returnUrl, onSelect, appearance, }: PlanCardProps): React__default.ReactElement;
384
1115
 
385
1116
  /**
386
1117
  * PlanComparison — Side-by-side feature comparison table.
387
1118
  * UI-01: Renders shadcn-style table with plan names as headers and features as rows.
388
- * Check/cross icons for boolean values. Uses CSS variable theming.
1119
+ * Check/cross icons for boolean values. Themed through `appearance`.
389
1120
  */
390
1121
 
391
- interface ComparisonFeature {
392
- key: string;
393
- label: string;
394
- values: Record<string, string | boolean>;
395
- }
1122
+ type ComparisonFeature = ComparisonRow;
396
1123
  interface PlanComparisonProps {
397
- plans: Plan[];
398
- features: ComparisonFeature[];
1124
+ /** Plans from the public catalog. The rows are built from their entitlements and credit grants. */
1125
+ plans: PricingPlan[];
1126
+ /** Optional. Replaces the rows built from the plans. `values` is keyed by plan code. */
1127
+ features?: ComparisonFeature[];
1128
+ /** Optional. Orders the plans. By default they are sorted by base price, cheapest first. */
1129
+ sort?: (a: PricingPlan, b: PricingPlan) => number;
1130
+ appearance?: Appearance;
399
1131
  }
400
1132
  /**
401
- * PlanComparison renders a side-by-side feature comparison table.
402
- *
403
- * Usage:
404
- * ```tsx
405
- * <PlanComparison
406
- * plans={plans}
407
- * features={[
408
- * { key: 'api_calls', label: 'API Calls', values: { starter: '10K', pro: '100K' } },
409
- * { key: 'analytics', label: 'Analytics', values: { starter: false, pro: true } },
410
- * ]}
411
- * />
412
- * ```
1133
+ * PlanComparison renders a side-by-side comparison of catalog plans. A plan that does not have an
1134
+ * entitlement shows a cross, so the table shows the real difference between plans.
413
1135
  */
414
- declare function PlanComparison({ plans, features, }: PlanComparisonProps): React__default.ReactElement;
1136
+ declare function PlanComparison({ plans: catalogPlans, features: featureOverride, sort, appearance, }: PlanComparisonProps): React__default.ReactElement;
415
1137
 
416
1138
  interface RazorpayActions {
417
1139
  verifyCheckout?: VerifyCheckout;
@@ -449,6 +1171,7 @@ interface CheckoutButtonProps extends Omit<RazorpayActions, "verifyCheckout" | "
449
1171
  returnUrl?: string;
450
1172
  label?: string;
451
1173
  className?: string;
1174
+ appearance?: Appearance;
452
1175
  style?: React__default.CSSProperties;
453
1176
  onError?: (error: Error) => void;
454
1177
  /** @deprecated The server supplies the public Razorpay key in the checkout response. */
@@ -459,7 +1182,7 @@ interface CheckoutButtonProps extends Omit<RazorpayActions, "verifyCheckout" | "
459
1182
  onComplete?: (result: CompletedCheckoutResult) => void;
460
1183
  onScheduled?: (result: ScheduledCheckoutResult) => void;
461
1184
  }
462
- declare function CheckoutButton({ planCode, returnUrl, label, className, style, onError, razorpayKeyId, registerMandate, onProcessing, onDismiss, onStripeClientSecret, onSuccess, onComplete, onScheduled, }: CheckoutButtonProps): React__default.ReactElement;
1185
+ declare function CheckoutButton({ planCode, returnUrl, label, className, style, onError, razorpayKeyId, registerMandate, onProcessing, onDismiss, onStripeClientSecret, onSuccess, onComplete, onScheduled, appearance, }: CheckoutButtonProps): React__default.ReactElement;
463
1186
 
464
1187
  interface StripeCheckoutProps {
465
1188
  /** Stripe PaymentIntent client secret */
@@ -490,6 +1213,8 @@ interface StripeCheckoutProps {
490
1213
  style?: React__default.CSSProperties;
491
1214
  /** Optional custom controls for the PaymentIntent/PaymentElement branch. */
492
1215
  children?: React__default.ReactNode;
1216
+ /** Also passed to Stripe's Payment Element. Stripe's embedded Checkout uses your Stripe branding instead. */
1217
+ appearance?: Appearance;
493
1218
  }
494
1219
  interface UseCheckoutResult {
495
1220
  /** Trigger payment confirmation programmatically */
@@ -512,6 +1237,7 @@ interface ProviderCheckoutProps {
512
1237
  verifyCheckout?: VerifyCheckout;
513
1238
  getCheckoutStatus?: GetCheckoutStatus;
514
1239
  onDismiss?: () => void;
1240
+ appearance?: Appearance;
515
1241
  }
516
1242
  type CheckoutProps = StripeCheckoutProps | ProviderCheckoutProps;
517
1243
  declare function Checkout(props: CheckoutProps): React__default.JSX.Element;
@@ -547,7 +1273,10 @@ interface UpgradeModalProps {
547
1273
  onScheduled?: () => void;
548
1274
  onConfirm?: () => void;
549
1275
  onCancel?: () => void;
1276
+ /** Shows a Back button on the left of the actions, for a step that has a previous step. */
1277
+ onBack?: () => void;
550
1278
  onError?: (error: Error) => void;
1279
+ appearance?: Appearance;
551
1280
  }
552
1281
  declare function UpgradeModal(props: UpgradeModalProps): React__default.ReactElement | null;
553
1282
 
@@ -560,6 +1289,7 @@ interface UpgradeButtonProps {
560
1289
  preview?: ProrationPreview;
561
1290
  label?: string;
562
1291
  className?: string;
1292
+ appearance?: Appearance;
563
1293
  style?: React__default.CSSProperties;
564
1294
  onStripeClientSecret?: (clientSecret: string) => void;
565
1295
  onCheckoutStarted?: () => void;
@@ -567,7 +1297,7 @@ interface UpgradeButtonProps {
567
1297
  onUpgraded?: () => void;
568
1298
  onError?: (error: Error) => void;
569
1299
  }
570
- declare function UpgradeButton({ planCode, returnUrl, subscriptionId, quoteId, idempotencyKey, preview, label, className, style, onStripeClientSecret, onCheckoutStarted, onDowngradeScheduled, onUpgraded, onError, }: UpgradeButtonProps): React__default.ReactElement;
1300
+ declare function UpgradeButton({ planCode, returnUrl, subscriptionId, quoteId, idempotencyKey, preview, label, className, style, onStripeClientSecret, onCheckoutStarted, onDowngradeScheduled, onUpgraded, onError, appearance, }: UpgradeButtonProps): React__default.ReactElement;
571
1301
 
572
1302
  /**
573
1303
  * Presentational entitlement gate. The merchant backend owns entitlement
@@ -647,24 +1377,25 @@ declare function PlanGate({ currentPlan, allowedPlans, fallback, children, }: Pl
647
1377
  /**
648
1378
  * UpgradePrompt — Reusable upgrade message component.
649
1379
  * UI-03: Shows plan name + upgrade button; used as default fallback for LockedOverlay.
650
- * Uses CSS variable theming with --nozle-* namespace.
1380
+ * Themed through `appearance` (see the appearance tokens).
651
1381
  */
652
1382
 
653
1383
  interface UpgradePromptProps {
654
1384
  text?: string;
655
1385
  planName?: string;
656
1386
  onUpgrade?: () => void;
1387
+ appearance?: Appearance;
657
1388
  }
658
1389
  /**
659
1390
  * UpgradePrompt renders an upgrade call-to-action with a message and button.
660
1391
  * Used as default fallback in LockedOverlay and gate components.
661
1392
  */
662
- declare function UpgradePrompt({ text, planName, onUpgrade, }: UpgradePromptProps): React__default.ReactElement;
1393
+ declare function UpgradePrompt({ text, planName, onUpgrade, appearance, }: UpgradePromptProps): React__default.ReactElement;
663
1394
 
664
1395
  /**
665
1396
  * LockedOverlay — Wraps children with a blur filter + upgrade CTA overlay when locked.
666
1397
  * UI-03: Applies CSS blur(4px) to children with an upgrade prompt overlay.
667
- * Uses CSS variable theming with --nozle-* namespace.
1398
+ * Themed through `appearance` (see the appearance tokens).
668
1399
  */
669
1400
 
670
1401
  interface LockedOverlayProps {
@@ -678,6 +1409,7 @@ interface LockedOverlayProps {
678
1409
  onUpgrade?: () => void;
679
1410
  /** Content to blur when locked */
680
1411
  children: ReactNode;
1412
+ appearance?: Appearance;
681
1413
  }
682
1414
  /**
683
1415
  * LockedOverlay wraps children in a relative container.
@@ -694,37 +1426,46 @@ interface LockedOverlayProps {
694
1426
  * </LockedOverlay>
695
1427
  * ```
696
1428
  */
697
- declare function LockedOverlay({ locked, upgradeText, upgradePlanName, onUpgrade, children, }: LockedOverlayProps): React__default.ReactElement;
1429
+ declare function LockedOverlay({ locked, upgradeText, upgradePlanName, onUpgrade, children, appearance, }: LockedOverlayProps): React__default.ReactElement;
698
1430
 
699
- /**
700
- * UsageMeter — embeddable usage progress bar with automatic color thresholds.
701
- * Uses --nozle-* CSS variables for theming (customer-facing portal layer).
702
- *
703
- * Color thresholds:
704
- * < 80% → primary (normal)
705
- * 80-94% → warning (amber)
706
- * ≥ 95% → destructive (red)
707
- */
708
1431
  declare function getUsageMeterColor(percentage: number): string;
709
1432
  interface UsageMeterProps {
710
1433
  used: number;
711
- limit: number;
1434
+ /** `null` or `undefined` means the feature has no limit. */
1435
+ limit?: number | null;
712
1436
  label?: string;
713
1437
  showText?: boolean;
1438
+ appearance?: Appearance;
714
1439
  }
715
- declare function UsageMeter({ used, limit, label, showText, }: UsageMeterProps): React.JSX.Element;
1440
+ declare function UsageMeter({ used, limit, label, showText, appearance, }: UsageMeterProps): React.JSX.Element;
716
1441
 
717
1442
  interface UsageDashboardFeature {
718
1443
  key: string;
719
1444
  label: string;
720
1445
  used: number;
721
- limit: number;
1446
+ /** `null` or `undefined` means the feature has no limit. */
1447
+ limit?: number | null;
722
1448
  }
1449
+ /** The `can()` result fields the dashboard needs. */
1450
+ interface UsageResult {
1451
+ used: number;
1452
+ limit?: number | null;
1453
+ }
1454
+ /**
1455
+ * Joins a plan's metered entitlements (names come from the catalog) with the usage results you read
1456
+ * on your backend, keyed by feature code. Entitlements without a result are left out.
1457
+ */
1458
+ declare function usageItems(entitlements: CatalogEntitlement[], results: Record<string, UsageResult | undefined>): UsageDashboardFeature[];
723
1459
  interface UsageDashboardProps {
724
1460
  features?: UsageDashboardFeature[];
725
1461
  loading?: boolean;
1462
+ /** Shown in place of the meters when set. */
1463
+ error?: Error | string | null;
1464
+ /** Shown when there are no features. */
1465
+ emptyMessage?: string;
1466
+ appearance?: Appearance;
726
1467
  }
727
- declare function UsageDashboard({ features, loading, }: UsageDashboardProps): React.JSX.Element;
1468
+ declare function UsageDashboard({ features, loading, error, emptyMessage, appearance, }: UsageDashboardProps): React.JSX.Element;
728
1469
 
729
1470
  interface UsageAlertFeature {
730
1471
  key: string;
@@ -735,8 +1476,42 @@ interface UsageAlertProps {
735
1476
  features: UsageAlertFeature[];
736
1477
  threshold?: number;
737
1478
  upgradeHref?: string;
1479
+ appearance?: Appearance;
738
1480
  }
739
- declare function UsageAlert({ features, threshold, upgradeHref, }: UsageAlertProps): React.JSX.Element | null;
1481
+ declare function UsageAlert({ features, threshold, upgradeHref, appearance, }: UsageAlertProps): React.JSX.Element | null;
1482
+
1483
+ interface CurrentPlanDetail {
1484
+ label: string;
1485
+ value: ReactNode;
1486
+ }
1487
+ interface CurrentPlanProps {
1488
+ /** The `useSubscription` result. Omit it to read it through `billingEndpoint`. */
1489
+ subscription?: BillingSubscription | null;
1490
+ /** Meters to show. Omit to build them from the plan's metered limits and this period's usage. */
1491
+ usage?: UsageDashboardFeature[];
1492
+ /** Extra label and value rows, for example included events or a renewal date. */
1493
+ details?: CurrentPlanDetail[];
1494
+ /** Buttons for the header, for example a link to your billing portal. */
1495
+ actions?: ReactNode;
1496
+ /** Text of the notice shown when the customer is past due. */
1497
+ pastDueMessage?: string;
1498
+ /** A meter at or above this percentage shows a notice. Default 80; `null` turns notices off. */
1499
+ warningPercent?: number | null;
1500
+ title?: string;
1501
+ isLoading?: boolean;
1502
+ error?: Error | string | null;
1503
+ emptyMessage?: string;
1504
+ locale?: string;
1505
+ appearance?: Appearance;
1506
+ }
1507
+ /** Meters from the plan's metered limits joined with this period's units, by feature code. */
1508
+ declare function currentPlanMeters(entitlements: {
1509
+ feature_type: string;
1510
+ code: string;
1511
+ name: string;
1512
+ usage_limit?: number | null;
1513
+ }[] | undefined, usage: CustomerUsageData | null | undefined): UsageDashboardFeature[];
1514
+ declare function CurrentPlan(props: CurrentPlanProps): React__default.ReactElement;
740
1515
 
741
1516
  /**
742
1517
  * PlanBadge — simple badge displaying plan name with tier-based coloring.
@@ -745,13 +1520,10 @@ declare function UsageAlert({ features, threshold, upgradeHref, }: UsageAlertPro
745
1520
  interface PlanBadgeProps {
746
1521
  plan: string;
747
1522
  tier?: "free" | "starter" | "pro" | "enterprise";
1523
+ appearance?: Appearance;
748
1524
  }
749
- declare function PlanBadge({ plan, tier }: PlanBadgeProps): React__default.JSX.Element;
1525
+ declare function PlanBadge({ plan, tier, appearance }: PlanBadgeProps): React__default.JSX.Element;
750
1526
 
751
- /**
752
- * PaymentMethodDisplay — shows saved payment method details.
753
- * Displays last4, brand, expiry. "Update Payment Method" button opens checkout.
754
- */
755
1527
  interface PaymentMethod {
756
1528
  last4: string;
757
1529
  brand: string;
@@ -762,7 +1534,33 @@ interface PaymentMethodDisplayProps {
762
1534
  paymentMethod?: PaymentMethod;
763
1535
  onUpdatePaymentMethod?: () => void;
764
1536
  updateHref?: string;
1537
+ appearance?: Appearance;
1538
+ }
1539
+ declare function PaymentMethodDisplay({ paymentMethod, onUpdatePaymentMethod, updateHref, appearance, }: PaymentMethodDisplayProps): React.JSX.Element;
1540
+
1541
+ interface UsageBreakdownProps {
1542
+ /** The `customer_usage` object from Core's `current_usage`, read on your backend. */
1543
+ usage?: CustomerUsageData | null;
1544
+ isLoading?: boolean;
1545
+ error?: Error | string | null;
1546
+ emptyMessage?: string;
1547
+ appearance?: Appearance;
1548
+ }
1549
+ declare function UsageBreakdown({ usage, isLoading, error, emptyMessage, appearance, }: UsageBreakdownProps): React__default.ReactElement;
1550
+
1551
+ interface UsageTrendProps {
1552
+ /** The `usage_periods` of Core's `past_usage`, read on your backend, in any order. */
1553
+ periods?: CustomerUsageData[] | null;
1554
+ /**
1555
+ * Chart the units of this feature code in each period instead of the amount. Periods without the
1556
+ * feature show zero.
1557
+ */
1558
+ featureCode?: string;
1559
+ isLoading?: boolean;
1560
+ error?: Error | string | null;
1561
+ emptyMessage?: string;
1562
+ appearance?: Appearance;
765
1563
  }
766
- declare function PaymentMethodDisplay({ paymentMethod, onUpdatePaymentMethod, updateHref, }: PaymentMethodDisplayProps): React.JSX.Element;
1564
+ declare function UsageTrend({ periods, featureCode, isLoading, error, emptyMessage, appearance, }: UsageTrendProps): React__default.ReactElement;
767
1565
 
768
- export { BillingContext, type BillingContextValue, BillingPortal, BillingPortalError, type BillingPortalProps, type BillingPortalSession, BillingProvider, type BillingProviderProps, type CancellationActions, type CancellationApplyInput, CancellationControl, type CancellationControlProps, type CancellationInput, type CancellationOperation, type CancellationPreview, type CancellationSubscription, type Plan$1 as CatalogPlan, Checkout, CheckoutButton, type CheckoutButtonProps, type CheckoutProps, type CheckoutResult, type CheckoutStatus, type CheckoutSubscriptionResult, type ComparisonFeature, type CompletedCheckoutResult, type CreateBillingPortalSession, type CreateCheckout, type CreateCheckoutInput, FeatureGate, type FeatureGateProps, type GetCheckoutStatus, type HostedCheckoutResult, LockedOverlay, type LockedOverlayProps, type NozleClient, type PaymentMethod, PaymentMethodDisplay, type PaymentMethodDisplayProps, type Plan, PlanBadge, type PlanBadgeProps, PlanCard, type PlanCardProps, type PlanChangeActions, type PlanChangeApplyInput, PlanChangeControl, type PlanChangeControlProps, type PlanChangeInput, type PlanChangeOperation, type PlanChangePreview, type PlanChangePreviewInput, type PlanChangeState, type PlanChangeWithdrawInput, PlanComparison, type PlanComparisonProps, PlanGate, type PlanGateProps, type PortalPlan, type PricingPlan, PricingTable, type PricingTableProps, type ProcessingCheckoutResult, type ProrationPreview, type RazorpayCheckoutResult, type RazorpayVerification, type ScheduledCheckoutResult, UpgradeButton, type UpgradeButtonProps, UpgradeModal, type UpgradeModalProps, UpgradePrompt, type UpgradePromptProps, UsageAlert, type UsageAlertFeature, type UsageAlertProps, UsageDashboard, type UsageDashboardFeature, type UsageDashboardProps, UsageGate, type UsageGateProps, UsageMeter, type UsageMeterProps, type UseCheckoutResult, type UseCheckoutResult$1 as UseCheckoutSessionResult, type VerifyCheckout, getUsageMeterColor, useBillingContext, useCheckout, useCheckout$1 as useCheckoutSession, useNozleClient, useOptionalBillingContext, usePlans };
1566
+ export { Appearance, BillingContext, type BillingContextValue, type BillingFetch, BillingPortal, BillingPortalError, type BillingPortalProps, type BillingPortalSession, BillingProvider, type BillingProviderProps, BillingRequestError, type BillingSubscription, type CancellationActions, type CancellationApplyInput, CancellationControl, type CancellationControlProps, type CancellationInput, type CancellationOperation, type CancellationPreview, type CancellationSubscription, type CatalogCharge, type CatalogCreditGrantRule, type CatalogEntitlement, type Plan as CatalogPlan, type CatalogPrivilege, type ChargeUsageData, Checkout, CheckoutButton, type CheckoutButtonProps, type CheckoutProps, type CheckoutResult, type CheckoutStatus, type CheckoutSubscriptionResult, type ComparisonFeature, type ComparisonRow, type CompletedCheckoutResult, type CreateBillingPortalSession, type CreateCheckout, type CreateCheckoutInput, CreditBalance, type CreditBalanceData, type CreditBalanceProps, type CreditBalanceSource, CreditHistory, type CreditHistoryProps, type CreditOperationData, CurrentPlan, type CurrentPlanDetail, type CurrentPlanProps, type CustomerUsageData, ElementKey, type ElementProps, type EntitlementResult, FeatureGate, type FeatureGateProps, type GetCheckoutStatus, type GetPricingCardsOptions, type HostedCheckoutResult, type InvoiceData, type InvoicePageData, LockedOverlay, type LockedOverlayProps, type NozleClient, type PaymentMethod, PaymentMethodDisplay, type PaymentMethodDisplayProps, PlanBadge, type PlanBadgeProps, PlanCard, type PlanCardProps, type PlanChangeActions, type PlanChangeApplyInput, PlanChangeControl, type PlanChangeControlProps, type PlanChangeInput, type PlanChangeOperation, type PlanChangePreview, type PlanChangePreviewInput, type PlanChangeState, type PlanChangeWithdrawInput, PlanComparison, type PlanComparisonProps, PlanGate, type PlanGateProps, type PortalPlan, PoweredByNozle, type PricingCard, type PricingCatalog, type PricingEntitlement, type PricingFamily, type PricingFamilyFeature, type PricingFeature, type PricingFeatureOverrides, type PricingInterval, type PricingIntervalOption, type PricingPlan, type PricingPrivilege, PricingTable, type PricingTableProps, type ProcessingCheckoutResult, type ProrationPreview, type RazorpayCheckoutResult, type RazorpayVerification, type ScheduledCheckoutResult, UpgradeButton, type UpgradeButtonProps, UpgradeModal, type UpgradeModalProps, type UpgradePreview, UpgradePrompt, type UpgradePromptProps, UsageAlert, type UsageAlertFeature, type UsageAlertProps, UsageBreakdown, type UsageBreakdownProps, UsageDashboard, type UsageDashboardFeature, type UsageDashboardProps, UsageGate, type UsageGateProps, UsageMeter, type UsageMeterProps, type UsageResult, UsageTrend, type UsageTrendProps, type UseAppearance, type UseCheckoutResult, type UseCheckoutResult$1 as UseCheckoutSessionResult, type VerifyCheckout, comparisonRows, currentPlanMeters, getAvailableIntervals, getDefaultInterval, getPricingCards, getPricingIntervalOptions, getUsageMeterColor, planFeatures, sortPlansByPrice, usageItems, useAppearance, useBillingContext, useBillingRefresh, useCheckout, useCheckout$1 as useCheckoutSession, useCreditBalance, useCreditHistory, useEntitlement, useInvoiceDownload, useInvoices, useNozleBranding, useNozleClient, useOptionalBillingContext, usePlans, useSubscription, useUpgradePreview, useUsage };