@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.
@@ -7,6 +7,7 @@ var reactRouterDom = require('react-router-dom');
7
7
  var _defineProperty = require('@babel/runtime/helpers/defineProperty');
8
8
  var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
9
9
  var classnames = require('classnames');
10
+ var useStateWithDependency = require('@bigbinary/neeto-commons-frontend/react-utils/useStateWithDependency');
10
11
  var LeftArrow = require('@bigbinary/neeto-icons/LeftArrow');
11
12
  var Button = require('@bigbinary/neetoui/Button');
12
13
  var Typography = require('@bigbinary/neetoui/Typography');
@@ -75,7 +76,10 @@ var useProductEmbedStore = zustand.create(reactUtils.withImmutableActions(functi
75
76
  queryParams: [INITIAL_QUERY_PARAM],
76
77
  queryParamsProps: {
77
78
  helpPopoverProps: {},
78
- label: ""
79
+ label: "",
80
+ keyPlaceholder: "",
81
+ valuePlaceholder: "",
82
+ addButtonLabel: ""
79
83
  },
80
84
  setProductEmbedState: set,
81
85
  setQueryParams: function setQueryParams(queryParams) {
@@ -140,8 +144,7 @@ var elementPopupEmbedCode$1 = function elementPopupEmbedCode(_ref5) {
140
144
  };
141
145
  var iframeEmbedCode$1 = function iframeEmbedCode(_ref6) {
142
146
  var id = _ref6.id,
143
- customization = _ref6.customization,
144
- extraArgs = _ref6.extraArgs;
147
+ customization = _ref6.customization;
145
148
  var height = customization.height,
146
149
  width = customization.width,
147
150
  iframeTitle = customization.iframeTitle,
@@ -150,8 +153,7 @@ var iframeEmbedCode$1 = function iframeEmbedCode(_ref6) {
150
153
  var iframeSrc = buildIframeURL$1({
151
154
  id: id,
152
155
  iframeUrl: iframeUrl,
153
- queryParams: queryParams,
154
- extraArgs: extraArgs
156
+ queryParams: queryParams
155
157
  });
156
158
  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 -->");
157
159
  };
@@ -229,8 +231,7 @@ var elementPopupEmbedCode = function elementPopupEmbedCode(_ref5) {
229
231
  };
230
232
  var iframeEmbedCode = function iframeEmbedCode(_ref6) {
231
233
  var customization = _ref6.customization,
232
- id = _ref6.id,
233
- extraArgs = _ref6.extraArgs;
234
+ id = _ref6.id;
234
235
  var height = customization.height,
235
236
  width = customization.width,
236
237
  iframeTitle = customization.iframeTitle,
@@ -239,8 +240,7 @@ var iframeEmbedCode = function iframeEmbedCode(_ref6) {
239
240
  var iframeSrc = buildIframeURL$1({
240
241
  id: id,
241
242
  iframeUrl: iframeUrl,
242
- queryParams: queryParams,
243
- extraArgs: extraArgs
243
+ queryParams: queryParams
244
244
  });
245
245
  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 ");
246
246
  };
@@ -285,28 +285,17 @@ var toCamelCasedString = function toCamelCasedString(string) {
285
285
  };
286
286
  var buildIframeURL$1 = function buildIframeURL(_ref3) {
287
287
  var id = _ref3.id,
288
- iframeURL = _ref3.iframeURL,
289
- queryParams = _ref3.queryParams,
290
- extraArgs = _ref3.extraArgs;
291
- var url = new URL(iframeURL || "".concat(location.origin, "/embed/").concat(id));
292
- if (!queryParams && !extraArgs) return url.toString();
293
- if (queryParams) {
294
- var parsedQueryParams = JSON.parse(queryParams);
295
- Object.entries(parsedQueryParams).forEach(function (_ref4) {
296
- var _ref5 = _slicedToArray(_ref4, 2),
297
- key = _ref5[0],
298
- value = _ref5[1];
299
- url.searchParams.append(key, value);
300
- });
301
- }
302
- if (extraArgs) {
303
- Object.entries(extraArgs).forEach(function (_ref6) {
304
- var _ref7 = _slicedToArray(_ref6, 2),
305
- key = _ref7[0],
306
- value = _ref7[1];
307
- url.searchParams.append(key, value);
308
- });
309
- }
288
+ iframeUrl = _ref3.iframeUrl,
289
+ queryParams = _ref3.queryParams;
290
+ var url = new URL(iframeUrl || "".concat(location.origin, "/embed/").concat(id));
291
+ if (!queryParams) return url.toString();
292
+ var parsedQueryParams = JSON.parse(queryParams);
293
+ Object.entries(parsedQueryParams).forEach(function (_ref4) {
294
+ var _ref5 = _slicedToArray(_ref4, 2),
295
+ key = _ref5[0],
296
+ value = _ref5[1];
297
+ url.searchParams.append(key, value);
298
+ });
310
299
  return url.toString();
311
300
  };
312
301
 
@@ -364,7 +353,7 @@ var DynamicQueryParams = function DynamicQueryParams(_ref) {
364
353
  "data-testid": "dynamic-query-key-name-input",
365
354
  name: "queryParams.".concat(index, ".name"),
366
355
  value: param.name,
367
- placeholder: t("neetoMolecules.productEmbed.queryParam.keyNamePlaceholder"),
356
+ placeholder: queryParamsProps.keyPlaceholder || t("neetoMolecules.productEmbed.queryParam.keyNamePlaceholder"),
368
357
  onChange: function onChange(e) {
369
358
  return handleInputChange(index, "name", e.target.value);
370
359
  }
@@ -373,7 +362,7 @@ var DynamicQueryParams = function DynamicQueryParams(_ref) {
373
362
  "data-testid": "dynamic-query-key-value-input",
374
363
  name: "queryParams.".concat(index, ".value"),
375
364
  value: param.value,
376
- placeholder: t("neetoMolecules.productEmbed.queryParam.keyValuePlaceholder"),
365
+ placeholder: queryParamsProps.valuePlaceholder || t("neetoMolecules.productEmbed.queryParam.keyValuePlaceholder"),
377
366
  onChange: function onChange(e) {
378
367
  return handleInputChange(index, "value", e.target.value);
379
368
  }
@@ -389,10 +378,11 @@ var DynamicQueryParams = function DynamicQueryParams(_ref) {
389
378
  }), /*#__PURE__*/jsxRuntime.jsx(Button, {
390
379
  className: "my-2",
391
380
  "data-cy": "dynamic-query-add-new-button",
381
+ "data-testid": "dynamic-query-add-new-button",
392
382
  icon: Plus,
393
383
  iconPosition: "left",
394
- label: t("neetoMolecules.productEmbed.queryParam.addQueryParam"),
395
384
  style: "link",
385
+ label: queryParamsProps.addButtonLabel || t("neetoMolecules.productEmbed.queryParam.addQueryParam"),
396
386
  onClick: handleAddQueryParam
397
387
  })]
398
388
  });
@@ -1490,6 +1480,7 @@ injectCss.n(css,{});
1490
1480
  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; }
1491
1481
  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; }
1492
1482
  var EmbedRenderer = function EmbedRenderer(_ref) {
1483
+ var _options$iframe;
1493
1484
  var className = _ref.className,
1494
1485
  customEmbedScriptPath = _ref.customEmbedScriptPath,
1495
1486
  customPreviewIframeUrl = _ref.customPreviewIframeUrl,
@@ -1508,12 +1499,12 @@ var EmbedRenderer = function EmbedRenderer(_ref) {
1508
1499
  _useState2 = _slicedToArray(_useState, 2),
1509
1500
  isScriptLoading = _useState2[0],
1510
1501
  setIsScriptLoading = _useState2[1];
1511
- var _useState3 = React.useState(function () {
1502
+ var _useStateWithDependen = useStateWithDependency(function () {
1512
1503
  return buildDefaultCustomization(options);
1513
- }),
1514
- _useState4 = _slicedToArray(_useState3, 2),
1515
- customizations = _useState4[0],
1516
- setCustomizations = _useState4[1];
1504
+ }, [options === null || options === void 0 || (_options$iframe = options.iframe) === null || _options$iframe === void 0 ? void 0 : _options$iframe.iframeUrl]),
1505
+ _useStateWithDependen2 = _slicedToArray(_useStateWithDependen, 2),
1506
+ customizations = _useStateWithDependen2[0],
1507
+ setCustomizations = _useStateWithDependen2[1];
1517
1508
  var description = customizations[selectedEmbed].description;
1518
1509
  var customization = customizations[selectedEmbed];
1519
1510
  var CustomizationComponent = EMBED_CUSTOMIZATION_COMPONENTS[selectedEmbed];
@@ -1677,10 +1668,7 @@ var ProductEmbed = function ProductEmbed(_ref) {
1677
1668
  _ref$isQueryParamsEna = _ref.isQueryParamsEnabled,
1678
1669
  isQueryParamsEnabled = _ref$isQueryParamsEna === void 0 ? false : _ref$isQueryParamsEna,
1679
1670
  _ref$queryParamsProps = _ref.queryParamsProps,
1680
- queryParamsProps = _ref$queryParamsProps === void 0 ? {
1681
- helpPopoverProps: {},
1682
- label: ""
1683
- } : _ref$queryParamsProps,
1671
+ queryParamsProps = _ref$queryParamsProps === void 0 ? {} : _ref$queryParamsProps,
1684
1672
  _ref$options = _ref.options,
1685
1673
  options = _ref$options === void 0 ? {} : _ref$options,
1686
1674
  _ref$extraArgs = _ref.extraArgs,