@websolutespa/bom-mixer-ui 1.7.7 → 1.7.9

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,21 @@
1
1
  # @websolutespa/bom-mixer-ui
2
2
 
3
+ ## 1.7.9
4
+
5
+ ### Patch Changes
6
+
7
+ - Modified: SvgAnimation over mode last frame
8
+ - Modified: Media, MediaImage using exact dimensions
9
+ - Updated dependencies
10
+ - @websolutespa/bom-mixer-models@1.7.3
11
+ - @websolutespa/bom-core@1.7.4
12
+
13
+ ## 1.7.8
14
+
15
+ ### Patch Changes
16
+
17
+ - 75b1311: Fixing: Media srcset breakpoints
18
+
3
19
  ## 1.7.7
4
20
 
5
21
  ### Patch Changes
package/dist/cjs/index.js CHANGED
@@ -4383,14 +4383,21 @@ const MediaImage = _a => {
4383
4383
  }));
4384
4384
  };
4385
4385
  function getMediaSizes(mediaQuery, ratio, size) {
4386
+ // console.log('getMediaSizes', size, ratio);
4386
4387
  if (size) {
4387
4388
  if (typeof size === 'number') {
4388
- return Object.entries(ratio).map(_ref2 => {
4389
+ const s = size;
4390
+ // console.log('typeof size === \'number\'', size);
4391
+ const sizes = Object.entries(ratio).map(_ref2 => {
4389
4392
  let [k, v] = _ref2;
4390
- return [size, parseInt(String(mediaQuery[k])), v];
4391
- });
4393
+ const w = IMAGE_SIZEMAP[k];
4394
+ return [w && s > w ? w : s, parseInt(String(mediaQuery[k])), v];
4395
+ }).filter(x => x[0] >= x[1]);
4396
+ // console.log(size, 'sizes', sizes);
4397
+ return sizes;
4392
4398
  }
4393
4399
  if (isMediaSizeVariant(size)) {
4400
+ // console.log('isMediaSizeVariant');
4394
4401
  const sizeLimit = IMAGE_SIZEMAP[size] || 0;
4395
4402
  // console.log(size, ratio[size], sizeLimit);
4396
4403
  return Object.entries(IMAGE_SIZEMAP).filter(_ref3 => {
@@ -4403,10 +4410,13 @@ function getMediaSizes(mediaQuery, ratio, size) {
4403
4410
  }
4404
4411
  }
4405
4412
  size = size || IMAGE_SIZEMAP;
4406
- return Object.entries(size).map(_ref5 => {
4413
+ // console.log('size || IMAGE_SIZEMAP', size, IMAGE_SIZEMAP);
4414
+ const sizes = Object.entries(size).map(_ref5 => {
4407
4415
  let [k, v] = _ref5;
4408
4416
  return [v, parseInt(String(mediaQuery[k])), ratio[k]];
4409
4417
  });
4418
+ // console.log(size, 'sizes', sizes, ratio);
4419
+ return sizes;
4410
4420
  }
4411
4421
  function getImageProps(_a, mediaQuery) {
4412
4422
  var {
@@ -4424,15 +4434,25 @@ function getImageProps(_a, mediaQuery) {
4424
4434
  size
4425
4435
  } = props,
4426
4436
  otherProps = __rest(props, ["width", "height", "size"]);
4437
+ let useSize = size;
4438
+ if (typeof width === 'string' && width.indexOf('px') !== -1) {
4439
+ useSize = parseInt(width);
4440
+ }
4441
+ // console.log(useSize, width);
4427
4442
  const ratio = getMediaRatio(props);
4428
- const sizes = getMediaSizes(mediaQuery, ratio, size);
4443
+ const sizes = getMediaSizes(mediaQuery, ratio, useSize);
4429
4444
  const imageSrc = getImageSrc(src, sizes[0][0], sizes[0][2]);
4430
4445
  const imageSrcSet = getImageSrcset(src, sizes);
4431
4446
  const imageSizes = getImageSizes(sizes);
4447
+ let useWidth = typeof width === 'string' ? parseInt(width) : width;
4448
+ let useHeight = typeof height === 'string' ? parseInt(height) : height;
4449
+ // console.log('width', width, 'useWidth', useWidth, 'height', height, 'useHeight', useHeight, 'useSize', useSize);
4432
4450
  return Object.assign({
4433
4451
  src: imageSrc,
4434
4452
  srcSet: imageSrcSet,
4435
- sizes: imageSizes
4453
+ sizes: imageSizes,
4454
+ width: useWidth ? `${useWidth}px` : undefined,
4455
+ height: useHeight ? `${useHeight}px` : undefined
4436
4456
  }, otherProps);
4437
4457
  }
4438
4458
  function getMediaRatio(props) {
@@ -4492,7 +4512,7 @@ function getImageSrcset(src, sizes, quality) {
4492
4512
  return sizes.length > 1 ? sizes.map(size => getImageSrc(src, size[0], size[2], quality) + ` ${size[0]}w`).join(', ') : undefined;
4493
4513
  }
4494
4514
  function getImageSizes(sizes) {
4495
- return sizes.length > 1 ? sizes.map((size, i) => `${i < sizes.length - 1 ? `(max-width: ${sizes[i + 1][1]}px) ` : ''}${size[0]}px`).join(', ') : undefined;
4515
+ return sizes.length > 1 ? sizes.map((size, i) => `${i < sizes.length - 1 ? `(max-width: ${sizes[i + 1][1] - 1}px) ` : ''}${size[0]}px`).join(', ') : undefined;
4496
4516
  }
4497
4517
  function isSVG(src) {
4498
4518
  return src.indexOf('.svg') !== -1;
@@ -4628,6 +4648,7 @@ const MediaBase = /*#__PURE__*/React.forwardRef((_a, ref) => {
4628
4648
  const classNames = bomCore.getClassNames(className, 'media', {
4629
4649
  'media--gallery': id
4630
4650
  });
4651
+ // console.log('props.width', props.width, 'props.height', props.height);
4631
4652
  const mediaChildren = item && !children ? getMediaItems(item, {
4632
4653
  width,
4633
4654
  height,
@@ -4694,16 +4715,22 @@ function getMediaItems(itemOrItems, options) {
4694
4715
  if (x.title) {
4695
4716
  mediaItem.title = x.title;
4696
4717
  }
4718
+ mediaItem.width = options.width || x.width;
4719
+ /*
4697
4720
  if (options.width) {
4698
4721
  mediaItem.width = parseInt(String(options.width));
4699
4722
  } else if (x.width) {
4700
4723
  mediaItem.width = x.width;
4701
4724
  }
4725
+ */
4726
+ mediaItem.height = options.height || x.height;
4727
+ /*
4702
4728
  if (options.height) {
4703
4729
  mediaItem.height = parseInt(String(options.height));
4704
4730
  } else if (x.height) {
4705
4731
  mediaItem.height = x.height;
4706
4732
  }
4733
+ */
4707
4734
  mediaItem.aspectRatio = options.aspectRatio;
4708
4735
  mediaItem.aspectRatioSm = options.aspectRatioSm;
4709
4736
  mediaItem.aspectRatioMd = options.aspectRatioMd;
@@ -4712,7 +4739,8 @@ function getMediaItems(itemOrItems, options) {
4712
4739
  return mediaItem;
4713
4740
  });
4714
4741
  const hasGallery = options.galleryId != null && typeof options.open === 'function';
4715
- const getMediaItemProps = media => {
4742
+ const getMediaItemProps = _a => {
4743
+ var media = __rest(_a, ["width", "height"]);
4716
4744
  const title = media.title || options.title || media.alt || options.alt;
4717
4745
  const alt = media.alt || options.alt || media.title || options.title;
4718
4746
  const src = media.src || media.url || '';
@@ -4734,8 +4762,9 @@ function getMediaItems(itemOrItems, options) {
4734
4762
  };
4735
4763
  }
4736
4764
  if (bomCore.resolveMediaType(media) === 'image') {
4737
- let width = undefined;
4738
- let height = undefined;
4765
+ /*
4766
+ let width: number | undefined = undefined;
4767
+ let height: number | undefined = undefined;
4739
4768
  if (options.width) {
4740
4769
  width = parseInt(String(options.width));
4741
4770
  }
@@ -4744,14 +4773,18 @@ function getMediaItems(itemOrItems, options) {
4744
4773
  height = parseInt(String(options.height));
4745
4774
  }
4746
4775
  props.height = height;
4747
- if (options.eager) {
4748
- props.loading = 'eager';
4749
- }
4776
+ console.log('width', width, options.width, 'height', height, options.height);
4777
+ */
4778
+ props.width = options.width;
4779
+ props.height = options.height;
4750
4780
  props.aspectRatio = options.aspectRatio;
4751
4781
  props.aspectRatioSm = options.aspectRatioSm;
4752
4782
  props.aspectRatioMd = options.aspectRatioMd;
4753
4783
  props.aspectRatioLg = options.aspectRatioLg;
4754
4784
  props.aspectRatioXl = options.aspectRatioXl;
4785
+ if (options.eager) {
4786
+ props.loading = 'eager';
4787
+ }
4755
4788
  }
4756
4789
  return props;
4757
4790
  };
@@ -6746,11 +6779,18 @@ const SvgAnimation = /*#__PURE__*/React.forwardRef((_a, forwardedRef) => {
6746
6779
  return;
6747
6780
  }
6748
6781
  // console.log(playerRef.current.currentFrame);
6749
- if (mode === SvgAnimationStrategy.Default) {
6750
- playerRef.current.goToAndPlay(0);
6751
- }
6752
- if (mode === SvgAnimationStrategy.Once && playerRef.current.currentFrame === 0) {
6753
- playerRef.current.goToAndPlay(0);
6782
+ switch (mode) {
6783
+ case SvgAnimationStrategy.Default:
6784
+ playerRef.current.goToAndPlay(0);
6785
+ break;
6786
+ case SvgAnimationStrategy.Once:
6787
+ if (playerRef.current.currentFrame === 0) {
6788
+ playerRef.current.goToAndPlay(0);
6789
+ }
6790
+ break;
6791
+ case SvgAnimationStrategy.Over:
6792
+ playerRef.current.goToAndStop(playerRef.current.totalFrames - 1, true);
6793
+ break;
6754
6794
  }
6755
6795
  }
6756
6796
  } else {
@@ -6802,9 +6842,9 @@ const SvgAnimation = /*#__PURE__*/React.forwardRef((_a, forwardedRef) => {
6802
6842
  playerRef.current.goToAndPlay(0);
6803
6843
  }
6804
6844
  };
6805
- const onMouseOver = event => {
6806
- if (typeof props.onMouseOver === 'function') {
6807
- props.onMouseOver(event);
6845
+ const onMouseEnter = event => {
6846
+ if (typeof props.onMouseEnter === 'function') {
6847
+ props.onMouseEnter(event);
6808
6848
  }
6809
6849
  if (!playerRef.current) {
6810
6850
  return;
@@ -6813,6 +6853,17 @@ const SvgAnimation = /*#__PURE__*/React.forwardRef((_a, forwardedRef) => {
6813
6853
  playerRef.current.goToAndPlay(0);
6814
6854
  }
6815
6855
  };
6856
+ const onMouseLeave = event => {
6857
+ if (typeof props.onMouseLeave === 'function') {
6858
+ props.onMouseLeave(event);
6859
+ }
6860
+ if (!playerRef.current) {
6861
+ return;
6862
+ }
6863
+ if (mode === SvgAnimationStrategy.Over) {
6864
+ playerRef.current.goToAndStop(playerRef.current.totalFrames - 1, true);
6865
+ }
6866
+ };
6816
6867
  const classNames = bomCore.getClassNames('lottie', className, {
6817
6868
  loading: !animationData
6818
6869
  });
@@ -6820,7 +6871,8 @@ const SvgAnimation = /*#__PURE__*/React.forwardRef((_a, forwardedRef) => {
6820
6871
  ref: elementRef,
6821
6872
  className: classNames
6822
6873
  }, props, {
6823
- onMouseOver: onMouseOver,
6874
+ onMouseEnter: onMouseEnter,
6875
+ onMouseLeave: onMouseLeave,
6824
6876
  children: [animationData && jsxRuntime.jsx(LottiePlayerLight__default.default, {
6825
6877
  ref: playerRef,
6826
6878
  animationData: animationData,