@bigbinary/neeto-molecules 3.16.64 → 3.16.66

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.
@@ -136,10 +136,28 @@ var elementPopupEmbedCode$1 = function elementPopupEmbedCode(_ref5) {
136
136
  queryParams = customization.queryParams;
137
137
  return "\n <!-- This is a demo button, you can use any element on your website instead. -->\n <button id=\"".concat(elementSelector, "\">Click to open popup</button>\n\n <!-- ").concat(globalProps.appName, " element-click embed code begins -->\n ").concat(embedBaseScript(embedScriptLink), "\n <script>\n ").concat(camelCasedAppName$1, ".embed({\n type: \"elementClick\",\n id: \"").concat(id, "\",\n organization: \"").concat(globalProps.organization.subdomain, "\",\n elementSelector: \"#").concat(elementSelector, "\",").concat(embedQueryParam$1(queryParams)).concat(embedEnv$1()).concat(parseExtraArgs$1(extraArgs), "\n });\n </script>\n <!-- ").concat(globalProps.appName, " element-click embed code ends -->");
138
138
  };
139
+ var iframeEmbedCode$1 = function iframeEmbedCode(_ref6) {
140
+ var id = _ref6.id,
141
+ customization = _ref6.customization,
142
+ extraArgs = _ref6.extraArgs;
143
+ var height = customization.height,
144
+ width = customization.width,
145
+ iframeTitle = customization.iframeTitle,
146
+ iframeUrl = customization.iframeUrl,
147
+ queryParams = customization.queryParams;
148
+ var iframeSrc = buildIframeURL$1({
149
+ id: id,
150
+ iframeUrl: iframeUrl,
151
+ queryParams: queryParams,
152
+ extraArgs: extraArgs
153
+ });
154
+ 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
+ };
139
156
  var htmlCodeGenerators = {
140
157
  inline: inlineEmbedCode$1,
141
158
  floatingPopup: floatingPopupEmbedCode$1,
142
- elementPopup: elementPopupEmbedCode$1
159
+ elementPopup: elementPopupEmbedCode$1,
160
+ iframe: iframeEmbedCode$1
143
161
  };
144
162
 
145
163
  var camelCasedAppName = globalProps.appName.replace(/^neeto/i, "neeto");
@@ -207,10 +225,28 @@ var elementPopupEmbedCode = function elementPopupEmbedCode(_ref5) {
207
225
  queryParams = customization.queryParams;
208
226
  return "\n import { useEffect } from \"react\";\n\n const App = () => {\n const ".concat(embedFunctionName, " = () => {\n ").concat(embedScript(embedScriptLink), "\n embedScript.onload = () => {\n window.").concat(camelCasedAppName, ".embed({\n type: \"elementClick\",\n id: \"").concat(id, "\",\n organization: \"").concat(globalProps.organization.subdomain, "\",\n elementSelector: \"#").concat(elementSelector, "\",").concat(embedQueryParam(queryParams)).concat(embedEnv()).concat(parseExtraArgs(extraArgs), "\n });\n };\n\n document.body.appendChild(embedScript);\n ").concat(cleanupFunction, "\n };\n\n useEffect(() => ").concat(embedFunctionName, "(), []);\n\n return <button id=\"").concat(elementSelector, "\">Click to open popup</button>;\n };");
209
227
  };
228
+ var iframeEmbedCode = function iframeEmbedCode(_ref6) {
229
+ var customization = _ref6.customization,
230
+ id = _ref6.id,
231
+ extraArgs = _ref6.extraArgs;
232
+ var height = customization.height,
233
+ width = customization.width,
234
+ iframeTitle = customization.iframeTitle,
235
+ iframeUrl = customization.iframeUrl,
236
+ queryParams = customization.queryParams;
237
+ var iframeSrc = buildIframeURL$1({
238
+ id: id,
239
+ iframeUrl: iframeUrl,
240
+ queryParams: queryParams,
241
+ extraArgs: extraArgs
242
+ });
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
+ };
210
245
  var reactCodeGenerators = {
211
246
  inline: inlineEmbedCode,
212
247
  floatingPopup: floatingPopupEmbedCode,
213
- elementPopup: elementPopupEmbedCode
248
+ elementPopup: elementPopupEmbedCode,
249
+ iframe: iframeEmbedCode
214
250
  };
215
251
 
216
252
  var _excluded = ["selectedLanguage", "type"];
@@ -245,6 +281,32 @@ var toCamelCasedString = function toCamelCasedString(string) {
245
281
  return nextChar.toUpperCase();
246
282
  });
247
283
  };
284
+ var buildIframeURL$1 = function buildIframeURL(_ref3) {
285
+ var id = _ref3.id,
286
+ iframeURL = _ref3.iframeURL,
287
+ queryParams = _ref3.queryParams,
288
+ extraArgs = _ref3.extraArgs;
289
+ var url = new URL(iframeURL || "".concat(location.origin, "/embed/").concat(id));
290
+ if (!queryParams && !extraArgs) return url.toString();
291
+ if (queryParams) {
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
+ });
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
+ }
308
+ return url.toString();
309
+ };
248
310
 
249
311
  function ownKeys$3(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; }
250
312
  function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -474,6 +536,72 @@ var FloatingPopup$1 = function FloatingPopup(_ref) {
474
536
  });
475
537
  };
476
538
 
539
+ var Iframe$1 = function Iframe(_ref) {
540
+ var customization = _ref.customization,
541
+ updateCustomization = _ref.updateCustomization,
542
+ otherCustomizations = _ref.otherCustomizations;
543
+ var _useTranslation = useTranslation(),
544
+ t = _useTranslation.t;
545
+ var _useProductEmbedStore = useProductEmbedStore(function (store) {
546
+ return {
547
+ isQueryParamsEnabled: store["isQueryParamsEnabled"]
548
+ };
549
+ }, shallow),
550
+ isQueryParamsEnabled = _useProductEmbedStore.isQueryParamsEnabled;
551
+ var height = customization.height,
552
+ width = customization.width;
553
+ var handleInputChange = function handleInputChange(_ref2, attribute) {
554
+ var value = _ref2.target.value;
555
+ return updateCustomization(_defineProperty({}, attribute, value));
556
+ };
557
+ useEffect(function () {
558
+ if (isQueryParamsEnabled) return;
559
+ updateCustomization({
560
+ queryParams: undefined
561
+ });
562
+ }, []);
563
+ return /*#__PURE__*/jsxs(Fragment, {
564
+ children: [/*#__PURE__*/jsxs("div", {
565
+ className: "flex flex-col gap-2",
566
+ children: [/*#__PURE__*/jsx(Label, {
567
+ "data-cy": "window-size-text",
568
+ children: t("neetoMolecules.productEmbed.iframe.sizeOfIframe")
569
+ }), /*#__PURE__*/jsxs("div", {
570
+ className: "flex justify-between gap-x-2",
571
+ children: [/*#__PURE__*/jsx(Input, {
572
+ className: "neeto-molecules-product-embed-size-input",
573
+ "data-cy": "iframe-width-input-field",
574
+ "data-testid": "iframe-width-input-field",
575
+ max: 100,
576
+ min: 0,
577
+ prefix: "W",
578
+ suffix: "%",
579
+ type: "number",
580
+ value: width,
581
+ onChange: function onChange(e) {
582
+ return handleInputChange(e, "width");
583
+ }
584
+ }), /*#__PURE__*/jsx(Input, {
585
+ className: "neeto-molecules-product-embed-size-input",
586
+ "data-cy": "iframe-height-input-field",
587
+ "data-testid": "iframe-height-input-field",
588
+ max: 100,
589
+ min: 0,
590
+ prefix: "H",
591
+ suffix: "%",
592
+ type: "number",
593
+ value: height,
594
+ onChange: function onChange(e) {
595
+ return handleInputChange(e, "height");
596
+ }
597
+ })]
598
+ })]
599
+ }), otherCustomizations(), isQueryParamsEnabled && /*#__PURE__*/jsx(DynamicQueryParams, {
600
+ updateCustomization: updateCustomization
601
+ })]
602
+ });
603
+ };
604
+
477
605
  var Inline$1 = function Inline(_ref) {
478
606
  var customization = _ref.customization,
479
607
  updateCustomization = _ref.updateCustomization,
@@ -1032,10 +1160,11 @@ var ElementPopupIcon = function ElementPopupIcon(_ref3) {
1032
1160
  var EMBED_OPTIONS = {
1033
1161
  INLINE: "inline",
1034
1162
  FLOATING_POPUP: "floatingPopup",
1035
- ELEMENT_POPUP: "elementPopup"
1163
+ ELEMENT_POPUP: "elementPopup",
1164
+ IFRAME: "iframe"
1036
1165
  };
1037
- var EMBED_ICONS = _defineProperty(_defineProperty(_defineProperty({}, EMBED_OPTIONS.INLINE, InlineEmbedIcon), EMBED_OPTIONS.FLOATING_POPUP, FloatingPopupIcon), EMBED_OPTIONS.ELEMENT_POPUP, ElementPopupIcon);
1038
- var DEFAULT_CUSTOMIZATION = _defineProperty(_defineProperty(_defineProperty({}, EMBED_OPTIONS.INLINE, {
1166
+ var EMBED_ICONS = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, EMBED_OPTIONS.INLINE, InlineEmbedIcon), EMBED_OPTIONS.FLOATING_POPUP, FloatingPopupIcon), EMBED_OPTIONS.ELEMENT_POPUP, ElementPopupIcon), EMBED_OPTIONS.IFRAME, InlineEmbedIcon);
1167
+ var DEFAULT_CUSTOMIZATION = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, EMBED_OPTIONS.INLINE, {
1039
1168
  width: 100,
1040
1169
  height: 100,
1041
1170
  elementSelector: "inline-embed-container"
@@ -1047,9 +1176,13 @@ var DEFAULT_CUSTOMIZATION = _defineProperty(_defineProperty(_defineProperty({},
1047
1176
  btnPosition: "bottomRight"
1048
1177
  }), EMBED_OPTIONS.ELEMENT_POPUP, {
1049
1178
  elementSelector: "open-popup-button"
1179
+ }), EMBED_OPTIONS.IFRAME, {
1180
+ height: 100,
1181
+ width: 100,
1182
+ iframeTitle: "Iframe embed"
1050
1183
  });
1051
- var EMBED_CUSTOMIZATION_COMPONENTS = _defineProperty(_defineProperty(_defineProperty({}, EMBED_OPTIONS.INLINE, Inline$1), EMBED_OPTIONS.FLOATING_POPUP, FloatingPopup$1), EMBED_OPTIONS.ELEMENT_POPUP, ElementPopup$1);
1052
- var EMBED_TITLES = _defineProperty(_defineProperty(_defineProperty({}, EMBED_OPTIONS.INLINE, t("neetoMolecules.productEmbed.inline.title")), EMBED_OPTIONS.FLOATING_POPUP, t("neetoMolecules.productEmbed.floatingPopup.title")), EMBED_OPTIONS.ELEMENT_POPUP, t("neetoMolecules.productEmbed.elementPopup.title"));
1184
+ var EMBED_CUSTOMIZATION_COMPONENTS = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, EMBED_OPTIONS.INLINE, Inline$1), EMBED_OPTIONS.FLOATING_POPUP, FloatingPopup$1), EMBED_OPTIONS.ELEMENT_POPUP, ElementPopup$1), EMBED_OPTIONS.IFRAME, Iframe$1);
1185
+ var EMBED_TITLES = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, EMBED_OPTIONS.INLINE, t("neetoMolecules.productEmbed.inline.title")), EMBED_OPTIONS.FLOATING_POPUP, t("neetoMolecules.productEmbed.floatingPopup.title")), EMBED_OPTIONS.ELEMENT_POPUP, t("neetoMolecules.productEmbed.elementPopup.title")), EMBED_OPTIONS.IFRAME, t("neetoMolecules.productEmbed.iframe.title"));
1053
1186
  var SUPPORTED_LANGUAGES = [{
1054
1187
  value: "html",
1055
1188
  label: t("neetoMolecules.productEmbed.language.html")
@@ -1323,6 +1456,23 @@ var FloatingPopup = function FloatingPopup(_ref) {
1323
1456
  });
1324
1457
  };
1325
1458
 
1459
+ var Iframe = function Iframe(_ref) {
1460
+ var iframeURL = _ref.iframeURL,
1461
+ customization = _ref.customization;
1462
+ var height = customization.height,
1463
+ width = customization.width,
1464
+ iframeTitle = customization.iframeTitle;
1465
+ return /*#__PURE__*/jsx("iframe", {
1466
+ allowFullScreen: true,
1467
+ className: "m-auto",
1468
+ frameBorder: "0",
1469
+ height: "".concat(height, "%"),
1470
+ src: iframeURL,
1471
+ title: iframeTitle,
1472
+ width: "".concat(width, "%")
1473
+ });
1474
+ };
1475
+
1326
1476
  var Inline = function Inline(_ref) {
1327
1477
  var iframeURL = _ref.iframeURL,
1328
1478
  customization = _ref.customization;
@@ -1357,7 +1507,7 @@ var Preview = function Preview(_ref) {
1357
1507
  };
1358
1508
  }, shallow),
1359
1509
  queryParams = _useProductEmbedStore.queryParams;
1360
- var preview = _defineProperty(_defineProperty(_defineProperty({}, EMBED_OPTIONS.INLINE, Inline), EMBED_OPTIONS.FLOATING_POPUP, FloatingPopup), EMBED_OPTIONS.ELEMENT_POPUP, ElementPopup);
1510
+ var preview = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, EMBED_OPTIONS.INLINE, Inline), EMBED_OPTIONS.FLOATING_POPUP, FloatingPopup), EMBED_OPTIONS.ELEMENT_POPUP, ElementPopup), EMBED_OPTIONS.IFRAME, Iframe);
1361
1511
  var iframeURL = buildIframeURL(customPreviewIframeUrl || "".concat(location.origin, "/embed/").concat(id), queryParams);
1362
1512
  var Component = preview[selectedEmbed];
1363
1513
  if (isScriptLoading) {