@informedai/react 0.4.9 → 0.4.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -748,9 +748,17 @@ function AssistantWidget({ className, theme, position = "inline", defaultCollaps
748
748
  const [isCollapsed, setIsCollapsed] = (0, import_react2.useState)(defaultCollapsed);
749
749
  const [inputValue, setInputValue] = (0, import_react2.useState)("");
750
750
  const messagesEndRef = (0, import_react2.useRef)(null);
751
+ const inputRef = (0, import_react2.useRef)(null);
752
+ const wasStreamingRef = (0, import_react2.useRef)(false);
751
753
  (0, import_react2.useEffect)(() => {
752
754
  messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
753
755
  }, [session?.widgetMessages, streamingContent]);
756
+ (0, import_react2.useEffect)(() => {
757
+ if (wasStreamingRef.current && !isStreaming) {
758
+ inputRef.current?.focus();
759
+ }
760
+ wasStreamingRef.current = isStreaming;
761
+ }, [isStreaming]);
754
762
  const handleSubmit = async (e) => {
755
763
  e.preventDefault();
756
764
  if (!inputValue.trim() || isStreaming) return;
@@ -1027,6 +1035,7 @@ function AssistantWidget({ className, theme, position = "inline", defaultCollaps
1027
1035
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1028
1036
  "input",
1029
1037
  {
1038
+ ref: inputRef,
1030
1039
  type: "text",
1031
1040
  value: inputValue,
1032
1041
  onChange: (e) => setInputValue(e.target.value),
package/dist/index.mjs CHANGED
@@ -718,9 +718,17 @@ function AssistantWidget({ className, theme, position = "inline", defaultCollaps
718
718
  const [isCollapsed, setIsCollapsed] = useState2(defaultCollapsed);
719
719
  const [inputValue, setInputValue] = useState2("");
720
720
  const messagesEndRef = useRef2(null);
721
+ const inputRef = useRef2(null);
722
+ const wasStreamingRef = useRef2(false);
721
723
  useEffect2(() => {
722
724
  messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
723
725
  }, [session?.widgetMessages, streamingContent]);
726
+ useEffect2(() => {
727
+ if (wasStreamingRef.current && !isStreaming) {
728
+ inputRef.current?.focus();
729
+ }
730
+ wasStreamingRef.current = isStreaming;
731
+ }, [isStreaming]);
724
732
  const handleSubmit = async (e) => {
725
733
  e.preventDefault();
726
734
  if (!inputValue.trim() || isStreaming) return;
@@ -997,6 +1005,7 @@ function AssistantWidget({ className, theme, position = "inline", defaultCollaps
997
1005
  /* @__PURE__ */ jsx2(
998
1006
  "input",
999
1007
  {
1008
+ ref: inputRef,
1000
1009
  type: "text",
1001
1010
  value: inputValue,
1002
1011
  onChange: (e) => setInputValue(e.target.value),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@informedai/react",
3
- "version": "0.4.9",
3
+ "version": "0.4.10",
4
4
  "description": "React SDK for InformedAI Assistant - AI-powered content creation widget",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",