UNPKG

@shopify/app-bridge-core

Version:

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

118 lines (117 loc) 3.87 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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); 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.FeedbackModal = exports.Action = void 0; exports.open = open; exports.close = close; exports.create = create; var helper_1 = require("../helper"); var ActionSet_1 = require("../ActionSet"); var types_1 = require("../types"); /** * Action for the Feedback Modal group * @public */ var Action; (function (Action) { Action["OPEN"] = "APP::FEEDBACK_MODAL::OPEN"; Action["CLOSE"] = "APP::FEEDBACK_MODAL::CLOSE"; })(Action || (exports.Action = Action = {})); function open(payload) { return (0, helper_1.actionWrapper)({ group: types_1.Group.FeedbackModal, payload: payload, type: Action.OPEN, }); } function close(payload) { return (0, helper_1.actionWrapper)({ group: types_1.Group.FeedbackModal, payload: payload, type: Action.CLOSE, }); } /** * FeedbackModal action set */ var FeedbackModal = /** @class */ (function (_super) { __extends(FeedbackModal, _super); /** * Returns a new instance of a FeedbackModal action set * @param app the client application */ function FeedbackModal(app, options) { var _this = _super.call(this, app, types_1.Group.FeedbackModal, types_1.Group.FeedbackModal) || this; _this.options = options; _this.set(options); return _this; } Object.defineProperty(FeedbackModal.prototype, "payload", { /** * Returns the action set payload */ get: function () { return __assign({ id: this.id }, this.options); }, enumerable: false, configurable: true }); FeedbackModal.prototype.set = function (options) { this.options = (0, helper_1.getMergedProps)(this.options, options); return this; }; /** * Dispatches a given action with the action set payload * @param action the action enum * @returns the action set instance */ FeedbackModal.prototype.dispatch = function (action) { switch (action) { case Action.OPEN: { var openAction = open(this.payload); this.app.dispatch(openAction); break; } case Action.CLOSE: { var closeAction = close(this.payload); this.app.dispatch(closeAction); break; } } return this; }; return FeedbackModal; }(ActionSet_1.ActionSet)); exports.FeedbackModal = FeedbackModal; /** * Returns a new instance of a FeedbackModal action set * @param app the client application */ function create(app, options) { return new FeedbackModal(app, options); }