@wistia/wistia-player-react
Version:
An embeddable wistia-player web component and React wrapper to add responsive, lightweight, and SEO-friendly videos to your site.
42 lines (40 loc) • 1.32 kB
JavaScript
import {
getMergedEmbedOption,
isString,
wistiaPlayerStyleBlock
} from "./chunk-FSLSW5KG.mjs";
// src/WistiaPlayer.tsx
import { forwardRef, Suspense, lazy, Fragment } from "react";
import { jsx, jsxs } from "react/jsx-runtime";
var WistiaPlayerWrapper = lazy(
async () => import("./WistiaPlayerWrapper-BJQKWTOP.mjs").then((module) => ({
default: module.WistiaPlayerWrapper
}))
);
var WistiaPlayer = forwardRef(
(props, ref) => {
const { aspect, embedHost, mediaId, swatch, style } = props;
const mergedEmbedHost = getMergedEmbedOption(mediaId, "embedHost", embedHost ?? void 0);
const finalEmbedHost = isString(mergedEmbedHost) ? mergedEmbedHost : "fast.wistia.com";
const shouldDisplaySwatch = aspect !== void 0;
const styleBlock = wistiaPlayerStyleBlock({
mediaId,
embedHost: finalEmbedHost,
aspect,
shouldLoadSwatch: swatch
});
return /* @__PURE__ */ jsx(
Suspense,
{
fallback: shouldDisplaySwatch && /* @__PURE__ */ jsxs(Fragment, { children: [
/* @__PURE__ */ jsx("style", { children: styleBlock }),
/* @__PURE__ */ jsx("wistia-player", { "media-id": mediaId, style })
] }),
children: /* @__PURE__ */ jsx(WistiaPlayerWrapper, { ref, ...props })
}
);
}
);
export {
WistiaPlayer
};