@bigbinary/neeto-molecules 3.15.0 → 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/{Chevron-tz1-4YT4.js → Chevron-C3M0XG3p.js} +2 -2
- package/dist/{Chevron-tz1-4YT4.js.map → Chevron-C3M0XG3p.js.map} +1 -1
- package/dist/Codeblock.js +1 -1
- package/dist/Codeblock.js.map +1 -1
- package/dist/ConfigurePageSidebar.js +1 -1
- package/dist/ProductEmbed.js +154 -80
- package/dist/ProductEmbed.js.map +1 -1
- package/dist/Sidebar.js +17 -3
- package/dist/Sidebar.js.map +1 -1
- package/dist/cjs/BrowserPreview.js +3 -2
- package/dist/cjs/BrowserPreview.js.map +1 -1
- package/dist/cjs/{Chevron-55AGkSis.js → Chevron-kf8dWOcZ.js} +2 -2
- package/dist/cjs/{Chevron-55AGkSis.js.map → Chevron-kf8dWOcZ.js.map} +1 -1
- package/dist/cjs/Codeblock.js +1 -1
- package/dist/cjs/Codeblock.js.map +1 -1
- package/dist/cjs/ConfigurePageSidebar.js +1 -1
- package/dist/cjs/ProductEmbed.js +152 -78
- package/dist/cjs/ProductEmbed.js.map +1 -1
- package/dist/cjs/Sidebar.js +17 -3
- package/dist/cjs/Sidebar.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/types/Sidebar.d.ts +1 -0
package/dist/ProductEmbed.js
CHANGED
|
@@ -2,23 +2,23 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
|
2
2
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
3
3
|
import { useState, useEffect, createElement } from 'react';
|
|
4
4
|
import classnames from 'classnames';
|
|
5
|
-
import { noop } from '@bigbinary/neeto-cist';
|
|
5
|
+
import { filterBy, noop } from '@bigbinary/neeto-cist';
|
|
6
6
|
import LeftArrow from '@bigbinary/neeto-icons/LeftArrow';
|
|
7
7
|
import Button from '@bigbinary/neetoui/Button';
|
|
8
8
|
import Typography from '@bigbinary/neetoui/Typography';
|
|
9
|
-
import {
|
|
9
|
+
import { toPairs, mergeDeepLeft, isEmpty, mergeLeft } from 'ramda';
|
|
10
10
|
import { useTranslation } from 'react-i18next';
|
|
11
11
|
import Codeblock from './Codeblock.js';
|
|
12
12
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
13
13
|
import { t } from 'i18next';
|
|
14
14
|
import Code$1 from '@bigbinary/neeto-icons/Code';
|
|
15
|
-
import Eye from '@bigbinary/neeto-icons/Eye';
|
|
16
15
|
import Input from '@bigbinary/neetoui/Input';
|
|
17
16
|
import Callout from '@bigbinary/neetoui/Callout';
|
|
18
17
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
19
18
|
import Delete from '@bigbinary/neeto-icons/Delete';
|
|
20
19
|
import Plus from '@bigbinary/neeto-icons/Plus';
|
|
21
20
|
import Label from '@bigbinary/neetoui/Label';
|
|
21
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
22
22
|
import Checkbox from '@bigbinary/neetoui/Checkbox';
|
|
23
23
|
import Select from '@bigbinary/neetoui/Select';
|
|
24
24
|
import ColorPicker from '@bigbinary/neetoui/ColorPicker';
|
|
@@ -30,17 +30,17 @@ import { n } from './inject-css-DmrvuTKK.js';
|
|
|
30
30
|
import 'react-syntax-highlighter';
|
|
31
31
|
import 'react-syntax-highlighter/dist/esm/styles/prism';
|
|
32
32
|
import './CopyToClipboardButton.js';
|
|
33
|
-
import '@babel/runtime/helpers/objectWithoutProperties';
|
|
34
33
|
import '@bigbinary/neeto-commons-frontend/utils/general';
|
|
35
34
|
import '@bigbinary/neeto-icons/Copy';
|
|
36
35
|
import '@bigbinary/neeto-icons/Check';
|
|
37
36
|
|
|
38
37
|
var Code = function Code(_ref) {
|
|
39
|
-
var code = _ref.code
|
|
38
|
+
var code = _ref.code,
|
|
39
|
+
tab = _ref.tab;
|
|
40
40
|
return /*#__PURE__*/jsx("div", {
|
|
41
|
-
className: "relative w-full overflow-y-auto",
|
|
41
|
+
className: "neeto-molecules-embed__code-block relative w-full overflow-y-auto",
|
|
42
42
|
"data-cy": "embed-code-block",
|
|
43
|
-
"data-testid": "
|
|
43
|
+
"data-testid": "".concat(tab, "-code-block"),
|
|
44
44
|
children: /*#__PURE__*/jsx(Codeblock, {
|
|
45
45
|
code: code
|
|
46
46
|
})
|
|
@@ -49,16 +49,16 @@ var Code = function Code(_ref) {
|
|
|
49
49
|
|
|
50
50
|
var TAB_KEYS = {
|
|
51
51
|
HTML: "html",
|
|
52
|
-
|
|
52
|
+
REACT: "react"
|
|
53
53
|
};
|
|
54
54
|
var TABS = [{
|
|
55
55
|
key: TAB_KEYS.HTML,
|
|
56
56
|
label: t("neetoMolecules.productEmbed.tab.html"),
|
|
57
57
|
icon: Code$1
|
|
58
58
|
}, {
|
|
59
|
-
key: TAB_KEYS.
|
|
60
|
-
label: t("neetoMolecules.productEmbed.tab.
|
|
61
|
-
icon:
|
|
59
|
+
key: TAB_KEYS.REACT,
|
|
60
|
+
label: t("neetoMolecules.productEmbed.tab.react"),
|
|
61
|
+
icon: Code$1
|
|
62
62
|
}];
|
|
63
63
|
var EMBED_OPTIONS = {
|
|
64
64
|
INLINE: "inline",
|
|
@@ -93,17 +93,17 @@ var INITIAL_QUERY_PARAM = {
|
|
|
93
93
|
value: ""
|
|
94
94
|
};
|
|
95
95
|
|
|
96
|
-
var camelCasedAppName = globalProps.appName.replace(/^neeto/i, "neeto");
|
|
96
|
+
var camelCasedAppName$1 = globalProps.appName.replace(/^neeto/i, "neeto");
|
|
97
97
|
var embedBaseScript = function embedBaseScript(embedScriptLink) {
|
|
98
|
-
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>");
|
|
98
|
+
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>");
|
|
99
99
|
};
|
|
100
|
-
var embedEnv = function embedEnv() {
|
|
100
|
+
var embedEnv$1 = function embedEnv() {
|
|
101
101
|
return globalProps.railsEnv !== "production" ? "\n".concat(TAB_STRING, " env: \"").concat(globalProps.railsEnv, "\",") : "";
|
|
102
102
|
};
|
|
103
|
-
var embedQueryParam = function embedQueryParam(queryParams) {
|
|
103
|
+
var embedQueryParam$1 = function embedQueryParam(queryParams) {
|
|
104
104
|
return queryParams ? "\n".concat(TAB_STRING, " queryParams: ").concat(queryParams, ",") : "";
|
|
105
105
|
};
|
|
106
|
-
var parseExtraArgs = function parseExtraArgs(extraArgs) {
|
|
106
|
+
var parseExtraArgs$1 = function parseExtraArgs(extraArgs) {
|
|
107
107
|
return toPairs(extraArgs).map(function (_ref) {
|
|
108
108
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
109
109
|
key = _ref2[0],
|
|
@@ -111,6 +111,81 @@ var parseExtraArgs = function parseExtraArgs(extraArgs) {
|
|
|
111
111
|
return "\n".concat(TAB_STRING, " ").concat(key, ": \"").concat(value, "\"");
|
|
112
112
|
});
|
|
113
113
|
};
|
|
114
|
+
var inlineEmbedCode$1 = function inlineEmbedCode(_ref3) {
|
|
115
|
+
var customization = _ref3.customization,
|
|
116
|
+
id = _ref3.id,
|
|
117
|
+
embedScriptLink = _ref3.embedScriptLink,
|
|
118
|
+
extraArgs = _ref3.extraArgs,
|
|
119
|
+
inlineWrapperStyle = _ref3.inlineWrapperStyle;
|
|
120
|
+
var elementSelector = customization.elementSelector,
|
|
121
|
+
_customization$width = customization.width,
|
|
122
|
+
width = _customization$width === void 0 ? 100 : _customization$width,
|
|
123
|
+
_customization$height = customization.height,
|
|
124
|
+
height = _customization$height === void 0 ? 100 : _customization$height,
|
|
125
|
+
queryParams = customization.queryParams;
|
|
126
|
+
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 -->");
|
|
127
|
+
};
|
|
128
|
+
var floatingPopupEmbedCode$1 = function floatingPopupEmbedCode(_ref4) {
|
|
129
|
+
var customization = _ref4.customization,
|
|
130
|
+
id = _ref4.id,
|
|
131
|
+
embedScriptLink = _ref4.embedScriptLink,
|
|
132
|
+
extraArgs = _ref4.extraArgs;
|
|
133
|
+
var btnTextColor = customization.btnTextColor,
|
|
134
|
+
showIcon = customization.showIcon,
|
|
135
|
+
btnText = customization.btnText,
|
|
136
|
+
btnPosition = customization.btnPosition,
|
|
137
|
+
btnColor = customization.btnColor,
|
|
138
|
+
icon = customization.icon,
|
|
139
|
+
queryParams = customization.queryParams;
|
|
140
|
+
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 -->");
|
|
141
|
+
};
|
|
142
|
+
var elementPopupEmbedCode$1 = function elementPopupEmbedCode(_ref5) {
|
|
143
|
+
var customization = _ref5.customization,
|
|
144
|
+
id = _ref5.id,
|
|
145
|
+
embedScriptLink = _ref5.embedScriptLink,
|
|
146
|
+
extraArgs = _ref5.extraArgs;
|
|
147
|
+
var elementSelector = customization.elementSelector,
|
|
148
|
+
queryParams = customization.queryParams;
|
|
149
|
+
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 -->");
|
|
150
|
+
};
|
|
151
|
+
var htmlCodeGenerators = {
|
|
152
|
+
inline: inlineEmbedCode$1,
|
|
153
|
+
floatingPopup: floatingPopupEmbedCode$1,
|
|
154
|
+
elementPopup: elementPopupEmbedCode$1
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
var camelCasedAppName = globalProps.appName.replace(/^neeto/i, "neeto");
|
|
158
|
+
var embedFunctionName = "".concat(camelCasedAppName, "Embed");
|
|
159
|
+
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");
|
|
160
|
+
var embedScript = function embedScript(scriptLink) {
|
|
161
|
+
return "const embedScript = document.createElement(\"script\");\n embedScript.src = \"".concat(scriptLink, "\";\n embedScript.async = true;\n document.body.appendChild(embedScript);\n");
|
|
162
|
+
};
|
|
163
|
+
var cleanupFunction = "// Cleanup function\n return () => {\n document.body.removeChild(baseScript);\n document.body.removeChild(embedScript);\n };";
|
|
164
|
+
var embedEnv = function embedEnv() {
|
|
165
|
+
return globalProps.railsEnv !== "production" ? "\n".concat(TAB_STRING).concat(TAB_STRING, "env: \"").concat(globalProps.railsEnv, "\",") : "";
|
|
166
|
+
};
|
|
167
|
+
var embedQueryParam = function embedQueryParam(queryParams) {
|
|
168
|
+
return queryParams ? "\n".concat(TAB_STRING).concat(TAB_STRING, "queryParams: ").concat(queryParams, ",") : "";
|
|
169
|
+
};
|
|
170
|
+
var parseExtraArgs = function parseExtraArgs(extraArgs) {
|
|
171
|
+
return toPairs(extraArgs).map(function (_ref) {
|
|
172
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
173
|
+
key = _ref2[0],
|
|
174
|
+
value = _ref2[1];
|
|
175
|
+
return "\n".concat(TAB_STRING).concat(TAB_STRING).concat(key, ": \"").concat(value, "\"");
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
var parseInlineStyle = function parseInlineStyle(styleString) {
|
|
179
|
+
return styleString ? styleString.split(";").map(function (rule) {
|
|
180
|
+
var _rule$split$map = rule.split(":").map(function (s) {
|
|
181
|
+
return s.trim();
|
|
182
|
+
}),
|
|
183
|
+
_rule$split$map2 = _slicedToArray(_rule$split$map, 2),
|
|
184
|
+
key = _rule$split$map2[0],
|
|
185
|
+
value = _rule$split$map2[1];
|
|
186
|
+
return key && value ? "".concat(key, ": \"").concat(value, "\"") : null;
|
|
187
|
+
}).filter(Boolean).join(", ") : 'height: "90vh", width: "100%"';
|
|
188
|
+
};
|
|
114
189
|
var inlineEmbedCode = function inlineEmbedCode(_ref3) {
|
|
115
190
|
var customization = _ref3.customization,
|
|
116
191
|
id = _ref3.id,
|
|
@@ -123,7 +198,7 @@ var inlineEmbedCode = function inlineEmbedCode(_ref3) {
|
|
|
123
198
|
_customization$height = customization.height,
|
|
124
199
|
height = _customization$height === void 0 ? 100 : _customization$height,
|
|
125
200
|
queryParams = customization.queryParams;
|
|
126
|
-
return "\n
|
|
201
|
+
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 };");
|
|
127
202
|
};
|
|
128
203
|
var floatingPopupEmbedCode = function floatingPopupEmbedCode(_ref4) {
|
|
129
204
|
var customization = _ref4.customization,
|
|
@@ -137,7 +212,7 @@ var floatingPopupEmbedCode = function floatingPopupEmbedCode(_ref4) {
|
|
|
137
212
|
btnColor = customization.btnColor,
|
|
138
213
|
icon = customization.icon,
|
|
139
214
|
queryParams = customization.queryParams;
|
|
140
|
-
return "\n
|
|
215
|
+
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 };");
|
|
141
216
|
};
|
|
142
217
|
var elementPopupEmbedCode = function elementPopupEmbedCode(_ref5) {
|
|
143
218
|
var customization = _ref5.customization,
|
|
@@ -146,55 +221,34 @@ var elementPopupEmbedCode = function elementPopupEmbedCode(_ref5) {
|
|
|
146
221
|
extraArgs = _ref5.extraArgs;
|
|
147
222
|
var elementSelector = customization.elementSelector,
|
|
148
223
|
queryParams = customization.queryParams;
|
|
149
|
-
return "\n
|
|
150
|
-
};
|
|
151
|
-
var
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
embedScriptLink: embedScriptLink,
|
|
165
|
-
extraArgs: extraArgs,
|
|
166
|
-
inlineWrapperStyle: inlineWrapperStyle
|
|
167
|
-
});
|
|
168
|
-
case "floatingPopup":
|
|
169
|
-
return floatingPopupEmbedCode({
|
|
170
|
-
customization: customization,
|
|
171
|
-
id: id,
|
|
172
|
-
embedScriptLink: embedScriptLink,
|
|
173
|
-
extraArgs: extraArgs
|
|
174
|
-
});
|
|
175
|
-
case "elementPopup":
|
|
176
|
-
return elementPopupEmbedCode({
|
|
177
|
-
customization: customization,
|
|
178
|
-
id: id,
|
|
179
|
-
embedScriptLink: embedScriptLink,
|
|
180
|
-
extraArgs: extraArgs
|
|
181
|
-
});
|
|
182
|
-
default:
|
|
183
|
-
return "";
|
|
184
|
-
}
|
|
224
|
+
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 };");
|
|
225
|
+
};
|
|
226
|
+
var reactCodeGenerators = {
|
|
227
|
+
inline: inlineEmbedCode,
|
|
228
|
+
floatingPopup: floatingPopupEmbedCode,
|
|
229
|
+
elementPopup: elementPopupEmbedCode
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
var _excluded = ["tab", "type"];
|
|
233
|
+
var generateCode = function generateCode(options) {
|
|
234
|
+
var _reactCodeGenerators$, _htmlCodeGenerators$t;
|
|
235
|
+
var tab = options.tab,
|
|
236
|
+
type = options.type,
|
|
237
|
+
embeddedCodeOptions = _objectWithoutProperties(options, _excluded);
|
|
238
|
+
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);
|
|
185
239
|
};
|
|
186
240
|
var buildDefaultCustomization = function buildDefaultCustomization(defaultCustomizations) {
|
|
187
241
|
return mergeDeepLeft(defaultCustomizations, DEFAULT_CUSTOMIZATION);
|
|
188
242
|
};
|
|
189
243
|
var buildQueryParamsFromInputFields = function buildQueryParamsFromInputFields(inputFields) {
|
|
190
|
-
var filteredInputFields = inputFields.filter(function (
|
|
191
|
-
var name =
|
|
192
|
-
value =
|
|
244
|
+
var filteredInputFields = inputFields.filter(function (_ref) {
|
|
245
|
+
var name = _ref.name,
|
|
246
|
+
value = _ref.value;
|
|
193
247
|
return name && value;
|
|
194
248
|
});
|
|
195
|
-
var queryParams = filteredInputFields.reduce(function (queryParams,
|
|
196
|
-
var name =
|
|
197
|
-
value =
|
|
249
|
+
var queryParams = filteredInputFields.reduce(function (queryParams, _ref2) {
|
|
250
|
+
var name = _ref2.name,
|
|
251
|
+
value = _ref2.value;
|
|
198
252
|
queryParams[name] = value;
|
|
199
253
|
return queryParams;
|
|
200
254
|
}, {});
|
|
@@ -515,14 +569,15 @@ var Customization = function Customization(_ref) {
|
|
|
515
569
|
};
|
|
516
570
|
|
|
517
571
|
var Header = function Header(_ref) {
|
|
518
|
-
var
|
|
519
|
-
setTab = _ref.setTab
|
|
572
|
+
var supportedLanguagesTabs = _ref.supportedLanguagesTabs,
|
|
573
|
+
setTab = _ref.setTab,
|
|
574
|
+
tab = _ref.tab;
|
|
520
575
|
return /*#__PURE__*/jsx("div", {
|
|
521
|
-
className: "flex w-full
|
|
576
|
+
className: "flex w-full",
|
|
522
577
|
children: /*#__PURE__*/jsx(Tab, {
|
|
523
578
|
noUnderline: true,
|
|
524
579
|
className: "neeto-molecules-product-embed-tab",
|
|
525
|
-
children:
|
|
580
|
+
children: supportedLanguagesTabs.map(function (_ref2) {
|
|
526
581
|
var key = _ref2.key,
|
|
527
582
|
label = _ref2.label,
|
|
528
583
|
icon = _ref2.icon;
|
|
@@ -675,6 +730,8 @@ var Preview = function Preview(_ref) {
|
|
|
675
730
|
});
|
|
676
731
|
}
|
|
677
732
|
return /*#__PURE__*/jsx(BrowserPreview, {
|
|
733
|
+
className: "h-full",
|
|
734
|
+
wrapperClassName: "neeto-molecules-embed__browser-preview pointer-events-auto",
|
|
678
735
|
children: /*#__PURE__*/jsx(Component, {
|
|
679
736
|
customization: customization,
|
|
680
737
|
iframeURL: iframeURL
|
|
@@ -682,7 +739,7 @@ var Preview = function Preview(_ref) {
|
|
|
682
739
|
});
|
|
683
740
|
};
|
|
684
741
|
|
|
685
|
-
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}}";
|
|
742
|
+
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%}";
|
|
686
743
|
n(css,{});
|
|
687
744
|
|
|
688
745
|
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; }
|
|
@@ -706,12 +763,19 @@ var ProductEmbed = function ProductEmbed(_ref) {
|
|
|
706
763
|
_ref$otherCustomizati = _ref.otherCustomizations,
|
|
707
764
|
otherCustomizations = _ref$otherCustomizati === void 0 ? noop : _ref$otherCustomizati,
|
|
708
765
|
_ref$inlineWrapperSty = _ref.inlineWrapperStyle,
|
|
709
|
-
inlineWrapperStyle = _ref$inlineWrapperSty === void 0 ? "" : _ref$inlineWrapperSty
|
|
766
|
+
inlineWrapperStyle = _ref$inlineWrapperSty === void 0 ? "" : _ref$inlineWrapperSty,
|
|
767
|
+
_ref$supportedLanguag = _ref.supportedLanguages,
|
|
768
|
+
supportedLanguages = _ref$supportedLanguag === void 0 ? ["html"] : _ref$supportedLanguag;
|
|
769
|
+
var supportedLanguagesTabs = filterBy({
|
|
770
|
+
key: function key(_key) {
|
|
771
|
+
return supportedLanguages === null || supportedLanguages === void 0 ? void 0 : supportedLanguages.includes(_key);
|
|
772
|
+
}
|
|
773
|
+
}, TABS);
|
|
710
774
|
var _useState = useState(true),
|
|
711
775
|
_useState2 = _slicedToArray(_useState, 2),
|
|
712
776
|
isScriptLoading = _useState2[0],
|
|
713
777
|
setIsScriptLoading = _useState2[1];
|
|
714
|
-
var _useState3 = useState(
|
|
778
|
+
var _useState3 = useState(supportedLanguagesTabs[0].key),
|
|
715
779
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
716
780
|
tab = _useState4[0],
|
|
717
781
|
setTab = _useState4[1];
|
|
@@ -728,8 +792,9 @@ var ProductEmbed = function ProductEmbed(_ref) {
|
|
|
728
792
|
var _useTranslation = useTranslation(),
|
|
729
793
|
t = _useTranslation.t;
|
|
730
794
|
var embedScriptLink = customEmbedScriptPath || "".concat(window.location.protocol, "//").concat(window.location.host, "/javascript/embed.js");
|
|
731
|
-
var code =
|
|
795
|
+
var code = generateCode({
|
|
732
796
|
id: id,
|
|
797
|
+
tab: tab,
|
|
733
798
|
type: selectedOption,
|
|
734
799
|
customization: customizations[selectedOption],
|
|
735
800
|
embedScriptLink: embedScriptLink,
|
|
@@ -786,21 +851,30 @@ var ProductEmbed = function ProductEmbed(_ref) {
|
|
|
786
851
|
})]
|
|
787
852
|
})]
|
|
788
853
|
}), /*#__PURE__*/jsxs("div", {
|
|
789
|
-
className: "neeto-molecules-embed__preview neeto-ui-bg-white flex min-h-screen w-full min-w-0 flex-col gap-
|
|
854
|
+
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",
|
|
790
855
|
children: [/*#__PURE__*/jsx(Header, {
|
|
791
856
|
setTab: setTab,
|
|
857
|
+
supportedLanguagesTabs: supportedLanguagesTabs,
|
|
792
858
|
tab: tab
|
|
793
|
-
}), /*#__PURE__*/
|
|
794
|
-
className: "flex flex-grow
|
|
795
|
-
children:
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
859
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
860
|
+
className: "flex min-h-0 flex-grow flex-col gap-3",
|
|
861
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
862
|
+
className: "flex-shrink-0",
|
|
863
|
+
"data-testid": "embed-code-block",
|
|
864
|
+
children: /*#__PURE__*/jsx(Code, {
|
|
865
|
+
code: code,
|
|
866
|
+
tab: tab
|
|
867
|
+
})
|
|
868
|
+
}), /*#__PURE__*/jsx("div", {
|
|
869
|
+
className: "flex-grow",
|
|
870
|
+
children: /*#__PURE__*/jsx(Preview, {
|
|
871
|
+
customPreviewIframeUrl: customPreviewIframeUrl,
|
|
872
|
+
id: id,
|
|
873
|
+
isScriptLoading: isScriptLoading,
|
|
874
|
+
selectedOption: selectedOption,
|
|
875
|
+
customization: customizations[selectedOption]
|
|
876
|
+
})
|
|
877
|
+
})]
|
|
804
878
|
})]
|
|
805
879
|
})]
|
|
806
880
|
});
|