@websolutespa/bom-mixer-ui 1.8.5 → 1.8.7

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.7
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixing: MediaVideo & SvgAnimation src change issue
8
+
9
+ ## 1.8.6
10
+
11
+ ### Patch Changes
12
+
13
+ - Modified: Meta, MediaGallery
14
+
3
15
  ## 1.8.5
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"
@@ -5514,7 +5537,8 @@ const MediaGallery = /*#__PURE__*/React.forwardRef((_a, ref) => {
5514
5537
  }).filter(x => x && x.galleryId === id).map(x => x.media);
5515
5538
  // console.log('MediaGallery.open', medias, media);
5516
5539
  const initialSlide = media && !Array.isArray(media) ? medias.reduce((p, c, i) => {
5517
- if (c.src === media.src) {
5540
+ const mediaSrc = media.src || media.url;
5541
+ if (c.src === mediaSrc) {
5518
5542
  return i;
5519
5543
  } else {
5520
5544
  return p;
@@ -5646,8 +5670,8 @@ MediaGallery.displayName = 'MediaGallery';
5646
5670
  function Meta(_ref) {
5647
5671
  let {
5648
5672
  children,
5649
- websiteName = 'WebsiteName',
5650
- structuredDataCollections
5673
+ structuredDataCollections,
5674
+ brand
5651
5675
  } = _ref;
5652
5676
  var _a, _b, _e;
5653
5677
  const page = bomMixerHooks.usePage();
@@ -5688,7 +5712,7 @@ function Meta(_ref) {
5688
5712
  }
5689
5713
  }
5690
5714
  // structuredData
5691
- const structuredData = bomMixerModels.resolveStructuredData(page, websiteName, structuredDataCollections);
5715
+ const structuredData = bomMixerModels.resolveStructuredData(page, structuredDataCollections, brand);
5692
5716
  return jsxRuntime.jsxs(Head__default.default, {
5693
5717
  children: [jsxRuntime.jsx("title", {
5694
5718
  children: title
@@ -5716,7 +5740,7 @@ function Meta(_ref) {
5716
5740
  hrefLang: alternate.locale
5717
5741
  }, `${alternate.locale}-${alternate.market}`)), page.media && jsxRuntime.jsx("meta", {
5718
5742
  property: "og:image",
5719
- content: bomMixerModels.resolveHref(page.media.src)
5743
+ content: bomMixerModels.resolveHref(page.media.src || page.media.url)
5720
5744
  }), false , structuredData && jsxRuntime.jsx("script", {
5721
5745
  type: "application/ld+json",
5722
5746
  children: structuredData
@@ -6997,7 +7021,7 @@ const SvgAnimation = /*#__PURE__*/React.forwardRef((_a, forwardedRef) => {
6997
7021
  }
6998
7022
  }
6999
7023
  // eslint-disable-next-line react-hooks/exhaustive-deps
7000
- }, [shouldLoad]);
7024
+ }, [shouldLoad, href]);
7001
7025
  // handle intersection
7002
7026
  React.useEffect(() => {
7003
7027
  if (isIntersecting) {
@@ -7035,7 +7059,7 @@ const SvgAnimation = /*#__PURE__*/React.forwardRef((_a, forwardedRef) => {
7035
7059
  playerRef.current.stop();
7036
7060
  }
7037
7061
  }
7038
- }, [isIntersecting, mode, shouldLoad]);
7062
+ }, [isIntersecting, mode, shouldLoad, href]);
7039
7063
  // handle scroll
7040
7064
  React.useEffect(() => {
7041
7065
  const scrollElement = mode === SvgAnimationStrategy.Scroll ? scrollableRef ? scrollableRef.current : window : undefined;