@progress/kendo-react-conversational-ui
Version:
React Chat component allows the user to participate in chat sessions with users or chat bots. KendoReact Conversational UI components
9 lines (8 loc) • 2.65 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
;const b=require("react"),g=require("@progress/kendo-react-common"),h=require("@progress/kendo-react-buttons"),d=require("@progress/kendo-svg-icons"),w=require("@progress/kendo-react-intl"),r=require("../../../messages/index.js"),F=require("../ChatContext.js");function M(a){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const o in a)if(o!=="default"){const s=Object.getOwnPropertyDescriptor(a,o);Object.defineProperty(i,o,s.get?s:{enumerable:!0,get:()=>a[o]})}}return i.default=a,Object.freeze(i)}const n=M(b),N=a=>{const{files:i,onFileRemove:o,onFileAction:s,onDownload:m,fileActions:k,renderInTextarea:I=!1}=a,{messageFilesLayout:u="vertical"}=F.useChatContext(),p=w.useLocalization(),C=[{id:"download",label:"Download",svgIcon:d.downloadIcon}],f=k||C,x=e=>{if(e==null)return"";if(e===0)return"0 B";const t=1024,c=["B","KB","MB","GB","TB"],l=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/Math.pow(t,l)).toFixed(2))} ${c[l]}`},E=e=>"."+e.split(".").pop()||"",v=(e,t)=>{var c,l;(l=(c=e.syntheticEvent)==null?void 0:c.stopPropagation)==null||l.call(c),e.item.id==="download"&&(m==null||m([t])),s==null||s(e.item,e,t)},B=e=>I?n.createElement(h.Button,{fillMode:"flat",themeColor:"base",svgIcon:d.xIcon,onClick:t=>{t.stopPropagation(),o==null||o(e.name)},"aria-label":`${p.toLanguageString(r.removeFile,r.messages[r.removeFile])} ${e.name}`}):f.length>0&&n.createElement(h.DropDownButton,{fillMode:"flat",themeColor:"base",svgIcon:d.moreVerticalIcon,onClick:t=>{t.syntheticEvent.stopPropagation()},onItemClick:t=>v(t,e),items:f.map(t=>({id:t.id,icon:t.icon,text:t.label,svgIcon:t.svgIcon})),"aria-label":`${p.toLanguageString(r.fileActions,r.messages[r.fileActions])} ${e.name}`}),z=n.useCallback(()=>g.classNames("k-chat-file-wrapper",{"k-chat-files-wrap":u==="wrap","k-chat-files-horizontal":u==="horizontal"}),[u]);return n.createElement("ul",{className:z()},i.map(e=>n.createElement("li",{key:e.name,className:"k-chat-file"},n.createElement(g.IconWrap,{size:"xlarge",...g.getFileExtensionIcon(E(e.name))}),n.createElement("div",{className:"k-chat-file-info"},n.createElement("span",{className:"k-chat-file-name"},e.name),n.createElement("span",{className:"k-chat-file-size"},x(e.size))),B(e))))};module.exports=N;