UNPKG

@shopify/hydrogen-react

Version:

React components, hooks, and utilities for creating custom Shopify storefronts

40 lines (39 loc) 1.19 kB
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); const jsxRuntime = require("react/jsx-runtime"); function ExternalVideo(props) { var _a, _b; const { data, options, id = data.id, frameBorder = "0", allow = "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture", allowFullScreen = true, loading = "lazy", ...passthroughProps } = props; if (!data.embedUrl) { throw new Error(`<ExternalVideo/> requires the 'embedUrl' property`); } let finalUrl = data.embedUrl; if (options) { const urlObject = new URL(data.embedUrl); for (const key of Object.keys(options)) { urlObject.searchParams.set(key, options[key]); } finalUrl = urlObject.toString(); } return /* @__PURE__ */ jsxRuntime.jsx("iframe", { ...passthroughProps, id: id != null ? id : data.embedUrl, title: (_b = (_a = data.alt) != null ? _a : data.id) != null ? _b : "external video", frameBorder, allow, allowFullScreen, src: finalUrl, loading }); } exports.ExternalVideo = ExternalVideo; //# sourceMappingURL=ExternalVideo.js.map