@bigbinary/neeto-molecules 3.16.45 → 3.16.46
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/cjs/ProductEmbed.js
CHANGED
|
@@ -149,13 +149,12 @@ var htmlCodeGenerators = {
|
|
|
149
149
|
|
|
150
150
|
var camelCasedAppName = globalProps.appName.replace(/^neeto/i, "neeto");
|
|
151
151
|
var embedFunctionName = "embed".concat(globalProps.appName);
|
|
152
|
-
var baseScript = "const baseScript = document.createElement(\"script\");\n baseScript.innerHTML = `window.".concat(camelCasedAppName, " = window.").concat(camelCasedAppName, " || { embed: function(){(").concat(camelCasedAppName, ".q=").concat(camelCasedAppName, ".q||[]).push(arguments)} };`\n document.body.appendChild(baseScript);\n");
|
|
153
152
|
var embedScript = function embedScript(scriptLink) {
|
|
154
|
-
return "const embedScript = document.createElement(\"script\");\n embedScript.src = \"".concat(scriptLink, "\";\n embedScript.async = true;\n
|
|
153
|
+
return "const embedScript = document.createElement(\"script\");\n embedScript.type = \"module\";\n embedScript.src = \"".concat(scriptLink, "\";\n embedScript.async = true;\n");
|
|
155
154
|
};
|
|
156
|
-
var cleanupFunction = "
|
|
155
|
+
var cleanupFunction = "\n return () => {\n embedScript.onload = null;\n if(window.".concat(camelCasedAppName, ") window.").concat(camelCasedAppName, ".destroy();\n document.body.removeChild(embedScript);\n };");
|
|
157
156
|
var embedEnv = function embedEnv() {
|
|
158
|
-
return globalProps.railsEnv !== "production" ? "\n".concat(TAB_STRING).concat(TAB_STRING, "env: \"").concat(globalProps.railsEnv, "\",") : "";
|
|
157
|
+
return globalProps.railsEnv !== "production" ? "\n".concat(TAB_STRING).concat(TAB_STRING, " env: \"").concat(globalProps.railsEnv, "\",") : "";
|
|
159
158
|
};
|
|
160
159
|
var embedQueryParam = function embedQueryParam(queryParams) {
|
|
161
160
|
return queryParams ? "\n".concat(TAB_STRING).concat(TAB_STRING, "queryParams: ").concat(queryParams, ",") : "";
|
|
@@ -191,7 +190,7 @@ var inlineEmbedCode = function inlineEmbedCode(_ref3) {
|
|
|
191
190
|
_customization$height = customization.height,
|
|
192
191
|
height = _customization$height === void 0 ? 100 : _customization$height,
|
|
193
192
|
queryParams = customization.queryParams;
|
|
194
|
-
return "\n import { useEffect } from \"react\";\n\n const App = () => {\n const ".concat(embedFunctionName, " = () => {\n ").concat(
|
|
193
|
+
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: \"inline\",\n id: \"").concat(id, "\",\n organization: \"").concat(globalProps.organization.subdomain, "\",\n elementSelector: \"#").concat(elementSelector, "\",\n styles: { height: \"").concat(height, "%\", width: \"").concat(width, "%\" },").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 (\n <div\n id=\"inline-embed-container\"\n style={{ ").concat(parseInlineStyle(inlineWrapperStyle), " }}\n />\n );\n };");
|
|
195
194
|
};
|
|
196
195
|
var floatingPopupEmbedCode = function floatingPopupEmbedCode(_ref4) {
|
|
197
196
|
var customization = _ref4.customization,
|
|
@@ -205,7 +204,7 @@ var floatingPopupEmbedCode = function floatingPopupEmbedCode(_ref4) {
|
|
|
205
204
|
btnColor = customization.btnColor,
|
|
206
205
|
icon = customization.icon,
|
|
207
206
|
queryParams = customization.queryParams;
|
|
208
|
-
return "\n import { useEffect } from \"react\";\n\n const App = () => {\n const ".concat(embedFunctionName, " = () => {\n ").concat(
|
|
207
|
+
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: \"floatingPopup\",\n id: \"").concat(id, "\",\n organization: \"").concat(globalProps.organization.subdomain, "\",\n styles: {\n btnTextColor: \"").concat(btnTextColor, "\",\n btnPosition: \"").concat(btnPosition, "\",\n btnColor: \"").concat(btnColor, "\",\n btnText: \"").concat(btnText, "\",").concat(icon ? "\n".concat(TAB_STRING).concat(TAB_STRING, " showIcon: ").concat(showIcon, ",") : "", "\n },").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 <div />;\n };");
|
|
209
208
|
};
|
|
210
209
|
var elementPopupEmbedCode = function elementPopupEmbedCode(_ref5) {
|
|
211
210
|
var customization = _ref5.customization,
|
|
@@ -214,7 +213,7 @@ var elementPopupEmbedCode = function elementPopupEmbedCode(_ref5) {
|
|
|
214
213
|
extraArgs = _ref5.extraArgs;
|
|
215
214
|
var elementSelector = customization.elementSelector,
|
|
216
215
|
queryParams = customization.queryParams;
|
|
217
|
-
return "\n import { useEffect } from \"react\";\n\n const App = () => {\n const ".concat(embedFunctionName, " = () => {\n ").concat(
|
|
216
|
+
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 };");
|
|
218
217
|
};
|
|
219
218
|
var reactCodeGenerators = {
|
|
220
219
|
inline: inlineEmbedCode,
|