@shopify/app-bridge
Version:
[](https://travis-ci.com/Shopify/app-bridge) [](https:
63 lines (62 loc) • 2.58 kB
TypeScript
/**
* @module ResourcePicker
*/
import { ClientApplication } from '../../client';
import { ErrorAction } from '../Error';
import { ActionSet } from '../helper';
import { ActionSetProps, Group, MetaAction } from '../types';
import { Action, ActionType, BaseOptions, ClosePayload, Options, Payload, ResourceSelection, ResourceType, SelectPayload } from './types';
export declare const GROUP: Group;
export interface ActionBase extends MetaAction {
readonly group: typeof GROUP;
}
export interface SelectAction extends ActionBase {
readonly type: typeof ActionType.SELECT;
readonly payload: SelectPayload;
}
export interface UpdateAction extends ActionBase {
readonly type: typeof ActionType.UPDATE;
readonly payload: Payload;
}
export interface CloseAction extends ActionBase {
readonly type: typeof ActionType.CLOSE;
}
export interface OpenAction extends ActionBase {
readonly type: typeof ActionType.OPEN;
readonly payload: Payload;
}
export declare type ResourcePickerAction = SelectAction | UpdateAction | CloseAction | OpenAction | MetaAction;
export declare function select(payload: SelectPayload): SelectAction;
export declare function open(payload: Payload): OpenAction;
export declare function close(payload: ClosePayload): CloseAction;
export declare function update(payload: Payload): UpdateAction;
export declare function validationError(action: ResourcePickerAction): undefined | ErrorAction;
export declare class ResourcePicker extends ActionSet implements ActionSetProps<Options, Payload> {
readonly resourceType: ResourceType;
initialQuery?: string;
title?: string;
selectMultiple?: boolean;
showHidden?: boolean;
selection: ResourceSelection[];
constructor(app: ClientApplication<any>, options: Options, resourceType: ResourceType);
readonly payload: {
id: string;
resourceType: ResourceType;
initialQuery: string | undefined;
selectMultiple: boolean | undefined;
showHidden: boolean | undefined;
title: string | undefined;
};
readonly options: {
initialQuery: string | undefined;
selectMultiple: boolean | undefined;
showHidden: boolean | undefined;
title: string | undefined;
};
set(options: Partial<Options>, shouldUpdate?: boolean): this;
dispatch(action: Action, selection?: ResourceSelection[]): this;
protected update(): void;
protected open(): void;
protected close(): void;
}
export declare const create: (app: ClientApplication<any>, baseOptions: BaseOptions) => ResourcePicker;