@pickaxeproject/react 1.1.1 → 1.1.3
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/Form/History/Item.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/History/Response.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 +3 -1
- package/dist/cjs/src/components/Pickaxe/common/PickaxeCompactHead.d.ts +6 -0
- package/dist/cjs/src/hooks/pickaxe/usePickaxeContext.d.ts +1 -0
- package/dist/esm/components/Pickaxe/Chat/History/index.js +1 -1
- package/dist/esm/components/Pickaxe/Form/History/Item.js +1 -1
- package/dist/esm/components/Pickaxe/Form/History/Response.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 +3 -1
- package/dist/esm/src/components/Pickaxe/common/PickaxeCompactHead.d.ts +6 -0
- package/dist/esm/src/hooks/pickaxe/usePickaxeContext.d.ts +1 -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("react/jsx-runtime"),s=require("react"),o=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../../hooks/studio/useStyleFontSize.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),o=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../../hooks/studio/useStyleFontSize.js"),n=require("../../Addons/Document/hooks/useDocument.js"),t=require("date-fns"),i=require("../../common/PickaxeMarkdown/index.js"),l=require("../../common/PickaxeMarkdown/Renderer.js"),r=require("../../../Icons/message-square-notes.svg.js"),c=require("../../../Icons/visitor.svg.js"),d=require("../../common/PickaxeIcon.js"),u=require("../../common/PickaxeSimpleButton.js"),m=require("../../common/PickaxeCopyButton.js"),x=require("../../../../common/cn.js");exports.default=({item:h})=>{const{pickaxe:p,styles:j,colors:f,misc:v,translations:g,setChatId:b,setIsNewChat:k}=o.usePickaxeContext(),y=a.useStyleFontSize(),{upsertDocuments:w}=n.useDocument(),N=s.useMemo((()=>t.format(h.createdAt,"hh:mm a MMM dd, yy")),[h]),q=s.useMemo((()=>h&&h.messages?h.messages.length:0),[h]),O=s.useMemo((()=>{var e,s,o,a;if("form"===h.type){return(null!==(e=h.questions)&&void 0!==e?e:[]).map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 500;">${e.question}</p>\n <p>${e.answer||"n/a"}</p>\n</div>`)).join("")}return null!==(a=null===(o=null===(s=h.messages)||void 0===s?void 0:s[0])||void 0===o?void 0:o.message)&&void 0!==a?a:""}),[h]),C=s.useMemo((()=>{var e,s,o,a;return"form"===h.type?null!==(e=h.questionResponse)&&void 0!==e?e:"":null!==(a=null===(o=null===(s=h.messages)||void 0===s?void 0:s[1])||void 0===o?void 0:o.message)&&void 0!==a?a:""}),[h]);return e.jsxs("div",Object.assign({className:"flex flex-col shadow-black transition duration-300 hover:shadow"},{children:[e.jsxs("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:f.primary,color:f.text}},{children:[e.jsx("div",Object.assign({className:"shrink-0 pt-1"},{children:e.jsx(c.default,{className:"h-6 w-6"})})),e.jsxs("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-1.5 scrollbar-track-gray-100 scrollbar-thumb-[#4A4A4B] lg:max-w-[520px] lg:scrollbar-thin"},{children:[e.jsx("input",{id:`${h.responseId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:O.length<280}),e.jsx("div",{className:"danger-html hidden flex-col peer-checked:flex",dangerouslySetInnerHTML:{__html:O}}),e.jsx("label",Object.assign({htmlFor:`${h.responseId}-input`,className:x.default(y.b3,"mt-1 flex shrink-0 whitespace-nowrap font-semibold peer-checked:hidden hover:cursor-pointer"),style:{color:f.accent}},{children:(null==g?void 0:g["see-input"])||"See input"})),e.jsx("label",Object.assign({htmlFor:`${h.responseId}-input`,className:x.default(y.b3,"hidden shrink-0 whitespace-nowrap font-semibold peer-checked:flex hover:cursor-pointer"),style:{color:f.accent}},{children:(null==g?void 0:g["hide-input"])||"Hide input"}))]}))]})),e.jsxs("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:f.secondary,color:f.secondaryText}},{children:[v.isChatImage&&e.jsx(d.default,{src:null==p?void 0:p.chaticon,alt:`${null==p?void 0:p.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1",textColor:f.secondaryText}),e.jsxs("div",Object.assign({className:"flex w-full flex-col gap-y-2 overflow-hidden"},{children:[e.jsx(i.PickaxeMarkdown,Object.assign({theme:j.theme,accentColor:f.accent,linkPreviews:!0,actions:!0},{children:e.jsx(l.PickaxeMarkdownRenderer,{className:"overflow-x-auto pb-2 font-semilight opacity-90 scrollbar scrollbar-thin",value:C})})),e.jsxs("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[e.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[(null==p?void 0:p.enablechatresponses)&&e.jsxs(u.default,Object.assign({color:f.accent,onClick:()=>{return e=h.responseId,w([]),k(!1),void b(e);var e}},{children:[e.jsx(r.default,{className:"h-4 w-4 shrink-0"}),e.jsx("p",Object.assign({className:x.default(y.b3,"font-semibold")},{children:q+1}))]})),e.jsx(m.default,{color:f.accent,text:C})]})),e.jsx("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:e.jsx("p",Object.assign({className:x.default(y.b3,"font-semibold uppercase opacity-30")},{children:N}))}))]}))]}))]}))]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),o=require("../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("../../../../hooks/pickaxe/useResponseContext.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),o=require("../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("../../../../hooks/pickaxe/useResponseContext.js"),n=require("../../Addons/Scroll/hooks/useScrollContext.js"),r=require("../../../../hooks/studio/useStyleFontSize.js"),l=require("../../Addons/Document/hooks/useDocument.js"),a=require("date-fns"),i=require("../../common/PickaxeMarkdown/index.js"),c=require("../../common/PickaxeMarkdown/Renderer.js"),d=require("../../../Icons/message-square-notes.svg.js"),u=require("../../../Icons/visitor.svg.js"),x=require("../../common/PickaxeIcon.js"),h=require("../../common/PickaxeSimpleButton.js"),m=require("../../common/PickaxeCopyButton.js"),p=require("../../Addons/Scroll/ScrollLockView.js"),j=require("../../../../common/cn.js");exports.default=()=>{var f;const{pickaxe:b,styles:g,colors:k,misc:v,translations:y,setChatId:w,setIsNewChat:q}=o.usePickaxeContext(),{response:N}=t.useResponseContext(),{scrollTargetRef:C,scrollContainerRef:O}=n.useScrollContext(),M=r.useStyleFontSize(),{upsertDocuments:I}=l.useDocument(),S=s.useMemo((()=>N?a.format(N.createdAt,"hh:mm a MMM dd, yy"):a.format(new Date,"hh:mm a MMM dd, yy")),[N]),P=s.useMemo((()=>{var e;if(!N)return"";return(null!==(e=N.questions)&&void 0!==e?e:[]).map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 500;">${e.question}</p>\n <p>${e.answer||"n/a"}</p>\n</div>`)).join("")}),[N]);return N?e.jsxs("div",Object.assign({ref:C,className:"flex flex-col shadow-black transition duration-300 hover:shadow"},{children:[e.jsxs("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:k.primary,color:k.text}},{children:[e.jsx("div",Object.assign({className:"shrink-0 pt-1"},{children:e.jsx(u.default,{className:"h-6 w-6"})})),e.jsxs("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-[6px] scrollbar scrollbar-thin"},{children:[e.jsx("input",{id:`${N.responseId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:P.length<280}),e.jsx("div",{className:"danger-html hidden flex-col opacity-50 peer-checked:flex",dangerouslySetInnerHTML:{__html:P}}),e.jsx("label",Object.assign({htmlFor:`${N.responseId}-input`,className:j.default(M.b3,"mt-1 flex shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:hidden hover:cursor-pointer"),style:{color:k.accent}},{children:(null==y?void 0:y["see-input"])||"See input"})),e.jsx("label",Object.assign({htmlFor:`${N.responseId}-input`,className:j.default(M.b3,"hidden shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:flex hover:cursor-pointer"),style:{color:k.accent}},{children:(null==y?void 0:y["hide-input"])||"Hide input"}))]}))]})),e.jsxs("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:k.secondary,color:k.secondaryText}},{children:[v.isChatImage&&e.jsx(x.default,{src:null==b?void 0:b.chaticon,alt:`${null==b?void 0:b.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1",textColor:k.secondaryText}),e.jsxs("div",Object.assign({ref:O,className:"flex w-full flex-col gap-y-2 overflow-hidden"},{children:[e.jsx(i.PickaxeMarkdown,Object.assign({theme:g.theme,accentColor:k.accent,linkPreviews:!0,actions:!0},{children:e.jsx(c.PickaxeMarkdownRenderer,{className:"overflow-x-auto pb-2 font-semilight opacity-90 scrollbar scrollbar-thin",value:N.questionResponse})})),e.jsxs("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[e.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[(null==b?void 0:b.enablechatresponses)&&e.jsxs(h.default,Object.assign({color:k.accent,onClick:()=>{return e=N.responseId,I([]),q(!1),void w(e);var e}},{children:[e.jsx(d.default,{className:"h-4 w-4 shrink-0"}),e.jsx("p",Object.assign({className:j.default(M.b3,"font-semibold")},{children:N.messages.length+1}))]})),e.jsx(m.default,{color:k.accent,text:null!==(f=N.questionResponse)&&void 0!==f?f:""})]})),e.jsx("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:e.jsx("p",Object.assign({className:j.default(M.b3,"font-semibold uppercase opacity-30")},{children:S}))}))]}))]}))]})),e.jsx(p.default,{className:"w-full"})]})):null};
|
|
@@ -1 +1 @@
|
|
|
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:
|
|
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:n,userId:a="",studioUserId:d="",deploymentId:c="",styles:l,colors:u,limits:h={},misc:p={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:F,chatInput:m="",responsiveBy:I="viewport",loadFont:x=!0,forceMobile:y=!1,isEmbed:S=!1,onGenerateComplete:f})=>{const[g,j]=t.useState(""),[b,v]=t.useState(""),[P,w]=t.useState(null),[C,k]=t.useState(!1),[O,q]=t.useState(!0),[D,H]=t.useState(!0),[B,E]=t.useState(!1);return t.useEffect((()=>{k(!1)}),[null==l?void 0:l.font]),e.jsx(o.Provider,Object.assign({value:Object.assign({formId:g,chatId:b,userId:a,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:p,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading..."},F),chatInput:m,responsiveBy:I,isFontLoaded:C,isNewChat:O,isShowIceBreaker:D,isShowHistory:B,loadFont:x,forceMobile:y,isEmbed:S,setIsFontLoaded:k,setFormId:j,setChatId:v,setPickaxe:w,setIsNewChat:q,setIsShowIceBreaker:H,setIsShowHistory:E},f&&{onGenerateComplete:f})},{children:e.jsx(i.default,Object.assign({limits:h},{children:e.jsx(r.default,{children:e.jsx(s.default,{children:n})})}))}))};
|
|
@@ -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}))]}))};
|
|
@@ -52,6 +52,7 @@ type PickaxeContextType = {
|
|
|
52
52
|
isShowHistory: boolean;
|
|
53
53
|
loadFont: boolean;
|
|
54
54
|
forceMobile: boolean;
|
|
55
|
+
isEmbed: boolean;
|
|
55
56
|
setFormId: SetState<string>;
|
|
56
57
|
setChatId: SetState<string>;
|
|
57
58
|
setPickaxe: SetState<Pickaxe | null>;
|
|
@@ -75,8 +76,9 @@ export interface IPickaxeProviderProps {
|
|
|
75
76
|
responsiveBy?: PickaxeResponsiveBy;
|
|
76
77
|
loadFont?: boolean;
|
|
77
78
|
forceMobile?: boolean;
|
|
79
|
+
isEmbed?: boolean;
|
|
78
80
|
onGenerateComplete?: (responseId: string) => void;
|
|
79
81
|
}
|
|
80
82
|
export declare const PickaxeContext: import("react").Context<PickaxeContextType>;
|
|
81
|
-
export declare const PickaxeProvider: ({ children, userId, studioUserId, deploymentId, styles, colors, limits, misc, translations, chatInput, 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;
|
|
82
84
|
export {};
|
|
@@ -17,6 +17,7 @@ export declare const usePickaxeContext: () => {
|
|
|
17
17
|
isShowHistory: boolean;
|
|
18
18
|
loadFont: boolean;
|
|
19
19
|
forceMobile: boolean;
|
|
20
|
+
isEmbed: boolean;
|
|
20
21
|
setFormId: import("../../types/common").SetState<string>;
|
|
21
22
|
setChatId: import("../../types/common").SetState<string>;
|
|
22
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{jsxs as e,jsx as s}from"react/jsx-runtime";import{useMemo as o}from"react";import{usePickaxeContext as t}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useStyleFontSize as n}from"../../../../hooks/studio/useStyleFontSize.js";import{useDocument as i}from"../../Addons/Document/hooks/useDocument.js";import{format as
|
|
1
|
+
import{jsxs as e,jsx as s}from"react/jsx-runtime";import{useMemo as o}from"react";import{usePickaxeContext as t}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useStyleFontSize as n}from"../../../../hooks/studio/useStyleFontSize.js";import{useDocument as i}from"../../Addons/Document/hooks/useDocument.js";import{format as l}from"date-fns";import{PickaxeMarkdown as r}from"../../common/PickaxeMarkdown/index.js";import{PickaxeMarkdownRenderer as a}from"../../common/PickaxeMarkdown/Renderer.js";import c from"../../../Icons/message-square-notes.svg.js";import m from"../../../Icons/visitor.svg.js";import d from"../../common/PickaxeIcon.js";import p from"../../common/PickaxeSimpleButton.js";import h from"../../common/PickaxeCopyButton.js";import u from"../../../../common/cn.js";const f=({item:f})=>{const{pickaxe:g,styles:v,colors:x,misc:b,translations:j,setChatId:y,setIsNewChat:k}=t(),w=n(),{upsertDocuments:N}=i(),O=o((()=>l(f.createdAt,"hh:mm a MMM dd, yy")),[f]),C=o((()=>f&&f.messages?f.messages.length:0),[f]),I=o((()=>{var e,s,o,t;if("form"===f.type){return(null!==(e=f.questions)&&void 0!==e?e:[]).map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 500;">${e.question}</p>\n <p>${e.answer||"n/a"}</p>\n</div>`)).join("")}return null!==(t=null===(o=null===(s=f.messages)||void 0===s?void 0:s[0])||void 0===o?void 0:o.message)&&void 0!==t?t:""}),[f]),P=o((()=>{var e,s,o,t;return"form"===f.type?null!==(e=f.questionResponse)&&void 0!==e?e:"":null!==(t=null===(o=null===(s=f.messages)||void 0===s?void 0:s[1])||void 0===o?void 0:o.message)&&void 0!==t?t:""}),[f]);return e("div",Object.assign({className:"flex flex-col shadow-black transition duration-300 hover:shadow"},{children:[e("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:x.primary,color:x.text}},{children:[s("div",Object.assign({className:"shrink-0 pt-1"},{children:s(m,{className:"h-6 w-6"})})),e("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-1.5 scrollbar-track-gray-100 scrollbar-thumb-[#4A4A4B] lg:max-w-[520px] lg:scrollbar-thin"},{children:[s("input",{id:`${f.responseId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:I.length<280}),s("div",{className:"danger-html hidden flex-col peer-checked:flex",dangerouslySetInnerHTML:{__html:I}}),s("label",Object.assign({htmlFor:`${f.responseId}-input`,className:u(w.b3,"mt-1 flex shrink-0 whitespace-nowrap font-semibold peer-checked:hidden hover:cursor-pointer"),style:{color:x.accent}},{children:(null==j?void 0:j["see-input"])||"See input"})),s("label",Object.assign({htmlFor:`${f.responseId}-input`,className:u(w.b3,"hidden shrink-0 whitespace-nowrap font-semibold peer-checked:flex hover:cursor-pointer"),style:{color:x.accent}},{children:(null==j?void 0:j["hide-input"])||"Hide input"}))]}))]})),e("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:x.secondary,color:x.secondaryText}},{children:[b.isChatImage&&s(d,{src:null==g?void 0:g.chaticon,alt:`${null==g?void 0:g.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1",textColor:x.secondaryText}),e("div",Object.assign({className:"flex w-full flex-col gap-y-2 overflow-hidden"},{children:[s(r,Object.assign({theme:v.theme,accentColor:x.accent,linkPreviews:!0,actions:!0},{children:s(a,{className:"overflow-x-auto pb-2 font-semilight opacity-90 scrollbar scrollbar-thin",value:P})})),e("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[e("div",Object.assign({className:"flex items-center gap-3"},{children:[(null==g?void 0:g.enablechatresponses)&&e(p,Object.assign({color:x.accent,onClick:()=>{return e=f.responseId,N([]),k(!1),void y(e);var e}},{children:[s(c,{className:"h-4 w-4 shrink-0"}),s("p",Object.assign({className:u(w.b3,"font-semibold")},{children:C+1}))]})),s(h,{color:x.accent,text:P})]})),s("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:s("p",Object.assign({className:u(w.b3,"font-semibold uppercase opacity-30")},{children:O}))}))]}))]}))]}))]}))};export{f as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as o}from"react/jsx-runtime";import{useMemo as s}from"react";import{usePickaxeContext as t}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as
|
|
1
|
+
import{jsxs as e,jsx as o}from"react/jsx-runtime";import{useMemo as s}from"react";import{usePickaxeContext as t}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as n}from"../../../../hooks/pickaxe/useResponseContext.js";import{useScrollContext as r}from"../../Addons/Scroll/hooks/useScrollContext.js";import{useStyleFontSize as i}from"../../../../hooks/studio/useStyleFontSize.js";import{useDocument as l}from"../../Addons/Document/hooks/useDocument.js";import{format as c}from"date-fns";import{PickaxeMarkdown as a}from"../../common/PickaxeMarkdown/index.js";import{PickaxeMarkdownRenderer as m}from"../../common/PickaxeMarkdown/Renderer.js";import d from"../../../Icons/message-square-notes.svg.js";import p from"../../../Icons/visitor.svg.js";import h from"../../common/PickaxeIcon.js";import f from"../../common/PickaxeSimpleButton.js";import u from"../../common/PickaxeCopyButton.js";import x from"../../Addons/Scroll/ScrollLockView.js";import g from"../../../../common/cn.js";const b=()=>{var b;const{pickaxe:v,styles:j,colors:k,misc:y,translations:w,setChatId:N,setIsNewChat:C}=t(),{response:O}=n(),{scrollTargetRef:I,scrollContainerRef:S}=r(),D=i(),{upsertDocuments:P}=l(),M=s((()=>c(O?O.createdAt:new Date,"hh:mm a MMM dd, yy")),[O]),R=s((()=>{var e;if(!O)return"";return(null!==(e=O.questions)&&void 0!==e?e:[]).map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 500;">${e.question}</p>\n <p>${e.answer||"n/a"}</p>\n</div>`)).join("")}),[O]);return O?e("div",Object.assign({ref:I,className:"flex flex-col shadow-black transition duration-300 hover:shadow"},{children:[e("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:k.primary,color:k.text}},{children:[o("div",Object.assign({className:"shrink-0 pt-1"},{children:o(p,{className:"h-6 w-6"})})),e("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-[6px] scrollbar scrollbar-thin"},{children:[o("input",{id:`${O.responseId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:R.length<280}),o("div",{className:"danger-html hidden flex-col opacity-50 peer-checked:flex",dangerouslySetInnerHTML:{__html:R}}),o("label",Object.assign({htmlFor:`${O.responseId}-input`,className:g(D.b3,"mt-1 flex shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:hidden hover:cursor-pointer"),style:{color:k.accent}},{children:(null==w?void 0:w["see-input"])||"See input"})),o("label",Object.assign({htmlFor:`${O.responseId}-input`,className:g(D.b3,"hidden shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:flex hover:cursor-pointer"),style:{color:k.accent}},{children:(null==w?void 0:w["hide-input"])||"Hide input"}))]}))]})),e("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:k.secondary,color:k.secondaryText}},{children:[y.isChatImage&&o(h,{src:null==v?void 0:v.chaticon,alt:`${null==v?void 0:v.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1",textColor:k.secondaryText}),e("div",Object.assign({ref:S,className:"flex w-full flex-col gap-y-2 overflow-hidden"},{children:[o(a,Object.assign({theme:j.theme,accentColor:k.accent,linkPreviews:!0,actions:!0},{children:o(m,{className:"overflow-x-auto pb-2 font-semilight opacity-90 scrollbar scrollbar-thin",value:O.questionResponse})})),e("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[e("div",Object.assign({className:"flex items-center gap-3"},{children:[(null==v?void 0:v.enablechatresponses)&&e(f,Object.assign({color:k.accent,onClick:()=>{return e=O.responseId,P([]),C(!1),void N(e);var e}},{children:[o(d,{className:"h-4 w-4 shrink-0"}),o("p",Object.assign({className:g(D.b3,"font-semibold")},{children:O.messages.length+1}))]})),o(u,{color:k.accent,text:null!==(b=O.questionResponse)&&void 0!==b?b:""})]})),o("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:o("p",Object.assign({className:g(D.b3,"font-semibold uppercase opacity-30")},{children:M}))}))]}))]}))]})),o(x,{className:"w-full"})]})):null};export{b as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{createContext as s,useState as
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{createContext as s,useState as t,useEffect as i}from"react";import o 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:p,limits:h={},misc:F={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:I,chatInput:u="",responsiveBy:y="viewport",loadFont:g=!0,forceMobile:f=!1,isEmbed:b=!1,onGenerateComplete:j})=>{const[v,w]=t(""),[S,x]=t(""),[P,C]=t(null),[O,k]=t(!1),[D,H]=t(!0),[B,L]=t(!0),[T,E]=t(!1);return i((()=>{k(!1)}),[null==m?void 0:m.font]),e(a.Provider,Object.assign({value:Object.assign({formId:v,chatId:S,userId:d,studioUserId:c,deploymentId:l,pickaxe:P,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"},p),misc:F,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading..."},I),chatInput:u,responsiveBy:y,isFontLoaded:O,isNewChat:D,isShowIceBreaker:B,isShowHistory:T,loadFont:g,forceMobile:f,isEmbed:b,setIsFontLoaded:k,setFormId:w,setChatId:x,setPickaxe:C,setIsNewChat:H,setIsShowIceBreaker:L,setIsShowHistory:E},j&&{onGenerateComplete:j})},{children:e(r,Object.assign({limits:h},{children:e(n,{children:e(o,{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};
|
|
@@ -52,6 +52,7 @@ type PickaxeContextType = {
|
|
|
52
52
|
isShowHistory: boolean;
|
|
53
53
|
loadFont: boolean;
|
|
54
54
|
forceMobile: boolean;
|
|
55
|
+
isEmbed: boolean;
|
|
55
56
|
setFormId: SetState<string>;
|
|
56
57
|
setChatId: SetState<string>;
|
|
57
58
|
setPickaxe: SetState<Pickaxe | null>;
|
|
@@ -75,8 +76,9 @@ export interface IPickaxeProviderProps {
|
|
|
75
76
|
responsiveBy?: PickaxeResponsiveBy;
|
|
76
77
|
loadFont?: boolean;
|
|
77
78
|
forceMobile?: boolean;
|
|
79
|
+
isEmbed?: boolean;
|
|
78
80
|
onGenerateComplete?: (responseId: string) => void;
|
|
79
81
|
}
|
|
80
82
|
export declare const PickaxeContext: import("react").Context<PickaxeContextType>;
|
|
81
|
-
export declare const PickaxeProvider: ({ children, userId, studioUserId, deploymentId, styles, colors, limits, misc, translations, chatInput, 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;
|
|
82
84
|
export {};
|
|
@@ -17,6 +17,7 @@ export declare const usePickaxeContext: () => {
|
|
|
17
17
|
isShowHistory: boolean;
|
|
18
18
|
loadFont: boolean;
|
|
19
19
|
forceMobile: boolean;
|
|
20
|
+
isEmbed: boolean;
|
|
20
21
|
setFormId: import("../../types/common").SetState<string>;
|
|
21
22
|
setChatId: import("../../types/common").SetState<string>;
|
|
22
23
|
setPickaxe: import("../../types/common").SetState<import("../../types/pickaxe").Pickaxe | null>;
|