@websolutespa/bom-mixer-ui 1.8.1 → 1.8.3
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 +14 -0
- package/dist/cjs/index.js +48 -9
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/components/media/media-image.js +39 -8
- package/dist/esm/components/media/media-image.js.map +1 -1
- package/dist/esm/components/media/media-items.js +8 -0
- package/dist/esm/components/media/media-items.js.map +1 -1
- package/dist/esm/lazy/text-description/text-description.js +1 -1
- package/dist/esm/lazy/text-description/text-description.js.map +1 -1
- package/dist/types/components/media/media-image.d.ts +2 -0
- package/dist/types/components/media/media-image.d.ts.map +1 -1
- package/dist/types/components/media/media-items.d.ts +4 -0
- package/dist/types/components/media/media-items.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/media/media-image.tsx +27 -14
- package/src/components/media/media-items.tsx +12 -0
- package/src/lazy/text-description/text-description.tsx +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @websolutespa/bom-mixer-ui
|
|
2
2
|
|
|
3
|
+
## 1.8.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Modified: IAnchor
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @websolutespa/bom-core@1.8.3
|
|
10
|
+
|
|
11
|
+
## 1.8.2
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Modified: imageHandler
|
|
16
|
+
|
|
3
17
|
## 1.8.1
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/cjs/index.js
CHANGED
|
@@ -4411,9 +4411,11 @@ exports.ImageStrategy = void 0;
|
|
|
4411
4411
|
ImageStrategy["Custom"] = "custom";
|
|
4412
4412
|
})(exports.ImageStrategy || (exports.ImageStrategy = {}));
|
|
4413
4413
|
const IMAGE_SIZE_VARIANTS = ['xs', 'sm', 'md', 'lg', 'xl'];
|
|
4414
|
-
const IMAGE_SIZES = process.env.IMAGE_SIZES ? process.env.IMAGE_SIZES.split(',').map(x => parseInt(x)) : [
|
|
4414
|
+
const IMAGE_SIZES = process.env.IMAGE_SIZES ? process.env.IMAGE_SIZES.split(',').map(x => parseInt(x)) : [750, 960, 1440, 1600, 1920];
|
|
4415
4415
|
const IMAGE_SIZEMAP = Object.fromEntries(IMAGE_SIZES.map((x, i) => [IMAGE_SIZE_VARIANTS[i], x]));
|
|
4416
|
-
const
|
|
4416
|
+
const IMAGE_FOCAL_X = 50;
|
|
4417
|
+
const IMAGE_FOCAL_Y = 50;
|
|
4418
|
+
const IMAGE_QUALITY = process.env.IMAGE_QUALITY ? parseInt(process.env.IMAGE_QUALITY) : 90;
|
|
4417
4419
|
const IMAGE_STRATEGY = process.env.IMAGE_STRATEGY ? process.env.IMAGE_STRATEGY : exports.ImageStrategy.Mixer;
|
|
4418
4420
|
function isMediaSizeVariant(item) {
|
|
4419
4421
|
return typeof item === 'string';
|
|
@@ -4556,8 +4558,8 @@ function getImageProps(_a, mediaQuery) {
|
|
|
4556
4558
|
}
|
|
4557
4559
|
const ratio = getMediaRatio(useWidth, useHeight, props.aspectRatio, props.aspectRatioSm, props.aspectRatioMd, props.aspectRatioLg, props.aspectRatioXl);
|
|
4558
4560
|
const sizes = getMediaSizes(mediaQuery, ratio, useSize, props.mediaWidth, props.mediaHeight);
|
|
4559
|
-
const imageSrc = getImageSrc(src, sizes[0][0], sizes[0][2]);
|
|
4560
|
-
const imageSrcSet = getImageSrcset(src, sizes);
|
|
4561
|
+
const imageSrc = getImageSrc(src, sizes[0][0], sizes[0][2], props.mediaFocalX, props.mediaFocalY);
|
|
4562
|
+
const imageSrcSet = getImageSrcset(src, sizes, props.mediaFocalX, props.mediaFocalY);
|
|
4561
4563
|
const imageSizes = getImageSizes(sizes);
|
|
4562
4564
|
// console.log('useSize', useSize, 'width', width, useWidth, 'height', height, useHeight);
|
|
4563
4565
|
return Object.assign({
|
|
@@ -4597,23 +4599,52 @@ const BASE_URLS = {
|
|
|
4597
4599
|
[exports.ImageStrategy.Oven]: bomMixerStore.getRemoteApiUrl('/_image')
|
|
4598
4600
|
};
|
|
4599
4601
|
const BASE_URL = BASE_URLS[IMAGE_STRATEGY];
|
|
4600
|
-
function getImageSrc(src, width, ratio, quality) {
|
|
4602
|
+
function getImageSrc(src, width, ratio, focalX, focalY, quality) {
|
|
4603
|
+
if (focalX === void 0) {
|
|
4604
|
+
focalX = IMAGE_FOCAL_X;
|
|
4605
|
+
}
|
|
4606
|
+
if (focalY === void 0) {
|
|
4607
|
+
focalY = IMAGE_FOCAL_Y;
|
|
4608
|
+
}
|
|
4601
4609
|
if (quality === void 0) {
|
|
4602
4610
|
quality = IMAGE_QUALITY;
|
|
4603
4611
|
}
|
|
4604
4612
|
if (isSVG(src)) {
|
|
4605
4613
|
return src;
|
|
4606
4614
|
}
|
|
4607
|
-
|
|
4615
|
+
switch (IMAGE_STRATEGY) {
|
|
4616
|
+
case exports.ImageStrategy.Mixer:
|
|
4617
|
+
case exports.ImageStrategy.Oven:
|
|
4618
|
+
{
|
|
4619
|
+
const {
|
|
4620
|
+
origin,
|
|
4621
|
+
pathname,
|
|
4622
|
+
search
|
|
4623
|
+
} = src.indexOf('http') === 0 ? new URL(src) : {
|
|
4624
|
+
origin: '',
|
|
4625
|
+
pathname: src,
|
|
4626
|
+
search: ''
|
|
4627
|
+
};
|
|
4628
|
+
return ratio !== 0 ? `${BASE_URL}${pathname}?origin=${encodeURIComponent(origin)}&search=${encodeURIComponent(search)}&w=${width}&h=${Math.round(width / ratio)}&x=${focalX}&y=${focalY}&q=${quality}` : `${BASE_URL}${pathname}?origin=${encodeURIComponent(origin)}&search=${encodeURIComponent(search)}&w=${width}&x=${focalX}&y=${focalY}&q=${quality}`;
|
|
4629
|
+
}
|
|
4630
|
+
default:
|
|
4631
|
+
return ratio !== 0 ? `${BASE_URL}?url=${encodeURIComponent(src)}&w=${width}&h=${Math.round(width / ratio)}&q=${quality}` : `${BASE_URL}?url=${encodeURIComponent(src)}&w=${width}&q=${quality}`;
|
|
4632
|
+
}
|
|
4608
4633
|
}
|
|
4609
|
-
function getImageSrcset(src, sizes, quality) {
|
|
4634
|
+
function getImageSrcset(src, sizes, focalX, focalY, quality) {
|
|
4635
|
+
if (focalX === void 0) {
|
|
4636
|
+
focalX = IMAGE_FOCAL_X;
|
|
4637
|
+
}
|
|
4638
|
+
if (focalY === void 0) {
|
|
4639
|
+
focalY = IMAGE_FOCAL_Y;
|
|
4640
|
+
}
|
|
4610
4641
|
if (quality === void 0) {
|
|
4611
4642
|
quality = IMAGE_QUALITY;
|
|
4612
4643
|
}
|
|
4613
4644
|
if (isSVG(src)) {
|
|
4614
4645
|
return undefined;
|
|
4615
4646
|
}
|
|
4616
|
-
return sizes.length > 1 ? sizes.map(size => getImageSrc(src, size[0], size[2], quality) + ` ${size[0]}w`).join(', ') : undefined;
|
|
4647
|
+
return sizes.length > 1 ? sizes.map(size => getImageSrc(src, size[0], size[2], focalX, focalY, quality) + ` ${size[0]}w`).join(', ') : undefined;
|
|
4617
4648
|
}
|
|
4618
4649
|
function getImageSizes(sizes) {
|
|
4619
4650
|
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;
|
|
@@ -4744,6 +4775,12 @@ function getMediaItem(item, options) {
|
|
|
4744
4775
|
if (typeof item.height === 'number') {
|
|
4745
4776
|
mediaItem.mediaHeight = item.height;
|
|
4746
4777
|
}
|
|
4778
|
+
if (typeof item.focalX === 'number') {
|
|
4779
|
+
mediaItem.mediaFocalX = item.focalX;
|
|
4780
|
+
}
|
|
4781
|
+
if (typeof item.focalY === 'number') {
|
|
4782
|
+
mediaItem.mediaFocalY = item.focalY;
|
|
4783
|
+
}
|
|
4747
4784
|
mediaItem.width = options.width;
|
|
4748
4785
|
mediaItem.height = options.height;
|
|
4749
4786
|
mediaItem.aspectRatio = options.aspectRatio;
|
|
@@ -4783,6 +4820,8 @@ function getMediaItemProps(mediaItem, options) {
|
|
|
4783
4820
|
if (bomCore.isMediaImage(media)) {
|
|
4784
4821
|
mediaItemProps.mediaWidth = mediaItem.mediaWidth;
|
|
4785
4822
|
mediaItemProps.mediaHeight = mediaItem.mediaHeight;
|
|
4823
|
+
mediaItemProps.mediaFocalX = mediaItem.mediaFocalX;
|
|
4824
|
+
mediaItemProps.mediaFocalY = mediaItem.mediaFocalY;
|
|
4786
4825
|
mediaItemProps.width = options.width;
|
|
4787
4826
|
mediaItemProps.height = options.height;
|
|
4788
4827
|
mediaItemProps.aspectRatio = options.aspectRatio;
|
|
@@ -11355,7 +11394,7 @@ const TextDescription = _ref => {
|
|
|
11355
11394
|
const classNames = bomCore.getClassNames('text-description');
|
|
11356
11395
|
return jsxRuntime.jsx(Section, {
|
|
11357
11396
|
className: classNames,
|
|
11358
|
-
id: (_a = item.anchor) === null || _a === void 0 ? void 0 : _a.
|
|
11397
|
+
id: (_a = item.anchor) === null || _a === void 0 ? void 0 : _a.hash,
|
|
11359
11398
|
padding: "0 0 2rem 0",
|
|
11360
11399
|
children: jsxRuntime.jsx(Container, {
|
|
11361
11400
|
maxWidthMd: "80ch",
|