@bigbinary/neeto-molecules 3.15.1 → 3.15.2
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/BrowserPreview.js +3 -2
- package/dist/BrowserPreview.js.map +1 -1
- package/dist/Codeblock.js +1 -1
- package/dist/Codeblock.js.map +1 -1
- package/dist/ProductEmbed.js +154 -80
- package/dist/ProductEmbed.js.map +1 -1
- package/dist/cjs/BrowserPreview.js +3 -2
- package/dist/cjs/BrowserPreview.js.map +1 -1
- package/dist/cjs/Codeblock.js +1 -1
- package/dist/cjs/Codeblock.js.map +1 -1
- package/dist/cjs/ProductEmbed.js +152 -78
- package/dist/cjs/ProductEmbed.js.map +1 -1
- package/package.json +1 -1
- package/src/translations/en.json +1 -1
- package/types/BrowserPreview.d.ts +1 -0
- package/types/ProductEmbed.d.ts +3 -0
package/dist/cjs/ProductEmbed.js
CHANGED
|
@@ -14,13 +14,13 @@ var Codeblock = require('./Codeblock.js');
|
|
|
14
14
|
var jsxRuntime = require('react/jsx-runtime');
|
|
15
15
|
var i18next = require('i18next');
|
|
16
16
|
var Code$1 = require('@bigbinary/neeto-icons/Code');
|
|
17
|
-
var Eye = require('@bigbinary/neeto-icons/Eye');
|
|
18
17
|
var Input = require('@bigbinary/neetoui/Input');
|
|
19
18
|
var Callout = require('@bigbinary/neetoui/Callout');
|
|
20
19
|
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
21
20
|
var Delete = require('@bigbinary/neeto-icons/Delete');
|
|
22
21
|
var Plus = require('@bigbinary/neeto-icons/Plus');
|
|
23
22
|
var Label = require('@bigbinary/neetoui/Label');
|
|
23
|
+
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
24
24
|
var Checkbox = require('@bigbinary/neetoui/Checkbox');
|
|
25
25
|
var Select = require('@bigbinary/neetoui/Select');
|
|
26
26
|
var ColorPicker = require('@bigbinary/neetoui/ColorPicker');
|
|
@@ -32,17 +32,17 @@ var injectCss = require('./inject-css-vQvjPR2x.js');
|
|
|
32
32
|
require('react-syntax-highlighter');
|
|
33
33
|
require('react-syntax-highlighter/dist/esm/styles/prism');
|
|
34
34
|
require('./CopyToClipboardButton.js');
|
|
35
|
-
require('@babel/runtime/helpers/objectWithoutProperties');
|
|
36
35
|
require('@bigbinary/neeto-commons-frontend/utils/general');
|
|
37
36
|
require('@bigbinary/neeto-icons/Copy');
|
|
38
37
|
require('@bigbinary/neeto-icons/Check');
|
|
39
38
|
|
|
40
39
|
var Code = function Code(_ref) {
|
|
41
|
-
var code = _ref.code
|
|
40
|
+
var code = _ref.code,
|
|
41
|
+
tab = _ref.tab;
|
|
42
42
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
43
|
-
className: "relative w-full overflow-y-auto",
|
|
43
|
+
className: "neeto-molecules-embed__code-block relative w-full overflow-y-auto",
|
|
44
44
|
"data-cy": "embed-code-block",
|
|
45
|
-
"data-testid": "
|
|
45
|
+
"data-testid": "".concat(tab, "-code-block"),
|
|
46
46
|
children: /*#__PURE__*/jsxRuntime.jsx(Codeblock, {
|
|
47
47
|
code: code
|
|
48
48
|
})
|
|
@@ -51,16 +51,16 @@ var Code = function Code(_ref) {
|
|
|
51
51
|
|
|
52
52
|
var TAB_KEYS = {
|
|
53
53
|
HTML: "html",
|
|
54
|
-
|
|
54
|
+
REACT: "react"
|
|
55
55
|
};
|
|
56
56
|
var TABS = [{
|
|
57
57
|
key: TAB_KEYS.HTML,
|
|
58
58
|
label: i18next.t("neetoMolecules.productEmbed.tab.html"),
|
|
59
59
|
icon: Code$1
|
|
60
60
|
}, {
|
|
61
|
-
key: TAB_KEYS.
|
|
62
|
-
label: i18next.t("neetoMolecules.productEmbed.tab.
|
|
63
|
-
icon:
|
|
61
|
+
key: TAB_KEYS.REACT,
|
|
62
|
+
label: i18next.t("neetoMolecules.productEmbed.tab.react"),
|
|
63
|
+
icon: Code$1
|
|
64
64
|
}];
|
|
65
65
|
var EMBED_OPTIONS = {
|
|
66
66
|
INLINE: "inline",
|
|
@@ -95,17 +95,17 @@ var INITIAL_QUERY_PARAM = {
|
|
|
95
95
|
value: ""
|
|
96
96
|
};
|
|
97
97
|
|
|
98
|
-
var camelCasedAppName = globalProps.appName.replace(/^neeto/i, "neeto");
|
|
98
|
+
var camelCasedAppName$1 = globalProps.appName.replace(/^neeto/i, "neeto");
|
|
99
99
|
var embedBaseScript = function embedBaseScript(embedScriptLink) {
|
|
100
|
-
return "<script>window.".concat(camelCasedAppName, " = window.").concat(camelCasedAppName, " || { embed: function(){(").concat(camelCasedAppName, ".q=").concat(camelCasedAppName, ".q||[]).push(arguments)} };</script>\n <script async\n src=\"").concat(embedScriptLink, "\">\n </script>");
|
|
100
|
+
return "<script>window.".concat(camelCasedAppName$1, " = window.").concat(camelCasedAppName$1, " || { embed: function(){(").concat(camelCasedAppName$1, ".q=").concat(camelCasedAppName$1, ".q||[]).push(arguments)} };</script>\n <script async\n src=\"").concat(embedScriptLink, "\">\n </script>");
|
|
101
101
|
};
|
|
102
|
-
var embedEnv = function embedEnv() {
|
|
102
|
+
var embedEnv$1 = function embedEnv() {
|
|
103
103
|
return globalProps.railsEnv !== "production" ? "\n".concat(TAB_STRING, " env: \"").concat(globalProps.railsEnv, "\",") : "";
|
|
104
104
|
};
|
|
105
|
-
var embedQueryParam = function embedQueryParam(queryParams) {
|
|
105
|
+
var embedQueryParam$1 = function embedQueryParam(queryParams) {
|
|
106
106
|
return queryParams ? "\n".concat(TAB_STRING, " queryParams: ").concat(queryParams, ",") : "";
|
|
107
107
|
};
|
|
108
|
-
var parseExtraArgs = function parseExtraArgs(extraArgs) {
|
|
108
|
+
var parseExtraArgs$1 = function parseExtraArgs(extraArgs) {
|
|
109
109
|
return ramda.toPairs(extraArgs).map(function (_ref) {
|
|
110
110
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
111
111
|
key = _ref2[0],
|
|
@@ -113,6 +113,81 @@ var parseExtraArgs = function parseExtraArgs(extraArgs) {
|
|
|
113
113
|
return "\n".concat(TAB_STRING, " ").concat(key, ": \"").concat(value, "\"");
|
|
114
114
|
});
|
|
115
115
|
};
|
|
116
|
+
var inlineEmbedCode$1 = function inlineEmbedCode(_ref3) {
|
|
117
|
+
var customization = _ref3.customization,
|
|
118
|
+
id = _ref3.id,
|
|
119
|
+
embedScriptLink = _ref3.embedScriptLink,
|
|
120
|
+
extraArgs = _ref3.extraArgs,
|
|
121
|
+
inlineWrapperStyle = _ref3.inlineWrapperStyle;
|
|
122
|
+
var elementSelector = customization.elementSelector,
|
|
123
|
+
_customization$width = customization.width,
|
|
124
|
+
width = _customization$width === void 0 ? 100 : _customization$width,
|
|
125
|
+
_customization$height = customization.height,
|
|
126
|
+
height = _customization$height === void 0 ? 100 : _customization$height,
|
|
127
|
+
queryParams = customization.queryParams;
|
|
128
|
+
return "\n <!-- ".concat(globalProps.appName, " inline embed code begins -->\n <div style=\"").concat(inlineWrapperStyle || "height: 90vh; width: 100%;", "\" id=\"").concat(elementSelector, "\">\n <!-- ").concat(globalProps.appName, " widget will be added here -->\n </div>\n ").concat(embedBaseScript(embedScriptLink), "\n <script>\n ").concat(camelCasedAppName$1, ".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$1(queryParams)).concat(embedEnv$1()).concat(parseExtraArgs$1(extraArgs), "\n });\n </script>\n <!-- ").concat(globalProps.appName, " inline embed code ends -->");
|
|
129
|
+
};
|
|
130
|
+
var floatingPopupEmbedCode$1 = function floatingPopupEmbedCode(_ref4) {
|
|
131
|
+
var customization = _ref4.customization,
|
|
132
|
+
id = _ref4.id,
|
|
133
|
+
embedScriptLink = _ref4.embedScriptLink,
|
|
134
|
+
extraArgs = _ref4.extraArgs;
|
|
135
|
+
var btnTextColor = customization.btnTextColor,
|
|
136
|
+
showIcon = customization.showIcon,
|
|
137
|
+
btnText = customization.btnText,
|
|
138
|
+
btnPosition = customization.btnPosition,
|
|
139
|
+
btnColor = customization.btnColor,
|
|
140
|
+
icon = customization.icon,
|
|
141
|
+
queryParams = customization.queryParams;
|
|
142
|
+
return "\n <!-- ".concat(globalProps.appName, " floating-popup embed code begins -->\n ").concat(embedBaseScript(embedScriptLink), "\n <script>\n ").concat(camelCasedAppName$1, ".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$1(queryParams)).concat(embedEnv$1()).concat(parseExtraArgs$1(extraArgs), "\n });\n </script>\n <!-- ").concat(globalProps.appName, " floating-popup embed code ends -->");
|
|
143
|
+
};
|
|
144
|
+
var elementPopupEmbedCode$1 = function elementPopupEmbedCode(_ref5) {
|
|
145
|
+
var customization = _ref5.customization,
|
|
146
|
+
id = _ref5.id,
|
|
147
|
+
embedScriptLink = _ref5.embedScriptLink,
|
|
148
|
+
extraArgs = _ref5.extraArgs;
|
|
149
|
+
var elementSelector = customization.elementSelector,
|
|
150
|
+
queryParams = customization.queryParams;
|
|
151
|
+
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 -->");
|
|
152
|
+
};
|
|
153
|
+
var htmlCodeGenerators = {
|
|
154
|
+
inline: inlineEmbedCode$1,
|
|
155
|
+
floatingPopup: floatingPopupEmbedCode$1,
|
|
156
|
+
elementPopup: elementPopupEmbedCode$1
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
var camelCasedAppName = globalProps.appName.replace(/^neeto/i, "neeto");
|
|
160
|
+
var embedFunctionName = "".concat(camelCasedAppName, "Embed");
|
|
161
|
+
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");
|
|
162
|
+
var embedScript = function embedScript(scriptLink) {
|
|
163
|
+
return "const embedScript = document.createElement(\"script\");\n embedScript.src = \"".concat(scriptLink, "\";\n embedScript.async = true;\n document.body.appendChild(embedScript);\n");
|
|
164
|
+
};
|
|
165
|
+
var cleanupFunction = "// Cleanup function\n return () => {\n document.body.removeChild(baseScript);\n document.body.removeChild(embedScript);\n };";
|
|
166
|
+
var embedEnv = function embedEnv() {
|
|
167
|
+
return globalProps.railsEnv !== "production" ? "\n".concat(TAB_STRING).concat(TAB_STRING, "env: \"").concat(globalProps.railsEnv, "\",") : "";
|
|
168
|
+
};
|
|
169
|
+
var embedQueryParam = function embedQueryParam(queryParams) {
|
|
170
|
+
return queryParams ? "\n".concat(TAB_STRING).concat(TAB_STRING, "queryParams: ").concat(queryParams, ",") : "";
|
|
171
|
+
};
|
|
172
|
+
var parseExtraArgs = function parseExtraArgs(extraArgs) {
|
|
173
|
+
return ramda.toPairs(extraArgs).map(function (_ref) {
|
|
174
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
175
|
+
key = _ref2[0],
|
|
176
|
+
value = _ref2[1];
|
|
177
|
+
return "\n".concat(TAB_STRING).concat(TAB_STRING).concat(key, ": \"").concat(value, "\"");
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
var parseInlineStyle = function parseInlineStyle(styleString) {
|
|
181
|
+
return styleString ? styleString.split(";").map(function (rule) {
|
|
182
|
+
var _rule$split$map = rule.split(":").map(function (s) {
|
|
183
|
+
return s.trim();
|
|
184
|
+
}),
|
|
185
|
+
_rule$split$map2 = _slicedToArray(_rule$split$map, 2),
|
|
186
|
+
key = _rule$split$map2[0],
|
|
187
|
+
value = _rule$split$map2[1];
|
|
188
|
+
return key && value ? "".concat(key, ": \"").concat(value, "\"") : null;
|
|
189
|
+
}).filter(Boolean).join(", ") : 'height: "90vh", width: "100%"';
|
|
190
|
+
};
|
|
116
191
|
var inlineEmbedCode = function inlineEmbedCode(_ref3) {
|
|
117
192
|
var customization = _ref3.customization,
|
|
118
193
|
id = _ref3.id,
|
|
@@ -125,7 +200,7 @@ var inlineEmbedCode = function inlineEmbedCode(_ref3) {
|
|
|
125
200
|
_customization$height = customization.height,
|
|
126
201
|
height = _customization$height === void 0 ? 100 : _customization$height,
|
|
127
202
|
queryParams = customization.queryParams;
|
|
128
|
-
return "\n
|
|
203
|
+
return "\n import { useEffect } from \"react\";\n\n const App = () => {\n const ".concat(embedFunctionName, " = () => {\n ").concat(baseScript, "\n ").concat(embedScript(embedScriptLink), "\n ").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 ").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 };");
|
|
129
204
|
};
|
|
130
205
|
var floatingPopupEmbedCode = function floatingPopupEmbedCode(_ref4) {
|
|
131
206
|
var customization = _ref4.customization,
|
|
@@ -139,7 +214,7 @@ var floatingPopupEmbedCode = function floatingPopupEmbedCode(_ref4) {
|
|
|
139
214
|
btnColor = customization.btnColor,
|
|
140
215
|
icon = customization.icon,
|
|
141
216
|
queryParams = customization.queryParams;
|
|
142
|
-
return "\n
|
|
217
|
+
return "\n import { useEffect } from \"react\";\n\n const App = () => {\n const ".concat(embedFunctionName, " = () => {\n ").concat(baseScript, "\n ").concat(embedScript(embedScriptLink), "\n ").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 ").concat(cleanupFunction, "\n };\n\n useEffect(() => ").concat(embedFunctionName, "(), []);\n\n return <div />;\n };");
|
|
143
218
|
};
|
|
144
219
|
var elementPopupEmbedCode = function elementPopupEmbedCode(_ref5) {
|
|
145
220
|
var customization = _ref5.customization,
|
|
@@ -148,55 +223,34 @@ var elementPopupEmbedCode = function elementPopupEmbedCode(_ref5) {
|
|
|
148
223
|
extraArgs = _ref5.extraArgs;
|
|
149
224
|
var elementSelector = customization.elementSelector,
|
|
150
225
|
queryParams = customization.queryParams;
|
|
151
|
-
return "\n
|
|
152
|
-
};
|
|
153
|
-
var
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
embedScriptLink: embedScriptLink,
|
|
167
|
-
extraArgs: extraArgs,
|
|
168
|
-
inlineWrapperStyle: inlineWrapperStyle
|
|
169
|
-
});
|
|
170
|
-
case "floatingPopup":
|
|
171
|
-
return floatingPopupEmbedCode({
|
|
172
|
-
customization: customization,
|
|
173
|
-
id: id,
|
|
174
|
-
embedScriptLink: embedScriptLink,
|
|
175
|
-
extraArgs: extraArgs
|
|
176
|
-
});
|
|
177
|
-
case "elementPopup":
|
|
178
|
-
return elementPopupEmbedCode({
|
|
179
|
-
customization: customization,
|
|
180
|
-
id: id,
|
|
181
|
-
embedScriptLink: embedScriptLink,
|
|
182
|
-
extraArgs: extraArgs
|
|
183
|
-
});
|
|
184
|
-
default:
|
|
185
|
-
return "";
|
|
186
|
-
}
|
|
226
|
+
return "\n import { useEffect } from \"react\";\n\n const App = () => {\n const ".concat(embedFunctionName, " = () => {\n ").concat(baseScript, "\n ").concat(embedScript(embedScriptLink), "\n ").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 ").concat(cleanupFunction, "\n };\n\n useEffect(() => ").concat(embedFunctionName, "(), []);\n\n return <div />;\n };");
|
|
227
|
+
};
|
|
228
|
+
var reactCodeGenerators = {
|
|
229
|
+
inline: inlineEmbedCode,
|
|
230
|
+
floatingPopup: floatingPopupEmbedCode,
|
|
231
|
+
elementPopup: elementPopupEmbedCode
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
var _excluded = ["tab", "type"];
|
|
235
|
+
var generateCode = function generateCode(options) {
|
|
236
|
+
var _reactCodeGenerators$, _htmlCodeGenerators$t;
|
|
237
|
+
var tab = options.tab,
|
|
238
|
+
type = options.type,
|
|
239
|
+
embeddedCodeOptions = _objectWithoutProperties(options, _excluded);
|
|
240
|
+
return tab === "react" ? (_reactCodeGenerators$ = reactCodeGenerators[type]) === null || _reactCodeGenerators$ === void 0 ? void 0 : _reactCodeGenerators$.call(reactCodeGenerators, embeddedCodeOptions) : (_htmlCodeGenerators$t = htmlCodeGenerators[type]) === null || _htmlCodeGenerators$t === void 0 ? void 0 : _htmlCodeGenerators$t.call(htmlCodeGenerators, embeddedCodeOptions);
|
|
187
241
|
};
|
|
188
242
|
var buildDefaultCustomization = function buildDefaultCustomization(defaultCustomizations) {
|
|
189
243
|
return ramda.mergeDeepLeft(defaultCustomizations, DEFAULT_CUSTOMIZATION);
|
|
190
244
|
};
|
|
191
245
|
var buildQueryParamsFromInputFields = function buildQueryParamsFromInputFields(inputFields) {
|
|
192
|
-
var filteredInputFields = inputFields.filter(function (
|
|
193
|
-
var name =
|
|
194
|
-
value =
|
|
246
|
+
var filteredInputFields = inputFields.filter(function (_ref) {
|
|
247
|
+
var name = _ref.name,
|
|
248
|
+
value = _ref.value;
|
|
195
249
|
return name && value;
|
|
196
250
|
});
|
|
197
|
-
var queryParams = filteredInputFields.reduce(function (queryParams,
|
|
198
|
-
var name =
|
|
199
|
-
value =
|
|
251
|
+
var queryParams = filteredInputFields.reduce(function (queryParams, _ref2) {
|
|
252
|
+
var name = _ref2.name,
|
|
253
|
+
value = _ref2.value;
|
|
200
254
|
queryParams[name] = value;
|
|
201
255
|
return queryParams;
|
|
202
256
|
}, {});
|
|
@@ -517,14 +571,15 @@ var Customization = function Customization(_ref) {
|
|
|
517
571
|
};
|
|
518
572
|
|
|
519
573
|
var Header = function Header(_ref) {
|
|
520
|
-
var
|
|
521
|
-
setTab = _ref.setTab
|
|
574
|
+
var supportedLanguagesTabs = _ref.supportedLanguagesTabs,
|
|
575
|
+
setTab = _ref.setTab,
|
|
576
|
+
tab = _ref.tab;
|
|
522
577
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
523
|
-
className: "flex w-full
|
|
578
|
+
className: "flex w-full",
|
|
524
579
|
children: /*#__PURE__*/jsxRuntime.jsx(Tab, {
|
|
525
580
|
noUnderline: true,
|
|
526
581
|
className: "neeto-molecules-product-embed-tab",
|
|
527
|
-
children:
|
|
582
|
+
children: supportedLanguagesTabs.map(function (_ref2) {
|
|
528
583
|
var key = _ref2.key,
|
|
529
584
|
label = _ref2.label,
|
|
530
585
|
icon = _ref2.icon;
|
|
@@ -677,6 +732,8 @@ var Preview = function Preview(_ref) {
|
|
|
677
732
|
});
|
|
678
733
|
}
|
|
679
734
|
return /*#__PURE__*/jsxRuntime.jsx(BrowserPreview, {
|
|
735
|
+
className: "h-full",
|
|
736
|
+
wrapperClassName: "neeto-molecules-embed__browser-preview pointer-events-auto",
|
|
680
737
|
children: /*#__PURE__*/jsxRuntime.jsx(Component, {
|
|
681
738
|
customization: customization,
|
|
682
739
|
iframeURL: iframeURL
|
|
@@ -684,7 +741,7 @@ var Preview = function Preview(_ref) {
|
|
|
684
741
|
});
|
|
685
742
|
};
|
|
686
743
|
|
|
687
|
-
var css = ".neeto-molecules-product-embed-size-input.neeto-ui-input__wrapper .neeto-ui-input__prefix{align-self:stretch;background-color:rgb(var(--neeto-ui-gray-200));margin-left:0!important;padding-left:.75rem;padding-right:.75rem}.neeto-molecules-product-embed-tab{gap:.5rem}.neeto-molecules-product-embed-tab .neeto-ui-tab{border-radius:var(--neeto-ui-btn-border-radius);color:rgb(var(--neeto-ui-gray-800))}.neeto-molecules-product-embed-tab .neeto-ui-tab:not(.active):hover{background-color:rgb(var(--neeto-ui-gray-100))}.neeto-molecules-product-embed-tab .neeto-ui-tab.active{background-color:rgb(var(--neeto-ui-gray-200))}.neeto-molecules-embed__left-sidebar{align-items:flex-start;display:flex;flex-direction:column;flex-shrink:0;overflow-y:auto;padding:1.5rem;width:100%}@media (min-width:768px){.neeto-molecules-embed__left-sidebar{border-right:1px solid rgb(var(--neeto-ui-gray-200));max-width:25rem}}@media (min-width:1024px){.neeto-molecules-embed__left-sidebar{max-width:27.5rem}}";
|
|
744
|
+
var css = ".neeto-molecules-product-embed-size-input.neeto-ui-input__wrapper .neeto-ui-input__prefix{align-self:stretch;background-color:rgb(var(--neeto-ui-gray-200));margin-left:0!important;padding-left:.75rem;padding-right:.75rem}.neeto-molecules-product-embed-tab{gap:.5rem}.neeto-molecules-product-embed-tab .neeto-ui-tab{border-radius:var(--neeto-ui-btn-border-radius);color:rgb(var(--neeto-ui-gray-800))}.neeto-molecules-product-embed-tab .neeto-ui-tab:not(.active):hover{background-color:rgb(var(--neeto-ui-gray-100))}.neeto-molecules-product-embed-tab .neeto-ui-tab.active{background-color:rgb(var(--neeto-ui-gray-200))}.neeto-molecules-embed__left-sidebar{align-items:flex-start;display:flex;flex-direction:column;flex-shrink:0;overflow-y:auto;padding:1.5rem;width:100%}@media (min-width:768px){.neeto-molecules-embed__left-sidebar{border-right:1px solid rgb(var(--neeto-ui-gray-200));max-width:25rem}}@media (min-width:1024px){.neeto-molecules-embed__left-sidebar{max-width:27.5rem}}.neeto-molecules-embed__code-block .neeto-molecules-code-block{font-size:.875rem;height:15.625rem;margin-top:0!important}.neeto-molecules-embed__browser-preview{height:100%;min-height:18.75rem}.neeto-molecules-embed__browser-preview .neeto-molecules-browser-preview__body{position:relative}.neeto-molecules-embed__browser-preview .neeto-molecules-browser-preview__body iframe{height:100%;left:0;position:absolute;top:0;width:100%}";
|
|
688
745
|
injectCss.n(css,{});
|
|
689
746
|
|
|
690
747
|
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; }
|
|
@@ -708,12 +765,19 @@ var ProductEmbed = function ProductEmbed(_ref) {
|
|
|
708
765
|
_ref$otherCustomizati = _ref.otherCustomizations,
|
|
709
766
|
otherCustomizations = _ref$otherCustomizati === void 0 ? neetoCist.noop : _ref$otherCustomizati,
|
|
710
767
|
_ref$inlineWrapperSty = _ref.inlineWrapperStyle,
|
|
711
|
-
inlineWrapperStyle = _ref$inlineWrapperSty === void 0 ? "" : _ref$inlineWrapperSty
|
|
768
|
+
inlineWrapperStyle = _ref$inlineWrapperSty === void 0 ? "" : _ref$inlineWrapperSty,
|
|
769
|
+
_ref$supportedLanguag = _ref.supportedLanguages,
|
|
770
|
+
supportedLanguages = _ref$supportedLanguag === void 0 ? ["html"] : _ref$supportedLanguag;
|
|
771
|
+
var supportedLanguagesTabs = neetoCist.filterBy({
|
|
772
|
+
key: function key(_key) {
|
|
773
|
+
return supportedLanguages === null || supportedLanguages === void 0 ? void 0 : supportedLanguages.includes(_key);
|
|
774
|
+
}
|
|
775
|
+
}, TABS);
|
|
712
776
|
var _useState = React.useState(true),
|
|
713
777
|
_useState2 = _slicedToArray(_useState, 2),
|
|
714
778
|
isScriptLoading = _useState2[0],
|
|
715
779
|
setIsScriptLoading = _useState2[1];
|
|
716
|
-
var _useState3 = React.useState(
|
|
780
|
+
var _useState3 = React.useState(supportedLanguagesTabs[0].key),
|
|
717
781
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
718
782
|
tab = _useState4[0],
|
|
719
783
|
setTab = _useState4[1];
|
|
@@ -730,8 +794,9 @@ var ProductEmbed = function ProductEmbed(_ref) {
|
|
|
730
794
|
var _useTranslation = reactI18next.useTranslation(),
|
|
731
795
|
t = _useTranslation.t;
|
|
732
796
|
var embedScriptLink = customEmbedScriptPath || "".concat(window.location.protocol, "//").concat(window.location.host, "/javascript/embed.js");
|
|
733
|
-
var code =
|
|
797
|
+
var code = generateCode({
|
|
734
798
|
id: id,
|
|
799
|
+
tab: tab,
|
|
735
800
|
type: selectedOption,
|
|
736
801
|
customization: customizations[selectedOption],
|
|
737
802
|
embedScriptLink: embedScriptLink,
|
|
@@ -788,21 +853,30 @@ var ProductEmbed = function ProductEmbed(_ref) {
|
|
|
788
853
|
})]
|
|
789
854
|
})]
|
|
790
855
|
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
791
|
-
className: "neeto-molecules-embed__preview neeto-ui-bg-white flex min-h-screen w-full min-w-0 flex-col gap-
|
|
856
|
+
className: "neeto-molecules-embed__preview neeto-ui-bg-white flex min-h-screen w-full min-w-0 flex-col gap-3 overflow-y-auto p-6 md:min-h-0 md:flex-grow",
|
|
792
857
|
children: [/*#__PURE__*/jsxRuntime.jsx(Header, {
|
|
793
858
|
setTab: setTab,
|
|
859
|
+
supportedLanguagesTabs: supportedLanguagesTabs,
|
|
794
860
|
tab: tab
|
|
795
|
-
}), /*#__PURE__*/jsxRuntime.
|
|
796
|
-
className: "flex flex-grow
|
|
797
|
-
children:
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
861
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
862
|
+
className: "flex min-h-0 flex-grow flex-col gap-3",
|
|
863
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
864
|
+
className: "flex-shrink-0",
|
|
865
|
+
"data-testid": "embed-code-block",
|
|
866
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Code, {
|
|
867
|
+
code: code,
|
|
868
|
+
tab: tab
|
|
869
|
+
})
|
|
870
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
871
|
+
className: "flex-grow",
|
|
872
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Preview, {
|
|
873
|
+
customPreviewIframeUrl: customPreviewIframeUrl,
|
|
874
|
+
id: id,
|
|
875
|
+
isScriptLoading: isScriptLoading,
|
|
876
|
+
selectedOption: selectedOption,
|
|
877
|
+
customization: customizations[selectedOption]
|
|
878
|
+
})
|
|
879
|
+
})]
|
|
806
880
|
})]
|
|
807
881
|
})]
|
|
808
882
|
});
|