UNPKG

@shopify/hydrogen-react

Version:

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

55 lines (54 loc) 1.5 kB
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const jsxRuntime = require("react/jsx-runtime"); const React = require("react"); const Image = require("./Image.js"); const Video = React.forwardRef((props, ref) => { var _a; const { data, previewImageOptions, id = data.id, playsInline = true, controls = true, sourceProps = {}, ...passthroughProps } = props; const posterUrl = Image.shopifyLoader({ src: ((_a = data.previewImage) == null ? void 0 : _a.url) ?? "", ...previewImageOptions }); if (!data.sources) { throw new Error(`<Video/> requires a 'data.sources' array`); } return ( // eslint-disable-next-line jsx-a11y/media-has-caption /* @__PURE__ */ jsxRuntime.jsx( "video", { ...passthroughProps, id, playsInline, controls, poster: posterUrl, ref, children: data.sources.map((source) => { if (!((source == null ? void 0 : source.url) && (source == null ? void 0 : source.mimeType))) { throw new Error(`<Video/> needs 'source.url' and 'source.mimeType'`); } return /* @__PURE__ */ React.createElement( "source", { ...sourceProps, key: source.url, src: source.url, type: source.mimeType } ); }) } ) ); }); exports.Video = Video; //# sourceMappingURL=Video.js.map