UNPKG

@shopify/app-bridge

Version:

**Shopify is doubling our engineering staff in 2021! [Join our team and work on libraries like this one.](https://smrtr.io/5GGrc)**

100 lines (99 loc) 2.84 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.close = exports.show = exports.create = exports.Share = exports.Action = void 0; var types_1 = require("../types"); var helper_1 = require("../helper"); /** * Types */ /** * @public */ var Action; (function (Action) { Action["SHOW"] = "APP::SHARE::SHOW"; Action["CLOSE"] = "APP::SHARE::CLOSE"; })(Action = exports.Action || (exports.Action = {})); /** * Action */ /** * A set of actions for displaying a Share Sheet component * @public */ var Share = /** @class */ (function (_super) { __extends(Share, _super); function Share(app) { return _super.call(this, app, types_1.Group.Share, types_1.Group.Share) || this; } /** * @public */ Share.prototype.dispatch = function (action, payload) { switch (action) { case Action.SHOW: this.dispatchShareAction(Action.SHOW, payload); break; default: throw new Error("Action: " + action + " not supported"); } return this; }; /** * @internal */ Share.prototype.dispatchShareAction = function (actionType, payload) { this.app.dispatch(helper_1.actionWrapper({ type: actionType, group: types_1.Group.Share, payload: __assign({ id: this.id }, payload), })); }; return Share; }(helper_1.ActionSet)); exports.Share = Share; /** * @public */ function create(app) { return new Share(app); } exports.create = create; function show() { return helper_1.actionWrapper({ group: types_1.Group.Share, type: Action.SHOW, }); } exports.show = show; function close() { return helper_1.actionWrapper({ group: types_1.Group.Share, type: Action.CLOSE, }); } exports.close = close;