UNPKG

@polls-platform/web

Version:

Polls Platform SDK

532 lines (528 loc) 15.5 kB
// Generated by dts-bundle-generator v6.13.0 import { AnalyticsEvent, OpenPollFlow, OptionRequest, PollState, PostVoteActionMap, Theme } from '@polls-platform/core'; import { DynamicPollTheme } from '@polls-platform/core/built/internal'; import React from 'react'; import { CSSProperties, ReactElement } from 'react'; /** * Props for `init`, a shorthand initializer for customers with hard-coded configs * @deprecated please use `initializePolls` * @category 1. Initialization */ export interface InitProps { apiKey: string; } /** * This is shorthand initializer for customers with hard-coded configs * @deprecated please use `initializePolls` * @category 1. Initialization * @param apiKey */ export declare function init({ apiKey }: InitProps): void; export declare enum PollOptionSource { shopifyCart = "shopifyCart", swymDefaultWishList = "swymDefaultWishList" } export type GetPollOptionsFunction = () => OptionRequest[] | Promise<OptionRequest[]>; export interface CreatePollProps { pollOptionSource: PollOptionSource | GetPollOptionsFunction; pollSettings: { multipleVotes: boolean; postVoteActionMap?: PostVoteActionMap; }; pollTitle: string; pollOwnerId: string; pollState: PollState; } /** @internal */ export declare const ShopifyCartItem: z.ZodObject<{ id: z.ZodNumber; url: z.ZodString; title: z.ZodString; image: z.ZodString; price: z.ZodNullable<z.ZodOptional<z.ZodNumber>>; vendor: z.ZodNullable<z.ZodOptional<z.ZodString>>; variant_title: z.ZodNullable<z.ZodOptional<z.ZodString>>; product_type: z.ZodNullable<z.ZodOptional<z.ZodString>>; product_description: z.ZodNullable<z.ZodOptional<z.ZodString>>; sku: z.ZodNullable<z.ZodOptional<z.ZodString>>; }, "strip", z.ZodTypeAny, { price?: number | null | undefined; vendor?: string | null | undefined; variant_title?: string | null | undefined; product_type?: string | null | undefined; product_description?: string | null | undefined; sku?: string | null | undefined; id: number; url: string; title: string; image: string; }, { price?: number | null | undefined; vendor?: string | null | undefined; variant_title?: string | null | undefined; product_type?: string | null | undefined; product_description?: string | null | undefined; sku?: string | null | undefined; id: number; url: string; title: string; image: string; }>; /** @internal */ export type ShopifyCartItem = z.infer<typeof ShopifyCartItem>; /** @internal */ export declare const ShopifyCartItemList: z.ZodArray<z.ZodObject<{ id: z.ZodNumber; url: z.ZodString; title: z.ZodString; image: z.ZodString; price: z.ZodNullable<z.ZodOptional<z.ZodNumber>>; vendor: z.ZodNullable<z.ZodOptional<z.ZodString>>; variant_title: z.ZodNullable<z.ZodOptional<z.ZodString>>; product_type: z.ZodNullable<z.ZodOptional<z.ZodString>>; product_description: z.ZodNullable<z.ZodOptional<z.ZodString>>; sku: z.ZodNullable<z.ZodOptional<z.ZodString>>; }, "strip", z.ZodTypeAny, { price?: number | null | undefined; vendor?: string | null | undefined; variant_title?: string | null | undefined; product_type?: string | null | undefined; product_description?: string | null | undefined; sku?: string | null | undefined; id: number; url: string; title: string; image: string; }, { price?: number | null | undefined; vendor?: string | null | undefined; variant_title?: string | null | undefined; product_type?: string | null | undefined; product_description?: string | null | undefined; sku?: string | null | undefined; id: number; url: string; title: string; image: string; }>, "many">; /** @internal */ export type ShopifyCartItemList = z.infer<typeof ShopifyCartItemList>; /** @internal */ export declare const ShopifyCartResponse: z.ZodObject<{ items: z.ZodArray<z.ZodObject<{ id: z.ZodNumber; url: z.ZodString; title: z.ZodString; image: z.ZodString; price: z.ZodNullable<z.ZodOptional<z.ZodNumber>>; vendor: z.ZodNullable<z.ZodOptional<z.ZodString>>; variant_title: z.ZodNullable<z.ZodOptional<z.ZodString>>; product_type: z.ZodNullable<z.ZodOptional<z.ZodString>>; product_description: z.ZodNullable<z.ZodOptional<z.ZodString>>; sku: z.ZodNullable<z.ZodOptional<z.ZodString>>; }, "strip", z.ZodTypeAny, { price?: number | null | undefined; vendor?: string | null | undefined; variant_title?: string | null | undefined; product_type?: string | null | undefined; product_description?: string | null | undefined; sku?: string | null | undefined; id: number; url: string; title: string; image: string; }, { price?: number | null | undefined; vendor?: string | null | undefined; variant_title?: string | null | undefined; product_type?: string | null | undefined; product_description?: string | null | undefined; sku?: string | null | undefined; id: number; url: string; title: string; image: string; }>, "many">; }, "strip", z.ZodTypeAny, { items: { price?: number | null | undefined; vendor?: string | null | undefined; variant_title?: string | null | undefined; product_type?: string | null | undefined; product_description?: string | null | undefined; sku?: string | null | undefined; id: number; url: string; title: string; image: string; }[]; }, { items: { price?: number | null | undefined; vendor?: string | null | undefined; variant_title?: string | null | undefined; product_type?: string | null | undefined; product_description?: string | null | undefined; sku?: string | null | undefined; id: number; url: string; title: string; image: string; }[]; }>; /** @internal */ export type ShopifyCartResponse = z.infer<typeof ShopifyCartResponse>; /** @internal */ export declare const ShopifyProduct: z.ZodObject<{ id: z.ZodNumber; title: z.ZodString; images: z.ZodArray<z.ZodObject<{ src: z.ZodString; }, "strip", z.ZodTypeAny, { src: string; }, { src: string; }>, "many">; body_html: z.ZodString; handle: z.ZodString; }, "strip", z.ZodTypeAny, { id: number; title: string; images: { src: string; }[]; body_html: string; handle: string; }, { id: number; title: string; images: { src: string; }[]; body_html: string; handle: string; }>; export type ShopifyProduct = z.infer<typeof ShopifyProduct>; export declare enum CornerRounding { square = "square", light = "light", heavy = "heavy" } /** * CSS in JS font styles */ export interface FontStyle { fontFamily?: string; fontSize?: string; fontWeight?: string; letterSpacing?: string; } export interface LoadingViewProps { isVisible: boolean; title: string; imageUrl: string; theme: Theme; fontStyles?: { default?: FontStyle; titleFont?: FontStyle; }; } export declare const LoadingView: React.FC<LoadingViewProps>; /** @internal */ export declare enum MobileModalStyle { fullScreen = "fullScreen", drawer = "drawer" } /** @internal */ export interface ModalProps { didCompleteExitAnimation?: () => void; mobileModalStyle?: MobileModalStyle; children: ReactElement<{ closeModal: () => void; }, any>; } /** @internal */ export interface ModalContentProps { closeModal?: () => void; } /** @internal */ export declare const Modal: React.FC<ModalProps>; /** * Props to pass to the `PollButton` component * @category 4. PollButton */ export interface PollButtonProps { containerStyle?: CSSProperties; appearance: { colors: { backgroundColor: string; titleTextColor: string; subtitleTextColor: string; buttonBackgroundColor: string; buttonTextColor: string; }; text: { titleText: string; subtitleText: string; buttonText: string; }; fontStyles?: { titleFont?: FontStyle; subtitleFont?: FontStyle; buttonFont?: FontStyle; }; cornerRounding: CornerRounding; justifyContent?: CSSProperties["justifyContent"]; }; layout: { fullWidth: boolean; }; createPollProps: CreatePollProps; howItWorksAppearance?: HowItWorksAppearance; pollViewAppearance?: PollViewAppearance; shouldShowLoading?: boolean; } export declare enum ResponsiveSize { desktop = "desktop", tablet = "tablet", mobile = "mobile" } export declare const PollButton: React.FC<PollButtonProps>; /** * Appearance controls for the poll view */ export interface PollViewAppearance { /** * Controls the appearance of the loading screen when creating/opening a poll * default: light */ theme?: Theme; /** * Font style overrides */ fontStyles?: { /** * Default font styles to be applied everywhere, unless overridden by more specific font styles below */ default?: FontStyle; /** * Font style for the title text on the poll loading screen */ loadingTitleFont?: FontStyle; }; } /** * Props to pass the `PollView` Component * @category 3. PollView */ export interface PollViewProps { /** * styles to be applied to the outer most component of the PollView. * styles will be merged by overriding default styles */ style?: CSSProperties; /** * The poll source can be either a Poll ID or Poll URL * When creating a poll with the `createPoll` or `createPollAsync` functions * the url returned by those functions can be passed directly to this prop. * This prop is also used when opening an existing poll. */ pollSource: string; /** * The `PollView` component is used for both creating polls and opening polls. * This property is used to determine which flow the user is in */ openPollFlow: OpenPollFlow; /** * @deprecated please use the appearance prop instead * Controls the appearance of the loading screen when creating/opening a poll * default: light */ theme?: Theme; /** * Appearance controls for the poll view */ appearance?: PollViewAppearance; /** * This callback forwards analytics events that occur within the poll. * For more information, go to https://docs.pollsplatform.com/analytics * Analytics can be forwarded to your own data warehouse such as Google Analytics. */ didReceiveAnalyticsEvent?: (event: AnalyticsEvent) => void; } /** * The `PollView` component is used for both creating and opening polls. * For more information, go to https://docs.pollsplatform.com/react. * Before navigating the user to this screen, you must have a poll URL. * You can create a poll using the `createPoll` and `createPollAsync` functions * which will respond with a URL that can be passed here. * Or if you already have the URL of an existing poll you can pass it * @category 3. PollView */ export declare const PollView: React.FC<PollViewProps>; export interface HowItWorksAppearance { theme?: Theme; primaryColor?: string; cornerRounding?: CornerRounding; } export interface HowItWorksProps { appearance?: HowItWorksAppearance; didPressClose?: () => void; } export declare function HowItWorks(props: HowItWorksProps): JSX.Element; export declare enum Corner { topLeft = "topLeft", topRight = "topRight", bottomRight = "bottomRight", bottomLeft = "bottomLeft" } export interface PollOverlayProps { appearance: { colors: { primaryColor: string; backgroundColor: string; iconColor: string; titleTextColor: string; subtitleTextColor: string; }; text: { titleText: string; subtitleText: string; }; cornerRounding: CornerRounding; }; position: { corner: Corner; horizontalMargin: number; verticalMargin: number; }; createPollProps: CreatePollProps; overlayMode: OverlayMode; pollViewAppearance?: PollViewAppearance; howItWorksAppearance?: HowItWorksAppearance; isPreviewMode?: boolean; isEnabledOnMobile?: boolean; } export declare enum OverlayMode { compact = "compact", expanded = "expanded", auto = "auto" } export declare const PollOverlay: React.FC<PollOverlayProps>; /** @internal */ export interface ToolTipProps { appearance: { colors: { backgroundColor: string; titleTextColor: string; subtitleTextColor: string; buttonBackgroundColor: string; buttonTextColor: string; }; text: { titleText: string; subtitleText: string; buttonText: string; }; fontStyles?: { titleFont?: FontStyle; subtitleFont?: FontStyle; buttonFont?: FontStyle; }; cornerRounding: CornerRounding; }; onDismiss: () => void; } /** @internal */ export declare const ToolTip: React.FC<ToolTipProps>; export interface FadeInImageProps { src: string; alt: string; className?: string; } export declare const FadeInImage: React.FC<FadeInImageProps>; /** * Props for `injectPollButton` * @category 4. PollButton */ export interface InjectPollButtonProps { /** * Props to be passed to the underlying `PollButton`, see `PollButtonProps` for details. */ createPollButtonProps: PollButtonProps; /** * The ID of the existing element on the DOM in which you would like to inject the poll button */ domTargetNodeId: string; /** * The CSS Properties of the container that will hold the poll button */ containerStyle?: Partial<CSSStyleDeclaration>; } /** * This function injects a poll button into a given element in the DOM. * This is intended to be used by projects that do not use React. * If you use React, consider using the <PollButton> component. * @category 4. PollButton * @param InjectPollButtonProps */ export declare function injectPollButton({ createPollButtonProps, domTargetNodeId, containerStyle }: InjectPollButtonProps): void; export interface InjectPollOverlayProps { pollOverlayProps: PollOverlayProps; domTargetNodeId?: string; } export declare function injectPollOverlay({ pollOverlayProps, domTargetNodeId }: InjectPollOverlayProps): void; /** * Props for `openPoll` * @category 3. PollView */ export interface OpenPollProps { /** * Props to be passed to the underlying `PollView`, see `PollViewProps` for details. */ pollViewProps: PollViewProps; /** * The node in the DOM in which you'd like the poll to be presented. * This should typically be the document.body (which is the default) * Note that scrolling will temporarily be disabled while the poll is open. */ domTargetNode?: Node; /** * The function to be called when the user closes the poll */ onClose?: () => void; } /** * This function opens a newly created or existing poll. * The background of the target node will be darkened and the poll * will be presented in a modal view with animation. * When the user dismisses the modal, it will dismiss with animation * and all injected elements will be cleaned up from the DOM. * This is intended to be used by projects that do not use React. * If you use React, consider using the <PollView> component. * @category 3. PollView * @param OpenPollProps */ export declare function openPoll({ pollViewProps, domTargetNode, onClose }: OpenPollProps): void; export interface InitShopifyConfig { apiKey: string; storeId: string; storeUrl: string; } export interface InitShopifyProps { config: InitShopifyConfig; dynamicPollTheme: DynamicPollTheme; howItWorksAppearance: HowItWorksAppearance; pollViewAppearance: PollViewAppearance; injectPollOverlayProps?: InjectPollOverlayProps; shouldVerifyAccountStatus?: boolean; } export declare function initShopify({ config, dynamicPollTheme, howItWorksAppearance, pollViewAppearance, injectPollOverlayProps, shouldVerifyAccountStatus, }: InitShopifyProps): void; export interface OpenHowItWorksModalProps { domTargetNode?: Node; howItWorksProps: HowItWorksProps; onClose?: () => void; } export declare function openHowItWorksModal({ domTargetNode, howItWorksProps, onClose, }: OpenHowItWorksModalProps): void; export * from "@polls-platform/core/built/internal"; export {};