UNPKG

@shopify/app-bridge-core

Version:

**[Join our team and work on libraries like this one.](https://www.shopify.ca/careers)**

69 lines (66 loc) 1.52 kB
import { Group } from '../types.js'; import { actionWrapper } from '../helper.js'; import { ActionSet } from '../ActionSet.js'; /** * Types */ /** * @public */ var Action; (function (Action) { Action["SHOW"] = "APP::SHARE::SHOW"; Action["CLOSE"] = "APP::SHARE::CLOSE"; })(Action || (Action = {})); /** * Action */ /** * A set of actions for displaying a Share Sheet component * @public */ class Share extends ActionSet { constructor(app) { super(app, Group.Share, Group.Share); } dispatch(action, payload) { switch (action) { case Action.SHOW: this.dispatchShareAction(Action.SHOW, payload); break; case Action.CLOSE: this.dispatchShareAction(Action.CLOSE, payload); break; default: throw new Error(`Action: ${action} not supported`); } return this; } /** * @internal */ dispatchShareAction(actionType, payload) { this.app.dispatch(actionWrapper({ type: actionType, group: Group.Share, payload: { id: this.id, ...payload, }, })); } } function show() { return actionWrapper({ group: Group.Share, type: Action.SHOW, }); } function close(payload) { return actionWrapper({ group: Group.Share, type: Action.CLOSE, payload, }); } export { Action, Share, close, show };