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

50 lines (43 loc) 1.86 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var React = require('react'); var polarisInternal = require('@shopify/polaris-internal'); var compose = require('@shopify/react-compose'); var store_reducers_embeddedApp_toast_index = require('../store/reducers/embeddedApp/toast/index.js'); var withFeature = require('../withFeature.js'); function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } var React__default = /*#__PURE__*/_interopDefault(React); var compose__default = /*#__PURE__*/_interopDefault(compose); /** * The UI component for the Toast feature * @public * */ function Toast(props) { var _a, _b; var actions = props.actions, content = props.store.content; var action = ((_a = content === null || content === void 0 ? void 0 : content.action) === null || _a === void 0 ? void 0 : _a.content) ? { content: (_b = content === null || content === void 0 ? void 0 : content.action) === null || _b === void 0 ? void 0 : _b.content, onAction: function () { actions.action({ id: content.id, }); }, } : undefined; return content ? (React__default.default.createElement(polarisInternal.Toast, { error: content.error, duration: content.duration, onDismiss: handleToastDismiss, content: content.message, action: action })) : null; function handleToastDismiss() { if (!content) { return; } actions.clear({ id: content.id }); actions.legacyClear({ id: content.id }); } } /** * The Toast feature with its reducer, actions and UI component * @public * */ var Toast$1 = compose__default.default(withFeature.default(store_reducers_embeddedApp_toast_index.feature))(Toast); exports.Toast = Toast; exports.default = Toast$1;