@kite-copilot/chat-panel 0.2.18 → 0.2.19

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/auto.cjs CHANGED
@@ -1266,6 +1266,7 @@ var initialMessages = [];
1266
1266
  function ChatPanel({
1267
1267
  isOpen = true,
1268
1268
  onClose,
1269
+ onOpen,
1269
1270
  onBack,
1270
1271
  onNavigate,
1271
1272
  onActionComplete,
@@ -1367,6 +1368,9 @@ function ChatPanel({
1367
1368
  const [pendingBulkSession, setPendingBulkSession] = React4.useState(null);
1368
1369
  const pendingBulkSessionRef = React4.useRef(null);
1369
1370
  const fileInputRef = React4.useRef(null);
1371
+ const [searchExpanded, setSearchExpanded] = React4.useState(false);
1372
+ const [searchInput, setSearchInput] = React4.useState("");
1373
+ const searchInputRef = React4.useRef(null);
1370
1374
  React4.useEffect(() => {
1371
1375
  if (!activeGuide || activeGuide.id !== "add-api-key" || activeGuide.stepIndex !== 2) {
1372
1376
  return;
@@ -2597,6 +2601,81 @@ ${userText}`
2597
2601
  ]);
2598
2602
  }
2599
2603
  }
2604
+ if (!isOpen) {
2605
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "fixed bottom-6 left-1/2 -translate-x-1/2 z-50", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: `flex items-center gap-3 rounded-xl bg-white border border-gray-200 shadow-lg px-4 py-3 hover:shadow-xl transition-all duration-300 ease-out ${searchExpanded ? "w-[480px]" : "w-[320px]"}`, children: !searchExpanded ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-3 w-full", children: [
2606
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2607
+ "button",
2608
+ {
2609
+ onClick: () => {
2610
+ setSearchExpanded(true);
2611
+ setTimeout(() => searchInputRef.current?.focus(), 100);
2612
+ },
2613
+ className: "flex items-center gap-3 flex-1 group",
2614
+ children: [
2615
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-sm text-gray-500 flex-1 text-left", children: "Ask a question..." }),
2616
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-xs text-gray-400 font-medium", children: "\u2318I" })
2617
+ ]
2618
+ }
2619
+ ),
2620
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2621
+ "button",
2622
+ {
2623
+ onClick: () => {
2624
+ onOpen?.();
2625
+ },
2626
+ className: "h-7 w-7 rounded-lg bg-gray-100 hover:bg-gray-200 flex items-center justify-center transition-colors",
2627
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Sparkles, { className: "h-3.5 w-3.5 text-black", fill: "currentColor" })
2628
+ }
2629
+ )
2630
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
2631
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2632
+ "input",
2633
+ {
2634
+ ref: searchInputRef,
2635
+ type: "text",
2636
+ value: searchInput,
2637
+ onChange: (e) => setSearchInput(e.target.value),
2638
+ onKeyDown: (e) => {
2639
+ if (e.key === "Enter" && searchInput.trim()) {
2640
+ e.preventDefault();
2641
+ onOpen?.();
2642
+ startChatFlow(searchInput.trim());
2643
+ setSearchInput("");
2644
+ setSearchExpanded(false);
2645
+ } else if (e.key === "Escape") {
2646
+ setSearchExpanded(false);
2647
+ setSearchInput("");
2648
+ }
2649
+ },
2650
+ onBlur: () => {
2651
+ if (!searchInput.trim()) {
2652
+ setTimeout(() => setSearchExpanded(false), 200);
2653
+ }
2654
+ },
2655
+ placeholder: "Ask a question...",
2656
+ className: "flex-1 text-sm text-gray-700 outline-none bg-transparent"
2657
+ }
2658
+ ),
2659
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-2", children: [
2660
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-xs text-gray-400 font-medium", children: "\u21B5 Enter" }),
2661
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2662
+ "button",
2663
+ {
2664
+ onClick: () => {
2665
+ onOpen?.();
2666
+ if (searchInput.trim()) {
2667
+ setInput(searchInput);
2668
+ }
2669
+ setSearchInput("");
2670
+ setSearchExpanded(false);
2671
+ },
2672
+ className: "h-7 w-7 rounded-lg bg-gray-100 hover:bg-gray-200 flex items-center justify-center transition-colors cursor-pointer",
2673
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Sparkles, { className: "h-3.5 w-3.5 text-black", fill: "currentColor" })
2674
+ }
2675
+ )
2676
+ ] })
2677
+ ] }) }) });
2678
+ }
2600
2679
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2601
2680
  "section",
2602
2681
  {
@@ -3909,26 +3988,6 @@ ${userText}`
3909
3988
  }
3910
3989
  );
3911
3990
  }
3912
- function PanelToggle({
3913
- isOpen,
3914
- onClick,
3915
- className = ""
3916
- }) {
3917
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3918
- "button",
3919
- {
3920
- type: "button",
3921
- onClick,
3922
- className: `fixed top-1/2 z-50 flex items-center justify-center w-6 h-16 bg-gray-100 hover:bg-gray-200 border border-gray-200 border-r-0 rounded-l-lg text-gray-600 hover:text-gray-800 shadow-md transition-all duration-300 ${className}`,
3923
- "aria-label": isOpen ? "Close help panel" : "Open help panel",
3924
- style: {
3925
- right: isOpen ? `${PANEL_WIDTH}px` : "0px",
3926
- transform: "translateY(-50%)"
3927
- },
3928
- children: isOpen ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.ChevronRight, { className: "h-4 w-4" }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.ChevronLeft, { className: "h-4 w-4" })
3929
- }
3930
- );
3931
- }
3932
3991
  function ChatPanelWithToggle({
3933
3992
  onNavigate,
3934
3993
  onActionComplete,
@@ -3958,22 +4017,20 @@ function ChatPanelWithToggle({
3958
4017
  document.body.style.transition = originalTransition;
3959
4018
  };
3960
4019
  }, [isOpen]);
3961
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
3962
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PanelToggle, { isOpen, onClick: () => setIsOpen(!isOpen) }),
3963
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3964
- ChatPanel,
3965
- {
3966
- isOpen,
3967
- onClose: () => setIsOpen(false),
3968
- onNavigate,
3969
- onActionComplete,
3970
- currentPage,
3971
- agentUrl,
3972
- startingQuestions,
3973
- startingQuestionsEndpoint
3974
- }
3975
- )
3976
- ] });
4020
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
4021
+ ChatPanel,
4022
+ {
4023
+ isOpen,
4024
+ onClose: () => setIsOpen(false),
4025
+ onOpen: () => setIsOpen(true),
4026
+ onNavigate,
4027
+ onActionComplete,
4028
+ currentPage,
4029
+ agentUrl,
4030
+ startingQuestions,
4031
+ startingQuestionsEndpoint
4032
+ }
4033
+ );
3977
4034
  }
3978
4035
 
3979
4036
  // src/createKiteChat.tsx
package/dist/auto.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { K as KiteChatConfig, a as KiteChatInstance } from './createKiteChat-BMLaQQQk.cjs';
1
+ import { K as KiteChatConfig, a as KiteChatInstance } from './createKiteChat-CyoN-YV4.cjs';
2
2
  import 'react/jsx-runtime';
3
3
 
4
4
  /**
package/dist/auto.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { K as KiteChatConfig, a as KiteChatInstance } from './createKiteChat-BMLaQQQk.js';
1
+ import { K as KiteChatConfig, a as KiteChatInstance } from './createKiteChat-CyoN-YV4.js';
2
2
  import 'react/jsx-runtime';
3
3
 
4
4
  /**
package/dist/auto.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createKiteChat
3
- } from "./chunk-UW3AFJMK.js";
3
+ } from "./chunk-5SGUG45C.js";
4
4
 
5
5
  // src/auto.ts
6
6
  function mountKiteChat(config) {
@@ -1265,6 +1265,7 @@ var initialMessages = [];
1265
1265
  function ChatPanel({
1266
1266
  isOpen = true,
1267
1267
  onClose,
1268
+ onOpen,
1268
1269
  onBack,
1269
1270
  onNavigate,
1270
1271
  onActionComplete,
@@ -1366,6 +1367,9 @@ function ChatPanel({
1366
1367
  const [pendingBulkSession, setPendingBulkSession] = React4.useState(null);
1367
1368
  const pendingBulkSessionRef = React4.useRef(null);
1368
1369
  const fileInputRef = React4.useRef(null);
1370
+ const [searchExpanded, setSearchExpanded] = React4.useState(false);
1371
+ const [searchInput, setSearchInput] = React4.useState("");
1372
+ const searchInputRef = React4.useRef(null);
1369
1373
  React4.useEffect(() => {
1370
1374
  if (!activeGuide || activeGuide.id !== "add-api-key" || activeGuide.stepIndex !== 2) {
1371
1375
  return;
@@ -2596,6 +2600,81 @@ ${userText}`
2596
2600
  ]);
2597
2601
  }
2598
2602
  }
2603
+ if (!isOpen) {
2604
+ return /* @__PURE__ */ jsx9("div", { className: "fixed bottom-6 left-1/2 -translate-x-1/2 z-50", children: /* @__PURE__ */ jsx9("div", { className: `flex items-center gap-3 rounded-xl bg-white border border-gray-200 shadow-lg px-4 py-3 hover:shadow-xl transition-all duration-300 ease-out ${searchExpanded ? "w-[480px]" : "w-[320px]"}`, children: !searchExpanded ? /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-3 w-full", children: [
2605
+ /* @__PURE__ */ jsxs5(
2606
+ "button",
2607
+ {
2608
+ onClick: () => {
2609
+ setSearchExpanded(true);
2610
+ setTimeout(() => searchInputRef.current?.focus(), 100);
2611
+ },
2612
+ className: "flex items-center gap-3 flex-1 group",
2613
+ children: [
2614
+ /* @__PURE__ */ jsx9("span", { className: "text-sm text-gray-500 flex-1 text-left", children: "Ask a question..." }),
2615
+ /* @__PURE__ */ jsx9("span", { className: "text-xs text-gray-400 font-medium", children: "\u2318I" })
2616
+ ]
2617
+ }
2618
+ ),
2619
+ /* @__PURE__ */ jsx9(
2620
+ "button",
2621
+ {
2622
+ onClick: () => {
2623
+ onOpen?.();
2624
+ },
2625
+ className: "h-7 w-7 rounded-lg bg-gray-100 hover:bg-gray-200 flex items-center justify-center transition-colors",
2626
+ children: /* @__PURE__ */ jsx9(Sparkles, { className: "h-3.5 w-3.5 text-black", fill: "currentColor" })
2627
+ }
2628
+ )
2629
+ ] }) : /* @__PURE__ */ jsxs5(Fragment2, { children: [
2630
+ /* @__PURE__ */ jsx9(
2631
+ "input",
2632
+ {
2633
+ ref: searchInputRef,
2634
+ type: "text",
2635
+ value: searchInput,
2636
+ onChange: (e) => setSearchInput(e.target.value),
2637
+ onKeyDown: (e) => {
2638
+ if (e.key === "Enter" && searchInput.trim()) {
2639
+ e.preventDefault();
2640
+ onOpen?.();
2641
+ startChatFlow(searchInput.trim());
2642
+ setSearchInput("");
2643
+ setSearchExpanded(false);
2644
+ } else if (e.key === "Escape") {
2645
+ setSearchExpanded(false);
2646
+ setSearchInput("");
2647
+ }
2648
+ },
2649
+ onBlur: () => {
2650
+ if (!searchInput.trim()) {
2651
+ setTimeout(() => setSearchExpanded(false), 200);
2652
+ }
2653
+ },
2654
+ placeholder: "Ask a question...",
2655
+ className: "flex-1 text-sm text-gray-700 outline-none bg-transparent"
2656
+ }
2657
+ ),
2658
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2", children: [
2659
+ /* @__PURE__ */ jsx9("span", { className: "text-xs text-gray-400 font-medium", children: "\u21B5 Enter" }),
2660
+ /* @__PURE__ */ jsx9(
2661
+ "button",
2662
+ {
2663
+ onClick: () => {
2664
+ onOpen?.();
2665
+ if (searchInput.trim()) {
2666
+ setInput(searchInput);
2667
+ }
2668
+ setSearchInput("");
2669
+ setSearchExpanded(false);
2670
+ },
2671
+ className: "h-7 w-7 rounded-lg bg-gray-100 hover:bg-gray-200 flex items-center justify-center transition-colors cursor-pointer",
2672
+ children: /* @__PURE__ */ jsx9(Sparkles, { className: "h-3.5 w-3.5 text-black", fill: "currentColor" })
2673
+ }
2674
+ )
2675
+ ] })
2676
+ ] }) }) });
2677
+ }
2599
2678
  return /* @__PURE__ */ jsxs5(
2600
2679
  "section",
2601
2680
  {
@@ -3957,22 +4036,20 @@ function ChatPanelWithToggle({
3957
4036
  document.body.style.transition = originalTransition;
3958
4037
  };
3959
4038
  }, [isOpen]);
3960
- return /* @__PURE__ */ jsxs5(Fragment2, { children: [
3961
- /* @__PURE__ */ jsx9(PanelToggle, { isOpen, onClick: () => setIsOpen(!isOpen) }),
3962
- /* @__PURE__ */ jsx9(
3963
- ChatPanel,
3964
- {
3965
- isOpen,
3966
- onClose: () => setIsOpen(false),
3967
- onNavigate,
3968
- onActionComplete,
3969
- currentPage,
3970
- agentUrl,
3971
- startingQuestions,
3972
- startingQuestionsEndpoint
3973
- }
3974
- )
3975
- ] });
4039
+ return /* @__PURE__ */ jsx9(
4040
+ ChatPanel,
4041
+ {
4042
+ isOpen,
4043
+ onClose: () => setIsOpen(false),
4044
+ onOpen: () => setIsOpen(true),
4045
+ onNavigate,
4046
+ onActionComplete,
4047
+ currentPage,
4048
+ agentUrl,
4049
+ startingQuestions,
4050
+ startingQuestionsEndpoint
4051
+ }
4052
+ );
3976
4053
  }
3977
4054
  function HelpButton({ onClick, className = "" }) {
3978
4055
  return /* @__PURE__ */ jsx9(
@@ -87,6 +87,8 @@ interface ChatPanelProps {
87
87
  isOpen?: boolean;
88
88
  /** Callback when the panel should close */
89
89
  onClose?: () => void;
90
+ /** Callback when the panel should open */
91
+ onOpen?: () => void;
90
92
  onBack?: () => void;
91
93
  onNavigate?: (page: Page, subtab?: SettingsTab) => void;
92
94
  onActionComplete?: (actionType: ActionType, data: ActionData) => void;
@@ -97,7 +99,7 @@ interface ChatPanelProps {
97
99
  /** API endpoint to fetch starting questions */
98
100
  startingQuestionsEndpoint?: string;
99
101
  }
100
- declare function ChatPanel({ isOpen, onClose, onBack, onNavigate, onActionComplete, currentPage, agentUrl, startingQuestions: startingQuestionsProp, startingQuestionsEndpoint, }?: ChatPanelProps): react_jsx_runtime.JSX.Element;
102
+ declare function ChatPanel({ isOpen, onClose, onOpen, onBack, onNavigate, onActionComplete, currentPage, agentUrl, startingQuestions: startingQuestionsProp, startingQuestionsEndpoint, }?: ChatPanelProps): react_jsx_runtime.JSX.Element;
101
103
  /**
102
104
  * PanelToggle - An arrow button on the right edge that toggles the side panel
103
105
  * Shows left arrow when closed (click to open), right arrow when open (click to close)
@@ -87,6 +87,8 @@ interface ChatPanelProps {
87
87
  isOpen?: boolean;
88
88
  /** Callback when the panel should close */
89
89
  onClose?: () => void;
90
+ /** Callback when the panel should open */
91
+ onOpen?: () => void;
90
92
  onBack?: () => void;
91
93
  onNavigate?: (page: Page, subtab?: SettingsTab) => void;
92
94
  onActionComplete?: (actionType: ActionType, data: ActionData) => void;
@@ -97,7 +99,7 @@ interface ChatPanelProps {
97
99
  /** API endpoint to fetch starting questions */
98
100
  startingQuestionsEndpoint?: string;
99
101
  }
100
- declare function ChatPanel({ isOpen, onClose, onBack, onNavigate, onActionComplete, currentPage, agentUrl, startingQuestions: startingQuestionsProp, startingQuestionsEndpoint, }?: ChatPanelProps): react_jsx_runtime.JSX.Element;
102
+ declare function ChatPanel({ isOpen, onClose, onOpen, onBack, onNavigate, onActionComplete, currentPage, agentUrl, startingQuestions: startingQuestionsProp, startingQuestionsEndpoint, }?: ChatPanelProps): react_jsx_runtime.JSX.Element;
101
103
  /**
102
104
  * PanelToggle - An arrow button on the right edge that toggles the side panel
103
105
  * Shows left arrow when closed (click to open), right arrow when open (click to close)