@bigbinary/neeto-commons-frontend 2.0.14 → 2.0.15
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/README.md +1 -1
- package/initializers.cjs.js +16 -4
- package/initializers.js +16 -4
- package/package.json +1 -1
- package/react-utils.cjs.js +272 -179
- package/react-utils.js +273 -180
package/react-utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import React__default, { useState, useEffect,
|
|
2
|
+
import React__default, { useState, useEffect, useRef, useReducer } from 'react';
|
|
3
3
|
import { Search, Check, Copy, Help, LeftArrow as LeftArrow$1, User, Settings } from '@bigbinary/neeto-icons';
|
|
4
4
|
import { Dropdown, Input, Label, Checkbox, Typography, Tooltip, Button, Toastr, Modal, Switch, PageLoader } from '@bigbinary/neetoui';
|
|
5
5
|
import { curryN, isNil, complement as complement$1, isEmpty, curry, includes, __, filter, trim, toLower, identity, without, append, fromPairs, keys, values, last, pluck, any, uniq, intersection, mergeLeft, not as not$2, toPairs, assoc } from 'ramda';
|
|
@@ -495,11 +495,13 @@ var HoneybadgerErrorBoundary = function HoneybadgerErrorBoundary(_ref) {
|
|
|
495
495
|
};
|
|
496
496
|
|
|
497
497
|
var EMBED_WIDGET_S3_SCRIPT_STRING = "<script src=\"https://neeto-widget.s3.ap-south-1.amazonaws.com/embedNeetoWidget.js\"></script>";
|
|
498
|
-
var
|
|
499
|
-
var
|
|
500
|
-
var
|
|
501
|
-
var
|
|
502
|
-
var
|
|
498
|
+
var NEETO_WIDGET_USER_IDENTITY_KEY = "NeetoWidgetUserIdentity";
|
|
499
|
+
var SESSION_CONTEXT_KEY = "NeetoReplayWidgetSessionContext";
|
|
500
|
+
var DISABLE_NEETO_CHAT = "enableNeetoChat: false,";
|
|
501
|
+
var DISABLE_NEETO_CHANGELOG = "enableNeetoChangelog: false,";
|
|
502
|
+
var DISABLE_NEETO_REPLAY = "enableNeetoReplay: false,";
|
|
503
|
+
var SAMPLE_CONTEXT_CODE_STRING = "window.".concat(SESSION_CONTEXT_KEY, " = {\n key1: \"value\",\n key2: [\"array\", \"of\", \"values\"],\n /* More key-value pairs */\n}");
|
|
504
|
+
var SAMPLE_USER_IDENTITY_CODE_STRING = "window.".concat(NEETO_WIDGET_USER_IDENTITY_KEY, " = {\n user_identifier: \"USER_ID_HERE\",\n name: \"USER_NAME_HERE\",\n email: \"USER_EMAIL_HERE\",\n started_at: \"YYYY-MM-DD\",\n}");
|
|
503
505
|
var WIDGET_TYPES = {
|
|
504
506
|
changelog: "changelog",
|
|
505
507
|
chat: "chat",
|
|
@@ -515,6 +517,13 @@ var QUERY_KEYS = {
|
|
|
515
517
|
};
|
|
516
518
|
var DEFAULT_QUERY_STALE_TIME = 60 * 60 * 1000; // 1 hour in milliseconds
|
|
517
519
|
|
|
520
|
+
var EMAIL_TYPES = {
|
|
521
|
+
embedCode: "embedCode",
|
|
522
|
+
userIdentity: "userIdentity",
|
|
523
|
+
sessionContext: "sessionContext",
|
|
524
|
+
"null": ""
|
|
525
|
+
};
|
|
526
|
+
|
|
518
527
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
519
528
|
|
|
520
529
|
var propTypes = {exports: {}};
|
|
@@ -1699,6 +1708,125 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
1699
1708
|
propTypes.exports = requireFactoryWithThrowingShims()();
|
|
1700
1709
|
}
|
|
1701
1710
|
|
|
1711
|
+
function useDebounce(value) {
|
|
1712
|
+
var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 350;
|
|
1713
|
+
|
|
1714
|
+
var _useState = useState(value),
|
|
1715
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1716
|
+
debouncedValue = _useState2[0],
|
|
1717
|
+
setDebouncedValue = _useState2[1];
|
|
1718
|
+
|
|
1719
|
+
useEffect(function () {
|
|
1720
|
+
var handler = setTimeout(function () {
|
|
1721
|
+
setDebouncedValue(value);
|
|
1722
|
+
}, delay);
|
|
1723
|
+
return function () {
|
|
1724
|
+
clearTimeout(handler);
|
|
1725
|
+
};
|
|
1726
|
+
}, [value]);
|
|
1727
|
+
return debouncedValue;
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
var useFuncDebounce = function useFuncDebounce(func) {
|
|
1731
|
+
var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 350;
|
|
1732
|
+
var timer = useRef(null);
|
|
1733
|
+
|
|
1734
|
+
var debouncedFunc = function debouncedFunc() {
|
|
1735
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1736
|
+
args[_key] = arguments[_key];
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
clearTimeout(timer.current);
|
|
1740
|
+
timer.current = setTimeout(function () {
|
|
1741
|
+
return func.apply(void 0, args);
|
|
1742
|
+
}, delay);
|
|
1743
|
+
};
|
|
1744
|
+
|
|
1745
|
+
debouncedFunc.cancel = function () {
|
|
1746
|
+
return clearTimeout(timer.current);
|
|
1747
|
+
};
|
|
1748
|
+
|
|
1749
|
+
return debouncedFunc;
|
|
1750
|
+
};
|
|
1751
|
+
|
|
1752
|
+
var useForceUpdate = function useForceUpdate() {
|
|
1753
|
+
var _useState = useState(0),
|
|
1754
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1755
|
+
setValue = _useState2[1];
|
|
1756
|
+
|
|
1757
|
+
return function () {
|
|
1758
|
+
return setValue(function (value) {
|
|
1759
|
+
return value + 1;
|
|
1760
|
+
});
|
|
1761
|
+
};
|
|
1762
|
+
};
|
|
1763
|
+
|
|
1764
|
+
var useIsElementVisibleInDom = function useIsElementVisibleInDom(target) {
|
|
1765
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
|
|
1766
|
+
|
|
1767
|
+
var _useState = useState(false),
|
|
1768
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1769
|
+
isIntersecting = _useState2[0],
|
|
1770
|
+
setIntersecting = _useState2[1];
|
|
1771
|
+
|
|
1772
|
+
var forceUpdate = useForceUpdate();
|
|
1773
|
+
useEffect(function () {
|
|
1774
|
+
if (!target) return forceUpdate();
|
|
1775
|
+
var observer = new IntersectionObserver(function (_ref) {
|
|
1776
|
+
var _ref2 = _slicedToArray(_ref, 1),
|
|
1777
|
+
entry = _ref2[0];
|
|
1778
|
+
|
|
1779
|
+
return setIntersecting(entry.isIntersecting);
|
|
1780
|
+
}, options);
|
|
1781
|
+
observer.observe(target);
|
|
1782
|
+
return function () {
|
|
1783
|
+
return observer.unobserve(target);
|
|
1784
|
+
};
|
|
1785
|
+
}, [target, options]);
|
|
1786
|
+
return isIntersecting;
|
|
1787
|
+
};
|
|
1788
|
+
|
|
1789
|
+
var useOnClickOutside = function useOnClickOutside(ref, handler) {
|
|
1790
|
+
useEffect(function () {
|
|
1791
|
+
var listener = function listener(event) {
|
|
1792
|
+
// Do nothing if clicking ref's element or descendent elements
|
|
1793
|
+
if (!ref.current || ref.current.contains(event.target)) {
|
|
1794
|
+
return;
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
handler(event);
|
|
1798
|
+
};
|
|
1799
|
+
|
|
1800
|
+
document.addEventListener("mousedown", listener);
|
|
1801
|
+
document.addEventListener("touchstart", listener);
|
|
1802
|
+
return function () {
|
|
1803
|
+
document.removeEventListener("mousedown", listener);
|
|
1804
|
+
document.removeEventListener("touchstart", listener);
|
|
1805
|
+
};
|
|
1806
|
+
}, [handler]);
|
|
1807
|
+
};
|
|
1808
|
+
|
|
1809
|
+
var usePrevious = function usePrevious(value) {
|
|
1810
|
+
var ref = useRef(value);
|
|
1811
|
+
useEffect(function () {
|
|
1812
|
+
ref.current = value;
|
|
1813
|
+
}, [value]);
|
|
1814
|
+
return ref.current;
|
|
1815
|
+
};
|
|
1816
|
+
|
|
1817
|
+
var useUpdateEffect = function useUpdateEffect(callback) {
|
|
1818
|
+
var dependencies = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
1819
|
+
var isInitialMount = useRef(true);
|
|
1820
|
+
useEffect(function () {
|
|
1821
|
+
if (isInitialMount.current) {
|
|
1822
|
+
isInitialMount.current = false;
|
|
1823
|
+
return;
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1826
|
+
callback();
|
|
1827
|
+
}, dependencies);
|
|
1828
|
+
};
|
|
1829
|
+
|
|
1702
1830
|
var classnames$1 = {exports: {}};
|
|
1703
1831
|
|
|
1704
1832
|
/*!
|
|
@@ -85585,7 +85713,7 @@ var copyToClipboard = /*#__PURE__*/function () {
|
|
|
85585
85713
|
|
|
85586
85714
|
var CodeBlock = function CodeBlock(_ref) {
|
|
85587
85715
|
var _ref$title = _ref.title,
|
|
85588
|
-
title = _ref$title === void 0 ? "Code snippet" : _ref$title,
|
|
85716
|
+
title = _ref$title === void 0 ? /*#__PURE__*/React__default.createElement("div", null, "Code snippet") : _ref$title,
|
|
85589
85717
|
codeString = _ref.codeString,
|
|
85590
85718
|
_ref$showCopyButton = _ref.showCopyButton,
|
|
85591
85719
|
showCopyButton = _ref$showCopyButton === void 0 ? true : _ref$showCopyButton,
|
|
@@ -85646,7 +85774,7 @@ var CodeBlock = function CodeBlock(_ref) {
|
|
|
85646
85774
|
};
|
|
85647
85775
|
|
|
85648
85776
|
CodeBlock.propTypes = {
|
|
85649
|
-
title: propTypes.exports.
|
|
85777
|
+
title: propTypes.exports.object,
|
|
85650
85778
|
codeString: propTypes.exports.string,
|
|
85651
85779
|
showCopyButton: propTypes.exports.bool,
|
|
85652
85780
|
className: propTypes.exports.string,
|
|
@@ -85659,6 +85787,8 @@ var getWidgetApiKeyUrl = function getWidgetApiKeyUrl() {
|
|
|
85659
85787
|
};
|
|
85660
85788
|
var EMBED_CODE_EMAIL_URL = "api/v1/widget/email_snippets";
|
|
85661
85789
|
var WIDGET_KB_BASE_URL = "https://neetowidgethelp.neetokb.com";
|
|
85790
|
+
var NEETO_REPLAY_CONFIGURE_URL = "".concat(WIDGET_KB_BASE_URL, "/articles/configure-neetoreplay");
|
|
85791
|
+
var NEETO_CHAT_USER_IDENTITY_URL = "".concat(WIDGET_KB_BASE_URL, "/articles/configuring-neetochat");
|
|
85662
85792
|
var WIDGET_KB_HELP_URL = {
|
|
85663
85793
|
changelog: "".concat(WIDGET_KB_BASE_URL, "/categories/getting-started-with-neetochangelog"),
|
|
85664
85794
|
chat: "".concat(WIDGET_KB_BASE_URL, "/categories/getting-started-with-neetochat"),
|
|
@@ -85718,16 +85848,6 @@ var embedWidgetEnvironment = function embedWidgetEnvironment() {
|
|
|
85718
85848
|
}
|
|
85719
85849
|
};
|
|
85720
85850
|
|
|
85721
|
-
var getSampleUserIdentity = function getSampleUserIdentity(enabledWidgets) {
|
|
85722
|
-
return indentAndFormat(SAMPLE_USER_IDENTITY_CODE_STRING, function (cmd) {
|
|
85723
|
-
if (!enabledWidgets.chat && !cmd.includes("email") && !cmd.includes("{") && !cmd.includes("}") || !enabledWidgets.chat && !enabledWidgets.replay) {
|
|
85724
|
-
return getCommentedCommand(cmd, false, true);
|
|
85725
|
-
}
|
|
85726
|
-
|
|
85727
|
-
return cmd;
|
|
85728
|
-
});
|
|
85729
|
-
};
|
|
85730
|
-
|
|
85731
85851
|
var embedWidgetApiKey = function embedWidgetApiKey(apiKey) {
|
|
85732
85852
|
return "apiKey: \"".concat(apiKey, "\",");
|
|
85733
85853
|
};
|
|
@@ -85750,17 +85870,28 @@ var embedWidgetFunctionCall = function embedWidgetFunctionCall(enabledWidgets, a
|
|
|
85750
85870
|
}), "\n});");
|
|
85751
85871
|
};
|
|
85752
85872
|
|
|
85873
|
+
var filterMarkedCommands = function filterMarkedCommands(queryString) {
|
|
85874
|
+
return queryString.split("\n").filter(function (line) {
|
|
85875
|
+
return !line.includes("///") && line.trim();
|
|
85876
|
+
}).join("\n");
|
|
85877
|
+
};
|
|
85878
|
+
|
|
85879
|
+
var getSampleUserIdentity = function getSampleUserIdentity(enabledWidgets) {
|
|
85880
|
+
return filterMarkedCommands(SAMPLE_USER_IDENTITY_CODE_STRING.split("\n").map(function (cmd) {
|
|
85881
|
+
if (!enabledWidgets.chat && !cmd.includes("email") && !cmd.includes("{") && !cmd.includes("}") || !enabledWidgets.chat && !enabledWidgets.replay) {
|
|
85882
|
+
return getCommentedCommand(cmd, false, true);
|
|
85883
|
+
}
|
|
85884
|
+
|
|
85885
|
+
return cmd;
|
|
85886
|
+
}).join("\n"));
|
|
85887
|
+
};
|
|
85753
85888
|
var sampleConsolidatedCodeString = function sampleConsolidatedCodeString(enabledWidgets, apiKey) {
|
|
85754
|
-
return "".concat(EMBED_WIDGET_S3_SCRIPT_STRING, "\n<script>\n ").concat(
|
|
85755
|
-
return getCommentedCommand(cmd, enabledWidgets.replay, true);
|
|
85756
|
-
}), "\n\n ").concat(indentAndFormat(embedWidgetFunctionCall(enabledWidgets, apiKey)), "\n</script>");
|
|
85889
|
+
return filterMarkedCommands("".concat(EMBED_WIDGET_S3_SCRIPT_STRING, "\n<script>\n ").concat(enabledWidgets.chat || enabledWidgets.replay ? "window.".concat(NEETO_WIDGET_USER_IDENTITY_KEY, " = {};") : "", "\n ").concat(enabledWidgets.replay ? "window.".concat(SESSION_CONTEXT_KEY, " = {};") : "", "\n\n ").concat(indentAndFormat(embedWidgetFunctionCall(enabledWidgets, apiKey)), "\n</script>"));
|
|
85757
85890
|
};
|
|
85758
|
-
var getEmailWidgetSnippetFormInitialValues = function getEmailWidgetSnippetFormInitialValues(
|
|
85891
|
+
var getEmailWidgetSnippetFormInitialValues = function getEmailWidgetSnippetFormInitialValues(subject) {
|
|
85759
85892
|
return {
|
|
85760
85893
|
emails: "",
|
|
85761
|
-
subject:
|
|
85762
|
-
selectedWidgets: selectedWidgets
|
|
85763
|
-
})
|
|
85894
|
+
subject: subject
|
|
85764
85895
|
};
|
|
85765
85896
|
};
|
|
85766
85897
|
var getSelectedWidgetsCombinedText = function getSelectedWidgetsCombinedText(widgets) {
|
|
@@ -85786,7 +85917,10 @@ var CodeSnippet = function CodeSnippet(_ref) {
|
|
|
85786
85917
|
_ref$onSent = _ref.onSent,
|
|
85787
85918
|
onSent = _ref$onSent === void 0 ? noop$2 : _ref$onSent,
|
|
85788
85919
|
codeString = _ref.codeString,
|
|
85789
|
-
|
|
85920
|
+
_ref$subject = _ref.subject,
|
|
85921
|
+
subject = _ref$subject === void 0 ? "" : _ref$subject,
|
|
85922
|
+
_ref$body = _ref.body,
|
|
85923
|
+
body = _ref$body === void 0 ? "" : _ref$body;
|
|
85790
85924
|
|
|
85791
85925
|
var _useTranslation = useTranslation(),
|
|
85792
85926
|
t = _useTranslation.t;
|
|
@@ -85814,7 +85948,7 @@ var CodeSnippet = function CodeSnippet(_ref) {
|
|
|
85814
85948
|
emailMutation.mutate({
|
|
85815
85949
|
subject: formData.subject,
|
|
85816
85950
|
emails: pluck("value", formData.emails),
|
|
85817
|
-
message:
|
|
85951
|
+
message: body,
|
|
85818
85952
|
snippet: codeString
|
|
85819
85953
|
});
|
|
85820
85954
|
|
|
@@ -85831,19 +85965,13 @@ var CodeSnippet = function CodeSnippet(_ref) {
|
|
|
85831
85965
|
};
|
|
85832
85966
|
}();
|
|
85833
85967
|
|
|
85834
|
-
var getDefaultBody = function getDefaultBody() {
|
|
85835
|
-
return t("neetoCommons.widget.email.body", {
|
|
85836
|
-
selectedWidgets: getSelectedWidgetsCombinedText(selectedWidgets)
|
|
85837
|
-
});
|
|
85838
|
-
};
|
|
85839
|
-
|
|
85840
85968
|
return /*#__PURE__*/React__default.createElement(Modal, {
|
|
85841
85969
|
className: "rounded-lg w-1/2 mx-auto",
|
|
85842
85970
|
isOpen: isModalOpen,
|
|
85843
85971
|
size: "medium",
|
|
85844
85972
|
onClose: onClose
|
|
85845
85973
|
}, /*#__PURE__*/React__default.createElement(Formik, {
|
|
85846
|
-
initialValues: getEmailWidgetSnippetFormInitialValues(
|
|
85974
|
+
initialValues: getEmailWidgetSnippetFormInitialValues(subject),
|
|
85847
85975
|
validationSchema: EMAIL_WIDGET_SNIPPET_FORM_VALIDATION_SCHEMA,
|
|
85848
85976
|
onSubmit: handleSubmit
|
|
85849
85977
|
}, /*#__PURE__*/React__default.createElement(Form, null, /*#__PURE__*/React__default.createElement(Modal.Header, null, /*#__PURE__*/React__default.createElement(Typography, {
|
|
@@ -85866,7 +85994,7 @@ var CodeSnippet = function CodeSnippet(_ref) {
|
|
|
85866
85994
|
}, /*#__PURE__*/React__default.createElement(Typography, {
|
|
85867
85995
|
className: "mb-6",
|
|
85868
85996
|
style: "body1"
|
|
85869
|
-
},
|
|
85997
|
+
}, body), /*#__PURE__*/React__default.createElement(CodeBlock, {
|
|
85870
85998
|
className: "neeto-ui-bg-primary-100 neeto-ui-rounded-xl overflow-hidden",
|
|
85871
85999
|
codeString: codeString,
|
|
85872
86000
|
copyButton: false,
|
|
@@ -85892,7 +86020,8 @@ CodeSnippet.propTypes = {
|
|
|
85892
86020
|
onClose: propTypes.exports.func,
|
|
85893
86021
|
onSent: propTypes.exports.func,
|
|
85894
86022
|
codeString: propTypes.exports.string,
|
|
85895
|
-
|
|
86023
|
+
subject: propTypes.exports.string,
|
|
86024
|
+
body: propTypes.exports.string
|
|
85896
86025
|
};
|
|
85897
86026
|
|
|
85898
86027
|
var useFetchApiKey = function useFetchApiKey() {
|
|
@@ -85933,7 +86062,7 @@ var SelectionTabs = function SelectionTabs(_ref) {
|
|
|
85933
86062
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
85934
86063
|
className: "mb-4 px-2 w-full flex items-center justify-between gap-2"
|
|
85935
86064
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
85936
|
-
className: "flex items-center justify-start gap-
|
|
86065
|
+
className: "flex items-center justify-start gap-1"
|
|
85937
86066
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
85938
86067
|
className: "font-semibold text-base"
|
|
85939
86068
|
}, "neeto", formattedPrimaryWidget), /*#__PURE__*/React__default.createElement("a", {
|
|
@@ -85941,7 +86070,7 @@ var SelectionTabs = function SelectionTabs(_ref) {
|
|
|
85941
86070
|
target: "_blank",
|
|
85942
86071
|
rel: "noreferrer"
|
|
85943
86072
|
}, /*#__PURE__*/React__default.createElement(Help, {
|
|
85944
|
-
size:
|
|
86073
|
+
size: 16
|
|
85945
86074
|
}))), /*#__PURE__*/React__default.createElement("div", {
|
|
85946
86075
|
className: "flex items-center justify-end gap-2"
|
|
85947
86076
|
}, renderSelectedTab()));
|
|
@@ -85954,8 +86083,6 @@ SelectionTabs.propTypes = {
|
|
|
85954
86083
|
};
|
|
85955
86084
|
|
|
85956
86085
|
var EmbedCode = function EmbedCode(_ref) {
|
|
85957
|
-
var _apiKeyResult$data2;
|
|
85958
|
-
|
|
85959
86086
|
var _ref$primaryApp = _ref.primaryApp,
|
|
85960
86087
|
primaryApp = _ref$primaryApp === void 0 ? "" : _ref$primaryApp,
|
|
85961
86088
|
_ref$initialSelectedW = _ref.initialSelectedWidgets,
|
|
@@ -85967,16 +86094,18 @@ var EmbedCode = function EmbedCode(_ref) {
|
|
|
85967
86094
|
var apiKeyResult = useFetchApiKey();
|
|
85968
86095
|
var initialWidgets = uniq(intersection(append(primaryApp, initialSelectedWidgets), WIDGET_TYPES_VALUES));
|
|
85969
86096
|
|
|
85970
|
-
var _useState = useState(
|
|
86097
|
+
var _useState = useState(EMAIL_TYPES["null"]),
|
|
85971
86098
|
_useState2 = _slicedToArray(_useState, 2),
|
|
85972
|
-
|
|
85973
|
-
|
|
86099
|
+
emailType = _useState2[0],
|
|
86100
|
+
setEmailType = _useState2[1];
|
|
85974
86101
|
|
|
85975
86102
|
var _useState3 = useState(intersection(initialWidgets, WIDGET_TYPES_VALUES)),
|
|
85976
86103
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
85977
86104
|
selectedWidgets = _useState4[0],
|
|
85978
86105
|
setSelectedWidgets = _useState4[1];
|
|
85979
86106
|
|
|
86107
|
+
var previousEmailType = usePrevious(emailType);
|
|
86108
|
+
|
|
85980
86109
|
var updateSelectedWidgets = function updateSelectedWidgets(widget) {
|
|
85981
86110
|
if (selectedWidgets.includes(widget)) {
|
|
85982
86111
|
setSelectedWidgets(without([widget], selectedWidgets));
|
|
@@ -85988,25 +86117,64 @@ var EmbedCode = function EmbedCode(_ref) {
|
|
|
85988
86117
|
var enabledWidgets = fromPairs(selectedWidgets.map(function (widget) {
|
|
85989
86118
|
return [widget, true];
|
|
85990
86119
|
}));
|
|
85991
|
-
|
|
86120
|
+
|
|
86121
|
+
var getEmbedCodeString = function getEmbedCodeString() {
|
|
85992
86122
|
var _apiKeyResult$data;
|
|
85993
86123
|
|
|
85994
86124
|
if ((_apiKeyResult$data = apiKeyResult.data) !== null && _apiKeyResult$data !== void 0 && _apiKeyResult$data.widgetApiKey) {
|
|
85995
|
-
return sampleConsolidatedCodeString(enabledWidgets, apiKeyResult.data.widgetApiKey)
|
|
85996
|
-
return !line.includes("///") && line.trim();
|
|
85997
|
-
}).join("\n");
|
|
86125
|
+
return sampleConsolidatedCodeString(enabledWidgets, apiKeyResult.data.widgetApiKey);
|
|
85998
86126
|
}
|
|
85999
86127
|
|
|
86000
86128
|
return "";
|
|
86001
|
-
}
|
|
86129
|
+
};
|
|
86130
|
+
|
|
86131
|
+
var getSnippetProps = function getSnippetProps(selectedEmailType) {
|
|
86132
|
+
switch (selectedEmailType) {
|
|
86133
|
+
case EMAIL_TYPES.embedCode:
|
|
86134
|
+
return {
|
|
86135
|
+
codeString: getEmbedCodeString(),
|
|
86136
|
+
subject: t("neetoCommons.widget.email.fields.subject.values.embedCode", {
|
|
86137
|
+
selectedWidgets: getSelectedWidgetsCombinedText(selectedWidgets)
|
|
86138
|
+
}),
|
|
86139
|
+
body: t("neetoCommons.widget.email.body.values.embedCode", {
|
|
86140
|
+
selectedWidgets: getSelectedWidgetsCombinedText(selectedWidgets),
|
|
86141
|
+
neetoKbUrl: WIDGET_KB_BASE_URL
|
|
86142
|
+
})
|
|
86143
|
+
};
|
|
86002
86144
|
|
|
86003
|
-
|
|
86145
|
+
case EMAIL_TYPES.userIdentity:
|
|
86146
|
+
return {
|
|
86147
|
+
codeString: getSampleUserIdentity(enabledWidgets),
|
|
86148
|
+
subject: t("neetoCommons.widget.email.fields.subject.values.userIdentity"),
|
|
86149
|
+
body: t("neetoCommons.widget.email.body.values.userIdentity", {
|
|
86150
|
+
userIdentityKbUrl: enabledWidgets.chat ? NEETO_CHAT_USER_IDENTITY_URL : NEETO_REPLAY_CONFIGURE_URL
|
|
86151
|
+
})
|
|
86152
|
+
};
|
|
86153
|
+
|
|
86154
|
+
case EMAIL_TYPES.sessionContext:
|
|
86155
|
+
return {
|
|
86156
|
+
codeString: SAMPLE_CONTEXT_CODE_STRING,
|
|
86157
|
+
subject: t("neetoCommons.widget.email.fields.subject.values.sessionContext"),
|
|
86158
|
+
body: t("neetoCommons.widget.email.body.values.sessionContext", {
|
|
86159
|
+
sessionContextKbUrl: NEETO_REPLAY_CONFIGURE_URL
|
|
86160
|
+
})
|
|
86161
|
+
};
|
|
86162
|
+
|
|
86163
|
+
case EMAIL_TYPES["null"]:
|
|
86164
|
+
return previousEmailType !== EMAIL_TYPES["null"] ? getSnippetProps(previousEmailType) : {};
|
|
86165
|
+
|
|
86166
|
+
default:
|
|
86167
|
+
throw new Error("Invalid email type received.");
|
|
86168
|
+
}
|
|
86169
|
+
};
|
|
86170
|
+
|
|
86171
|
+
var handleSendViaEmail = function handleSendViaEmail(selectedEmail) {
|
|
86004
86172
|
if (isEmpty(selectedWidgets)) {
|
|
86005
86173
|
Toastr.error(t("neetoCommons.widget.installation.snippet.disabledError"));
|
|
86006
86174
|
return;
|
|
86007
86175
|
}
|
|
86008
86176
|
|
|
86009
|
-
|
|
86177
|
+
setEmailType(selectedEmail);
|
|
86010
86178
|
};
|
|
86011
86179
|
|
|
86012
86180
|
if (apiKeyResult.isLoading) {
|
|
@@ -86016,20 +86184,22 @@ var EmbedCode = function EmbedCode(_ref) {
|
|
|
86016
86184
|
}
|
|
86017
86185
|
|
|
86018
86186
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
86019
|
-
className: "mx-auto w-full flex-col items-center justify-start"
|
|
86187
|
+
className: "mx-auto w-full flex-col items-center justify-start mb-10"
|
|
86020
86188
|
}, /*#__PURE__*/React__default.createElement(SelectionTabs, {
|
|
86021
86189
|
primarySelectedWidget: primaryApp,
|
|
86022
86190
|
selectedWidgets: selectedWidgets,
|
|
86023
86191
|
updateSelectedWidgets: updateSelectedWidgets
|
|
86024
86192
|
}), /*#__PURE__*/React__default.createElement("div", {
|
|
86025
|
-
className: "mx-auto w-full max-w-2xl flex-grow flex-col items-center justify-start"
|
|
86193
|
+
className: "mx-auto w-full max-w-2xl flex-grow flex-col items-center justify-start mb-6"
|
|
86026
86194
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
86027
86195
|
className: "mx-auto mb-4 w-full"
|
|
86028
86196
|
}, /*#__PURE__*/React__default.createElement(CodeBlock, {
|
|
86029
|
-
codeString:
|
|
86197
|
+
codeString: getEmbedCodeString(),
|
|
86030
86198
|
className: "neeto-ui-bg-primary-100 neeto-ui-rounded-xl overflow-hidden",
|
|
86031
|
-
title: "Embed
|
|
86032
|
-
sendViaEmail:
|
|
86199
|
+
title: /*#__PURE__*/React__default.createElement("div", null, "Embed code"),
|
|
86200
|
+
sendViaEmail: function sendViaEmail() {
|
|
86201
|
+
return handleSendViaEmail(EMAIL_TYPES.embedCode);
|
|
86202
|
+
}
|
|
86033
86203
|
})), /*#__PURE__*/React__default.createElement("div", {
|
|
86034
86204
|
className: "w-full"
|
|
86035
86205
|
}, /*#__PURE__*/React__default.createElement(Trans, {
|
|
@@ -86045,14 +86215,56 @@ var EmbedCode = function EmbedCode(_ref) {
|
|
|
86045
86215
|
className: "font-normal"
|
|
86046
86216
|
})
|
|
86047
86217
|
}
|
|
86048
|
-
}, "Place the embed code in your HTML file. This will embed the selected widgets in your website.")), /*#__PURE__*/React__default.createElement(
|
|
86049
|
-
|
|
86050
|
-
|
|
86051
|
-
|
|
86218
|
+
}, "Place the embed code in your HTML file. This will embed the selected widgets in your website."))), enabledWidgets.chat || enabledWidgets.replay ? /*#__PURE__*/React__default.createElement("div", {
|
|
86219
|
+
className: "mx-auto w-full max-w-2xl flex-grow flex-col items-center justify-start mb-6"
|
|
86220
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
86221
|
+
className: "mx-auto mb-4 w-full"
|
|
86222
|
+
}, /*#__PURE__*/React__default.createElement(CodeBlock, {
|
|
86223
|
+
codeString: getSampleUserIdentity(enabledWidgets),
|
|
86224
|
+
className: "neeto-ui-bg-primary-100 neeto-ui-rounded-xl overflow-hidden",
|
|
86225
|
+
sendViaEmail: function sendViaEmail() {
|
|
86226
|
+
return handleSendViaEmail(EMAIL_TYPES.userIdentity);
|
|
86227
|
+
},
|
|
86228
|
+
title: /*#__PURE__*/React__default.createElement("div", {
|
|
86229
|
+
className: "flex items-center justify-start"
|
|
86230
|
+
}, /*#__PURE__*/React__default.createElement("div", null, "User identity (Optional)"), /*#__PURE__*/React__default.createElement("a", {
|
|
86231
|
+
href: enabledWidgets.chat ? NEETO_CHAT_USER_IDENTITY_URL : NEETO_REPLAY_CONFIGURE_URL,
|
|
86232
|
+
target: "_blank",
|
|
86233
|
+
rel: "noreferrer",
|
|
86234
|
+
className: "ml-1"
|
|
86235
|
+
}, /*#__PURE__*/React__default.createElement(Help, {
|
|
86236
|
+
size: 16
|
|
86237
|
+
})))
|
|
86238
|
+
})), /*#__PURE__*/React__default.createElement("div", {
|
|
86239
|
+
className: "w-full"
|
|
86240
|
+
}, t("neetoCommons.widget.installation.instructions.userIdentity"))) : null, enabledWidgets.replay ? /*#__PURE__*/React__default.createElement("div", {
|
|
86241
|
+
className: "mx-auto w-full max-w-2xl flex-grow flex-col items-center justify-start"
|
|
86242
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
86243
|
+
className: "mx-auto mb-4 w-full"
|
|
86244
|
+
}, /*#__PURE__*/React__default.createElement(CodeBlock, {
|
|
86245
|
+
codeString: SAMPLE_CONTEXT_CODE_STRING,
|
|
86246
|
+
className: "neeto-ui-bg-primary-100 neeto-ui-rounded-xl overflow-hidden",
|
|
86247
|
+
sendViaEmail: function sendViaEmail() {
|
|
86248
|
+
return handleSendViaEmail(EMAIL_TYPES.sessionContext);
|
|
86249
|
+
},
|
|
86250
|
+
title: /*#__PURE__*/React__default.createElement("div", {
|
|
86251
|
+
className: "flex items-center justify-start"
|
|
86252
|
+
}, /*#__PURE__*/React__default.createElement("div", null, "Session context (Optional)"), /*#__PURE__*/React__default.createElement("a", {
|
|
86253
|
+
href: NEETO_REPLAY_CONFIGURE_URL,
|
|
86254
|
+
target: "_blank",
|
|
86255
|
+
rel: "noreferrer",
|
|
86256
|
+
className: "ml-1"
|
|
86257
|
+
}, /*#__PURE__*/React__default.createElement(Help, {
|
|
86258
|
+
size: 16
|
|
86259
|
+
})))
|
|
86260
|
+
})), /*#__PURE__*/React__default.createElement("div", {
|
|
86261
|
+
className: "w-full"
|
|
86262
|
+
}, t("neetoCommons.widget.installation.instructions.sessionContext"))) : null, /*#__PURE__*/React__default.createElement(CodeSnippet, _extends$4({
|
|
86263
|
+
isModalOpen: !!emailType && isNotEmpty(selectedWidgets),
|
|
86052
86264
|
onClose: function onClose() {
|
|
86053
|
-
return
|
|
86265
|
+
return setEmailType(EMAIL_TYPES["null"]);
|
|
86054
86266
|
}
|
|
86055
|
-
})));
|
|
86267
|
+
}, getSnippetProps(emailType))));
|
|
86056
86268
|
};
|
|
86057
86269
|
|
|
86058
86270
|
EmbedCode.propTypes = {
|
|
@@ -86236,125 +86448,6 @@ var NeetoWidget = {
|
|
|
86236
86448
|
WIDGET_TYPES: WIDGET_TYPES
|
|
86237
86449
|
};
|
|
86238
86450
|
|
|
86239
|
-
function useDebounce(value) {
|
|
86240
|
-
var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 350;
|
|
86241
|
-
|
|
86242
|
-
var _useState = useState(value),
|
|
86243
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
86244
|
-
debouncedValue = _useState2[0],
|
|
86245
|
-
setDebouncedValue = _useState2[1];
|
|
86246
|
-
|
|
86247
|
-
useEffect(function () {
|
|
86248
|
-
var handler = setTimeout(function () {
|
|
86249
|
-
setDebouncedValue(value);
|
|
86250
|
-
}, delay);
|
|
86251
|
-
return function () {
|
|
86252
|
-
clearTimeout(handler);
|
|
86253
|
-
};
|
|
86254
|
-
}, [value]);
|
|
86255
|
-
return debouncedValue;
|
|
86256
|
-
}
|
|
86257
|
-
|
|
86258
|
-
var useFuncDebounce = function useFuncDebounce(func) {
|
|
86259
|
-
var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 350;
|
|
86260
|
-
var timer = useRef(null);
|
|
86261
|
-
|
|
86262
|
-
var debouncedFunc = function debouncedFunc() {
|
|
86263
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
86264
|
-
args[_key] = arguments[_key];
|
|
86265
|
-
}
|
|
86266
|
-
|
|
86267
|
-
clearTimeout(timer.current);
|
|
86268
|
-
timer.current = setTimeout(function () {
|
|
86269
|
-
return func.apply(void 0, args);
|
|
86270
|
-
}, delay);
|
|
86271
|
-
};
|
|
86272
|
-
|
|
86273
|
-
debouncedFunc.cancel = function () {
|
|
86274
|
-
return clearTimeout(timer.current);
|
|
86275
|
-
};
|
|
86276
|
-
|
|
86277
|
-
return debouncedFunc;
|
|
86278
|
-
};
|
|
86279
|
-
|
|
86280
|
-
var useForceUpdate = function useForceUpdate() {
|
|
86281
|
-
var _useState = useState(0),
|
|
86282
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
86283
|
-
setValue = _useState2[1];
|
|
86284
|
-
|
|
86285
|
-
return function () {
|
|
86286
|
-
return setValue(function (value) {
|
|
86287
|
-
return value + 1;
|
|
86288
|
-
});
|
|
86289
|
-
};
|
|
86290
|
-
};
|
|
86291
|
-
|
|
86292
|
-
var useIsElementVisibleInDom = function useIsElementVisibleInDom(target) {
|
|
86293
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
|
|
86294
|
-
|
|
86295
|
-
var _useState = useState(false),
|
|
86296
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
86297
|
-
isIntersecting = _useState2[0],
|
|
86298
|
-
setIntersecting = _useState2[1];
|
|
86299
|
-
|
|
86300
|
-
var forceUpdate = useForceUpdate();
|
|
86301
|
-
useEffect(function () {
|
|
86302
|
-
if (!target) return forceUpdate();
|
|
86303
|
-
var observer = new IntersectionObserver(function (_ref) {
|
|
86304
|
-
var _ref2 = _slicedToArray(_ref, 1),
|
|
86305
|
-
entry = _ref2[0];
|
|
86306
|
-
|
|
86307
|
-
return setIntersecting(entry.isIntersecting);
|
|
86308
|
-
}, options);
|
|
86309
|
-
observer.observe(target);
|
|
86310
|
-
return function () {
|
|
86311
|
-
return observer.unobserve(target);
|
|
86312
|
-
};
|
|
86313
|
-
}, [target, options]);
|
|
86314
|
-
return isIntersecting;
|
|
86315
|
-
};
|
|
86316
|
-
|
|
86317
|
-
var useOnClickOutside = function useOnClickOutside(ref, handler) {
|
|
86318
|
-
useEffect(function () {
|
|
86319
|
-
var listener = function listener(event) {
|
|
86320
|
-
// Do nothing if clicking ref's element or descendent elements
|
|
86321
|
-
if (!ref.current || ref.current.contains(event.target)) {
|
|
86322
|
-
return;
|
|
86323
|
-
}
|
|
86324
|
-
|
|
86325
|
-
handler(event);
|
|
86326
|
-
};
|
|
86327
|
-
|
|
86328
|
-
document.addEventListener("mousedown", listener);
|
|
86329
|
-
document.addEventListener("touchstart", listener);
|
|
86330
|
-
return function () {
|
|
86331
|
-
document.removeEventListener("mousedown", listener);
|
|
86332
|
-
document.removeEventListener("touchstart", listener);
|
|
86333
|
-
};
|
|
86334
|
-
}, [handler]);
|
|
86335
|
-
};
|
|
86336
|
-
|
|
86337
|
-
var usePrevious = function usePrevious(value) {
|
|
86338
|
-
var ref = useRef(value);
|
|
86339
|
-
useEffect(function () {
|
|
86340
|
-
ref.current = value;
|
|
86341
|
-
}, [value]);
|
|
86342
|
-
return ref.current;
|
|
86343
|
-
};
|
|
86344
|
-
|
|
86345
|
-
var useUpdateEffect = function useUpdateEffect(callback) {
|
|
86346
|
-
var dependencies = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
86347
|
-
var isInitialMount = useRef(true);
|
|
86348
|
-
useEffect(function () {
|
|
86349
|
-
if (isInitialMount.current) {
|
|
86350
|
-
isInitialMount.current = false;
|
|
86351
|
-
return;
|
|
86352
|
-
}
|
|
86353
|
-
|
|
86354
|
-
callback();
|
|
86355
|
-
}, dependencies);
|
|
86356
|
-
};
|
|
86357
|
-
|
|
86358
86451
|
var ReducerBasedProvider = function ReducerBasedProvider(initialValue, StateContext, DispatchContext, reducer) {
|
|
86359
86452
|
return function Provider(_ref) {
|
|
86360
86453
|
var children = _ref.children;
|