@progress/kendo-react-conversational-ui 14.5.0-develop.9 → 15.0.0-develop.1
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/README.md +4 -4
- package/ai-prompt/AIPrompt.d.ts +6 -0
- package/ai-prompt/AIPrompt.js +1 -1
- package/ai-prompt/AIPrompt.mjs +40 -38
- package/chat/ChatPropsAndState.d.ts +17 -0
- package/chat/components/Chat.js +1 -1
- package/chat/components/Chat.mjs +224 -222
- package/chat/components/ChatMessage.js +1 -1
- package/chat/components/ChatMessage.mjs +123 -108
- package/chat/hooks/useEndlessScroll.js +1 -1
- package/chat/hooks/useEndlessScroll.mjs +103 -101
- package/dist/cdn/js/kendo-react-conversational-ui.js +1 -1
- package/messages/index.d.ts +5 -0
- package/messages/index.js +1 -1
- package/messages/index.mjs +12 -10
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +11 -11
- package/prompt-box/PromptBox.js +1 -1
- package/prompt-box/PromptBox.mjs +135 -137
package/prompt-box/PromptBox.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ge=require("react"),o=require("prop-types"),d=require("@progress/kendo-react-common"),se=require("@progress/kendo-svg-icons"),Ke=require("./PromptBoxActionButton.js"),Xe=require("./PromptBoxSpeechToTextButton.js"),Ze=require("./PromptBoxUploadButton.js"),Je=require("./FileBox.js"),Ee=require("../package-metadata.js"),Qe=require("@progress/kendo-react-intl"),a=require("../messages/index.js");function Ye(E){const O=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(E){for(const F in E)if(F!=="default"){const j=Object.getOwnPropertyDescriptor(E,F);Object.defineProperty(O,F,j.get?j:{enumerable:!0,get:()=>E[F]})}}return O.default=E,Object.freeze(O)}const t=Ye(Ge),g="k-prompt-box",et=20,tt=50,y={mode:"auto",rows:1,defaultValue:"",disabled:!1,readOnly:!1,loading:!1,uploadButtonConfig:!1,speechToTextButtonConfig:!0,actionButtonConfig:!0},re=t.forwardRef((E,O)=>{const F=!d.validatePackage(Ee.packageMetadata,{component:"PromptBox"}),j=d.getLicenseMessage(Ee.packageMetadata),v=Qe.useLocalization(),Se={...y,...E},{mode:s=y.mode,fillMode:le,rows:M=y.rows,maxTextAreaHeight:u,value:ae,defaultValue:Te=y.defaultValue,disabled:p=y.disabled,readOnly:Ae=y.readOnly,placeholder:Re,title:Fe,maxLength:we,inputAttributes:Pe,topAffix:ie,startAffix:k,endAffix:x,header:Ne,onChange:w,onFocus:Z,onBlur:J,onPromptAction:Q,attachments:ce,loading:C=y.loading,uploadButtonConfig:h=y.uploadButtonConfig,speechToTextButtonConfig:z=y.speechToTextButtonConfig,actionButtonConfig:q=y.actionButtonConfig,className:Oe,style:Me,...He}=Se,r=t.useRef(null),[Le,_]=t.useState(Te),[Ie,Y]=t.useState([]),[c,ue]=t.useState(!1),fe=t.useRef(null),D=t.useRef(null),H=t.useRef(0),pe=t.useRef(0),L=t.useRef(!1),me=t.useRef(0),U=t.useRef(0),S=t.useCallback((e,n)=>e?typeof e=="function"?e(n):e:null,[]),T=ae!==void 0,f=T?ae:Le,A=ce!==void 0,R=A?ce:Ie,I=t.useMemo(()=>!!(f!=null&&f.trim()||R.length>0),[f,R.length]),P=t.useCallback(()=>{if(!r.current||s==="single")return;const e=r.current,n=globalThis.getComputedStyle(e),l=Number.parseFloat(n.lineHeight)||et,i=Number.parseFloat(n.paddingTop)||0,B=Number.parseFloat(n.paddingBottom)||0;H.current=e.offsetHeight||l+i+B,pe.current=l*M+i+B,s==="auto"&&!c&&(U.current=e.offsetWidth)},[s,M,c]),$e=t.useCallback(()=>s==="auto"?1:M,[s,M]),de=t.useCallback(e=>{if(u){const n=Number.parseInt(u,10);if(e>n)return n}return Math.max(pe.current,e)},[u]),W=t.useCallback(e=>{e.style.overflow="hidden",e.style.height=`${H.current}px`;const n=e.scrollHeight,l=de(n);e.style.height=`${l}px`,u&&n>Number.parseInt(u,10)&&(e.style.overflow="")},[de,u]),V=t.useCallback(e=>{e.style.overflow="hidden",e.style.height=`${H.current}px`;const n=e.scrollHeight,l=u?Math.min(n,Number.parseInt(u,10)):n;e.style.height=`${l}px`,u&&n>Number.parseInt(u,10)&&(e.style.overflow="")},[u]),ge=t.useCallback(e=>{if(U.current<=0)return!1;const n=e.style.height,l=e.style.width;e.style.overflow="hidden",e.style.width=`${U.current}px`,e.style.height=`${H.current}px`;const i=e.scrollWidth<=U.current&&e.scrollHeight<=H.current;return e.style.overflow="",l?e.style.width=l:e.style.width="",n?e.style.height=n:e.style.height="",i},[]),G=t.useCallback((e,n)=>{if(L.current)return;if((e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight)&&!c){L.current=!0,ue(!0);return}if(c){V(e);const i=me.current;n<i&&ge(e)&&(e.style.height="",L.current=!0,ue(!1))}},[c,V,ge]),N=t.useCallback(()=>{var l;if(s==="single"||!r.current)return;const e=r.current,n=((l=e.value)==null?void 0:l.length)||0;s==="multi"?W(e):s==="auto"&&G(e,n)},[s,W,G]);t.useEffect(()=>{s!=="single"&&r.current&&P()},[s,P]),t.useEffect(()=>{s!=="single"&&r.current&&(P(),N())},[M,s,P,N]),t.useEffect(()=>{if(s!=="single"&&r.current){const e=(f==null?void 0:f.length)||0;requestAnimationFrame(()=>{if(r.current){const n=r.current;s==="multi"?W(n):s==="auto"&&G(n,e),me.current=e}})}},[f,s,W,G]),t.useEffect(()=>{s==="auto"&&c&&r.current&&requestAnimationFrame(()=>{if(r.current){const e=r.current;V(e),L.current=!1}})},[c,s,V]),t.useEffect(()=>{if(s==="auto"&&r.current){const e=r.current;c||(e.style.height="",e.style.overflow="",L.current=!1)}},[s,c]),t.useEffect(()=>{if(s==="single"||!r.current)return;const e=r.current;let n;const l=()=>{clearTimeout(n),n=setTimeout(()=>{r.current&&(s==="auto"&&!c&&P(),N())},tt)},i=new ResizeObserver(l);return i.observe(e),()=>{i.disconnect(),clearTimeout(n)}},[s,c,P,N]);const m=t.useCallback(()=>({focus:()=>{var e;return(e=r.current)==null?void 0:e.focus()},blur:()=>{var e;return(e=r.current)==null?void 0:e.blur()},element:r.current,get value(){return f}}),[f]);t.useImperativeHandle(O,m);const je=t.useCallback(e=>{const n=e.target.value;!T&&!p&&_(n),w&&!p&&d.dispatchEvent(w,e,{...m(),value:n},{value:n}),s!=="single"&&N()},[_,w,p,T,m,s,N]),ze=t.useCallback(e=>{Z&&!p&&d.dispatchEvent(Z,e,m(),void 0)},[Z,p,m]),qe=t.useCallback(e=>{J&&!p&&d.dispatchEvent(J,e,m(),void 0)},[J,p,m]),he=t.useCallback(e=>{e.preventDefault()},[]),K=t.useCallback(e=>{Q&&d.dispatchEvent(Q,e,m(),{value:f,attachments:R}),T||_(""),A||Y([])},[Q,m,f,R,T,A]),_e=t.useCallback(e=>{if(!(e.key==="Enter"&&e.shiftKey)){if(e.key==="ArrowUp"||e.key==="ArrowDown"){e.stopPropagation();return}if(e.key==="Enter"){if(e.preventDefault(),C)return;I&&K(e)}}},[K,C,I]),be={disabled:p,readOnly:Ae,placeholder:Re,title:Fe,maxLength:we,"aria-label":v.toLanguageString(a.promptBoxInput,a.messages[a.promptBoxInput]),value:f,onKeyDown:_e,...Pe,onChange:je,onFocus:ze,onBlur:qe,ref:r},Be=t.useCallback(e=>{var i,B;const{isFinal:n,alternatives:l}=e;if(l.length>0){const ne=l[0];if(n){const X=((i=r.current)==null?void 0:i.value)||"",$=(X?`${X} `:"")+ne.transcript;if(T||_($),w&&!p){const ke={target:r.current,currentTarget:r.current};d.dispatchEvent(w,ke,{...m(),value:$},{value:$})}}}(B=r.current)==null||B.focus()},[T,w,p,m]),ye=t.useCallback(()=>{var e,n;(n=(e=fe.current)==null?void 0:e.actionElement)==null||n.click()},[]),ve=t.useCallback(e=>{var i;const n=Array.from(e.affectedFiles),l=typeof h=="object"&&h.onSelectAttachments;A||Y(B=>[...B,...n]),l&&l({selectedFiles:e.affectedFiles,allFiles:e.newState}),(i=r.current)==null||i.focus()},[h,A]),b=t.useMemo(()=>({uploadButtonProps:{fillMode:"flat",svgIcon:se.paperclipIcon,size:"small",rounded:"full",onClick:ye,onFilesAdd:ve,files:R,uploadRef:fe,"aria-label":v.toLanguageString(a.promptBoxAttachFile,a.messages[a.promptBoxAttachFile]),title:v.toLanguageString(a.promptBoxAttachFile,a.messages[a.promptBoxAttachFile]),_registerRemoveCallback:e=>{D.current=e}},speechToTextButtonProps:{fillMode:"flat",size:"small",rounded:"full",onResult:Be},actionButtonProps:{rounded:"full",size:"small",svgIcon:C?se.stopIcon:se.arrowUpIcon,className:C?"k-generating":"",onClick:K,onMouseDown:he,disabled:!C&&!I,"aria-disabled":!C&&!I,"aria-label":C?v.toLanguageString(a.promptBoxStopGenerating,a.messages[a.promptBoxStopGenerating]):v.toLanguageString(a.promptBoxSendButton,a.messages[a.promptBoxSendButton]),title:C?v.toLanguageString(a.promptBoxStopGenerating,a.messages[a.promptBoxStopGenerating]):v.toLanguageString(a.promptBoxSendButton,a.messages[a.promptBoxSendButton]),"aria-live":"polite"}}),[Be,ve,R,K,he,C,ye,v,I]),De=t.useCallback(e=>{A||Y(l=>l.filter(i=>i.name!==e));const n=typeof h=="object"&&h.onRemoveAttachment;n&&(D.current=n),D.current&&D.current(e)},[h,A]),ee=()=>{const e=z!==!1,n=q!==!1,l=h!==!1,i=typeof z=="object"?z:void 0,B=typeof h=="object"?h:{},{restrictions:ne,multiple:X=!0,accept:$,onSelectAttachments:ke,onRemoveAttachment:nt,...We}=B,oe={restrictions:ne,multiple:X,accept:$},Ve=typeof q=="object"?q:void 0;return t.createElement(t.Fragment,null,l&&t.createElement(Ze.PromptBoxUploadButton,{...b.uploadButtonProps,restrictions:oe.restrictions,multiple:oe.multiple,accept:oe.accept,...We}),e&&t.createElement(Xe.PromptBoxSpeechToTextButton,{...b.speechToTextButtonProps,...i}),n&&t.createElement(Ke.PromptBoxActionButton,{...b.actionButtonProps,...Ve}))},te=s==="multi"||s==="auto"&&c,xe=h!==!1||z!==!1||q!==!1,Ce=x||xe,Ue=k||x||xe;return t.createElement("div",{"aria-label":v.toLanguageString(a.promptBoxAriaLabel,a.messages[a.promptBoxAriaLabel]),...He,className:d.classNames(Oe,"k-input",g,{[`k-input-${le}`]:le,"k-disabled":p,"k-prompt-box-singleline":s==="single","k-prompt-box-multiline":te}),style:Me},t.createElement(Je.FileBox,{files:R,onRemoveFile:De,header:Ne}),s==="single"?t.createElement("div",{className:`${g}-content`},k&&t.createElement("div",{className:`${g}-affix`},S(k,b)),t.createElement("input",{...be,className:d.classNames("k-input-inner",`${g}-input`)}),Ce?t.createElement("div",{className:`${g}-affix`},x&&S(x,b),ee()):null):t.createElement("div",{className:`${g}-content`},s==="multi"&&ie&&t.createElement("div",{className:`${g}-affix`},S(ie,b)),s==="auto"&&!c&&k&&t.createElement("div",{className:`${g}-affix`},S(k,b)),t.createElement("textarea",{...be,className:d.classNames("k-input-inner",`${g}-textarea`),rows:$e(),style:u?{maxHeight:u}:{},...te&&{"aria-multiline":"true"}}),s==="auto"&&!c&&Ce?t.createElement("div",{className:`${g}-affix`},x&&S(x,b),ee()):null,te&&Ue?t.createElement("div",{className:`${g}-affix`},k&&S(k,b),(k||x)&&t.createElement("div",{className:"k-spacer"}),x&&S(x,b),ee()):null),F&&t.createElement(d.WatermarkOverlay,{message:j}))});re.propTypes={value:o.string,defaultValue:o.string,mode:o.oneOf(["single","multi","auto"]),rows:o.number,maxTextAreaHeight:o.string,title:o.string,disabled:o.bool,readOnly:o.bool,placeholder:o.string,maxLength:o.number,inputAttributes:o.object,fillMode:o.oneOf(["solid","flat","outline"]),topAffix:o.oneOfType([o.func,o.element,o.string]),startAffix:o.oneOfType([o.func,o.element,o.string]),endAffix:o.oneOfType([o.func,o.element,o.string]),header:o.oneOfType([o.func,o.element,o.string]),onChange:o.func,onFocus:o.func,onBlur:o.func,loading:o.bool,uploadButtonConfig:o.oneOfType([o.bool,o.object]),speechToTextButtonConfig:o.oneOfType([o.bool,o.object]),actionButtonConfig:o.oneOfType([o.bool,o.object]),attachments:o.array,onPromptAction:o.func,className:o.string,style:o.object};re.displayName="KendoPromptBox";exports.PromptBox=re;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ge=require("react"),o=require("prop-types"),d=require("@progress/kendo-react-common"),oe=require("@progress/kendo-svg-icons"),Ke=require("./PromptBoxActionButton.js"),Xe=require("./PromptBoxSpeechToTextButton.js"),Ze=require("./PromptBoxUploadButton.js"),Je=require("./FileBox.js"),Ee=require("../package-metadata.js"),Qe=require("@progress/kendo-react-intl"),i=require("../messages/index.js");function Ye(E){const O=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(E){for(const F in E)if(F!=="default"){const $=Object.getOwnPropertyDescriptor(E,F);Object.defineProperty(O,F,$.get?$:{enumerable:!0,get:()=>E[F]})}}return O.default=E,Object.freeze(O)}const t=Ye(Ge),g="k-prompt-box",et=20,tt=50,y={mode:"auto",rows:1,defaultValue:"",disabled:!1,readOnly:!1,loading:!1,uploadButtonConfig:!1,speechToTextButtonConfig:!0,actionButtonConfig:!0},se=t.forwardRef((E,O)=>{const F=!d.validatePackage(Ee.packageMetadata,{component:"PromptBox"}),$=d.getLicenseMessage(Ee.packageMetadata),x=Qe.useLocalization(),Te={...y,...E},{mode:s=y.mode,fillMode:re,rows:M=y.rows,maxTextAreaHeight:u,value:le,defaultValue:Se=y.defaultValue,disabled:p=y.disabled,readOnly:Ae=y.readOnly,placeholder:Re,title:Fe,maxLength:we,inputAttributes:Pe,topAffix:ie,startAffix:C,endAffix:v,header:Ne,onChange:w,onFocus:Z,onBlur:J,onPromptAction:Q,attachments:ae,loading:k=y.loading,uploadButtonConfig:h=y.uploadButtonConfig,speechToTextButtonConfig:j=y.speechToTextButtonConfig,actionButtonConfig:z=y.actionButtonConfig,className:Oe,style:Me,...He}=Te,r=t.useRef(null),[Le,q]=t.useState(Se),[Ie,Y]=t.useState([]),[c,ce]=t.useState(!1),ue=t.useRef(null),_=t.useRef(null),H=t.useRef(0),fe=t.useRef(0),L=t.useRef(!1),pe=t.useRef(0),D=t.useRef(0),T=t.useCallback((e,n)=>e?typeof e=="function"?e(n):e:null,[]),S=le!==void 0,f=S?le:Le,A=ae!==void 0,R=A?ae:Ie,U=t.useMemo(()=>!!(f!=null&&f.trim()||R.length>0),[f,R.length]),P=t.useCallback(()=>{if(!r.current||s==="single")return;const e=r.current,n=globalThis.getComputedStyle(e),l=Number.parseFloat(n.lineHeight)||et,a=Number.parseFloat(n.paddingTop)||0,B=Number.parseFloat(n.paddingBottom)||0;H.current=e.offsetHeight||l+a+B,fe.current=l*M+a+B,s==="auto"&&!c&&(D.current=e.offsetWidth)},[s,M,c]),$e=t.useCallback(()=>s==="auto"?1:M,[s,M]),me=t.useCallback(e=>{if(u){const n=Number.parseInt(u,10);if(e>n)return n}return Math.max(fe.current,e)},[u]),W=t.useCallback(e=>{e.style.overflow="hidden",e.style.height=`${H.current}px`;const n=e.scrollHeight,l=me(n);e.style.height=`${l}px`,u&&n>Number.parseInt(u,10)&&(e.style.overflow="")},[me,u]),V=t.useCallback(e=>{e.style.overflow="hidden",e.style.height=`${H.current}px`;const n=e.scrollHeight,l=u?Math.min(n,Number.parseInt(u,10)):n;e.style.height=`${l}px`,u&&n>Number.parseInt(u,10)&&(e.style.overflow="")},[u]),de=t.useCallback(e=>{if(D.current<=0)return!1;const n=e.style.height,l=e.style.width;e.style.overflow="hidden",e.style.width=`${D.current}px`,e.style.height=`${H.current}px`;const a=e.scrollWidth<=D.current&&e.scrollHeight<=H.current;return e.style.overflow="",l?e.style.width=l:e.style.width="",n?e.style.height=n:e.style.height="",a},[]),G=t.useCallback((e,n)=>{if(L.current)return;if((e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight)&&!c){L.current=!0,ce(!0);return}if(c){V(e);const a=pe.current;n<a&&de(e)&&(e.style.height="",L.current=!0,ce(!1))}},[c,V,de]),N=t.useCallback(()=>{var l;if(s==="single"||!r.current)return;const e=r.current,n=((l=e.value)==null?void 0:l.length)||0;s==="multi"?W(e):s==="auto"&&G(e,n)},[s,W,G]);t.useEffect(()=>{s!=="single"&&r.current&&P()},[s,P]),t.useEffect(()=>{s!=="single"&&r.current&&(P(),N())},[M,s,P,N]),t.useEffect(()=>{if(s!=="single"&&r.current){const e=(f==null?void 0:f.length)||0;requestAnimationFrame(()=>{if(r.current){const n=r.current;s==="multi"?W(n):s==="auto"&&G(n,e),pe.current=e}})}},[f,s,W,G]),t.useEffect(()=>{s==="auto"&&c&&r.current&&requestAnimationFrame(()=>{if(r.current){const e=r.current;V(e),L.current=!1}})},[c,s,V]),t.useEffect(()=>{if(s==="auto"&&r.current){const e=r.current;c||(e.style.height="",e.style.overflow="",L.current=!1)}},[s,c]),t.useEffect(()=>{if(s==="single"||!r.current)return;const e=r.current;let n;const l=()=>{clearTimeout(n),n=setTimeout(()=>{r.current&&(s==="auto"&&!c&&P(),N())},tt)},a=new ResizeObserver(l);return a.observe(e),()=>{a.disconnect(),clearTimeout(n)}},[s,c,P,N]);const m=t.useCallback(()=>({focus:()=>{var e;return(e=r.current)==null?void 0:e.focus()},blur:()=>{var e;return(e=r.current)==null?void 0:e.blur()},element:r.current,get value(){return f}}),[f]);t.useImperativeHandle(O,m);const je=t.useCallback(e=>{const n=e.target.value;!S&&!p&&q(n),w&&!p&&d.dispatchEvent(w,e,{...m(),value:n},{value:n}),s!=="single"&&N()},[q,w,p,S,m,s,N]),ze=t.useCallback(e=>{Z&&!p&&d.dispatchEvent(Z,e,m(),void 0)},[Z,p,m]),qe=t.useCallback(e=>{J&&!p&&d.dispatchEvent(J,e,m(),void 0)},[J,p,m]),ge=t.useCallback(e=>{e.preventDefault()},[]),K=t.useCallback(e=>{Q&&d.dispatchEvent(Q,e,m(),{value:f,attachments:R}),S||q(""),A||Y([])},[Q,m,f,R,S,A]),_e=t.useCallback(e=>{if(!(e.key==="Enter"&&e.shiftKey)){if(e.key==="ArrowUp"||e.key==="ArrowDown"){e.stopPropagation();return}if(e.key==="Enter"){if(e.preventDefault(),k)return;U&&K(e)}}},[K,k,U]),he={disabled:p,readOnly:Ae,placeholder:Re,title:Fe,maxLength:we,"aria-label":x.toLanguageString(i.promptBoxInput,i.messages[i.promptBoxInput]),value:f,onKeyDown:_e,...Pe,onChange:je,onFocus:ze,onBlur:qe,ref:r},be=t.useCallback(e=>{var a,B;const{isFinal:n,alternatives:l}=e;if(l.length>0){const te=l[0];if(n){const X=((a=r.current)==null?void 0:a.value)||"",I=(X?`${X} `:"")+te.transcript;if(S||q(I),w&&!p){const ke={target:r.current,currentTarget:r.current};d.dispatchEvent(w,ke,{...m(),value:I},{value:I})}}}(B=r.current)==null||B.focus()},[S,w,p,m]),Be=t.useCallback(()=>{var e,n;(n=(e=ue.current)==null?void 0:e.actionElement)==null||n.click()},[]),ye=t.useCallback(e=>{var a;const n=Array.from(e.affectedFiles),l=typeof h=="object"&&h.onSelectAttachments;A||Y(B=>[...B,...n]),l&&l({selectedFiles:e.affectedFiles,allFiles:e.newState}),(a=r.current)==null||a.focus()},[h,A]),b=t.useMemo(()=>({uploadButtonProps:{fillMode:"flat",svgIcon:oe.paperclipIcon,size:"small",rounded:"full",onClick:Be,onFilesAdd:ye,files:R,uploadRef:ue,"aria-label":x.toLanguageString(i.promptBoxAttachFile,i.messages[i.promptBoxAttachFile]),title:x.toLanguageString(i.promptBoxAttachFile,i.messages[i.promptBoxAttachFile]),_registerRemoveCallback:e=>{_.current=e}},speechToTextButtonProps:{fillMode:"flat",size:"small",rounded:"full",onResult:be},actionButtonProps:{rounded:"full",size:"small",svgIcon:k?oe.stopIcon:oe.arrowUpIcon,className:k?"k-generating":"",onClick:K,onMouseDown:ge,disabled:!k&&!U,"aria-label":k?x.toLanguageString(i.promptBoxStopGenerating,i.messages[i.promptBoxStopGenerating]):x.toLanguageString(i.promptBoxSendButton,i.messages[i.promptBoxSendButton]),title:k?x.toLanguageString(i.promptBoxStopGenerating,i.messages[i.promptBoxStopGenerating]):x.toLanguageString(i.promptBoxSendButton,i.messages[i.promptBoxSendButton]),"aria-live":"polite"}}),[be,ye,R,K,ge,k,Be,x,U]),De=t.useCallback(e=>{A||Y(l=>l.filter(a=>a.name!==e));const n=typeof h=="object"&&h.onRemoveAttachment;n&&(_.current=n),_.current&&_.current(e)},[h,A]),ee=()=>{const e=j!==!1,n=z!==!1,l=h!==!1,a=typeof j=="object"?j:void 0,B=typeof h=="object"?h:{},{restrictions:te,multiple:X=!0,accept:I,onSelectAttachments:ke,onRemoveAttachment:nt,...We}=B,ne={restrictions:te,multiple:X,accept:I},Ve=typeof z=="object"?z:void 0;return t.createElement(t.Fragment,null,l&&t.createElement(Ze.PromptBoxUploadButton,{...b.uploadButtonProps,restrictions:ne.restrictions,multiple:ne.multiple,accept:ne.accept,...We}),e&&t.createElement(Xe.PromptBoxSpeechToTextButton,{...b.speechToTextButtonProps,...a}),n&&t.createElement(Ke.PromptBoxActionButton,{...b.actionButtonProps,...Ve}))},ve=s==="multi"||s==="auto"&&c,xe=h!==!1||j!==!1||z!==!1,Ce=v||xe,Ue=C||v||xe;return t.createElement("div",{...He,className:d.classNames(Oe,"k-input",g,{[`k-input-${re}`]:re,"k-disabled":p,"k-prompt-box-singleline":s==="single","k-prompt-box-multiline":ve}),style:Me},t.createElement(Je.FileBox,{files:R,onRemoveFile:De,header:Ne}),s==="single"?t.createElement("div",{className:`${g}-content`},C&&t.createElement("div",{className:`${g}-affix`},T(C,b)),t.createElement("input",{...he,className:d.classNames("k-input-inner",`${g}-input`)}),Ce?t.createElement("div",{className:`${g}-affix`},v&&T(v,b),ee()):null):t.createElement("div",{className:`${g}-content`},s==="multi"&&ie&&t.createElement("div",{className:`${g}-affix`},T(ie,b)),s==="auto"&&!c&&C&&t.createElement("div",{className:`${g}-affix`},T(C,b)),t.createElement("textarea",{...he,className:d.classNames("k-input-inner",`${g}-textarea`),rows:$e(),style:u?{maxHeight:u}:{},"aria-multiline":"true"}),s==="auto"&&!c&&Ce?t.createElement("div",{className:`${g}-affix`},v&&T(v,b),ee()):null,ve&&Ue?t.createElement("div",{className:`${g}-affix`},C&&T(C,b),(C||v)&&t.createElement("div",{className:"k-spacer"}),v&&T(v,b),ee()):null),F&&t.createElement(d.WatermarkOverlay,{message:$}))});se.propTypes={value:o.string,defaultValue:o.string,mode:o.oneOf(["single","multi","auto"]),rows:o.number,maxTextAreaHeight:o.string,title:o.string,disabled:o.bool,readOnly:o.bool,placeholder:o.string,maxLength:o.number,inputAttributes:o.object,fillMode:o.oneOf(["solid","flat","outline"]),topAffix:o.oneOfType([o.func,o.element,o.string]),startAffix:o.oneOfType([o.func,o.element,o.string]),endAffix:o.oneOfType([o.func,o.element,o.string]),header:o.oneOfType([o.func,o.element,o.string]),onChange:o.func,onFocus:o.func,onBlur:o.func,loading:o.bool,uploadButtonConfig:o.oneOfType([o.bool,o.object]),speechToTextButtonConfig:o.oneOfType([o.bool,o.object]),actionButtonConfig:o.oneOfType([o.bool,o.object]),attachments:o.array,onPromptAction:o.func,className:o.string,style:o.object};se.displayName="KendoPromptBox";exports.PromptBox=se;
|
package/prompt-box/PromptBox.mjs
CHANGED
|
@@ -7,16 +7,16 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import * as t from "react";
|
|
9
9
|
import o from "prop-types";
|
|
10
|
-
import { validatePackage as
|
|
11
|
-
import { stopIcon as
|
|
12
|
-
import { PromptBoxActionButton as
|
|
13
|
-
import { PromptBoxSpeechToTextButton as
|
|
14
|
-
import { PromptBoxUploadButton as
|
|
15
|
-
import { FileBox as
|
|
10
|
+
import { validatePackage as Je, getLicenseMessage as Qe, dispatchEvent as O, classNames as ne, WatermarkOverlay as Ye } from "@progress/kendo-react-common";
|
|
11
|
+
import { stopIcon as et, arrowUpIcon as tt, paperclipIcon as nt } from "@progress/kendo-svg-icons";
|
|
12
|
+
import { PromptBoxActionButton as ot } from "./PromptBoxActionButton.mjs";
|
|
13
|
+
import { PromptBoxSpeechToTextButton as st } from "./PromptBoxSpeechToTextButton.mjs";
|
|
14
|
+
import { PromptBoxUploadButton as lt } from "./PromptBoxUploadButton.mjs";
|
|
15
|
+
import { FileBox as rt } from "./FileBox.mjs";
|
|
16
16
|
import { packageMetadata as ke } from "../package-metadata.mjs";
|
|
17
|
-
import { useLocalization as
|
|
18
|
-
import { promptBoxInput as Ee, messages as
|
|
19
|
-
const p = "k-prompt-box",
|
|
17
|
+
import { useLocalization as it } from "@progress/kendo-react-intl";
|
|
18
|
+
import { promptBoxInput as Ee, messages as A, promptBoxStopGenerating as K, promptBoxSendButton as q, promptBoxAttachFile as G } from "../messages/index.mjs";
|
|
19
|
+
const p = "k-prompt-box", at = 20, ct = 50, b = {
|
|
20
20
|
mode: "auto",
|
|
21
21
|
rows: 1,
|
|
22
22
|
defaultValue: "",
|
|
@@ -26,64 +26,64 @@ const p = "k-prompt-box", ct = 20, ut = 50, b = {
|
|
|
26
26
|
uploadButtonConfig: !1,
|
|
27
27
|
speechToTextButtonConfig: !0,
|
|
28
28
|
actionButtonConfig: !0
|
|
29
|
-
}, Te = t.forwardRef((
|
|
30
|
-
const
|
|
29
|
+
}, Te = t.forwardRef((xe, Ae) => {
|
|
30
|
+
const Re = !Je(ke, { component: "PromptBox" }), we = Qe(ke), v = it(), Fe = { ...b, ...xe }, {
|
|
31
31
|
mode: s = b.mode,
|
|
32
|
-
fillMode:
|
|
32
|
+
fillMode: oe,
|
|
33
33
|
rows: S = b.rows,
|
|
34
34
|
maxTextAreaHeight: c,
|
|
35
|
-
value:
|
|
36
|
-
defaultValue:
|
|
35
|
+
value: se,
|
|
36
|
+
defaultValue: Se = b.defaultValue,
|
|
37
37
|
disabled: f = b.disabled,
|
|
38
|
-
readOnly:
|
|
39
|
-
placeholder:
|
|
40
|
-
title:
|
|
38
|
+
readOnly: Pe = b.readOnly,
|
|
39
|
+
placeholder: Ne,
|
|
40
|
+
title: He,
|
|
41
41
|
maxLength: Oe,
|
|
42
|
-
inputAttributes:
|
|
43
|
-
topAffix:
|
|
44
|
-
startAffix:
|
|
45
|
-
endAffix:
|
|
46
|
-
header:
|
|
42
|
+
inputAttributes: Le,
|
|
43
|
+
topAffix: le,
|
|
44
|
+
startAffix: B,
|
|
45
|
+
endAffix: y,
|
|
46
|
+
header: Me,
|
|
47
47
|
onChange: R,
|
|
48
48
|
onFocus: X,
|
|
49
49
|
onBlur: Z,
|
|
50
50
|
onPromptAction: J,
|
|
51
|
-
attachments:
|
|
52
|
-
loading:
|
|
51
|
+
attachments: re,
|
|
52
|
+
loading: C = b.loading,
|
|
53
53
|
uploadButtonConfig: d = b.uploadButtonConfig,
|
|
54
|
-
speechToTextButtonConfig:
|
|
55
|
-
actionButtonConfig:
|
|
56
|
-
className:
|
|
57
|
-
style:
|
|
58
|
-
...
|
|
59
|
-
} =
|
|
54
|
+
speechToTextButtonConfig: L = b.speechToTextButtonConfig,
|
|
55
|
+
actionButtonConfig: M = b.actionButtonConfig,
|
|
56
|
+
className: Ie,
|
|
57
|
+
style: $e,
|
|
58
|
+
...ze
|
|
59
|
+
} = Fe, l = t.useRef(null), [je, I] = t.useState(Se), [De, Q] = t.useState([]), [a, ie] = t.useState(!1), ae = t.useRef(null), $ = t.useRef(null), P = t.useRef(0), ce = t.useRef(0), N = t.useRef(!1), ue = t.useRef(0), z = t.useRef(0), k = t.useCallback(
|
|
60
60
|
(e, n) => e ? typeof e == "function" ? e(n) : e : null,
|
|
61
61
|
[]
|
|
62
|
-
),
|
|
63
|
-
() => !!(u != null && u.trim() ||
|
|
64
|
-
[u,
|
|
62
|
+
), E = se !== void 0, u = E ? se : je, T = re !== void 0, x = T ? re : De, j = t.useMemo(
|
|
63
|
+
() => !!(u != null && u.trim() || x.length > 0),
|
|
64
|
+
[u, x.length]
|
|
65
65
|
), w = t.useCallback(() => {
|
|
66
66
|
if (!l.current || s === "single")
|
|
67
67
|
return;
|
|
68
|
-
const e = l.current, n = globalThis.getComputedStyle(e), r = Number.parseFloat(n.lineHeight) ||
|
|
69
|
-
P.current = e.offsetHeight || r + i + h,
|
|
70
|
-
}, [s, S, a]),
|
|
68
|
+
const e = l.current, n = globalThis.getComputedStyle(e), r = Number.parseFloat(n.lineHeight) || at, i = Number.parseFloat(n.paddingTop) || 0, h = Number.parseFloat(n.paddingBottom) || 0;
|
|
69
|
+
P.current = e.offsetHeight || r + i + h, ce.current = r * S + i + h, s === "auto" && !a && (z.current = e.offsetWidth);
|
|
70
|
+
}, [s, S, a]), _e = t.useCallback(() => s === "auto" ? 1 : S, [s, S]), fe = t.useCallback(
|
|
71
71
|
(e) => {
|
|
72
72
|
if (c) {
|
|
73
73
|
const n = Number.parseInt(c, 10);
|
|
74
74
|
if (e > n)
|
|
75
75
|
return n;
|
|
76
76
|
}
|
|
77
|
-
return Math.max(
|
|
77
|
+
return Math.max(ce.current, e);
|
|
78
78
|
},
|
|
79
79
|
[c]
|
|
80
80
|
), D = t.useCallback(
|
|
81
81
|
(e) => {
|
|
82
82
|
e.style.overflow = "hidden", e.style.height = `${P.current}px`;
|
|
83
|
-
const n = e.scrollHeight, r =
|
|
83
|
+
const n = e.scrollHeight, r = fe(n);
|
|
84
84
|
e.style.height = `${r}px`, c && n > Number.parseInt(c, 10) && (e.style.overflow = "");
|
|
85
85
|
},
|
|
86
|
-
[
|
|
86
|
+
[fe, c]
|
|
87
87
|
), _ = t.useCallback(
|
|
88
88
|
(e) => {
|
|
89
89
|
e.style.overflow = "hidden", e.style.height = `${P.current}px`;
|
|
@@ -91,28 +91,28 @@ const p = "k-prompt-box", ct = 20, ut = 50, b = {
|
|
|
91
91
|
e.style.height = `${r}px`, c && n > Number.parseInt(c, 10) && (e.style.overflow = "");
|
|
92
92
|
},
|
|
93
93
|
[c]
|
|
94
|
-
),
|
|
95
|
-
if (
|
|
94
|
+
), me = t.useCallback((e) => {
|
|
95
|
+
if (z.current <= 0)
|
|
96
96
|
return !1;
|
|
97
97
|
const n = e.style.height, r = e.style.width;
|
|
98
|
-
e.style.overflow = "hidden", e.style.width = `${
|
|
99
|
-
const i = e.scrollWidth <=
|
|
98
|
+
e.style.overflow = "hidden", e.style.width = `${z.current}px`, e.style.height = `${P.current}px`;
|
|
99
|
+
const i = e.scrollWidth <= z.current && e.scrollHeight <= P.current;
|
|
100
100
|
return e.style.overflow = "", r ? e.style.width = r : e.style.width = "", n ? e.style.height = n : e.style.height = "", i;
|
|
101
101
|
}, []), W = t.useCallback(
|
|
102
102
|
(e, n) => {
|
|
103
103
|
if (N.current)
|
|
104
104
|
return;
|
|
105
105
|
if ((e.scrollWidth > e.clientWidth || e.scrollHeight > e.clientHeight) && !a) {
|
|
106
|
-
N.current = !0,
|
|
106
|
+
N.current = !0, ie(!0);
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
109
109
|
if (a) {
|
|
110
110
|
_(e);
|
|
111
|
-
const i =
|
|
112
|
-
n < i &&
|
|
111
|
+
const i = ue.current;
|
|
112
|
+
n < i && me(e) && (e.style.height = "", N.current = !0, ie(!1));
|
|
113
113
|
}
|
|
114
114
|
},
|
|
115
|
-
[a, _,
|
|
115
|
+
[a, _, me]
|
|
116
116
|
), F = t.useCallback(() => {
|
|
117
117
|
var r;
|
|
118
118
|
if (s === "single" || !l.current)
|
|
@@ -130,7 +130,7 @@ const p = "k-prompt-box", ct = 20, ut = 50, b = {
|
|
|
130
130
|
requestAnimationFrame(() => {
|
|
131
131
|
if (l.current) {
|
|
132
132
|
const n = l.current;
|
|
133
|
-
s === "multi" ? D(n) : s === "auto" && W(n, e),
|
|
133
|
+
s === "multi" ? D(n) : s === "auto" && W(n, e), ue.current = e;
|
|
134
134
|
}
|
|
135
135
|
});
|
|
136
136
|
}
|
|
@@ -154,7 +154,7 @@ const p = "k-prompt-box", ct = 20, ut = 50, b = {
|
|
|
154
154
|
const r = () => {
|
|
155
155
|
clearTimeout(n), n = setTimeout(() => {
|
|
156
156
|
l.current && (s === "auto" && !a && w(), F());
|
|
157
|
-
},
|
|
157
|
+
}, ct);
|
|
158
158
|
}, i = new ResizeObserver(r);
|
|
159
159
|
return i.observe(e), () => {
|
|
160
160
|
i.disconnect(), clearTimeout(n);
|
|
@@ -174,11 +174,11 @@ const p = "k-prompt-box", ct = 20, ut = 50, b = {
|
|
|
174
174
|
return u;
|
|
175
175
|
}
|
|
176
176
|
}), [u]);
|
|
177
|
-
t.useImperativeHandle(
|
|
178
|
-
const
|
|
177
|
+
t.useImperativeHandle(Ae, m);
|
|
178
|
+
const We = t.useCallback(
|
|
179
179
|
(e) => {
|
|
180
180
|
const n = e.target.value;
|
|
181
|
-
!
|
|
181
|
+
!E && !f && I(n), R && !f && O(
|
|
182
182
|
R,
|
|
183
183
|
e,
|
|
184
184
|
{
|
|
@@ -188,18 +188,18 @@ const p = "k-prompt-box", ct = 20, ut = 50, b = {
|
|
|
188
188
|
{ value: n }
|
|
189
189
|
), s !== "single" && F();
|
|
190
190
|
},
|
|
191
|
-
[
|
|
192
|
-
),
|
|
191
|
+
[I, R, f, E, m, s, F]
|
|
192
|
+
), Ue = t.useCallback(
|
|
193
193
|
(e) => {
|
|
194
194
|
X && !f && O(X, e, m(), void 0);
|
|
195
195
|
},
|
|
196
196
|
[X, f, m]
|
|
197
|
-
),
|
|
197
|
+
), Ve = t.useCallback(
|
|
198
198
|
(e) => {
|
|
199
199
|
Z && !f && O(Z, e, m(), void 0);
|
|
200
200
|
},
|
|
201
201
|
[Z, f, m]
|
|
202
|
-
),
|
|
202
|
+
), pe = t.useCallback((e) => {
|
|
203
203
|
e.preventDefault();
|
|
204
204
|
}, []), U = t.useCallback(
|
|
205
205
|
(e) => {
|
|
@@ -209,12 +209,12 @@ const p = "k-prompt-box", ct = 20, ut = 50, b = {
|
|
|
209
209
|
m(),
|
|
210
210
|
{
|
|
211
211
|
value: u,
|
|
212
|
-
attachments:
|
|
212
|
+
attachments: x
|
|
213
213
|
}
|
|
214
|
-
),
|
|
214
|
+
), E || I(""), T || Q([]);
|
|
215
215
|
},
|
|
216
|
-
[J, m, u,
|
|
217
|
-
),
|
|
216
|
+
[J, m, u, x, E, T]
|
|
217
|
+
), Ke = t.useCallback(
|
|
218
218
|
(e) => {
|
|
219
219
|
if (!(e.key === "Enter" && e.shiftKey)) {
|
|
220
220
|
if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
@@ -222,37 +222,37 @@ const p = "k-prompt-box", ct = 20, ut = 50, b = {
|
|
|
222
222
|
return;
|
|
223
223
|
}
|
|
224
224
|
if (e.key === "Enter") {
|
|
225
|
-
if (e.preventDefault(),
|
|
225
|
+
if (e.preventDefault(), C)
|
|
226
226
|
return;
|
|
227
|
-
|
|
227
|
+
j && U(e);
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
230
|
},
|
|
231
|
-
[U,
|
|
232
|
-
),
|
|
231
|
+
[U, C, j]
|
|
232
|
+
), de = {
|
|
233
233
|
disabled: f,
|
|
234
|
-
readOnly:
|
|
235
|
-
placeholder:
|
|
236
|
-
title:
|
|
234
|
+
readOnly: Pe,
|
|
235
|
+
placeholder: Ne,
|
|
236
|
+
title: He,
|
|
237
237
|
maxLength: Oe,
|
|
238
|
-
"aria-label":
|
|
238
|
+
"aria-label": v.toLanguageString(Ee, A[Ee]),
|
|
239
239
|
value: u,
|
|
240
240
|
// let them rewrite kb navigation if needed
|
|
241
|
-
onKeyDown:
|
|
242
|
-
...
|
|
243
|
-
onChange:
|
|
244
|
-
onFocus:
|
|
245
|
-
onBlur:
|
|
241
|
+
onKeyDown: Ke,
|
|
242
|
+
...Le,
|
|
243
|
+
onChange: We,
|
|
244
|
+
onFocus: Ue,
|
|
245
|
+
onBlur: Ve,
|
|
246
246
|
ref: l
|
|
247
|
-
},
|
|
247
|
+
}, ge = t.useCallback(
|
|
248
248
|
(e) => {
|
|
249
249
|
var i, h;
|
|
250
250
|
const { isFinal: n, alternatives: r } = e;
|
|
251
251
|
if (r.length > 0) {
|
|
252
|
-
const
|
|
252
|
+
const ee = r[0];
|
|
253
253
|
if (n) {
|
|
254
|
-
const V = ((i = l.current) == null ? void 0 : i.value) || "",
|
|
255
|
-
if (
|
|
254
|
+
const V = ((i = l.current) == null ? void 0 : i.value) || "", H = (V ? `${V} ` : "") + ee.transcript;
|
|
255
|
+
if (E || I(H), R && !f) {
|
|
256
256
|
const Ce = {
|
|
257
257
|
target: l.current,
|
|
258
258
|
currentTarget: l.current
|
|
@@ -262,20 +262,20 @@ const p = "k-prompt-box", ct = 20, ut = 50, b = {
|
|
|
262
262
|
Ce,
|
|
263
263
|
{
|
|
264
264
|
...m(),
|
|
265
|
-
value:
|
|
265
|
+
value: H
|
|
266
266
|
},
|
|
267
|
-
{ value:
|
|
267
|
+
{ value: H }
|
|
268
268
|
);
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
272
|
(h = l.current) == null || h.focus();
|
|
273
273
|
},
|
|
274
|
-
[
|
|
275
|
-
),
|
|
274
|
+
[E, R, f, m]
|
|
275
|
+
), he = t.useCallback(() => {
|
|
276
276
|
var e, n;
|
|
277
|
-
(n = (e =
|
|
278
|
-
}, []),
|
|
277
|
+
(n = (e = ae.current) == null ? void 0 : e.actionElement) == null || n.click();
|
|
278
|
+
}, []), be = t.useCallback(
|
|
279
279
|
(e) => {
|
|
280
280
|
var i;
|
|
281
281
|
const n = Array.from(e.affectedFiles), r = typeof d == "object" && d.onSelectAttachments;
|
|
@@ -288,107 +288,105 @@ const p = "k-prompt-box", ct = 20, ut = 50, b = {
|
|
|
288
288
|
), g = t.useMemo(() => ({
|
|
289
289
|
uploadButtonProps: {
|
|
290
290
|
fillMode: "flat",
|
|
291
|
-
svgIcon:
|
|
291
|
+
svgIcon: nt,
|
|
292
292
|
size: "small",
|
|
293
293
|
rounded: "full",
|
|
294
|
-
onClick:
|
|
295
|
-
onFilesAdd:
|
|
296
|
-
files:
|
|
297
|
-
uploadRef:
|
|
298
|
-
"aria-label":
|
|
299
|
-
title:
|
|
294
|
+
onClick: he,
|
|
295
|
+
onFilesAdd: be,
|
|
296
|
+
files: x,
|
|
297
|
+
uploadRef: ae,
|
|
298
|
+
"aria-label": v.toLanguageString(G, A[G]),
|
|
299
|
+
title: v.toLanguageString(G, A[G]),
|
|
300
300
|
// Hidden prop to register callback overrides
|
|
301
301
|
_registerRemoveCallback: (e) => {
|
|
302
|
-
|
|
302
|
+
$.current = e;
|
|
303
303
|
}
|
|
304
304
|
},
|
|
305
305
|
speechToTextButtonProps: {
|
|
306
306
|
fillMode: "flat",
|
|
307
307
|
size: "small",
|
|
308
308
|
rounded: "full",
|
|
309
|
-
onResult:
|
|
309
|
+
onResult: ge
|
|
310
310
|
},
|
|
311
311
|
actionButtonProps: {
|
|
312
312
|
rounded: "full",
|
|
313
313
|
size: "small",
|
|
314
|
-
svgIcon:
|
|
315
|
-
className:
|
|
314
|
+
svgIcon: C ? et : tt,
|
|
315
|
+
className: C ? "k-generating" : "",
|
|
316
316
|
onClick: U,
|
|
317
|
-
onMouseDown:
|
|
318
|
-
disabled: !
|
|
319
|
-
"aria-
|
|
320
|
-
|
|
321
|
-
title: B ? y.toLanguageString(K, k[K]) : y.toLanguageString(q, k[q]),
|
|
317
|
+
onMouseDown: pe,
|
|
318
|
+
disabled: !C && !j,
|
|
319
|
+
"aria-label": C ? v.toLanguageString(K, A[K]) : v.toLanguageString(q, A[q]),
|
|
320
|
+
title: C ? v.toLanguageString(K, A[K]) : v.toLanguageString(q, A[q]),
|
|
322
321
|
"aria-live": "polite"
|
|
323
322
|
}
|
|
324
323
|
}), [
|
|
325
|
-
|
|
326
|
-
ye,
|
|
327
|
-
A,
|
|
328
|
-
U,
|
|
329
|
-
de,
|
|
330
|
-
B,
|
|
324
|
+
ge,
|
|
331
325
|
be,
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
326
|
+
x,
|
|
327
|
+
U,
|
|
328
|
+
pe,
|
|
329
|
+
C,
|
|
330
|
+
he,
|
|
331
|
+
v,
|
|
332
|
+
j
|
|
333
|
+
]), qe = t.useCallback(
|
|
335
334
|
(e) => {
|
|
336
335
|
T || Q((r) => r.filter((i) => i.name !== e));
|
|
337
336
|
const n = typeof d == "object" && d.onRemoveAttachment;
|
|
338
|
-
n && (
|
|
337
|
+
n && ($.current = n), $.current && $.current(e);
|
|
339
338
|
},
|
|
340
339
|
[d, T]
|
|
341
340
|
), Y = () => {
|
|
342
|
-
const e =
|
|
343
|
-
restrictions:
|
|
341
|
+
const e = L !== !1, n = M !== !1, r = d !== !1, i = typeof L == "object" ? L : void 0, h = typeof d == "object" ? d : {}, {
|
|
342
|
+
restrictions: ee,
|
|
344
343
|
multiple: V = !0,
|
|
345
|
-
accept:
|
|
344
|
+
accept: H,
|
|
346
345
|
onSelectAttachments: Ce,
|
|
347
|
-
onRemoveAttachment:
|
|
348
|
-
...
|
|
349
|
-
} = h,
|
|
346
|
+
onRemoveAttachment: ut,
|
|
347
|
+
...Xe
|
|
348
|
+
} = h, te = { restrictions: ee, multiple: V, accept: H }, Ze = typeof M == "object" ? M : void 0;
|
|
350
349
|
return /* @__PURE__ */ t.createElement(t.Fragment, null, r && /* @__PURE__ */ t.createElement(
|
|
351
|
-
|
|
350
|
+
lt,
|
|
352
351
|
{
|
|
353
352
|
...g.uploadButtonProps,
|
|
354
|
-
restrictions:
|
|
355
|
-
multiple:
|
|
356
|
-
accept:
|
|
357
|
-
...
|
|
353
|
+
restrictions: te.restrictions,
|
|
354
|
+
multiple: te.multiple,
|
|
355
|
+
accept: te.accept,
|
|
356
|
+
...Xe
|
|
358
357
|
}
|
|
359
358
|
), e && /* @__PURE__ */ t.createElement(
|
|
360
|
-
|
|
359
|
+
st,
|
|
361
360
|
{
|
|
362
361
|
...g.speechToTextButtonProps,
|
|
363
362
|
...i
|
|
364
363
|
}
|
|
365
|
-
), n && /* @__PURE__ */ t.createElement(
|
|
366
|
-
},
|
|
364
|
+
), n && /* @__PURE__ */ t.createElement(ot, { ...g.actionButtonProps, ...Ze }));
|
|
365
|
+
}, ye = s === "multi" || s === "auto" && a, ve = d !== !1 || L !== !1 || M !== !1, Be = y || ve, Ge = B || y || ve;
|
|
367
366
|
return /* @__PURE__ */ t.createElement(
|
|
368
367
|
"div",
|
|
369
368
|
{
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
[`k-input-${se}`]: se,
|
|
369
|
+
...ze,
|
|
370
|
+
className: ne(Ie, "k-input", p, {
|
|
371
|
+
[`k-input-${oe}`]: oe,
|
|
374
372
|
"k-disabled": f,
|
|
375
373
|
"k-prompt-box-singleline": s === "single",
|
|
376
|
-
"k-prompt-box-multiline":
|
|
374
|
+
"k-prompt-box-multiline": ye
|
|
377
375
|
}),
|
|
378
|
-
style:
|
|
376
|
+
style: $e
|
|
379
377
|
},
|
|
380
|
-
/* @__PURE__ */ t.createElement(
|
|
381
|
-
s === "single" ? /* @__PURE__ */ t.createElement("div", { className: `${p}-content` },
|
|
378
|
+
/* @__PURE__ */ t.createElement(rt, { files: x, onRemoveFile: qe, header: Me }),
|
|
379
|
+
s === "single" ? /* @__PURE__ */ t.createElement("div", { className: `${p}-content` }, B && /* @__PURE__ */ t.createElement("div", { className: `${p}-affix` }, k(B, g)), /* @__PURE__ */ t.createElement("input", { ...de, className: ne("k-input-inner", `${p}-input`) }), Be ? /* @__PURE__ */ t.createElement("div", { className: `${p}-affix` }, y && k(y, g), Y()) : null) : /* @__PURE__ */ t.createElement("div", { className: `${p}-content` }, s === "multi" && le && /* @__PURE__ */ t.createElement("div", { className: `${p}-affix` }, k(le, g)), s === "auto" && !a && B && /* @__PURE__ */ t.createElement("div", { className: `${p}-affix` }, k(B, g)), /* @__PURE__ */ t.createElement(
|
|
382
380
|
"textarea",
|
|
383
381
|
{
|
|
384
|
-
...
|
|
385
|
-
className:
|
|
386
|
-
rows:
|
|
382
|
+
...de,
|
|
383
|
+
className: ne("k-input-inner", `${p}-textarea`),
|
|
384
|
+
rows: _e(),
|
|
387
385
|
style: c ? { maxHeight: c } : {},
|
|
388
|
-
|
|
386
|
+
"aria-multiline": "true"
|
|
389
387
|
}
|
|
390
|
-
), s === "auto" && !a && Be ? /* @__PURE__ */ t.createElement("div", { className: `${p}-affix` },
|
|
391
|
-
|
|
388
|
+
), s === "auto" && !a && Be ? /* @__PURE__ */ t.createElement("div", { className: `${p}-affix` }, y && k(y, g), Y()) : null, ye && Ge ? /* @__PURE__ */ t.createElement("div", { className: `${p}-affix` }, B && k(B, g), (B || y) && /* @__PURE__ */ t.createElement("div", { className: "k-spacer" }), y && k(y, g), Y()) : null),
|
|
389
|
+
Re && /* @__PURE__ */ t.createElement(Ye, { message: we })
|
|
392
390
|
);
|
|
393
391
|
});
|
|
394
392
|
Te.propTypes = {
|