UNPKG

tdesign-miniprogram

Version:
1 lines 1.71 kB
import{__decorate}from"tslib";import{SuperComponent,wxComponent}from"../common/src/index";import props from"./props";import config from"../common/config";const{prefix:prefix}=config,name=`${prefix}-chat-message`;let ChatMessage=class extends SuperComponent{constructor(){super(...arguments),this.options={multipleSlots:!0},this.properties=props,this.data={classPrefix:name,article:"",showAvatar:null,showName:null,showDateTime:null,contentClasses:[],chatItemClass:[]},this.observers={avatar(){this.setShowAvatar()},name(){this.setShowName()},datetime(){this.setShowDateTime()},classPrefix(){this.setContentClasses()},"classPrefix, variant, placement, showDateTime"(){this.setChatItemClass()}},this.methods={handleLongPress(t){this.triggerEvent("longpress",{e:t,id:this.data.chatId})},setShowAvatar(){var t;this.setData({showAvatar:(null===(t=this.properties)||void 0===t?void 0:t.avatar)||""})},setShowName(){var t;this.setData({showName:(null===(t=this.properties)||void 0===t?void 0:t.name)||""})},setShowDateTime(){var t;this.setData({showDateTime:(null===(t=this.properties)||void 0===t?void 0:t.datetime)||""})},setContentClasses(){this.setData({contentClasses:[`${this.data.classPrefix}__content`]})},setChatItemClass(){const{classPrefix:t,showDateTime:e}=this.data,{variant:s,role:a,placement:i}=this.properties,o=[`${t}`,`${t}--${s}`,a,i];e&&o.push(`${t}__header`),this.setData({chatItemClass:o})}},this.lifetimes={created(){this.data.handleLongPress=this.handleLongPress.bind(this)},attached(){this.setShowAvatar(),this.setShowName(),this.setShowDateTime(),this.setContentClasses(),this.setChatItemClass()},detached(){}}}};ChatMessage=__decorate([wxComponent()],ChatMessage);export default ChatMessage;