UNPKG

@revenuecat/purchases-ui-js

Version:

Web components for Paywalls. Powered by RevenueCat

30 lines (29 loc) 2 kB
import { type ActionsProps, type ComponentLocalizations, type ComponentState, type Extra, type PaywallComponent, type PurchaseStateProps, type SupportedActions } from "../../data/entities"; import type { VariableDictionary } from "../../utils/variable-utils"; import type { ZStackChildStyles } from "../stack/stack-utils"; import TextNode from "../text/TextNode.svelte"; import { Footer, Image, Package, PurchaseButton, Stack, Timeline } from "../.."; import ButtonNode from "../button/ButtonNode.svelte"; import type { Component } from "svelte"; type SupportedComponents = TextNode | Stack | Image | ButtonNode | PurchaseButton | Package | Footer | Timeline; interface Props extends ActionsProps, PurchaseStateProps { nodeData: PaywallComponent; labels: ComponentLocalizations; onAction?: (action: SupportedActions, data?: Extra) => void; variableDictionary?: VariableDictionary; zStackChildStyles?: ZStackChildStyles; componentState?: ComponentState; } declare const Node: Component<Props, { /** * This function returns the component class and the node data for a given paywall component. * It first checks if the component type is supported and returns the corresponding component class. * If not supported, it checks if the fallback component type is supported and returns the corresponding component class, * finally it throws an error if the component type is not supported and the fallback component type is not supported. * @param nodeData:PaywallComponent - the PaywallComponent object representing a Node in the paywall * @returns [Component<SupportedComponents>, PaywallComponent] - a tuple containing the component class and the node data * @throws Error - if the component type and the fallback component type are not supported */ getComponentClass: (nodeData: PaywallComponent) => [Component<SupportedComponents>, PaywallComponent]; }, "">; type Node = ReturnType<typeof Node>; export default Node;