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

40 lines (37 loc) 1.44 kB
import React from 'react'; import { Toast as Toast$2 } from '@shopify/polaris-internal'; import compose from '@shopify/react-compose'; import { feature } from '../store/reducers/embeddedApp/toast/index.js'; import withFeature from '../withFeature.js'; /** * 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.createElement(Toast$2, { 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(withFeature(feature))(Toast); export { Toast, Toast$1 as default };