vviinn-widgets 2.5.2 → 2.7.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/{app-globals-d15b4c2c.js → app-globals-047a582c.js} +1 -1
- package/dist/cjs/{highlight-box_22.cjs.entry.js → cropper-handler_27.cjs.entry.js} +473 -85
- package/dist/cjs/{customized-slots-0c0d0665.js → customized-slots-cb722e68.js} +1 -1
- package/dist/cjs/{index-0f5516a6.js → index-bd771524.js} +1 -1
- package/dist/cjs/{imageSearch.store-865c23f4.js → index-d07466b9.js} +14707 -11093
- package/dist/cjs/{index-31b9cb7a.js → index-fcafbfe5.js} +1 -1
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/cjs/{vviinn-carousel_3.cjs.entry.js → vviinn-carousel_2.cjs.entry.js} +35 -208
- package/dist/cjs/vviinn-recommendations-sidebar.cjs.entry.js +5 -3
- package/dist/cjs/vviinn-vpr-button.cjs.entry.js +7 -2
- package/dist/cjs/vviinn-vps-button.cjs.entry.js +4 -4
- package/dist/cjs/vviinn-widgets.cjs.js +3 -3
- package/dist/collection/campaign/VCSCampaignService.js +4 -2
- package/dist/collection/campaign/VPRCampaignService.js +4 -2
- package/dist/collection/components/vviinn-vpr-button/recommendations-sidebar/recommendations-sidebar.js +21 -1
- package/dist/collection/components/vviinn-vpr-button/stories/args.js +6 -0
- package/dist/collection/components/vviinn-vpr-button/stories/vviinn-vpr-button.stories.js +2 -0
- package/dist/collection/components/vviinn-vpr-button/vviinn-vpr-button.js +23 -0
- package/dist/collection/components/vviinn-vpr-widget/stories/args.js +7 -0
- package/dist/collection/components/vviinn-vpr-widget/stories/vviinn-vpr-widget.stories.js +12 -13
- package/dist/collection/components/vviinn-vpr-widget/vviinn-vpr-vidget.js +28 -1
- package/dist/collection/components/vviinn-vps-button/stories/vviinn-vps-button.stories.js +9 -5
- package/dist/collection/components/vviinn-vps-button/vviinn-vps-button.js +18 -1
- package/dist/collection/components/vviinn-vps-widget/stories/vviinn-vps-widget.stories.js +11 -7
- package/dist/collection/components/vviinn-vps-widget/vviinn-vps-widget.js +23 -0
- package/dist/collection/searchSession/searchSession.js +6 -1
- package/dist/collection/store/imageSearch.store.js +2 -7
- package/dist/esm/{app-globals-6f6aa89e.js → app-globals-68b1d848.js} +1 -1
- package/dist/esm/{highlight-box_22.entry.js → cropper-handler_27.entry.js} +404 -21
- package/dist/esm/{customized-slots-6b427dda.js → customized-slots-95a05ceb.js} +1 -1
- package/dist/esm/{imageSearch.store-0ae87235.js → index-33fe5a25.js} +14832 -11234
- package/dist/esm/{index-59f44eaa.js → index-75a1f589.js} +1 -1
- package/dist/esm/{index-ac05c460.js → index-f9df412f.js} +2 -2
- package/dist/esm/loader.js +3 -3
- package/dist/esm/{vviinn-carousel_3.entry.js → vviinn-carousel_2.entry.js} +15 -187
- package/dist/esm/vviinn-recommendations-sidebar.entry.js +5 -3
- package/dist/esm/vviinn-vpr-button.entry.js +7 -2
- package/dist/esm/vviinn-vps-button.entry.js +4 -4
- package/dist/esm/vviinn-widgets.js +3 -3
- package/dist/types/campaign/CampaignService.d.ts +1 -1
- package/dist/types/campaign/VCSCampaignService.d.ts +2 -1
- package/dist/types/campaign/VPRCampaignService.d.ts +2 -1
- package/dist/types/components/vviinn-vpr-button/recommendations-sidebar/recommendations-sidebar.d.ts +2 -0
- package/dist/types/components/vviinn-vpr-button/stories/args.d.ts +6 -0
- package/dist/types/components/vviinn-vpr-button/stories/vviinn-vpr-button.stories.d.ts +6 -0
- package/dist/types/components/vviinn-vpr-button/vviinn-vpr-button.d.ts +2 -0
- package/dist/types/components/vviinn-vpr-widget/stories/args.d.ts +6 -0
- package/dist/types/components/vviinn-vpr-widget/stories/vviinn-vpr-widget.stories.d.ts +6 -0
- package/dist/types/components/vviinn-vpr-widget/vviinn-vpr-vidget.d.ts +3 -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 +2 -0
- package/dist/types/components.d.ts +40 -0
- package/dist/types/searchSession/searchSession.d.ts +2 -1
- package/dist/types/store/imageSearch.store.d.ts +7 -6
- package/dist/vviinn-widgets/{p-bad1809f.js → p-4e55513e.js} +1 -1
- package/dist/vviinn-widgets/p-5358970c.entry.js +1 -0
- package/{www/build/p-c36546fa.js → dist/vviinn-widgets/p-66015ad7.js} +1 -1
- package/dist/vviinn-widgets/p-669a156c.entry.js +1 -0
- package/dist/vviinn-widgets/p-8080679b.entry.js +1 -0
- package/dist/vviinn-widgets/p-9de1b0e7.js +1 -0
- package/dist/vviinn-widgets/{p-ee46fc83.js → p-b254eee7.js} +1 -1
- package/dist/vviinn-widgets/p-c1cd51ef.entry.js +1 -0
- package/dist/vviinn-widgets/p-e32c30d4.entry.js +1 -0
- package/dist/vviinn-widgets/{p-118ac907.js → p-f6e59cb2.js} +1 -1
- package/dist/vviinn-widgets/vviinn-widgets.esm.js +1 -1
- package/package.json +3 -3
- package/www/build/{p-bad1809f.js → p-4e55513e.js} +1 -1
- package/www/build/p-5358970c.entry.js +1 -0
- package/{dist/vviinn-widgets/p-c36546fa.js → www/build/p-66015ad7.js} +1 -1
- package/www/build/p-669a156c.entry.js +1 -0
- package/www/build/p-8080679b.entry.js +1 -0
- package/www/build/p-9de1b0e7.js +1 -0
- package/www/build/{p-ee46fc83.js → p-b254eee7.js} +1 -1
- package/www/build/p-c1cd51ef.entry.js +1 -0
- package/www/build/p-e32c30d4.entry.js +1 -0
- package/www/build/p-eb8f77e4.js +1 -0
- package/www/build/{p-118ac907.js → p-f6e59cb2.js} +1 -1
- package/www/build/vviinn-widgets.esm.js +1 -1
- package/www/index.html +1 -1
- package/dist/cjs/Handler-176539c8.js +0 -331
- package/dist/cjs/cropper-handler.cjs.entry.js +0 -27
- package/dist/cjs/index-0eb3036a.js +0 -3235
- package/dist/cjs/vviinn-error.cjs.entry.js +0 -19
- package/dist/cjs/vviinn-preloader.cjs.entry.js +0 -26
- package/dist/cjs/vviinn-vps-widget.cjs.entry.js +0 -167
- package/dist/esm/Handler-f9b8735c.js +0 -309
- package/dist/esm/cropper-handler.entry.js +0 -23
- package/dist/esm/index-2e296af4.js +0 -3224
- package/dist/esm/vviinn-error.entry.js +0 -15
- package/dist/esm/vviinn-preloader.entry.js +0 -22
- package/dist/esm/vviinn-vps-widget.entry.js +0 -163
- package/dist/vviinn-widgets/p-11f61564.js +0 -1
- package/dist/vviinn-widgets/p-39fdc5c9.entry.js +0 -1
- package/dist/vviinn-widgets/p-762dc067.entry.js +0 -1
- package/dist/vviinn-widgets/p-7e2f542c.js +0 -1
- package/dist/vviinn-widgets/p-8d56e795.entry.js +0 -1
- package/dist/vviinn-widgets/p-8f955b15.entry.js +0 -1
- package/dist/vviinn-widgets/p-9654fe35.entry.js +0 -1
- package/dist/vviinn-widgets/p-9e5adc42.js +0 -1
- package/dist/vviinn-widgets/p-b3731705.entry.js +0 -1
- package/dist/vviinn-widgets/p-d991330b.entry.js +0 -1
- package/dist/vviinn-widgets/p-da9c933b.entry.js +0 -1
- package/dist/vviinn-widgets/p-f41e25f0.entry.js +0 -1
- package/www/build/p-11f61564.js +0 -1
- package/www/build/p-39fdc5c9.entry.js +0 -1
- package/www/build/p-762dc067.entry.js +0 -1
- package/www/build/p-7e2f542c.js +0 -1
- package/www/build/p-8d56e795.entry.js +0 -1
- package/www/build/p-8f955b15.entry.js +0 -1
- package/www/build/p-9654fe35.entry.js +0 -1
- package/www/build/p-9e5adc42.js +0 -1
- package/www/build/p-b3731705.entry.js +0 -1
- package/www/build/p-cfd998c1.js +0 -1
- package/www/build/p-d991330b.entry.js +0 -1
- package/www/build/p-da9c933b.entry.js +0 -1
- package/www/build/p-f41e25f0.entry.js +0 -1
|
@@ -73,6 +73,7 @@ const Template = (args) => `<style>
|
|
|
73
73
|
position="${args.position}"
|
|
74
74
|
sidebar-title="${args.sidebarTitle}"
|
|
75
75
|
modal-scrollbar="${args.modalScrollbar}"
|
|
76
|
+
campaigns="${args.campaigns}"
|
|
76
77
|
source-image="${args.showSourceImage
|
|
77
78
|
? "https://www.moebel-shop.de/media/image/e3/e9/28/0749295-001_600x600.jpg"
|
|
78
79
|
: ""}"></vviinn-vpr-button>`;
|
|
@@ -80,6 +81,7 @@ export const Default = Template.bind({});
|
|
|
80
81
|
Default.args = {
|
|
81
82
|
token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOjgzLCJqdGkiOiI3ZTg2Y2I1YS00ZTFjLTRhYjctYjU2My1lN2FjMTYzZTYyZDIiLCJzY29wZXMiOlsidnByIiwidnBzIiwidnBjIl19.SbaQnBkvoXer3GPCWUthFQStFKLHZNMBfj4Qu44WHM8nzaIt48I74yVy4gVbX29vtd6jIkDPdakqEXRXmAxOCtv7_nsd4iBs1yMegfOWW5g8f10PKfZqmWJcfhwKIEElnUMFmP6rXpogntZ7iFfeTBbiRNzQPhkaa7jUjgQkCC4",
|
|
82
83
|
productId: "4114460310",
|
|
84
|
+
campaigns: "",
|
|
83
85
|
};
|
|
84
86
|
Default.parameters = {
|
|
85
87
|
design: {
|
|
@@ -10,6 +10,8 @@ export class VviinnVprButton {
|
|
|
10
10
|
this.sourceImage = null;
|
|
11
11
|
this.sidebarTitle = "Visually similar products";
|
|
12
12
|
this.modalScrollbar = false;
|
|
13
|
+
/** comma-separated list of campaign-ids */
|
|
14
|
+
this.campaigns = "";
|
|
13
15
|
this.sidebar = null;
|
|
14
16
|
this.sidebarCloseListener = () => {
|
|
15
17
|
document.body.removeChild(this.sidebar);
|
|
@@ -29,11 +31,14 @@ export class VviinnVprButton {
|
|
|
29
31
|
sidebar.position = this.position;
|
|
30
32
|
sidebar.sourceImage = this.sourceImage;
|
|
31
33
|
sidebar.widgetScrollbar = this.modalScrollbar;
|
|
34
|
+
sidebar.campaigns = this.campaigns;
|
|
32
35
|
this.sidebar = sidebar;
|
|
33
36
|
sidebar.addEventListener("modalClosed", this.sidebarCloseListener);
|
|
34
37
|
document.body.append(this.sidebar);
|
|
35
38
|
}
|
|
36
39
|
disconnectedCallback() {
|
|
40
|
+
if (!this.sidebar)
|
|
41
|
+
return;
|
|
37
42
|
this.sidebar.removeEventListener("modalCLosed", this.sidebarCloseListener);
|
|
38
43
|
document.body.removeChild(this.sidebar);
|
|
39
44
|
}
|
|
@@ -151,6 +156,24 @@ export class VviinnVprButton {
|
|
|
151
156
|
"attribute": "modal-scrollbar",
|
|
152
157
|
"reflect": false,
|
|
153
158
|
"defaultValue": "false"
|
|
159
|
+
},
|
|
160
|
+
"campaigns": {
|
|
161
|
+
"type": "string",
|
|
162
|
+
"mutable": false,
|
|
163
|
+
"complexType": {
|
|
164
|
+
"original": "string",
|
|
165
|
+
"resolved": "string",
|
|
166
|
+
"references": {}
|
|
167
|
+
},
|
|
168
|
+
"required": false,
|
|
169
|
+
"optional": false,
|
|
170
|
+
"docs": {
|
|
171
|
+
"tags": [],
|
|
172
|
+
"text": "comma-separated list of campaign-ids"
|
|
173
|
+
},
|
|
174
|
+
"attribute": "campaigns",
|
|
175
|
+
"reflect": false,
|
|
176
|
+
"defaultValue": "\"\""
|
|
154
177
|
}
|
|
155
178
|
}; }
|
|
156
179
|
}
|
|
@@ -19,6 +19,12 @@ const productId = {
|
|
|
19
19
|
type: "text",
|
|
20
20
|
},
|
|
21
21
|
};
|
|
22
|
+
const campaigns = {
|
|
23
|
+
name: "campaigns",
|
|
24
|
+
control: {
|
|
25
|
+
type: "text",
|
|
26
|
+
},
|
|
27
|
+
};
|
|
22
28
|
const cssUrl = {
|
|
23
29
|
name: "css-url",
|
|
24
30
|
description: "Optional for custom CSS. It will overwrite all other settings.",
|
|
@@ -118,6 +124,7 @@ export const argTypes = {
|
|
|
118
124
|
analyticsId,
|
|
119
125
|
apiPath,
|
|
120
126
|
campaignType,
|
|
127
|
+
campaigns,
|
|
121
128
|
contentAlignment,
|
|
122
129
|
cssUrl,
|
|
123
130
|
imageWidth,
|
|
@@ -14,14 +14,14 @@ export default {
|
|
|
14
14
|
component: "vviinn-vpr-widget",
|
|
15
15
|
argTypes: Object.assign(Object.assign({}, argTypes), { mode: {
|
|
16
16
|
table: {
|
|
17
|
-
disable: true
|
|
18
|
-
}
|
|
17
|
+
disable: true,
|
|
18
|
+
},
|
|
19
19
|
} }),
|
|
20
20
|
parameters: {
|
|
21
21
|
controls: {
|
|
22
|
-
exclude: excludeControls
|
|
23
|
-
}
|
|
24
|
-
}
|
|
22
|
+
exclude: excludeControls,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
25
|
};
|
|
26
26
|
const allignementLeft = `
|
|
27
27
|
vviinn-vpr-widget::part(title),
|
|
@@ -159,6 +159,7 @@ const Template = (args) => `
|
|
|
159
159
|
show-scroll="${args.showScrollbars}"
|
|
160
160
|
image-width="${args.imageWidth}"
|
|
161
161
|
campaign-type="${args.campaignType}"
|
|
162
|
+
campaigns="${args.campaigns}"
|
|
162
163
|
>
|
|
163
164
|
</vviinn-vpr-widget>
|
|
164
165
|
`;
|
|
@@ -166,6 +167,7 @@ export const Grid = Template.bind({});
|
|
|
166
167
|
Grid.args = {
|
|
167
168
|
analyticsId: "UA-34442043-5",
|
|
168
169
|
apiPath: "https://api.vviinn.com",
|
|
170
|
+
campaigns: "",
|
|
169
171
|
campaignType: "VPR",
|
|
170
172
|
contentAlignment: "Centered",
|
|
171
173
|
imageWidth: 420,
|
|
@@ -180,16 +182,15 @@ Grid.args = {
|
|
|
180
182
|
showTitle: true,
|
|
181
183
|
titleFontSize: 28,
|
|
182
184
|
titleName: "Recommended products",
|
|
183
|
-
token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOjgzLCJqdGkiOiI3ZTg2Y2I1YS00ZTFjLTRhYjctYjU2My1lN2FjMTYzZTYyZDIiLCJzY29wZXMiOlsidnByIiwidnBzIiwidnBjIl19.SbaQnBkvoXer3GPCWUthFQStFKLHZNMBfj4Qu44WHM8nzaIt48I74yVy4gVbX29vtd6jIkDPdakqEXRXmAxOCtv7_nsd4iBs1yMegfOWW5g8f10PKfZqmWJcfhwKIEElnUMFmP6rXpogntZ7iFfeTBbiRNzQPhkaa7jUjgQkCC4"
|
|
185
|
+
token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOjgzLCJqdGkiOiI3ZTg2Y2I1YS00ZTFjLTRhYjctYjU2My1lN2FjMTYzZTYyZDIiLCJzY29wZXMiOlsidnByIiwidnBzIiwidnBjIl19.SbaQnBkvoXer3GPCWUthFQStFKLHZNMBfj4Qu44WHM8nzaIt48I74yVy4gVbX29vtd6jIkDPdakqEXRXmAxOCtv7_nsd4iBs1yMegfOWW5g8f10PKfZqmWJcfhwKIEElnUMFmP6rXpogntZ7iFfeTBbiRNzQPhkaa7jUjgQkCC4",
|
|
184
186
|
};
|
|
185
187
|
Grid.argTypes = Object.assign({}, gridLayoutArgs);
|
|
186
|
-
Grid.decorators = [
|
|
187
|
-
gridDecorator
|
|
188
|
-
];
|
|
188
|
+
Grid.decorators = [gridDecorator];
|
|
189
189
|
export const Continuity = Template.bind({});
|
|
190
190
|
Continuity.args = {
|
|
191
191
|
analyticsId: "UA-34442043-5",
|
|
192
192
|
apiPath: "https://api.vviinn.com",
|
|
193
|
+
campaigns: "",
|
|
193
194
|
campaignType: "VPR",
|
|
194
195
|
contentAlignment: "Left",
|
|
195
196
|
imageWidth: 300,
|
|
@@ -204,9 +205,7 @@ Continuity.args = {
|
|
|
204
205
|
showTitle: true,
|
|
205
206
|
titleFontSize: 28,
|
|
206
207
|
titleName: "Recommended products",
|
|
207
|
-
token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOjgzLCJqdGkiOiI3ZTg2Y2I1YS00ZTFjLTRhYjctYjU2My1lN2FjMTYzZTYyZDIiLCJzY29wZXMiOlsidnByIiwidnBzIiwidnBjIl19.SbaQnBkvoXer3GPCWUthFQStFKLHZNMBfj4Qu44WHM8nzaIt48I74yVy4gVbX29vtd6jIkDPdakqEXRXmAxOCtv7_nsd4iBs1yMegfOWW5g8f10PKfZqmWJcfhwKIEElnUMFmP6rXpogntZ7iFfeTBbiRNzQPhkaa7jUjgQkCC4"
|
|
208
|
+
token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOjgzLCJqdGkiOiI3ZTg2Y2I1YS00ZTFjLTRhYjctYjU2My1lN2FjMTYzZTYyZDIiLCJzY29wZXMiOlsidnByIiwidnBzIiwidnBjIl19.SbaQnBkvoXer3GPCWUthFQStFKLHZNMBfj4Qu44WHM8nzaIt48I74yVy4gVbX29vtd6jIkDPdakqEXRXmAxOCtv7_nsd4iBs1yMegfOWW5g8f10PKfZqmWJcfhwKIEElnUMFmP6rXpogntZ7iFfeTBbiRNzQPhkaa7jUjgQkCC4",
|
|
208
209
|
};
|
|
209
|
-
Continuity.decorators = [
|
|
210
|
-
continuityDecorator
|
|
211
|
-
];
|
|
210
|
+
Continuity.decorators = [continuityDecorator];
|
|
212
211
|
Continuity.argTypes = Object.assign({}, continuityLayoutArgs);
|
|
@@ -10,6 +10,7 @@ import { Subject } from "rxjs";
|
|
|
10
10
|
import { v4 as uuidv4 } from "uuid";
|
|
11
11
|
import { createTrackingApi } from "../../openApi";
|
|
12
12
|
import { createProductClickVprEvent, createProductViewVprEvent, createWidgetVprEvent, } from "../../tracking";
|
|
13
|
+
import { checkEmpryString } from "../../utils/option/option";
|
|
13
14
|
/**
|
|
14
15
|
* @part product-card - product card itself
|
|
15
16
|
* @part title - title inside product card
|
|
@@ -41,6 +42,8 @@ export class VviinnVprWidget {
|
|
|
41
42
|
this.campaignType = "VPR";
|
|
42
43
|
/** Locale for currency formatting */
|
|
43
44
|
this.locale = "de-DE";
|
|
45
|
+
/** comma-separated list of campaign-ids */
|
|
46
|
+
this.campaigns = "";
|
|
44
47
|
/** @internal */
|
|
45
48
|
this.apiPath = "https://api.vviinn.com";
|
|
46
49
|
/** @internal */
|
|
@@ -57,6 +60,9 @@ export class VviinnVprWidget {
|
|
|
57
60
|
handleCampaignTypeChange() {
|
|
58
61
|
this.getRecommendations();
|
|
59
62
|
}
|
|
63
|
+
handleCampaignsChange() {
|
|
64
|
+
this.getRecommendations();
|
|
65
|
+
}
|
|
60
66
|
handleApiPathChange(newPath) {
|
|
61
67
|
state.apiPath = newPath;
|
|
62
68
|
this.getRecommendations();
|
|
@@ -106,7 +112,7 @@ export class VviinnVprWidget {
|
|
|
106
112
|
return;
|
|
107
113
|
const campaignType = this.campaignType.length > 0 ? this.campaignType : "VPR";
|
|
108
114
|
const headers = createBearAuthedHeader(this.token);
|
|
109
|
-
const request = pipe(TE.of(getRecommendationsService(campaignType)), TE.ap(TE.of(this.productId)), TE.ap(TE.of(headers)), TE.flatten);
|
|
115
|
+
const request = pipe(TE.of(getRecommendationsService(campaignType)), TE.ap(TE.of(this.productId)), TE.ap(TE.of(checkEmpryString(this.campaigns))), TE.ap(TE.of(headers)), TE.flatten);
|
|
110
116
|
const runRequest = await request();
|
|
111
117
|
pipe(runRequest, E.fold((error) => this.handleError(error), (data) => this.handleRecommendationsSucces(data)));
|
|
112
118
|
}
|
|
@@ -351,6 +357,24 @@ export class VviinnVprWidget {
|
|
|
351
357
|
"reflect": false,
|
|
352
358
|
"defaultValue": "\"de-DE\""
|
|
353
359
|
},
|
|
360
|
+
"campaigns": {
|
|
361
|
+
"type": "string",
|
|
362
|
+
"mutable": false,
|
|
363
|
+
"complexType": {
|
|
364
|
+
"original": "string",
|
|
365
|
+
"resolved": "string",
|
|
366
|
+
"references": {}
|
|
367
|
+
},
|
|
368
|
+
"required": false,
|
|
369
|
+
"optional": false,
|
|
370
|
+
"docs": {
|
|
371
|
+
"tags": [],
|
|
372
|
+
"text": "comma-separated list of campaign-ids"
|
|
373
|
+
},
|
|
374
|
+
"attribute": "campaigns",
|
|
375
|
+
"reflect": false,
|
|
376
|
+
"defaultValue": "\"\""
|
|
377
|
+
},
|
|
354
378
|
"apiPath": {
|
|
355
379
|
"type": "string",
|
|
356
380
|
"mutable": false,
|
|
@@ -457,6 +481,9 @@ export class VviinnVprWidget {
|
|
|
457
481
|
}, {
|
|
458
482
|
"propName": "campaignType",
|
|
459
483
|
"methodName": "handleCampaignTypeChange"
|
|
484
|
+
}, {
|
|
485
|
+
"propName": "campaigns",
|
|
486
|
+
"methodName": "handleCampaignsChange"
|
|
460
487
|
}, {
|
|
461
488
|
"propName": "apiPath",
|
|
462
489
|
"methodName": "handleApiPathChange"
|
|
@@ -3,10 +3,11 @@ export default {
|
|
|
3
3
|
component: "vviinn-vps-button",
|
|
4
4
|
parameters: {
|
|
5
5
|
viewport: {
|
|
6
|
-
defaultViewport: "mobile2"
|
|
7
|
-
}
|
|
6
|
+
defaultViewport: "mobile2",
|
|
7
|
+
},
|
|
8
8
|
},
|
|
9
|
-
decorators: [
|
|
9
|
+
decorators: [
|
|
10
|
+
(story) => `
|
|
10
11
|
<div style="display: grid;
|
|
11
12
|
position: absolute;
|
|
12
13
|
top: 0;
|
|
@@ -17,15 +18,18 @@ export default {
|
|
|
17
18
|
justify-items: center;">
|
|
18
19
|
${story()}
|
|
19
20
|
</div>
|
|
20
|
-
|
|
21
|
+
`,
|
|
22
|
+
],
|
|
21
23
|
};
|
|
22
24
|
const Template = (args) => `
|
|
23
25
|
<vviinn-vps-button
|
|
24
26
|
api-path="${args.apiPath}"
|
|
25
27
|
token="${args.token}"
|
|
28
|
+
campaign-id="${args.campaignId}"
|
|
26
29
|
></vviinn-vps-button>`;
|
|
27
30
|
export const Default = Template.bind({});
|
|
28
31
|
Default.args = {
|
|
29
32
|
token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOjgzLCJqdGkiOiI3ZTg2Y2I1YS00ZTFjLTRhYjctYjU2My1lN2FjMTYzZTYyZDIiLCJzY29wZXMiOlsidnByIiwidnBzIiwidnBjIl19.SbaQnBkvoXer3GPCWUthFQStFKLHZNMBfj4Qu44WHM8nzaIt48I74yVy4gVbX29vtd6jIkDPdakqEXRXmAxOCtv7_nsd4iBs1yMegfOWW5g8f10PKfZqmWJcfhwKIEElnUMFmP6rXpogntZ7iFfeTBbiRNzQPhkaa7jUjgQkCC4",
|
|
30
|
-
apiPath: "https://api.vviinn.com"
|
|
33
|
+
apiPath: "https://api.vviinn.com",
|
|
34
|
+
campaignId: "",
|
|
31
35
|
};
|
|
@@ -60,7 +60,7 @@ export class VviinnVpsButton {
|
|
|
60
60
|
h("slot", null,
|
|
61
61
|
h(CameraIcon, null)),
|
|
62
62
|
h(SlotSkeleton, null),
|
|
63
|
-
h("vviinn-vps-widget", { active: this.pressed, "currency-sign": "\u20AC", token: this.token, locale: this.locale, apiPath: this.apiPath, exportparts: "brand, currency, deeplink, image, image-link, price-amount, price-container, price-outdated, price-prefix, price-regular, price-sale, title, product-card, example-images" })));
|
|
63
|
+
h("vviinn-vps-widget", { active: this.pressed, "currency-sign": "\u20AC", token: this.token, locale: this.locale, apiPath: this.apiPath, exportparts: "brand, currency, deeplink, image, image-link, price-amount, price-container, price-outdated, price-prefix, price-regular, price-sale, title, product-card, example-images", campaignId: this.campaignId })));
|
|
64
64
|
}
|
|
65
65
|
static get is() { return "vviinn-vps-button"; }
|
|
66
66
|
static get encapsulation() { return "shadow"; }
|
|
@@ -124,6 +124,23 @@ export class VviinnVpsButton {
|
|
|
124
124
|
"reflect": false,
|
|
125
125
|
"defaultValue": "\"de-DE\""
|
|
126
126
|
},
|
|
127
|
+
"campaignId": {
|
|
128
|
+
"type": "string",
|
|
129
|
+
"mutable": false,
|
|
130
|
+
"complexType": {
|
|
131
|
+
"original": "string",
|
|
132
|
+
"resolved": "string",
|
|
133
|
+
"references": {}
|
|
134
|
+
},
|
|
135
|
+
"required": false,
|
|
136
|
+
"optional": true,
|
|
137
|
+
"docs": {
|
|
138
|
+
"tags": [],
|
|
139
|
+
"text": "Campaign using for visual search"
|
|
140
|
+
},
|
|
141
|
+
"attribute": "campaign-id",
|
|
142
|
+
"reflect": false
|
|
143
|
+
},
|
|
127
144
|
"apiPath": {
|
|
128
145
|
"type": "string",
|
|
129
146
|
"mutable": false,
|
|
@@ -2,22 +2,25 @@ export default {
|
|
|
2
2
|
title: "Widgets/Visual Search/Widget",
|
|
3
3
|
parameters: {
|
|
4
4
|
viewport: {
|
|
5
|
-
defaultViewport: "mobile2"
|
|
6
|
-
}
|
|
7
|
-
}
|
|
5
|
+
defaultViewport: "mobile2",
|
|
6
|
+
},
|
|
7
|
+
},
|
|
8
8
|
};
|
|
9
|
-
const Template = ({ token, apiPath }) => `
|
|
9
|
+
const Template = ({ token, apiPath, campaignId }) => `
|
|
10
10
|
<vviinn-vps-widget token="${token}"
|
|
11
11
|
api-path="${apiPath}"
|
|
12
|
+
campaign-id="${campaignId}"
|
|
12
13
|
active="true">
|
|
13
14
|
</vviinn-vps-widget>`;
|
|
14
15
|
export const Default = Template.bind({});
|
|
15
16
|
Default.args = {
|
|
16
17
|
token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOjgzLCJqdGkiOiI3ZTg2Y2I1YS00ZTFjLTRhYjctYjU2My1lN2FjMTYzZTYyZDIiLCJzY29wZXMiOlsidnByIiwidnBzIiwidnBjIl19.SbaQnBkvoXer3GPCWUthFQStFKLHZNMBfj4Qu44WHM8nzaIt48I74yVy4gVbX29vtd6jIkDPdakqEXRXmAxOCtv7_nsd4iBs1yMegfOWW5g8f10PKfZqmWJcfhwKIEElnUMFmP6rXpogntZ7iFfeTBbiRNzQPhkaa7jUjgQkCC4",
|
|
17
|
-
apiPath: "https://api.vviinn.com"
|
|
18
|
+
apiPath: "https://api.vviinn.com",
|
|
19
|
+
campaignId: "",
|
|
18
20
|
};
|
|
19
21
|
Default.storyName = "Modal Window";
|
|
20
|
-
Default.decorators = [
|
|
22
|
+
Default.decorators = [
|
|
23
|
+
(Story) => `
|
|
21
24
|
<style>
|
|
22
25
|
.sb-show-main.sb-main-padded {
|
|
23
26
|
padding: unset;
|
|
@@ -30,4 +33,5 @@ Default.decorators = [(Story) => `
|
|
|
30
33
|
justify-items: center;
|
|
31
34
|
}
|
|
32
35
|
</style>
|
|
33
|
-
${Story()}
|
|
36
|
+
${Story()}`,
|
|
37
|
+
];
|
|
@@ -2,10 +2,15 @@ import { Component, Host, h, State, Prop, Element, Watch, Listen, } from "@stenc
|
|
|
2
2
|
import { state } from "../../store/store";
|
|
3
3
|
import { imageSearchState } from "../../store/imageSearch.store";
|
|
4
4
|
import * as O from "fp-ts/lib/Option";
|
|
5
|
+
import { isEmpty } from "fp-ts/string";
|
|
5
6
|
import { slotChangeListener } from "../customized-slots";
|
|
6
7
|
import { v4 as uuidv4 } from "uuid";
|
|
7
8
|
import { createTrackingApi } from "../../openApi";
|
|
8
9
|
import { createFilterEvent, createProductClickVpsEvent, createProductViewVpsEvent, createSearchEvent, createWidgetVpsEvent, } from "../../tracking";
|
|
10
|
+
import { pipe } from "fp-ts/lib/function";
|
|
11
|
+
const filterInt = (value) => /^[-+]?(\d+|Infinity)$/.test(value) ? Number(value) : NaN;
|
|
12
|
+
const notEmptyString = (s) => !isEmpty(s);
|
|
13
|
+
const notNan = (n) => !isNaN(n);
|
|
9
14
|
/**
|
|
10
15
|
* @prop --color-primary: color used for action button, slider bullets and selected detected object;
|
|
11
16
|
*
|
|
@@ -101,6 +106,7 @@ export class VviinnVpsWidget {
|
|
|
101
106
|
state.currencySign = this.currencySign;
|
|
102
107
|
state.locale = this.locale;
|
|
103
108
|
imageSearchState.token = this.token;
|
|
109
|
+
imageSearchState.campaignId = pipe(this.campaignId, O.fromNullable, O.chain(O.fromPredicate(notEmptyString)), O.map(filterInt), O.chain(O.fromPredicate(notNan)), O.map((s) => `${s}`));
|
|
104
110
|
this.uiSessionId = uuidv4();
|
|
105
111
|
}
|
|
106
112
|
trackOpenEvent() {
|
|
@@ -306,6 +312,23 @@ export class VviinnVpsWidget {
|
|
|
306
312
|
"attribute": "locale",
|
|
307
313
|
"reflect": false,
|
|
308
314
|
"defaultValue": "\"de-DE\""
|
|
315
|
+
},
|
|
316
|
+
"campaignId": {
|
|
317
|
+
"type": "string",
|
|
318
|
+
"mutable": false,
|
|
319
|
+
"complexType": {
|
|
320
|
+
"original": "string",
|
|
321
|
+
"resolved": "string",
|
|
322
|
+
"references": {}
|
|
323
|
+
},
|
|
324
|
+
"required": false,
|
|
325
|
+
"optional": true,
|
|
326
|
+
"docs": {
|
|
327
|
+
"tags": [],
|
|
328
|
+
"text": "Campaign using for visual search"
|
|
329
|
+
},
|
|
330
|
+
"attribute": "campaign-id",
|
|
331
|
+
"reflect": false
|
|
309
332
|
}
|
|
310
333
|
}; }
|
|
311
334
|
static get states() { return {
|
|
@@ -3,6 +3,7 @@ import { makeRequest } from "../network/request";
|
|
|
3
3
|
import { createInitPostRequest, getApiPath } from "../network/utils";
|
|
4
4
|
import * as E from "fp-ts/Either";
|
|
5
5
|
import * as TE from "fp-ts/TaskEither";
|
|
6
|
+
import * as O from "fp-ts/Option";
|
|
6
7
|
import { processBearerToken } from "../utils/token/tokenUtils";
|
|
7
8
|
import { sequenceToEither } from "../utils/either";
|
|
8
9
|
import { imageFormFromFile } from "../Image/form";
|
|
@@ -17,7 +18,11 @@ export const detectedObjectEq = {
|
|
|
17
18
|
x.rectangle.height === y.rectangle.height &&
|
|
18
19
|
x.rectangle.width === y.rectangle.width,
|
|
19
20
|
};
|
|
20
|
-
export const searchSessionClient = (initialData
|
|
21
|
+
export const searchSessionClient = (initialData, campaignId = O.none) => {
|
|
22
|
+
const searchUrl = "search/session";
|
|
23
|
+
const requestUrl = pipe(campaignId, O.fold(() => searchUrl, (campaignId) => `${searchUrl}?campaign-id=${campaignId}`));
|
|
24
|
+
return pipe(sequenceToEither(getApiPath(), createInitPostRequest), TE.fromEither, TE.chainW(makeRequest(requestUrl, initialData)));
|
|
25
|
+
};
|
|
21
26
|
export const makeRequestFromFile = (token, file) => pipe(sequenceToEither(processBearerToken(token), E.right(imageFormFromFile(file))), E.map(([headers, body]) => {
|
|
22
27
|
return {
|
|
23
28
|
headers,
|
|
@@ -23,16 +23,11 @@ const makeAuthorizedRequest = (token) => pipe(token, processBearerToken, E.map((
|
|
|
23
23
|
};
|
|
24
24
|
}));
|
|
25
25
|
const { state, onChange } = createStore({
|
|
26
|
-
|
|
26
|
+
campaignId: O.none,
|
|
27
27
|
results: [],
|
|
28
28
|
filters: [],
|
|
29
|
-
resetCategoryLink: undefined,
|
|
30
|
-
activeIonLink: undefined,
|
|
31
29
|
cropperHandlers: [],
|
|
32
|
-
selectedCropper: undefined,
|
|
33
|
-
rectangleSearchForm: undefined,
|
|
34
30
|
detectedObjects: [],
|
|
35
|
-
detectedObject: undefined,
|
|
36
31
|
objectDetectionInProgress: false,
|
|
37
32
|
imageWidth: RESIZED_IMAGE_WIDTH,
|
|
38
33
|
image: O.none,
|
|
@@ -93,7 +88,7 @@ export const uploadFile = (file) => {
|
|
|
93
88
|
headers,
|
|
94
89
|
body,
|
|
95
90
|
};
|
|
96
|
-
}), TE.fromEither, TE.chain(searchSessionClient), TE.map((sessionResponse) => {
|
|
91
|
+
}), TE.fromEither, TE.chain((request) => searchSessionClient(request, state.campaignId)), TE.map((sessionResponse) => {
|
|
97
92
|
updateState(sessionResponse);
|
|
98
93
|
detectObjects(sessionResponse);
|
|
99
94
|
state.loading = false;
|