@websolutespa/bom-mixer-ui 1.8.6 → 1.8.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @websolutespa/bom-mixer-ui
2
2
 
3
+ ## 1.8.8
4
+
5
+ ### Patch Changes
6
+
7
+ - Added: brand.logo as default og:image in Meta
8
+
9
+ ## 1.8.7
10
+
11
+ ### Patch Changes
12
+
13
+ - Fixing: MediaVideo & SvgAnimation src change issue
14
+
3
15
  ## 1.8.6
4
16
 
5
17
  ### Patch Changes
package/dist/cjs/index.js CHANGED
@@ -4701,36 +4701,59 @@ const MediaVideo_ = _a => {
4701
4701
  var {
4702
4702
  className,
4703
4703
  onLoaded,
4704
- canLoad = true,
4705
- src
4704
+ canLoad = true
4706
4705
  } = _a,
4707
- props = __rest(_a, ["className", "onLoaded", "canLoad", "src"]);
4706
+ props = __rest(_a, ["className", "onLoaded", "canLoad"]);
4708
4707
  const videoRef = React.useRef(null);
4709
4708
  const {
4710
4709
  locale
4711
4710
  } = bomMixerHooks.useLayout();
4712
- const classNames = bomCore.getClassNames(className, 'video', 'video--muted');
4713
- const onLoad = () => {
4714
- if (typeof onLoaded === 'function' && videoRef.current && videoRef.current.readyState && videoRef.current.readyState >= 2) {
4715
- onLoaded(videoRef);
4716
- }
4717
- };
4711
+ const [src, setSrc] = React.useState();
4718
4712
  React.useEffect(() => {
4719
- if (videoRef.current && canLoad) {
4713
+ if (videoRef.current && src) {
4720
4714
  const video = videoRef.current;
4721
- if (video.readyState && video.readyState >= 2) {
4722
- if (typeof onLoaded === 'function') {
4715
+ const onReadyState = () => {
4716
+ if (typeof onLoaded === 'function' && videoRef.current && videoRef.current.readyState && videoRef.current.readyState >= 2) {
4723
4717
  onLoaded(videoRef);
4724
4718
  }
4719
+ };
4720
+ if (video.readyState && video.readyState >= 2) {
4721
+ onReadyState();
4725
4722
  } else {
4726
- video.addEventListener('loadeddata', onLoad);
4723
+ video.addEventListener('loadeddata', onReadyState);
4727
4724
  return () => {
4728
- video.removeEventListener('loadeddata', onLoad);
4725
+ video.removeEventListener('loadeddata', onReadyState);
4729
4726
  };
4730
4727
  }
4731
4728
  }
4732
4729
  return () => {};
4733
- }, [videoRef, canLoad]);
4730
+ }, [videoRef, onLoaded, src]);
4731
+ const isIntersecting = bomMixerHooks.useIntersectionObserver(videoRef, {
4732
+ threshold: 0,
4733
+ root: null,
4734
+ rootMargin: '0px'
4735
+ });
4736
+ // handle intersection
4737
+ React.useEffect(() => {
4738
+ if (isIntersecting && canLoad) {
4739
+ // on enter
4740
+ if (src !== props.src) {
4741
+ setSrc(props.src);
4742
+ } else {
4743
+ if (!videoRef.current) {
4744
+ return;
4745
+ }
4746
+ videoRef.current.play();
4747
+ }
4748
+ } else {
4749
+ // on exit
4750
+ if (!videoRef.current) {
4751
+ return;
4752
+ }
4753
+ videoRef.current.pause();
4754
+ }
4755
+ }, [isIntersecting, canLoad, videoRef, src, props.src]);
4756
+ const classNames = bomCore.getClassNames(className, 'video', 'video--muted');
4734
4757
  return jsxRuntime.jsx(StyledMediaVideo, Object.assign({
4735
4758
  ref: videoRef,
4736
4759
  className: classNames,
@@ -4739,7 +4762,7 @@ const MediaVideo_ = _a => {
4739
4762
  muted: true,
4740
4763
  loop: true
4741
4764
  }, props, {
4742
- children: canLoad && jsxRuntime.jsxs(jsxRuntime.Fragment, {
4765
+ children: src && jsxRuntime.jsxs(jsxRuntime.Fragment, {
4743
4766
  children: [jsxRuntime.jsx("source", {
4744
4767
  src: src,
4745
4768
  type: "video/mp4"
@@ -5690,6 +5713,8 @@ function Meta(_ref) {
5690
5713
  }
5691
5714
  // structuredData
5692
5715
  const structuredData = bomMixerModels.resolveStructuredData(page, structuredDataCollections, brand);
5716
+ // image
5717
+ const image = page.media ? page.media.src || page.media.url : brand === null || brand === void 0 ? void 0 : brand.logo;
5693
5718
  return jsxRuntime.jsxs(Head__default.default, {
5694
5719
  children: [jsxRuntime.jsx("title", {
5695
5720
  children: title
@@ -5715,9 +5740,9 @@ function Meta(_ref) {
5715
5740
  rel: "alternate",
5716
5741
  href: bomMixerModels.resolveHref(alternate.id),
5717
5742
  hrefLang: alternate.locale
5718
- }, `${alternate.locale}-${alternate.market}`)), page.media && jsxRuntime.jsx("meta", {
5743
+ }, `${alternate.locale}-${alternate.market}`)), image && jsxRuntime.jsx("meta", {
5719
5744
  property: "og:image",
5720
- content: bomMixerModels.resolveHref(page.media.src || page.media.url)
5745
+ content: bomMixerModels.resolveHref(image)
5721
5746
  }), false , structuredData && jsxRuntime.jsx("script", {
5722
5747
  type: "application/ld+json",
5723
5748
  children: structuredData
@@ -6998,7 +7023,7 @@ const SvgAnimation = /*#__PURE__*/React.forwardRef((_a, forwardedRef) => {
6998
7023
  }
6999
7024
  }
7000
7025
  // eslint-disable-next-line react-hooks/exhaustive-deps
7001
- }, [shouldLoad]);
7026
+ }, [shouldLoad, href]);
7002
7027
  // handle intersection
7003
7028
  React.useEffect(() => {
7004
7029
  if (isIntersecting) {
@@ -7036,7 +7061,7 @@ const SvgAnimation = /*#__PURE__*/React.forwardRef((_a, forwardedRef) => {
7036
7061
  playerRef.current.stop();
7037
7062
  }
7038
7063
  }
7039
- }, [isIntersecting, mode, shouldLoad]);
7064
+ }, [isIntersecting, mode, shouldLoad, href]);
7040
7065
  // handle scroll
7041
7066
  React.useEffect(() => {
7042
7067
  const scrollElement = mode === SvgAnimationStrategy.Scroll ? scrollableRef ? scrollableRef.current : window : undefined;