UNPKG

jodit-pro

Version:

PRO Version of Jodit Editor

2 lines (1 loc) 2.83 kB
var p=Object.defineProperty;var h=(r,t)=>p(r,"name",{value:t,configurable:!0});var a,l=function(r,t,n,o){var s=arguments.length,e=s<3?t:o===null?o=Object.getOwnPropertyDescriptor(t,n):o,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")e=Reflect.decorate(r,t,n,o);else for(var d=r.length-1;d>=0;d--)(i=r[d])&&(e=(s<3?i(e):s>3?i(t,n,e):i(t,n))||e);return s>3&&e&&Object.defineProperty(t,n,e),e};import{autobind as v,component as u,watch as m}from"jodit/esm/core/decorators/index.js";import{UIElement as f}from"jodit/esm/core/ui/index.js";import{UIButton as j}from"jodit/esm/core/ui/button/index.js";import{Confirm as _}from"jodit/esm/modules/dialog/confirm.js";let c=(a=class extends f{className(){return"UIConversationListItem"}constructor(t,n,o=!1,s){super(t),this.opts=s,this.conversation=n,this.isActive=o,this.updateContent()}render(){return'<div class="jodit-ui-conversation-list__item"></div>'}setActive(t){this.isActive=t,this.updateContent()}updateContent(){const t=this.container;t.innerHTML="",t.setAttribute("data-id",this.conversation.id),this.isActive?t.classList.add("jodit-ui-conversation-list__item_active"):t.classList.remove("jodit-ui-conversation-list__item_active");const n=this.j.c.div("jodit-ui-conversation-list__item-avatar");n.textContent="AI",t.appendChild(n);const o=this.j.c.div("jodit-ui-conversation-list__item-wrapper"),s=this.j.c.div("jodit-ui-conversation-list__item-content"),e=this.j.c.div("jodit-ui-conversation-list__item-title");if(e.textContent=this.conversation.title,s.appendChild(e),this.opts.showTimestamps){const i=this.j.c.div("jodit-ui-conversation-list__item-meta");i.textContent=this.opts.formatTimestamp(this.conversation.updated,this.j.i18n.bind(this.j)),s.appendChild(i)}if(o.appendChild(s),this.conversation.messageCount>0){const i=this.j.c.div("jodit-ui-conversation-list__item-badge");i.textContent=String(this.conversation.messageCount),o.appendChild(i)}t.appendChild(o),this.deleteButton||(this.deleteButton=new j(this.j,{icon:{name:"bin"},variant:"outline",size:"tiny",tooltip:"Delete conversation"}),this.deleteButton.container.classList.add("jodit-ui-conversation-list__item-delete"),this.deleteButton.onAction(i=>{i.stopPropagation(),this.onDelete()})),t.appendChild(this.deleteButton.container)}onClick(){this.j.e.fire("selectConversation.ai-assistant-pro",this.conversation.id)}onDelete(){_.call(void 0,this.j.i18n("Are you sure you want to delete this conversation?"),this.j.i18n("Delete conversation"),t=>{t&&this.j.e.fire("deleteConversation.ai-assistant-pro",this.conversation.id)})}destruct(){var t;(t=this.deleteButton)===null||t===void 0||t.destruct(),super.destruct()}},h(a,"UIConversationListItem"),a);l([m("container:click")],c.prototype,"onClick",null),l([v],c.prototype,"onDelete",null),c=l([u],c);export{c as UIConversationListItem};