vviinn-widgets 2.44.2 → 2.46.0
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/VisualSearchIcon-1180d079.js +8 -0
- package/dist/cjs/{customized-slots-49c03dc1.js → customized-slots-1b59bd38.js} +1 -0
- package/dist/cjs/{index-7ff2ab5f.js → index-279a6a0f.js} +75 -75
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{package-5912f89d.js → package-3b910c03.js} +1 -1
- package/dist/cjs/{search-filters_16.cjs.entry.js → search-filters_17.cjs.entry.js} +116 -55
- package/dist/cjs/{imageSearch.store-dc4e98b3.js → search.store-0b319593.js} +55 -21
- package/dist/cjs/vviinn-button.cjs.entry.js +2 -2
- package/dist/cjs/vviinn-carousel_4.cjs.entry.js +60 -51
- package/dist/cjs/vviinn-preloader.cjs.entry.js +2 -2
- package/dist/cjs/vviinn-recommendations-sidebar.cjs.entry.js +4 -2
- package/dist/cjs/vviinn-vpr-button.cjs.entry.js +3 -3
- package/dist/cjs/vviinn-vps-button.cjs.entry.js +7 -4
- package/dist/cjs/vviinn-vps-widget.cjs.entry.js +65 -40
- package/dist/cjs/vviinn-widgets.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/customized-slots.js +1 -0
- package/dist/collection/components/image-search/search-filters/search-filters.js +5 -5
- package/dist/collection/components/vviinn-error/vviinn-empty-results/vviinn-empty-results.js +2 -1
- package/dist/collection/components/vviinn-example-image/vviinn-example-image.js +1 -1
- package/dist/collection/components/vviinn-icons/icons/ArrowIcon.js +2 -0
- package/dist/collection/components/vviinn-icons/icons/BasketIcon.js +2 -0
- package/dist/collection/components/vviinn-icons/icons/CameraActionIcon.js +2 -0
- package/dist/collection/components/vviinn-icons/icons/CameraIcon.js +2 -0
- package/dist/collection/components/vviinn-icons/icons/CheckCircleIcon.js +2 -0
- package/dist/collection/components/vviinn-icons/icons/CheckIcon.js +2 -0
- package/dist/collection/components/vviinn-icons/icons/ChevronIcon.js +2 -0
- package/dist/collection/components/vviinn-icons/icons/CloseIcon.js +2 -0
- package/dist/collection/components/vviinn-icons/icons/CrossIcon.js +2 -0
- package/dist/collection/components/vviinn-icons/icons/GalleryActionIcon.js +2 -0
- package/dist/collection/components/vviinn-icons/icons/LoaderIcon.js +2 -0
- package/dist/collection/components/vviinn-icons/icons/MinusIcon.js +2 -0
- package/dist/collection/components/vviinn-icons/icons/PlusIcon.js +2 -0
- package/dist/collection/components/vviinn-icons/icons/RoundCameraIcon.js +2 -0
- package/dist/collection/components/vviinn-icons/icons/SecondaryActionIcon.js +2 -0
- package/dist/collection/components/vviinn-icons/icons/TextSearchIcon.js +2 -0
- package/dist/collection/components/vviinn-icons/icons/UpdateIcon.js +2 -0
- package/dist/collection/components/vviinn-icons/icons/UploadActionIcon.js +2 -0
- package/dist/collection/components/vviinn-icons/icons/VisualSearchIcon.js +2 -0
- package/dist/collection/components/vviinn-icons/icons/WarningIcon.js +2 -0
- package/dist/collection/components/vviinn-icons/index.js +20 -18
- package/dist/collection/components/vviinn-image-selector/vviinn-image-selector.js +1 -1
- package/dist/collection/components/vviinn-image-view/vviinn-detected-object/vviinn-detected-object.js +7 -7
- package/dist/collection/components/vviinn-image-view/vviinn-image-view.js +7 -8
- package/dist/collection/components/vviinn-modal/vviinn-modal.js +2 -2
- package/dist/collection/components/vviinn-preloader/vviinn-preloader.js +2 -2
- package/dist/collection/components/vviinn-privacy-badge/vviinn-privacy-badge.css +1 -0
- package/dist/collection/components/vviinn-product-card/vviinn-product-card.js +2 -2
- package/dist/collection/components/vviinn-text-search/vviinn-text-search.css +63 -0
- package/dist/collection/components/vviinn-text-search/vviinn-text-search.js +118 -0
- package/dist/collection/components/vviinn-vpr-widget/vviinn-vpr-vidget.js +7 -4
- package/dist/collection/components/vviinn-vps-button/stories/vviinn-vps-button.stories.js +2 -0
- package/dist/collection/components/vviinn-vps-button/vviinn-vps-button.js +20 -1
- package/dist/collection/components/vviinn-vps-widget/stories/vviinn-vps-widget.stories.js +2 -0
- package/dist/collection/components/vviinn-vps-widget/vviinn-vps-widget.css +15 -1
- package/dist/collection/components/vviinn-vps-widget/vviinn-vps-widget.js +77 -31
- package/dist/collection/locale/resources-vps.js +2 -0
- package/dist/collection/network/request.js +1 -1
- package/dist/collection/searchSession/searchSession.js +5 -10
- package/dist/collection/store/{imageSearch.store.js → search.store.js} +34 -5
- package/dist/esm/VisualSearchIcon-13f7da6a.js +6 -0
- package/dist/esm/{customized-slots-9a9f8c20.js → customized-slots-3bea41d2.js} +1 -0
- package/dist/esm/{index-53105ad4.js → index-9c15b8f1.js} +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{package-b2424850.js → package-cae9f186.js} +1 -1
- package/dist/esm/{search-filters_16.entry.js → search-filters_17.entry.js} +85 -25
- package/dist/esm/{imageSearch.store-c0f2a178.js → search.store-5eebcfbe.js} +54 -21
- package/dist/esm/vviinn-button.entry.js +1 -1
- package/dist/esm/vviinn-carousel_4.entry.js +19 -10
- package/dist/esm/vviinn-preloader.entry.js +2 -2
- package/dist/esm/vviinn-recommendations-sidebar.entry.js +4 -2
- package/dist/esm/vviinn-vpr-button.entry.js +2 -2
- package/dist/esm/vviinn-vps-button.entry.js +8 -5
- package/dist/esm/vviinn-vps-widget.entry.js +61 -36
- package/dist/esm/vviinn-widgets.js +1 -1
- package/dist/types/components/vviinn-icons/icons/ArrowIcon.d.ts +1 -0
- package/dist/types/components/vviinn-icons/icons/BasketIcon.d.ts +1 -0
- package/dist/types/components/vviinn-icons/icons/CameraActionIcon.d.ts +1 -0
- package/dist/types/components/vviinn-icons/icons/CameraIcon.d.ts +1 -0
- package/dist/types/components/vviinn-icons/icons/CheckCircleIcon.d.ts +1 -0
- package/dist/types/components/vviinn-icons/icons/CheckIcon.d.ts +1 -0
- package/dist/types/components/vviinn-icons/icons/ChevronIcon.d.ts +1 -0
- package/dist/types/components/vviinn-icons/icons/CloseIcon.d.ts +1 -0
- package/dist/types/components/vviinn-icons/icons/CrossIcon.d.ts +1 -0
- package/dist/types/components/vviinn-icons/icons/GalleryActionIcon.d.ts +1 -0
- package/dist/types/components/vviinn-icons/icons/LoaderIcon.d.ts +1 -0
- package/dist/types/components/vviinn-icons/icons/MinusIcon.d.ts +1 -0
- package/dist/types/components/vviinn-icons/icons/PlusIcon.d.ts +1 -0
- package/dist/types/components/vviinn-icons/icons/RoundCameraIcon.d.ts +1 -0
- package/dist/types/components/vviinn-icons/icons/SecondaryActionIcon.d.ts +1 -0
- package/dist/types/components/vviinn-icons/icons/TextSearchIcon.d.ts +1 -0
- package/dist/types/components/vviinn-icons/icons/UpdateIcon.d.ts +1 -0
- package/dist/types/components/vviinn-icons/icons/UploadActionIcon.d.ts +1 -0
- package/dist/types/components/vviinn-icons/icons/VisualSearchIcon.d.ts +1 -0
- package/dist/types/components/vviinn-icons/icons/WarningIcon.d.ts +1 -0
- package/dist/types/components/vviinn-icons/index.d.ts +20 -17
- package/dist/types/components/vviinn-text-search/vviinn-text-search.d.ts +18 -0
- package/dist/types/components/vviinn-vpr-widget/vviinn-vpr-vidget.d.ts +1 -0
- package/dist/types/components/vviinn-vps-button/vviinn-vps-button.d.ts +2 -0
- package/dist/types/components/vviinn-vps-widget/vviinn-vps-widget.d.ts +9 -0
- package/dist/types/components.d.ts +37 -0
- package/dist/types/network/request.d.ts +1 -1
- package/dist/types/searchSession/searchSession.d.ts +17 -3
- package/dist/types/store/{imageSearch.store.d.ts → search.store.d.ts} +6 -4
- package/{www/build/p-987a8e9f.js → dist/vviinn-widgets/p-04cdf7c5.js} +1 -1
- package/dist/vviinn-widgets/{p-7f2c9319.entry.js → p-185e2420.entry.js} +1 -1
- package/dist/vviinn-widgets/p-1a1d85b7.js +1 -0
- package/dist/vviinn-widgets/p-3d2759e3.entry.js +1 -0
- package/dist/vviinn-widgets/{p-da7273ce.js → p-41ab810c.js} +1 -1
- package/dist/vviinn-widgets/{p-ed082ecf.entry.js → p-4c726a51.entry.js} +1 -1
- package/dist/vviinn-widgets/p-ae471f24.entry.js +11 -0
- package/dist/vviinn-widgets/p-b21ebac9.js +1 -0
- package/dist/vviinn-widgets/p-c96f5909.entry.js +1 -0
- package/dist/vviinn-widgets/p-d1592ac5.entry.js +1 -0
- package/dist/vviinn-widgets/p-d162fe72.entry.js +1 -0
- package/dist/vviinn-widgets/{p-010b4979.entry.js → p-ec7b07a0.entry.js} +1 -1
- package/dist/vviinn-widgets/p-ed482314.js +1 -0
- package/dist/vviinn-widgets/vviinn-widgets.esm.js +1 -1
- package/package.json +1 -1
- package/{dist/vviinn-widgets/p-987a8e9f.js → www/build/p-04cdf7c5.js} +1 -1
- package/www/build/{p-7f2c9319.entry.js → p-185e2420.entry.js} +1 -1
- package/www/build/p-1a1d85b7.js +1 -0
- package/www/build/p-3d2759e3.entry.js +1 -0
- package/www/build/{p-da7273ce.js → p-41ab810c.js} +1 -1
- package/www/build/{p-ed082ecf.entry.js → p-4c726a51.entry.js} +1 -1
- package/www/build/p-ae471f24.entry.js +11 -0
- package/www/build/p-b21ebac9.js +1 -0
- package/www/build/p-c96f5909.entry.js +1 -0
- package/www/build/p-d1592ac5.entry.js +1 -0
- package/www/build/p-d162fe72.entry.js +1 -0
- package/www/build/{p-010b4979.entry.js → p-ec7b07a0.entry.js} +1 -1
- package/www/build/p-ed482314.js +1 -0
- package/www/build/vviinn-widgets.esm.js +1 -1
- package/dist/cjs/index-28052f80.js +0 -48
- package/dist/esm/index-ac58a953.js +0 -34
- package/dist/vviinn-widgets/p-044c5f45.entry.js +0 -1
- package/dist/vviinn-widgets/p-726774f9.js +0 -1
- package/dist/vviinn-widgets/p-7f19baa1.js +0 -1
- package/dist/vviinn-widgets/p-a7cc44b3.entry.js +0 -1
- package/dist/vviinn-widgets/p-ab938400.entry.js +0 -1
- package/dist/vviinn-widgets/p-b1e9dd46.entry.js +0 -1
- package/dist/vviinn-widgets/p-c8ef8d6c.js +0 -1
- package/dist/vviinn-widgets/p-ecd1c141.entry.js +0 -11
- package/www/build/p-044c5f45.entry.js +0 -1
- package/www/build/p-726774f9.js +0 -1
- package/www/build/p-7f19baa1.js +0 -1
- package/www/build/p-a7cc44b3.entry.js +0 -1
- package/www/build/p-ab938400.entry.js +0 -1
- package/www/build/p-b1e9dd46.entry.js +0 -1
- package/www/build/p-c8ef8d6c.js +0 -1
- package/www/build/p-ecd1c141.entry.js +0 -11
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
1
|
+
export { ArrowIcon } from "./icons/ArrowIcon";
|
|
2
|
+
export { BasketIcon } from "./icons/BasketIcon";
|
|
3
|
+
export { CameraActionIcon } from "./icons/CameraActionIcon";
|
|
4
|
+
export { CameraIcon } from "./icons/CameraIcon";
|
|
5
|
+
export { CheckCircleIcon } from "./icons/CheckCircleIcon";
|
|
6
|
+
export { CheckIcon } from "./icons/CheckIcon";
|
|
7
|
+
export { ChevronIcon } from "./icons/ChevronIcon";
|
|
8
|
+
export { CloseIcon } from "./icons/CloseIcon";
|
|
9
|
+
export { CrossIcon } from "./icons/CrossIcon";
|
|
10
|
+
export { GalleryActionIcon } from "./icons/GalleryActionIcon";
|
|
11
|
+
export { LoaderIcon } from "./icons/LoaderIcon";
|
|
12
|
+
export { MinusIcon } from "./icons/MinusIcon";
|
|
13
|
+
export { PlusIcon } from "./icons/PlusIcon";
|
|
14
|
+
export { RoundCameraIcon } from "./icons/RoundCameraIcon";
|
|
15
|
+
export { SecondaryActionIcon } from "./icons/SecondaryActionIcon";
|
|
16
|
+
export { TextSearchIcon } from "./icons/TextSearchIcon";
|
|
17
|
+
export { UpdateIcon } from "./icons/UpdateIcon";
|
|
18
|
+
export { UploadActionIcon } from "./icons/UploadActionIcon";
|
|
19
|
+
export { VisualSearchIcon } from "./icons/VisualSearchIcon";
|
|
20
|
+
export { WarningIcon } from "./icons/WarningIcon";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Host, h, } from "@stencil/core";
|
|
2
2
|
import * as E from "fp-ts/Either";
|
|
3
3
|
import { pipe } from "fp-ts/lib/function";
|
|
4
|
-
import { processSelectedFile } from "../../store/
|
|
4
|
+
import { processSelectedFile } from "../../store/search.store";
|
|
5
5
|
/**
|
|
6
6
|
* @part button - button look and feel
|
|
7
7
|
*/
|
|
@@ -4,7 +4,7 @@ import * as O from "fp-ts/lib/Option";
|
|
|
4
4
|
import { foldValueObject } from "../../../network/ion/ValueObject";
|
|
5
5
|
import { detectedObjectEq, } from "../../../searchSession/searchSession";
|
|
6
6
|
import { fromAlt, scaleWithSized, center } from "../../../geometry/Rectangle";
|
|
7
|
-
import {
|
|
7
|
+
import { searchState, makeRectangularSearchRequest, } from "../../../store/search.store";
|
|
8
8
|
export class VviinnDetectedObject {
|
|
9
9
|
constructor() {
|
|
10
10
|
this.detectedObject = undefined;
|
|
@@ -12,19 +12,19 @@ export class VviinnDetectedObject {
|
|
|
12
12
|
this.position = ["0", "0"];
|
|
13
13
|
}
|
|
14
14
|
getObjectPosition() {
|
|
15
|
-
return pipe(
|
|
15
|
+
return pipe(searchState.imageBounds, O.map((bounds) => {
|
|
16
16
|
const objectRectangle = fromAlt(foldValueObject(this.detectedObject).rectangle);
|
|
17
17
|
const { x, y } = pipe(objectRectangle, scaleWithSized(bounds), center);
|
|
18
18
|
return [`${x}px`, `${y}px`];
|
|
19
19
|
}), O.getOrElse(() => ["0", "0"]));
|
|
20
20
|
}
|
|
21
21
|
selectDetectedObject() {
|
|
22
|
-
pipe(
|
|
22
|
+
pipe(searchState.imageBounds, O.map((bounds) => {
|
|
23
23
|
const rectangle = foldValueObject(this.detectedObject).rectangle;
|
|
24
24
|
const transformedRect = fromAlt(rectangle);
|
|
25
25
|
const scaledRect = scaleWithSized(bounds)(transformedRect);
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
searchState.detectedObject = this.detectedObject;
|
|
27
|
+
searchState.searchArea = O.some(scaledRect);
|
|
28
28
|
}));
|
|
29
29
|
makeRectangularSearchRequest();
|
|
30
30
|
this.vviinnSelectObject.emit(Object.assign(Object.assign({}, this.basicEventData), { detectedObject: this.detectedObject }));
|
|
@@ -32,10 +32,10 @@ export class VviinnDetectedObject {
|
|
|
32
32
|
isActive() {
|
|
33
33
|
if (!this.detectedObject)
|
|
34
34
|
return false;
|
|
35
|
-
if (!
|
|
35
|
+
if (!searchState.detectedObject)
|
|
36
36
|
return false;
|
|
37
37
|
const thisObject = foldValueObject(this.detectedObject);
|
|
38
|
-
const savedObject = foldValueObject(
|
|
38
|
+
const savedObject = foldValueObject(searchState.detectedObject);
|
|
39
39
|
return detectedObjectEq.equals(thisObject, savedObject);
|
|
40
40
|
}
|
|
41
41
|
render() {
|
|
@@ -2,7 +2,7 @@ import { Host, h, } from "@stencil/core";
|
|
|
2
2
|
import { pipe } from "fp-ts/lib/function";
|
|
3
3
|
import * as O from "fp-ts/lib/Option";
|
|
4
4
|
import Cropper from "cropperjs";
|
|
5
|
-
import {
|
|
5
|
+
import { searchState, makeRectangularSearchRequest, } from "../../store/search.store";
|
|
6
6
|
import { sequenceToOption } from "../../utils/option/option";
|
|
7
7
|
import { fromImage } from "../../geometry/Rectangle";
|
|
8
8
|
import { dimensionsFromImage, scaleByLargestSide } from "../../Image/sizing";
|
|
@@ -59,9 +59,9 @@ const ValidateCropBoxData = (cropBoxData) => {
|
|
|
59
59
|
export class VviinnImageView {
|
|
60
60
|
constructor() {
|
|
61
61
|
this.cropEnd = () => {
|
|
62
|
-
|
|
62
|
+
searchState.searchArea = O.some(this.getCropboxData());
|
|
63
63
|
makeRectangularSearchRequest();
|
|
64
|
-
|
|
64
|
+
searchState.detectedObject = undefined;
|
|
65
65
|
this.vviinnImageCrop.emit(this.basicEventData);
|
|
66
66
|
};
|
|
67
67
|
this.basicEventData = undefined;
|
|
@@ -110,8 +110,8 @@ export class VviinnImageView {
|
|
|
110
110
|
width: width - width * INITIAL_CROP_AREA_OFFSET,
|
|
111
111
|
height: height - height * INITIAL_CROP_AREA_OFFSET,
|
|
112
112
|
};
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
searchState.imageBounds = O.some(imageBounds);
|
|
114
|
+
searchState.searchArea = O.some(searchArea);
|
|
115
115
|
if (width / height < SUPPORTED_ASPECT_RATIO ||
|
|
116
116
|
height / width < SUPPORTED_ASPECT_RATIO) {
|
|
117
117
|
this.setShowAspectRatioError(true);
|
|
@@ -131,14 +131,13 @@ export class VviinnImageView {
|
|
|
131
131
|
return (h("vviinn-detected-object", { detectedObject: object, basicEventData: this.basicEventData }));
|
|
132
132
|
}
|
|
133
133
|
renderImage() {
|
|
134
|
-
return pipe(sequenceToOption(
|
|
134
|
+
return pipe(sequenceToOption(searchState.imageUrl, searchState.image), O.map(([url, refImage]) => {
|
|
135
135
|
const [width, height] = getImageSizes(refImage);
|
|
136
136
|
return (h("img", { decoding: "async", width: width, height: height, src: url, draggable: false, onLoad: () => this.loadImage() }));
|
|
137
137
|
}), O.getOrElse(() => null));
|
|
138
138
|
}
|
|
139
139
|
render() {
|
|
140
|
-
return (h(Host, null, h("div", { class: "container" }, h("div", { class: "image-container" }, this.renderImage(),
|
|
141
|
-
imageSearchState.objectDetectionInProgress) &&
|
|
140
|
+
return (h(Host, null, h("div", { class: "container" }, h("div", { class: "image-container" }, this.renderImage(), searchState.detectedObjects.map((o) => this.renderDetectedObject(o))), (searchState.loading || searchState.objectDetectionInProgress) &&
|
|
142
141
|
!this.showAspectRatioError &&
|
|
143
142
|
!this.hidePreloader ? (h("div", { class: "image-preloader" }, h("vviinn-preloader", null))) : null)));
|
|
144
143
|
}
|
|
@@ -2,7 +2,7 @@ import { Host, h, } from "@stencil/core";
|
|
|
2
2
|
import i18next from "i18next";
|
|
3
3
|
import { slotChangeListener } from "../customized-slots";
|
|
4
4
|
import { campaignTypeNames } from "../../campaign/Campaign";
|
|
5
|
-
import {
|
|
5
|
+
import { searchState } from "../../store/search.store";
|
|
6
6
|
import * as O from "fp-ts/lib/Option";
|
|
7
7
|
import { pipe } from "fp-ts/lib/function";
|
|
8
8
|
import { sequenceToOption } from "../../utils/option/option";
|
|
@@ -43,7 +43,7 @@ export class VviinnModal {
|
|
|
43
43
|
this.slider = true;
|
|
44
44
|
}
|
|
45
45
|
renderImage() {
|
|
46
|
-
return pipe(sequenceToOption(
|
|
46
|
+
return pipe(sequenceToOption(searchState.imageUrl, searchState.image), O.map(([url]) => {
|
|
47
47
|
const image = (h("img", { width: "28", height: "28", src: url, class: "title-image" }));
|
|
48
48
|
return image;
|
|
49
49
|
}), O.getOrElse(() => null));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Host, h } from "@stencil/core";
|
|
2
|
-
import {
|
|
2
|
+
import { searchState } from "../../store/search.store";
|
|
3
3
|
export class VviinnPreloader {
|
|
4
4
|
isActive() {
|
|
5
|
-
return
|
|
5
|
+
return searchState.loading || searchState.objectDetectionInProgress;
|
|
6
6
|
}
|
|
7
7
|
render() {
|
|
8
8
|
return (h(Host, { class: {
|
|
@@ -4,7 +4,7 @@ import { getAnalyticsModule } from "../../analytics/GeneralAnalytics";
|
|
|
4
4
|
import * as O from "fp-ts/lib/Option";
|
|
5
5
|
import i18next from "i18next";
|
|
6
6
|
import { state } from "../../store/store";
|
|
7
|
-
import {
|
|
7
|
+
import { searchState } from "../../store/search.store";
|
|
8
8
|
import { Linked, Price, ResponsiveImage, Image, } from "./render-helpers";
|
|
9
9
|
import styles from "./vviinn-product-card.css";
|
|
10
10
|
import { campaignTypeNames, } from "../../campaign/Campaign";
|
|
@@ -133,7 +133,7 @@ export class VviinnProductCard {
|
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
135
|
getProduct() {
|
|
136
|
-
return
|
|
136
|
+
return searchState.results.find((r) => r.productId === this.productId);
|
|
137
137
|
}
|
|
138
138
|
renderImage() {
|
|
139
139
|
const props = {
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: block;
|
|
3
|
+
position: relative;
|
|
4
|
+
width: 100%;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.text-search-input {
|
|
8
|
+
width: 100%;
|
|
9
|
+
height: 48px;
|
|
10
|
+
padding: 0 16px;
|
|
11
|
+
font-size: 16px;
|
|
12
|
+
box-sizing: border-box;
|
|
13
|
+
font-style: normal;
|
|
14
|
+
font-weight: 400;
|
|
15
|
+
border-radius: 8px;
|
|
16
|
+
border: 1px solid #e0e0e0;
|
|
17
|
+
transition: border-color 0.2s;
|
|
18
|
+
outline: none;
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.text-search-input::-moz-placeholder {
|
|
23
|
+
color: #a8a8a8;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.text-search-input::placeholder {
|
|
27
|
+
color: #a8a8a8;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.text-search-input:focus,
|
|
31
|
+
.text-search-input:active {
|
|
32
|
+
border-color: #8d8d8d;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.text-search-button {
|
|
36
|
+
position: absolute;
|
|
37
|
+
right: 1px;
|
|
38
|
+
top: 1px;
|
|
39
|
+
border: none;
|
|
40
|
+
border-radius: 0 7px 7px 0;
|
|
41
|
+
width: 46px;
|
|
42
|
+
height: 46px;
|
|
43
|
+
display: flex;
|
|
44
|
+
justify-content: center;
|
|
45
|
+
align-items: center;
|
|
46
|
+
background-color: #f4f4f4;
|
|
47
|
+
transition: background-color 0.2s;
|
|
48
|
+
cursor: pointer;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.text-search-button:not(:disabled):hover {
|
|
52
|
+
background-color: #e0e0e0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.text-search-button:disabled {
|
|
56
|
+
cursor: unset;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
vviinn-preloader {
|
|
60
|
+
--preloader-size: 16px;
|
|
61
|
+
display: flex;
|
|
62
|
+
color: #525252;
|
|
63
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Host, h, } from "@stencil/core";
|
|
2
|
+
import { processSelectedText, searchState } from "../../store/search.store";
|
|
3
|
+
import { TextSearchIcon } from "../vviinn-icons";
|
|
4
|
+
import { slotChangeListener } from "../customized-slots";
|
|
5
|
+
import i18next from "i18next";
|
|
6
|
+
/**
|
|
7
|
+
* @part text-search-input - Text search input.
|
|
8
|
+
* @slot vviinn-text-search-icon - Icon of text search block.
|
|
9
|
+
*/
|
|
10
|
+
export class VviinnTextSearch {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.clearSearchQuery = false;
|
|
13
|
+
this.initialSearchQuery = "";
|
|
14
|
+
this.searchQuery = this.initialSearchQuery;
|
|
15
|
+
}
|
|
16
|
+
componentWillLoad() {
|
|
17
|
+
slotChangeListener(this, this.el);
|
|
18
|
+
}
|
|
19
|
+
handleInputChange(event) {
|
|
20
|
+
this.searchQuery = event.target.value;
|
|
21
|
+
}
|
|
22
|
+
handleKeyPress(event) {
|
|
23
|
+
if (event.key === "Enter") {
|
|
24
|
+
this.handleSearch();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async handleSearch() {
|
|
28
|
+
if (!this.searchQuery)
|
|
29
|
+
return;
|
|
30
|
+
await processSelectedText(this.searchQuery);
|
|
31
|
+
this.vviinnTextSearchFinished.emit(this.searchQuery);
|
|
32
|
+
if (this.clearSearchQuery) {
|
|
33
|
+
this.searchQuery = "";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
render() {
|
|
37
|
+
return (h(Host, { exportparts: "text-search-input" }, h("input", { class: "text-search-input", part: "text-search-input", type: "text", placeholder: i18next.t("textSearchPlaceholder"), value: this.searchQuery, onInput: (event) => this.handleInputChange(event), onKeyUp: (event) => this.handleKeyPress(event) }), h("button", { class: "text-search-button", onClick: () => this.handleSearch(), disabled: searchState.loading }, searchState.loading && searchState.searchType === "text" ? (h("vviinn-preloader", null)) : (h("slot", { name: "vviinn-text-search-icon" }, h(TextSearchIcon, null))))));
|
|
38
|
+
}
|
|
39
|
+
static get is() { return "vviinn-text-search"; }
|
|
40
|
+
static get encapsulation() { return "shadow"; }
|
|
41
|
+
static get originalStyleUrls() {
|
|
42
|
+
return {
|
|
43
|
+
"$": ["vviinn-text-search.css"]
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
static get styleUrls() {
|
|
47
|
+
return {
|
|
48
|
+
"$": ["vviinn-text-search.css"]
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
static get properties() {
|
|
52
|
+
return {
|
|
53
|
+
"clearSearchQuery": {
|
|
54
|
+
"type": "boolean",
|
|
55
|
+
"mutable": false,
|
|
56
|
+
"complexType": {
|
|
57
|
+
"original": "boolean",
|
|
58
|
+
"resolved": "boolean",
|
|
59
|
+
"references": {}
|
|
60
|
+
},
|
|
61
|
+
"required": false,
|
|
62
|
+
"optional": false,
|
|
63
|
+
"docs": {
|
|
64
|
+
"tags": [],
|
|
65
|
+
"text": ""
|
|
66
|
+
},
|
|
67
|
+
"attribute": "clear-search-query",
|
|
68
|
+
"reflect": false,
|
|
69
|
+
"defaultValue": "false"
|
|
70
|
+
},
|
|
71
|
+
"initialSearchQuery": {
|
|
72
|
+
"type": "string",
|
|
73
|
+
"mutable": false,
|
|
74
|
+
"complexType": {
|
|
75
|
+
"original": "string",
|
|
76
|
+
"resolved": "string",
|
|
77
|
+
"references": {}
|
|
78
|
+
},
|
|
79
|
+
"required": false,
|
|
80
|
+
"optional": false,
|
|
81
|
+
"docs": {
|
|
82
|
+
"tags": [],
|
|
83
|
+
"text": ""
|
|
84
|
+
},
|
|
85
|
+
"attribute": "initial-search-query",
|
|
86
|
+
"reflect": false,
|
|
87
|
+
"defaultValue": "\"\""
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
static get states() {
|
|
92
|
+
return {
|
|
93
|
+
"searchQuery": {}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
static get events() {
|
|
97
|
+
return [{
|
|
98
|
+
"method": "vviinnTextSearchFinished",
|
|
99
|
+
"name": "vviinnTextSearchFinished",
|
|
100
|
+
"bubbles": true,
|
|
101
|
+
"cancelable": true,
|
|
102
|
+
"composed": true,
|
|
103
|
+
"docs": {
|
|
104
|
+
"tags": [{
|
|
105
|
+
"name": "internal",
|
|
106
|
+
"text": undefined
|
|
107
|
+
}],
|
|
108
|
+
"text": ""
|
|
109
|
+
},
|
|
110
|
+
"complexType": {
|
|
111
|
+
"original": "any",
|
|
112
|
+
"resolved": "any",
|
|
113
|
+
"references": {}
|
|
114
|
+
}
|
|
115
|
+
}];
|
|
116
|
+
}
|
|
117
|
+
static get elementRef() { return "el"; }
|
|
118
|
+
}
|
|
@@ -22,7 +22,7 @@ import { createBearAuthedHeader } from "./token-helpers";
|
|
|
22
22
|
import { state } from "../../store/store";
|
|
23
23
|
import { campaignTypeNames } from "../../campaign/Campaign";
|
|
24
24
|
import { getRecommendationsService } from "../../campaign/CampaignService";
|
|
25
|
-
import {
|
|
25
|
+
import { searchState } from "../../store/search.store";
|
|
26
26
|
import { SlotSkeleton } from "../customized-slots";
|
|
27
27
|
import { createTrackingApi } from "../../openApi";
|
|
28
28
|
import { createWidgetVprEvent, createWidgetVpcEvent, createProductVpcEventByType, createProductVprEventByType, createAddToBasketVpcEvent, createAddToBasketVprEvent, createResultVpcEventByType, createResultVprEventByType, } from "../../tracking";
|
|
@@ -122,6 +122,9 @@ export class VviinnVprWidget {
|
|
|
122
122
|
window.location.href = deeplink;
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
+
findProductById(id) {
|
|
126
|
+
return this.recommendations.find((r) => r.productId === id);
|
|
127
|
+
}
|
|
125
128
|
handleProductIdChange() {
|
|
126
129
|
this.getRecommendations();
|
|
127
130
|
}
|
|
@@ -200,7 +203,7 @@ export class VviinnVprWidget {
|
|
|
200
203
|
}
|
|
201
204
|
async trackProductClick({ detail }) {
|
|
202
205
|
const { productId, clickEvent } = detail;
|
|
203
|
-
const product = this.
|
|
206
|
+
const product = this.findProductById(productId);
|
|
204
207
|
if (!product || !product.deeplink)
|
|
205
208
|
return;
|
|
206
209
|
const productClickEvent = this.getProductTrackEvent(detail, "click");
|
|
@@ -218,7 +221,7 @@ export class VviinnVprWidget {
|
|
|
218
221
|
}
|
|
219
222
|
async trackAuxClick({ detail }) {
|
|
220
223
|
const { productId } = detail;
|
|
221
|
-
const product = this.
|
|
224
|
+
const product = this.findProductById(productId);
|
|
222
225
|
if (!product || !product.deeplink)
|
|
223
226
|
return;
|
|
224
227
|
const productClickEvent = this.getProductTrackEvent(detail, "click");
|
|
@@ -310,7 +313,7 @@ export class VviinnVprWidget {
|
|
|
310
313
|
this.vviinnResultLoad.emit(this.getBasicEventData());
|
|
311
314
|
this.trackResultEvent("load");
|
|
312
315
|
this.recommendations = (_a = data === null || data === void 0 ? void 0 : data.extended) !== null && _a !== void 0 ? _a : data;
|
|
313
|
-
|
|
316
|
+
searchState.results = this.recommendations;
|
|
314
317
|
this.productIds = this.recommendations.map((r) => r.productId);
|
|
315
318
|
this.productImageLoadedSubject.subscribe((id) => {
|
|
316
319
|
this.productIds = this.productIds.filter((x) => x !== id);
|
|
@@ -33,6 +33,7 @@ const Template = (args) => `
|
|
|
33
33
|
product-detail-new-tab="${args.productDetailNewTab}"
|
|
34
34
|
api-path="${args.apiPath}"
|
|
35
35
|
image-resolution-width="${args.imageResolutionWidth}"
|
|
36
|
+
text-search-show="${args.textSearchShow}"
|
|
36
37
|
></vviinn-vps-button>`;
|
|
37
38
|
export const Modal = Template.bind({});
|
|
38
39
|
Modal.storyName = "Modal";
|
|
@@ -47,6 +48,7 @@ Modal.args = {
|
|
|
47
48
|
addStyle: true,
|
|
48
49
|
apiPath: "https://api.vviinn.com",
|
|
49
50
|
imageResolutionWidth: 250,
|
|
51
|
+
textSearchShow: false,
|
|
50
52
|
};
|
|
51
53
|
export const Upload = Template.bind({});
|
|
52
54
|
Upload.args = {
|
|
@@ -56,6 +56,7 @@ export class VviinnVpsButton {
|
|
|
56
56
|
this.productDetailNewTab = true;
|
|
57
57
|
this.imageResolutionWidth = 250;
|
|
58
58
|
this.exampleImageSource = DEFAULT_EXAMPLE_IMAGE;
|
|
59
|
+
this.textSearchShow = false;
|
|
59
60
|
this.apiPath = undefined;
|
|
60
61
|
this.buttonPressed = false;
|
|
61
62
|
}
|
|
@@ -75,7 +76,7 @@ export class VviinnVpsButton {
|
|
|
75
76
|
render() {
|
|
76
77
|
return (h(Host, { tabindex: "0", role: "button" }, h("vviinn-button", { onClick: () => {
|
|
77
78
|
this.handleClick();
|
|
78
|
-
}, addStyle: this.addStyle, part: "vviinn-button" }, h("slot", null, h(CameraIcon, null))), h(SlotSkeleton, null), h("vviinn-vps-widget", { mode: this.mode, "currency-sign": this.currencySign, token: this.token, locale: this.locale, apiPath: this.apiPath, exportparts: "brand, deeplink, currency, image, image-link, price-amount-sale, price-amount-outdated, price-amount-regular, price-container, price-outdated, price-regular, price-sale, price-prefix, title, product-card, upload-photo_button, show-files_button, start-camera_button", campaignId: this.campaignId, showingInButton: true, buttonPressed: this.buttonPressed, resetVpsButton: this.resetButton.bind(this), buttonElementId: this.el.id, active: this.buttonPressed && this.mode === "modal", excluded: this.excluded, productDetailNewTab: this.productDetailNewTab, imageResolutionWidth: this.imageResolutionWidth, exampleImageSource: this.exampleImageSource })));
|
|
79
|
+
}, addStyle: this.addStyle, part: "vviinn-button" }, h("slot", null, h(CameraIcon, null))), h(SlotSkeleton, null), h("vviinn-vps-widget", { mode: this.mode, "currency-sign": this.currencySign, token: this.token, locale: this.locale, apiPath: this.apiPath, exportparts: "brand, deeplink, currency, image, image-link, price-amount-sale, price-amount-outdated, price-amount-regular, price-container, price-outdated, price-regular, price-sale, price-prefix, title, product-card, upload-photo_button, show-files_button, start-camera_button", campaignId: this.campaignId, showingInButton: true, buttonPressed: this.buttonPressed, resetVpsButton: this.resetButton.bind(this), buttonElementId: this.el.id, active: this.buttonPressed && this.mode === "modal", excluded: this.excluded, productDetailNewTab: this.productDetailNewTab, imageResolutionWidth: this.imageResolutionWidth, exampleImageSource: this.exampleImageSource, textSearchShow: this.textSearchShow })));
|
|
79
80
|
}
|
|
80
81
|
static get is() { return "vviinn-vps-button"; }
|
|
81
82
|
static get encapsulation() { return "shadow"; }
|
|
@@ -275,6 +276,24 @@ export class VviinnVpsButton {
|
|
|
275
276
|
"reflect": false,
|
|
276
277
|
"defaultValue": "DEFAULT_EXAMPLE_IMAGE"
|
|
277
278
|
},
|
|
279
|
+
"textSearchShow": {
|
|
280
|
+
"type": "boolean",
|
|
281
|
+
"mutable": false,
|
|
282
|
+
"complexType": {
|
|
283
|
+
"original": "boolean",
|
|
284
|
+
"resolved": "boolean",
|
|
285
|
+
"references": {}
|
|
286
|
+
},
|
|
287
|
+
"required": false,
|
|
288
|
+
"optional": false,
|
|
289
|
+
"docs": {
|
|
290
|
+
"tags": [],
|
|
291
|
+
"text": "Show the text search"
|
|
292
|
+
},
|
|
293
|
+
"attribute": "text-search-show",
|
|
294
|
+
"reflect": false,
|
|
295
|
+
"defaultValue": "false"
|
|
296
|
+
},
|
|
278
297
|
"apiPath": {
|
|
279
298
|
"type": "string",
|
|
280
299
|
"mutable": false,
|
|
@@ -17,6 +17,7 @@ const Template = (args) => `
|
|
|
17
17
|
product-detail-new-tab="${args.productDetailNewTab}"
|
|
18
18
|
api-path="${args.apiPath}"
|
|
19
19
|
image-resolution-width="${args.imageResolutionWidth}"
|
|
20
|
+
text-search-show="${args.textSearchShow}"
|
|
20
21
|
>
|
|
21
22
|
</vviinn-vps-widget>`;
|
|
22
23
|
export const Default = Template.bind({});
|
|
@@ -30,6 +31,7 @@ Default.args = {
|
|
|
30
31
|
active: true,
|
|
31
32
|
apiPath: "https://api.vviinn.com",
|
|
32
33
|
imageResolutionWidth: 250,
|
|
34
|
+
textSearchShow: false,
|
|
33
35
|
};
|
|
34
36
|
Default.storyName = "Main";
|
|
35
37
|
Default.decorators = [
|
|
@@ -59,11 +59,15 @@ vviinn-overlayed-modal.first-screen::part(secondary-action) {
|
|
|
59
59
|
gap: 12px;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
#start-page_block vviinn-text-search {
|
|
63
|
+
margin-top: 12px;
|
|
64
|
+
}
|
|
65
|
+
|
|
62
66
|
.buttons-group {
|
|
63
67
|
display: flex;
|
|
64
68
|
flex-direction: column;
|
|
65
69
|
gap: 12px;
|
|
66
|
-
margin: 24px
|
|
70
|
+
margin-top: 24px;
|
|
67
71
|
}
|
|
68
72
|
|
|
69
73
|
.action-button {
|
|
@@ -120,6 +124,11 @@ vviinn-overlayed-modal.first-screen::part(secondary-action) {
|
|
|
120
124
|
box-sizing: border-box;
|
|
121
125
|
}
|
|
122
126
|
|
|
127
|
+
.results-page .text-search-wrapper {
|
|
128
|
+
width: 100%;
|
|
129
|
+
padding: 24px;
|
|
130
|
+
}
|
|
131
|
+
|
|
123
132
|
.products {
|
|
124
133
|
width: 100%;
|
|
125
134
|
align-content: center;
|
|
@@ -231,6 +240,11 @@ search-filters::part(filter active) {
|
|
|
231
240
|
width: 60%;
|
|
232
241
|
}
|
|
233
242
|
|
|
243
|
+
vviinn-preloader {
|
|
244
|
+
--preloader-size: 24px;
|
|
245
|
+
display: flex;
|
|
246
|
+
}
|
|
247
|
+
|
|
234
248
|
@media (max-width: 1080px) {
|
|
235
249
|
#start-page_block {
|
|
236
250
|
padding: 24px 36px;
|