UNPKG

@shopify/app-bridge-host

Version:

App Bridge Host contains components and middleware to be consumed by the app's host, as well as the host itself. The middleware and `Frame` component are responsible for facilitating communication between the client and host, and used to act on actions se

60 lines (53 loc) 2.21 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var tslib = require('tslib'); var TitleBar = require('@shopify/app-bridge-core/actions/TitleBar'); var titleBar = require('@shopify/app-bridge-core/validate/actions/titleBar'); var actions = require('./actions.js'); function _interopNamespace(e) { if (e && e.__esModule) return e; var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { if (k !== 'default') { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, get: function () { return e[k]; } }); } }); } n.default = e; return Object.freeze(n); } var TitleBar__namespace = /*#__PURE__*/_interopNamespace(TitleBar); var defaultTitlebarStore = null; function titleBarReducer(state, action) { if (state === void 0) { state = defaultTitlebarStore; } switch (action.type) { case TitleBar__namespace.Action.UPDATE: { // Need to cast the action to the correct type var castAction = action; if (titleBar.validateAction(castAction)) { return state; } var _a = castAction.payload, title = _a.title, buttons = _a.buttons, breadcrumbs = _a.breadcrumbs; return tslib.__assign(tslib.__assign({}, state), { title: title, breadcrumbs: breadcrumbs, buttons: buttons }); } case actions.SET_PAGINATION: { // Need to cast the action to the correct type var castAction = action; return tslib.__assign(tslib.__assign({}, state), { pagination: castAction.payload }); } case actions.SET_APP_INFO: { var castAction = action; var currentAppInfo = (state && state.appInfo) || {}; return tslib.__assign(tslib.__assign({}, state), { appInfo: tslib.__assign(tslib.__assign({}, currentAppInfo), castAction.payload) }); } default: return state; } } exports.default = titleBarReducer; exports.defaultTitlebarStore = defaultTitlebarStore;