@pickaxeproject/react 1.1.0 → 1.1.2
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/Chat/History/index.js +1 -1
- package/dist/cjs/components/Pickaxe/Chat/Input.js +1 -1
- package/dist/cjs/components/Pickaxe/Provider.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeCompactHead.js +1 -0
- package/dist/cjs/src/components/Pickaxe/Provider.d.ts +5 -1
- package/dist/cjs/src/components/Pickaxe/common/PickaxeCompactHead.d.ts +6 -0
- package/dist/cjs/src/hooks/pickaxe/usePickaxeContext.d.ts +2 -0
- package/dist/esm/components/Pickaxe/Chat/History/index.js +1 -1
- package/dist/esm/components/Pickaxe/Chat/Input.js +1 -1
- package/dist/esm/components/Pickaxe/Provider.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeCompactHead.js +1 -0
- package/dist/esm/src/components/Pickaxe/Provider.d.ts +5 -1
- package/dist/esm/src/components/Pickaxe/common/PickaxeCompactHead.d.ts +6 -0
- package/dist/esm/src/hooks/pickaxe/usePickaxeContext.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),a=require("../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("../../../../hooks/pickaxe/useResponseContext.js"),r=require("../../../../hooks/studio/useStyleFontSize.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),a=require("../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("../../../../hooks/pickaxe/useResponseContext.js"),r=require("../../../../hooks/studio/useStyleFontSize.js"),o=require("../../../../hooks/pickaxe/useConversation.js"),n=require("../../../../hooks/core/useDebounce.js"),l=require("../../common/PickaxeIcon.js"),i=require("../../../Core/ErrorAlert.js"),c=require("../../Addons/Scroll/ScrollLockView.js"),d=require("../../common/PickaxeHead.js"),u=require("../../common/PickaxeCompactHead.js"),x=require("../../common/PickaxeInfoModal.js"),m=require("../../common/PickaxeUpgradeCard.js"),f=require("./Message.js"),j=require("../../../../common/cn.js");exports.default=()=>{var g;const p=o.useConversation(),h=r.useStyleFontSize(),{pickaxe:b,styles:k,colors:v,responsiveBy:E,isNewChat:w,setChatId:y,isEmbed:C}=a.usePickaxeContext(),{messages:N,status:O,limitData:q,error:S}=t.useResponseContext(),[B,P]=s.useState(!1),[F,R]=s.useState(!1),I=s.useRef(null),M=s.useRef(null),z=s.useRef(null),T=s.useMemo((()=>!!p.data&&!(p.data.messages.length<=1)),[p.data]),D=s.useMemo((()=>p.isSuccess&&w&&!T),[p.isSuccess,w,T]),H=n.useDebounce((()=>{L()}),200),L=s.useCallback((()=>{if(!I.current||!z.current)return;const e=I.current.getBoundingClientRect(),s=z.current.getBoundingClientRect().top-e.top;R(s<=210)}),[]);return s.useEffect((()=>{if(!I.current||!z.current)return;const e=new ResizeObserver((()=>{H()}));return e.observe(I.current),e.observe(z.current),()=>{e.disconnect()}}),[]),e.jsxs("div",Object.assign({ref:I,className:j.default("relative flex flex-grow flex-col",!C||!F&&D?"justify-end":"justify-between gap-y-4")},{children:[B&&e.jsx(x.default,{isOpen:B,onChangeIsOpen:P}),!C||!F&&D?e.jsx("div",Object.assign({ref:M,className:j.default("absolute left-1/2 top-0 flex w-full max-w-[550px] -translate-x-1/2 -translate-y-1/3 transform flex-col items-center px-4 opacity-0 duration-300",D&&!F&&"top-1/4 opacity-100")},{children:e.jsx(d.default,{iconClassName:"duration-300 hover:opacity-90",maxLines:2,onIconClick:()=>y("")})})):e.jsx(u.default,{}),e.jsx("div",Object.assign({ref:z,className:"pxe-messages-container flex w-full justify-center"},{children:p.isLoading?e.jsxs("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[e.jsx("div",{className:"h-10 w-[70%] animate-pulse justify-self-end rounded bg-[#E5E7EB] dark:bg-[#1E1E1F]",style:{backgroundColor:"dark"===k.theme?"#1E1E1F":"#E5E7EB"}}),e.jsx("div",{className:"h-[150px] w-[70%] animate-pulse rounded bg-[#E5E7EB] dark:bg-[#1E1E1F]",style:{backgroundColor:"dark"===k.theme?"#1E1E1F":"#E5E7EB"}}),e.jsx("div",{className:"h-10 w-[50%] animate-pulse justify-self-end rounded bg-[#E5E7EB] dark:bg-[#1E1E1F]",style:{backgroundColor:"dark"===k.theme?"#1E1E1F":"#E5E7EB"}})]})):p.isError?e.jsx("div",Object.assign({className:"flex w-full max-w-[800px] justify-center pt-10"},{children:e.jsxs("p",Object.assign({className:j.default(h.b2,"text-center font-semibold")},{children:["Something went wrong. Please try again, or"," ",e.jsx("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:"contact us"}))," ","for help."]}))})):e.jsxs("div",Object.assign({className:"flex flex-col w-full"},{children:[e.jsxs("div",Object.assign({className:j.default("relative grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-4 pt-6","viewport"===E?"min-[767px]:pt-10":"@[767px]/pickaxe-root:pt-10")},{children:[p.data.messages.map(((s,a)=>e.jsx(f.default,{index:a,message:s},a))),N.map(((s,a)=>e.jsx(f.default,{index:p.data.messages.length+a,message:s},a))),"fetching"===O?e.jsxs("div",Object.assign({className:"flex max-w-[80%] items-center gap-x-3"},{children:["NONE"!==(null==b?void 0:b.chaticon)&&e.jsx(l.default,{src:null!==(g=null==b?void 0:b.chaticon)&&void 0!==g?g:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/chaticons/${null==b?void 0:b.formid}.png`,alt:`${null==b?void 0:b.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6",textColor:v.text}),e.jsxs("div",Object.assign({className:"flex items-center gap-x-2 rounded px-4 py-4",style:{backgroundColor:v.secondary+"80",color:v.secondaryText}},{children:[e.jsx("div",{className:"h-1.5 w-1.5 animate-dot rounded-full",style:{backgroundColor:v.secondaryText}}),e.jsx("div",{className:"h-1.5 w-1.5 animate-dot-down rounded-full",style:{backgroundColor:v.secondaryText}}),e.jsx("div",{className:"h-1.5 w-1.5 animate-dot rounded-full",style:{backgroundColor:v.secondaryText}})]}))]})):q?e.jsx("div",Object.assign({className:"flex max-w-[80%] items-center gap-x-3"},{children:e.jsx(m.default,{})})):S?e.jsx("div",Object.assign({className:"flex max-w-[80%] items-center gap-x-3"},{children:e.jsx(i.default,{error:S})})):null]})),e.jsx(c.default,{className:"w-full"})]}))}))]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),o=require("../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../../../hooks/pickaxe/useResponseContext.js"),i=require("../../../hooks/pickaxe/useDimensionContext.js"),n=require("../../../hooks/studio/useStyleInput.js"),a=require("../../../hooks/studio/useStyleFontSize.js"),l=require("../../../hooks/pickaxe/useConversation.js"),d=require("../../../hooks/pickaxe/useSubmit.js"),c=require("../../../hooks/pickaxe/useSubmitResult.js"),u=require("../../../common/documents.js"),m=require("../../../common/api/streamer.js"),p=require("../Addons/Document/hooks/useDocument.js"),x=require("../Addons/Scroll/hooks/useScroll.js"),f=require("../../../hooks/core/useHover.js"),b=require("../../../common/utils.js"),g=require("../../Icons/attach-vertical.svg.js"),h=require("../../Icons/spinner-lines.svg.js"),j=require("../../Icons/file.svg.js"),v=require("../../Icons/x.svg.js"),y=require("../../Icons/arrow-right.svg.js"),k=require("../common/PickaxeBranding.js"),w=require("../Addons/IceBreaker/index.js"),I=require("react-textarea-autosize"),O=require("../../../common/error.js"),C=require("../../../common/cn.js");function N(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var q=N(I);exports.default=()=>{var I;const{formId:N,chatId:S,userId:R,studioUserId:D,deploymentId:A,pickaxe:_,styles:T,colors:U,misc:H,responsiveBy:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),o=require("../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../../../hooks/pickaxe/useResponseContext.js"),i=require("../../../hooks/pickaxe/useDimensionContext.js"),n=require("../../../hooks/studio/useStyleInput.js"),a=require("../../../hooks/studio/useStyleFontSize.js"),l=require("../../../hooks/pickaxe/useConversation.js"),d=require("../../../hooks/pickaxe/useSubmit.js"),c=require("../../../hooks/pickaxe/useSubmitResult.js"),u=require("../../../common/documents.js"),m=require("../../../common/api/streamer.js"),p=require("../Addons/Document/hooks/useDocument.js"),x=require("../Addons/Scroll/hooks/useScroll.js"),f=require("../../../hooks/core/useHover.js"),b=require("../../../common/utils.js"),g=require("../../Icons/attach-vertical.svg.js"),h=require("../../Icons/spinner-lines.svg.js"),j=require("../../Icons/file.svg.js"),v=require("../../Icons/x.svg.js"),y=require("../../Icons/arrow-right.svg.js"),k=require("../common/PickaxeBranding.js"),w=require("../Addons/IceBreaker/index.js"),I=require("react-textarea-autosize"),O=require("../../../common/error.js"),C=require("../../../common/cn.js");function N(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var q=N(I);exports.default=()=>{var I;const{formId:N,chatId:S,userId:R,studioUserId:D,deploymentId:A,pickaxe:_,styles:T,colors:U,misc:E,chatInput:H,responsiveBy:M,forceMobile:z,isNewChat:B,setIsNewChat:F,setIsShowIceBreaker:L,onGenerateComplete:P}=o.usePickaxeContext(),{messages:W,status:$,limits:G,setMessages:K,setStatus:J,setLimitData:Q,setError:V,setIsGenerating:X}=r.useResponseContext(),{isMobile:Y}=i.useDimensionContext(),{documents:Z,isUploading:ee,isImageUploadAllowed:se,upsertDocuments:te,onFileUpload:oe}=p.useDocument(),{scrollStartSession:re,scrollEndSession:ie,scrollToBottom:ne}=x.useScroll({auto:!0}),ae=l.useConversation(),le=d.useSubmit(),de=c.useSubmitResult(),ce=a.useStyleFontSize(),ue=n.useStyleInput(),[me,pe]=t.useState(H),xe=t.useRef(null),fe=f.useHover(),{isHover:be}=fe,ge=e.__rest(fe,["isHover"]),he=f.useHover(),{isHover:je}=he,ve=e.__rest(he,["isHover"]),ye=t.useMemo((()=>{var e,s,t;return!!B&&(!!_&&(!ae.isLoading&&(!((null!==(s=null===(e=ae.data)||void 0===e?void 0:e.messages.length)&&void 0!==s?s:0)>1)&&!!(null===(t=_.icebreakers)||void 0===t?void 0:t.length))))}),[_,B,ae.data,ae.isLoading]),ke=s=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if(ee||"idle"!==$)return;const e=null!=s?s:me;if(!e)return;pe(""),V(""),Q(null),X(!0),F(!1);const t=new Date,o="enduserupload"===(null==_?void 0:_.documentuploadtype),r=Z.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),i=r.length?r[r.length-1].documentId:"";J("fetching"),re(),ne();const n=Array.from(W);let a=[...n,{id:W.length+1,role:"user",content:e}];K(a),ne();const{success:l,data:d,actionData:c,usedDocumentIds:u,endUserDocumentId:p,endUserImageId:x,rawUserInput:f,error:b}=yield le.mutateAsync(Object.assign(Object.assign(Object.assign({formId:N,responseId:S,value:e},o&&i&&{documentId:i}),D&&{studioUserId:D}),A&&{deploymentId:A}));if(!l)throw new Error(null!=b?b:"An error occurred, please try again.");const g=[];p&&g.push(p),x&&g.push(x),g.length>0&&(a=[...n,Object.assign({id:W.length+1,role:"user",content:e},g&&{documentIds:g})],K(a),ne()),te([]),ne();const h=(yield m.streamer({formId:N,responseId:S,data:d,actionData:c})).body;if(!h)throw new Error("Streaming error");const j=h.getReader(),v=new TextDecoder,y=a.length;let k="",w=!0,I=!1;for(;w;){const{value:e,done:s}=yield j.read();w=!s;if(k+=v.decode(e),k)K([...a.slice(0,y),{id:W.length+1,role:"assistant",content:k}]),I||(J("streaming"),I=!0);else if(!w&&!k)throw new Error("Server error")}const O=new Date;k&&(ne(),J("idle"),yield de.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:N,responseId:S,documentIds:u},R&&{userId:R}),D&&{studioUserId:D}),D&&(null==_?void 0:_.studioid)&&{studioId:_.studioid}),A&&{deploymentId:A}),{messages:[Object.assign(Object.assign({role:"user",message:f},g&&{documentIds:g}),{sentAt:t}),{role:"assistant",message:k,sentAt:O}]})),null==P||P(S))}catch(e){let s=O.default(e)||"";s&&!s.includes("Unexpected token 'A',")||(s="Oops! We're experiencing high traffic at the moment. Please try again later.");const t=Object.entries(G).find((([e])=>s.includes(e)));t?Q(t[1]):V(s),ne()}finally{J("idle"),X(!1),ie()}}));return t.useEffect((()=>{L(ye)}),[ye]),t.useEffect((()=>{pe(H)}),[H]),s.jsxs("div",Object.assign({className:C.default("fixed flex w-full flex-col bottom-0 left-0","viewport"===M?"min-[767px]:relative min-[767px]:bottom-auto min-[767px]:left-auto":"absolute @[767px]/pickaxe-root:relative @[767px]/pickaxe-root:bottom-auto @[767px]/pickaxe-root:left-auto")},{children:[!E.isWhiteLabel&&s.jsx("div",Object.assign({className:"flex justify-end pr-3 pb-3 @[767px]/pickaxe-root:pr-0"},{children:s.jsx(k.default,{animateHover:!0})})),ye&&s.jsx(w.default,{data:(null==_?void 0:_.icebreakers)||[],onSend:ke}),s.jsxs("div",Object.assign({id:(null==_?void 0:_.formid)+"--chat-parent",style:Object.assign(Object.assign({},ue),(Y||z)&&{paddingLeft:"0.75rem",paddingRight:"0.75rem"}),className:C.default("flex min-h-[56px] flex-col gap-y-2 px-4 py-3 pb-[15px]","block"===T.formFieldStyle&&"shadow")},{children:["idle"===$&&Z.length>0&&s.jsx("div",Object.assign({className:C.default("grid grid-cols-1","viewport"===M?"min-[765px]:grid-cols-2":"@[767px]/pickaxe-root:grid-cols-2")},{children:Z.map((e=>{var o,r,i;return s.jsx(t.Fragment,{children:"document"===e.type?s.jsxs("div",Object.assign({className:"relative gap-x-[10px] flex items-center px-2 h-[56px] border",style:{borderRadius:ue.borderRadius,borderColor:U.secondaryText+"50"}},{children:[s.jsx("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:U.accent,borderRadius:ue.borderRadius}},{children:ee?s.jsx(h.default,{className:"w-5 h-5 animate-spin",style:{color:U.accentText}}):s.jsx(j.default,{className:"w-5 h-5",style:{color:U.accentText}})})),s.jsxs("div",Object.assign({className:"flex flex-col justify-center truncate"},{children:[s.jsx("p",Object.assign({className:(C.default(ce.b3),"font-medium truncate")},{children:e.name})),s.jsx("p",Object.assign({className:C.default(ce.b4,"opacity-80 truncate")},{children:b.formatBytes(e.size)}))]})),s.jsx("button",Object.assign({type:"button",disabled:ee||"idle"!==$,onClick:()=>te([]),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:U.accent,borderColor:ue.backgroundColor}},{children:s.jsx(v.default,{className:"w-4 h-4",style:{color:U.accentText}})}))]})):"image"===e.type?s.jsxs("div",Object.assign({className:"relative h-[56px] w-[56px] bg-stone-100",style:{borderRadius:ue.borderRadius}},{children:["finished"===e.status?s.jsx("img",{style:{borderRadius:ue.borderRadius},className:"object-cover w-full h-full",src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${null===(o=e.documentId)||void 0===o?void 0:o.split("-")[2]}/${null===(r=e.documentId)||void 0===r?void 0:r.split("-")[1]}.${null===(i=e.documentId)||void 0===i?void 0:i.split("-")[2]}`,alt:""}):s.jsx("div",{className:"h-full w-full animate-pulse",style:{borderRadius:ue.borderRadius,backgroundColor:U.secondary}}),s.jsx("button",Object.assign({type:"button",disabled:ee||"idle"!==$,onClick:()=>te([]),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:U.accent,borderColor:ue.backgroundColor}},{children:s.jsx(v.default,{className:"w-4 h-4",style:{color:U.accentText}})}))]})):null},e.id)}))})),s.jsxs("div",Object.assign({className:"flex items-end gap-x-2 grow"},{children:[s.jsx(q.default,{id:(null==_?void 0:_.formid)+"--chat-textarea",className:C.default(ce.b2,"max-h-60 mb-[0.2em] w-full resize-none border-transparent bg-transparent outline-none ring-0 scrollbar scrollbar-thin placeholder:text-inherit placeholder:opacity-50",!me.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap"),value:me,placeholder:null!==(I=null==_?void 0:_.placeholdertext)&&void 0!==I?I:"What do you want to talk about?",onChange:e=>pe(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),ee||"idle"!==$||ke()))}}),s.jsxs("div",Object.assign({className:"flex items-center gap-x-2"},{children:["enduserupload"===(null==_?void 0:_.documentuploadtype)&&s.jsxs("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full transition-colors duration-200 ease-in-out",style:{backgroundColor:je?U.accent+"10":void 0},disabled:ee||"idle"!==$,onClick:()=>{var e;return null===(e=xe.current)||void 0===e?void 0:e.click()}},ve,{children:[s.jsx("input",{id:"file-upload",ref:xe,type:"file",accept:[...u.allowedFileMimeTypes,...se?u.allowedImageMimeTypes:[]].join(", "),multiple:!1,hidden:!0,className:"hidden",onChange:s=>e.__awaiter(void 0,void 0,void 0,(function*(){yield oe(Array.from(s.target.files||[])),s.target.value=""}))}),s.jsx(g.default,{className:"h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",style:{color:je?U.accent:U.accent+"80"}})]})),s.jsx("button",Object.assign({id:(null==_?void 0:_.formid)+"--chat-button",className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full duration-200 transition-colors ease-in-out",style:{backgroundColor:be?U.accent:U.accent+"10"},disabled:ee||"idle"!==$,onClick:()=>ke()},ge,{children:s.jsx(y.default,{className:"h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",style:{color:be?U.accentText:U.accent}})}))]}))]}))]}))]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),s=require("./Addons/Document/Provider.js"),i=require("./ResponseProvider.js"),r=require("./DimensionProvider.js");const o=t.createContext({});exports.PickaxeContext=o,exports.PickaxeProvider=({children:a,userId:n="",studioUserId:d="",deploymentId:c="",styles:l,colors:u,limits:h={},misc:F={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:m,chatInput:p="",responsiveBy:I="viewport",loadFont:x=!0,forceMobile:y=!1,isEmbed:f=!1,onGenerateComplete:g})=>{const[j,S]=t.useState(""),[b,v]=t.useState(""),[P,w]=t.useState(null),[C,k]=t.useState(!1),[O,q]=t.useState(!0),[D,B]=t.useState(!0),[E,H]=t.useState(!1);return t.useEffect((()=>{k(!1)}),[null==l?void 0:l.font]),e.jsx(o.Provider,Object.assign({value:Object.assign({formId:j,chatId:b,userId:n,studioUserId:d,deploymentId:c,pickaxe:P,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},l),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},u),misc:F,translations:Object.assign({"new-chat":"New chat","see-history":"See history",processing:"Processing...",uploading:"Uploading...",loading:"Loading..."},m),chatInput:p,responsiveBy:I,isFontLoaded:C,isNewChat:O,isShowIceBreaker:D,isShowHistory:E,loadFont:x,forceMobile:y,isEmbed:f,setIsFontLoaded:k,setFormId:S,setChatId:v,setPickaxe:w,setIsNewChat:q,setIsShowIceBreaker:B,setIsShowHistory:H},g&&{onGenerateComplete:g})},{children:e.jsx(i.default,Object.assign({limits:h},{children:e.jsx(r.default,{children:e.jsx(s.default,{children:a})})}))}))};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),i=require("../../../hooks/pickaxe/usePickaxeContext.js"),s=require("../../../hooks/studio/useStyleFontSize.js"),r=require("../../../common/cn.js"),o=require("./PickaxeIcon.js");exports.default=({iconClassName:l,onIconClick:c})=>{const{pickaxe:u,misc:a}=i.usePickaxeContext(),n=s.useStyleFontSize(),x=t.useMemo((()=>({title:(null==u?void 0:u.formtitle)||""})),[u]);return e.jsxs("div",Object.assign({className:"flex h-[56px] items-center gap-x-4 px-4"},{children:[a.isProfileImage&&e.jsx(o.default,Object.assign({src:null==u?void 0:u.coverphoto,alt:`${null==u?void 0:u.formtitle}'s Profile Picture`,width:32,height:32,className:r.default("shrink-0 h-[32px] w-[32px] rounded-full",l,!!c&&"cursor-pointer")},c&&{onClick:c})),a.isTitle&&e.jsx("p",Object.assign({className:r.default(n.b1,"truncate")},{children:x.title}))]}))};
|
|
@@ -43,6 +43,7 @@ type PickaxeContextType = {
|
|
|
43
43
|
styles: PickaxeProviderStyles;
|
|
44
44
|
colors: PickaxeProviderColors;
|
|
45
45
|
misc: PickaxeMisc;
|
|
46
|
+
chatInput: string;
|
|
46
47
|
translations: PickaxeTranslations;
|
|
47
48
|
responsiveBy: PickaxeResponsiveBy;
|
|
48
49
|
isFontLoaded: boolean;
|
|
@@ -51,6 +52,7 @@ type PickaxeContextType = {
|
|
|
51
52
|
isShowHistory: boolean;
|
|
52
53
|
loadFont: boolean;
|
|
53
54
|
forceMobile: boolean;
|
|
55
|
+
isEmbed: boolean;
|
|
54
56
|
setFormId: SetState<string>;
|
|
55
57
|
setChatId: SetState<string>;
|
|
56
58
|
setPickaxe: SetState<Pickaxe | null>;
|
|
@@ -70,11 +72,13 @@ export interface IPickaxeProviderProps {
|
|
|
70
72
|
limits?: Record<string, PickaxeLimitData>;
|
|
71
73
|
misc?: PickaxeMisc;
|
|
72
74
|
translations?: PickaxeTranslations;
|
|
75
|
+
chatInput?: string;
|
|
73
76
|
responsiveBy?: PickaxeResponsiveBy;
|
|
74
77
|
loadFont?: boolean;
|
|
75
78
|
forceMobile?: boolean;
|
|
79
|
+
isEmbed?: boolean;
|
|
76
80
|
onGenerateComplete?: (responseId: string) => void;
|
|
77
81
|
}
|
|
78
82
|
export declare const PickaxeContext: import("react").Context<PickaxeContextType>;
|
|
79
|
-
export declare const PickaxeProvider: ({ children, userId, studioUserId, deploymentId, styles, colors, limits, misc, translations, responsiveBy, loadFont, forceMobile, onGenerateComplete, }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
83
|
+
export declare const PickaxeProvider: ({ children, userId, studioUserId, deploymentId, styles, colors, limits, misc, translations, chatInput, responsiveBy, loadFont, forceMobile, isEmbed, onGenerateComplete, }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
80
84
|
export {};
|
|
@@ -8,6 +8,7 @@ export declare const usePickaxeContext: () => {
|
|
|
8
8
|
styles: import("../../components/Pickaxe/Provider").PickaxeProviderStyles;
|
|
9
9
|
colors: import("../../components/Pickaxe/Provider").PickaxeProviderColors;
|
|
10
10
|
misc: import("../../components/Pickaxe/Provider").PickaxeMisc;
|
|
11
|
+
chatInput: string;
|
|
11
12
|
translations: import("../../components/Pickaxe/Provider").PickaxeTranslations;
|
|
12
13
|
responsiveBy: import("../../components/Pickaxe/Provider").PickaxeResponsiveBy;
|
|
13
14
|
isFontLoaded: boolean;
|
|
@@ -16,6 +17,7 @@ export declare const usePickaxeContext: () => {
|
|
|
16
17
|
isShowHistory: boolean;
|
|
17
18
|
loadFont: boolean;
|
|
18
19
|
forceMobile: boolean;
|
|
20
|
+
isEmbed: boolean;
|
|
19
21
|
setFormId: import("../../types/common").SetState<string>;
|
|
20
22
|
setChatId: import("../../types/common").SetState<string>;
|
|
21
23
|
setPickaxe: import("../../types/common").SetState<import("../../types/pickaxe").Pickaxe | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as s}from"react/jsx-runtime";import{useState as a,useRef as o,useMemo as t,useCallback as r,useEffect as n}from"react";import{usePickaxeContext as i}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as
|
|
1
|
+
import{jsxs as e,jsx as s}from"react/jsx-runtime";import{useState as a,useRef as o,useMemo as t,useCallback as r,useEffect as n}from"react";import{usePickaxeContext as i}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as c}from"../../../../hooks/pickaxe/useResponseContext.js";import{useStyleFontSize as l}from"../../../../hooks/studio/useStyleFontSize.js";import{useConversation as m}from"../../../../hooks/pickaxe/useConversation.js";import{useDebounce as d}from"../../../../hooks/core/useDebounce.js";import p from"../../common/PickaxeIcon.js";import u from"../../../Core/ErrorAlert.js";import f from"../../Addons/Scroll/ScrollLockView.js";import x from"../../common/PickaxeHead.js";import g from"../../common/PickaxeCompactHead.js";import h from"../../common/PickaxeInfoModal.js";import b from"../../common/PickaxeUpgradeCard.js";import j from"./Message.js";import k from"../../../../common/cn.js";const E=()=>{var E;const w=m(),v=l(),{pickaxe:y,styles:N,colors:C,responsiveBy:O,isNewChat:B,setChatId:F,isEmbed:P}=i(),{messages:S,status:I,limitData:R,error:T}=c(),[z,H]=a(!1),[L,A]=a(!1),D=o(null),M=o(null),$=o(null),U=t((()=>!!w.data&&!(w.data.messages.length<=1)),[w.data]),V=t((()=>w.isSuccess&&B&&!U),[w.isSuccess,B,U]),_=d((()=>{q()}),200),q=r((()=>{if(!D.current||!$.current)return;const e=D.current.getBoundingClientRect(),s=$.current.getBoundingClientRect().top-e.top;A(s<=210)}),[]);return n((()=>{if(!D.current||!$.current)return;const e=new ResizeObserver((()=>{_()}));return e.observe(D.current),e.observe($.current),()=>{e.disconnect()}}),[]),e("div",Object.assign({ref:D,className:k("relative flex flex-grow flex-col",!P||!L&&V?"justify-end":"justify-between gap-y-4")},{children:[z&&s(h,{isOpen:z,onChangeIsOpen:H}),!P||!L&&V?s("div",Object.assign({ref:M,className:k("absolute left-1/2 top-0 flex w-full max-w-[550px] -translate-x-1/2 -translate-y-1/3 transform flex-col items-center px-4 opacity-0 duration-300",V&&!L&&"top-1/4 opacity-100")},{children:s(x,{iconClassName:"duration-300 hover:opacity-90",maxLines:2,onIconClick:()=>F("")})})):s(g,{}),s("div",Object.assign({ref:$,className:"pxe-messages-container flex w-full justify-center"},{children:w.isLoading?e("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[s("div",{className:"h-10 w-[70%] animate-pulse justify-self-end rounded bg-[#E5E7EB] dark:bg-[#1E1E1F]",style:{backgroundColor:"dark"===N.theme?"#1E1E1F":"#E5E7EB"}}),s("div",{className:"h-[150px] w-[70%] animate-pulse rounded bg-[#E5E7EB] dark:bg-[#1E1E1F]",style:{backgroundColor:"dark"===N.theme?"#1E1E1F":"#E5E7EB"}}),s("div",{className:"h-10 w-[50%] animate-pulse justify-self-end rounded bg-[#E5E7EB] dark:bg-[#1E1E1F]",style:{backgroundColor:"dark"===N.theme?"#1E1E1F":"#E5E7EB"}})]})):w.isError?s("div",Object.assign({className:"flex w-full max-w-[800px] justify-center pt-10"},{children:e("p",Object.assign({className:k(v.b2,"text-center font-semibold")},{children:["Something went wrong. Please try again, or"," ",s("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:"contact us"}))," ","for help."]}))})):e("div",Object.assign({className:"flex flex-col w-full"},{children:[e("div",Object.assign({className:k("relative grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-4 pt-6","viewport"===O?"min-[767px]:pt-10":"@[767px]/pickaxe-root:pt-10")},{children:[w.data.messages.map(((e,a)=>s(j,{index:a,message:e},a))),S.map(((e,a)=>s(j,{index:w.data.messages.length+a,message:e},a))),"fetching"===I?e("div",Object.assign({className:"flex max-w-[80%] items-center gap-x-3"},{children:["NONE"!==(null==y?void 0:y.chaticon)&&s(p,{src:null!==(E=null==y?void 0:y.chaticon)&&void 0!==E?E:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/chaticons/${null==y?void 0:y.formid}.png`,alt:`${null==y?void 0:y.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6",textColor:C.text}),e("div",Object.assign({className:"flex items-center gap-x-2 rounded px-4 py-4",style:{backgroundColor:C.secondary+"80",color:C.secondaryText}},{children:[s("div",{className:"h-1.5 w-1.5 animate-dot rounded-full",style:{backgroundColor:C.secondaryText}}),s("div",{className:"h-1.5 w-1.5 animate-dot-down rounded-full",style:{backgroundColor:C.secondaryText}}),s("div",{className:"h-1.5 w-1.5 animate-dot rounded-full",style:{backgroundColor:C.secondaryText}})]}))]})):R?s("div",Object.assign({className:"flex max-w-[80%] items-center gap-x-3"},{children:s(b,{})})):T?s("div",Object.assign({className:"flex max-w-[80%] items-center gap-x-3"},{children:s(u,{error:T})})):null]})),s(f,{className:"w-full"})]}))}))]}))};export{E as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as e,__awaiter as t}from"../../../_virtual/_tslib.js";import{jsxs as o,jsx as s}from"react/jsx-runtime";import{useState as r,useRef as i,useMemo as n,useEffect as a,Fragment as l}from"react";import{usePickaxeContext as d}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as c}from"../../../hooks/pickaxe/useResponseContext.js";import{useDimensionContext as u}from"../../../hooks/pickaxe/useDimensionContext.js";import{useStyleInput as m}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as p}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as f}from"../../../hooks/pickaxe/useConversation.js";import{useSubmit as h}from"../../../hooks/pickaxe/useSubmit.js";import{useSubmitResult as g}from"../../../hooks/pickaxe/useSubmitResult.js";import{allowedFileMimeTypes as b,allowedImageMimeTypes as v}from"../../../common/documents.js";import{streamer as x}from"../../../common/api/streamer.js";import{useDocument as j}from"../Addons/Document/hooks/useDocument.js";import{useScroll as y}from"../Addons/Scroll/hooks/useScroll.js";import{useHover as k}from"../../../hooks/core/useHover.js";import{formatBytes as
|
|
1
|
+
import{__rest as e,__awaiter as t}from"../../../_virtual/_tslib.js";import{jsxs as o,jsx as s}from"react/jsx-runtime";import{useState as r,useRef as i,useMemo as n,useEffect as a,Fragment as l}from"react";import{usePickaxeContext as d}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as c}from"../../../hooks/pickaxe/useResponseContext.js";import{useDimensionContext as u}from"../../../hooks/pickaxe/useDimensionContext.js";import{useStyleInput as m}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as p}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as f}from"../../../hooks/pickaxe/useConversation.js";import{useSubmit as h}from"../../../hooks/pickaxe/useSubmit.js";import{useSubmitResult as g}from"../../../hooks/pickaxe/useSubmitResult.js";import{allowedFileMimeTypes as b,allowedImageMimeTypes as v}from"../../../common/documents.js";import{streamer as x}from"../../../common/api/streamer.js";import{useDocument as j}from"../Addons/Document/hooks/useDocument.js";import{useScroll as y}from"../Addons/Scroll/hooks/useScroll.js";import{useHover as k}from"../../../hooks/core/useHover.js";import{formatBytes as I}from"../../../common/utils.js";import w from"../../Icons/attach-vertical.svg.js";import O from"../../Icons/spinner-lines.svg.js";import N from"../../Icons/file.svg.js";import C from"../../Icons/x.svg.js";import S from"../../Icons/arrow-right.svg.js";import R from"../common/PickaxeBranding.js";import D from"../Addons/IceBreaker/index.js";import A from"react-textarea-autosize";import U from"../../../common/error.js";import T from"../../../common/cn.js";const E=()=>{var E;const{formId:H,chatId:z,userId:B,studioUserId:L,deploymentId:F,pickaxe:M,styles:P,colors:W,misc:$,chatInput:G,responsiveBy:K,forceMobile:_,isNewChat:q,setIsNewChat:J,setIsShowIceBreaker:Q,onGenerateComplete:V}=d(),{messages:X,status:Y,limits:Z,setMessages:ee,setStatus:te,setLimitData:oe,setError:se,setIsGenerating:re}=c(),{isMobile:ie}=u(),{documents:ne,isUploading:ae,isImageUploadAllowed:le,upsertDocuments:de,onFileUpload:ce}=j(),{scrollStartSession:ue,scrollEndSession:me,scrollToBottom:pe}=y({auto:!0}),fe=f(),he=h(),ge=g(),be=p(),ve=m(),[xe,je]=r(G),ye=i(null),ke=k(),{isHover:Ie}=ke,we=e(ke,["isHover"]),Oe=k(),{isHover:Ne}=Oe,Ce=e(Oe,["isHover"]),Se=n((()=>{var e,t,o;return!!q&&(!!M&&(!fe.isLoading&&(!((null!==(t=null===(e=fe.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&!!(null===(o=M.icebreakers)||void 0===o?void 0:o.length))))}),[M,q,fe.data,fe.isLoading]),Re=e=>t(void 0,void 0,void 0,(function*(){try{if(ae||"idle"!==Y)return;const t=null!=e?e:xe;if(!t)return;je(""),se(""),oe(null),re(!0),J(!1);const o=new Date,s="enduserupload"===(null==M?void 0:M.documentuploadtype),r=ne.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),i=r.length?r[r.length-1].documentId:"";te("fetching"),ue(),pe();const n=Array.from(X);let a=[...n,{id:X.length+1,role:"user",content:t}];ee(a),pe();const{success:l,data:d,actionData:c,usedDocumentIds:u,endUserDocumentId:m,endUserImageId:p,rawUserInput:f,error:h}=yield he.mutateAsync(Object.assign(Object.assign(Object.assign({formId:H,responseId:z,value:t},s&&i&&{documentId:i}),L&&{studioUserId:L}),F&&{deploymentId:F}));if(!l)throw new Error(null!=h?h:"An error occurred, please try again.");const g=[];m&&g.push(m),p&&g.push(p),g.length>0&&(a=[...n,Object.assign({id:X.length+1,role:"user",content:t},g&&{documentIds:g})],ee(a),pe()),de([]),pe();const b=(yield x({formId:H,responseId:z,data:d,actionData:c})).body;if(!b)throw new Error("Streaming error");const v=b.getReader(),j=new TextDecoder,y=a.length;let k="",I=!0,w=!1;for(;I;){const{value:e,done:t}=yield v.read();I=!t;if(k+=j.decode(e),k)ee([...a.slice(0,y),{id:X.length+1,role:"assistant",content:k}]),w||(te("streaming"),w=!0);else if(!I&&!k)throw new Error("Server error")}const O=new Date;k&&(pe(),te("idle"),yield ge.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:H,responseId:z,documentIds:u},B&&{userId:B}),L&&{studioUserId:L}),L&&(null==M?void 0:M.studioid)&&{studioId:M.studioid}),F&&{deploymentId:F}),{messages:[Object.assign(Object.assign({role:"user",message:f},g&&{documentIds:g}),{sentAt:o}),{role:"assistant",message:k,sentAt:O}]})),null==V||V(z))}catch(e){let t=U(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later.");const o=Object.entries(Z).find((([e])=>t.includes(e)));o?oe(o[1]):se(t),pe()}finally{te("idle"),re(!1),me()}}));return a((()=>{Q(Se)}),[Se]),a((()=>{je(G)}),[G]),o("div",Object.assign({className:T("fixed flex w-full flex-col bottom-0 left-0","viewport"===K?"min-[767px]:relative min-[767px]:bottom-auto min-[767px]:left-auto":"absolute @[767px]/pickaxe-root:relative @[767px]/pickaxe-root:bottom-auto @[767px]/pickaxe-root:left-auto")},{children:[!$.isWhiteLabel&&s("div",Object.assign({className:"flex justify-end pr-3 pb-3 @[767px]/pickaxe-root:pr-0"},{children:s(R,{animateHover:!0})})),Se&&s(D,{data:(null==M?void 0:M.icebreakers)||[],onSend:Re}),o("div",Object.assign({id:(null==M?void 0:M.formid)+"--chat-parent",style:Object.assign(Object.assign({},ve),(ie||_)&&{paddingLeft:"0.75rem",paddingRight:"0.75rem"}),className:T("flex min-h-[56px] flex-col gap-y-2 px-4 py-3 pb-[15px]","block"===P.formFieldStyle&&"shadow")},{children:["idle"===Y&&ne.length>0&&s("div",Object.assign({className:T("grid grid-cols-1","viewport"===K?"min-[765px]:grid-cols-2":"@[767px]/pickaxe-root:grid-cols-2")},{children:ne.map((e=>{var t,r,i;return s(l,{children:"document"===e.type?o("div",Object.assign({className:"relative gap-x-[10px] flex items-center px-2 h-[56px] border",style:{borderRadius:ve.borderRadius,borderColor:W.secondaryText+"50"}},{children:[s("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:W.accent,borderRadius:ve.borderRadius}},{children:ae?s(O,{className:"w-5 h-5 animate-spin",style:{color:W.accentText}}):s(N,{className:"w-5 h-5",style:{color:W.accentText}})})),o("div",Object.assign({className:"flex flex-col justify-center truncate"},{children:[s("p",Object.assign({className:(T(be.b3),"font-medium truncate")},{children:e.name})),s("p",Object.assign({className:T(be.b4,"opacity-80 truncate")},{children:I(e.size)}))]})),s("button",Object.assign({type:"button",disabled:ae||"idle"!==Y,onClick:()=>de([]),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:W.accent,borderColor:ve.backgroundColor}},{children:s(C,{className:"w-4 h-4",style:{color:W.accentText}})}))]})):"image"===e.type?o("div",Object.assign({className:"relative h-[56px] w-[56px] bg-stone-100",style:{borderRadius:ve.borderRadius}},{children:["finished"===e.status?s("img",{style:{borderRadius:ve.borderRadius},className:"object-cover w-full h-full",src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${null===(t=e.documentId)||void 0===t?void 0:t.split("-")[2]}/${null===(r=e.documentId)||void 0===r?void 0:r.split("-")[1]}.${null===(i=e.documentId)||void 0===i?void 0:i.split("-")[2]}`,alt:""}):s("div",{className:"h-full w-full animate-pulse",style:{borderRadius:ve.borderRadius,backgroundColor:W.secondary}}),s("button",Object.assign({type:"button",disabled:ae||"idle"!==Y,onClick:()=>de([]),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:W.accent,borderColor:ve.backgroundColor}},{children:s(C,{className:"w-4 h-4",style:{color:W.accentText}})}))]})):null},e.id)}))})),o("div",Object.assign({className:"flex items-end gap-x-2 grow"},{children:[s(A,{id:(null==M?void 0:M.formid)+"--chat-textarea",className:T(be.b2,"max-h-60 mb-[0.2em] w-full resize-none border-transparent bg-transparent outline-none ring-0 scrollbar scrollbar-thin placeholder:text-inherit placeholder:opacity-50",!xe.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap"),value:xe,placeholder:null!==(E=null==M?void 0:M.placeholdertext)&&void 0!==E?E:"What do you want to talk about?",onChange:e=>je(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),ae||"idle"!==Y||Re()))}}),o("div",Object.assign({className:"flex items-center gap-x-2"},{children:["enduserupload"===(null==M?void 0:M.documentuploadtype)&&o("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full transition-colors duration-200 ease-in-out",style:{backgroundColor:Ne?W.accent+"10":void 0},disabled:ae||"idle"!==Y,onClick:()=>{var e;return null===(e=ye.current)||void 0===e?void 0:e.click()}},Ce,{children:[s("input",{id:"file-upload",ref:ye,type:"file",accept:[...b,...le?v:[]].join(", "),multiple:!1,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){yield ce(Array.from(e.target.files||[])),e.target.value=""}))}),s(w,{className:"h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",style:{color:Ne?W.accent:W.accent+"80"}})]})),s("button",Object.assign({id:(null==M?void 0:M.formid)+"--chat-button",className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full duration-200 transition-colors ease-in-out",style:{backgroundColor:Ie?W.accent:W.accent+"10"},disabled:ae||"idle"!==Y,onClick:()=>Re()},we,{children:s(S,{className:"h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",style:{color:Ie?W.accentText:W.accent}})}))]}))]}))]}))]}))};export{E as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{createContext as s,useState as o,useEffect as t}from"react";import i from"./Addons/Document/Provider.js";import r from"./ResponseProvider.js";import n from"./DimensionProvider.js";const a=s({}),d=({children:s,userId:d="",studioUserId:c="",deploymentId:l="",styles:m,colors:h,limits:
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{createContext as s,useState as o,useEffect as t}from"react";import i from"./Addons/Document/Provider.js";import r from"./ResponseProvider.js";import n from"./DimensionProvider.js";const a=s({}),d=({children:s,userId:d="",studioUserId:c="",deploymentId:l="",styles:m,colors:h,limits:p={},misc:F={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:I,chatInput:y="",responsiveBy:g="viewport",loadFont:u=!0,forceMobile:f=!1,isEmbed:b=!1,onGenerateComplete:j})=>{const[v,w]=o(""),[x,P]=o(""),[S,C]=o(null),[O,k]=o(!1),[D,B]=o(!0),[H,L]=o(!0),[T,E]=o(!1);return t((()=>{k(!1)}),[null==m?void 0:m.font]),e(a.Provider,Object.assign({value:Object.assign({formId:v,chatId:x,userId:d,studioUserId:c,deploymentId:l,pickaxe:S,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},m),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},h),misc:F,translations:Object.assign({"new-chat":"New chat","see-history":"See history",processing:"Processing...",uploading:"Uploading...",loading:"Loading..."},I),chatInput:y,responsiveBy:g,isFontLoaded:O,isNewChat:D,isShowIceBreaker:H,isShowHistory:T,loadFont:u,forceMobile:f,isEmbed:b,setIsFontLoaded:k,setFormId:w,setChatId:P,setPickaxe:C,setIsNewChat:B,setIsShowIceBreaker:L,setIsShowHistory:E},j&&{onGenerateComplete:j})},{children:e(r,Object.assign({limits:p},{children:e(n,{children:e(i,{children:s})})}))}))};export{a as PickaxeContext,d as PickaxeProvider};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsxs as e,jsx as o}from"react/jsx-runtime";import{useMemo as i}from"react";import{usePickaxeContext as t}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useStyleFontSize as s}from"../../../hooks/studio/useStyleFontSize.js";import r from"../../../common/cn.js";import c from"./PickaxeIcon.js";const l=({iconClassName:l,onIconClick:n})=>{const{pickaxe:m,misc:a}=t(),p=s(),u=i((()=>({title:(null==m?void 0:m.formtitle)||""})),[m]);return e("div",Object.assign({className:"flex h-[56px] items-center gap-x-4 px-4"},{children:[a.isProfileImage&&o(c,Object.assign({src:null==m?void 0:m.coverphoto,alt:`${null==m?void 0:m.formtitle}'s Profile Picture`,width:32,height:32,className:r("shrink-0 h-[32px] w-[32px] rounded-full",l,!!n&&"cursor-pointer")},n&&{onClick:n})),a.isTitle&&o("p",Object.assign({className:r(p.b1,"truncate")},{children:u.title}))]}))};export{l as default};
|
|
@@ -43,6 +43,7 @@ type PickaxeContextType = {
|
|
|
43
43
|
styles: PickaxeProviderStyles;
|
|
44
44
|
colors: PickaxeProviderColors;
|
|
45
45
|
misc: PickaxeMisc;
|
|
46
|
+
chatInput: string;
|
|
46
47
|
translations: PickaxeTranslations;
|
|
47
48
|
responsiveBy: PickaxeResponsiveBy;
|
|
48
49
|
isFontLoaded: boolean;
|
|
@@ -51,6 +52,7 @@ type PickaxeContextType = {
|
|
|
51
52
|
isShowHistory: boolean;
|
|
52
53
|
loadFont: boolean;
|
|
53
54
|
forceMobile: boolean;
|
|
55
|
+
isEmbed: boolean;
|
|
54
56
|
setFormId: SetState<string>;
|
|
55
57
|
setChatId: SetState<string>;
|
|
56
58
|
setPickaxe: SetState<Pickaxe | null>;
|
|
@@ -70,11 +72,13 @@ export interface IPickaxeProviderProps {
|
|
|
70
72
|
limits?: Record<string, PickaxeLimitData>;
|
|
71
73
|
misc?: PickaxeMisc;
|
|
72
74
|
translations?: PickaxeTranslations;
|
|
75
|
+
chatInput?: string;
|
|
73
76
|
responsiveBy?: PickaxeResponsiveBy;
|
|
74
77
|
loadFont?: boolean;
|
|
75
78
|
forceMobile?: boolean;
|
|
79
|
+
isEmbed?: boolean;
|
|
76
80
|
onGenerateComplete?: (responseId: string) => void;
|
|
77
81
|
}
|
|
78
82
|
export declare const PickaxeContext: import("react").Context<PickaxeContextType>;
|
|
79
|
-
export declare const PickaxeProvider: ({ children, userId, studioUserId, deploymentId, styles, colors, limits, misc, translations, responsiveBy, loadFont, forceMobile, onGenerateComplete, }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
83
|
+
export declare const PickaxeProvider: ({ children, userId, studioUserId, deploymentId, styles, colors, limits, misc, translations, chatInput, responsiveBy, loadFont, forceMobile, isEmbed, onGenerateComplete, }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
80
84
|
export {};
|
|
@@ -8,6 +8,7 @@ export declare const usePickaxeContext: () => {
|
|
|
8
8
|
styles: import("../../components/Pickaxe/Provider").PickaxeProviderStyles;
|
|
9
9
|
colors: import("../../components/Pickaxe/Provider").PickaxeProviderColors;
|
|
10
10
|
misc: import("../../components/Pickaxe/Provider").PickaxeMisc;
|
|
11
|
+
chatInput: string;
|
|
11
12
|
translations: import("../../components/Pickaxe/Provider").PickaxeTranslations;
|
|
12
13
|
responsiveBy: import("../../components/Pickaxe/Provider").PickaxeResponsiveBy;
|
|
13
14
|
isFontLoaded: boolean;
|
|
@@ -16,6 +17,7 @@ export declare const usePickaxeContext: () => {
|
|
|
16
17
|
isShowHistory: boolean;
|
|
17
18
|
loadFont: boolean;
|
|
18
19
|
forceMobile: boolean;
|
|
20
|
+
isEmbed: boolean;
|
|
19
21
|
setFormId: import("../../types/common").SetState<string>;
|
|
20
22
|
setChatId: import("../../types/common").SetState<string>;
|
|
21
23
|
setPickaxe: import("../../types/common").SetState<import("../../types/pickaxe").Pickaxe | null>;
|