vviinn-widgets 2.145.13 → 2.146.1
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/dist/cjs/{constants-0a36f053.js → constants-21309688.js} +5 -0
- package/dist/cjs/{index-de717525.js → index-ab40eb55.js} +1 -1
- package/dist/cjs/{package-0598a72d.js → package-ebf6ab72.js} +1 -1
- package/dist/cjs/search-filters_13.cjs.entry.js +7 -7
- package/dist/cjs/{search.store-5d72b491.js → search.store-f6717a99.js} +33 -29
- package/dist/cjs/vviinn-carousel_9.cjs.entry.js +3 -3
- package/dist/cjs/vviinn-detected-object_7.cjs.entry.js +2 -2
- package/dist/cjs/vviinn-selected-filters.cjs.entry.js +1 -1
- package/dist/cjs/vviinn-text-search.cjs.entry.js +1 -1
- package/dist/cjs/vviinn-vps-button.cjs.entry.js +2 -2
- package/dist/collection/Image/imageToB64.js +1 -1
- package/dist/collection/Image/resizeImage.js +4 -4
- package/dist/collection/Image/sizing.js +10 -10
- package/dist/collection/Image/sizing.spec.js +74 -9
- package/dist/collection/Image/toFile.js +10 -8
- package/dist/collection/components/vviinn-results/vviinn-results.js +3 -2
- package/dist/collection/components/vviinn-vps-button/vviinn-vps-button.js +3 -2
- package/dist/collection/components/vviinn-vps-widget/vviinn-vps-widget.js +4 -3
- package/dist/collection/store/file-processing.js +4 -1
- package/dist/collection/store/search.store.js +5 -6
- package/dist/collection/widget/constants.js +2 -0
- package/dist/esm/{constants-c2f6bdfe.js → constants-7fd90481.js} +4 -1
- package/dist/esm/{index-4bb33163.js → index-e75e8e40.js} +1 -1
- package/dist/esm/{package-578728c8.js → package-bef1c31a.js} +1 -1
- package/dist/esm/search-filters_13.entry.js +7 -7
- package/dist/esm/{search.store-c897e270.js → search.store-77ffc2f3.js} +33 -29
- package/dist/esm/vviinn-carousel_9.entry.js +3 -3
- package/dist/esm/vviinn-detected-object_7.entry.js +2 -2
- package/dist/esm/vviinn-selected-filters.entry.js +1 -1
- package/dist/esm/vviinn-text-search.entry.js +1 -1
- package/dist/esm/vviinn-vps-button.entry.js +2 -2
- package/dist/types/Image/resizeImage.d.ts +1 -1
- package/dist/types/Image/sizing.d.ts +2 -2
- package/dist/types/store/search.store.d.ts +0 -1
- package/dist/types/widget/constants.d.ts +2 -0
- package/dist/vviinn-widgets/p-0f1b98bc.js +1 -0
- package/dist/vviinn-widgets/p-33c6c053.entry.js +11 -0
- package/{www/build/p-e720457a.entry.js → dist/vviinn-widgets/p-6a804b1b.entry.js} +1 -1
- package/dist/vviinn-widgets/{p-800ea3cc.js → p-a21652b4.js} +1 -1
- package/dist/vviinn-widgets/{p-f601d5c0.js → p-a8b9a8e6.js} +1 -1
- package/{www/build/p-5b49585c.entry.js → dist/vviinn-widgets/p-aadc5fa6.entry.js} +1 -1
- package/dist/vviinn-widgets/{p-380b7211.js → p-b037d569.js} +1 -1
- package/dist/vviinn-widgets/{p-27943563.entry.js → p-bb106857.entry.js} +1 -1
- package/dist/vviinn-widgets/p-d2aa342d.entry.js +1 -0
- package/dist/vviinn-widgets/{p-c79f3aa6.entry.js → p-fc5e3427.entry.js} +1 -1
- package/dist/vviinn-widgets/vviinn-widgets.esm.js +1 -1
- package/package.json +1 -1
- package/www/build/p-0f1b98bc.js +1 -0
- package/www/build/p-33c6c053.entry.js +11 -0
- package/{dist/vviinn-widgets/p-e720457a.entry.js → www/build/p-6a804b1b.entry.js} +1 -1
- package/www/build/{p-800ea3cc.js → p-a21652b4.js} +1 -1
- package/www/build/{p-f601d5c0.js → p-a8b9a8e6.js} +1 -1
- package/{dist/vviinn-widgets/p-5b49585c.entry.js → www/build/p-aadc5fa6.entry.js} +1 -1
- package/www/build/{p-380b7211.js → p-b037d569.js} +1 -1
- package/www/build/{p-27943563.entry.js → p-bb106857.entry.js} +1 -1
- package/www/build/p-d2aa342d.entry.js +1 -0
- package/www/build/{p-c79f3aa6.entry.js → p-fc5e3427.entry.js} +1 -1
- package/www/build/vviinn-widgets.esm.js +1 -1
- package/dist/vviinn-widgets/p-78e70ca6.entry.js +0 -11
- package/dist/vviinn-widgets/p-92c02a9f.js +0 -1
- package/dist/vviinn-widgets/p-dec3bc0e.entry.js +0 -1
- package/www/build/p-78e70ca6.entry.js +0 -11
- package/www/build/p-92c02a9f.js +0 -1
- package/www/build/p-dec3bc0e.entry.js +0 -1
|
@@ -3,8 +3,13 @@
|
|
|
3
3
|
const findSlotElements = (el) => Array.from(el.querySelectorAll("[slot]"));
|
|
4
4
|
const getSlotNames = (slotElements) => slotElements.map((el) => el.getAttribute("slot"));
|
|
5
5
|
|
|
6
|
+
const SEARCH_WIDGET_IMAGE_RESOLUTION_WIDTH = 320;
|
|
7
|
+
const RESULTS_WIDGET_IMAGE_RESOLUTION_WIDTH = 500;
|
|
8
|
+
|
|
6
9
|
const DEFAULT_EXAMPLE_IMAGE = "https://cdn.vviinn.com/assets/merchant/default/vviinn_img_start-hero.jpg";
|
|
7
10
|
|
|
8
11
|
exports.DEFAULT_EXAMPLE_IMAGE = DEFAULT_EXAMPLE_IMAGE;
|
|
12
|
+
exports.RESULTS_WIDGET_IMAGE_RESOLUTION_WIDTH = RESULTS_WIDGET_IMAGE_RESOLUTION_WIDTH;
|
|
13
|
+
exports.SEARCH_WIDGET_IMAGE_RESOLUTION_WIDTH = SEARCH_WIDGET_IMAGE_RESOLUTION_WIDTH;
|
|
9
14
|
exports.findSlotElements = findSlotElements;
|
|
10
15
|
exports.getSlotNames = getSlotNames;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const index = require('./index-711d38e6.js');
|
|
4
|
-
const search_store = require('./search.store-
|
|
4
|
+
const search_store = require('./search.store-f6717a99.js');
|
|
5
5
|
|
|
6
6
|
const PlusIcon = () => (index.h("svg", { width: "32", height: "32", viewBox: "0 0 32 32", fill: "none", xmlns: "http://www.w3.org/2000/svg", class: "plus-icon" },
|
|
7
7
|
index.h("path", { d: "M14.6667 17.3333H8.00001C7.62223 17.3333 7.30556 17.2056 7.05001 16.95C6.79445 16.6944 6.66667 16.3778 6.66667 16C6.66667 15.6222 6.79445 15.3056 7.05001 15.05C7.30556 14.7944 7.62223 14.6667 8.00001 14.6667H14.6667V8.00001C14.6667 7.62223 14.7944 7.30556 15.05 7.05001C15.3056 6.79445 15.6222 6.66667 16 6.66667C16.3778 6.66667 16.6944 6.79445 16.95 7.05001C17.2056 7.30556 17.3333 7.62223 17.3333 8.00001V14.6667H24C24.3778 14.6667 24.6944 14.7944 24.95 15.05C25.2056 15.3056 25.3333 15.6222 25.3333 16C25.3333 16.3778 25.2056 16.6944 24.95 16.95C24.6944 17.2056 24.3778 17.3333 24 17.3333H17.3333V24C17.3333 24.3778 17.2056 24.6944 16.95 24.95C16.6944 25.2056 16.3778 25.3333 16 25.3333C15.6222 25.3333 15.3056 25.2056 15.05 24.95C14.7944 24.6944 14.6667 24.3778 14.6667 24V17.3333Z", fill: "currentColor" })));
|
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-711d38e6.js');
|
|
6
|
-
const search_store = require('./search.store-
|
|
6
|
+
const search_store = require('./search.store-f6717a99.js');
|
|
7
7
|
const customizedSlots = require('./customized-slots-93d9f5c9.js');
|
|
8
|
-
const index$1 = require('./index-
|
|
8
|
+
const index$1 = require('./index-ab40eb55.js');
|
|
9
9
|
const Rectangle = require('./Rectangle-99c25901.js');
|
|
10
|
-
const _package = require('./package-
|
|
10
|
+
const _package = require('./package-ebf6ab72.js');
|
|
11
11
|
const i18next = require('./i18next-74ff3413.js');
|
|
12
12
|
const resources = require('./resources-f8c5d64c.js');
|
|
13
13
|
const index$2 = require('./index-9ea9f6a5.js');
|
|
14
|
-
const constants = require('./constants-
|
|
14
|
+
const constants = require('./constants-21309688.js');
|
|
15
15
|
const WarningIcon = require('./WarningIcon-65f4b692.js');
|
|
16
16
|
|
|
17
17
|
const CameraActionIcon = () => (index.h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none" },
|
|
@@ -3938,7 +3938,7 @@ const VviinnResults = class {
|
|
|
3938
3938
|
this.token = undefined;
|
|
3939
3939
|
this.searchId = undefined;
|
|
3940
3940
|
this.uiSessionId = undefined;
|
|
3941
|
-
this.imageResolutionWidth =
|
|
3941
|
+
this.imageResolutionWidth = constants.RESULTS_WIDGET_IMAGE_RESOLUTION_WIDTH;
|
|
3942
3942
|
this.currencySign = "€";
|
|
3943
3943
|
this.locale = "de-DE";
|
|
3944
3944
|
this.productDetailsNewTab = false;
|
|
@@ -4456,7 +4456,7 @@ const VviinnVpsWidget = class {
|
|
|
4456
4456
|
this.excluded = "";
|
|
4457
4457
|
this.productDetailsNewTab = true;
|
|
4458
4458
|
this.productDetailsRedirect = true;
|
|
4459
|
-
this.imageResolutionWidth =
|
|
4459
|
+
this.imageResolutionWidth = constants.SEARCH_WIDGET_IMAGE_RESOLUTION_WIDTH;
|
|
4460
4460
|
this.exampleImageSource = constants.DEFAULT_EXAMPLE_IMAGE;
|
|
4461
4461
|
this.textSearchShow = false;
|
|
4462
4462
|
this.addToBasketShow = false;
|
|
@@ -4702,7 +4702,7 @@ const VviinnVpsWidget = class {
|
|
|
4702
4702
|
}), class: { invisible: this.haveErrors() } }))), index.h("vviinn-slide", { class: {
|
|
4703
4703
|
"results-page": true,
|
|
4704
4704
|
active: this.isResultSlide(),
|
|
4705
|
-
} }, this.isResultSlide() && this.state.searchType === "image" && (index.h("div", { class: "source-wrapper image-wrapper" }, index.h("vviinn-cropper", { basicEventData: this.getBasicEventData(), showAspectRatioError: this.showAspectRatioError, showInWidget: true }), index.h("div", { class: {
|
|
4705
|
+
} }, this.isResultSlide() && this.state.searchType === "image" && (index.h("div", { class: "source-wrapper image-wrapper" }, index.h("vviinn-cropper", { basicEventData: this.getBasicEventData(), showAspectRatioError: this.showAspectRatioError, apiPath: this.apiPath, showInWidget: true }), index.h("div", { class: {
|
|
4706
4706
|
"filters-wrapper": true,
|
|
4707
4707
|
hidden: this.showAspectRatioError,
|
|
4708
4708
|
} }, index.h("div", { class: "filters" }, this.state.filters.map((filter) => (index.h("search-filters", { filter: filter, basicEventData: this.getBasicEventData() }))))))), this.isResultSlide() && this.state.searchType === "text" && (index.h("div", { class: "source-wrapper text-search-wrapper" }, index.h("vviinn-text-search", { token: this.token, showInWidget: true, searchQuery: this.searchQuery, apiPath: this.apiPath, locale: this.locale }), index.h("div", { class: {
|
|
@@ -17135,18 +17135,18 @@ const ordByKind = {
|
|
|
17135
17135
|
return x.kind === y.kind ? 0 : x.kind === "width" ? -1 : 1;
|
|
17136
17136
|
},
|
|
17137
17137
|
};
|
|
17138
|
-
const
|
|
17139
|
-
const
|
|
17140
|
-
const
|
|
17138
|
+
const sortDimensionsBySize = _Array.sort(ordBySize);
|
|
17139
|
+
const sortDimensionsByKind = _Array.sort(ordByKind);
|
|
17140
|
+
const getDimensionsRatio = (sortedDimensions) => {
|
|
17141
17141
|
const [smallest, largest] = sortedDimensions;
|
|
17142
17142
|
return smallest.size / largest.size;
|
|
17143
17143
|
};
|
|
17144
|
-
const
|
|
17145
|
-
const sortedDimensions =
|
|
17146
|
-
const ratio =
|
|
17147
|
-
const newSmallestSide = Object.assign(Object.assign({}, sortedDimensions[0]), { size: toSize * ratio });
|
|
17148
|
-
const newLargestSide = Object.assign(Object.assign({}, sortedDimensions[1]), { size: toSize });
|
|
17149
|
-
return
|
|
17144
|
+
const scaleBySide = (toSize, comparedSide) => (dimensions) => {
|
|
17145
|
+
const sortedDimensions = sortDimensionsBySize(dimensions);
|
|
17146
|
+
const ratio = getDimensionsRatio(sortedDimensions);
|
|
17147
|
+
const newSmallestSide = Object.assign(Object.assign({}, sortedDimensions[0]), { size: comparedSide === "smallest" ? toSize : toSize * ratio });
|
|
17148
|
+
const newLargestSide = Object.assign(Object.assign({}, sortedDimensions[1]), { size: comparedSide === "largest" ? toSize : toSize / ratio });
|
|
17149
|
+
return sortDimensionsByKind([newLargestSide, newSmallestSide]);
|
|
17150
17150
|
};
|
|
17151
17151
|
const dimensionsFromImage = (image) => {
|
|
17152
17152
|
const { naturalWidth, naturalHeight } = image;
|
|
@@ -17154,7 +17154,7 @@ const dimensionsFromImage = (image) => {
|
|
|
17154
17154
|
};
|
|
17155
17155
|
const getImageSizes = (i, defaultImageSize) => {
|
|
17156
17156
|
const dimensions = dimensionsFromImage(i);
|
|
17157
|
-
const resize =
|
|
17157
|
+
const resize = scaleBySide(defaultImageSize, "largest");
|
|
17158
17158
|
const newDimensions = resize(dimensions);
|
|
17159
17159
|
const sizes = newDimensions.map((d) => d.size);
|
|
17160
17160
|
return [sizes[0], sizes[1]];
|
|
@@ -17173,8 +17173,8 @@ const imageDataFromImage = (image) => {
|
|
|
17173
17173
|
context.drawImage(image, 0, 0);
|
|
17174
17174
|
return context.getImageData(0, 0, naturalWidth, naturalHeight);
|
|
17175
17175
|
};
|
|
17176
|
-
const resizeImage = (
|
|
17177
|
-
const scale =
|
|
17176
|
+
const resizeImage = (side, i) => {
|
|
17177
|
+
const scale = scaleBySide(side, "smallest");
|
|
17178
17178
|
const [destinationCanvas, destinationContext] = createCanvasWithContext();
|
|
17179
17179
|
const imageDimensions = dimensionsFromImage(i);
|
|
17180
17180
|
const [destinationWidth, destinationHeight] = scale(imageDimensions).map((d) => d.size);
|
|
@@ -17184,7 +17184,7 @@ const resizeImage = (width, i) => {
|
|
|
17184
17184
|
destinationCanvas.height = destinationHeight;
|
|
17185
17185
|
dist.lanczos(originImageData, destinationImageData);
|
|
17186
17186
|
destinationContext.putImageData(destinationImageData, 0, 0);
|
|
17187
|
-
return destinationCanvas.toDataURL();
|
|
17187
|
+
return destinationCanvas.toDataURL("image/jpeg", 0.7);
|
|
17188
17188
|
};
|
|
17189
17189
|
|
|
17190
17190
|
const toFile = async (b64data) => {
|
|
@@ -17195,15 +17195,17 @@ const toFile = async (b64data) => {
|
|
|
17195
17195
|
lastModified: Date.now(),
|
|
17196
17196
|
});
|
|
17197
17197
|
};
|
|
17198
|
-
const convertB64toFileTask = (b64data) => () =>
|
|
17199
|
-
|
|
17200
|
-
|
|
17201
|
-
|
|
17202
|
-
|
|
17203
|
-
|
|
17198
|
+
const convertB64toFileTask = (b64data) => () => {
|
|
17199
|
+
return new Promise(async (resolve, _) => {
|
|
17200
|
+
const request = await fetch(b64data);
|
|
17201
|
+
const blob = await request.blob();
|
|
17202
|
+
const file = new File([blob], "image", {
|
|
17203
|
+
type: blob.type,
|
|
17204
|
+
lastModified: Date.now(),
|
|
17205
|
+
});
|
|
17206
|
+
resolve(file);
|
|
17204
17207
|
});
|
|
17205
|
-
|
|
17206
|
-
});
|
|
17208
|
+
};
|
|
17207
17209
|
|
|
17208
17210
|
const imageToB64 = (i) => {
|
|
17209
17211
|
const canvas = document.createElement("canvas");
|
|
@@ -17212,11 +17214,14 @@ const imageToB64 = (i) => {
|
|
|
17212
17214
|
canvas.width = naturalWidth;
|
|
17213
17215
|
canvas.height = naturalHeight;
|
|
17214
17216
|
ctx.drawImage(i, 0, 0, naturalWidth, naturalHeight);
|
|
17215
|
-
return canvas.toDataURL();
|
|
17217
|
+
return canvas.toDataURL("image/jpeg");
|
|
17216
17218
|
};
|
|
17217
17219
|
|
|
17218
17220
|
const checkFileWithExtention = (file) => _function.pipe(file, Option.fromNullable, Either.fromOption(() => fileDoesntExistError), Either.chain(checkImageType));
|
|
17219
|
-
const optionalResize = (image, size) =>
|
|
17221
|
+
const optionalResize = (image, size) => {
|
|
17222
|
+
const smallestSide = Math.min(image.naturalWidth, image.naturalHeight);
|
|
17223
|
+
return smallestSide > size ? resizeImage(size, image) : imageToB64(image);
|
|
17224
|
+
};
|
|
17220
17225
|
const resizeFileTo = (size) => (file) => _function.pipe(file, imageFromFileTask, Task.map((image) => optionalResize(image, size)), Task.chain(convertB64toFileTask));
|
|
17221
17226
|
|
|
17222
17227
|
const encodeToBase64UTF8 = (str) => {
|
|
@@ -17225,8 +17230,8 @@ const encodeToBase64UTF8 = (str) => {
|
|
|
17225
17230
|
return btoa(String.fromCharCode.apply(null, utf8Array));
|
|
17226
17231
|
};
|
|
17227
17232
|
|
|
17228
|
-
const
|
|
17229
|
-
const
|
|
17233
|
+
const IMAGE_SMALLEST_SIDE_TO_RESIZE = 800;
|
|
17234
|
+
const HI_RES_IMAGE_SMALLEST_SIDE_TO_RESIZE = 2000;
|
|
17230
17235
|
const makeAuthorizedRequest = (token) => pipe(token, processBearerToken, map$4((headers) => {
|
|
17231
17236
|
return {
|
|
17232
17237
|
headers,
|
|
@@ -17244,7 +17249,6 @@ const storeDefaults = {
|
|
|
17244
17249
|
objectDetectionInProgress: false,
|
|
17245
17250
|
resultLoaded: false,
|
|
17246
17251
|
resultViewed: false,
|
|
17247
|
-
imageWidth: RESIZED_IMAGE_WIDTH,
|
|
17248
17252
|
image: Option.none,
|
|
17249
17253
|
serverError: false,
|
|
17250
17254
|
loading: false,
|
|
@@ -17254,7 +17258,7 @@ const { state: componentsState } = createStore(storeDefaults);
|
|
|
17254
17258
|
const useStore = (store) => store === "widget" ? searchState : componentsState;
|
|
17255
17259
|
const resetStore = (store) => {
|
|
17256
17260
|
const state = useStore(store);
|
|
17257
|
-
Object.assign(state, storeDefaults);
|
|
17261
|
+
Object.assign(state, Object.assign(Object.assign({}, storeDefaults), { campaignId: state.campaignId, excluded: state.excluded }));
|
|
17258
17262
|
};
|
|
17259
17263
|
const updateState = (store) => async (response) => {
|
|
17260
17264
|
var _a;
|
|
@@ -17379,11 +17383,11 @@ const processSelectedFile = (store) => async (file) => {
|
|
|
17379
17383
|
state.image = Option.none;
|
|
17380
17384
|
state.detectedObjects = [];
|
|
17381
17385
|
const originFile = checkFileWithExtention(file);
|
|
17382
|
-
const fileResizer = resizeFileTo(
|
|
17386
|
+
const fileResizer = resizeFileTo(IMAGE_SMALLEST_SIDE_TO_RESIZE);
|
|
17383
17387
|
const resizeFileTask = pipe(originFile, fromEither, chainTaskK(fileResizer));
|
|
17384
17388
|
await pipe(resizeFileTask, chainTaskK(imageFromFileTask), map(setSelectedImage(store)))();
|
|
17385
17389
|
const session = await pipe(resizeFileTask, chain(uploadFile(store)))();
|
|
17386
|
-
const hiResFileResizer = resizeFileTo(
|
|
17390
|
+
const hiResFileResizer = resizeFileTo(HI_RES_IMAGE_SMALLEST_SIDE_TO_RESIZE);
|
|
17387
17391
|
const resizeHiResFileTask = pipe(originFile, fromEither, chainTaskK(hiResFileResizer));
|
|
17388
17392
|
const resizedHiResFile = await resizeHiResFileTask();
|
|
17389
17393
|
pipe(sequenceToEither(session, resizedHiResFile), map$4(([sessionObject, file]) => uploadHiResFile(store)(sessionObject, file)));
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-711d38e6.js');
|
|
6
|
-
const search_store = require('./search.store-
|
|
7
|
-
const _package = require('./package-
|
|
8
|
-
const index$1 = require('./index-
|
|
6
|
+
const search_store = require('./search.store-f6717a99.js');
|
|
7
|
+
const _package = require('./package-ebf6ab72.js');
|
|
8
|
+
const index$1 = require('./index-ab40eb55.js');
|
|
9
9
|
const i18next = require('./i18next-74ff3413.js');
|
|
10
10
|
const customizedSlots = require('./customized-slots-93d9f5c9.js');
|
|
11
11
|
const index$2 = require('./index-9ea9f6a5.js');
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-711d38e6.js');
|
|
6
|
-
const search_store = require('./search.store-
|
|
6
|
+
const search_store = require('./search.store-f6717a99.js');
|
|
7
7
|
const Rectangle = require('./Rectangle-99c25901.js');
|
|
8
8
|
const i18next = require('./i18next-74ff3413.js');
|
|
9
9
|
const WarningIcon = require('./WarningIcon-65f4b692.js');
|
|
10
10
|
const customizedSlots = require('./customized-slots-93d9f5c9.js');
|
|
11
|
-
const _package = require('./package-
|
|
11
|
+
const _package = require('./package-ebf6ab72.js');
|
|
12
12
|
const index$1 = require('./index-9ea9f6a5.js');
|
|
13
13
|
|
|
14
14
|
const SecondaryActionIcon = () => (index.h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none" },
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-711d38e6.js');
|
|
6
6
|
const triggerFilter = require('./triggerFilter-ec550117.js');
|
|
7
|
-
const search_store = require('./search.store-
|
|
7
|
+
const search_store = require('./search.store-f6717a99.js');
|
|
8
8
|
require('./Rectangle-99c25901.js');
|
|
9
9
|
|
|
10
10
|
const vviinnFiltersCss = ":host{--font-family-base:Inter, system-ui, sans-serif;--font-family-mono:monospace;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;--font-size-title:24px;--font-size-headline:18px;--font-size-label-large:16px;--font-size-label:14px;--font-size-body-large:16px;--font-size-body:14px;--font-size-caption:12px;--line-height-title:32px;--line-height-headline:24px;--line-height-label-large:24px;--line-height-label:20px;--line-height-body-large:24px;--line-height-body:20px;--line-height-caption:16px;--letter-spacing-title:0px;--letter-spacing-headline:0px;--letter-spacing-label-large:0px;--letter-spacing-label:0px;--letter-spacing-body-large:0px;--letter-spacing-body:0px;--letter-spacing-caption:0px;--font-weight-400:400;--font-weight-500:500;--font-weight-600:600;--font-weight-700:700;--spacing-none:0px;--spacing-25:2px;--spacing-50:4px;--spacing-75:6px;--spacing-100:8px;--spacing-125:10px;--spacing-150:12px;--spacing-200:16px;--spacing-250:20px;--spacing-300:24px;--spacing-400:32px;--spacing-500:40px;--spacing-600:48px;--border-radius-none:0px;--border-radius-25:2px;--border-radius-50:4px;--border-radius-100:8px;--border-radius-150:12px;--border-radius-200:16px;--border-radius-300:24px;--border-radius-400:32px;--border-radius-full:9999px;--stroke-width-none:0px;--stroke-width-25:1px;--stroke-width-50:2px;--stroke-width-75:3px;--stroke-width-100:4px;--stroke-width-150:6px;--stroke-width-200:8px;--stroke-width-300:12px;--product-card-widget-min-width:135px;--product-card-results-min-width:250px;--image-set-mode-min-size:155px;--product-card-set-mode-max-width:300px;--source-card-set-mode-max-width:500px;--filter-blur-none:0px;--filter-blur-100:8px;--filter-blur-150:12px;--filter-blur-200:16px;--color-bg-base:#ffffff;--color-bg-inverse:#161616;--color-border-00:#ffffff;--color-border-01:#f4f4f4;--color-border-02:#e0e0e0;--color-border-03:#c6c6c6;--color-border-inverse-00:#161616;--color-border-inverse-01:#393939;--color-field-01:#ffffff;--color-field-02:#f4f4f4;--color-icon-primary:#161616;--color-icon-secondary:#525252;--color-icon-helper:#8d8d8d;--color-icon-on-color:#ffffff;--color-icon-inverse:#ffffff;--color-icon-disabled:#16161640;--color-text-primary:#161616;--color-text-secondary:#525252;--color-text-helper:#8d8d8d;--color-text-placeholder:#a8a8a8;--color-text-on-color:#ffffff;--color-text-inverse:#ffffff;--color-text-disabled:#16161640;--button-bg-color-primary:#000000;--button-bg-color-primary-hover:#161616;--button-bg-color-primary-active:#1e1e1e;--button-bg-color-secondary:#f4f4f4;--button-bg-color-secondary-hover:#e0e0e0;--button-bg-color-secondary-active:#c6c6c6;--button-bg-color-ghost-hover:#f4f4f4;--button-bg-color-ghost-active:#eaeaea;--button-bg-color-frosted:#6f6f6f66;--button-bg-color-frosted-hover:#6f6f6f80;--button-bg-color-frosted-active:#6f6f6f99;--button-bg-color-disabled:#e0e0e0;--button-bg-color-positive:#dcfce7;--surface-bg-color-01:#f4f4f4;--surface-bg-color-01-hover:#eaeaea;--surface-bg-color-01-active:#e0e0e0;--surface-bg-color-02:#ffffff;--surface-bg-color-inverse:#262626;--surface-bg-color-inverse-hover:#303030;--surface-bg-color-inverse-active:#393939;--surface-bg-color-disabled:#e0e0e0;--chip-bg-color-primary:#161616;--chip-bg-color-primary-hover:#1e1e1e;--chip-bg-color-primary-active:#262626;--chip-bg-color-subtle:#f4f4f4;--chip-bg-color-subtle-hover:#eaeaea;--chip-bg-color-subtle-active:#e0e0e0;--chip-bg-color-outline-hover:#f4f4f4;--chip-bg-color-outline-active:#eaeaea;--label-bg-color-accent:#ff3944;}:host{display:block;font-family:var(--font-family, var(--font-family-base));font-style:normal;}:host(.show-in-widget.preview-filters){padding-left:24px}.filters-modal-list,.sub-filters-wrapper,.main-filters-list,.filters-modal-sub-list,.selected-filters-wrapper{list-style:none;margin:0;padding:0}.main-filters-list{padding:var(--spacing-25);gap:var(--spacing-25);border-radius:8px;background:var(--surface-bg-color-01);display:inline-flex}vviinn-price-range{max-width:400px;padding-bottom:var(--spacing-150)}:host(.show-in-widget) vviinn-price-range{max-width:unset}.filters-modal-main-button,.filters-sub-button,.filters-main-button,.filters-modal-close,.filters-sub-button-selected{font-family:var(--font-family, var(--font-family-base));cursor:pointer;border:none}.filters-sub-button,.filters-main-button{font-size:var(--font-size-body);font-weight:var(--font-weight-400);line-height:var(--line-height-body);letter-spacing:var(--letter-spacing-body);display:flex;justify-content:center;align-items:center;border-radius:6px}.filters-main-button{padding:var(--spacing-100);color:var(--color-text-helper);background:none;transition:background 0.15s,\n color 0.15s}.filters-main-button.active,.filters-main-button:hover{background:var(--surface-bg-color-02);color:var(--color-text-primary)}.sub-filters-wrapper,.selected-filters-wrapper{gap:var(--spacing-100);display:flex;flex-direction:row;overflow-x:auto;scrollbar-width:thin;padding-bottom:6px}.sub-filters-wrapper{align-items:center;gap:var(--spacing-100);margin-top:16px;margin:16px -2px 0}.sub-filters-wrapper>li{padding:2px}.selected-filters-wrapper{margin-top:var(--spacing-125);gap:var(--spacing-100);flex-wrap:wrap}:host(.show-in-widget.preview-filters) .selected-filters-wrapper{flex-wrap:unset;overflow-x:auto}:host(.show-in-widget.preview-filters) .sub-filters-wrapper,:host(.show-in-widget.preview-filters) .selected-filters-wrapper{transform:translateX(-24px);padding-left:var(--spacing-300);padding-right:var(--spacing-300);width:100%}.filters-sub-button{color:var(--color-text-primary);background:var(--surface-bg-color-01);padding:var(--spacing-100);gap:var(--spacing-25);height:100%}.filters-sub-button>span,.filters-sub-button-selected>span{display:inline-flex;justify-content:center;align-items:center;gap:var(--spacing-25);white-space:nowrap}.filters-sub-button>span>span,.filters-sub-button-selected>span>span{padding:var(--spacing-25)}.filters-sub-button:hover{background:var(--surface-bg-color-01-hover)}.filters-sub-button:disabled{cursor:not-allowed;background:var(--surface-bg-color-disabled);color:var(--color-text-disabled)}.filters-more-button{display:flex;padding:var(--spacing-100);gap:var(--spacing-50);border-radius:var(--border-radius-100);align-items:flex-start;background-color:var(--button-bg-color-secondary);transition:background-color 0.1s;border:none;cursor:pointer}.filters-more-button:hover{background-color:var(--button-bg-color-secondary-hover)}.filters-modal-wrapper{display:flex;flex-direction:column;background:#ffffff}.filters-modal.button,.filters-modal.modal{display:none;position:fixed;top:0;bottom:0;right:0;left:0;z-index:99999;background-color:rgba(0, 0, 0, 0.5)}.filters-modal.button .filters-modal-wrapper{position:fixed;top:0;bottom:0;right:0;width:420px;z-index:99999;border-radius:var(--border-radius-400) var(--border-radius-none)\n var(--border-radius-none) var(--border-radius-400)}.filters-modal.preview{display:block}.filters-modal.open{display:block}.filters-modal-header{position:relative;padding:var(--spacing-200) 0;color:var(--color-text-primary);text-align:center;font-size:var(--font-size-headline);font-weight:var(--font-weight-500);line-height:var(--line-height-headline);letter-spacing:var(--letter-spacing-headline);border-bottom:1px solid var(--color-border-01);display:flex;justify-content:center;gap:5px}.filters-modal-main{overflow-y:auto;scrolbar-width:thin}.filters-modal-list{margin:var(--spacing-50) 0 0 var(--spacing-300)}.filters-modal-list>li{padding-right:var(--spacing-300)}.filters-modal-list>li:not(:last-child) .filters-modal-main-button-wrapper{border-bottom:1px solid var(--color-border-01)}.filters-modal-main-button{width:100%;background:none;text-align:left;padding:var(--spacing-200) 0;color:var(--color-text-primary);font-size:var(--font-size-label-large);font-weight:var(--font-weight-500);line-height:var(--line-height-label-large);letter-spacing:var(--letter-spacing-label-large)}.filters-modal-sub-list{display:none}.filters-modal-sub-list.open{display:flex;align-items:center;flex-wrap:wrap;gap:8px;padding-bottom:var(--spacing-150)}.filters-modal-sub-list>li{display:contents}.filters-modal-close{position:absolute;color:#6f6f6f;right:var(--spacing-100);top:var(--spacing-200);cursor:pointer;background:none}.filters-modal-close:hover{color:#000}.filters-modal.preview .filters-modal-close{display:none}.filters-more-modal-button{background:none;border:none;cursor:pointer;display:flex;padding:var(--spacing-100);align-items:center;gap:var(--spacing-25);border-radius:var(--border-radius-100);background-color:var(--surface-bg-color-01);transition:background-color 0.1s;font-family:var(--font-family, var(--font-family-base));font-size:var(--font-size-label);color:var(--color-text-primary)}.filters-more-modal-button:hover{background-color:var(--surface-bg-color-01-hover)}.filters-more-modal-button.active{background:var(--surface-bg-color-inverse);color:var(--color-text-inverse)}.filters-more-modal-button>span{display:flex;align-items:center;justify-content:center;gap:var(--spacing-25)}.filters-more-modal-button>span>span{white-space:nowrap;padding:var(--spacing-25)}.filters-more-modal-button:disabled{cursor:not-allowed;opacity:0.5}.filters-modal-actions{border-top:1px solid var(--color-border-01);padding:var(--spacing-125);z-index:10;border-radius:0px 0px 0px 32px}.filters-modal-apply,.filters-modal-reset{font-family:var(--font-family, var(--font-family-base))}.filters-modal-apply{cursor:pointer;width:100%;border:none;margin-bottom:20px;display:flex;padding:var(--spacing-150);justify-content:center;align-items:center;gap:var(--spacing-50);align-self:stretch;color:var(--color-text-inverse);text-align:center;border-radius:var(--border-radius-150);background:var(--button-bg-color-primary);font-size:var(--font-size-label-large);font-weight:var(--font-weight-500);line-height:var(--line-height-label-large);letter-spacing:var(--letter-spacing-label-large)}.filters-modal-apply:disabled{background:var(--button-bg-color-disabled);color:var(--color-text-disabled)}.filters-modal-reset{background:none;border:none;cursor:pointer;display:block;text-align:center;width:100%;padding:var(--spacing-125) 0;color:var(--color-text-secondary);text-align:center;font-size:var(--font-size-label);font-weight:var(--font-weight-500);line-height:var(--line-height-label);letter-spacing:var(--letter-spacing-label)}.filters-modal-reset:hover{color:var(--color-text-primary)}.selected-filters-wrapper>li .filters-sub-button-selected{border-radius:var(--border-radius-100);background:var(--surface-bg-color-inverse);display:flex;align-items:center;justify-content:center;cursor:pointer;padding:var(--spacing-100)}.filters-sub-button-selected{display:flex;align-items:center;gap:var(--spacing-25);background:var(--surface-bg-color-inverse);border-radius:var(--border-radius-100);color:var(--color-text-inverse);text-overflow:ellipsis;font-size:var(--font-size-body);font-weight:var(--font-weight-400);line-height:var(--line-height-body);letter-spacing:var(--letter-spacing-body);padding:var(--spacing-100)}.filters-sub-button-color{width:40px;height:40px;border:var(--stroke-width-50) solid var(--color-border-01);border-radius:var(--border-radius-full);display:inline-block;box-sizing:border-box;position:relative}.filters-sub-button-color-dot{position:absolute;left:0;top:0;width:100%;height:100%;border-radius:var(--border-radius-full)}.filters-sub-button-color:disabled{opacity:0.25}.selected-filters-wrapper .filters-sub-button-selected.filters-sub-button-color{width:24px;height:24px;border:none}.filters-sub-button-color>span{display:none}.filters-sub-button-color.active{border:var(--stroke-width-75) solid var(--color-border-inverse-00);background-color:white}.filters-sub-button-color.active .filters-sub-button-color-dot{transform:scale(0.75)}.filters-modal-main-button-added-options{color:var(--color-text-secondary);text-overflow:ellipsis;font-size:var(--font-size-body);font-weight:var(--font-weight-400);line-height:var(--line-height-body);letter-spacing:var(--letter-spacing-body)}.filters-modal-main-button-added-options>span::after{content:\", \"}.filters-modal-main-button-added-options>span:last-child::after{content:\"\"}@media (max-width: 768px){:host(.show-in-widget.preview-filters){padding-right:var(--spacing-300)}.sub-filters-wrapper,.selected-filters-wrapper{flex-wrap:unset;overflow-x:auto;padding-bottom:0}.sub-filters-wrapper,.selected-filters-wrapper{margin-top:16px;-webkit-overflow-scrolling:touch;scrollbar-width:none;-ms-overflow-style:none}.sub-filters-wrapper::-webkit-scrollbar,.selected-filters-wrapper::-webkit-scrollbar{display:none}.filters-modal.button .filters-modal-wrapper,.filters-modal.modal .filters-modal-wrapper{width:100%;border-radius:24px 24px 0px 0px}.filters-modal.button .filters-modal-wrapper{top:10%}.filters-modal.modal .filters-modal-wrapper{position:fixed;width:100%;height:calc(100% - 64px);bottom:0;transform:translateY(-64px)}.filters-modal.modal .filters-modal-header{font-size:var(--font-size-body-large)}.filters-modal.modal .filters-modal-main{padding-bottom:120px}}";
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-711d38e6.js');
|
|
6
|
-
const search_store = require('./search.store-
|
|
6
|
+
const search_store = require('./search.store-f6717a99.js');
|
|
7
7
|
const customizedSlots = require('./customized-slots-93d9f5c9.js');
|
|
8
8
|
const i18next = require('./i18next-74ff3413.js');
|
|
9
9
|
const resources = require('./resources-f8c5d64c.js');
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-711d38e6.js');
|
|
6
6
|
const customizedSlots = require('./customized-slots-93d9f5c9.js');
|
|
7
|
-
const constants = require('./constants-
|
|
7
|
+
const constants = require('./constants-21309688.js');
|
|
8
8
|
|
|
9
9
|
const SearchModalCameraIcon = () => (index.h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none" },
|
|
10
10
|
index.h("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M18 4H20C22.21 4 24 5.79 24 8V16H22V8C22 6.9 21.1 6 20 6H16.93L16.34 5.11L14.93 3H9.07L7.66 5.11L7.07 6H4C2.9 6 2 6.9 2 8V18C2 19.1 2.9 20 4 20H9V22H4C1.79 22 0 20.21 0 18V8C0 5.79 1.79 4 4 4H6L8 1H16L18 4ZM12 8C14.76 8 17 10.24 17 13L16.99 13.01C16.99 14.02 16.68 14.97 16.16 15.76L20.7 20.3L19.29 21.71L14.75 17.17C13.96 17.69 13.02 18 12 18C9.24 18 7 15.76 7 13C7 10.24 9.24 8 12 8ZM9 13C9 14.65 10.35 16 12 16C13.65 16 15 14.65 15 13C15 11.35 13.65 10 12 10C10.35 10 9 11.35 9 13Z", fill: "#161616" })));
|
|
@@ -51,7 +51,7 @@ const VviinnVpsButton = class {
|
|
|
51
51
|
this.excluded = "";
|
|
52
52
|
this.productDetailsNewTab = true;
|
|
53
53
|
this.productDetailsRedirect = true;
|
|
54
|
-
this.imageResolutionWidth =
|
|
54
|
+
this.imageResolutionWidth = constants.SEARCH_WIDGET_IMAGE_RESOLUTION_WIDTH;
|
|
55
55
|
this.exampleImageSource = constants.DEFAULT_EXAMPLE_IMAGE;
|
|
56
56
|
this.textSearchShow = false;
|
|
57
57
|
this.addToBasketShow = false;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { lanczos } from "@rgba-image/lanczos";
|
|
2
|
-
import { dimensionsFromImage,
|
|
2
|
+
import { dimensionsFromImage, scaleBySide } from "./sizing";
|
|
3
3
|
const createCanvasWithContext = () => {
|
|
4
4
|
const canvas = document.createElement("canvas");
|
|
5
5
|
const contenx = canvas.getContext("2d");
|
|
@@ -13,8 +13,8 @@ const imageDataFromImage = (image) => {
|
|
|
13
13
|
context.drawImage(image, 0, 0);
|
|
14
14
|
return context.getImageData(0, 0, naturalWidth, naturalHeight);
|
|
15
15
|
};
|
|
16
|
-
export const resizeImage = (
|
|
17
|
-
const scale =
|
|
16
|
+
export const resizeImage = (side, i) => {
|
|
17
|
+
const scale = scaleBySide(side, "smallest");
|
|
18
18
|
const [destinationCanvas, destinationContext] = createCanvasWithContext();
|
|
19
19
|
const imageDimensions = dimensionsFromImage(i);
|
|
20
20
|
const [destinationWidth, destinationHeight] = scale(imageDimensions).map((d) => d.size);
|
|
@@ -24,5 +24,5 @@ export const resizeImage = (width, i) => {
|
|
|
24
24
|
destinationCanvas.height = destinationHeight;
|
|
25
25
|
lanczos(originImageData, destinationImageData);
|
|
26
26
|
destinationContext.putImageData(destinationImageData, 0, 0);
|
|
27
|
-
return destinationCanvas.toDataURL();
|
|
27
|
+
return destinationCanvas.toDataURL("image/jpeg", 0.7);
|
|
28
28
|
};
|
|
@@ -20,18 +20,18 @@ const ordByKind = {
|
|
|
20
20
|
return x.kind === y.kind ? 0 : x.kind === "width" ? -1 : 1;
|
|
21
21
|
},
|
|
22
22
|
};
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
23
|
+
const sortDimensionsBySize = sort(ordBySize);
|
|
24
|
+
const sortDimensionsByKind = sort(ordByKind);
|
|
25
|
+
const getDimensionsRatio = (sortedDimensions) => {
|
|
26
26
|
const [smallest, largest] = sortedDimensions;
|
|
27
27
|
return smallest.size / largest.size;
|
|
28
28
|
};
|
|
29
|
-
export const
|
|
30
|
-
const sortedDimensions =
|
|
31
|
-
const ratio =
|
|
32
|
-
const newSmallestSide = Object.assign(Object.assign({}, sortedDimensions[0]), { size: toSize * ratio });
|
|
33
|
-
const newLargestSide = Object.assign(Object.assign({}, sortedDimensions[1]), { size: toSize });
|
|
34
|
-
return
|
|
29
|
+
export const scaleBySide = (toSize, comparedSide) => (dimensions) => {
|
|
30
|
+
const sortedDimensions = sortDimensionsBySize(dimensions);
|
|
31
|
+
const ratio = getDimensionsRatio(sortedDimensions);
|
|
32
|
+
const newSmallestSide = Object.assign(Object.assign({}, sortedDimensions[0]), { size: comparedSide === "smallest" ? toSize : toSize * ratio });
|
|
33
|
+
const newLargestSide = Object.assign(Object.assign({}, sortedDimensions[1]), { size: comparedSide === "largest" ? toSize : toSize / ratio });
|
|
34
|
+
return sortDimensionsByKind([newLargestSide, newSmallestSide]);
|
|
35
35
|
};
|
|
36
36
|
export const dimensionsFromImage = (image) => {
|
|
37
37
|
const { naturalWidth, naturalHeight } = image;
|
|
@@ -39,7 +39,7 @@ export const dimensionsFromImage = (image) => {
|
|
|
39
39
|
};
|
|
40
40
|
export const getImageSizes = (i, defaultImageSize) => {
|
|
41
41
|
const dimensions = dimensionsFromImage(i);
|
|
42
|
-
const resize =
|
|
42
|
+
const resize = scaleBySide(defaultImageSize, "largest");
|
|
43
43
|
const newDimensions = resize(dimensions);
|
|
44
44
|
const sizes = newDimensions.map((d) => d.size);
|
|
45
45
|
return [sizes[0], sizes[1]];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
describe("Image sizing utils", () => {
|
|
1
|
+
import { scaleBySide } from "./sizing";
|
|
2
|
+
describe("Image sizing utils, smallest side resizing", () => {
|
|
3
3
|
it("should resize correctly if width > height", () => {
|
|
4
4
|
const w = {
|
|
5
5
|
kind: "width",
|
|
@@ -11,13 +11,13 @@ describe("Image sizing utils", () => {
|
|
|
11
11
|
};
|
|
12
12
|
const expectedWidth = {
|
|
13
13
|
kind: "width",
|
|
14
|
-
size:
|
|
14
|
+
size: 300,
|
|
15
15
|
};
|
|
16
16
|
const expectedHeight = {
|
|
17
17
|
kind: "height",
|
|
18
|
-
size:
|
|
18
|
+
size: 150,
|
|
19
19
|
};
|
|
20
|
-
const scaleDimensions =
|
|
20
|
+
const scaleDimensions = scaleBySide(150, "smallest");
|
|
21
21
|
const result = scaleDimensions([w, h]);
|
|
22
22
|
expect(result).toStrictEqual([expectedWidth, expectedHeight]);
|
|
23
23
|
});
|
|
@@ -32,13 +32,13 @@ describe("Image sizing utils", () => {
|
|
|
32
32
|
};
|
|
33
33
|
const expectedWidth = {
|
|
34
34
|
kind: "width",
|
|
35
|
-
size:
|
|
35
|
+
size: 200,
|
|
36
36
|
};
|
|
37
37
|
const expectedHeight = {
|
|
38
38
|
kind: "height",
|
|
39
|
-
size:
|
|
39
|
+
size: 400,
|
|
40
40
|
};
|
|
41
|
-
const scaleDimensions =
|
|
41
|
+
const scaleDimensions = scaleBySide(200, "smallest");
|
|
42
42
|
const result = scaleDimensions([w, h]);
|
|
43
43
|
expect(result).toStrictEqual([expectedWidth, expectedHeight]);
|
|
44
44
|
});
|
|
@@ -59,7 +59,72 @@ describe("Image sizing utils", () => {
|
|
|
59
59
|
kind: "height",
|
|
60
60
|
size: 500,
|
|
61
61
|
};
|
|
62
|
-
const scaleDimensions =
|
|
62
|
+
const scaleDimensions = scaleBySide(500, "smallest");
|
|
63
|
+
const result = scaleDimensions([w, h]);
|
|
64
|
+
expect(result).toStrictEqual([expectedWidth, expectedHeight]);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
describe("Image sizing utils, largest side resizing", () => {
|
|
68
|
+
it("should resize correctly if width > height", () => {
|
|
69
|
+
const w = {
|
|
70
|
+
kind: "width",
|
|
71
|
+
size: 600,
|
|
72
|
+
};
|
|
73
|
+
const h = {
|
|
74
|
+
kind: "height",
|
|
75
|
+
size: 300,
|
|
76
|
+
};
|
|
77
|
+
const expectedWidth = {
|
|
78
|
+
kind: "width",
|
|
79
|
+
size: 400,
|
|
80
|
+
};
|
|
81
|
+
const expectedHeight = {
|
|
82
|
+
kind: "height",
|
|
83
|
+
size: 200,
|
|
84
|
+
};
|
|
85
|
+
const scaleDimensions = scaleBySide(400, "largest");
|
|
86
|
+
const result = scaleDimensions([w, h]);
|
|
87
|
+
expect(result).toStrictEqual([expectedWidth, expectedHeight]);
|
|
88
|
+
});
|
|
89
|
+
it("should resize correctly if width < height", () => {
|
|
90
|
+
const w = {
|
|
91
|
+
kind: "width",
|
|
92
|
+
size: 300,
|
|
93
|
+
};
|
|
94
|
+
const h = {
|
|
95
|
+
kind: "height",
|
|
96
|
+
size: 600,
|
|
97
|
+
};
|
|
98
|
+
const expectedWidth = {
|
|
99
|
+
kind: "width",
|
|
100
|
+
size: 200,
|
|
101
|
+
};
|
|
102
|
+
const expectedHeight = {
|
|
103
|
+
kind: "height",
|
|
104
|
+
size: 400,
|
|
105
|
+
};
|
|
106
|
+
const scaleDimensions = scaleBySide(400, "largest");
|
|
107
|
+
const result = scaleDimensions([w, h]);
|
|
108
|
+
expect(result).toStrictEqual([expectedWidth, expectedHeight]);
|
|
109
|
+
});
|
|
110
|
+
it("should resize correctly if width == height", () => {
|
|
111
|
+
const w = {
|
|
112
|
+
kind: "width",
|
|
113
|
+
size: 600,
|
|
114
|
+
};
|
|
115
|
+
const h = {
|
|
116
|
+
kind: "height",
|
|
117
|
+
size: 600,
|
|
118
|
+
};
|
|
119
|
+
const expectedWidth = {
|
|
120
|
+
kind: "width",
|
|
121
|
+
size: 400,
|
|
122
|
+
};
|
|
123
|
+
const expectedHeight = {
|
|
124
|
+
kind: "height",
|
|
125
|
+
size: 400,
|
|
126
|
+
};
|
|
127
|
+
const scaleDimensions = scaleBySide(400, "largest");
|
|
63
128
|
const result = scaleDimensions([w, h]);
|
|
64
129
|
expect(result).toStrictEqual([expectedWidth, expectedHeight]);
|
|
65
130
|
});
|
|
@@ -6,12 +6,14 @@ export const toFile = async (b64data) => {
|
|
|
6
6
|
lastModified: Date.now(),
|
|
7
7
|
});
|
|
8
8
|
};
|
|
9
|
-
export const convertB64toFileTask = (b64data) => () =>
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
export const convertB64toFileTask = (b64data) => () => {
|
|
10
|
+
return new Promise(async (resolve, _) => {
|
|
11
|
+
const request = await fetch(b64data);
|
|
12
|
+
const blob = await request.blob();
|
|
13
|
+
const file = new File([blob], "image", {
|
|
14
|
+
type: blob.type,
|
|
15
|
+
lastModified: Date.now(),
|
|
16
|
+
});
|
|
17
|
+
resolve(file);
|
|
15
18
|
});
|
|
16
|
-
|
|
17
|
-
});
|
|
19
|
+
};
|
|
@@ -26,6 +26,7 @@ import { productCardSlotNames, slotChangeListener, vprIconSlotName, } from "../c
|
|
|
26
26
|
import { getCustomLabels } from "../../recommendation";
|
|
27
27
|
import { productCardParts } from "../../cssParts";
|
|
28
28
|
import { findSlotElements, getSlotNames } from "../../dom";
|
|
29
|
+
import { RESULTS_WIDGET_IMAGE_RESOLUTION_WIDTH } from "../../widget/constants";
|
|
29
30
|
export class VviinnResults {
|
|
30
31
|
constructor() {
|
|
31
32
|
var _a;
|
|
@@ -125,7 +126,7 @@ export class VviinnResults {
|
|
|
125
126
|
this.token = undefined;
|
|
126
127
|
this.searchId = undefined;
|
|
127
128
|
this.uiSessionId = undefined;
|
|
128
|
-
this.imageResolutionWidth =
|
|
129
|
+
this.imageResolutionWidth = RESULTS_WIDGET_IMAGE_RESOLUTION_WIDTH;
|
|
129
130
|
this.currencySign = "€";
|
|
130
131
|
this.locale = "de-DE";
|
|
131
132
|
this.productDetailsNewTab = false;
|
|
@@ -459,7 +460,7 @@ export class VviinnResults {
|
|
|
459
460
|
},
|
|
460
461
|
"attribute": "image-resolution-width",
|
|
461
462
|
"reflect": false,
|
|
462
|
-
"defaultValue": "
|
|
463
|
+
"defaultValue": "RESULTS_WIDGET_IMAGE_RESOLUTION_WIDTH"
|
|
463
464
|
},
|
|
464
465
|
"currencySign": {
|
|
465
466
|
"type": "string",
|
|
@@ -3,6 +3,7 @@ import { SearchModalCameraIcon, SearchModalFullSearchIcon, SearchModalImageSearc
|
|
|
3
3
|
import { SlotSkeleton } from "../customized-slots";
|
|
4
4
|
import { DEFAULT_EXAMPLE_IMAGE } from "../../assets/constants";
|
|
5
5
|
import { findSlotElements } from "../../dom";
|
|
6
|
+
import { SEARCH_WIDGET_IMAGE_RESOLUTION_WIDTH } from "../../widget/constants";
|
|
6
7
|
/**
|
|
7
8
|
* @slot vviinn-teaser-text - Text on the widget's main screen.
|
|
8
9
|
* @slot vviinn-image-upload-button-text - Title of Upload Button.
|
|
@@ -70,7 +71,7 @@ export class VviinnVpsButton {
|
|
|
70
71
|
this.excluded = "";
|
|
71
72
|
this.productDetailsNewTab = true;
|
|
72
73
|
this.productDetailsRedirect = true;
|
|
73
|
-
this.imageResolutionWidth =
|
|
74
|
+
this.imageResolutionWidth = SEARCH_WIDGET_IMAGE_RESOLUTION_WIDTH;
|
|
74
75
|
this.exampleImageSource = DEFAULT_EXAMPLE_IMAGE;
|
|
75
76
|
this.textSearchShow = false;
|
|
76
77
|
this.addToBasketShow = false;
|
|
@@ -320,7 +321,7 @@ export class VviinnVpsButton {
|
|
|
320
321
|
},
|
|
321
322
|
"attribute": "image-resolution-width",
|
|
322
323
|
"reflect": false,
|
|
323
|
-
"defaultValue": "
|
|
324
|
+
"defaultValue": "SEARCH_WIDGET_IMAGE_RESOLUTION_WIDTH"
|
|
324
325
|
},
|
|
325
326
|
"exampleImageSource": {
|
|
326
327
|
"type": "string",
|
|
@@ -29,6 +29,7 @@ import { videoStreamSettings } from "../../video/settings";
|
|
|
29
29
|
import { checkDeviceType } from "../../helpers";
|
|
30
30
|
import { extendedFiltersParts, filtersParts, modalParts, productCardParts, searchBarParts, searchWidgetButtonParts, searchWidgetFilterParts, } from "../../cssParts";
|
|
31
31
|
import { findSlotElements } from "../../dom";
|
|
32
|
+
import { SEARCH_WIDGET_IMAGE_RESOLUTION_WIDTH } from "../../widget/constants";
|
|
32
33
|
const CAMERA_START_DELAY = 500;
|
|
33
34
|
/**
|
|
34
35
|
* @slot vviinn-teaser-text - Text on the widget's main screen.
|
|
@@ -218,7 +219,7 @@ export class VviinnVpsWidget {
|
|
|
218
219
|
this.excluded = "";
|
|
219
220
|
this.productDetailsNewTab = true;
|
|
220
221
|
this.productDetailsRedirect = true;
|
|
221
|
-
this.imageResolutionWidth =
|
|
222
|
+
this.imageResolutionWidth = SEARCH_WIDGET_IMAGE_RESOLUTION_WIDTH;
|
|
222
223
|
this.exampleImageSource = DEFAULT_EXAMPLE_IMAGE;
|
|
223
224
|
this.textSearchShow = false;
|
|
224
225
|
this.addToBasketShow = false;
|
|
@@ -464,7 +465,7 @@ export class VviinnVpsWidget {
|
|
|
464
465
|
}), class: { invisible: this.haveErrors() } }))), h("vviinn-slide", { class: {
|
|
465
466
|
"results-page": true,
|
|
466
467
|
active: this.isResultSlide(),
|
|
467
|
-
} }, this.isResultSlide() && this.state.searchType === "image" && (h("div", { class: "source-wrapper image-wrapper" }, h("vviinn-cropper", { basicEventData: this.getBasicEventData(), showAspectRatioError: this.showAspectRatioError, showInWidget: true }), h("div", { class: {
|
|
468
|
+
} }, this.isResultSlide() && this.state.searchType === "image" && (h("div", { class: "source-wrapper image-wrapper" }, h("vviinn-cropper", { basicEventData: this.getBasicEventData(), showAspectRatioError: this.showAspectRatioError, apiPath: this.apiPath, showInWidget: true }), h("div", { class: {
|
|
468
469
|
"filters-wrapper": true,
|
|
469
470
|
hidden: this.showAspectRatioError,
|
|
470
471
|
} }, h("div", { class: "filters" }, this.state.filters.map((filter) => (h("search-filters", { filter: filter, basicEventData: this.getBasicEventData() }))))))), this.isResultSlide() && this.state.searchType === "text" && (h("div", { class: "source-wrapper text-search-wrapper" }, h("vviinn-text-search", { token: this.token, showInWidget: true, searchQuery: this.searchQuery, apiPath: this.apiPath, locale: this.locale }), h("div", { class: {
|
|
@@ -650,7 +651,7 @@ export class VviinnVpsWidget {
|
|
|
650
651
|
},
|
|
651
652
|
"attribute": "image-resolution-width",
|
|
652
653
|
"reflect": false,
|
|
653
|
-
"defaultValue": "
|
|
654
|
+
"defaultValue": "SEARCH_WIDGET_IMAGE_RESOLUTION_WIDTH"
|
|
654
655
|
},
|
|
655
656
|
"exampleImageSource": {
|
|
656
657
|
"type": "string",
|
|
@@ -9,5 +9,8 @@ import { resizeImage } from "../Image/resizeImage";
|
|
|
9
9
|
import { convertB64toFileTask } from "../Image/toFile";
|
|
10
10
|
import { imageToB64 } from "../Image/imageToB64";
|
|
11
11
|
export const checkFileWithExtention = (file) => pipe(file, O.fromNullable, E.fromOption(() => fileDoesntExistError), E.chain(checkImageType));
|
|
12
|
-
const optionalResize = (image, size) =>
|
|
12
|
+
const optionalResize = (image, size) => {
|
|
13
|
+
const smallestSide = Math.min(image.naturalWidth, image.naturalHeight);
|
|
14
|
+
return smallestSide > size ? resizeImage(size, image) : imageToB64(image);
|
|
15
|
+
};
|
|
13
16
|
export const resizeFileTo = (size) => (file) => pipe(file, imageFromFileTask, T.map((image) => optionalResize(image, size)), T.chain(convertB64toFileTask));
|