@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.cjs.js
CHANGED
|
@@ -527,11 +527,13 @@ var HoneybadgerErrorBoundary = function HoneybadgerErrorBoundary(_ref) {
|
|
|
527
527
|
};
|
|
528
528
|
|
|
529
529
|
var EMBED_WIDGET_S3_SCRIPT_STRING = "<script src=\"https://neeto-widget.s3.ap-south-1.amazonaws.com/embedNeetoWidget.js\"></script>";
|
|
530
|
-
var
|
|
531
|
-
var
|
|
532
|
-
var
|
|
533
|
-
var
|
|
534
|
-
var
|
|
530
|
+
var NEETO_WIDGET_USER_IDENTITY_KEY = "NeetoWidgetUserIdentity";
|
|
531
|
+
var SESSION_CONTEXT_KEY = "NeetoReplayWidgetSessionContext";
|
|
532
|
+
var DISABLE_NEETO_CHAT = "enableNeetoChat: false,";
|
|
533
|
+
var DISABLE_NEETO_CHANGELOG = "enableNeetoChangelog: false,";
|
|
534
|
+
var DISABLE_NEETO_REPLAY = "enableNeetoReplay: false,";
|
|
535
|
+
var SAMPLE_CONTEXT_CODE_STRING = "window.".concat(SESSION_CONTEXT_KEY, " = {\n key1: \"value\",\n key2: [\"array\", \"of\", \"values\"],\n /* More key-value pairs */\n}");
|
|
536
|
+
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}");
|
|
535
537
|
var WIDGET_TYPES = {
|
|
536
538
|
changelog: "changelog",
|
|
537
539
|
chat: "chat",
|
|
@@ -547,6 +549,13 @@ var QUERY_KEYS = {
|
|
|
547
549
|
};
|
|
548
550
|
var DEFAULT_QUERY_STALE_TIME = 60 * 60 * 1000; // 1 hour in milliseconds
|
|
549
551
|
|
|
552
|
+
var EMAIL_TYPES = {
|
|
553
|
+
embedCode: "embedCode",
|
|
554
|
+
userIdentity: "userIdentity",
|
|
555
|
+
sessionContext: "sessionContext",
|
|
556
|
+
"null": ""
|
|
557
|
+
};
|
|
558
|
+
|
|
550
559
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
551
560
|
|
|
552
561
|
var propTypes = {exports: {}};
|
|
@@ -1731,6 +1740,125 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
1731
1740
|
propTypes.exports = requireFactoryWithThrowingShims()();
|
|
1732
1741
|
}
|
|
1733
1742
|
|
|
1743
|
+
function useDebounce(value) {
|
|
1744
|
+
var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 350;
|
|
1745
|
+
|
|
1746
|
+
var _useState = React.useState(value),
|
|
1747
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1748
|
+
debouncedValue = _useState2[0],
|
|
1749
|
+
setDebouncedValue = _useState2[1];
|
|
1750
|
+
|
|
1751
|
+
React.useEffect(function () {
|
|
1752
|
+
var handler = setTimeout(function () {
|
|
1753
|
+
setDebouncedValue(value);
|
|
1754
|
+
}, delay);
|
|
1755
|
+
return function () {
|
|
1756
|
+
clearTimeout(handler);
|
|
1757
|
+
};
|
|
1758
|
+
}, [value]);
|
|
1759
|
+
return debouncedValue;
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1762
|
+
var useFuncDebounce = function useFuncDebounce(func) {
|
|
1763
|
+
var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 350;
|
|
1764
|
+
var timer = React.useRef(null);
|
|
1765
|
+
|
|
1766
|
+
var debouncedFunc = function debouncedFunc() {
|
|
1767
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1768
|
+
args[_key] = arguments[_key];
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1771
|
+
clearTimeout(timer.current);
|
|
1772
|
+
timer.current = setTimeout(function () {
|
|
1773
|
+
return func.apply(void 0, args);
|
|
1774
|
+
}, delay);
|
|
1775
|
+
};
|
|
1776
|
+
|
|
1777
|
+
debouncedFunc.cancel = function () {
|
|
1778
|
+
return clearTimeout(timer.current);
|
|
1779
|
+
};
|
|
1780
|
+
|
|
1781
|
+
return debouncedFunc;
|
|
1782
|
+
};
|
|
1783
|
+
|
|
1784
|
+
var useForceUpdate = function useForceUpdate() {
|
|
1785
|
+
var _useState = React.useState(0),
|
|
1786
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1787
|
+
setValue = _useState2[1];
|
|
1788
|
+
|
|
1789
|
+
return function () {
|
|
1790
|
+
return setValue(function (value) {
|
|
1791
|
+
return value + 1;
|
|
1792
|
+
});
|
|
1793
|
+
};
|
|
1794
|
+
};
|
|
1795
|
+
|
|
1796
|
+
var useIsElementVisibleInDom = function useIsElementVisibleInDom(target) {
|
|
1797
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
|
|
1798
|
+
|
|
1799
|
+
var _useState = React.useState(false),
|
|
1800
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1801
|
+
isIntersecting = _useState2[0],
|
|
1802
|
+
setIntersecting = _useState2[1];
|
|
1803
|
+
|
|
1804
|
+
var forceUpdate = useForceUpdate();
|
|
1805
|
+
React.useEffect(function () {
|
|
1806
|
+
if (!target) return forceUpdate();
|
|
1807
|
+
var observer = new IntersectionObserver(function (_ref) {
|
|
1808
|
+
var _ref2 = _slicedToArray(_ref, 1),
|
|
1809
|
+
entry = _ref2[0];
|
|
1810
|
+
|
|
1811
|
+
return setIntersecting(entry.isIntersecting);
|
|
1812
|
+
}, options);
|
|
1813
|
+
observer.observe(target);
|
|
1814
|
+
return function () {
|
|
1815
|
+
return observer.unobserve(target);
|
|
1816
|
+
};
|
|
1817
|
+
}, [target, options]);
|
|
1818
|
+
return isIntersecting;
|
|
1819
|
+
};
|
|
1820
|
+
|
|
1821
|
+
var useOnClickOutside = function useOnClickOutside(ref, handler) {
|
|
1822
|
+
React.useEffect(function () {
|
|
1823
|
+
var listener = function listener(event) {
|
|
1824
|
+
// Do nothing if clicking ref's element or descendent elements
|
|
1825
|
+
if (!ref.current || ref.current.contains(event.target)) {
|
|
1826
|
+
return;
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1829
|
+
handler(event);
|
|
1830
|
+
};
|
|
1831
|
+
|
|
1832
|
+
document.addEventListener("mousedown", listener);
|
|
1833
|
+
document.addEventListener("touchstart", listener);
|
|
1834
|
+
return function () {
|
|
1835
|
+
document.removeEventListener("mousedown", listener);
|
|
1836
|
+
document.removeEventListener("touchstart", listener);
|
|
1837
|
+
};
|
|
1838
|
+
}, [handler]);
|
|
1839
|
+
};
|
|
1840
|
+
|
|
1841
|
+
var usePrevious = function usePrevious(value) {
|
|
1842
|
+
var ref = React.useRef(value);
|
|
1843
|
+
React.useEffect(function () {
|
|
1844
|
+
ref.current = value;
|
|
1845
|
+
}, [value]);
|
|
1846
|
+
return ref.current;
|
|
1847
|
+
};
|
|
1848
|
+
|
|
1849
|
+
var useUpdateEffect = function useUpdateEffect(callback) {
|
|
1850
|
+
var dependencies = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
1851
|
+
var isInitialMount = React.useRef(true);
|
|
1852
|
+
React.useEffect(function () {
|
|
1853
|
+
if (isInitialMount.current) {
|
|
1854
|
+
isInitialMount.current = false;
|
|
1855
|
+
return;
|
|
1856
|
+
}
|
|
1857
|
+
|
|
1858
|
+
callback();
|
|
1859
|
+
}, dependencies);
|
|
1860
|
+
};
|
|
1861
|
+
|
|
1734
1862
|
var classnames$1 = {exports: {}};
|
|
1735
1863
|
|
|
1736
1864
|
/*!
|
|
@@ -85617,7 +85745,7 @@ var copyToClipboard = /*#__PURE__*/function () {
|
|
|
85617
85745
|
|
|
85618
85746
|
var CodeBlock = function CodeBlock(_ref) {
|
|
85619
85747
|
var _ref$title = _ref.title,
|
|
85620
|
-
title = _ref$title === void 0 ? "Code snippet" : _ref$title,
|
|
85748
|
+
title = _ref$title === void 0 ? /*#__PURE__*/React__default["default"].createElement("div", null, "Code snippet") : _ref$title,
|
|
85621
85749
|
codeString = _ref.codeString,
|
|
85622
85750
|
_ref$showCopyButton = _ref.showCopyButton,
|
|
85623
85751
|
showCopyButton = _ref$showCopyButton === void 0 ? true : _ref$showCopyButton,
|
|
@@ -85678,7 +85806,7 @@ var CodeBlock = function CodeBlock(_ref) {
|
|
|
85678
85806
|
};
|
|
85679
85807
|
|
|
85680
85808
|
CodeBlock.propTypes = {
|
|
85681
|
-
title: propTypes.exports.
|
|
85809
|
+
title: propTypes.exports.object,
|
|
85682
85810
|
codeString: propTypes.exports.string,
|
|
85683
85811
|
showCopyButton: propTypes.exports.bool,
|
|
85684
85812
|
className: propTypes.exports.string,
|
|
@@ -85691,6 +85819,8 @@ var getWidgetApiKeyUrl = function getWidgetApiKeyUrl() {
|
|
|
85691
85819
|
};
|
|
85692
85820
|
var EMBED_CODE_EMAIL_URL = "api/v1/widget/email_snippets";
|
|
85693
85821
|
var WIDGET_KB_BASE_URL = "https://neetowidgethelp.neetokb.com";
|
|
85822
|
+
var NEETO_REPLAY_CONFIGURE_URL = "".concat(WIDGET_KB_BASE_URL, "/articles/configure-neetoreplay");
|
|
85823
|
+
var NEETO_CHAT_USER_IDENTITY_URL = "".concat(WIDGET_KB_BASE_URL, "/articles/configuring-neetochat");
|
|
85694
85824
|
var WIDGET_KB_HELP_URL = {
|
|
85695
85825
|
changelog: "".concat(WIDGET_KB_BASE_URL, "/categories/getting-started-with-neetochangelog"),
|
|
85696
85826
|
chat: "".concat(WIDGET_KB_BASE_URL, "/categories/getting-started-with-neetochat"),
|
|
@@ -85750,16 +85880,6 @@ var embedWidgetEnvironment = function embedWidgetEnvironment() {
|
|
|
85750
85880
|
}
|
|
85751
85881
|
};
|
|
85752
85882
|
|
|
85753
|
-
var getSampleUserIdentity = function getSampleUserIdentity(enabledWidgets) {
|
|
85754
|
-
return indentAndFormat(SAMPLE_USER_IDENTITY_CODE_STRING, function (cmd) {
|
|
85755
|
-
if (!enabledWidgets.chat && !cmd.includes("email") && !cmd.includes("{") && !cmd.includes("}") || !enabledWidgets.chat && !enabledWidgets.replay) {
|
|
85756
|
-
return getCommentedCommand(cmd, false, true);
|
|
85757
|
-
}
|
|
85758
|
-
|
|
85759
|
-
return cmd;
|
|
85760
|
-
});
|
|
85761
|
-
};
|
|
85762
|
-
|
|
85763
85883
|
var embedWidgetApiKey = function embedWidgetApiKey(apiKey) {
|
|
85764
85884
|
return "apiKey: \"".concat(apiKey, "\",");
|
|
85765
85885
|
};
|
|
@@ -85782,17 +85902,28 @@ var embedWidgetFunctionCall = function embedWidgetFunctionCall(enabledWidgets, a
|
|
|
85782
85902
|
}), "\n});");
|
|
85783
85903
|
};
|
|
85784
85904
|
|
|
85905
|
+
var filterMarkedCommands = function filterMarkedCommands(queryString) {
|
|
85906
|
+
return queryString.split("\n").filter(function (line) {
|
|
85907
|
+
return !line.includes("///") && line.trim();
|
|
85908
|
+
}).join("\n");
|
|
85909
|
+
};
|
|
85910
|
+
|
|
85911
|
+
var getSampleUserIdentity = function getSampleUserIdentity(enabledWidgets) {
|
|
85912
|
+
return filterMarkedCommands(SAMPLE_USER_IDENTITY_CODE_STRING.split("\n").map(function (cmd) {
|
|
85913
|
+
if (!enabledWidgets.chat && !cmd.includes("email") && !cmd.includes("{") && !cmd.includes("}") || !enabledWidgets.chat && !enabledWidgets.replay) {
|
|
85914
|
+
return getCommentedCommand(cmd, false, true);
|
|
85915
|
+
}
|
|
85916
|
+
|
|
85917
|
+
return cmd;
|
|
85918
|
+
}).join("\n"));
|
|
85919
|
+
};
|
|
85785
85920
|
var sampleConsolidatedCodeString = function sampleConsolidatedCodeString(enabledWidgets, apiKey) {
|
|
85786
|
-
return "".concat(EMBED_WIDGET_S3_SCRIPT_STRING, "\n<script>\n ").concat(
|
|
85787
|
-
return getCommentedCommand(cmd, enabledWidgets.replay, true);
|
|
85788
|
-
}), "\n\n ").concat(indentAndFormat(embedWidgetFunctionCall(enabledWidgets, apiKey)), "\n</script>");
|
|
85921
|
+
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>"));
|
|
85789
85922
|
};
|
|
85790
|
-
var getEmailWidgetSnippetFormInitialValues = function getEmailWidgetSnippetFormInitialValues(
|
|
85923
|
+
var getEmailWidgetSnippetFormInitialValues = function getEmailWidgetSnippetFormInitialValues(subject) {
|
|
85791
85924
|
return {
|
|
85792
85925
|
emails: "",
|
|
85793
|
-
subject:
|
|
85794
|
-
selectedWidgets: selectedWidgets
|
|
85795
|
-
})
|
|
85926
|
+
subject: subject
|
|
85796
85927
|
};
|
|
85797
85928
|
};
|
|
85798
85929
|
var getSelectedWidgetsCombinedText = function getSelectedWidgetsCombinedText(widgets) {
|
|
@@ -85818,7 +85949,10 @@ var CodeSnippet = function CodeSnippet(_ref) {
|
|
|
85818
85949
|
_ref$onSent = _ref.onSent,
|
|
85819
85950
|
onSent = _ref$onSent === void 0 ? noop$2 : _ref$onSent,
|
|
85820
85951
|
codeString = _ref.codeString,
|
|
85821
|
-
|
|
85952
|
+
_ref$subject = _ref.subject,
|
|
85953
|
+
subject = _ref$subject === void 0 ? "" : _ref$subject,
|
|
85954
|
+
_ref$body = _ref.body,
|
|
85955
|
+
body = _ref$body === void 0 ? "" : _ref$body;
|
|
85822
85956
|
|
|
85823
85957
|
var _useTranslation = reactI18next.useTranslation(),
|
|
85824
85958
|
t = _useTranslation.t;
|
|
@@ -85846,7 +85980,7 @@ var CodeSnippet = function CodeSnippet(_ref) {
|
|
|
85846
85980
|
emailMutation.mutate({
|
|
85847
85981
|
subject: formData.subject,
|
|
85848
85982
|
emails: ramda.pluck("value", formData.emails),
|
|
85849
|
-
message:
|
|
85983
|
+
message: body,
|
|
85850
85984
|
snippet: codeString
|
|
85851
85985
|
});
|
|
85852
85986
|
|
|
@@ -85863,19 +85997,13 @@ var CodeSnippet = function CodeSnippet(_ref) {
|
|
|
85863
85997
|
};
|
|
85864
85998
|
}();
|
|
85865
85999
|
|
|
85866
|
-
var getDefaultBody = function getDefaultBody() {
|
|
85867
|
-
return t("neetoCommons.widget.email.body", {
|
|
85868
|
-
selectedWidgets: getSelectedWidgetsCombinedText(selectedWidgets)
|
|
85869
|
-
});
|
|
85870
|
-
};
|
|
85871
|
-
|
|
85872
86000
|
return /*#__PURE__*/React__default["default"].createElement(neetoui.Modal, {
|
|
85873
86001
|
className: "rounded-lg w-1/2 mx-auto",
|
|
85874
86002
|
isOpen: isModalOpen,
|
|
85875
86003
|
size: "medium",
|
|
85876
86004
|
onClose: onClose
|
|
85877
86005
|
}, /*#__PURE__*/React__default["default"].createElement(formik.Formik, {
|
|
85878
|
-
initialValues: getEmailWidgetSnippetFormInitialValues(
|
|
86006
|
+
initialValues: getEmailWidgetSnippetFormInitialValues(subject),
|
|
85879
86007
|
validationSchema: EMAIL_WIDGET_SNIPPET_FORM_VALIDATION_SCHEMA,
|
|
85880
86008
|
onSubmit: handleSubmit
|
|
85881
86009
|
}, /*#__PURE__*/React__default["default"].createElement(formik.Form, null, /*#__PURE__*/React__default["default"].createElement(neetoui.Modal.Header, null, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
|
|
@@ -85898,7 +86026,7 @@ var CodeSnippet = function CodeSnippet(_ref) {
|
|
|
85898
86026
|
}, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
|
|
85899
86027
|
className: "mb-6",
|
|
85900
86028
|
style: "body1"
|
|
85901
|
-
},
|
|
86029
|
+
}, body), /*#__PURE__*/React__default["default"].createElement(CodeBlock, {
|
|
85902
86030
|
className: "neeto-ui-bg-primary-100 neeto-ui-rounded-xl overflow-hidden",
|
|
85903
86031
|
codeString: codeString,
|
|
85904
86032
|
copyButton: false,
|
|
@@ -85924,7 +86052,8 @@ CodeSnippet.propTypes = {
|
|
|
85924
86052
|
onClose: propTypes.exports.func,
|
|
85925
86053
|
onSent: propTypes.exports.func,
|
|
85926
86054
|
codeString: propTypes.exports.string,
|
|
85927
|
-
|
|
86055
|
+
subject: propTypes.exports.string,
|
|
86056
|
+
body: propTypes.exports.string
|
|
85928
86057
|
};
|
|
85929
86058
|
|
|
85930
86059
|
var useFetchApiKey = function useFetchApiKey() {
|
|
@@ -85965,7 +86094,7 @@ var SelectionTabs = function SelectionTabs(_ref) {
|
|
|
85965
86094
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
85966
86095
|
className: "mb-4 px-2 w-full flex items-center justify-between gap-2"
|
|
85967
86096
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
85968
|
-
className: "flex items-center justify-start gap-
|
|
86097
|
+
className: "flex items-center justify-start gap-1"
|
|
85969
86098
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
85970
86099
|
className: "font-semibold text-base"
|
|
85971
86100
|
}, "neeto", formattedPrimaryWidget), /*#__PURE__*/React__default["default"].createElement("a", {
|
|
@@ -85973,7 +86102,7 @@ var SelectionTabs = function SelectionTabs(_ref) {
|
|
|
85973
86102
|
target: "_blank",
|
|
85974
86103
|
rel: "noreferrer"
|
|
85975
86104
|
}, /*#__PURE__*/React__default["default"].createElement(neetoIcons.Help, {
|
|
85976
|
-
size:
|
|
86105
|
+
size: 16
|
|
85977
86106
|
}))), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
85978
86107
|
className: "flex items-center justify-end gap-2"
|
|
85979
86108
|
}, renderSelectedTab()));
|
|
@@ -85986,8 +86115,6 @@ SelectionTabs.propTypes = {
|
|
|
85986
86115
|
};
|
|
85987
86116
|
|
|
85988
86117
|
var EmbedCode = function EmbedCode(_ref) {
|
|
85989
|
-
var _apiKeyResult$data2;
|
|
85990
|
-
|
|
85991
86118
|
var _ref$primaryApp = _ref.primaryApp,
|
|
85992
86119
|
primaryApp = _ref$primaryApp === void 0 ? "" : _ref$primaryApp,
|
|
85993
86120
|
_ref$initialSelectedW = _ref.initialSelectedWidgets,
|
|
@@ -85999,16 +86126,18 @@ var EmbedCode = function EmbedCode(_ref) {
|
|
|
85999
86126
|
var apiKeyResult = useFetchApiKey();
|
|
86000
86127
|
var initialWidgets = ramda.uniq(ramda.intersection(ramda.append(primaryApp, initialSelectedWidgets), WIDGET_TYPES_VALUES));
|
|
86001
86128
|
|
|
86002
|
-
var _useState = React.useState(
|
|
86129
|
+
var _useState = React.useState(EMAIL_TYPES["null"]),
|
|
86003
86130
|
_useState2 = _slicedToArray(_useState, 2),
|
|
86004
|
-
|
|
86005
|
-
|
|
86131
|
+
emailType = _useState2[0],
|
|
86132
|
+
setEmailType = _useState2[1];
|
|
86006
86133
|
|
|
86007
86134
|
var _useState3 = React.useState(ramda.intersection(initialWidgets, WIDGET_TYPES_VALUES)),
|
|
86008
86135
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
86009
86136
|
selectedWidgets = _useState4[0],
|
|
86010
86137
|
setSelectedWidgets = _useState4[1];
|
|
86011
86138
|
|
|
86139
|
+
var previousEmailType = usePrevious(emailType);
|
|
86140
|
+
|
|
86012
86141
|
var updateSelectedWidgets = function updateSelectedWidgets(widget) {
|
|
86013
86142
|
if (selectedWidgets.includes(widget)) {
|
|
86014
86143
|
setSelectedWidgets(ramda.without([widget], selectedWidgets));
|
|
@@ -86020,25 +86149,64 @@ var EmbedCode = function EmbedCode(_ref) {
|
|
|
86020
86149
|
var enabledWidgets = ramda.fromPairs(selectedWidgets.map(function (widget) {
|
|
86021
86150
|
return [widget, true];
|
|
86022
86151
|
}));
|
|
86023
|
-
|
|
86152
|
+
|
|
86153
|
+
var getEmbedCodeString = function getEmbedCodeString() {
|
|
86024
86154
|
var _apiKeyResult$data;
|
|
86025
86155
|
|
|
86026
86156
|
if ((_apiKeyResult$data = apiKeyResult.data) !== null && _apiKeyResult$data !== void 0 && _apiKeyResult$data.widgetApiKey) {
|
|
86027
|
-
return sampleConsolidatedCodeString(enabledWidgets, apiKeyResult.data.widgetApiKey)
|
|
86028
|
-
return !line.includes("///") && line.trim();
|
|
86029
|
-
}).join("\n");
|
|
86157
|
+
return sampleConsolidatedCodeString(enabledWidgets, apiKeyResult.data.widgetApiKey);
|
|
86030
86158
|
}
|
|
86031
86159
|
|
|
86032
86160
|
return "";
|
|
86033
|
-
}
|
|
86161
|
+
};
|
|
86162
|
+
|
|
86163
|
+
var getSnippetProps = function getSnippetProps(selectedEmailType) {
|
|
86164
|
+
switch (selectedEmailType) {
|
|
86165
|
+
case EMAIL_TYPES.embedCode:
|
|
86166
|
+
return {
|
|
86167
|
+
codeString: getEmbedCodeString(),
|
|
86168
|
+
subject: t("neetoCommons.widget.email.fields.subject.values.embedCode", {
|
|
86169
|
+
selectedWidgets: getSelectedWidgetsCombinedText(selectedWidgets)
|
|
86170
|
+
}),
|
|
86171
|
+
body: t("neetoCommons.widget.email.body.values.embedCode", {
|
|
86172
|
+
selectedWidgets: getSelectedWidgetsCombinedText(selectedWidgets),
|
|
86173
|
+
neetoKbUrl: WIDGET_KB_BASE_URL
|
|
86174
|
+
})
|
|
86175
|
+
};
|
|
86034
86176
|
|
|
86035
|
-
|
|
86177
|
+
case EMAIL_TYPES.userIdentity:
|
|
86178
|
+
return {
|
|
86179
|
+
codeString: getSampleUserIdentity(enabledWidgets),
|
|
86180
|
+
subject: t("neetoCommons.widget.email.fields.subject.values.userIdentity"),
|
|
86181
|
+
body: t("neetoCommons.widget.email.body.values.userIdentity", {
|
|
86182
|
+
userIdentityKbUrl: enabledWidgets.chat ? NEETO_CHAT_USER_IDENTITY_URL : NEETO_REPLAY_CONFIGURE_URL
|
|
86183
|
+
})
|
|
86184
|
+
};
|
|
86185
|
+
|
|
86186
|
+
case EMAIL_TYPES.sessionContext:
|
|
86187
|
+
return {
|
|
86188
|
+
codeString: SAMPLE_CONTEXT_CODE_STRING,
|
|
86189
|
+
subject: t("neetoCommons.widget.email.fields.subject.values.sessionContext"),
|
|
86190
|
+
body: t("neetoCommons.widget.email.body.values.sessionContext", {
|
|
86191
|
+
sessionContextKbUrl: NEETO_REPLAY_CONFIGURE_URL
|
|
86192
|
+
})
|
|
86193
|
+
};
|
|
86194
|
+
|
|
86195
|
+
case EMAIL_TYPES["null"]:
|
|
86196
|
+
return previousEmailType !== EMAIL_TYPES["null"] ? getSnippetProps(previousEmailType) : {};
|
|
86197
|
+
|
|
86198
|
+
default:
|
|
86199
|
+
throw new Error("Invalid email type received.");
|
|
86200
|
+
}
|
|
86201
|
+
};
|
|
86202
|
+
|
|
86203
|
+
var handleSendViaEmail = function handleSendViaEmail(selectedEmail) {
|
|
86036
86204
|
if (ramda.isEmpty(selectedWidgets)) {
|
|
86037
86205
|
neetoui.Toastr.error(t("neetoCommons.widget.installation.snippet.disabledError"));
|
|
86038
86206
|
return;
|
|
86039
86207
|
}
|
|
86040
86208
|
|
|
86041
|
-
|
|
86209
|
+
setEmailType(selectedEmail);
|
|
86042
86210
|
};
|
|
86043
86211
|
|
|
86044
86212
|
if (apiKeyResult.isLoading) {
|
|
@@ -86048,20 +86216,22 @@ var EmbedCode = function EmbedCode(_ref) {
|
|
|
86048
86216
|
}
|
|
86049
86217
|
|
|
86050
86218
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
86051
|
-
className: "mx-auto w-full flex-col items-center justify-start"
|
|
86219
|
+
className: "mx-auto w-full flex-col items-center justify-start mb-10"
|
|
86052
86220
|
}, /*#__PURE__*/React__default["default"].createElement(SelectionTabs, {
|
|
86053
86221
|
primarySelectedWidget: primaryApp,
|
|
86054
86222
|
selectedWidgets: selectedWidgets,
|
|
86055
86223
|
updateSelectedWidgets: updateSelectedWidgets
|
|
86056
86224
|
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
86057
|
-
className: "mx-auto w-full max-w-2xl flex-grow flex-col items-center justify-start"
|
|
86225
|
+
className: "mx-auto w-full max-w-2xl flex-grow flex-col items-center justify-start mb-6"
|
|
86058
86226
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
86059
86227
|
className: "mx-auto mb-4 w-full"
|
|
86060
86228
|
}, /*#__PURE__*/React__default["default"].createElement(CodeBlock, {
|
|
86061
|
-
codeString:
|
|
86229
|
+
codeString: getEmbedCodeString(),
|
|
86062
86230
|
className: "neeto-ui-bg-primary-100 neeto-ui-rounded-xl overflow-hidden",
|
|
86063
|
-
title: "Embed
|
|
86064
|
-
sendViaEmail:
|
|
86231
|
+
title: /*#__PURE__*/React__default["default"].createElement("div", null, "Embed code"),
|
|
86232
|
+
sendViaEmail: function sendViaEmail() {
|
|
86233
|
+
return handleSendViaEmail(EMAIL_TYPES.embedCode);
|
|
86234
|
+
}
|
|
86065
86235
|
})), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
86066
86236
|
className: "w-full"
|
|
86067
86237
|
}, /*#__PURE__*/React__default["default"].createElement(reactI18next.Trans, {
|
|
@@ -86077,14 +86247,56 @@ var EmbedCode = function EmbedCode(_ref) {
|
|
|
86077
86247
|
className: "font-normal"
|
|
86078
86248
|
})
|
|
86079
86249
|
}
|
|
86080
|
-
}, "Place the embed code in your HTML file. This will embed the selected widgets in your website.")), /*#__PURE__*/React__default["default"].createElement(
|
|
86081
|
-
|
|
86082
|
-
|
|
86083
|
-
|
|
86250
|
+
}, "Place the embed code in your HTML file. This will embed the selected widgets in your website."))), enabledWidgets.chat || enabledWidgets.replay ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
86251
|
+
className: "mx-auto w-full max-w-2xl flex-grow flex-col items-center justify-start mb-6"
|
|
86252
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
86253
|
+
className: "mx-auto mb-4 w-full"
|
|
86254
|
+
}, /*#__PURE__*/React__default["default"].createElement(CodeBlock, {
|
|
86255
|
+
codeString: getSampleUserIdentity(enabledWidgets),
|
|
86256
|
+
className: "neeto-ui-bg-primary-100 neeto-ui-rounded-xl overflow-hidden",
|
|
86257
|
+
sendViaEmail: function sendViaEmail() {
|
|
86258
|
+
return handleSendViaEmail(EMAIL_TYPES.userIdentity);
|
|
86259
|
+
},
|
|
86260
|
+
title: /*#__PURE__*/React__default["default"].createElement("div", {
|
|
86261
|
+
className: "flex items-center justify-start"
|
|
86262
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", null, "User identity (Optional)"), /*#__PURE__*/React__default["default"].createElement("a", {
|
|
86263
|
+
href: enabledWidgets.chat ? NEETO_CHAT_USER_IDENTITY_URL : NEETO_REPLAY_CONFIGURE_URL,
|
|
86264
|
+
target: "_blank",
|
|
86265
|
+
rel: "noreferrer",
|
|
86266
|
+
className: "ml-1"
|
|
86267
|
+
}, /*#__PURE__*/React__default["default"].createElement(neetoIcons.Help, {
|
|
86268
|
+
size: 16
|
|
86269
|
+
})))
|
|
86270
|
+
})), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
86271
|
+
className: "w-full"
|
|
86272
|
+
}, t("neetoCommons.widget.installation.instructions.userIdentity"))) : null, enabledWidgets.replay ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
86273
|
+
className: "mx-auto w-full max-w-2xl flex-grow flex-col items-center justify-start"
|
|
86274
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
86275
|
+
className: "mx-auto mb-4 w-full"
|
|
86276
|
+
}, /*#__PURE__*/React__default["default"].createElement(CodeBlock, {
|
|
86277
|
+
codeString: SAMPLE_CONTEXT_CODE_STRING,
|
|
86278
|
+
className: "neeto-ui-bg-primary-100 neeto-ui-rounded-xl overflow-hidden",
|
|
86279
|
+
sendViaEmail: function sendViaEmail() {
|
|
86280
|
+
return handleSendViaEmail(EMAIL_TYPES.sessionContext);
|
|
86281
|
+
},
|
|
86282
|
+
title: /*#__PURE__*/React__default["default"].createElement("div", {
|
|
86283
|
+
className: "flex items-center justify-start"
|
|
86284
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", null, "Session context (Optional)"), /*#__PURE__*/React__default["default"].createElement("a", {
|
|
86285
|
+
href: NEETO_REPLAY_CONFIGURE_URL,
|
|
86286
|
+
target: "_blank",
|
|
86287
|
+
rel: "noreferrer",
|
|
86288
|
+
className: "ml-1"
|
|
86289
|
+
}, /*#__PURE__*/React__default["default"].createElement(neetoIcons.Help, {
|
|
86290
|
+
size: 16
|
|
86291
|
+
})))
|
|
86292
|
+
})), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
86293
|
+
className: "w-full"
|
|
86294
|
+
}, t("neetoCommons.widget.installation.instructions.sessionContext"))) : null, /*#__PURE__*/React__default["default"].createElement(CodeSnippet, _extends$4({
|
|
86295
|
+
isModalOpen: !!emailType && isNotEmpty(selectedWidgets),
|
|
86084
86296
|
onClose: function onClose() {
|
|
86085
|
-
return
|
|
86297
|
+
return setEmailType(EMAIL_TYPES["null"]);
|
|
86086
86298
|
}
|
|
86087
|
-
})));
|
|
86299
|
+
}, getSnippetProps(emailType))));
|
|
86088
86300
|
};
|
|
86089
86301
|
|
|
86090
86302
|
EmbedCode.propTypes = {
|
|
@@ -86268,125 +86480,6 @@ var NeetoWidget = {
|
|
|
86268
86480
|
WIDGET_TYPES: WIDGET_TYPES
|
|
86269
86481
|
};
|
|
86270
86482
|
|
|
86271
|
-
function useDebounce(value) {
|
|
86272
|
-
var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 350;
|
|
86273
|
-
|
|
86274
|
-
var _useState = React.useState(value),
|
|
86275
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
86276
|
-
debouncedValue = _useState2[0],
|
|
86277
|
-
setDebouncedValue = _useState2[1];
|
|
86278
|
-
|
|
86279
|
-
React.useEffect(function () {
|
|
86280
|
-
var handler = setTimeout(function () {
|
|
86281
|
-
setDebouncedValue(value);
|
|
86282
|
-
}, delay);
|
|
86283
|
-
return function () {
|
|
86284
|
-
clearTimeout(handler);
|
|
86285
|
-
};
|
|
86286
|
-
}, [value]);
|
|
86287
|
-
return debouncedValue;
|
|
86288
|
-
}
|
|
86289
|
-
|
|
86290
|
-
var useFuncDebounce = function useFuncDebounce(func) {
|
|
86291
|
-
var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 350;
|
|
86292
|
-
var timer = React.useRef(null);
|
|
86293
|
-
|
|
86294
|
-
var debouncedFunc = function debouncedFunc() {
|
|
86295
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
86296
|
-
args[_key] = arguments[_key];
|
|
86297
|
-
}
|
|
86298
|
-
|
|
86299
|
-
clearTimeout(timer.current);
|
|
86300
|
-
timer.current = setTimeout(function () {
|
|
86301
|
-
return func.apply(void 0, args);
|
|
86302
|
-
}, delay);
|
|
86303
|
-
};
|
|
86304
|
-
|
|
86305
|
-
debouncedFunc.cancel = function () {
|
|
86306
|
-
return clearTimeout(timer.current);
|
|
86307
|
-
};
|
|
86308
|
-
|
|
86309
|
-
return debouncedFunc;
|
|
86310
|
-
};
|
|
86311
|
-
|
|
86312
|
-
var useForceUpdate = function useForceUpdate() {
|
|
86313
|
-
var _useState = React.useState(0),
|
|
86314
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
86315
|
-
setValue = _useState2[1];
|
|
86316
|
-
|
|
86317
|
-
return function () {
|
|
86318
|
-
return setValue(function (value) {
|
|
86319
|
-
return value + 1;
|
|
86320
|
-
});
|
|
86321
|
-
};
|
|
86322
|
-
};
|
|
86323
|
-
|
|
86324
|
-
var useIsElementVisibleInDom = function useIsElementVisibleInDom(target) {
|
|
86325
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
|
|
86326
|
-
|
|
86327
|
-
var _useState = React.useState(false),
|
|
86328
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
86329
|
-
isIntersecting = _useState2[0],
|
|
86330
|
-
setIntersecting = _useState2[1];
|
|
86331
|
-
|
|
86332
|
-
var forceUpdate = useForceUpdate();
|
|
86333
|
-
React.useEffect(function () {
|
|
86334
|
-
if (!target) return forceUpdate();
|
|
86335
|
-
var observer = new IntersectionObserver(function (_ref) {
|
|
86336
|
-
var _ref2 = _slicedToArray(_ref, 1),
|
|
86337
|
-
entry = _ref2[0];
|
|
86338
|
-
|
|
86339
|
-
return setIntersecting(entry.isIntersecting);
|
|
86340
|
-
}, options);
|
|
86341
|
-
observer.observe(target);
|
|
86342
|
-
return function () {
|
|
86343
|
-
return observer.unobserve(target);
|
|
86344
|
-
};
|
|
86345
|
-
}, [target, options]);
|
|
86346
|
-
return isIntersecting;
|
|
86347
|
-
};
|
|
86348
|
-
|
|
86349
|
-
var useOnClickOutside = function useOnClickOutside(ref, handler) {
|
|
86350
|
-
React.useEffect(function () {
|
|
86351
|
-
var listener = function listener(event) {
|
|
86352
|
-
// Do nothing if clicking ref's element or descendent elements
|
|
86353
|
-
if (!ref.current || ref.current.contains(event.target)) {
|
|
86354
|
-
return;
|
|
86355
|
-
}
|
|
86356
|
-
|
|
86357
|
-
handler(event);
|
|
86358
|
-
};
|
|
86359
|
-
|
|
86360
|
-
document.addEventListener("mousedown", listener);
|
|
86361
|
-
document.addEventListener("touchstart", listener);
|
|
86362
|
-
return function () {
|
|
86363
|
-
document.removeEventListener("mousedown", listener);
|
|
86364
|
-
document.removeEventListener("touchstart", listener);
|
|
86365
|
-
};
|
|
86366
|
-
}, [handler]);
|
|
86367
|
-
};
|
|
86368
|
-
|
|
86369
|
-
var usePrevious = function usePrevious(value) {
|
|
86370
|
-
var ref = React.useRef(value);
|
|
86371
|
-
React.useEffect(function () {
|
|
86372
|
-
ref.current = value;
|
|
86373
|
-
}, [value]);
|
|
86374
|
-
return ref.current;
|
|
86375
|
-
};
|
|
86376
|
-
|
|
86377
|
-
var useUpdateEffect = function useUpdateEffect(callback) {
|
|
86378
|
-
var dependencies = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
86379
|
-
var isInitialMount = React.useRef(true);
|
|
86380
|
-
React.useEffect(function () {
|
|
86381
|
-
if (isInitialMount.current) {
|
|
86382
|
-
isInitialMount.current = false;
|
|
86383
|
-
return;
|
|
86384
|
-
}
|
|
86385
|
-
|
|
86386
|
-
callback();
|
|
86387
|
-
}, dependencies);
|
|
86388
|
-
};
|
|
86389
|
-
|
|
86390
86483
|
var ReducerBasedProvider = function ReducerBasedProvider(initialValue, StateContext, DispatchContext, reducer) {
|
|
86391
86484
|
return function Provider(_ref) {
|
|
86392
86485
|
var children = _ref.children;
|