@dialpad/dialtone
Version:
Dialpad's Dialtone design system monorepo
2 lines • 9.72 kB
JavaScript
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}}),require(`../../chunk-Bmb41Sf3.cjs`);const e=require(`../../common/utils/index.cjs`),t=require(`../../_plugin-vue_export-helper-D8jCH6HB.cjs`),n=require(`../badge/badge.cjs`),r=require(`../../localization/index.cjs`),i=require(`../button/button.cjs`),a=require(`../tooltip/tooltip.cjs`),o=require(`../emoji-text-wrapper/emoji-text-wrapper.cjs`),s=require(`./general-row-constants.cjs`),c=require(`./leftbar-general-row-icon.cjs`);let l=require(`vue`),u=require(`@dialpad/dialtone-icons/vue3`);var d={compatConfig:{MODE:3},name:`DtRecipeGeneralRow`,components:{DtEmojiTextWrapper:o.default,DtBadge:n.default,DtButton:i.default,DtTooltip:a.default,DtIconPhone:u.DtIconPhone,DtIconWaveform:u.DtIconWaveform,DtRecipeLeftbarGeneralRowIcon:c.default},inheritAttrs:!1,props:{type:{type:String,default:`inbox`,validator:e=>Object.values(s.LEFTBAR_GENERAL_ROW_TYPES).includes(e)},ariaLabel:{type:String,default:``},description:{type:String,required:!0},color:{type:String,default:null,validator:e=>Object.keys(s.LEFTBAR_GENERAL_ROW_CONTACT_CENTER_COLORS).includes(e)},channelSetting:{type:String,default:null},hasUnreads:{type:Boolean,default:!1},unreadCount:{type:String,default:null},unreadMentionCount:{type:String,default:null},selected:{type:Boolean,default:!1},muted:{type:Boolean,default:!1},activeVoiceChat:{type:Boolean,default:!1},dndText:{type:String,default:``},hasCallButton:{type:Boolean,default:!1},isTyping:{type:Boolean,default:!1},iconSize:{type:String,default:`300`,validator:e=>s.LEFTBAR_GENERAL_ROW_ICON_SIZES.includes(e)}},emits:[`call`],data(){return{actionFocused:!1,labelWidth:`100%`,i18n:new r.DialtoneLocalization}},computed:{leftbarGeneralRowClasses(){return[`d-recipe-leftbar-row`,{"d-recipe-leftbar-row--no-action":!this.hasCallButton,"d-recipe-leftbar-row--has-unread":this.hasUnreads,"d-recipe-leftbar-row__unread-count":this.showUnreadCount||this.showUnreadMentionCount,"d-recipe-leftbar-row--selected":this.selected,"d-recipe-leftbar-row--muted":this.muted,"d-recipe-leftbar-row--action-focused":this.actionFocused}]},getIcon(){switch(this.type){case s.LEFTBAR_GENERAL_ROW_TYPES.CHANNELS:if(this.hasUnreads)return`channel unread`;break;case s.LEFTBAR_GENERAL_ROW_TYPES.LOCKED_CHANNEL:if(this.hasUnreads)return`locked channel unread`;break}return this.type},generalRowListeners(){return e.extractVueListeners(this.$attrs)},getAriaLabel(){return this.ariaLabel?this.ariaLabel:e.safeConcatStrings([this.typingTooltip,this.description,this.unreadCountTooltip,this.dndTextTooltip,this.activeVoiceChatTooltip])},hasActions(){return this.dndText||this.activeVoiceChat||this.showUnreadCount||this.hasCallButton||this.showUnreadMentionCount},showUnreadCount(){return!!this.unreadCount&&this.hasUnreads},showUnreadMentionCount(){return!!this.unreadMentionCount&&this.hasUnreads},hasUnreadCount(){return this.unreadCount!==null},hasUnreadMentionCount(){return this.unreadMentionCount!==null},shouldApplyCustomStyleForCountBadge(){return this.hasUnreadCount&&this.hasUnreadMentionCount},shouldApplyCustomStyleForMentionOnly(){return this.channelSetting===`always`&&!this.hasUnreadCount&&this.hasUnreadMentionCount},messageCount(){return isNaN(this.unreadCount)?this.unreadCount:Number(this.unreadCount)},mentionCount(){return isNaN(this.unreadMentionCount)?this.unreadMentionCount:Number(this.unreadMentionCount)},unreadCountTooltip(){return e.safeConcatStrings([this.unreadCount&&this.i18n.$t(`DIALTONE_UNREAD_MESSAGE_COUNT_TEXT`,{unreadCount:this.messageCount}),this.unreadMentionCount&&this.i18n.$t(`DIALTONE_UNREAD_MENTION_COUNT_TEXT`,{unreadCount:this.mentionCount})])},dndTextTooltip(){return this.dndText&&this.i18n.$t(`DIALTONE_GENERAL_ROW_DND_TEXT_TOOLTIP`)},activeVoiceChatTooltip(){return this.activeVoiceChat&&this.i18n.$t(`DIALTONE_GENERAL_ROW_ACTIVE_VOICE_CHAT_TEXT`)},callButtonTooltip(){return this.i18n.$t(`DIALTONE_GENERAL_ROW_CALL_BUTTON_TOOLTIP`)},typingTooltip(){return this.isTyping&&this.i18n.$t(`DIALTONE_TYPING_TEXT`)}},watch:{$props:{immediate:!0,deep:!0,async handler(){this.validateProps(),await this.$nextTick(),this.adjustLabelWidth()}}},mounted(){this.resizeObserver=new ResizeObserver(this.adjustLabelWidth),this.resizeObserver.observe(e.returnFirstEl(this.$el)),this.adjustLabelWidth()},beforeUnmount:function(){this.resizeObserver.disconnect()},methods:{removeClassStyleAttrs:e.removeClassStyleAttrs,addClassStyleAttrs:e.addClassStyleAttrs,validateProps(){this.type===s.LEFTBAR_GENERAL_ROW_TYPES.CONTACT_CENTER&&!Object.keys(s.LEFTBAR_GENERAL_ROW_CONTACT_CENTER_COLORS).includes(this.color)&&console.error(s.LEFTBAR_GENERAL_ROW_CONTACT_CENTER_VALIDATION_ERROR)},adjustLabelWidth(){this.labelWidth=(e.returnFirstEl(this.$el)?.querySelector(`.d-recipe-leftbar-row__primary`)?.clientWidth||0)-((e.returnFirstEl(this.$el)?.querySelector(`.d-recipe-leftbar-row__omega`)?.clientWidth||0)+(e.returnFirstEl(this.$el)?.querySelector(`.d-recipe-leftbar-row__alpha`)?.clientWidth||0)+16)+`px`}}},f=[`data-qa`,`aria-label`,`title`,`href`],p={class:`d-recipe-leftbar-row__alpha`},m={key:0,class:`d-recipe-leftbar-row__is-typing`},h={key:0,class:`d-recipe-leftbar-row__omega`},g={key:1,class:`d-recipe-leftbar-row__active-voice`},_={key:3,class:`d-recipe-leftbar-row__action`,"data-qa":`dt-recipe-leftbar-row-action`};function v(e,t,n,r,i,a){let o=(0,l.resolveComponent)(`dt-recipe-leftbar-general-row-icon`),s=(0,l.resolveComponent)(`dt-emoji-text-wrapper`),c=(0,l.resolveComponent)(`dt-tooltip`),u=(0,l.resolveComponent)(`dt-icon-waveform`),d=(0,l.resolveComponent)(`dt-badge`),v=(0,l.resolveComponent)(`dt-icon-phone`),y=(0,l.resolveComponent)(`dt-button`),b=(0,l.resolveDirective)(`dt-tooltip`);return(0,l.openBlock)(),(0,l.createElementBlock)(`div`,(0,l.mergeProps)({class:a.leftbarGeneralRowClasses},a.addClassStyleAttrs(e.$attrs),{"data-qa":`dt-recipe-leftbar-row`}),[(0,l.createElementVNode)(`a`,(0,l.mergeProps)({class:`d-recipe-leftbar-row__primary`,"data-qa":`data-qa`in e.$attrs?e.$attrs[`data-qa`]:`d-recipe-leftbar-row-link`,"aria-label":a.getAriaLabel,title:n.description,href:`href`in e.$attrs?e.$attrs.href:`javascript:void(0)`},a.removeClassStyleAttrs(e.$attrs),(0,l.toHandlers)(a.generalRowListeners,!0)),[(0,l.createElementVNode)(`div`,p,[n.isTyping?(0,l.withDirectives)(((0,l.openBlock)(),(0,l.createElementBlock)(`div`,m,[...t[3]||(t[3]=[(0,l.createElementVNode)(`span`,null,null,-1),(0,l.createElementVNode)(`span`,null,null,-1),(0,l.createElementVNode)(`span`,null,null,-1)])])),[[b,a.typingTooltip]]):(0,l.renderSlot)(e.$slots,`left`,{key:1},()=>[(0,l.createVNode)(o,{type:a.getIcon,color:n.color,"icon-size":n.iconSize,"data-qa":`dt-recipe-leftbar-row-icon`},null,8,[`type`,`color`,`icon-size`])])]),(0,l.createElementVNode)(`div`,{class:`d-recipe-leftbar-row__label`,style:(0,l.normalizeStyle)(`flex-basis: ${i.labelWidth}`)},[(0,l.renderSlot)(e.$slots,`label`,{},()=>[(0,l.createVNode)(s,{class:`d-recipe-leftbar-row__description`,"data-qa":`dt-recipe-leftbar-row-description`,size:`200`},{default:(0,l.withCtx)(()=>[(0,l.createTextVNode)((0,l.toDisplayString)(n.description),1)]),_:1})])],4)],16,f),a.hasActions?((0,l.openBlock)(),(0,l.createElementBlock)(`div`,h,[n.dndText?((0,l.openBlock)(),(0,l.createBlock)(c,{key:0,placement:`top`,message:a.dndTextTooltip},{anchor:(0,l.withCtx)(()=>[(0,l.createElementVNode)(`div`,{ref:`d-recipe-leftbar-row-dnd`,class:`d-recipe-leftbar-row__dnd`,"data-qa":`dt-recipe-leftbar-row-dnd`},(0,l.toDisplayString)(n.dndText),513)]),_:1},8,[`message`])):(0,l.createCommentVNode)(``,!0),n.activeVoiceChat?(0,l.withDirectives)(((0,l.openBlock)(),(0,l.createElementBlock)(`div`,g,[(0,l.createVNode)(u,{size:`300`})])),[[b,a.activeVoiceChatTooltip]]):a.showUnreadCount||a.showUnreadMentionCount?((0,l.openBlock)(),(0,l.createBlock)(c,{key:2,message:a.unreadCountTooltip,placement:`top`},{anchor:(0,l.withCtx)(()=>[a.showUnreadCount?((0,l.openBlock)(),(0,l.createBlock)(d,{key:0,kind:`count`,type:`bulletin`,"data-qa":`dt-recipe-leftbar-row-unread-badge`,class:(0,l.normalizeClass)([`d-recipe-leftbar-row__unread-badge`,{"d-recipe-leftbar-row__unread-count-badge":a.shouldApplyCustomStyleForCountBadge}])},{default:(0,l.withCtx)(()=>[(0,l.createTextVNode)((0,l.toDisplayString)(n.unreadCount),1)]),_:1},8,[`class`])):(0,l.createCommentVNode)(``,!0),a.showUnreadMentionCount?((0,l.openBlock)(),(0,l.createBlock)(d,{key:1,kind:`count`,type:`bulletin`,"data-qa":`dt-recipe-leftbar-row-unread-mention-badge`,class:(0,l.normalizeClass)([`d-recipe-leftbar-row__unread-badge`,{"d-recipe-leftbar-row__unread-mention-count-badge":a.shouldApplyCustomStyleForCountBadge},{"d-recipe-leftbar-row__unread-mention-only-count-badge":a.shouldApplyCustomStyleForMentionOnly}])},{default:(0,l.withCtx)(()=>[(0,l.createTextVNode)((0,l.toDisplayString)(n.unreadMentionCount),1)]),_:1},8,[`class`])):(0,l.createCommentVNode)(``,!0)]),_:1},8,[`message`])):(0,l.createCommentVNode)(``,!0),n.hasCallButton?((0,l.openBlock)(),(0,l.createElementBlock)(`div`,_,[(0,l.createVNode)(c,{message:a.callButtonTooltip,placement:`top`},{anchor:(0,l.withCtx)(()=>[(0,l.createVNode)(y,{class:`d-recipe-leftbar-row__action-button`,"data-qa":`dt-recipe-leftbar-row-action-call-button`,circle:``,size:`xs`,kind:`inverted`,"aria-label":a.callButtonTooltip,onFocus:t[0]||(t[0]=e=>i.actionFocused=!0),onBlur:t[1]||(t[1]=e=>i.actionFocused=!1),onClick:t[2]||(t[2]=(0,l.withModifiers)(t=>e.$emit(`call`,t),[`stop`]))},{icon:(0,l.withCtx)(()=>[(0,l.createVNode)(v,{size:`200`})]),_:1},8,[`aria-label`])]),_:1},8,[`message`])])):(0,l.createCommentVNode)(``,!0)])):(0,l.createCommentVNode)(``,!0)],16)}var y=t.t(d,[[`render`,v]]);exports.default=y;
//# sourceMappingURL=general-row.cjs.map