UNPKG

@shopify/app-bridge

Version:

[![Build Status](https://travis-ci.com/Shopify/app-bridge.svg?token=RBRyvqQyN525bnfz7J8p&branch=master)](https://travis-ci.com/Shopify/app-bridge) [![codecov](https://codecov.io/gh/Shopify/app-bridge/branch/master/graph/badge.svg?token=nZ21m39Dr6)](https:

93 lines (92 loc) 4.57 kB
/** * @module Modal */ import { ClientApplication } from '../../client'; import { ActionSetWithChildren } from '../helper'; import { ActionSetProps, ClickAction, Group, MetaAction } from '../types'; import { Button, Payload as ButtonPayload } from '../Button'; import { ErrorAction } from '../Error'; import { Action, ActionType, ClosePayload, Footer, FooterOptions, IframeOptions, IframePayload, MessageOptions, MessagePayload, Size } from './types'; export declare const GROUP: Group; export interface ActionBase extends MetaAction { readonly group: typeof GROUP; } export interface OpenAction extends ActionBase { readonly type: typeof ActionType.OPEN; readonly payload: MessagePayload | IframePayload; } export declare type UpdateAction = OpenAction; export interface CloseAction extends ActionBase { readonly type: typeof ActionType.CLOSE; } export declare type ModalAction = OpenAction | UpdateAction | CloseAction | MetaAction; export declare function openModal(modalPayload: MessagePayload | IframePayload): OpenAction; export declare function closeModal(modalClosePayload: ClosePayload): CloseAction; export declare function clickFooterButton(id: string, payload?: any): ClickAction; export declare function update(payload: MessagePayload | IframePayload): UpdateAction; export declare function isValidSrc(options: Partial<IframeOptions | IframePayload>, localOrigin?: string): boolean; export declare function validationError(action: OpenAction | UpdateAction | CloseAction | ClickAction | MetaAction, localOrigin?: string): undefined | ErrorAction; export declare function isValidModalProps(props: (MessageOptions | IframeOptions) | (MessagePayload | IframePayload) | undefined, localOrigin?: string): boolean; export declare function isValidModalFooter(footer?: Footer): boolean; export declare function isValidModalSize(size?: string): boolean; export declare function isIframeModal(options: MessagePayload | IframePayload | object): options is IframePayload; export declare function isMessageModal(options: MessagePayload | IframePayload | object): options is MessagePayload; export declare abstract class Modal extends ActionSetWithChildren { title?: string; size: Size; footerPrimary?: ButtonPayload; footerPrimaryOptions?: Button; footerSecondary?: ButtonPayload[]; footerSecondaryOptions?: Button[]; readonly footer: Footer | undefined; readonly footerOptions: FooterOptions | undefined; protected close(): void; protected setFooterPrimaryButton(newOptions: Button | undefined, updateCb: () => void): void; protected setFooterSecondaryButtons(newOptions: Button[] | undefined, updateCb: () => void): void; protected getChildButton(newAction: undefined | Button, currentAction: undefined | Button): Button | undefined; protected updatePrimaryFooterButton(newPayload: ButtonPayload, updateCb: () => void): void; protected updateSecondaryFooterButton(newPayload: ButtonPayload, updateCb: () => void): void; protected validateOptions(options: MessageOptions | IframeOptions): boolean; } export declare class ModalMessage extends Modal implements ActionSetProps<MessageOptions, MessagePayload> { message: string; constructor(app: ClientApplication<any>, options: MessageOptions); readonly payload: { footer: Footer | undefined; id: string; message: string; size: Size; title: string | undefined; }; readonly options: { footer: FooterOptions | undefined; message: string; size: Size; title: string | undefined; }; set(options: Partial<MessageOptions>, shouldUpdate?: boolean): this; dispatch(action: Action): this; } export declare class ModalIframe extends Modal implements ActionSetProps<IframeOptions, IframePayload> { url?: string; path?: string; constructor(app: ClientApplication<any>, options: IframeOptions); readonly payload: { footer: Footer | undefined; id: string; path: string | undefined; size: Size; title: string | undefined; url: string | undefined; }; readonly options: { footer: FooterOptions | undefined; path: string | undefined; size: Size; title: string | undefined; url: string | undefined; }; set(options: Partial<IframeOptions>, shouldUpdate?: boolean): this; dispatch(action: Action): this; } export declare const create: (app: ClientApplication<any>, options: MessageOptions | IframeOptions) => ModalMessage | ModalIframe;