@bigbinary/neeto-molecules 3.16.76 → 3.16.78
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/ProductEmbed.js +31 -43
- package/dist/ProductEmbed.js.map +1 -1
- package/dist/cjs/ProductEmbed.js +31 -43
- package/dist/cjs/ProductEmbed.js.map +1 -1
- package/package.json +1 -1
- package/types/ProductEmbed.d.ts +3 -0
package/dist/ProductEmbed.js
CHANGED
|
@@ -5,6 +5,7 @@ import { useLocation, useHistory } from 'react-router-dom';
|
|
|
5
5
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
6
6
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
7
7
|
import classnames from 'classnames';
|
|
8
|
+
import useStateWithDependency from '@bigbinary/neeto-commons-frontend/react-utils/useStateWithDependency';
|
|
8
9
|
import LeftArrow from '@bigbinary/neeto-icons/LeftArrow';
|
|
9
10
|
import Button from '@bigbinary/neetoui/Button';
|
|
10
11
|
import Typography from '@bigbinary/neetoui/Typography';
|
|
@@ -73,7 +74,10 @@ var useProductEmbedStore = create(withImmutableActions(function (set) {
|
|
|
73
74
|
queryParams: [INITIAL_QUERY_PARAM],
|
|
74
75
|
queryParamsProps: {
|
|
75
76
|
helpPopoverProps: {},
|
|
76
|
-
label: ""
|
|
77
|
+
label: "",
|
|
78
|
+
keyPlaceholder: "",
|
|
79
|
+
valuePlaceholder: "",
|
|
80
|
+
addButtonLabel: ""
|
|
77
81
|
},
|
|
78
82
|
setProductEmbedState: set,
|
|
79
83
|
setQueryParams: function setQueryParams(queryParams) {
|
|
@@ -138,8 +142,7 @@ var elementPopupEmbedCode$1 = function elementPopupEmbedCode(_ref5) {
|
|
|
138
142
|
};
|
|
139
143
|
var iframeEmbedCode$1 = function iframeEmbedCode(_ref6) {
|
|
140
144
|
var id = _ref6.id,
|
|
141
|
-
customization = _ref6.customization
|
|
142
|
-
extraArgs = _ref6.extraArgs;
|
|
145
|
+
customization = _ref6.customization;
|
|
143
146
|
var height = customization.height,
|
|
144
147
|
width = customization.width,
|
|
145
148
|
iframeTitle = customization.iframeTitle,
|
|
@@ -148,8 +151,7 @@ var iframeEmbedCode$1 = function iframeEmbedCode(_ref6) {
|
|
|
148
151
|
var iframeSrc = buildIframeURL$1({
|
|
149
152
|
id: id,
|
|
150
153
|
iframeUrl: iframeUrl,
|
|
151
|
-
queryParams: queryParams
|
|
152
|
-
extraArgs: extraArgs
|
|
154
|
+
queryParams: queryParams
|
|
153
155
|
});
|
|
154
156
|
return "\n <!-- ".concat(globalProps.appName, " iframe embed code begins -->\n <iframe\n allowfullscreen\n height=\"").concat(height, "\"\n width=\"").concat(width, "\"\n frameborder=\"0\"\n title=\"").concat(iframeTitle, "\"\n src=\"").concat(iframeSrc, "\"\n />\n <!-- ").concat(globalProps.appName, " iframe embed code ends -->");
|
|
155
157
|
};
|
|
@@ -227,8 +229,7 @@ var elementPopupEmbedCode = function elementPopupEmbedCode(_ref5) {
|
|
|
227
229
|
};
|
|
228
230
|
var iframeEmbedCode = function iframeEmbedCode(_ref6) {
|
|
229
231
|
var customization = _ref6.customization,
|
|
230
|
-
id = _ref6.id
|
|
231
|
-
extraArgs = _ref6.extraArgs;
|
|
232
|
+
id = _ref6.id;
|
|
232
233
|
var height = customization.height,
|
|
233
234
|
width = customization.width,
|
|
234
235
|
iframeTitle = customization.iframeTitle,
|
|
@@ -237,8 +238,7 @@ var iframeEmbedCode = function iframeEmbedCode(_ref6) {
|
|
|
237
238
|
var iframeSrc = buildIframeURL$1({
|
|
238
239
|
id: id,
|
|
239
240
|
iframeUrl: iframeUrl,
|
|
240
|
-
queryParams: queryParams
|
|
241
|
-
extraArgs: extraArgs
|
|
241
|
+
queryParams: queryParams
|
|
242
242
|
});
|
|
243
243
|
return "\n const App = () => {\n return (\n <>\n {/* ".concat(globalProps.appName, " iframe embed code begins */}\n <iframe\n allowFullScreen\n height=\"").concat(height, "\"\n width=\"").concat(width, "\"\n frameBorder=\"0\"\n title=\"").concat(iframeTitle, "\"\n src=\"").concat(iframeSrc, "\"\n />\n {/* ").concat(globalProps.appName, " iframe embed code ends */}\n </>\n );\n };\n ");
|
|
244
244
|
};
|
|
@@ -283,28 +283,17 @@ var toCamelCasedString = function toCamelCasedString(string) {
|
|
|
283
283
|
};
|
|
284
284
|
var buildIframeURL$1 = function buildIframeURL(_ref3) {
|
|
285
285
|
var id = _ref3.id,
|
|
286
|
-
|
|
287
|
-
queryParams = _ref3.queryParams
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
var
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
url.searchParams.append(key, value);
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
if (extraArgs) {
|
|
301
|
-
Object.entries(extraArgs).forEach(function (_ref6) {
|
|
302
|
-
var _ref7 = _slicedToArray(_ref6, 2),
|
|
303
|
-
key = _ref7[0],
|
|
304
|
-
value = _ref7[1];
|
|
305
|
-
url.searchParams.append(key, value);
|
|
306
|
-
});
|
|
307
|
-
}
|
|
286
|
+
iframeUrl = _ref3.iframeUrl,
|
|
287
|
+
queryParams = _ref3.queryParams;
|
|
288
|
+
var url = new URL(iframeUrl || "".concat(location.origin, "/embed/").concat(id));
|
|
289
|
+
if (!queryParams) return url.toString();
|
|
290
|
+
var parsedQueryParams = JSON.parse(queryParams);
|
|
291
|
+
Object.entries(parsedQueryParams).forEach(function (_ref4) {
|
|
292
|
+
var _ref5 = _slicedToArray(_ref4, 2),
|
|
293
|
+
key = _ref5[0],
|
|
294
|
+
value = _ref5[1];
|
|
295
|
+
url.searchParams.append(key, value);
|
|
296
|
+
});
|
|
308
297
|
return url.toString();
|
|
309
298
|
};
|
|
310
299
|
|
|
@@ -362,7 +351,7 @@ var DynamicQueryParams = function DynamicQueryParams(_ref) {
|
|
|
362
351
|
"data-testid": "dynamic-query-key-name-input",
|
|
363
352
|
name: "queryParams.".concat(index, ".name"),
|
|
364
353
|
value: param.name,
|
|
365
|
-
placeholder: t("neetoMolecules.productEmbed.queryParam.keyNamePlaceholder"),
|
|
354
|
+
placeholder: queryParamsProps.keyPlaceholder || t("neetoMolecules.productEmbed.queryParam.keyNamePlaceholder"),
|
|
366
355
|
onChange: function onChange(e) {
|
|
367
356
|
return handleInputChange(index, "name", e.target.value);
|
|
368
357
|
}
|
|
@@ -371,7 +360,7 @@ var DynamicQueryParams = function DynamicQueryParams(_ref) {
|
|
|
371
360
|
"data-testid": "dynamic-query-key-value-input",
|
|
372
361
|
name: "queryParams.".concat(index, ".value"),
|
|
373
362
|
value: param.value,
|
|
374
|
-
placeholder: t("neetoMolecules.productEmbed.queryParam.keyValuePlaceholder"),
|
|
363
|
+
placeholder: queryParamsProps.valuePlaceholder || t("neetoMolecules.productEmbed.queryParam.keyValuePlaceholder"),
|
|
375
364
|
onChange: function onChange(e) {
|
|
376
365
|
return handleInputChange(index, "value", e.target.value);
|
|
377
366
|
}
|
|
@@ -387,10 +376,11 @@ var DynamicQueryParams = function DynamicQueryParams(_ref) {
|
|
|
387
376
|
}), /*#__PURE__*/jsx(Button, {
|
|
388
377
|
className: "my-2",
|
|
389
378
|
"data-cy": "dynamic-query-add-new-button",
|
|
379
|
+
"data-testid": "dynamic-query-add-new-button",
|
|
390
380
|
icon: Plus,
|
|
391
381
|
iconPosition: "left",
|
|
392
|
-
label: t("neetoMolecules.productEmbed.queryParam.addQueryParam"),
|
|
393
382
|
style: "link",
|
|
383
|
+
label: queryParamsProps.addButtonLabel || t("neetoMolecules.productEmbed.queryParam.addQueryParam"),
|
|
394
384
|
onClick: handleAddQueryParam
|
|
395
385
|
})]
|
|
396
386
|
});
|
|
@@ -1488,6 +1478,7 @@ n(css,{});
|
|
|
1488
1478
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1489
1479
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1490
1480
|
var EmbedRenderer = function EmbedRenderer(_ref) {
|
|
1481
|
+
var _options$iframe;
|
|
1491
1482
|
var className = _ref.className,
|
|
1492
1483
|
customEmbedScriptPath = _ref.customEmbedScriptPath,
|
|
1493
1484
|
customPreviewIframeUrl = _ref.customPreviewIframeUrl,
|
|
@@ -1506,12 +1497,12 @@ var EmbedRenderer = function EmbedRenderer(_ref) {
|
|
|
1506
1497
|
_useState2 = _slicedToArray(_useState, 2),
|
|
1507
1498
|
isScriptLoading = _useState2[0],
|
|
1508
1499
|
setIsScriptLoading = _useState2[1];
|
|
1509
|
-
var
|
|
1500
|
+
var _useStateWithDependen = useStateWithDependency(function () {
|
|
1510
1501
|
return buildDefaultCustomization(options);
|
|
1511
|
-
}),
|
|
1512
|
-
|
|
1513
|
-
customizations =
|
|
1514
|
-
setCustomizations =
|
|
1502
|
+
}, [options === null || options === void 0 || (_options$iframe = options.iframe) === null || _options$iframe === void 0 ? void 0 : _options$iframe.iframeUrl]),
|
|
1503
|
+
_useStateWithDependen2 = _slicedToArray(_useStateWithDependen, 2),
|
|
1504
|
+
customizations = _useStateWithDependen2[0],
|
|
1505
|
+
setCustomizations = _useStateWithDependen2[1];
|
|
1515
1506
|
var description = customizations[selectedEmbed].description;
|
|
1516
1507
|
var customization = customizations[selectedEmbed];
|
|
1517
1508
|
var CustomizationComponent = EMBED_CUSTOMIZATION_COMPONENTS[selectedEmbed];
|
|
@@ -1675,10 +1666,7 @@ var ProductEmbed = function ProductEmbed(_ref) {
|
|
|
1675
1666
|
_ref$isQueryParamsEna = _ref.isQueryParamsEnabled,
|
|
1676
1667
|
isQueryParamsEnabled = _ref$isQueryParamsEna === void 0 ? false : _ref$isQueryParamsEna,
|
|
1677
1668
|
_ref$queryParamsProps = _ref.queryParamsProps,
|
|
1678
|
-
queryParamsProps = _ref$queryParamsProps === void 0 ? {
|
|
1679
|
-
helpPopoverProps: {},
|
|
1680
|
-
label: ""
|
|
1681
|
-
} : _ref$queryParamsProps,
|
|
1669
|
+
queryParamsProps = _ref$queryParamsProps === void 0 ? {} : _ref$queryParamsProps,
|
|
1682
1670
|
_ref$options = _ref.options,
|
|
1683
1671
|
options = _ref$options === void 0 ? {} : _ref$options,
|
|
1684
1672
|
_ref$extraArgs = _ref.extraArgs,
|