@bigbinary/neeto-molecules 3.16.65 → 3.16.67
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/FloatingActionMenu.js +1 -1
- package/dist/FloatingActionMenu.js.map +1 -1
- package/dist/ProductEmbed.js +158 -8
- package/dist/ProductEmbed.js.map +1 -1
- package/dist/cjs/FloatingActionMenu.js +1 -1
- package/dist/cjs/FloatingActionMenu.js.map +1 -1
- package/dist/cjs/ProductEmbed.js +158 -8
- package/dist/cjs/ProductEmbed.js.map +1 -1
- package/package.json +1 -1
- package/src/translations/en.json +4 -0
- package/types/ProductEmbed.d.ts +10 -0
package/dist/cjs/ProductEmbed.js
CHANGED
|
@@ -138,10 +138,28 @@ var elementPopupEmbedCode$1 = function elementPopupEmbedCode(_ref5) {
|
|
|
138
138
|
queryParams = customization.queryParams;
|
|
139
139
|
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 -->");
|
|
140
140
|
};
|
|
141
|
+
var iframeEmbedCode$1 = function iframeEmbedCode(_ref6) {
|
|
142
|
+
var id = _ref6.id,
|
|
143
|
+
customization = _ref6.customization,
|
|
144
|
+
extraArgs = _ref6.extraArgs;
|
|
145
|
+
var height = customization.height,
|
|
146
|
+
width = customization.width,
|
|
147
|
+
iframeTitle = customization.iframeTitle,
|
|
148
|
+
iframeUrl = customization.iframeUrl,
|
|
149
|
+
queryParams = customization.queryParams;
|
|
150
|
+
var iframeSrc = buildIframeURL$1({
|
|
151
|
+
id: id,
|
|
152
|
+
iframeUrl: iframeUrl,
|
|
153
|
+
queryParams: queryParams,
|
|
154
|
+
extraArgs: extraArgs
|
|
155
|
+
});
|
|
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 -->");
|
|
157
|
+
};
|
|
141
158
|
var htmlCodeGenerators = {
|
|
142
159
|
inline: inlineEmbedCode$1,
|
|
143
160
|
floatingPopup: floatingPopupEmbedCode$1,
|
|
144
|
-
elementPopup: elementPopupEmbedCode$1
|
|
161
|
+
elementPopup: elementPopupEmbedCode$1,
|
|
162
|
+
iframe: iframeEmbedCode$1
|
|
145
163
|
};
|
|
146
164
|
|
|
147
165
|
var camelCasedAppName = globalProps.appName.replace(/^neeto/i, "neeto");
|
|
@@ -209,10 +227,28 @@ var elementPopupEmbedCode = function elementPopupEmbedCode(_ref5) {
|
|
|
209
227
|
queryParams = customization.queryParams;
|
|
210
228
|
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 };");
|
|
211
229
|
};
|
|
230
|
+
var iframeEmbedCode = function iframeEmbedCode(_ref6) {
|
|
231
|
+
var customization = _ref6.customization,
|
|
232
|
+
id = _ref6.id,
|
|
233
|
+
extraArgs = _ref6.extraArgs;
|
|
234
|
+
var height = customization.height,
|
|
235
|
+
width = customization.width,
|
|
236
|
+
iframeTitle = customization.iframeTitle,
|
|
237
|
+
iframeUrl = customization.iframeUrl,
|
|
238
|
+
queryParams = customization.queryParams;
|
|
239
|
+
var iframeSrc = buildIframeURL$1({
|
|
240
|
+
id: id,
|
|
241
|
+
iframeUrl: iframeUrl,
|
|
242
|
+
queryParams: queryParams,
|
|
243
|
+
extraArgs: extraArgs
|
|
244
|
+
});
|
|
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
|
+
};
|
|
212
247
|
var reactCodeGenerators = {
|
|
213
248
|
inline: inlineEmbedCode,
|
|
214
249
|
floatingPopup: floatingPopupEmbedCode,
|
|
215
|
-
elementPopup: elementPopupEmbedCode
|
|
250
|
+
elementPopup: elementPopupEmbedCode,
|
|
251
|
+
iframe: iframeEmbedCode
|
|
216
252
|
};
|
|
217
253
|
|
|
218
254
|
var _excluded = ["selectedLanguage", "type"];
|
|
@@ -247,6 +283,32 @@ var toCamelCasedString = function toCamelCasedString(string) {
|
|
|
247
283
|
return nextChar.toUpperCase();
|
|
248
284
|
});
|
|
249
285
|
};
|
|
286
|
+
var buildIframeURL$1 = function buildIframeURL(_ref3) {
|
|
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
|
+
}
|
|
310
|
+
return url.toString();
|
|
311
|
+
};
|
|
250
312
|
|
|
251
313
|
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; }
|
|
252
314
|
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; }
|
|
@@ -476,6 +538,72 @@ var FloatingPopup$1 = function FloatingPopup(_ref) {
|
|
|
476
538
|
});
|
|
477
539
|
};
|
|
478
540
|
|
|
541
|
+
var Iframe$1 = function Iframe(_ref) {
|
|
542
|
+
var customization = _ref.customization,
|
|
543
|
+
updateCustomization = _ref.updateCustomization,
|
|
544
|
+
otherCustomizations = _ref.otherCustomizations;
|
|
545
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
546
|
+
t = _useTranslation.t;
|
|
547
|
+
var _useProductEmbedStore = useProductEmbedStore(function (store) {
|
|
548
|
+
return {
|
|
549
|
+
isQueryParamsEnabled: store["isQueryParamsEnabled"]
|
|
550
|
+
};
|
|
551
|
+
}, shallow.shallow),
|
|
552
|
+
isQueryParamsEnabled = _useProductEmbedStore.isQueryParamsEnabled;
|
|
553
|
+
var height = customization.height,
|
|
554
|
+
width = customization.width;
|
|
555
|
+
var handleInputChange = function handleInputChange(_ref2, attribute) {
|
|
556
|
+
var value = _ref2.target.value;
|
|
557
|
+
return updateCustomization(_defineProperty({}, attribute, value));
|
|
558
|
+
};
|
|
559
|
+
React.useEffect(function () {
|
|
560
|
+
if (isQueryParamsEnabled) return;
|
|
561
|
+
updateCustomization({
|
|
562
|
+
queryParams: undefined
|
|
563
|
+
});
|
|
564
|
+
}, []);
|
|
565
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
566
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
567
|
+
className: "flex flex-col gap-2",
|
|
568
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Label, {
|
|
569
|
+
"data-cy": "window-size-text",
|
|
570
|
+
children: t("neetoMolecules.productEmbed.iframe.sizeOfIframe")
|
|
571
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
572
|
+
className: "flex justify-between gap-x-2",
|
|
573
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Input, {
|
|
574
|
+
className: "neeto-molecules-product-embed-size-input",
|
|
575
|
+
"data-cy": "iframe-width-input-field",
|
|
576
|
+
"data-testid": "iframe-width-input-field",
|
|
577
|
+
max: 100,
|
|
578
|
+
min: 0,
|
|
579
|
+
prefix: "W",
|
|
580
|
+
suffix: "%",
|
|
581
|
+
type: "number",
|
|
582
|
+
value: width,
|
|
583
|
+
onChange: function onChange(e) {
|
|
584
|
+
return handleInputChange(e, "width");
|
|
585
|
+
}
|
|
586
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Input, {
|
|
587
|
+
className: "neeto-molecules-product-embed-size-input",
|
|
588
|
+
"data-cy": "iframe-height-input-field",
|
|
589
|
+
"data-testid": "iframe-height-input-field",
|
|
590
|
+
max: 100,
|
|
591
|
+
min: 0,
|
|
592
|
+
prefix: "H",
|
|
593
|
+
suffix: "%",
|
|
594
|
+
type: "number",
|
|
595
|
+
value: height,
|
|
596
|
+
onChange: function onChange(e) {
|
|
597
|
+
return handleInputChange(e, "height");
|
|
598
|
+
}
|
|
599
|
+
})]
|
|
600
|
+
})]
|
|
601
|
+
}), otherCustomizations(), isQueryParamsEnabled && /*#__PURE__*/jsxRuntime.jsx(DynamicQueryParams, {
|
|
602
|
+
updateCustomization: updateCustomization
|
|
603
|
+
})]
|
|
604
|
+
});
|
|
605
|
+
};
|
|
606
|
+
|
|
479
607
|
var Inline$1 = function Inline(_ref) {
|
|
480
608
|
var customization = _ref.customization,
|
|
481
609
|
updateCustomization = _ref.updateCustomization,
|
|
@@ -1034,10 +1162,11 @@ var ElementPopupIcon = function ElementPopupIcon(_ref3) {
|
|
|
1034
1162
|
var EMBED_OPTIONS = {
|
|
1035
1163
|
INLINE: "inline",
|
|
1036
1164
|
FLOATING_POPUP: "floatingPopup",
|
|
1037
|
-
ELEMENT_POPUP: "elementPopup"
|
|
1165
|
+
ELEMENT_POPUP: "elementPopup",
|
|
1166
|
+
IFRAME: "iframe"
|
|
1038
1167
|
};
|
|
1039
|
-
var EMBED_ICONS = _defineProperty(_defineProperty(_defineProperty({}, EMBED_OPTIONS.INLINE, InlineEmbedIcon), EMBED_OPTIONS.FLOATING_POPUP, FloatingPopupIcon), EMBED_OPTIONS.ELEMENT_POPUP, ElementPopupIcon);
|
|
1040
|
-
var DEFAULT_CUSTOMIZATION = _defineProperty(_defineProperty(_defineProperty({}, EMBED_OPTIONS.INLINE, {
|
|
1168
|
+
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);
|
|
1169
|
+
var DEFAULT_CUSTOMIZATION = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, EMBED_OPTIONS.INLINE, {
|
|
1041
1170
|
width: 100,
|
|
1042
1171
|
height: 100,
|
|
1043
1172
|
elementSelector: "inline-embed-container"
|
|
@@ -1049,9 +1178,13 @@ var DEFAULT_CUSTOMIZATION = _defineProperty(_defineProperty(_defineProperty({},
|
|
|
1049
1178
|
btnPosition: "bottomRight"
|
|
1050
1179
|
}), EMBED_OPTIONS.ELEMENT_POPUP, {
|
|
1051
1180
|
elementSelector: "open-popup-button"
|
|
1181
|
+
}), EMBED_OPTIONS.IFRAME, {
|
|
1182
|
+
height: 100,
|
|
1183
|
+
width: 100,
|
|
1184
|
+
iframeTitle: "Iframe embed"
|
|
1052
1185
|
});
|
|
1053
|
-
var EMBED_CUSTOMIZATION_COMPONENTS = _defineProperty(_defineProperty(_defineProperty({}, EMBED_OPTIONS.INLINE, Inline$1), EMBED_OPTIONS.FLOATING_POPUP, FloatingPopup$1), EMBED_OPTIONS.ELEMENT_POPUP, ElementPopup$1);
|
|
1054
|
-
var EMBED_TITLES = _defineProperty(_defineProperty(_defineProperty({}, EMBED_OPTIONS.INLINE, i18next.t("neetoMolecules.productEmbed.inline.title")), EMBED_OPTIONS.FLOATING_POPUP, i18next.t("neetoMolecules.productEmbed.floatingPopup.title")), EMBED_OPTIONS.ELEMENT_POPUP, i18next.t("neetoMolecules.productEmbed.elementPopup.title"));
|
|
1186
|
+
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);
|
|
1187
|
+
var EMBED_TITLES = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, EMBED_OPTIONS.INLINE, i18next.t("neetoMolecules.productEmbed.inline.title")), EMBED_OPTIONS.FLOATING_POPUP, i18next.t("neetoMolecules.productEmbed.floatingPopup.title")), EMBED_OPTIONS.ELEMENT_POPUP, i18next.t("neetoMolecules.productEmbed.elementPopup.title")), EMBED_OPTIONS.IFRAME, i18next.t("neetoMolecules.productEmbed.iframe.title"));
|
|
1055
1188
|
var SUPPORTED_LANGUAGES = [{
|
|
1056
1189
|
value: "html",
|
|
1057
1190
|
label: i18next.t("neetoMolecules.productEmbed.language.html")
|
|
@@ -1325,6 +1458,23 @@ var FloatingPopup = function FloatingPopup(_ref) {
|
|
|
1325
1458
|
});
|
|
1326
1459
|
};
|
|
1327
1460
|
|
|
1461
|
+
var Iframe = function Iframe(_ref) {
|
|
1462
|
+
var iframeURL = _ref.iframeURL,
|
|
1463
|
+
customization = _ref.customization;
|
|
1464
|
+
var height = customization.height,
|
|
1465
|
+
width = customization.width,
|
|
1466
|
+
iframeTitle = customization.iframeTitle;
|
|
1467
|
+
return /*#__PURE__*/jsxRuntime.jsx("iframe", {
|
|
1468
|
+
allowFullScreen: true,
|
|
1469
|
+
className: "m-auto",
|
|
1470
|
+
frameBorder: "0",
|
|
1471
|
+
height: "".concat(height, "%"),
|
|
1472
|
+
src: iframeURL,
|
|
1473
|
+
title: iframeTitle,
|
|
1474
|
+
width: "".concat(width, "%")
|
|
1475
|
+
});
|
|
1476
|
+
};
|
|
1477
|
+
|
|
1328
1478
|
var Inline = function Inline(_ref) {
|
|
1329
1479
|
var iframeURL = _ref.iframeURL,
|
|
1330
1480
|
customization = _ref.customization;
|
|
@@ -1359,7 +1509,7 @@ var Preview = function Preview(_ref) {
|
|
|
1359
1509
|
};
|
|
1360
1510
|
}, shallow.shallow),
|
|
1361
1511
|
queryParams = _useProductEmbedStore.queryParams;
|
|
1362
|
-
var preview = _defineProperty(_defineProperty(_defineProperty({}, EMBED_OPTIONS.INLINE, Inline), EMBED_OPTIONS.FLOATING_POPUP, FloatingPopup), EMBED_OPTIONS.ELEMENT_POPUP, ElementPopup);
|
|
1512
|
+
var preview = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, EMBED_OPTIONS.INLINE, Inline), EMBED_OPTIONS.FLOATING_POPUP, FloatingPopup), EMBED_OPTIONS.ELEMENT_POPUP, ElementPopup), EMBED_OPTIONS.IFRAME, Iframe);
|
|
1363
1513
|
var iframeURL = buildIframeURL(customPreviewIframeUrl || "".concat(location.origin, "/embed/").concat(id), queryParams);
|
|
1364
1514
|
var Component = preview[selectedEmbed];
|
|
1365
1515
|
if (isScriptLoading) {
|