@adadapted/react-native-sdk 3.1.6 → 3.1.8

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.
Files changed (39) hide show
  1. package/android/.project +18 -1
  2. package/android/.settings/org.eclipse.buildship.core.prefs +4 -4
  3. package/android/src/main/java/com/adadaptedreactnativesdk/AdadaptedReactNativeSdkModule.kt +1 -1
  4. package/lib/commonjs/api/adadaptedApiRequests.mock.js +0 -20
  5. package/lib/commonjs/api/adadaptedApiRequests.mock.js.map +1 -1
  6. package/lib/commonjs/api/adadaptedApiTypes.js +0 -5
  7. package/lib/commonjs/api/adadaptedApiTypes.js.map +1 -1
  8. package/lib/commonjs/components/AdZone.js +10 -40
  9. package/lib/commonjs/components/AdZone.js.map +1 -1
  10. package/lib/commonjs/index.js +1 -1
  11. package/lib/commonjs/index.js.map +1 -1
  12. package/lib/module/api/adadaptedApiRequests.mock.js +0 -20
  13. package/lib/module/api/adadaptedApiRequests.mock.js.map +1 -1
  14. package/lib/module/api/adadaptedApiTypes.js +0 -5
  15. package/lib/module/api/adadaptedApiTypes.js.map +1 -1
  16. package/lib/module/components/AdZone.js +10 -39
  17. package/lib/module/components/AdZone.js.map +1 -1
  18. package/lib/module/index.js +1 -1
  19. package/lib/module/index.js.map +1 -1
  20. package/lib/typescript/src/api/adadaptedApiTypes.d.ts +0 -47
  21. package/lib/typescript/src/components/AdZone.d.ts +0 -4
  22. package/lib/typescript/src/index.d.ts +1 -1
  23. package/package.json +2 -2
  24. package/src/api/adadaptedApiRequests.mock.ts +0 -20
  25. package/src/api/adadaptedApiTypes.ts +0 -48
  26. package/src/components/AdZone.tsx +13 -56
  27. package/src/index.tsx +1 -1
  28. package/lib/commonjs/components/AdPopup.js +0 -352
  29. package/lib/commonjs/components/AdPopup.js.map +0 -1
  30. package/lib/commonjs/components/AdPopup.test.js +0 -60
  31. package/lib/commonjs/components/AdPopup.test.js.map +0 -1
  32. package/lib/module/components/AdPopup.js +0 -339
  33. package/lib/module/components/AdPopup.js.map +0 -1
  34. package/lib/module/components/AdPopup.test.js +0 -50
  35. package/lib/module/components/AdPopup.test.js.map +0 -1
  36. package/lib/typescript/src/components/AdPopup.d.ts +0 -75
  37. package/lib/typescript/src/components/AdPopup.test.d.ts +0 -1
  38. package/src/components/AdPopup.test.tsx +0 -60
  39. package/src/components/AdPopup.tsx +0 -471
@@ -1,60 +0,0 @@
1
- "use strict";
2
-
3
- var React = _interopRequireWildcard(require("react"));
4
-
5
- var _enzyme = require("enzyme");
6
-
7
- var _AdPopup = require("./AdPopup");
8
-
9
- var _adadaptedApiTypes = require("../api/adadaptedApiTypes");
10
-
11
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
12
-
13
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
14
-
15
- /**
16
- * Unit tests for {@link AdPopup}
17
- * @module
18
- */
19
- describe("AdPopup", () => {
20
- test("Sample unit test", () => {
21
- const wrapper = (0, _enzyme.mount)( /*#__PURE__*/React.createElement(_AdPopup.AdPopup, {
22
- ad: {
23
- ad_id: "1816",
24
- impression_id: "100838::C4D792785EA1EC91",
25
- refresh_time: 30,
26
- hide_after_interaction: false,
27
- type: "html",
28
- creative_url: "https://testurl.com/a/NTLKNZKYMMI2NTM1;100838;1815?session_id=TEST_SESSION_ID&udid=00000000-0000-0000-0000-000000000000",
29
- tracking_html: "<html></html>",
30
- action_type: _adadaptedApiTypes.AdActionType.CONTENT,
31
- action_path: "",
32
- payload: {
33
- detailed_list_items: [{
34
- product_barcode: "0",
35
- product_brand: "Brand",
36
- product_category: "",
37
- product_discount: "",
38
- product_image: "",
39
- product_sku: "",
40
- product_title: "Sample Product"
41
- }]
42
- },
43
- popup: {
44
- title_text: "",
45
- background_color: "",
46
- text_color: "",
47
- alt_close_btn: "",
48
- type: "",
49
- hide_banner: false,
50
- hide_close_btn: false,
51
- hide_browser_nav: false
52
- }
53
- },
54
- onAddToListItemClicked: () => {// Mock this method.
55
- }
56
- }));
57
- wrapper.detach();
58
- });
59
- });
60
- //# sourceMappingURL=AdPopup.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["AdPopup.test.tsx"],"names":["describe","test","wrapper","ad_id","impression_id","refresh_time","hide_after_interaction","type","creative_url","tracking_html","action_type","AdActionType","CONTENT","action_path","payload","detailed_list_items","product_barcode","product_brand","product_category","product_discount","product_image","product_sku","product_title","popup","title_text","background_color","text_color","alt_close_btn","hide_banner","hide_close_btn","hide_browser_nav","detach"],"mappings":";;AAIA;;AACA;;AAEA;;AACA;;;;;;AARA;AACA;AACA;AACA;AASAA,QAAQ,CAAC,SAAD,EAAY,MAAM;AACtBC,EAAAA,IAAI,CAAC,kBAAD,EAAqB,MAAM;AAC3B,UAAMC,OAAuB,GAAG,iCAC5B,oBAAC,gBAAD;AACI,MAAA,EAAE,EAAE;AACAC,QAAAA,KAAK,EAAE,MADP;AAEAC,QAAAA,aAAa,EAAE,0BAFf;AAGAC,QAAAA,YAAY,EAAE,EAHd;AAIAC,QAAAA,sBAAsB,EAAE,KAJxB;AAKAC,QAAAA,IAAI,EAAE,MALN;AAMAC,QAAAA,YAAY,EACR,6HAPJ;AAQAC,QAAAA,aAAa,EAAE,eARf;AASAC,QAAAA,WAAW,EAAEC,gCAAaC,OAT1B;AAUAC,QAAAA,WAAW,EAAE,EAVb;AAWAC,QAAAA,OAAO,EAAE;AACLC,UAAAA,mBAAmB,EAAE,CACjB;AACIC,YAAAA,eAAe,EAAE,GADrB;AAEIC,YAAAA,aAAa,EAAE,OAFnB;AAGIC,YAAAA,gBAAgB,EAAE,EAHtB;AAIIC,YAAAA,gBAAgB,EAAE,EAJtB;AAKIC,YAAAA,aAAa,EAAE,EALnB;AAMIC,YAAAA,WAAW,EAAE,EANjB;AAOIC,YAAAA,aAAa,EAAE;AAPnB,WADiB;AADhB,SAXT;AAwBAC,QAAAA,KAAK,EAAE;AACHC,UAAAA,UAAU,EAAE,EADT;AAEHC,UAAAA,gBAAgB,EAAE,EAFf;AAGHC,UAAAA,UAAU,EAAE,EAHT;AAIHC,UAAAA,aAAa,EAAE,EAJZ;AAKHpB,UAAAA,IAAI,EAAE,EALH;AAMHqB,UAAAA,WAAW,EAAE,KANV;AAOHC,UAAAA,cAAc,EAAE,KAPb;AAQHC,UAAAA,gBAAgB,EAAE;AARf;AAxBP,OADR;AAoCI,MAAA,sBAAsB,EAAE,MAAM,CAC1B;AACH;AAtCL,MAD4B,CAAhC;AA2CA5B,IAAAA,OAAO,CAAC6B,MAAR;AACH,GA7CG,CAAJ;AA8CH,CA/CO,CAAR","sourcesContent":["/**\n * Unit tests for {@link AdPopup}\n * @module\n */\nimport * as React from \"react\";\nimport { mount, ReactWrapper } from \"enzyme\";\nimport { ExtractReactPropsType } from \"../types\";\nimport { AdPopup } from \"./AdPopup\";\nimport { AdActionType } from \"../api/adadaptedApiTypes\";\n\ntype AdPopupWrapper = ReactWrapper<ExtractReactPropsType<typeof AdPopup>>;\n\ndescribe(\"AdPopup\", () => {\n test(\"Sample unit test\", () => {\n const wrapper: AdPopupWrapper = mount(\n <AdPopup\n ad={{\n ad_id: \"1816\",\n impression_id: \"100838::C4D792785EA1EC91\",\n refresh_time: 30,\n hide_after_interaction: false,\n type: \"html\",\n creative_url:\n \"https://testurl.com/a/NTLKNZKYMMI2NTM1;100838;1815?session_id=TEST_SESSION_ID&amp;udid=00000000-0000-0000-0000-000000000000\",\n tracking_html: \"<html></html>\",\n action_type: AdActionType.CONTENT,\n action_path: \"\",\n payload: {\n detailed_list_items: [\n {\n product_barcode: \"0\",\n product_brand: \"Brand\",\n product_category: \"\",\n product_discount: \"\",\n product_image: \"\",\n product_sku: \"\",\n product_title: \"Sample Product\",\n },\n ],\n },\n popup: {\n title_text: \"\",\n background_color: \"\",\n text_color: \"\",\n alt_close_btn: \"\",\n type: \"\",\n hide_banner: false,\n hide_close_btn: false,\n hide_browser_nav: false,\n },\n }}\n onAddToListItemClicked={() => {\n // Mock this method.\n }}\n />\n );\n\n wrapper.detach();\n });\n});\n"]}
@@ -1,339 +0,0 @@
1
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
-
3
- /**
4
- * Component for creating an {@link AdPopup}.
5
- * @module
6
- */
7
- import * as React from "react";
8
- import { WebView } from "react-native-webview";
9
- import Modal from "react-native-modal";
10
- import { ActivityIndicator, Image, SafeAreaView, StyleSheet, Text, TouchableOpacity, View } from "react-native";
11
- import { AdActionType } from "../api/adadaptedApiTypes";
12
- import { safeInvoke } from "../util";
13
- /**
14
- * Props interface for {@link AdPopup}.
15
- */
16
-
17
- /**
18
- * Creates the AdPopup component.
19
- */
20
- export class AdPopup extends React.Component {
21
- /**
22
- * The web view element reference.
23
- */
24
-
25
- /**
26
- * @inheritDoc
27
- */
28
- constructor(props, context) {
29
- super(props, context);
30
-
31
- _defineProperty(this, "webViewElementRef", null);
32
-
33
- this.state = {
34
- canGoBack: false,
35
- canGoForward: false,
36
- isPageLoading: true
37
- };
38
- }
39
- /**
40
- * @inheritDoc
41
- */
42
-
43
-
44
- render() {
45
- // Generate the styles each render in case the ad is updated with
46
- // new settings that need to be reflected in the styles of the view.
47
- const styles = this.generateStyles();
48
- return /*#__PURE__*/React.createElement(Modal, {
49
- style: styles.mainView,
50
- isVisible: this.props.isOpen,
51
- hasBackdrop: false,
52
- coverScreen: true
53
- }, /*#__PURE__*/React.createElement(SafeAreaView, {
54
- style: {
55
- flex: 1
56
- }
57
- }, /*#__PURE__*/React.createElement(SafeAreaView, {
58
- style: styles.navHeaderView
59
- }, /*#__PURE__*/React.createElement(View, {
60
- style: styles.navArrowsContainer
61
- }, /*#__PURE__*/React.createElement(View, {
62
- onTouchStart: () => {
63
- if (this.webViewElementRef && this.state.canGoBack) {
64
- this.webViewElementRef.goBack();
65
- }
66
- }
67
- }, /*#__PURE__*/React.createElement(Image, {
68
- source: {
69
- uri: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAABpUlEQVRoQ+2YvUrFQBBGZ59Hq8QXsLcVLCwsFBQUFBQUlHsFBQUFBQUFLSwsBB9C+/2m0ifxAUYCCinM5i47c83Cpgy7yznzzZAfR5lfLnN+KgL/nWBJoCSQWIHSQokFTN5eEogtYVVVY+fcAhF9icg7M49jz2ivn2oCP/CjFsAngNksBP6Ab7gBYG7wAh3wJCLHg2+hLngiOgJwklL9Zq/pDATgDwCcpcKbCgTg9wBcaMCbCQR6foeZr7TgTQS64J1zW977G014dYFA22wAuNOGVxUIwK8BeLCAVxMIwK8AeLKCVxEIDOwyMz9bwqsI1HX9QUQzbVARWWLmF2t4LQFPRHW2Atm3UFP5rIf4t3UCD7BV7/2j1TyovswFJNa99/cWEqoCoXYSkU1mvtWWUBfomYltANeaEiYCPRK7AC61JMwEeiT2AZxrSJgKhCScc4fe+9NUCXOBnsEe/kd9z3Min/9CHUm8AZhPaaOptFAbsKqqkXNusbknIq+D/y+UUt1J9k49gUmgYtYUgZhqWawtCVhUNebMkkBMtSzWlgQsqhpz5jfHSasx85A3NgAAAABJRU5ErkJggg=="
70
- },
71
- style: styles.navLeftArrow
72
- })), /*#__PURE__*/React.createElement(View, {
73
- onTouchStart: () => {
74
- if (this.webViewElementRef && this.state.canGoForward) {
75
- this.webViewElementRef.goForward();
76
- }
77
- }
78
- }, /*#__PURE__*/React.createElement(Image, {
79
- source: {
80
- uri: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAABnklEQVRoQ+3YsUoEMRAG4H8ewCfRKpNeH0KwsLBQUFBQUFBQ8ERBQUFBQUELCwsLS3tfwFylzzOykAVZmz0yM+dCrs7O/d9Mwu2FMPAPDTw/KmDaE6wTqBMo7EDdQoUNLH68TiCEMCKieQAzIvI+Ho9HxW2doEDxBJj5C8Bs+50icuKJ0AB8AuDfTfNEFAPyFjruTt0LUQxogjPzEYDTaSBUABlxAODcG6EGyIg9AJeeCFVAEzyEsENE114IdUATPMa4JSK3HggTQN5OGwDurRFmgIxYA/BoiTAFZMQKgGcrhDkgH+xlInqxQLgAMmKJiF47iO+U0twE725/lk4bkFJK8d8DQgjD3ULMPNxDHGNcFZEni8Pb1jQ7AzHGdRF5sAzf1DYBhBA2iejOOrwJgJm3Adx4hFcHMPMugCuv8KoAZt4HcOEZXg0QYzwUkTPv8CqAwf+p794LNV3xupFQmQAzfwBYaLePZ3gVQN5Ci7nzb563ciqAkjdJjWdNfok1gvWtUQF9O2W1rk7AqrN969YJ9O2U1bo6AavO9q37A5jF5jGXG4ruAAAAAElFTkSuQmCC"
81
- },
82
- style: styles.navRightArrow
83
- }))), /*#__PURE__*/React.createElement(View, {
84
- style: styles.navBarTitleView
85
- }, /*#__PURE__*/React.createElement(Text, {
86
- style: styles.titleText,
87
- numberOfLines: 1,
88
- ellipsizeMode: "tail"
89
- }, this.props.ad.popup.title_text)), /*#__PURE__*/React.createElement(View, {
90
- style: styles.loadingIndicatorContainer
91
- }, this.state.isPageLoading ? /*#__PURE__*/React.createElement(ActivityIndicator, {
92
- size: "large",
93
- color: "#2969a0"
94
- }) : undefined)), /*#__PURE__*/React.createElement(WebView, {
95
- source: {
96
- uri: this.props.ad.action_path
97
- },
98
- ref: ref => {
99
- this.webViewElementRef = ref;
100
- },
101
- androidHardwareAccelerationDisabled: true,
102
- automaticallyAdjustContentInsets: false,
103
- allowFileAccess: true,
104
- style: styles.webView,
105
- javaScriptEnabled: true,
106
- injectedJavaScript: this.props.ad.action_type === AdActionType.POPUP || this.props.ad.action_type === AdActionType.LINK ? this.getAddToListCircularJavascript() : "",
107
- onMessage: event => {
108
- const responseObj = JSON.parse(event.nativeEvent.data);
109
- safeInvoke(this.props.onAddToListItemClicked, responseObj);
110
- },
111
- onNavigationStateChange: navState => {
112
- this.setState({
113
- canGoBack: navState.canGoBack,
114
- canGoForward: navState.canGoForward
115
- });
116
- },
117
- onLoadStart: () => {
118
- this.setState({
119
- isPageLoading: true
120
- });
121
- },
122
- onLoadEnd: () => {
123
- this.setState({
124
- isPageLoading: false
125
- });
126
- }
127
- }), /*#__PURE__*/React.createElement(SafeAreaView, {
128
- style: styles.closeButtonView
129
- }, /*#__PURE__*/React.createElement(TouchableOpacity, {
130
- style: styles.closeButtonContainer,
131
- onPress: () => {
132
- safeInvoke(this.props.onClose);
133
- }
134
- }, /*#__PURE__*/React.createElement(Text, {
135
- style: styles.closeButtonText
136
- }, "Close")))));
137
- }
138
- /**
139
- * Generates the javascript to pass down to the Web View that extracts the
140
- * clicked product information based on the circular ad design.
141
- * @returns the javascript string to pass to the Web View.
142
- */
143
-
144
-
145
- getAddToListCircularJavascript() {
146
- // TODO: This method should ultimately be removed. We shouldn't have to
147
- // hack the web view's javascript just to get the correct data to
148
- // return. When the circular templates get reworked, we should
149
- // build in an onMessage response within the circulars page so we
150
- // don't have to do it this way.
151
- return `
152
- const adButtons = document.getElementsByTagName("button");
153
-
154
- if (adButtons.length > 0) {
155
- if (adButtons.length > 1 && adButtons[1].getAttribute("data-payload-id")) {
156
- for (let x = 0; x < adButtons.length; x++) {
157
- if (adButtons[x].getAttribute("data-payload-id")) {
158
- adButtons[x].addEventListener("click", (event) => {
159
- window.ReactNativeWebView.postMessage(
160
- JSON.stringify(
161
- window.AdAdapted.payloads[adButtons[x].getAttribute("data-payload-id")]
162
- )
163
- );
164
- });
165
- }
166
- }
167
- } else {
168
- const onDataPostMessage = (imgSrc) => {
169
- const valueAfterLastSlash = imgSrc.match(/(?:[^\\/](?!(\\/)))+$/g).toString();
170
- const upcValueWithLeadingZeros = valueAfterLastSlash.match(/[^.]*/).toString();
171
- const finalUpcValue = parseInt(upcValueWithLeadingZeros, 10);
172
- const itemData = window.__NUXT__.data[0].items;
173
- let clickedItem = {};
174
-
175
- for (let i = 0; i < itemData.length; i++) {
176
- if (itemData[i].upc == finalUpcValue) {
177
- clickedItem = itemData[i];
178
- }
179
- }
180
-
181
- window.ReactNativeWebView.postMessage(
182
- JSON.stringify({
183
- product_barcode: clickedItem.upc,
184
- product_brand: clickedItem.brand,
185
- product_category: clickedItem.category,
186
- product_discount: clickedItem.sale_price,
187
- product_image: clickedItem.image,
188
- product_sku: clickedItem.retailer_sku,
189
- product_title: clickedItem.title
190
- })
191
- );
192
- };
193
-
194
- const onItemDialogLoad = () => {
195
- setTimeout(() => {
196
- document.getElementsByClassName("modal-body")[0].getElementsByTagName("button")[0].addEventListener("click", (event) => {
197
- onDataPostMessage(
198
- event.target.parentElement.getElementsByTagName("img")[0].getAttribute("src")
199
- );
200
- });
201
- }, 100);
202
- };
203
-
204
- const adItemImages = document.querySelectorAll(".item img");
205
- const adItemPromotionDivs = document.querySelectorAll(".item .promotion");
206
- const adItemTitleDivs = document.querySelectorAll(".item .title");
207
- const adItemPricingDivs = document.querySelectorAll(".item .pricing");
208
-
209
- for (let x = 0; x < adItemImages.length; x++) {
210
- adItemImages[x].addEventListener("click", (event) => {
211
- onItemDialogLoad();
212
- });
213
- }
214
-
215
- for (let x = 0; x < adItemPromotionDivs.length; x++) {
216
- adItemPromotionDivs[x].addEventListener("click", (event) => {
217
- onItemDialogLoad();
218
- });
219
- }
220
-
221
- for (let x = 0; x < adItemTitleDivs.length; x++) {
222
- adItemTitleDivs[x].addEventListener("click", (event) => {
223
- onItemDialogLoad();
224
- });
225
- }
226
-
227
- for (let x = 0; x < adItemPricingDivs.length; x++) {
228
- adItemPricingDivs[x].addEventListener("click", (event) => {
229
- onItemDialogLoad();
230
- });
231
- }
232
-
233
- for (let x = 0; x < adButtons.length; x++) {
234
- adButtons[x].addEventListener("click", (event) => {
235
- onDataPostMessage(
236
- event.target.parentElement.getElementsByTagName("img")[0].getAttribute("src")
237
- );
238
- });
239
- }
240
- }
241
- }
242
- `;
243
- }
244
- /**
245
- * Generates all component related styles.
246
- * @returns the styles needed for the component.
247
- */
248
-
249
-
250
- generateStyles() {
251
- const backButtonOpacity = this.state.canGoBack ? 1 : 0.3;
252
- const forwardButtonOpacity = this.state.canGoForward ? 1 : 0.3;
253
- return StyleSheet.create({
254
- mainView: {
255
- display: "flex",
256
- flexDirection: "column",
257
- position: "relative",
258
- margin: 0,
259
- width: "100%",
260
- height: "100%"
261
- },
262
- navHeaderView: {
263
- display: "flex",
264
- flexDirection: "row",
265
- height: 60,
266
- width: "100%",
267
- backgroundColor: "#dadada",
268
- zIndex: 1
269
- },
270
- navArrowsContainer: {
271
- display: "flex",
272
- flexDirection: "row",
273
- justifyContent: "center",
274
- alignItems: "center"
275
- },
276
- navLeftArrow: {
277
- width: 48,
278
- height: 48,
279
- marginRight: 5,
280
- marginLeft: 10,
281
- opacity: backButtonOpacity
282
- },
283
- navRightArrow: {
284
- width: 48,
285
- height: 48,
286
- marginRight: 10,
287
- marginLeft: 5,
288
- opacity: forwardButtonOpacity
289
- },
290
- navBarTitleView: {
291
- display: "flex",
292
- flexDirection: "row",
293
- alignItems: "center",
294
- flex: 1
295
- },
296
- titleText: {
297
- color: "#333333",
298
- fontWeight: "bold",
299
- fontSize: 18,
300
- overflow: "hidden",
301
- flexWrap: "nowrap"
302
- },
303
- loadingIndicatorContainer: {
304
- display: "flex",
305
- flexDirection: "row",
306
- justifyContent: "center",
307
- alignItems: "center",
308
- marginLeft: 10,
309
- marginRight: 10
310
- },
311
- webView: {
312
- width: "100%",
313
- height: "100%",
314
- zIndex: 0
315
- },
316
- closeButtonView: {
317
- height: 60,
318
- width: "100%",
319
- backgroundColor: "#dadada",
320
- zIndex: 1
321
- },
322
- closeButtonContainer: {
323
- display: "flex",
324
- justifyContent: "center",
325
- width: "100%",
326
- height: "100%"
327
- },
328
- closeButtonText: {
329
- width: "100%",
330
- color: "#2969a0",
331
- margin: "auto",
332
- fontSize: 18,
333
- textAlign: "center"
334
- }
335
- });
336
- }
337
-
338
- }
339
- //# sourceMappingURL=AdPopup.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["AdPopup.tsx"],"names":["React","WebView","Modal","ActivityIndicator","Image","SafeAreaView","StyleSheet","Text","TouchableOpacity","View","AdActionType","safeInvoke","AdPopup","Component","constructor","props","context","state","canGoBack","canGoForward","isPageLoading","render","styles","generateStyles","mainView","isOpen","flex","navHeaderView","navArrowsContainer","webViewElementRef","goBack","uri","navLeftArrow","goForward","navRightArrow","navBarTitleView","titleText","ad","popup","title_text","loadingIndicatorContainer","undefined","action_path","ref","webView","action_type","POPUP","LINK","getAddToListCircularJavascript","event","responseObj","JSON","parse","nativeEvent","data","onAddToListItemClicked","navState","setState","closeButtonView","closeButtonContainer","onClose","closeButtonText","backButtonOpacity","forwardButtonOpacity","create","display","flexDirection","position","margin","width","height","backgroundColor","zIndex","justifyContent","alignItems","marginRight","marginLeft","opacity","color","fontWeight","fontSize","overflow","flexWrap","textAlign"],"mappings":";;AAAA;AACA;AACA;AACA;AACA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,OAAT,QAAwB,sBAAxB;AACA,OAAOC,KAAP,MAAkB,oBAAlB;AACA,SACIC,iBADJ,EAEIC,KAFJ,EAIIC,YAJJ,EAKIC,UALJ,EAMIC,IANJ,EAQIC,gBARJ,EASIC,IATJ,QAWO,cAXP;AAYA,SAAaC,YAAb,QAAmD,0BAAnD;AACA,SAASC,UAAT,QAA2B,SAA3B;AAEA;AACA;AACA;;AA8FA;AACA;AACA;AACA,OAAO,MAAMC,OAAN,SAAsBZ,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AA,oBAAoB,EAAE;AAClBM,QAAAA,OAAO,EAAE,MADS;AAElBQ,QAAAA,cAAc,EAAE,QAFE;AAGlBJ,QAAAA,KAAK,EAAE,MAHW;AAIlBC,QAAAA,MAAM,EAAE;AAJU,OArED;AA2ErBT,MAAAA,eAAe,EAAE;AACbQ,QAAAA,KAAK,EAAE,MADM;AAEbS,QAAAA,KAAK,EAAE,SAFM;AAGbV,QAAAA,MAAM,EAAE,MAHK;AAIbY,QAAAA,QAAQ,EAAE,EAJG;AAKbG,QAAAA,SAAS,EAAE;AALE;AA3EI,KAAlB,CAAP;AAmFH;;AA5VsD","sourcesContent":["/**\n * Component for creating an {@link AdPopup}.\n * @module\n */\nimport * as React from \"react\";\nimport { WebView } from \"react-native-webview\";\nimport Modal from \"react-native-modal\";\nimport {\n ActivityIndicator,\n Image,\n ImageStyle,\n SafeAreaView,\n StyleSheet,\n Text,\n TextStyle,\n TouchableOpacity,\n View,\n ViewStyle,\n} from \"react-native\";\nimport { Ad, AdActionType, DetailedListItem } from \"../api/adadaptedApiTypes\";\nimport { safeInvoke } from \"../util\";\n\n/**\n * Props interface for {@link AdPopup}.\n */\ninterface Props {\n /**\n * The add to display in the popup.\n */\n ad: Ad;\n /**\n * If true, the ad popup is displayed.\n */\n isOpen?: boolean;\n /**\n * Triggered when the popup is closing.\n */\n onClose?(): void;\n /**\n * Triggered when an ad circular item is clicked and\n * the item should be \"added to list\".\n * @param item - The item to add to list.\n */\n onAddToListItemClicked(item: DetailedListItem): void;\n}\n\n/**\n * State interface for {@link AdPopup}.\n */\ninterface State {\n /**\n * If true, the popup web view can navigate back.\n */\n canGoBack: boolean;\n /**\n * If true, the popup web view can navigate forward.\n */\n canGoForward: boolean;\n /**\n * If true, the webview is loading a new page.\n */\n isPageLoading: boolean;\n}\n\n/**\n * Defines the style typing for the component.\n */\ninterface StyleDef {\n /**\n * Styles for the main View element.\n */\n mainView: ViewStyle;\n /**\n * Styles for the WebView element.\n */\n webView: ViewStyle;\n /**\n * Styles for the close button View element.\n */\n closeButtonView: ViewStyle;\n /**\n * Styles for the navigation header View element.\n */\n navHeaderView: ViewStyle;\n /**\n * Styles for the nav arrow buttons view.\n */\n navArrowsContainer: ViewStyle;\n /**\n * Styles for the navigation left arrow button.\n */\n navLeftArrow: ImageStyle;\n /**\n * Styles for the navigation right arrow button.\n */\n navRightArrow: ImageStyle;\n /**\n * Styles for the nav bar title container.\n */\n navBarTitleView: ViewStyle;\n /**\n * Styles for the title text.\n */\n titleText: TextStyle;\n /**\n * Styles for the loading indicator container.\n */\n loadingIndicatorContainer: ViewStyle;\n /**\n * Styles for the close button opacity container.\n */\n closeButtonContainer: ViewStyle;\n /**\n * Styles for the button text.\n */\n closeButtonText: TextStyle;\n}\n\n/**\n * Creates the AdPopup component.\n */\nexport class AdPopup extends React.Component<Props, State> {\n /**\n * The web view element reference.\n */\n private webViewElementRef: WebView | null = null;\n\n /**\n * @inheritDoc\n */\n constructor(props: Props, context?: any) {\n super(props, context);\n\n this.state = {\n canGoBack: false,\n canGoForward: false,\n isPageLoading: true,\n };\n }\n\n /**\n * @inheritDoc\n */\n public render(): JSX.Element {\n // Generate the styles each render in case the ad is updated with\n // new settings that need to be reflected in the styles of the view.\n const styles = this.generateStyles();\n\n return (\n <Modal\n style={styles.mainView}\n isVisible={this.props.isOpen}\n hasBackdrop={false}\n coverScreen={true}\n >\n <SafeAreaView style={{ flex: 1 }}>\n <SafeAreaView style={styles.navHeaderView}>\n <View style={styles.navArrowsContainer}>\n <View\n onTouchStart={() => {\n if (\n this.webViewElementRef &&\n this.state.canGoBack\n ) {\n this.webViewElementRef.goBack();\n }\n }}\n >\n <Image\n source={{\n uri:\n \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAABpUlEQVRoQ+2YvUrFQBBGZ59Hq8QXsLcVLCwsFBQUFBQUlHsFBQUFBQUFLSwsBB9C+/2m0ifxAUYCCinM5i47c83Cpgy7yznzzZAfR5lfLnN+KgL/nWBJoCSQWIHSQokFTN5eEogtYVVVY+fcAhF9icg7M49jz2ivn2oCP/CjFsAngNksBP6Ab7gBYG7wAh3wJCLHg2+hLngiOgJwklL9Zq/pDATgDwCcpcKbCgTg9wBcaMCbCQR6foeZr7TgTQS64J1zW977G014dYFA22wAuNOGVxUIwK8BeLCAVxMIwK8AeLKCVxEIDOwyMz9bwqsI1HX9QUQzbVARWWLmF2t4LQFPRHW2Atm3UFP5rIf4t3UCD7BV7/2j1TyovswFJNa99/cWEqoCoXYSkU1mvtWWUBfomYltANeaEiYCPRK7AC61JMwEeiT2AZxrSJgKhCScc4fe+9NUCXOBnsEe/kd9z3Min/9CHUm8AZhPaaOptFAbsKqqkXNusbknIq+D/y+UUt1J9k49gUmgYtYUgZhqWawtCVhUNebMkkBMtSzWlgQsqhpz5jfHSasx85A3NgAAAABJRU5ErkJggg==\",\n }}\n style={styles.navLeftArrow}\n />\n </View>\n <View\n onTouchStart={() => {\n if (\n this.webViewElementRef &&\n this.state.canGoForward\n ) {\n this.webViewElementRef.goForward();\n }\n }}\n >\n <Image\n source={{\n uri:\n \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAABnklEQVRoQ+3YsUoEMRAG4H8ewCfRKpNeH0KwsLBQUFBQUFBQ8ERBQUFBQUELCwsLS3tfwFylzzOykAVZmz0yM+dCrs7O/d9Mwu2FMPAPDTw/KmDaE6wTqBMo7EDdQoUNLH68TiCEMCKieQAzIvI+Ho9HxW2doEDxBJj5C8Bs+50icuKJ0AB8AuDfTfNEFAPyFjruTt0LUQxogjPzEYDTaSBUABlxAODcG6EGyIg9AJeeCFVAEzyEsENE114IdUATPMa4JSK3HggTQN5OGwDurRFmgIxYA/BoiTAFZMQKgGcrhDkgH+xlInqxQLgAMmKJiF47iO+U0twE725/lk4bkFJK8d8DQgjD3ULMPNxDHGNcFZEni8Pb1jQ7AzHGdRF5sAzf1DYBhBA2iejOOrwJgJm3Adx4hFcHMPMugCuv8KoAZt4HcOEZXg0QYzwUkTPv8CqAwf+p794LNV3xupFQmQAzfwBYaLePZ3gVQN5Ci7nzb563ciqAkjdJjWdNfok1gvWtUQF9O2W1rk7AqrN969YJ9O2U1bo6AavO9q37A5jF5jGXG4ruAAAAAElFTkSuQmCC\",\n }}\n style={styles.navRightArrow}\n />\n </View>\n </View>\n <View style={styles.navBarTitleView}>\n <Text\n style={styles.titleText}\n numberOfLines={1}\n ellipsizeMode={\"tail\"}\n >\n {this.props.ad.popup.title_text}\n </Text>\n </View>\n <View style={styles.loadingIndicatorContainer}>\n {this.state.isPageLoading ? (\n <ActivityIndicator\n size=\"large\"\n color=\"#2969a0\"\n />\n ) : undefined}\n </View>\n </SafeAreaView>\n <WebView\n source={{\n uri: this.props.ad.action_path,\n }}\n ref={(ref) => {\n this.webViewElementRef = ref;\n }}\n androidHardwareAccelerationDisabled={true}\n automaticallyAdjustContentInsets={false}\n allowFileAccess={true}\n style={styles.webView}\n javaScriptEnabled={true}\n injectedJavaScript={\n this.props.ad.action_type === AdActionType.POPUP ||\n this.props.ad.action_type === AdActionType.LINK\n ? this.getAddToListCircularJavascript()\n : \"\"\n }\n onMessage={(event) => {\n const responseObj: DetailedListItem = JSON.parse(\n event.nativeEvent.data\n );\n\n safeInvoke(\n this.props.onAddToListItemClicked,\n responseObj\n );\n }}\n onNavigationStateChange={(navState) => {\n this.setState({\n canGoBack: navState.canGoBack,\n canGoForward: navState.canGoForward,\n });\n }}\n onLoadStart={() => {\n this.setState({\n isPageLoading: true,\n });\n }}\n onLoadEnd={() => {\n this.setState({\n isPageLoading: false,\n });\n }}\n />\n <SafeAreaView style={styles.closeButtonView}>\n <TouchableOpacity\n style={styles.closeButtonContainer}\n onPress={() => {\n safeInvoke(this.props.onClose);\n }}\n >\n <Text style={styles.closeButtonText}>Close</Text>\n </TouchableOpacity>\n </SafeAreaView>\n </SafeAreaView>\n </Modal>\n );\n }\n\n /**\n * Generates the javascript to pass down to the Web View that extracts the\n * clicked product information based on the circular ad design.\n * @returns the javascript string to pass to the Web View.\n */\n private getAddToListCircularJavascript(): string {\n // TODO: This method should ultimately be removed. We shouldn't have to\n // hack the web view's javascript just to get the correct data to\n // return. When the circular templates get reworked, we should\n // build in an onMessage response within the circulars page so we\n // don't have to do it this way.\n return `\n const adButtons = document.getElementsByTagName(\"button\");\n\n if (adButtons.length > 0) {\n if (adButtons.length > 1 && adButtons[1].getAttribute(\"data-payload-id\")) {\n for (let x = 0; x < adButtons.length; x++) {\n if (adButtons[x].getAttribute(\"data-payload-id\")) {\n adButtons[x].addEventListener(\"click\", (event) => {\n window.ReactNativeWebView.postMessage(\n JSON.stringify(\n window.AdAdapted.payloads[adButtons[x].getAttribute(\"data-payload-id\")]\n )\n );\n });\n }\n }\n } else {\n const onDataPostMessage = (imgSrc) => {\n const valueAfterLastSlash = imgSrc.match(/(?:[^\\\\/](?!(\\\\/)))+$/g).toString();\n const upcValueWithLeadingZeros = valueAfterLastSlash.match(/[^.]*/).toString();\n const finalUpcValue = parseInt(upcValueWithLeadingZeros, 10);\n const itemData = window.__NUXT__.data[0].items;\n let clickedItem = {};\n \n for (let i = 0; i < itemData.length; i++) {\n if (itemData[i].upc == finalUpcValue) {\n clickedItem = itemData[i];\n }\n }\n \n window.ReactNativeWebView.postMessage(\n JSON.stringify({\n product_barcode: clickedItem.upc,\n product_brand: clickedItem.brand,\n product_category: clickedItem.category,\n product_discount: clickedItem.sale_price,\n product_image: clickedItem.image,\n product_sku: clickedItem.retailer_sku,\n product_title: clickedItem.title\n })\n );\n };\n \n const onItemDialogLoad = () => {\n setTimeout(() => {\n document.getElementsByClassName(\"modal-body\")[0].getElementsByTagName(\"button\")[0].addEventListener(\"click\", (event) => {\n onDataPostMessage(\n event.target.parentElement.getElementsByTagName(\"img\")[0].getAttribute(\"src\")\n );\n });\n }, 100);\n };\n \n const adItemImages = document.querySelectorAll(\".item img\");\n const adItemPromotionDivs = document.querySelectorAll(\".item .promotion\");\n const adItemTitleDivs = document.querySelectorAll(\".item .title\");\n const adItemPricingDivs = document.querySelectorAll(\".item .pricing\");\n \n for (let x = 0; x < adItemImages.length; x++) {\n adItemImages[x].addEventListener(\"click\", (event) => {\n onItemDialogLoad();\n });\n }\n \n for (let x = 0; x < adItemPromotionDivs.length; x++) {\n adItemPromotionDivs[x].addEventListener(\"click\", (event) => {\n onItemDialogLoad();\n });\n }\n \n for (let x = 0; x < adItemTitleDivs.length; x++) {\n adItemTitleDivs[x].addEventListener(\"click\", (event) => {\n onItemDialogLoad();\n });\n }\n \n for (let x = 0; x < adItemPricingDivs.length; x++) {\n adItemPricingDivs[x].addEventListener(\"click\", (event) => {\n onItemDialogLoad();\n });\n }\n \n for (let x = 0; x < adButtons.length; x++) {\n adButtons[x].addEventListener(\"click\", (event) => {\n onDataPostMessage(\n event.target.parentElement.getElementsByTagName(\"img\")[0].getAttribute(\"src\")\n );\n });\n }\n }\n }\n `;\n }\n\n /**\n * Generates all component related styles.\n * @returns the styles needed for the component.\n */\n private generateStyles(): StyleDef {\n const backButtonOpacity = this.state.canGoBack ? 1 : 0.3;\n const forwardButtonOpacity = this.state.canGoForward ? 1 : 0.3;\n\n return StyleSheet.create({\n mainView: {\n display: \"flex\",\n flexDirection: \"column\",\n position: \"relative\",\n margin: 0,\n width: \"100%\",\n height: \"100%\",\n },\n navHeaderView: {\n display: \"flex\",\n flexDirection: \"row\",\n height: 60,\n width: \"100%\",\n backgroundColor: \"#dadada\",\n zIndex: 1,\n },\n navArrowsContainer: {\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"center\",\n alignItems: \"center\",\n },\n navLeftArrow: {\n width: 48,\n height: 48,\n marginRight: 5,\n marginLeft: 10,\n opacity: backButtonOpacity,\n },\n navRightArrow: {\n width: 48,\n height: 48,\n marginRight: 10,\n marginLeft: 5,\n opacity: forwardButtonOpacity,\n },\n navBarTitleView: {\n display: \"flex\",\n flexDirection: \"row\",\n alignItems: \"center\",\n flex: 1,\n },\n titleText: {\n color: \"#333333\",\n fontWeight: \"bold\",\n fontSize: 18,\n overflow: \"hidden\",\n flexWrap: \"nowrap\",\n },\n loadingIndicatorContainer: {\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"center\",\n alignItems: \"center\",\n marginLeft: 10,\n marginRight: 10,\n },\n webView: {\n width: \"100%\",\n height: \"100%\",\n zIndex: 0,\n },\n closeButtonView: {\n height: 60,\n width: \"100%\",\n backgroundColor: \"#dadada\",\n zIndex: 1,\n },\n closeButtonContainer: {\n display: \"flex\",\n justifyContent: \"center\",\n width: \"100%\",\n height: \"100%\",\n },\n closeButtonText: {\n width: \"100%\",\n color: \"#2969a0\",\n margin: \"auto\",\n fontSize: 18,\n textAlign: \"center\",\n },\n });\n }\n}\n"]}
@@ -1,50 +0,0 @@
1
- /**
2
- * Unit tests for {@link AdPopup}
3
- * @module
4
- */
5
- import * as React from "react";
6
- import { mount } from "enzyme";
7
- import { AdPopup } from "./AdPopup";
8
- import { AdActionType } from "../api/adadaptedApiTypes";
9
- describe("AdPopup", () => {
10
- test("Sample unit test", () => {
11
- const wrapper = mount( /*#__PURE__*/React.createElement(AdPopup, {
12
- ad: {
13
- ad_id: "1816",
14
- impression_id: "100838::C4D792785EA1EC91",
15
- refresh_time: 30,
16
- hide_after_interaction: false,
17
- type: "html",
18
- creative_url: "https://testurl.com/a/NTLKNZKYMMI2NTM1;100838;1815?session_id=TEST_SESSION_ID&amp;udid=00000000-0000-0000-0000-000000000000",
19
- tracking_html: "<html></html>",
20
- action_type: AdActionType.CONTENT,
21
- action_path: "",
22
- payload: {
23
- detailed_list_items: [{
24
- product_barcode: "0",
25
- product_brand: "Brand",
26
- product_category: "",
27
- product_discount: "",
28
- product_image: "",
29
- product_sku: "",
30
- product_title: "Sample Product"
31
- }]
32
- },
33
- popup: {
34
- title_text: "",
35
- background_color: "",
36
- text_color: "",
37
- alt_close_btn: "",
38
- type: "",
39
- hide_banner: false,
40
- hide_close_btn: false,
41
- hide_browser_nav: false
42
- }
43
- },
44
- onAddToListItemClicked: () => {// Mock this method.
45
- }
46
- }));
47
- wrapper.detach();
48
- });
49
- });
50
- //# sourceMappingURL=AdPopup.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["AdPopup.test.tsx"],"names":["React","mount","AdPopup","AdActionType","describe","test","wrapper","ad_id","impression_id","refresh_time","hide_after_interaction","type","creative_url","tracking_html","action_type","CONTENT","action_path","payload","detailed_list_items","product_barcode","product_brand","product_category","product_discount","product_image","product_sku","product_title","popup","title_text","background_color","text_color","alt_close_btn","hide_banner","hide_close_btn","hide_browser_nav","detach"],"mappings":"AAAA;AACA;AACA;AACA;AACA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,KAAT,QAAoC,QAApC;AAEA,SAASC,OAAT,QAAwB,WAAxB;AACA,SAASC,YAAT,QAA6B,0BAA7B;AAIAC,QAAQ,CAAC,SAAD,EAAY,MAAM;AACtBC,EAAAA,IAAI,CAAC,kBAAD,EAAqB,MAAM;AAC3B,UAAMC,OAAuB,GAAGL,KAAK,eACjC,oBAAC,OAAD;AACI,MAAA,EAAE,EAAE;AACAM,QAAAA,KAAK,EAAE,MADP;AAEAC,QAAAA,aAAa,EAAE,0BAFf;AAGAC,QAAAA,YAAY,EAAE,EAHd;AAIAC,QAAAA,sBAAsB,EAAE,KAJxB;AAKAC,QAAAA,IAAI,EAAE,MALN;AAMAC,QAAAA,YAAY,EACR,6HAPJ;AAQAC,QAAAA,aAAa,EAAE,eARf;AASAC,QAAAA,WAAW,EAAEX,YAAY,CAACY,OAT1B;AAUAC,QAAAA,WAAW,EAAE,EAVb;AAWAC,QAAAA,OAAO,EAAE;AACLC,UAAAA,mBAAmB,EAAE,CACjB;AACIC,YAAAA,eAAe,EAAE,GADrB;AAEIC,YAAAA,aAAa,EAAE,OAFnB;AAGIC,YAAAA,gBAAgB,EAAE,EAHtB;AAIIC,YAAAA,gBAAgB,EAAE,EAJtB;AAKIC,YAAAA,aAAa,EAAE,EALnB;AAMIC,YAAAA,WAAW,EAAE,EANjB;AAOIC,YAAAA,aAAa,EAAE;AAPnB,WADiB;AADhB,SAXT;AAwBAC,QAAAA,KAAK,EAAE;AACHC,UAAAA,UAAU,EAAE,EADT;AAEHC,UAAAA,gBAAgB,EAAE,EAFf;AAGHC,UAAAA,UAAU,EAAE,EAHT;AAIHC,UAAAA,aAAa,EAAE,EAJZ;AAKHnB,UAAAA,IAAI,EAAE,EALH;AAMHoB,UAAAA,WAAW,EAAE,KANV;AAOHC,UAAAA,cAAc,EAAE,KAPb;AAQHC,UAAAA,gBAAgB,EAAE;AARf;AAxBP,OADR;AAoCI,MAAA,sBAAsB,EAAE,MAAM,CAC1B;AACH;AAtCL,MADiC,CAArC;AA2CA3B,IAAAA,OAAO,CAAC4B,MAAR;AACH,GA7CG,CAAJ;AA8CH,CA/CO,CAAR","sourcesContent":["/**\n * Unit tests for {@link AdPopup}\n * @module\n */\nimport * as React from \"react\";\nimport { mount, ReactWrapper } from \"enzyme\";\nimport { ExtractReactPropsType } from \"../types\";\nimport { AdPopup } from \"./AdPopup\";\nimport { AdActionType } from \"../api/adadaptedApiTypes\";\n\ntype AdPopupWrapper = ReactWrapper<ExtractReactPropsType<typeof AdPopup>>;\n\ndescribe(\"AdPopup\", () => {\n test(\"Sample unit test\", () => {\n const wrapper: AdPopupWrapper = mount(\n <AdPopup\n ad={{\n ad_id: \"1816\",\n impression_id: \"100838::C4D792785EA1EC91\",\n refresh_time: 30,\n hide_after_interaction: false,\n type: \"html\",\n creative_url:\n \"https://testurl.com/a/NTLKNZKYMMI2NTM1;100838;1815?session_id=TEST_SESSION_ID&amp;udid=00000000-0000-0000-0000-000000000000\",\n tracking_html: \"<html></html>\",\n action_type: AdActionType.CONTENT,\n action_path: \"\",\n payload: {\n detailed_list_items: [\n {\n product_barcode: \"0\",\n product_brand: \"Brand\",\n product_category: \"\",\n product_discount: \"\",\n product_image: \"\",\n product_sku: \"\",\n product_title: \"Sample Product\",\n },\n ],\n },\n popup: {\n title_text: \"\",\n background_color: \"\",\n text_color: \"\",\n alt_close_btn: \"\",\n type: \"\",\n hide_banner: false,\n hide_close_btn: false,\n hide_browser_nav: false,\n },\n }}\n onAddToListItemClicked={() => {\n // Mock this method.\n }}\n />\n );\n\n wrapper.detach();\n });\n});\n"]}
@@ -1,75 +0,0 @@
1
- /**
2
- * Component for creating an {@link AdPopup}.
3
- * @module
4
- */
5
- import * as React from "react";
6
- import { Ad, DetailedListItem } from "../api/adadaptedApiTypes";
7
- /**
8
- * Props interface for {@link AdPopup}.
9
- */
10
- interface Props {
11
- /**
12
- * The add to display in the popup.
13
- */
14
- ad: Ad;
15
- /**
16
- * If true, the ad popup is displayed.
17
- */
18
- isOpen?: boolean;
19
- /**
20
- * Triggered when the popup is closing.
21
- */
22
- onClose?(): void;
23
- /**
24
- * Triggered when an ad circular item is clicked and
25
- * the item should be "added to list".
26
- * @param item - The item to add to list.
27
- */
28
- onAddToListItemClicked(item: DetailedListItem): void;
29
- }
30
- /**
31
- * State interface for {@link AdPopup}.
32
- */
33
- interface State {
34
- /**
35
- * If true, the popup web view can navigate back.
36
- */
37
- canGoBack: boolean;
38
- /**
39
- * If true, the popup web view can navigate forward.
40
- */
41
- canGoForward: boolean;
42
- /**
43
- * If true, the webview is loading a new page.
44
- */
45
- isPageLoading: boolean;
46
- }
47
- /**
48
- * Creates the AdPopup component.
49
- */
50
- export declare class AdPopup extends React.Component<Props, State> {
51
- /**
52
- * The web view element reference.
53
- */
54
- private webViewElementRef;
55
- /**
56
- * @inheritDoc
57
- */
58
- constructor(props: Props, context?: any);
59
- /**
60
- * @inheritDoc
61
- */
62
- render(): JSX.Element;
63
- /**
64
- * Generates the javascript to pass down to the Web View that extracts the
65
- * clicked product information based on the circular ad design.
66
- * @returns the javascript string to pass to the Web View.
67
- */
68
- private getAddToListCircularJavascript;
69
- /**
70
- * Generates all component related styles.
71
- * @returns the styles needed for the component.
72
- */
73
- private generateStyles;
74
- }
75
- export {};
@@ -1 +0,0 @@
1
- export {};