@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/ProductEmbed.js
CHANGED
|
@@ -147,13 +147,12 @@ var htmlCodeGenerators = {
|
|
|
147
147
|
|
|
148
148
|
var camelCasedAppName = globalProps.appName.replace(/^neeto/i, "neeto");
|
|
149
149
|
var embedFunctionName = "embed".concat(globalProps.appName);
|
|
150
|
-
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");
|
|
151
150
|
var embedScript = function embedScript(scriptLink) {
|
|
152
|
-
return "const embedScript = document.createElement(\"script\");\n embedScript.src = \"".concat(scriptLink, "\";\n embedScript.async = true;\n
|
|
151
|
+
return "const embedScript = document.createElement(\"script\");\n embedScript.type = \"module\";\n embedScript.src = \"".concat(scriptLink, "\";\n embedScript.async = true;\n");
|
|
153
152
|
};
|
|
154
|
-
var cleanupFunction = "
|
|
153
|
+
var cleanupFunction = "\n return () => {\n embedScript.onload = null;\n if(window.".concat(camelCasedAppName, ") window.").concat(camelCasedAppName, ".destroy();\n document.body.removeChild(embedScript);\n };");
|
|
155
154
|
var embedEnv = function embedEnv() {
|
|
156
|
-
return globalProps.railsEnv !== "production" ? "\n".concat(TAB_STRING).concat(TAB_STRING, "env: \"").concat(globalProps.railsEnv, "\",") : "";
|
|
155
|
+
return globalProps.railsEnv !== "production" ? "\n".concat(TAB_STRING).concat(TAB_STRING, " env: \"").concat(globalProps.railsEnv, "\",") : "";
|
|
157
156
|
};
|
|
158
157
|
var embedQueryParam = function embedQueryParam(queryParams) {
|
|
159
158
|
return queryParams ? "\n".concat(TAB_STRING).concat(TAB_STRING, "queryParams: ").concat(queryParams, ",") : "";
|
|
@@ -189,7 +188,7 @@ var inlineEmbedCode = function inlineEmbedCode(_ref3) {
|
|
|
189
188
|
_customization$height = customization.height,
|
|
190
189
|
height = _customization$height === void 0 ? 100 : _customization$height,
|
|
191
190
|
queryParams = customization.queryParams;
|
|
192
|
-
return "\n import { useEffect } from \"react\";\n\n const App = () => {\n const ".concat(embedFunctionName, " = () => {\n ").concat(
|
|
191
|
+
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 };");
|
|
193
192
|
};
|
|
194
193
|
var floatingPopupEmbedCode = function floatingPopupEmbedCode(_ref4) {
|
|
195
194
|
var customization = _ref4.customization,
|
|
@@ -203,7 +202,7 @@ var floatingPopupEmbedCode = function floatingPopupEmbedCode(_ref4) {
|
|
|
203
202
|
btnColor = customization.btnColor,
|
|
204
203
|
icon = customization.icon,
|
|
205
204
|
queryParams = customization.queryParams;
|
|
206
|
-
return "\n import { useEffect } from \"react\";\n\n const App = () => {\n const ".concat(embedFunctionName, " = () => {\n ").concat(
|
|
205
|
+
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 };");
|
|
207
206
|
};
|
|
208
207
|
var elementPopupEmbedCode = function elementPopupEmbedCode(_ref5) {
|
|
209
208
|
var customization = _ref5.customization,
|
|
@@ -212,7 +211,7 @@ var elementPopupEmbedCode = function elementPopupEmbedCode(_ref5) {
|
|
|
212
211
|
extraArgs = _ref5.extraArgs;
|
|
213
212
|
var elementSelector = customization.elementSelector,
|
|
214
213
|
queryParams = customization.queryParams;
|
|
215
|
-
return "\n import { useEffect } from \"react\";\n\n const App = () => {\n const ".concat(embedFunctionName, " = () => {\n ").concat(
|
|
214
|
+
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 };");
|
|
216
215
|
};
|
|
217
216
|
var reactCodeGenerators = {
|
|
218
217
|
inline: inlineEmbedCode,
|