@revenuecat/purchases-ui-js
Version:
Web components for Paywalls. Powered by RevenueCat
51 lines (50 loc) • 2.52 kB
TypeScript
import type { PurchaseButtonMethod } from "./components/purchase-button";
interface ComponentInteractionBase<TType extends string, TValue extends string = string> {
componentType: TType;
componentName?: string;
componentValue: TValue;
}
interface IndexedTransition {
originIndex: number;
destinationIndex: number;
originContextName?: string;
destinationContextName?: string;
defaultIndex: number;
}
interface PackageTransition {
originPackageId?: string;
destinationPackageId: string;
defaultPackageId?: string;
}
type ButtonInteractionValue = "workflow" | "navigate_to_url" | "navigate_back" | "close_workflow" | "restore_purchases" | "navigate_to_customer_center" | "screen_redirect" | "navigate_to_privacy_policy" | "navigate_to_terms" | "navigate_to_sheet" | "navigate_to_offer_code" | "navigate_to_web_paywall_link";
export type TabInteractionData = ComponentInteractionBase<"tab"> & IndexedTransition;
export type SwitchInteractionData = ComponentInteractionBase<"switch", "on" | "off">;
export type CarouselInteractionData = ComponentInteractionBase<"carousel"> & IndexedTransition;
export type ButtonInteractionData = ComponentInteractionBase<"button", ButtonInteractionValue> & {
componentURL?: string;
};
export type TextInteractionData = ComponentInteractionBase<"text", "navigate_to_url"> & {
componentURL: string;
};
export type PackageInteractionData = ComponentInteractionBase<"package"> & PackageTransition & {
originProductId?: string;
destinationProductId?: string;
defaultProductId?: string;
};
export type PurchaseButtonInteractionData = ComponentInteractionBase<"purchase_button", PurchaseButtonMethod["type"]> & {
componentURL?: string;
currentPackageId: string;
currentProductId?: string;
resultingPackageId?: string;
resultingProductId?: string;
};
export type PackageSelectionSheetInteractionData = ComponentInteractionBase<"package_selection_sheet"> & {
currentPackageId?: string;
resultingPackageId?: string;
currentProductId?: string;
resultingProductId?: string;
};
export type ComponentInteractionData = TabInteractionData | SwitchInteractionData | CarouselInteractionData | ButtonInteractionData | TextInteractionData | PackageInteractionData | PurchaseButtonInteractionData | PackageSelectionSheetInteractionData;
export type ComponentInteractionType = ComponentInteractionData["componentType"];
export type OnComponentInteraction = (data: ComponentInteractionData) => void;
export {};