@bigbinary/neeto-assist-frontend 1.3.0 → 1.4.0-beta1
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 +22 -20
- package/app/javascript/src/translations/ar.json +40 -7
- package/app/javascript/src/translations/bg.json +40 -7
- package/app/javascript/src/translations/ca.json +40 -7
- package/app/javascript/src/translations/cs.json +40 -7
- package/app/javascript/src/translations/da.json +40 -7
- package/app/javascript/src/translations/de.json +40 -7
- package/app/javascript/src/translations/en.json +3 -8
- package/app/javascript/src/translations/es-MX.json +40 -7
- package/app/javascript/src/translations/es.json +40 -7
- package/app/javascript/src/translations/et.json +40 -7
- package/app/javascript/src/translations/fi.json +40 -7
- package/app/javascript/src/translations/fil.json +40 -7
- package/app/javascript/src/translations/fr.json +40 -7
- package/app/javascript/src/translations/he.json +40 -7
- package/app/javascript/src/translations/hi.json +40 -7
- package/app/javascript/src/translations/hr.json +40 -7
- package/app/javascript/src/translations/hu.json +40 -7
- package/app/javascript/src/translations/id.json +40 -7
- package/app/javascript/src/translations/it.json +40 -7
- package/app/javascript/src/translations/ja.json +40 -7
- package/app/javascript/src/translations/ko.json +40 -7
- package/app/javascript/src/translations/lv.json +40 -4
- package/app/javascript/src/translations/nl.json +40 -7
- package/app/javascript/src/translations/pl.json +40 -7
- package/app/javascript/src/translations/pt-BR.json +40 -7
- package/app/javascript/src/translations/pt.json +40 -7
- package/app/javascript/src/translations/ro.json +40 -7
- package/app/javascript/src/translations/ru.json +40 -7
- package/app/javascript/src/translations/sk.json +40 -7
- package/app/javascript/src/translations/sl.json +40 -7
- package/app/javascript/src/translations/sv.json +40 -7
- package/app/javascript/src/translations/th.json +40 -7
- package/app/javascript/src/translations/tr.json +40 -7
- package/app/javascript/src/translations/uk.json +40 -7
- package/app/javascript/src/translations/vi.json +40 -7
- package/app/javascript/src/translations/zh-CN.json +40 -7
- package/app/javascript/src/translations/zh-TW.json +40 -7
- package/dist/.ready +1 -1
- package/dist/NeetoAssistPane.js +158 -171
- package/dist/NeetoAssistPane.js.map +1 -1
- package/dist/cjs/NeetoAssistPane.js +156 -169
- package/dist/cjs/NeetoAssistPane.js.map +1 -1
- package/package.json +1 -1
- package/types.d.ts +9 -9
|
@@ -17,13 +17,13 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
17
17
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
18
18
|
var classnames = require('classnames');
|
|
19
19
|
var lucideReact = require('lucide-react');
|
|
20
|
+
var _toArray = require('@babel/runtime/helpers/toArray');
|
|
20
21
|
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
21
|
-
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
22
22
|
var utils = require('@bigbinary/neeto-commons-frontend/v2/utils');
|
|
23
|
+
require('@babel/runtime/helpers/objectWithoutProperties');
|
|
23
24
|
require('axios');
|
|
24
25
|
require('zustand');
|
|
25
26
|
require('@babel/runtime/helpers/typeof');
|
|
26
|
-
require('@babel/runtime/helpers/toArray');
|
|
27
27
|
|
|
28
28
|
// The first questions the engine offers for an empty thread. Only sentences
|
|
29
29
|
// are kept, each once, so a button never shows anything else.
|
|
@@ -377,8 +377,8 @@ var CommandMenu = function CommandMenu(_ref) {
|
|
|
377
377
|
});
|
|
378
378
|
};
|
|
379
379
|
|
|
380
|
-
function ownKeys$
|
|
381
|
-
function _objectSpread$
|
|
380
|
+
function ownKeys$4(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; }
|
|
381
|
+
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
382
382
|
var MessageInput = function MessageInput(_ref) {
|
|
383
383
|
var _menu$at$name, _menu$at;
|
|
384
384
|
var _ref$commands = _ref.commands,
|
|
@@ -492,7 +492,7 @@ var MessageInput = function MessageInput(_ref) {
|
|
|
492
492
|
requestId: newRequestId()
|
|
493
493
|
};
|
|
494
494
|
}
|
|
495
|
-
ask(_objectSpread$
|
|
495
|
+
ask(_objectSpread$4(_objectSpread$4({}, where), requestRef.current), {
|
|
496
496
|
onSuccess: function onSuccess() {
|
|
497
497
|
requestRef.current = null;
|
|
498
498
|
setQuestion("");
|
|
@@ -511,7 +511,7 @@ var MessageInput = function MessageInput(_ref) {
|
|
|
511
511
|
if (stopRequestRef.current === runId) return;
|
|
512
512
|
stopRequestRef.current = runId;
|
|
513
513
|
setStoppingRunId(runId);
|
|
514
|
-
stop(_objectSpread$
|
|
514
|
+
stop(_objectSpread$4(_objectSpread$4({}, where), {}, {
|
|
515
515
|
runId: runId
|
|
516
516
|
}), {
|
|
517
517
|
onError: function onError() {
|
|
@@ -645,6 +645,11 @@ var MessageInput = function MessageInput(_ref) {
|
|
|
645
645
|
// that reads it.
|
|
646
646
|
var ENGLISH = "en";
|
|
647
647
|
|
|
648
|
+
// The tabs of a suggested reply: the reading the customer is sent, and the
|
|
649
|
+
// English one.
|
|
650
|
+
var CUSTOMER_TAB = "customer";
|
|
651
|
+
var ENGLISH_TAB = "english";
|
|
652
|
+
|
|
648
653
|
// The languages that are written from right to left, by the first part of
|
|
649
654
|
// their tags: Arabic, Hebrew, Persian, Urdu, Pashto, Sindhi, Uyghur, Yiddish,
|
|
650
655
|
// Dhivehi and Sorani.
|
|
@@ -659,12 +664,6 @@ var RIGHT_TO_LEFT_LANGUAGES = ["ar", "he", "fa", "ur", "ps", "sd", "ug", "yi", "
|
|
|
659
664
|
// every letter of every script.
|
|
660
665
|
var RIGHT_TO_LEFT_LETTER_PATTERN = /[\u05D0-\u05EA\u05EF-\u05F2\u0620-\u063F\u0641-\u064A\u066E-\u066F\u0671-\u06D3\u06D5\u06E5-\u06E6\u06EE-\u06EF\u06FA-\u06FC\u06FF\u0750-\u07A5\u07B1\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40-\uFB41\uFB43-\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC]/;
|
|
661
666
|
|
|
662
|
-
// For a team that reads English, NeetoAssist can send a suggested reply, and
|
|
663
|
-
// what the customer wrote, in English beside another language. A reading is
|
|
664
|
-
// one of the two: its text, the tag of the language it is in, and the
|
|
665
|
-
// direction that language is written in. A run from an older NeetoAssist, or
|
|
666
|
-
// from a workspace that has not switched this on, carries neither, and the
|
|
667
|
-
// pane shows it as it always did.
|
|
668
667
|
var hasText = function hasText(value) {
|
|
669
668
|
return typeof value === "string" && value.trim() !== "";
|
|
670
669
|
};
|
|
@@ -674,10 +673,9 @@ var languageOf = function languageOf(code) {
|
|
|
674
673
|
return code.split("-")[0].toLowerCase();
|
|
675
674
|
};
|
|
676
675
|
|
|
677
|
-
//
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
return hasText(code) && hasText(other) && languageOf(code) === languageOf(other);
|
|
676
|
+
// A tag of English, with or without a region: "en", "en-GB".
|
|
677
|
+
var isEnglish = function isEnglish(code) {
|
|
678
|
+
return hasText(code) && languageOf(code) === ENGLISH;
|
|
681
679
|
};
|
|
682
680
|
|
|
683
681
|
// The direction a reading in another language is set in: from the right when
|
|
@@ -701,16 +699,6 @@ var inEnglish = function inEnglish(text) {
|
|
|
701
699
|
text: text
|
|
702
700
|
};
|
|
703
701
|
};
|
|
704
|
-
var customerWritesIn = function customerWritesIn(t, name) {
|
|
705
|
-
return name ? t("neetoAssist.languages.customerWritesIn", {
|
|
706
|
-
language: name
|
|
707
|
-
}) : t("neetoAssist.languages.customerWritesInAnotherLanguage");
|
|
708
|
-
};
|
|
709
|
-
var replyIsIn = function replyIsIn(t, name) {
|
|
710
|
-
return name ? t("neetoAssist.languages.replyIsIn", {
|
|
711
|
-
language: name
|
|
712
|
-
}) : t("neetoAssist.languages.replyIsInAnotherLanguage");
|
|
713
|
-
};
|
|
714
702
|
|
|
715
703
|
// "Show in English", with English named by the browser like any other
|
|
716
704
|
// language, or as the translation file has it when the browser names nothing.
|
|
@@ -720,19 +708,39 @@ var showInEnglish = function showInEnglish(t, english) {
|
|
|
720
708
|
}) : t("neetoAssist.languages.showInEnglish");
|
|
721
709
|
};
|
|
722
710
|
|
|
723
|
-
//
|
|
724
|
-
//
|
|
725
|
-
//
|
|
726
|
-
// a
|
|
727
|
-
//
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
711
|
+
// A language's name on a tab of its own, which starts with a capital also in a
|
|
712
|
+
// language that writes such names without one: "Español" for "español". The
|
|
713
|
+
// capital is the one the pane's language writes, as the dotted "İ" of
|
|
714
|
+
// Turkish. There is a name only where the browser took the pane's language
|
|
715
|
+
// for a tag, so it takes it here too.
|
|
716
|
+
var tabName = function tabName(code, locale) {
|
|
717
|
+
var name = languageName(code, locale);
|
|
718
|
+
if (!name) return null;
|
|
719
|
+
var _name = _toArray(name),
|
|
720
|
+
first = _name[0],
|
|
721
|
+
rest = _name.slice(1);
|
|
722
|
+
return first.toLocaleUpperCase(locale) + rest.join("");
|
|
723
|
+
};
|
|
724
|
+
|
|
725
|
+
// The readings of a suggested reply, as its tabs show them. A reply is in two
|
|
726
|
+
// languages when the run has the language the customer is sent it in and the
|
|
727
|
+
// reply both ways, each a text with something in it: the English reading, and
|
|
728
|
+
// the one the customer is sent. A reply in English that has no other reading,
|
|
729
|
+
// for a customer who writes English or too little to tell by, has the English
|
|
730
|
+
// reading alone, which is the reply as written. The run says so by naming
|
|
731
|
+
// English as the reply's language. One reading of a reply in another language
|
|
732
|
+
// is none.
|
|
731
733
|
var replyReadings = function replyReadings(_ref) {
|
|
732
|
-
var
|
|
734
|
+
var suggestedReply = _ref.suggestedReply,
|
|
733
735
|
suggestedReplyInCustomerLanguage = _ref.suggestedReplyInCustomerLanguage,
|
|
734
736
|
suggestedReplyInEnglish = _ref.suggestedReplyInEnglish,
|
|
735
737
|
suggestedReplyLanguage = _ref.suggestedReplyLanguage;
|
|
738
|
+
if (isEnglish(suggestedReplyLanguage)) {
|
|
739
|
+
return hasText(suggestedReply) ? {
|
|
740
|
+
english: inEnglish(suggestedReply),
|
|
741
|
+
customer: null
|
|
742
|
+
} : null;
|
|
743
|
+
}
|
|
736
744
|
var isInTwoLanguages = [suggestedReplyLanguage, suggestedReplyInCustomerLanguage, suggestedReplyInEnglish].every(hasText);
|
|
737
745
|
if (!isInTwoLanguages) return null;
|
|
738
746
|
return {
|
|
@@ -741,8 +749,7 @@ var replyReadings = function replyReadings(_ref) {
|
|
|
741
749
|
dir: directionOf(suggestedReplyLanguage, suggestedReplyInCustomerLanguage),
|
|
742
750
|
lang: suggestedReplyLanguage,
|
|
743
751
|
text: suggestedReplyInCustomerLanguage
|
|
744
|
-
}
|
|
745
|
-
customerLanguage: hasText(customerLanguage) ? customerLanguage : null
|
|
752
|
+
}
|
|
746
753
|
};
|
|
747
754
|
};
|
|
748
755
|
|
|
@@ -781,36 +788,27 @@ var languageName = function languageName(code, locale) {
|
|
|
781
788
|
}
|
|
782
789
|
};
|
|
783
790
|
|
|
784
|
-
//
|
|
785
|
-
// the
|
|
786
|
-
//
|
|
787
|
-
//
|
|
788
|
-
//
|
|
789
|
-
//
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
// Every sentence has a form without a name, for a language the browser has no
|
|
793
|
-
// name for. The names come from the browser and not from a customer, so they
|
|
794
|
-
// are safe to hand to the translator.
|
|
795
|
-
var replyWords = function replyWords(t, locale, _ref3) {
|
|
796
|
-
var _languageName;
|
|
791
|
+
// The tabs of a suggested reply, in the order the card shows them: the reading
|
|
792
|
+
// the customer is sent first, then the English one. A reply in English that
|
|
793
|
+
// has no other reading has its English tab alone. A tab is named by its
|
|
794
|
+
// language, in the language the pane is in, and by the translation file where
|
|
795
|
+
// the browser has no name for it, so the pane never shows a tag to a person.
|
|
796
|
+
// The names come from the browser and not from a customer.
|
|
797
|
+
var replyTabs = function replyTabs(t, locale, _ref3) {
|
|
798
|
+
var _tabName, _tabName2;
|
|
797
799
|
var customer = _ref3.customer,
|
|
798
|
-
|
|
799
|
-
var
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
showCustomer: theirs ? t("neetoAssist.languages.showIn", {
|
|
804
|
-
language: theirs
|
|
805
|
-
}) : t("neetoAssist.languages.showInTheirLanguage"),
|
|
806
|
-
showEnglish: showInEnglish(t, english),
|
|
807
|
-
useCustomer: theirs ? t("neetoAssist.languages.useIn", {
|
|
808
|
-
language: theirs
|
|
809
|
-
}) : t("neetoAssist.languages.useInTheirLanguage"),
|
|
810
|
-
useEnglish: english ? t("neetoAssist.languages.useIn", {
|
|
811
|
-
language: english
|
|
812
|
-
}) : t("neetoAssist.languages.useInEnglish")
|
|
800
|
+
english = _ref3.english;
|
|
801
|
+
var englishTab = {
|
|
802
|
+
value: ENGLISH_TAB,
|
|
803
|
+
label: (_tabName = tabName(ENGLISH, locale)) !== null && _tabName !== void 0 ? _tabName : t("neetoAssist.languages.english"),
|
|
804
|
+
reading: english
|
|
813
805
|
};
|
|
806
|
+
if (!customer) return [englishTab];
|
|
807
|
+
return [{
|
|
808
|
+
value: CUSTOMER_TAB,
|
|
809
|
+
label: (_tabName2 = tabName(customer.lang, locale)) !== null && _tabName2 !== void 0 ? _tabName2 : t("neetoAssist.languages.customerLanguage"),
|
|
810
|
+
reading: customer
|
|
811
|
+
}, englishTab];
|
|
814
812
|
};
|
|
815
813
|
|
|
816
814
|
// What "Customer wrote" says under the customer's words: that they were
|
|
@@ -830,8 +828,8 @@ var questionWords = function questionWords(t, locale, customerLanguage) {
|
|
|
830
828
|
};
|
|
831
829
|
};
|
|
832
830
|
|
|
833
|
-
function ownKeys$
|
|
834
|
-
function _objectSpread$
|
|
831
|
+
function ownKeys$3(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; }
|
|
832
|
+
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
835
833
|
var isSettled = function isSettled(_ref) {
|
|
836
834
|
var status = _ref.status;
|
|
837
835
|
return neeto_assist.SETTLED_ACTION_STATUSES.includes(status);
|
|
@@ -853,7 +851,7 @@ var answeredAction = function answeredAction(_ref2) {
|
|
|
853
851
|
if (status === 409) return body === null || body === void 0 ? void 0 : body.action;
|
|
854
852
|
if (status === 422 && isApply) {
|
|
855
853
|
var _body$message, _body$action;
|
|
856
|
-
return _objectSpread$
|
|
854
|
+
return _objectSpread$3(_objectSpread$3({}, body === null || body === void 0 ? void 0 : body.action), {}, {
|
|
857
855
|
status: "failed",
|
|
858
856
|
error: (_body$message = body === null || body === void 0 ? void 0 : body.message) !== null && _body$message !== void 0 ? _body$message : body === null || body === void 0 || (_body$action = body.action) === null || _body$action === void 0 ? void 0 : _body$action.error
|
|
859
857
|
});
|
|
@@ -868,7 +866,7 @@ var answeredAction = function answeredAction(_ref2) {
|
|
|
868
866
|
var shownAction = function shownAction(action, answer) {
|
|
869
867
|
if (!answer || isSettled(action)) return action;
|
|
870
868
|
var answered = answeredAction(answer);
|
|
871
|
-
return answered && isSettled(answered) ? _objectSpread$
|
|
869
|
+
return answered && isSettled(answered) ? _objectSpread$3(_objectSpread$3({}, action), answered) : action;
|
|
872
870
|
};
|
|
873
871
|
|
|
874
872
|
// The long text an action will save or send, while it is suggested or being
|
|
@@ -945,8 +943,8 @@ var MAX_TABLE_CELLS = MAX_TABLE_COLUMNS * (MAX_TABLE_ROWS + 1);
|
|
|
945
943
|
var ESCAPED_PIPE_PATTERN = /\\\|/g;
|
|
946
944
|
var UNSAFE_HTML_CHARACTERS = /[&<>"']/g;
|
|
947
945
|
|
|
948
|
-
function ownKeys$
|
|
949
|
-
function _objectSpread$
|
|
946
|
+
function ownKeys$2(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; }
|
|
947
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
950
948
|
var escapeHtmlCharacter = function escapeHtmlCharacter(character) {
|
|
951
949
|
switch (character) {
|
|
952
950
|
case "&":
|
|
@@ -1243,7 +1241,7 @@ var parseLightMarkdown = function parseLightMarkdown() {
|
|
|
1243
1241
|
} else if (listItem) {
|
|
1244
1242
|
var _openBlock;
|
|
1245
1243
|
if (((_openBlock = openBlock) === null || _openBlock === void 0 ? void 0 : _openBlock.type) !== listItem.type) {
|
|
1246
|
-
startBlock(_objectSpread$
|
|
1244
|
+
startBlock(_objectSpread$2({
|
|
1247
1245
|
type: listItem.type,
|
|
1248
1246
|
items: []
|
|
1249
1247
|
}, listItem.number === undefined ? {} : {
|
|
@@ -1740,8 +1738,8 @@ var Outcome = function Outcome(_ref) {
|
|
|
1740
1738
|
return null;
|
|
1741
1739
|
};
|
|
1742
1740
|
|
|
1743
|
-
function ownKeys$
|
|
1744
|
-
function _objectSpread$
|
|
1741
|
+
function ownKeys$1(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; }
|
|
1742
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1745
1743
|
var Card$1 = function Card(_ref) {
|
|
1746
1744
|
var action = _ref.action,
|
|
1747
1745
|
conversationId = _ref.conversationId,
|
|
@@ -1757,7 +1755,7 @@ var Card$1 = function Card(_ref) {
|
|
|
1757
1755
|
// The host is told through the hook, which still hears the answer to a
|
|
1758
1756
|
// click when this card is gone by then.
|
|
1759
1757
|
var _useApplyAction = useRunsApi.useApplyAction(conversationId, function (applied) {
|
|
1760
|
-
return onActionApplied === null || onActionApplied === void 0 ? void 0 : onActionApplied(_objectSpread$
|
|
1758
|
+
return onActionApplied === null || onActionApplied === void 0 ? void 0 : onActionApplied(_objectSpread$1(_objectSpread$1({}, action), applied));
|
|
1761
1759
|
}),
|
|
1762
1760
|
apply = _useApplyAction.mutate,
|
|
1763
1761
|
isApplying = _useApplyAction.isPending;
|
|
@@ -1923,34 +1921,36 @@ var Sources = function Sources(_ref) {
|
|
|
1923
1921
|
});
|
|
1924
1922
|
};
|
|
1925
1923
|
|
|
1926
|
-
var _excluded = ["onUseReply", "reading"];
|
|
1927
|
-
function ownKeys$1(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; }
|
|
1928
|
-
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1929
1924
|
var handOver = function handOver(onUseReply, text) {
|
|
1930
1925
|
return onUseReply(replyText(text), lightMarkdownToHtml(text));
|
|
1931
1926
|
};
|
|
1927
|
+
var Heading = function Heading(_ref) {
|
|
1928
|
+
var t = _ref.t;
|
|
1929
|
+
return /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
|
|
1930
|
+
color: "muted",
|
|
1931
|
+
variant: "body3",
|
|
1932
|
+
weight: "medium",
|
|
1933
|
+
children: t("neetoAssist.run.suggestedReply")
|
|
1934
|
+
});
|
|
1935
|
+
};
|
|
1932
1936
|
|
|
1933
|
-
// The frame and the heading
|
|
1934
|
-
|
|
1935
|
-
var
|
|
1936
|
-
|
|
1937
|
-
t = _ref.t;
|
|
1937
|
+
// The frame and the heading of a reply as written.
|
|
1938
|
+
var Card = function Card(_ref2) {
|
|
1939
|
+
var children = _ref2.children,
|
|
1940
|
+
t = _ref2.t;
|
|
1938
1941
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1939
1942
|
className: "border-border space-y-2 rounded-lg border p-3",
|
|
1940
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(
|
|
1941
|
-
|
|
1942
|
-
variant: "body3",
|
|
1943
|
-
weight: "medium",
|
|
1944
|
-
children: t("neetoAssist.run.suggestedReply")
|
|
1943
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Heading, {
|
|
1944
|
+
t: t
|
|
1945
1945
|
}), children]
|
|
1946
1946
|
});
|
|
1947
1947
|
};
|
|
1948
1948
|
|
|
1949
1949
|
// Copies the reply that is showing, as NeetoAssist wrote it, and says so in a
|
|
1950
1950
|
// toast.
|
|
1951
|
-
var CopyButton = function CopyButton(
|
|
1952
|
-
var t =
|
|
1953
|
-
text =
|
|
1951
|
+
var CopyButton = function CopyButton(_ref3) {
|
|
1952
|
+
var t = _ref3.t,
|
|
1953
|
+
text = _ref3.text;
|
|
1954
1954
|
return /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
|
|
1955
1955
|
"data-testid": "neeto-assist-copy-reply-button",
|
|
1956
1956
|
icon: lucideReact.Copy,
|
|
@@ -1965,106 +1965,93 @@ var CopyButton = function CopyButton(_ref2) {
|
|
|
1965
1965
|
});
|
|
1966
1966
|
};
|
|
1967
1967
|
|
|
1968
|
-
//
|
|
1969
|
-
//
|
|
1970
|
-
//
|
|
1971
|
-
// the
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
reading = _ref3.reading,
|
|
1975
|
-
buttonProps = _objectWithoutProperties(_ref3, _excluded);
|
|
1976
|
-
return /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, _objectSpread$1(_objectSpread$1({}, buttonProps), {}, {
|
|
1977
|
-
className: "h-auto min-h-7 max-w-full py-1 whitespace-normal",
|
|
1978
|
-
icon: lucideReact.CornerDownLeft,
|
|
1979
|
-
size: "sm",
|
|
1980
|
-
onClick: function onClick() {
|
|
1981
|
-
return handOver(onUseReply, reading.text);
|
|
1982
|
-
}
|
|
1983
|
-
}));
|
|
1984
|
-
};
|
|
1985
|
-
|
|
1986
|
-
// A reply that came in English and in the language the customer is sent it
|
|
1987
|
-
// in, for a rep who reads English. The card shows the English reading. The
|
|
1988
|
-
// link under it turns the card to what the customer will read, and back, and
|
|
1989
|
-
// the rep picks which of the two goes to the composer. Copy copies the one
|
|
1990
|
-
// that is showing. The card remembers its turn only while it is on screen.
|
|
1968
|
+
// A reply in the language the customer is sent it in and in English, for a
|
|
1969
|
+
// rep who reads English. Beside the heading is a tab for each, named by its
|
|
1970
|
+
// language: the customer's first, and showing to begin with, then English.
|
|
1971
|
+
// Use reply and Copy take the reading of the tab that is showing. A reply in
|
|
1972
|
+
// English that has no other reading has its English tab alone. The card
|
|
1973
|
+
// remembers its tab only while it is on screen.
|
|
1991
1974
|
// The block that holds a reading names its language, so a screen reader picks
|
|
1992
|
-
// the right voice
|
|
1993
|
-
//
|
|
1994
|
-
//
|
|
1995
|
-
//
|
|
1975
|
+
// the right voice. Its direction comes from that language too, so an Arabic
|
|
1976
|
+
// reading that opens with the name of a product still reads right to left.
|
|
1977
|
+
// A language's name can be long in a narrow pane ("Brazilian Portuguese"), so
|
|
1978
|
+
// the tabs go under the heading when the two do not fit side by side, and a
|
|
1979
|
+
// name that is still too long is cut short.
|
|
1996
1980
|
var Readings = function Readings(_ref4) {
|
|
1981
|
+
var _findBy;
|
|
1997
1982
|
var onUseReply = _ref4.onUseReply,
|
|
1998
1983
|
readings = _ref4.readings;
|
|
1999
1984
|
var _useTranslation = reactI18next.useTranslation(),
|
|
2000
1985
|
t = _useTranslation.t,
|
|
2001
1986
|
i18n = _useTranslation.i18n;
|
|
2002
|
-
var _useState = react.useState(
|
|
1987
|
+
var _useState = react.useState(null),
|
|
2003
1988
|
_useState2 = _slicedToArray(_useState, 2),
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
var
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
return /*#__PURE__*/jsxRuntime.jsxs(
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
1989
|
+
chosen = _useState2[0],
|
|
1990
|
+
setChosen = _useState2[1];
|
|
1991
|
+
var tabs = replyTabs(t, i18n.resolvedLanguage, readings);
|
|
1992
|
+
var shown = (_findBy = neetoCist.findBy({
|
|
1993
|
+
value: chosen
|
|
1994
|
+
}, tabs)) !== null && _findBy !== void 0 ? _findBy : tabs[0];
|
|
1995
|
+
return /*#__PURE__*/jsxRuntime.jsxs(neetoAtoms.Tabs, {
|
|
1996
|
+
className: "border-border flex flex-col gap-2 rounded-lg border p-3",
|
|
1997
|
+
"data-testid": "neeto-assist-reply-tabs",
|
|
1998
|
+
value: shown.value,
|
|
1999
|
+
onValueChange: setChosen,
|
|
2000
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
2001
|
+
className: "flex flex-wrap items-center justify-between gap-2",
|
|
2002
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Heading, {
|
|
2003
|
+
t: t
|
|
2004
|
+
}), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Tabs.List, {
|
|
2005
|
+
"aria-label": t("neetoAssist.languages.replyLanguage"),
|
|
2006
|
+
className: "max-w-full",
|
|
2007
|
+
children: tabs.map(function (_ref5) {
|
|
2008
|
+
var label = _ref5.label,
|
|
2009
|
+
value = _ref5.value;
|
|
2010
|
+
return /*#__PURE__*/react.createElement(neetoAtoms.Tabs.Item, {
|
|
2011
|
+
value: value,
|
|
2012
|
+
className: "min-w-0 flex-initial",
|
|
2013
|
+
"data-testid": "neeto-assist-reply-".concat(value, "-tab"),
|
|
2014
|
+
key: value
|
|
2015
|
+
}, /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
2016
|
+
className: "truncate",
|
|
2017
|
+
children: label
|
|
2018
|
+
}));
|
|
2019
|
+
})
|
|
2020
|
+
})]
|
|
2021
|
+
}), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Tabs.Content, {
|
|
2015
2022
|
"data-testid": "neeto-assist-reply-reading",
|
|
2016
|
-
dir: shown.dir,
|
|
2017
|
-
lang: shown.lang,
|
|
2023
|
+
dir: shown.reading.dir,
|
|
2024
|
+
lang: shown.reading.lang,
|
|
2025
|
+
value: shown.value,
|
|
2018
2026
|
children: /*#__PURE__*/jsxRuntime.jsx(FormattedText, {
|
|
2019
|
-
text: shown.text
|
|
2027
|
+
text: shown.reading.text
|
|
2020
2028
|
})
|
|
2021
2029
|
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
2022
|
-
className: "flex flex-wrap
|
|
2023
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
}), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
|
|
2029
|
-
className: "max-w-full text-start whitespace-normal",
|
|
2030
|
-
"data-testid": "neeto-assist-reply-language-toggle",
|
|
2031
|
-
label: isInCustomerLanguage ? words.showEnglish : words.showCustomer,
|
|
2032
|
-
variant: "link",
|
|
2030
|
+
className: "flex flex-wrap gap-2",
|
|
2031
|
+
children: [onUseReply && /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
|
|
2032
|
+
"data-testid": "neeto-assist-use-reply-button",
|
|
2033
|
+
icon: lucideReact.CornerDownLeft,
|
|
2034
|
+
label: t("neetoAssist.run.useReply"),
|
|
2035
|
+
size: "sm",
|
|
2033
2036
|
onClick: function onClick() {
|
|
2034
|
-
return
|
|
2037
|
+
return handOver(onUseReply, shown.reading.text);
|
|
2035
2038
|
}
|
|
2036
|
-
})]
|
|
2037
|
-
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
2038
|
-
className: "flex flex-wrap gap-2",
|
|
2039
|
-
children: [onUseReply && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
2040
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(UseReading, {
|
|
2041
|
-
onUseReply: onUseReply,
|
|
2042
|
-
"data-testid": "neeto-assist-use-reply-button",
|
|
2043
|
-
label: words.useCustomer,
|
|
2044
|
-
reading: customer
|
|
2045
|
-
}), /*#__PURE__*/jsxRuntime.jsx(UseReading, {
|
|
2046
|
-
onUseReply: onUseReply,
|
|
2047
|
-
"data-testid": "neeto-assist-use-english-reply-button",
|
|
2048
|
-
label: words.useEnglish,
|
|
2049
|
-
reading: english,
|
|
2050
|
-
variant: "outline"
|
|
2051
|
-
})]
|
|
2052
2039
|
}), /*#__PURE__*/jsxRuntime.jsx(CopyButton, {
|
|
2053
2040
|
t: t,
|
|
2054
|
-
text: shown.text
|
|
2041
|
+
text: shown.reading.text
|
|
2055
2042
|
})]
|
|
2056
2043
|
})]
|
|
2057
2044
|
});
|
|
2058
2045
|
};
|
|
2059
2046
|
|
|
2060
2047
|
// A reply as NeetoAssist wrote it, with "Use reply" for a host that has a
|
|
2061
|
-
// composer, and "Copy". A run that
|
|
2062
|
-
//
|
|
2063
|
-
var SuggestedReply = function SuggestedReply(
|
|
2064
|
-
var onUseReply =
|
|
2065
|
-
readings =
|
|
2066
|
-
t =
|
|
2067
|
-
text =
|
|
2048
|
+
// composer, and "Copy". A run that names the language of its reply shows its
|
|
2049
|
+
// readings in tabs instead.
|
|
2050
|
+
var SuggestedReply = function SuggestedReply(_ref6) {
|
|
2051
|
+
var onUseReply = _ref6.onUseReply,
|
|
2052
|
+
readings = _ref6.readings,
|
|
2053
|
+
t = _ref6.t,
|
|
2054
|
+
text = _ref6.text;
|
|
2068
2055
|
return readings ? /*#__PURE__*/jsxRuntime.jsx(Readings, {
|
|
2069
2056
|
onUseReply: onUseReply,
|
|
2070
2057
|
readings: readings
|