funda-ui 4.7.150 → 4.7.152
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/Chatbox/index.d.ts +7 -0
- package/Chatbox/index.js +247 -163
- package/lib/cjs/Chatbox/index.d.ts +7 -0
- package/lib/cjs/Chatbox/index.js +247 -163
- package/lib/esm/Chatbox/index.tsx +96 -11
- package/lib/esm/Textarea/index.tsx +0 -1
- package/package.json +1 -1
package/lib/cjs/Chatbox/index.js
CHANGED
|
@@ -4299,6 +4299,12 @@ var Chatbox = function Chatbox(props) {
|
|
|
4299
4299
|
setEnableStreamMode = _useState18[1];
|
|
4300
4300
|
var animatedMessagesRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(new Set()); // Add a ref to keep track of messages that have already been animated
|
|
4301
4301
|
|
|
4302
|
+
// Keep track of whether the default values have been initialized
|
|
4303
|
+
var _useState19 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)({}),
|
|
4304
|
+
_useState20 = src_slicedToArray(_useState19, 2),
|
|
4305
|
+
initializedDefaults = _useState20[0],
|
|
4306
|
+
setInitializedDefaults = _useState20[1];
|
|
4307
|
+
|
|
4302
4308
|
//
|
|
4303
4309
|
var timer = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
|
|
4304
4310
|
|
|
@@ -4597,10 +4603,10 @@ var Chatbox = function Chatbox(props) {
|
|
|
4597
4603
|
//================================================================
|
|
4598
4604
|
// Custom Questions
|
|
4599
4605
|
//================================================================
|
|
4600
|
-
var
|
|
4601
|
-
|
|
4602
|
-
questions =
|
|
4603
|
-
setQuestions =
|
|
4606
|
+
var _useState21 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(props.defaultQuestions),
|
|
4607
|
+
_useState22 = src_slicedToArray(_useState21, 2),
|
|
4608
|
+
questions = _useState22[0],
|
|
4609
|
+
setQuestions = _useState22[1];
|
|
4604
4610
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
|
|
4605
4611
|
if (props.defaultQuestions) {
|
|
4606
4612
|
setQuestions(props.defaultQuestions);
|
|
@@ -4621,10 +4627,10 @@ var Chatbox = function Chatbox(props) {
|
|
|
4621
4627
|
// Custom buttons
|
|
4622
4628
|
//================================================================
|
|
4623
4629
|
var toolkitBtnsRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
|
|
4624
|
-
var
|
|
4625
|
-
|
|
4626
|
-
activeButtons =
|
|
4627
|
-
setActiveButtons =
|
|
4630
|
+
var _useState23 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)({}),
|
|
4631
|
+
_useState24 = src_slicedToArray(_useState23, 2),
|
|
4632
|
+
activeButtons = _useState24[0],
|
|
4633
|
+
setActiveButtons = _useState24[1];
|
|
4628
4634
|
var closeDropdowns = function closeDropdowns() {
|
|
4629
4635
|
setActiveButtons(function (prev) {
|
|
4630
4636
|
var _args$toolkitButtons;
|
|
@@ -4639,19 +4645,48 @@ var Chatbox = function Chatbox(props) {
|
|
|
4639
4645
|
return newState;
|
|
4640
4646
|
});
|
|
4641
4647
|
};
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4648
|
+
|
|
4649
|
+
// The onClick action specifically used to perform the default options
|
|
4650
|
+
var executeDefaultOptionAction = /*#__PURE__*/function () {
|
|
4651
|
+
var _ref2 = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee2(actionStr, buttonId) {
|
|
4652
|
+
var actionFn;
|
|
4645
4653
|
return src_regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
4646
4654
|
while (1) switch (_context2.prev = _context2.next) {
|
|
4647
4655
|
case 0:
|
|
4648
4656
|
_context2.prev = 0;
|
|
4657
|
+
actionFn = new Function('method', 'isActive', 'button', actionStr); // To perform the action, pass false as the "isActive" parameter, as this is the default option
|
|
4658
|
+
_context2.next = 4;
|
|
4659
|
+
return actionFn(exposedMethods(), false, document.getElementById(buttonId));
|
|
4660
|
+
case 4:
|
|
4661
|
+
_context2.next = 9;
|
|
4662
|
+
break;
|
|
4663
|
+
case 6:
|
|
4664
|
+
_context2.prev = 6;
|
|
4665
|
+
_context2.t0 = _context2["catch"](0);
|
|
4666
|
+
console.error('Error executing default option action:', _context2.t0);
|
|
4667
|
+
case 9:
|
|
4668
|
+
case "end":
|
|
4669
|
+
return _context2.stop();
|
|
4670
|
+
}
|
|
4671
|
+
}, _callee2, null, [[0, 6]]);
|
|
4672
|
+
}));
|
|
4673
|
+
return function executeDefaultOptionAction(_x3, _x4) {
|
|
4674
|
+
return _ref2.apply(this, arguments);
|
|
4675
|
+
};
|
|
4676
|
+
}();
|
|
4677
|
+
var executeButtonAction = /*#__PURE__*/function () {
|
|
4678
|
+
var _ref3 = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee3(actionStr, buttonId, buttonElement) {
|
|
4679
|
+
var actionFn, result, options, newState;
|
|
4680
|
+
return src_regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
4681
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
4682
|
+
case 0:
|
|
4683
|
+
_context3.prev = 0;
|
|
4649
4684
|
actionFn = new Function('method', 'isActive', 'button', actionStr); // !!!REQUIRED "await"
|
|
4650
4685
|
// "customMethods" may be asynchronous
|
|
4651
|
-
|
|
4686
|
+
_context3.next = 4;
|
|
4652
4687
|
return actionFn(exposedMethods(), !activeButtons[buttonId], buttonElement);
|
|
4653
4688
|
case 4:
|
|
4654
|
-
result =
|
|
4689
|
+
result = _context3.sent;
|
|
4655
4690
|
// If the returned result is an array, it is a dynamic option
|
|
4656
4691
|
if (Array.isArray(result) && Object.keys(dynamicOptions).length === 0) {
|
|
4657
4692
|
options = result.map(function (item) {
|
|
@@ -4681,32 +4716,36 @@ var Chatbox = function Chatbox(props) {
|
|
|
4681
4716
|
setActiveButtons(function (prev) {
|
|
4682
4717
|
return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, buttonId, newState));
|
|
4683
4718
|
});
|
|
4684
|
-
return
|
|
4719
|
+
return _context3.abrupt("return", result);
|
|
4685
4720
|
case 11:
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
console.error('Error executing button action:',
|
|
4721
|
+
_context3.prev = 11;
|
|
4722
|
+
_context3.t0 = _context3["catch"](0);
|
|
4723
|
+
console.error('Error executing button action:', _context3.t0);
|
|
4689
4724
|
case 14:
|
|
4690
4725
|
case "end":
|
|
4691
|
-
return
|
|
4726
|
+
return _context3.stop();
|
|
4692
4727
|
}
|
|
4693
|
-
},
|
|
4728
|
+
}, _callee3, null, [[0, 11]]);
|
|
4694
4729
|
}));
|
|
4695
|
-
return function executeButtonAction(
|
|
4696
|
-
return
|
|
4730
|
+
return function executeButtonAction(_x5, _x6, _x7) {
|
|
4731
|
+
return _ref3.apply(this, arguments);
|
|
4697
4732
|
};
|
|
4698
4733
|
}();
|
|
4699
4734
|
|
|
4700
4735
|
// options
|
|
4701
|
-
var
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
// Store dynamic options
|
|
4706
|
-
var _useState25 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)({}),
|
|
4736
|
+
var _useState25 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)({
|
|
4737
|
+
curIndex: -1,
|
|
4738
|
+
curValue: ''
|
|
4739
|
+
}),
|
|
4707
4740
|
_useState26 = src_slicedToArray(_useState25, 2),
|
|
4708
|
-
|
|
4709
|
-
|
|
4741
|
+
selectedOpt = _useState26[0],
|
|
4742
|
+
setSelectedOpt = _useState26[1];
|
|
4743
|
+
|
|
4744
|
+
// Store dynamic options
|
|
4745
|
+
var _useState27 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)({}),
|
|
4746
|
+
_useState28 = src_slicedToArray(_useState27, 2),
|
|
4747
|
+
dynamicOptions = _useState28[0],
|
|
4748
|
+
setDynamicOptions = _useState28[1];
|
|
4710
4749
|
var getButtonOptions = function getButtonOptions(btn, buttonId) {
|
|
4711
4750
|
// If you are using the dynamic option and already have a cache, return the option for caching
|
|
4712
4751
|
//---------
|
|
@@ -4738,6 +4777,7 @@ var Chatbox = function Chatbox(props) {
|
|
|
4738
4777
|
return options;
|
|
4739
4778
|
};
|
|
4740
4779
|
var handleExecuteButtonSelect = function handleExecuteButtonSelect(buttonId, option, index, value) {
|
|
4780
|
+
var isDefaultSelection = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
4741
4781
|
if (option.value === "cancel") {
|
|
4742
4782
|
setSelectedOpt(function (prev) {
|
|
4743
4783
|
var newLabels = _objectSpread({}, prev);
|
|
@@ -4753,10 +4793,14 @@ var Chatbox = function Chatbox(props) {
|
|
|
4753
4793
|
return _objectSpread(_objectSpread({}, prev), {}, (_objectSpread4 = {}, _defineProperty(_objectSpread4, buttonId, option.label), _defineProperty(_objectSpread4, "curIndex", index), _defineProperty(_objectSpread4, "curValue", value), _objectSpread4));
|
|
4754
4794
|
});
|
|
4755
4795
|
}
|
|
4756
|
-
executeButtonAction(option.onClick, buttonId, document.getElementById(buttonId));
|
|
4757
4796
|
|
|
4758
|
-
//
|
|
4759
|
-
|
|
4797
|
+
// The button action is performed and the drop-down menu is closed only when it is not the default selection
|
|
4798
|
+
if (!isDefaultSelection) {
|
|
4799
|
+
executeButtonAction(option.onClick, buttonId, document.getElementById(buttonId));
|
|
4800
|
+
|
|
4801
|
+
// Close the drop-down
|
|
4802
|
+
closeDropdowns();
|
|
4803
|
+
}
|
|
4760
4804
|
};
|
|
4761
4805
|
|
|
4762
4806
|
// click outside
|
|
@@ -4813,25 +4857,25 @@ var Chatbox = function Chatbox(props) {
|
|
|
4813
4857
|
|
|
4814
4858
|
// parse chunk data
|
|
4815
4859
|
var parseChunkData = /*#__PURE__*/function () {
|
|
4816
|
-
var
|
|
4860
|
+
var _ref4 = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee4(chunk, index, complete) {
|
|
4817
4861
|
var lastContent, _args$responseExtract, extractPath, lines, _iterator, _step, line, _content, result, _iterator2, _step2, path, content, parsedContent, latestRes;
|
|
4818
|
-
return src_regeneratorRuntime().wrap(function
|
|
4819
|
-
while (1) switch (
|
|
4862
|
+
return src_regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
4863
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
4820
4864
|
case 0:
|
|
4821
4865
|
// Store the final content and bind it to loading
|
|
4822
4866
|
lastContent = '';
|
|
4823
|
-
|
|
4867
|
+
_context4.prev = 1;
|
|
4824
4868
|
// Extract response using the path
|
|
4825
4869
|
extractPath = (_args$responseExtract = args().responseExtractPath) === null || _args$responseExtract === void 0 ? void 0 : _args$responseExtract.slice(1); // Streaming data is JSON split by rows
|
|
4826
4870
|
lines = chunk.split("\n").filter(function (line) {
|
|
4827
4871
|
return line.trim() !== "";
|
|
4828
4872
|
});
|
|
4829
4873
|
_iterator = _createForOfIteratorHelper(lines);
|
|
4830
|
-
|
|
4874
|
+
_context4.prev = 5;
|
|
4831
4875
|
_iterator.s();
|
|
4832
4876
|
case 7:
|
|
4833
4877
|
if ((_step = _iterator.n()).done) {
|
|
4834
|
-
|
|
4878
|
+
_context4.next = 45;
|
|
4835
4879
|
break;
|
|
4836
4880
|
}
|
|
4837
4881
|
line = _step.value;
|
|
@@ -4842,7 +4886,7 @@ var Chatbox = function Chatbox(props) {
|
|
|
4842
4886
|
|
|
4843
4887
|
// Send the streamed data to the front end
|
|
4844
4888
|
if (!(line.indexOf('[DONE]') < 0)) {
|
|
4845
|
-
|
|
4889
|
+
_context4.next = 40;
|
|
4846
4890
|
break;
|
|
4847
4891
|
}
|
|
4848
4892
|
// STEP 1:
|
|
@@ -4850,14 +4894,14 @@ var Chatbox = function Chatbox(props) {
|
|
|
4850
4894
|
// Create a JSON string
|
|
4851
4895
|
_content = "".concat(line.replace(/^data:\s*/, '')); // Determine whether it is in JSON format
|
|
4852
4896
|
if (isValidJSON(_content)) {
|
|
4853
|
-
|
|
4897
|
+
_context4.next = 16;
|
|
4854
4898
|
break;
|
|
4855
4899
|
}
|
|
4856
4900
|
console.log('--> [ERROR] Wrong JSON format');
|
|
4857
4901
|
|
|
4858
4902
|
//reset SSE
|
|
4859
4903
|
closeSSE();
|
|
4860
|
-
return
|
|
4904
|
+
return _context4.abrupt("break", 45);
|
|
4861
4905
|
case 16:
|
|
4862
4906
|
// STEP 2:
|
|
4863
4907
|
// ------
|
|
@@ -4866,18 +4910,18 @@ var Chatbox = function Chatbox(props) {
|
|
|
4866
4910
|
// for Ollama API (STREAM END)
|
|
4867
4911
|
//*******
|
|
4868
4912
|
if (!(typeof result.done !== 'undefined')) {
|
|
4869
|
-
|
|
4913
|
+
_context4.next = 22;
|
|
4870
4914
|
break;
|
|
4871
4915
|
}
|
|
4872
4916
|
if (!(result.done === true)) {
|
|
4873
|
-
|
|
4917
|
+
_context4.next = 22;
|
|
4874
4918
|
break;
|
|
4875
4919
|
}
|
|
4876
4920
|
console.log('--> [DONE]');
|
|
4877
4921
|
|
|
4878
4922
|
//reset SSE
|
|
4879
4923
|
closeSSE();
|
|
4880
|
-
return
|
|
4924
|
+
return _context4.abrupt("break", 45);
|
|
4881
4925
|
case 22:
|
|
4882
4926
|
//*******
|
|
4883
4927
|
// for OpenAI API
|
|
@@ -4899,10 +4943,10 @@ var Chatbox = function Chatbox(props) {
|
|
|
4899
4943
|
// ------
|
|
4900
4944
|
// 🚀 !! IMPORTANT: Skip the error content
|
|
4901
4945
|
if (!(typeof content === 'undefined')) {
|
|
4902
|
-
|
|
4946
|
+
_context4.next = 26;
|
|
4903
4947
|
break;
|
|
4904
4948
|
}
|
|
4905
|
-
return
|
|
4949
|
+
return _context4.abrupt("continue", 43);
|
|
4906
4950
|
case 26:
|
|
4907
4951
|
// STEP 4:
|
|
4908
4952
|
// ------
|
|
@@ -4929,13 +4973,13 @@ var Chatbox = function Chatbox(props) {
|
|
|
4929
4973
|
// ------
|
|
4930
4974
|
parsedContent = tempLastContent.current; // If a render parser exists, it is used to process the string
|
|
4931
4975
|
if (!(typeof args().renderParser === 'function')) {
|
|
4932
|
-
|
|
4976
|
+
_context4.next = 36;
|
|
4933
4977
|
break;
|
|
4934
4978
|
}
|
|
4935
|
-
|
|
4979
|
+
_context4.next = 35;
|
|
4936
4980
|
return args().renderParser(parsedContent);
|
|
4937
4981
|
case 35:
|
|
4938
|
-
parsedContent =
|
|
4982
|
+
parsedContent = _context4.sent;
|
|
4939
4983
|
case 36:
|
|
4940
4984
|
// STEP 8:
|
|
4941
4985
|
// ------
|
|
@@ -4952,55 +4996,55 @@ var Chatbox = function Chatbox(props) {
|
|
|
4952
4996
|
// ------
|
|
4953
4997
|
// Scroll to the bottom
|
|
4954
4998
|
scrollToBottom();
|
|
4955
|
-
|
|
4999
|
+
_context4.next = 43;
|
|
4956
5000
|
break;
|
|
4957
5001
|
case 40:
|
|
4958
5002
|
console.log('--> [DONE]');
|
|
4959
5003
|
|
|
4960
5004
|
//reset SSE
|
|
4961
5005
|
closeSSE();
|
|
4962
|
-
return
|
|
5006
|
+
return _context4.abrupt("break", 45);
|
|
4963
5007
|
case 43:
|
|
4964
|
-
|
|
5008
|
+
_context4.next = 7;
|
|
4965
5009
|
break;
|
|
4966
5010
|
case 45:
|
|
4967
|
-
|
|
5011
|
+
_context4.next = 50;
|
|
4968
5012
|
break;
|
|
4969
5013
|
case 47:
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
_iterator.e(
|
|
5014
|
+
_context4.prev = 47;
|
|
5015
|
+
_context4.t0 = _context4["catch"](5);
|
|
5016
|
+
_iterator.e(_context4.t0);
|
|
4973
5017
|
case 50:
|
|
4974
|
-
|
|
5018
|
+
_context4.prev = 50;
|
|
4975
5019
|
_iterator.f();
|
|
4976
|
-
return
|
|
5020
|
+
return _context4.finish(50);
|
|
4977
5021
|
case 53:
|
|
4978
|
-
|
|
5022
|
+
_context4.next = 58;
|
|
4979
5023
|
break;
|
|
4980
5024
|
case 55:
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
console.error('--> Error processing chunk:',
|
|
5025
|
+
_context4.prev = 55;
|
|
5026
|
+
_context4.t1 = _context4["catch"](1);
|
|
5027
|
+
console.error('--> Error processing chunk:', _context4.t1);
|
|
4984
5028
|
case 58:
|
|
4985
5029
|
latestRes = complete ? lastContent : tempLastContent.current; // If a render parser exists, it is used to process the string
|
|
4986
5030
|
if (!(typeof args().renderParser === 'function')) {
|
|
4987
|
-
|
|
5031
|
+
_context4.next = 63;
|
|
4988
5032
|
break;
|
|
4989
5033
|
}
|
|
4990
|
-
|
|
5034
|
+
_context4.next = 62;
|
|
4991
5035
|
return args().renderParser(latestRes);
|
|
4992
5036
|
case 62:
|
|
4993
|
-
latestRes =
|
|
5037
|
+
latestRes = _context4.sent;
|
|
4994
5038
|
case 63:
|
|
4995
|
-
return
|
|
5039
|
+
return _context4.abrupt("return", formatLatestDisplayContent(latestRes));
|
|
4996
5040
|
case 64:
|
|
4997
5041
|
case "end":
|
|
4998
|
-
return
|
|
5042
|
+
return _context4.stop();
|
|
4999
5043
|
}
|
|
5000
|
-
},
|
|
5044
|
+
}, _callee4, null, [[1, 55], [5, 47, 50, 53]]);
|
|
5001
5045
|
}));
|
|
5002
|
-
return function parseChunkData(
|
|
5003
|
-
return
|
|
5046
|
+
return function parseChunkData(_x8, _x9, _x10) {
|
|
5047
|
+
return _ref4.apply(this, arguments);
|
|
5004
5048
|
};
|
|
5005
5049
|
}();
|
|
5006
5050
|
|
|
@@ -5008,11 +5052,11 @@ var Chatbox = function Chatbox(props) {
|
|
|
5008
5052
|
var tempLastContent = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)('');
|
|
5009
5053
|
var streamController = src_useStreamController({
|
|
5010
5054
|
onChunk: function () {
|
|
5011
|
-
var _onChunk = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function
|
|
5012
|
-
var _args$onChunk,
|
|
5055
|
+
var _onChunk = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee5(chunk, index) {
|
|
5056
|
+
var _args$onChunk, _args9;
|
|
5013
5057
|
var res;
|
|
5014
|
-
return src_regeneratorRuntime().wrap(function
|
|
5015
|
-
while (1) switch (
|
|
5058
|
+
return src_regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
5059
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
5016
5060
|
case 0:
|
|
5017
5061
|
// start (Execute it only once)
|
|
5018
5062
|
if (index === 0) {
|
|
@@ -5021,50 +5065,50 @@ var Chatbox = function Chatbox(props) {
|
|
|
5021
5065
|
}
|
|
5022
5066
|
|
|
5023
5067
|
//
|
|
5024
|
-
|
|
5068
|
+
_context5.next = 3;
|
|
5025
5069
|
return parseChunkData(chunk, index, false);
|
|
5026
5070
|
case 3:
|
|
5027
|
-
res =
|
|
5071
|
+
res = _context5.sent;
|
|
5028
5072
|
//
|
|
5029
|
-
(_args$onChunk = (
|
|
5073
|
+
(_args$onChunk = (_args9 = args()).onChunk) === null || _args$onChunk === void 0 ? void 0 : _args$onChunk.call(_args9, inputContentRef.current, res, conversationHistory.current);
|
|
5030
5074
|
case 5:
|
|
5031
5075
|
case "end":
|
|
5032
|
-
return
|
|
5076
|
+
return _context5.stop();
|
|
5033
5077
|
}
|
|
5034
|
-
},
|
|
5078
|
+
}, _callee5);
|
|
5035
5079
|
}));
|
|
5036
|
-
function onChunk(
|
|
5080
|
+
function onChunk(_x11, _x12) {
|
|
5037
5081
|
return _onChunk.apply(this, arguments);
|
|
5038
5082
|
}
|
|
5039
5083
|
return onChunk;
|
|
5040
5084
|
}(),
|
|
5041
5085
|
onComplete: function () {
|
|
5042
|
-
var _onComplete = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function
|
|
5043
|
-
var _args$onComplete,
|
|
5086
|
+
var _onComplete = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee6(lastContent) {
|
|
5087
|
+
var _args$onComplete, _args11;
|
|
5044
5088
|
var res;
|
|
5045
|
-
return src_regeneratorRuntime().wrap(function
|
|
5046
|
-
while (1) switch (
|
|
5089
|
+
return src_regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
5090
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
5047
5091
|
case 0:
|
|
5048
5092
|
console.log('--> Stream complete');
|
|
5049
|
-
|
|
5093
|
+
_context6.next = 3;
|
|
5050
5094
|
return parseChunkData(lastContent, 0, true);
|
|
5051
5095
|
case 3:
|
|
5052
|
-
res =
|
|
5096
|
+
res = _context6.sent;
|
|
5053
5097
|
// Display AI reply
|
|
5054
5098
|
displayMessage(args().answerNameRes, res);
|
|
5055
5099
|
|
|
5056
5100
|
//
|
|
5057
|
-
(_args$onComplete = (
|
|
5101
|
+
(_args$onComplete = (_args11 = args()).onComplete) === null || _args$onComplete === void 0 ? void 0 : _args$onComplete.call(_args11, inputContentRef.current, res, conversationHistory.current);
|
|
5058
5102
|
|
|
5059
5103
|
//
|
|
5060
5104
|
closeSSE();
|
|
5061
5105
|
case 7:
|
|
5062
5106
|
case "end":
|
|
5063
|
-
return
|
|
5107
|
+
return _context6.stop();
|
|
5064
5108
|
}
|
|
5065
|
-
},
|
|
5109
|
+
}, _callee6);
|
|
5066
5110
|
}));
|
|
5067
|
-
function onComplete(
|
|
5111
|
+
function onComplete(_x13) {
|
|
5068
5112
|
return _onComplete.apply(this, arguments);
|
|
5069
5113
|
}
|
|
5070
5114
|
return onComplete;
|
|
@@ -5118,34 +5162,34 @@ var Chatbox = function Chatbox(props) {
|
|
|
5118
5162
|
}
|
|
5119
5163
|
};
|
|
5120
5164
|
var sendMessage = /*#__PURE__*/function () {
|
|
5121
|
-
var
|
|
5122
|
-
var messageInput, message, inputMsg, _res, _args$onChunk2,
|
|
5123
|
-
return src_regeneratorRuntime().wrap(function
|
|
5124
|
-
while (1) switch (
|
|
5165
|
+
var _ref5 = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee7() {
|
|
5166
|
+
var messageInput, message, inputMsg, _res, _args$onChunk2, _args13, _args$onComplete2, _args14, reply, replyRes;
|
|
5167
|
+
return src_regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
5168
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
5125
5169
|
case 0:
|
|
5126
5170
|
if (!(rootRef.current === null || msgContainerRef.current === null || msInput.current === null)) {
|
|
5127
|
-
|
|
5171
|
+
_context7.next = 2;
|
|
5128
5172
|
break;
|
|
5129
5173
|
}
|
|
5130
|
-
return
|
|
5174
|
+
return _context7.abrupt("return");
|
|
5131
5175
|
case 2:
|
|
5132
5176
|
messageInput = msInput.current;
|
|
5133
5177
|
message = (0,sanitize.htmlEncode)(messageInput.value); // It fires in real time as the user enters
|
|
5134
5178
|
// Sanitizing input is the process of securing/cleaning/filtering input data.
|
|
5135
5179
|
if (!(typeof args().onInputCallback === 'function')) {
|
|
5136
|
-
|
|
5180
|
+
_context7.next = 8;
|
|
5137
5181
|
break;
|
|
5138
5182
|
}
|
|
5139
|
-
|
|
5183
|
+
_context7.next = 7;
|
|
5140
5184
|
return args().onInputCallback(message);
|
|
5141
5185
|
case 7:
|
|
5142
|
-
message =
|
|
5186
|
+
message = _context7.sent;
|
|
5143
5187
|
case 8:
|
|
5144
5188
|
if (!(message.trim() === '')) {
|
|
5145
|
-
|
|
5189
|
+
_context7.next = 10;
|
|
5146
5190
|
break;
|
|
5147
5191
|
}
|
|
5148
|
-
return
|
|
5192
|
+
return _context7.abrupt("return");
|
|
5149
5193
|
case 10:
|
|
5150
5194
|
// Start the timer
|
|
5151
5195
|
setElapsedTime(0); // Reset elapsed time
|
|
@@ -5158,13 +5202,13 @@ var Chatbox = function Chatbox(props) {
|
|
|
5158
5202
|
// user message
|
|
5159
5203
|
inputMsg = "".concat(message); // If a render parser exists, it is used to process the string
|
|
5160
5204
|
if (!(typeof args().renderParser === 'function')) {
|
|
5161
|
-
|
|
5205
|
+
_context7.next = 17;
|
|
5162
5206
|
break;
|
|
5163
5207
|
}
|
|
5164
|
-
|
|
5208
|
+
_context7.next = 16;
|
|
5165
5209
|
return args().renderParser(inputMsg);
|
|
5166
5210
|
case 16:
|
|
5167
|
-
inputMsg =
|
|
5211
|
+
inputMsg = _context7.sent;
|
|
5168
5212
|
case 17:
|
|
5169
5213
|
displayMessage(args().questionNameRes, inputMsg); // Display user message
|
|
5170
5214
|
|
|
@@ -5176,48 +5220,48 @@ var Chatbox = function Chatbox(props) {
|
|
|
5176
5220
|
|
|
5177
5221
|
// clear
|
|
5178
5222
|
if (inputContentRef.current) inputContentRef.current.clear();
|
|
5179
|
-
|
|
5180
|
-
|
|
5223
|
+
_context7.prev = 21;
|
|
5224
|
+
_context7.next = 24;
|
|
5181
5225
|
return mainRequest(message);
|
|
5182
5226
|
case 24:
|
|
5183
|
-
_res =
|
|
5227
|
+
_res = _context7.sent;
|
|
5184
5228
|
if (_res.useStreamRender) {
|
|
5185
|
-
|
|
5229
|
+
_context7.next = 36;
|
|
5186
5230
|
break;
|
|
5187
5231
|
}
|
|
5188
5232
|
reply = _res.reply;
|
|
5189
5233
|
replyRes = "".concat(reply); // If a render parser exists, it is used to process the string
|
|
5190
5234
|
if (!(typeof args().renderParser === 'function')) {
|
|
5191
|
-
|
|
5235
|
+
_context7.next = 32;
|
|
5192
5236
|
break;
|
|
5193
5237
|
}
|
|
5194
|
-
|
|
5238
|
+
_context7.next = 31;
|
|
5195
5239
|
return args().renderParser(replyRes);
|
|
5196
5240
|
case 31:
|
|
5197
|
-
replyRes =
|
|
5241
|
+
replyRes = _context7.sent;
|
|
5198
5242
|
case 32:
|
|
5199
5243
|
displayMessage(args().answerNameRes, replyRes); // Display AI reply
|
|
5200
5244
|
|
|
5201
5245
|
//
|
|
5202
|
-
(_args$onChunk2 = (
|
|
5203
|
-
(_args$onComplete2 = (
|
|
5246
|
+
(_args$onChunk2 = (_args13 = args()).onChunk) === null || _args$onChunk2 === void 0 ? void 0 : _args$onChunk2.call(_args13, inputContentRef.current, replyRes, conversationHistory.current);
|
|
5247
|
+
(_args$onComplete2 = (_args14 = args()).onComplete) === null || _args$onComplete2 === void 0 ? void 0 : _args$onComplete2.call(_args14, inputContentRef.current, replyRes, conversationHistory.current);
|
|
5204
5248
|
|
|
5205
5249
|
//reset SSE
|
|
5206
5250
|
closeSSE();
|
|
5207
5251
|
case 36:
|
|
5208
|
-
|
|
5252
|
+
_context7.next = 45;
|
|
5209
5253
|
break;
|
|
5210
5254
|
case 38:
|
|
5211
|
-
|
|
5212
|
-
|
|
5255
|
+
_context7.prev = 38;
|
|
5256
|
+
_context7.t0 = _context7["catch"](21);
|
|
5213
5257
|
// loading
|
|
5214
5258
|
setLoading(false);
|
|
5215
5259
|
|
|
5216
5260
|
// Stop the timer
|
|
5217
5261
|
clearInterval(timer.current);
|
|
5218
5262
|
timer.current = null;
|
|
5219
|
-
console.error('--> Error sending message:',
|
|
5220
|
-
displayMessage(args().answerNameRes, "Error: Unable to send message: ".concat(String(
|
|
5263
|
+
console.error('--> Error sending message:', _context7.t0);
|
|
5264
|
+
displayMessage(args().answerNameRes, "Error: Unable to send message: ".concat(String(_context7.t0))); // Display AI reply
|
|
5221
5265
|
case 45:
|
|
5222
5266
|
// clear
|
|
5223
5267
|
messageInput.value = '';
|
|
@@ -5229,12 +5273,12 @@ var Chatbox = function Chatbox(props) {
|
|
|
5229
5273
|
scrollToBottom();
|
|
5230
5274
|
case 48:
|
|
5231
5275
|
case "end":
|
|
5232
|
-
return
|
|
5276
|
+
return _context7.stop();
|
|
5233
5277
|
}
|
|
5234
|
-
},
|
|
5278
|
+
}, _callee7, null, [[21, 38]]);
|
|
5235
5279
|
}));
|
|
5236
5280
|
return function sendMessage() {
|
|
5237
|
-
return
|
|
5281
|
+
return _ref5.apply(this, arguments);
|
|
5238
5282
|
};
|
|
5239
5283
|
}();
|
|
5240
5284
|
var handleClickSafe = useDebounce_default()(function () {
|
|
@@ -5246,25 +5290,25 @@ var Chatbox = function Chatbox(props) {
|
|
|
5246
5290
|
setShow(false);
|
|
5247
5291
|
};
|
|
5248
5292
|
var mainRequest = /*#__PURE__*/function () {
|
|
5249
|
-
var
|
|
5293
|
+
var _ref6 = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee8(msg) {
|
|
5250
5294
|
var currentStreamMode, requestBodyRes, customResponse, content, isStream, contentRes, response, _errInfo, _args$responseExtract2, extractPath, _response, _errInfo2, jsonResponse, result, _iterator3, _step3, path, _content2, _err;
|
|
5251
|
-
return src_regeneratorRuntime().wrap(function
|
|
5252
|
-
while (1) switch (
|
|
5295
|
+
return src_regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
5296
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
5253
5297
|
case 0:
|
|
5254
5298
|
currentStreamMode = args().isStream; // Update stream mode
|
|
5255
5299
|
setEnableStreamMode(currentStreamMode);
|
|
5256
|
-
|
|
5300
|
+
_context8.prev = 2;
|
|
5257
5301
|
// Parse and interpolate request body template
|
|
5258
5302
|
requestBodyRes = JSON.parse((args().requestBodyTmpl || '{}').replace(/\{model\}/g, args().model).replace(/\{message\}/g, msg).replace(/\{token\}/g, chatId)); //
|
|
5259
5303
|
// If a formatter function exists, it is used to process the request body
|
|
5260
5304
|
if (!(typeof args().requestBodyFormatter === 'function')) {
|
|
5261
|
-
|
|
5305
|
+
_context8.next = 8;
|
|
5262
5306
|
break;
|
|
5263
5307
|
}
|
|
5264
|
-
|
|
5308
|
+
_context8.next = 7;
|
|
5265
5309
|
return args().requestBodyFormatter(requestBodyRes, args().latestContextData, conversationHistory.current);
|
|
5266
5310
|
case 7:
|
|
5267
|
-
requestBodyRes =
|
|
5311
|
+
requestBodyRes = _context8.sent;
|
|
5268
5312
|
case 8:
|
|
5269
5313
|
// Scroll to the bottom
|
|
5270
5314
|
setTimeout(function () {
|
|
@@ -5272,19 +5316,19 @@ var Chatbox = function Chatbox(props) {
|
|
|
5272
5316
|
scrollToBottom();
|
|
5273
5317
|
}, 500);
|
|
5274
5318
|
if (!(typeof args().customRequest === 'function')) {
|
|
5275
|
-
|
|
5319
|
+
_context8.next = 25;
|
|
5276
5320
|
break;
|
|
5277
5321
|
}
|
|
5278
5322
|
// Update stream mode
|
|
5279
5323
|
setEnableStreamMode(false);
|
|
5280
|
-
|
|
5324
|
+
_context8.next = 13;
|
|
5281
5325
|
return args().customRequest(msg, {
|
|
5282
5326
|
requestBody: requestBodyRes,
|
|
5283
5327
|
apiUrl: args().requestApiUrl || '',
|
|
5284
5328
|
headers: args().headerConfigRes
|
|
5285
5329
|
}, customMethodsRef.current, conversationHistory.current);
|
|
5286
5330
|
case 13:
|
|
5287
|
-
customResponse =
|
|
5331
|
+
customResponse = _context8.sent;
|
|
5288
5332
|
content = customResponse.content, isStream = customResponse.isStream;
|
|
5289
5333
|
contentRes = content; // Update stream mode
|
|
5290
5334
|
setEnableStreamMode(isStream);
|
|
@@ -5292,24 +5336,24 @@ var Chatbox = function Chatbox(props) {
|
|
|
5292
5336
|
// NORMAL
|
|
5293
5337
|
//++++++++++++++++++++++++++++++++++++++++++++++++
|
|
5294
5338
|
if (!(!isStream && typeof contentRes === 'string' && contentRes.trim() !== '')) {
|
|
5295
|
-
|
|
5339
|
+
_context8.next = 20;
|
|
5296
5340
|
break;
|
|
5297
5341
|
}
|
|
5298
5342
|
// Replace with a valid label
|
|
5299
5343
|
contentRes = fixHtmlTags(contentRes, args().withReasoning, args().reasoningSwitchLabel);
|
|
5300
|
-
return
|
|
5344
|
+
return _context8.abrupt("return", {
|
|
5301
5345
|
reply: formatLatestDisplayContent(contentRes),
|
|
5302
5346
|
useStreamRender: false
|
|
5303
5347
|
});
|
|
5304
5348
|
case 20:
|
|
5305
5349
|
if (!(isStream && isStreamResponse(contentRes))) {
|
|
5306
|
-
|
|
5350
|
+
_context8.next = 24;
|
|
5307
5351
|
break;
|
|
5308
5352
|
}
|
|
5309
|
-
|
|
5353
|
+
_context8.next = 23;
|
|
5310
5354
|
return streamController.start(contentRes);
|
|
5311
5355
|
case 23:
|
|
5312
|
-
return
|
|
5356
|
+
return _context8.abrupt("return", {
|
|
5313
5357
|
reply: tempAnimText,
|
|
5314
5358
|
// The final content will be in tempAnimText
|
|
5315
5359
|
useStreamRender: true
|
|
@@ -5323,19 +5367,19 @@ var Chatbox = function Chatbox(props) {
|
|
|
5323
5367
|
}
|
|
5324
5368
|
case 25:
|
|
5325
5369
|
if (!currentStreamMode) {
|
|
5326
|
-
|
|
5370
|
+
_context8.next = 39;
|
|
5327
5371
|
break;
|
|
5328
5372
|
}
|
|
5329
|
-
|
|
5373
|
+
_context8.next = 28;
|
|
5330
5374
|
return fetch(args().requestApiUrl || '', {
|
|
5331
5375
|
method: "POST",
|
|
5332
5376
|
body: JSON.stringify(requestBodyRes),
|
|
5333
5377
|
headers: args().headerConfigRes
|
|
5334
5378
|
});
|
|
5335
5379
|
case 28:
|
|
5336
|
-
response =
|
|
5380
|
+
response = _context8.sent;
|
|
5337
5381
|
if (response.ok) {
|
|
5338
|
-
|
|
5382
|
+
_context8.next = 34;
|
|
5339
5383
|
break;
|
|
5340
5384
|
}
|
|
5341
5385
|
_errInfo = "[ERROR] HTTP Error ".concat(response.status, ": ").concat(response.statusText);
|
|
@@ -5343,15 +5387,15 @@ var Chatbox = function Chatbox(props) {
|
|
|
5343
5387
|
|
|
5344
5388
|
// hide loader
|
|
5345
5389
|
setLoaderDisplay(false);
|
|
5346
|
-
return
|
|
5390
|
+
return _context8.abrupt("return", {
|
|
5347
5391
|
reply: _errInfo,
|
|
5348
5392
|
useStreamRender: false
|
|
5349
5393
|
});
|
|
5350
5394
|
case 34:
|
|
5351
|
-
|
|
5395
|
+
_context8.next = 36;
|
|
5352
5396
|
return streamController.start(response);
|
|
5353
5397
|
case 36:
|
|
5354
|
-
return
|
|
5398
|
+
return _context8.abrupt("return", {
|
|
5355
5399
|
reply: tempAnimText,
|
|
5356
5400
|
// The final content will be in tempAnimText
|
|
5357
5401
|
useStreamRender: true
|
|
@@ -5359,7 +5403,7 @@ var Chatbox = function Chatbox(props) {
|
|
|
5359
5403
|
case 39:
|
|
5360
5404
|
// Extract response using the path
|
|
5361
5405
|
extractPath = (_args$responseExtract2 = args().responseExtractPath) === null || _args$responseExtract2 === void 0 ? void 0 : _args$responseExtract2.slice(1);
|
|
5362
|
-
|
|
5406
|
+
_context8.next = 42;
|
|
5363
5407
|
return fetch(args().requestApiUrl || '', {
|
|
5364
5408
|
method: "POST",
|
|
5365
5409
|
headers: args().headerConfigRes,
|
|
@@ -5367,22 +5411,22 @@ var Chatbox = function Chatbox(props) {
|
|
|
5367
5411
|
signal: abortController.current.signal
|
|
5368
5412
|
});
|
|
5369
5413
|
case 42:
|
|
5370
|
-
_response =
|
|
5414
|
+
_response = _context8.sent;
|
|
5371
5415
|
if (_response.ok) {
|
|
5372
|
-
|
|
5416
|
+
_context8.next = 47;
|
|
5373
5417
|
break;
|
|
5374
5418
|
}
|
|
5375
5419
|
_errInfo2 = "[ERROR] HTTP Error ".concat(_response.status, ": ").concat(_response.statusText); // hide loader
|
|
5376
5420
|
setLoaderDisplay(false);
|
|
5377
|
-
return
|
|
5421
|
+
return _context8.abrupt("return", {
|
|
5378
5422
|
reply: _errInfo2,
|
|
5379
5423
|
useStreamRender: false
|
|
5380
5424
|
});
|
|
5381
5425
|
case 47:
|
|
5382
|
-
|
|
5426
|
+
_context8.next = 49;
|
|
5383
5427
|
return _response.json();
|
|
5384
5428
|
case 49:
|
|
5385
|
-
jsonResponse =
|
|
5429
|
+
jsonResponse = _context8.sent;
|
|
5386
5430
|
// hide loader
|
|
5387
5431
|
setLoaderDisplay(false);
|
|
5388
5432
|
result = jsonResponse;
|
|
@@ -5401,33 +5445,33 @@ var Chatbox = function Chatbox(props) {
|
|
|
5401
5445
|
}
|
|
5402
5446
|
_content2 = result; // Replace with a valid label
|
|
5403
5447
|
_content2 = fixHtmlTags(_content2, args().withReasoning, args().reasoningSwitchLabel);
|
|
5404
|
-
return
|
|
5448
|
+
return _context8.abrupt("return", {
|
|
5405
5449
|
reply: formatLatestDisplayContent(_content2),
|
|
5406
5450
|
useStreamRender: false
|
|
5407
5451
|
});
|
|
5408
5452
|
case 56:
|
|
5409
|
-
|
|
5453
|
+
_context8.next = 64;
|
|
5410
5454
|
break;
|
|
5411
5455
|
case 58:
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
_err = "--> Error in mainRequest: ".concat(
|
|
5456
|
+
_context8.prev = 58;
|
|
5457
|
+
_context8.t0 = _context8["catch"](2);
|
|
5458
|
+
_err = "--> Error in mainRequest: ".concat(_context8.t0);
|
|
5415
5459
|
console.error(_err);
|
|
5416
5460
|
|
|
5417
5461
|
//reset SSE
|
|
5418
5462
|
closeSSE();
|
|
5419
|
-
return
|
|
5463
|
+
return _context8.abrupt("return", {
|
|
5420
5464
|
reply: _err,
|
|
5421
5465
|
useStreamRender: false
|
|
5422
5466
|
});
|
|
5423
5467
|
case 64:
|
|
5424
5468
|
case "end":
|
|
5425
|
-
return
|
|
5469
|
+
return _context8.stop();
|
|
5426
5470
|
}
|
|
5427
|
-
},
|
|
5471
|
+
}, _callee8, null, [[2, 58]]);
|
|
5428
5472
|
}));
|
|
5429
|
-
return function mainRequest(
|
|
5430
|
-
return
|
|
5473
|
+
return function mainRequest(_x14) {
|
|
5474
|
+
return _ref6.apply(this, arguments);
|
|
5431
5475
|
};
|
|
5432
5476
|
}();
|
|
5433
5477
|
|
|
@@ -5464,6 +5508,44 @@ var Chatbox = function Chatbox(props) {
|
|
|
5464
5508
|
// Bind chatboxCopyToClipboard to window so it can be called in HTML code
|
|
5465
5509
|
window.chatboxCopyToClipboard = chatboxCopyToClipboard;
|
|
5466
5510
|
}, []);
|
|
5511
|
+
|
|
5512
|
+
// Initialize the default value of toolkit buttons
|
|
5513
|
+
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
|
|
5514
|
+
if (args().toolkitButtons) {
|
|
5515
|
+
args().toolkitButtons.forEach(function (btn, index) {
|
|
5516
|
+
var _id = "".concat(args().prefix || 'custom-', "chatbox-btn-tools-").concat(chatId).concat(index);
|
|
5517
|
+
if (btn.isSelect) {
|
|
5518
|
+
if (!initializedDefaults[_id] && typeof btn.defaultSelected === 'number') {
|
|
5519
|
+
var options = getButtonOptions(btn, _id);
|
|
5520
|
+
|
|
5521
|
+
// If there is a default selected item, initialize the selected state
|
|
5522
|
+
if (btn.defaultSelected >= 0 && btn.defaultSelected < options.length) {
|
|
5523
|
+
var defaultOption = options[btn.defaultSelected];
|
|
5524
|
+
if (defaultOption) {
|
|
5525
|
+
// Update the selected status
|
|
5526
|
+
// console.log('--> defaultOption: ', defaultOption);
|
|
5527
|
+
|
|
5528
|
+
// Pass the "isDefaultSelection" parameter as true
|
|
5529
|
+
handleExecuteButtonSelect(_id, defaultOption, btn.defaultSelected, defaultOption.value, true);
|
|
5530
|
+
|
|
5531
|
+
// Perform the onClick action alone
|
|
5532
|
+
executeDefaultOptionAction(defaultOption.onClick, _id);
|
|
5533
|
+
|
|
5534
|
+
// Mark this button with the default value initialized
|
|
5535
|
+
setInitializedDefaults(function (prev) {
|
|
5536
|
+
return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, _id, true));
|
|
5537
|
+
});
|
|
5538
|
+
}
|
|
5539
|
+
}
|
|
5540
|
+
}
|
|
5541
|
+
} else if (btn.active) {
|
|
5542
|
+
// For non-select buttons, if defaultActive is true, execute the onClick action
|
|
5543
|
+
executeButtonAction(btn.onClick, _id, document.getElementById(_id));
|
|
5544
|
+
}
|
|
5545
|
+
});
|
|
5546
|
+
}
|
|
5547
|
+
}, [chatId, args().toolkitButtons]); // It is only executed when the component is first rendered and when toolkitButtons changes
|
|
5548
|
+
|
|
5467
5549
|
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((dist_cjs_default()), {
|
|
5468
5550
|
show: true,
|
|
5469
5551
|
containerClassName: "Chatbox"
|
|
@@ -5693,8 +5775,8 @@ var Chatbox = function Chatbox(props) {
|
|
|
5693
5775
|
}
|
|
5694
5776
|
},
|
|
5695
5777
|
onChange: function onChange(e, el, value) {
|
|
5696
|
-
var _args$onInputChange,
|
|
5697
|
-
(_args$onInputChange = (
|
|
5778
|
+
var _args$onInputChange, _args17;
|
|
5779
|
+
(_args$onInputChange = (_args17 = args()).onInputChange) === null || _args$onInputChange === void 0 ? void 0 : _args$onInputChange.call(_args17, inputContentRef.current, value);
|
|
5698
5780
|
},
|
|
5699
5781
|
onFocus: function onFocus() {
|
|
5700
5782
|
setFocused(true);
|
|
@@ -5763,7 +5845,8 @@ var Chatbox = function Chatbox(props) {
|
|
|
5763
5845
|
className: "toolkit-select-wrapper"
|
|
5764
5846
|
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("button", {
|
|
5765
5847
|
id: _id,
|
|
5766
|
-
|
|
5848
|
+
"data-value": btn.value || '',
|
|
5849
|
+
className: "toolkit-select-btn ".concat(isActive ? 'active' : '', " ").concat(selectedOpt.curValue !== 'cancel' && typeof selectedOpt.curValue !== 'undefined' && selectedOpt.curValue !== '' ? 'opt-active' : ''),
|
|
5767
5850
|
onClick: function onClick(e) {
|
|
5768
5851
|
e.preventDefault();
|
|
5769
5852
|
setActiveButtons(function (prev) {
|
|
@@ -5800,7 +5883,8 @@ var Chatbox = function Chatbox(props) {
|
|
|
5800
5883
|
}, options.length > 0 ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, options.map(function (option, optIndex) {
|
|
5801
5884
|
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
5802
5885
|
key: optIndex,
|
|
5803
|
-
|
|
5886
|
+
"data-value": option.value || '',
|
|
5887
|
+
className: "toolkit-select-option ".concat(selectedOpt.curIndex === optIndex ? 'selected' : ''),
|
|
5804
5888
|
onClick: function onClick() {
|
|
5805
5889
|
return handleExecuteButtonSelect(_id, option, optIndex, option.value);
|
|
5806
5890
|
}
|