@pickaxeproject/react 6.10.4 → 6.11.0
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/cjs/components/Pickaxe/Addons/Scroll/hooks/useScroll.js +1 -1
- package/dist/cjs/components/Pickaxe/Chat/index.js +1 -1
- package/dist/cjs/src/components/Pickaxe/Addons/Scroll/hooks/useScroll.d.ts +7 -3
- package/dist/esm/components/Pickaxe/Addons/Scroll/hooks/useScroll.js +1 -1
- package/dist/esm/components/Pickaxe/Chat/index.js +1 -1
- package/dist/esm/src/components/Pickaxe/Addons/Scroll/hooks/useScroll.d.ts +7 -3
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("./useScrollContext.js");exports.useScroll=({auto:t,debug:o,smooth:n=!0})=>{const{scrollContainerRef:l,scrollTargetRef:s,isLocked:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("./useScrollContext.js");exports.useScroll=({auto:t=!1,debug:o,smooth:n=!0})=>{const{scrollContainerRef:l,scrollTargetRef:c,hasScrolledRef:s,isLocked:u,isScrollSession:i,isScrollIncreasing:a,setIsLocked:d,setIsScrollSession:v,setIsScrolling:h,setIsScrollIncreasing:b}=r.useScrollContext(),f=e.useRef(null),g=e.useRef(null),m=e.useRef(!1),w=e.useRef(0),C=e.useCallback((()=>{null!==f.current&&(cancelAnimationFrame(f.current),f.current=null)}),[]),S=e.useCallback((e=>{g.current&&clearTimeout(g.current),g.current=setTimeout((()=>{m.current=!1,h(!1)}),"smooth"===e?400:0)}),[h]),T=e.useCallback(((e={})=>{var r;if(!e.force&&s.current)return;const t=null!==(r=e.behavior)&&void 0!==r?r:n?"smooth":"auto",u=l.current,i=c.current;if(u||i){if(m.current=!0,h(!0),u){const e=Math.max(0,u.scrollHeight-u.clientHeight);u.scrollTo({top:e,behavior:t})}else if(i){const e=i.getBoundingClientRect().bottom+window.scrollY,r=Math.max(0,e-window.innerHeight);window.scrollTo({top:r,behavior:t})}o&&console.log("[useScroll] scrolled to the active bottom"),S(t)}else o&&console.log("[useScroll] no scroll element detected")}),[o,S,s,l,c,h,n]),R=e.useCallback(((e={})=>{C(),f.current=requestAnimationFrame((()=>{f.current=null,T(e)}))}),[C,T]),p=e.useCallback(((e={})=>{var r;if(!e.force&&s.current)return;const t=c.current;if(!t)return void(o&&console.log("[useScroll] scroll target not detected"));const l=null!==(r=e.behavior)&&void 0!==r?r:n?"smooth":"auto",u=t.getBoundingClientRect().bottom+window.scrollY,i=Math.max(0,u-500);m.current=!0,h(!0),window.scrollTo({top:i,behavior:l}),o&&console.log("[useScroll] scrolled to the form response"),S(l)}),[o,S,s,c,h,n]),E=e.useCallback(((e={})=>{C(),f.current=requestAnimationFrame((()=>{f.current=null,p(e)}))}),[C,p]),k=e.useCallback((()=>{s.current=!1,d(!0),v(!0)}),[s,d,v]),L=e.useCallback((()=>{v(!1)}),[v]),H=e.useCallback(((e={})=>R(e)),[R]),x=e.useCallback(((e={})=>E(e)),[E]);return e.useEffect((()=>{if(!t||!i||!u)return;let e=l.current,r=c.current,o=null,n=[];const s=()=>{var t;if(!o)return;const n=e?e.scrollHeight:null!==(t=null==r?void 0:r.getBoundingClientRect().height)&&void 0!==t?t:0,l=n>w.current;w.current=n,b(l),l&&(e?R({behavior:"auto"}):E({behavior:"auto"}))},a=new ResizeObserver(s);function d(){o&&(n.forEach((e=>a.unobserve(e))),n=[o,...Array.from(o.children)],n.forEach((e=>a.observe(e))))}const v=new MutationObserver((()=>{d(),s()}));let h=null;const f=()=>{var t;e=l.current,r=c.current;const n=null!=e?e:r;return!(!n||n===o)&&(v.disconnect(),a.disconnect(),o=n,w.current=e?e.scrollHeight:null!==(t=null==r?void 0:r.getBoundingClientRect().height)&&void 0!==t?t:0,d(),v.observe(o,{childList:!0,subtree:!0}),e?R({behavior:"auto"}):E({behavior:"auto"}),!0)};return f()||(h=new MutationObserver((()=>{f()&&(null==h||h.disconnect())})),h.observe(document.body,{childList:!0,subtree:!0})),()=>{null==h||h.disconnect(),v.disconnect(),a.disconnect()}}),[t,u,i,R,E,l,c,b]),e.useEffect((()=>{u&&(s.current=!1)}),[s,u]),e.useEffect((()=>{const e=l.current,r=null!=e?e:window,t=()=>{if(m.current)return;const r=(()=>{if(e)return e.scrollHeight-e.scrollTop-e.clientHeight<=32;const r=c.current;return!r||r.getBoundingClientRect().bottom-window.innerHeight<=32})();s.current=!r,d(r)},o=()=>{m.current&&(m.current=!1,h(!1),g.current&&(clearTimeout(g.current),g.current=null),e?e.scrollTo({top:e.scrollTop,behavior:"auto"}):window.scrollTo({top:window.scrollY,behavior:"auto"}))};return r.addEventListener("scroll",t,{passive:!0}),r.addEventListener("wheel",o,{passive:!0}),r.addEventListener("touchmove",o,{passive:!0}),()=>{r.removeEventListener("scroll",t),r.removeEventListener("wheel",o),r.removeEventListener("touchmove",o)}}),[s,l,c,d,h]),e.useEffect((()=>()=>{C(),g.current&&clearTimeout(g.current)}),[C]),{scrollContainerRef:l,scrollTargetRef:c,isScrollIncreasing:a,scrollStartSession:k,scrollEndSession:L,scrollToBottom:H,scrollToTarget:x}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),o=require("react"),s=require("../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../Addons/Auth/hooks/useAuthContext.js"),r=require("../../../hooks/pickaxe/useDimensionContext.js"),n=require("../Addons/Document/hooks/useDocument.js"),a=require("../Addons/Scroll/hooks/useScrollContext.js"),l=require("../../../hooks/studio/useStyleFontSize.js"),u=require("../../../hooks/core/useScrollToBottomVisibility.js"),c=require("./History/index.js"),d=require("./Input.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),o=require("react"),s=require("../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../Addons/Auth/hooks/useAuthContext.js"),r=require("../../../hooks/pickaxe/useDimensionContext.js"),n=require("../Addons/Document/hooks/useDocument.js"),a=require("../Addons/Scroll/hooks/useScrollContext.js"),l=require("../../../hooks/studio/useStyleFontSize.js"),u=require("../../../hooks/core/useScrollToBottomVisibility.js"),c=require("./History/index.js"),d=require("./Input.js"),h=require("../../Icons/attach-vertical.svg.js"),f=require("../../../common/cn.js"),m=require("../../../common/api/pickaxe.js"),p=require("uuid"),v=require("../../Core/StudioTip.js"),x=require("../common/ScrollToBottomButton.js"),j=require("../../../hooks/pickaxe/useResponseContext.js"),g=require("../Addons/Navbar/NavPill.js"),b=require("../../Icons/history.svg.js");exports.default=()=>{var k,y;const{deploymentType:S,isNewChat:w,setIsNewChat:C,sessionId:q,setSessionId:I,setLastSessionId:D,pickaxeId:N,sender:A,pickaxe:P,styles:T,isEmbed:_,translations:F}=s.usePickaxeContext(),{isSent:E}=i.useAuthContext(),{width:O,height:R,setDimension:H}=r.useDimensionContext(),{setDocuments:z,onFileUpload:B}=n.useDocument(),{scrollContainerRef:L,hasScrolledRef:G,isLocked:M,setIsLocked:V}=a.useScrollContext(),{isGenerating:U,messages:W}=j.useResponseContext(),J=l.useStyleFontSize(),[K,Q]=o.useState(0),[X,Y]=o.useState(!1),[Z,$]=o.useState(!1),ee=o.useRef(null),te=o.useRef(null),oe=o.useRef(0),[se,ie]=o.useState(null),[re,ne]=o.useState(!1),ae=(null==F?void 0:F["new-chat"])||"New chat",le="chat-input"===S&&w&&!E,ue=null!==(y=null===(k=null==P?void 0:P.documentuploadtype)||void 0===k?void 0:k.startsWith("enduserupload"))&&void 0!==y&&y,{hasScrollableContent:ce,isNearBottom:de}=u.default(L);o.useEffect((()=>()=>{z([])}),[]);const he=o.useCallback((()=>{if(!N||!A)return;const t=(o=0)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;try{const t=yield m.pickaxeApi2.post("/conversation/title",{sessionId:q,userId:A});if(t.data&&t.data.success){const e=t.data.title;if(e&&"Conversation Title"!==e)return void me(e)}else console.error("Failed to load conversation:",null===(e=t.data)||void 0===e?void 0:e.error)}catch(e){console.error("Error fetching conversation:",e)}o<20&&setTimeout((()=>t(o+1)),3e3)}));t()}),[N,A,q]);o.useEffect((()=>{U||w||!q||he()}),[U,w,q,he]),o.useEffect((()=>{if(!ee.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:o}=t.contentRect;H(parseInt(e.toFixed(0)),parseInt(o.toFixed(0)))}}));return e.observe(ee.current),()=>{e.disconnect()}}),[H]);const[fe,me]=o.useState(ae),pe=(null==P?void 0:P.formtitle)||"Pickaxe",ve=(null==P?void 0:P.coverphoto)||void 0,[xe,je]=o.useState(!1);o.useEffect((()=>{const e=!le&&!_&&T.portalTheme&&(W.filter((e=>"user"===e.role)).length>0||X||!w);je(null!=e&&e)}),[le,_,X,w,W,T.portalTheme]);const ge=o.useCallback((()=>{G.current=!1,V(!0),requestAnimationFrame((()=>{const e=L.current;e&&e.scrollTo({top:Math.max(0,e.scrollHeight-e.clientHeight),behavior:"smooth"})}))}),[G,L,V]);return t.jsxs("div",Object.assign({ref:ee,className:"relative flex h-full w-full flex-col items-center overflow-hidden",onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),ue&&(oe.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&$(!0))},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),ue&&(oe.current-=1,0===oe.current&&$(!1))},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(t.preventDefault(),t.stopPropagation(),$(!1),oe.current=0,!ue)return;const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(C(!1),yield B(e))}))},{children:[Z&&t.jsxs("div",Object.assign({className:"absolute inset-0 z-50 flex flex-col items-center justify-center rounded-lg bg-white/80 backdrop-blur-sm transition-all duration-300"},{children:[t.jsx("div",Object.assign({className:"flex h-24 w-24 items-center justify-center rounded-full bg-white shadow-lg animate-bounce text-black"},{children:t.jsx(h.default,{className:"h-10 w-10"})})),t.jsx("h3",Object.assign({className:f.default(J.h3,"mt-6 font-semibold text-c-primary text-black")},{children:(null==F?void 0:F["drop-files-to-upload"])||"Drop files to upload"})),t.jsx("p",Object.assign({className:f.default(J.b2,"mt-2 opacity-60 text-black")},{children:(null==F?void 0:F["add-anything-to-the-conversation"])||"Add anything to the conversation"}))]})),le?t.jsx(d.default,{}):t.jsxs(t.Fragment,{children:[xe&&t.jsxs("div",Object.assign({className:f.default("direct-link"===S?"absolute top-4 left-4 md:top-6 md:left-6 z-40 flex items-center gap-2 animate-in fade-in slide-in-from-top-4 duration-500":"w-full max-w-3xl mt-6 px-4 md:px-0 flex justify-start z-30 mb-4 animate-in fade-in slide-in-from-top-4 duration-500 gap-2","dark"===T.portalTheme?"glass-dark ":"")},{children:[t.jsx(g.NavPill,{text:pe,icon:ve}),w||fe===ae?t.jsx(g.NavPill,{text:fe}):t.jsx(g.EditableNavPill,{text:fe,sessionId:q,onRename:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(q)try{yield m.pickaxeApi2.patch("/conversation/title",{sessionId:q,name:t,userId:A}),me(t)}catch(e){console.error("Error renaming chat:",e),alert((null==F?void 0:F["failed-rename-chat"])||"Failed to rename chat.")}})),onDelete:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(q&&window.confirm((null==F?void 0:F["delete-confirm"])||"Are you sure you want to delete this conversation?"))try{yield m.pickaxeApi2.delete("/conversation",{data:{sessionId:q,userId:A}}),C(!0),I(p.v4()),me(ae)}catch(e){console.error("Error deleting chat:",e),alert((null==F?void 0:F["failed-delete-chat"])||"Failed to delete chat.")}})),isDarkGlass:"dark"===T.portalTheme}),t.jsx(v.StudioTip,Object.assign({content:F["chat-history"]||"Chat History",align:"bottom",containerClassName:"inline-flex shrink-0"},{children:t.jsx(g.HistoryPill,{icon:t.jsx(b.default,{}),onClick:()=>{I(""),D(q)}})}))]})),t.jsx(c.default,{additionalScrollHeight:K,isForceHideInfo:R<=545||O<=350||X,isInputFocused:X,onSubmit:t=>e.__awaiter(void 0,void 0,void 0,(function*(){te.current&&te.current.onSubmit(t)})),smitheryAuthData:se,resubmitPrompt:()=>{ie(null),ne(!0)}}),t.jsx(x.default,{isVisible:ce&&!M&&!de,bottom:K+65,onClick:ge}),t.jsx(d.default,{ref:te,onFocus:()=>Y(!0),onBlur:()=>Y(!1),onInputHeightChange:Q,initSmitheryAuthData:e=>ie(e),resubmitPrompt:re})]})]}))};
|
|
@@ -4,13 +4,17 @@ interface UseScrollProps {
|
|
|
4
4
|
debug?: boolean;
|
|
5
5
|
smooth?: boolean;
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
interface ScrollOptions {
|
|
8
|
+
behavior?: ScrollBehavior;
|
|
9
|
+
force?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const useScroll: ({ auto, debug, smooth, }: UseScrollProps) => {
|
|
8
12
|
scrollContainerRef: import("react").MutableRefObject<HTMLDivElement>;
|
|
9
13
|
scrollTargetRef: import("react").MutableRefObject<HTMLDivElement>;
|
|
10
14
|
isScrollIncreasing: boolean;
|
|
11
15
|
scrollStartSession: () => void;
|
|
12
16
|
scrollEndSession: () => void;
|
|
13
|
-
scrollToBottom: () => void;
|
|
14
|
-
scrollToTarget: () => void;
|
|
17
|
+
scrollToBottom: (options?: ScrollOptions) => void;
|
|
18
|
+
scrollToTarget: (options?: ScrollOptions) => void;
|
|
15
19
|
};
|
|
16
20
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{useRef as e,useCallback as r,useEffect as t}from"react";import{useScrollContext as o}from"./useScrollContext.js";const n=({auto:n=!1,debug:l,smooth:c=!0})=>{const{scrollContainerRef:s,scrollTargetRef:i,hasScrolledRef:u,isLocked:a,isScrollSession:d,isScrollIncreasing:v,setIsLocked:h,setIsScrollSession:m,setIsScrolling:g,setIsScrollIncreasing:b}=o(),f=e(null),w=e(null),S=e(!1),T=e(0),p=r((()=>{null!==f.current&&(cancelAnimationFrame(f.current),f.current=null)}),[]),R=r((e=>{w.current&&clearTimeout(w.current),w.current=setTimeout((()=>{S.current=!1,g(!1)}),"smooth"===e?400:0)}),[g]),L=r(((e={})=>{var r;if(!e.force&&u.current)return;const t=null!==(r=e.behavior)&&void 0!==r?r:c?"smooth":"auto",o=s.current,n=i.current;if(o||n){if(S.current=!0,g(!0),o){const e=Math.max(0,o.scrollHeight-o.clientHeight);o.scrollTo({top:e,behavior:t})}else if(n){const e=n.getBoundingClientRect().bottom+window.scrollY,r=Math.max(0,e-window.innerHeight);window.scrollTo({top:r,behavior:t})}l&&console.log("[useScroll] scrolled to the active bottom"),R(t)}else l&&console.log("[useScroll] no scroll element detected")}),[l,R,u,s,i,g,c]),E=r(((e={})=>{p(),f.current=requestAnimationFrame((()=>{f.current=null,L(e)}))}),[p,L]),C=r(((e={})=>{var r;if(!e.force&&u.current)return;const t=i.current;if(!t)return void(l&&console.log("[useScroll] scroll target not detected"));const o=null!==(r=e.behavior)&&void 0!==r?r:c?"smooth":"auto",n=t.getBoundingClientRect().bottom+window.scrollY,s=Math.max(0,n-500);S.current=!0,g(!0),window.scrollTo({top:s,behavior:o}),l&&console.log("[useScroll] scrolled to the form response"),R(o)}),[l,R,u,i,g,c]),H=r(((e={})=>{p(),f.current=requestAnimationFrame((()=>{f.current=null,C(e)}))}),[p,C]),I=r((()=>{u.current=!1,h(!0),m(!0)}),[u,h,m]),B=r((()=>{m(!1)}),[m]),x=r(((e={})=>E(e)),[E]),M=r(((e={})=>H(e)),[H]);return t((()=>{if(!n||!d||!a)return;let e=s.current,r=i.current,t=null,o=[];const l=()=>{var o;if(!t)return;const n=e?e.scrollHeight:null!==(o=null==r?void 0:r.getBoundingClientRect().height)&&void 0!==o?o:0,l=n>T.current;T.current=n,b(l),l&&(e?E({behavior:"auto"}):H({behavior:"auto"}))},c=new ResizeObserver(l);function u(){t&&(o.forEach((e=>c.unobserve(e))),o=[t,...Array.from(t.children)],o.forEach((e=>c.observe(e))))}const v=new MutationObserver((()=>{u(),l()}));let h=null;const m=()=>{var o;e=s.current,r=i.current;const n=null!=e?e:r;return!(!n||n===t)&&(v.disconnect(),c.disconnect(),t=n,T.current=e?e.scrollHeight:null!==(o=null==r?void 0:r.getBoundingClientRect().height)&&void 0!==o?o:0,u(),v.observe(t,{childList:!0,subtree:!0}),e?E({behavior:"auto"}):H({behavior:"auto"}),!0)};return m()||(h=new MutationObserver((()=>{m()&&(null==h||h.disconnect())})),h.observe(document.body,{childList:!0,subtree:!0})),()=>{null==h||h.disconnect(),v.disconnect(),c.disconnect()}}),[n,a,d,E,H,s,i,b]),t((()=>{a&&(u.current=!1)}),[u,a]),t((()=>{const e=s.current,r=null!=e?e:window,t=()=>{if(S.current)return;const r=(()=>{if(e)return e.scrollHeight-e.scrollTop-e.clientHeight<=32;const r=i.current;return!r||r.getBoundingClientRect().bottom-window.innerHeight<=32})();u.current=!r,h(r)},o=()=>{S.current&&(S.current=!1,g(!1),w.current&&(clearTimeout(w.current),w.current=null),e?e.scrollTo({top:e.scrollTop,behavior:"auto"}):window.scrollTo({top:window.scrollY,behavior:"auto"}))};return r.addEventListener("scroll",t,{passive:!0}),r.addEventListener("wheel",o,{passive:!0}),r.addEventListener("touchmove",o,{passive:!0}),()=>{r.removeEventListener("scroll",t),r.removeEventListener("wheel",o),r.removeEventListener("touchmove",o)}}),[u,s,i,h,g]),t((()=>()=>{p(),w.current&&clearTimeout(w.current)}),[p]),{scrollContainerRef:s,scrollTargetRef:i,isScrollIncreasing:v,scrollStartSession:I,scrollEndSession:B,scrollToBottom:x,scrollToTarget:M}};export{n as useScroll};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as
|
|
1
|
+
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as t,jsx as o,Fragment as i}from"react/jsx-runtime";import{useState as r,useRef as n,useEffect as s,useCallback as a}from"react";import{usePickaxeContext as l}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as c}from"../Addons/Auth/hooks/useAuthContext.js";import{useDimensionContext as d}from"../../../hooks/pickaxe/useDimensionContext.js";import{useDocument as m}from"../Addons/Document/hooks/useDocument.js";import{useScrollContext as u}from"../Addons/Scroll/hooks/useScrollContext.js";import{useStyleFontSize as h}from"../../../hooks/studio/useStyleFontSize.js";import f from"../../../hooks/core/useScrollToBottomVisibility.js";import p from"./History/index.js";import v from"./Input.js";import g from"../../Icons/attach-vertical.svg.js";import x from"../../../common/cn.js";import{pickaxeApi2 as b}from"../../../common/api/pickaxe.js";import{v4 as k}from"uuid";import{StudioTip as j}from"../../Core/StudioTip.js";import y from"../common/ScrollToBottomButton.js";import{useResponseContext as I}from"../../../hooks/pickaxe/useResponseContext.js";import{NavPill as w,EditableNavPill as D,HistoryPill as C}from"../Addons/Navbar/NavPill.js";import S from"../../Icons/history.svg.js";const N=()=>{var N,T;const{deploymentType:A,isNewChat:F,setIsNewChat:O,sessionId:P,setSessionId:H,setLastSessionId:R,pickaxeId:z,sender:B,pickaxe:E,styles:L,isEmbed:G,translations:V}=l(),{isSent:_}=c(),{width:q,height:M,setDimension:U}=d(),{setDocuments:W,onFileUpload:J}=m(),{scrollContainerRef:K,hasScrolledRef:Q,isLocked:X,setIsLocked:Y}=u(),{isGenerating:Z,messages:$}=I(),ee=h(),[te,oe]=r(0),[ie,re]=r(!1),[ne,se]=r(!1),ae=n(null),le=n(null),ce=n(0),[de,me]=r(null),[ue,he]=r(!1),fe=(null==V?void 0:V["new-chat"])||"New chat",pe="chat-input"===A&&F&&!_,ve=null!==(T=null===(N=null==E?void 0:E.documentuploadtype)||void 0===N?void 0:N.startsWith("enduserupload"))&&void 0!==T&&T,{hasScrollableContent:ge,isNearBottom:xe}=f(K);s((()=>()=>{W([])}),[]);const be=a((()=>{if(!z||!B)return;const t=(o=0)=>e(void 0,void 0,void 0,(function*(){var e;try{const t=yield b.post("/conversation/title",{sessionId:P,userId:B});if(t.data&&t.data.success){const e=t.data.title;if(e&&"Conversation Title"!==e)return void je(e)}else console.error("Failed to load conversation:",null===(e=t.data)||void 0===e?void 0:e.error)}catch(e){console.error("Error fetching conversation:",e)}o<20&&setTimeout((()=>t(o+1)),3e3)}));t()}),[z,B,P]);s((()=>{Z||F||!P||be()}),[Z,F,P,be]),s((()=>{if(!ae.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:o}=t.contentRect;U(parseInt(e.toFixed(0)),parseInt(o.toFixed(0)))}}));return e.observe(ae.current),()=>{e.disconnect()}}),[U]);const[ke,je]=r(fe),ye=(null==E?void 0:E.formtitle)||"Pickaxe",Ie=(null==E?void 0:E.coverphoto)||void 0,[we,De]=r(!1);s((()=>{const e=!pe&&!G&&L.portalTheme&&($.filter((e=>"user"===e.role)).length>0||ie||!F);De(null!=e&&e)}),[pe,G,ie,F,$,L.portalTheme]);const Ce=a((()=>{Q.current=!1,Y(!0),requestAnimationFrame((()=>{const e=K.current;e&&e.scrollTo({top:Math.max(0,e.scrollHeight-e.clientHeight),behavior:"smooth"})}))}),[Q,K,Y]);return t("div",Object.assign({ref:ae,className:"relative flex h-full w-full flex-col items-center overflow-hidden",onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),ve&&(ce.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&se(!0))},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),ve&&(ce.current-=1,0===ce.current&&se(!1))},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:t=>e(void 0,void 0,void 0,(function*(){if(t.preventDefault(),t.stopPropagation(),se(!1),ce.current=0,!ve)return;const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(O(!1),yield J(e))}))},{children:[ne&&t("div",Object.assign({className:"absolute inset-0 z-50 flex flex-col items-center justify-center rounded-lg bg-white/80 backdrop-blur-sm transition-all duration-300"},{children:[o("div",Object.assign({className:"flex h-24 w-24 items-center justify-center rounded-full bg-white shadow-lg animate-bounce text-black"},{children:o(g,{className:"h-10 w-10"})})),o("h3",Object.assign({className:x(ee.h3,"mt-6 font-semibold text-c-primary text-black")},{children:(null==V?void 0:V["drop-files-to-upload"])||"Drop files to upload"})),o("p",Object.assign({className:x(ee.b2,"mt-2 opacity-60 text-black")},{children:(null==V?void 0:V["add-anything-to-the-conversation"])||"Add anything to the conversation"}))]})),pe?o(v,{}):t(i,{children:[we&&t("div",Object.assign({className:x("direct-link"===A?"absolute top-4 left-4 md:top-6 md:left-6 z-40 flex items-center gap-2 animate-in fade-in slide-in-from-top-4 duration-500":"w-full max-w-3xl mt-6 px-4 md:px-0 flex justify-start z-30 mb-4 animate-in fade-in slide-in-from-top-4 duration-500 gap-2","dark"===L.portalTheme?"glass-dark ":"")},{children:[o(w,{text:ye,icon:Ie}),F||ke===fe?o(w,{text:ke}):o(D,{text:ke,sessionId:P,onRename:t=>e(void 0,void 0,void 0,(function*(){if(P)try{yield b.patch("/conversation/title",{sessionId:P,name:t,userId:B}),je(t)}catch(e){console.error("Error renaming chat:",e),alert((null==V?void 0:V["failed-rename-chat"])||"Failed to rename chat.")}})),onDelete:()=>e(void 0,void 0,void 0,(function*(){if(P&&window.confirm((null==V?void 0:V["delete-confirm"])||"Are you sure you want to delete this conversation?"))try{yield b.delete("/conversation",{data:{sessionId:P,userId:B}}),O(!0),H(k()),je(fe)}catch(e){console.error("Error deleting chat:",e),alert((null==V?void 0:V["failed-delete-chat"])||"Failed to delete chat.")}})),isDarkGlass:"dark"===L.portalTheme}),o(j,Object.assign({content:V["chat-history"]||"Chat History",align:"bottom",containerClassName:"inline-flex shrink-0"},{children:o(C,{icon:o(S,{}),onClick:()=>{H(""),R(P)}})}))]})),o(p,{additionalScrollHeight:te,isForceHideInfo:M<=545||q<=350||ie,isInputFocused:ie,onSubmit:t=>e(void 0,void 0,void 0,(function*(){le.current&&le.current.onSubmit(t)})),smitheryAuthData:de,resubmitPrompt:()=>{me(null),he(!0)}}),o(y,{isVisible:ge&&!X&&!xe,bottom:te+65,onClick:Ce}),o(v,{ref:le,onFocus:()=>re(!0),onBlur:()=>re(!1),onInputHeightChange:oe,initSmitheryAuthData:e=>me(e),resubmitPrompt:ue})]})]}))};export{N as default};
|
|
@@ -4,13 +4,17 @@ interface UseScrollProps {
|
|
|
4
4
|
debug?: boolean;
|
|
5
5
|
smooth?: boolean;
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
interface ScrollOptions {
|
|
8
|
+
behavior?: ScrollBehavior;
|
|
9
|
+
force?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const useScroll: ({ auto, debug, smooth, }: UseScrollProps) => {
|
|
8
12
|
scrollContainerRef: import("react").MutableRefObject<HTMLDivElement>;
|
|
9
13
|
scrollTargetRef: import("react").MutableRefObject<HTMLDivElement>;
|
|
10
14
|
isScrollIncreasing: boolean;
|
|
11
15
|
scrollStartSession: () => void;
|
|
12
16
|
scrollEndSession: () => void;
|
|
13
|
-
scrollToBottom: () => void;
|
|
14
|
-
scrollToTarget: () => void;
|
|
17
|
+
scrollToBottom: (options?: ScrollOptions) => void;
|
|
18
|
+
scrollToTarget: (options?: ScrollOptions) => void;
|
|
15
19
|
};
|
|
16
20
|
export {};
|