@dialpad/dialtone
Version:
Dialpad's Dialtone design system monorepo
236 lines (235 loc) • 6.34 kB
JavaScript
import g from "../emoji-text-wrapper/emoji-text-wrapper.js";
import w from "../avatar/avatar.js";
import { extractVueListeners as C, safeConcatStrings as S } from "../../common/utils/index.js";
import { DtIconUser as v } from "@dialpad/dialtone-icons/vue3";
import { resolveComponent as a, openBlock as o, createBlock as u, mergeProps as h, toHandlers as b, withCtx as t, createVNode as l, createSlots as x, createTextVNode as d, toDisplayString as c, createElementVNode as B, createElementBlock as T, normalizeClass as D, createCommentVNode as m } from "vue";
import { _ as k } from "../../_plugin-vue_export-helper-CHgC5LLL.js";
import R from "../general-row/general-row.js";
const q = {
compatConfig: { MODE: 3 },
name: "DtRecipeContactRow",
components: {
DtAvatar: w,
DtRecipeGeneralRow: R,
DtEmojiTextWrapper: g,
DtIconUser: v
},
inheritAttrs: !1,
props: {
/**
* Optional avatar image url.
* If not provided it will use the initial of the name.
*/
avatarSrc: {
type: String,
default: ""
},
/**
* Determines whether to show the presence indicator for
* Avatar - accepts PRESENCE_STATES values: 'busy', 'away', 'offline',
* or 'active'. By default, it's null and nothing is shown.
* defer validation to avatar component.
* @values null, busy, away, offline, active
*/
avatarPresence: {
type: String,
default: null
},
/**
* Avatar seed, set this to the user's ID to get the same avatar background gradient each time it is displayed.
*/
avatarSeed: {
type: String,
default: null
},
/**
* Avatar color to display if `avatarSrc` is empty.
*/
avatarColor: {
type: String,
default: null
},
/**
* Text describing the user's presence, such as "in a meeting"
*/
presenceText: {
type: String,
default: ""
},
/**
* Name of the contact
*/
name: {
type: String,
required: !0
},
/**
* Status as set by the user.
*/
userStatus: {
type: String,
default: ""
},
/**
* Gives a faded style to be used when muted
*/
muted: {
type: Boolean,
default: !1
},
/**
* Number of unread messages
*/
unreadCount: {
type: String,
default: null
},
/**
* Styles the row with an increased font weight to convey it has unreads. This must be true to see
* the unread count badge.
*/
hasUnreads: {
type: Boolean,
default: !1
},
/**
* Determines if the row is selected
*/
selected: {
type: Boolean,
default: !1
},
/**
* Initials will never be shown. Instead it will show a "User" icon.
*/
noInitials: {
type: Boolean,
default: !1
},
/**
* Shows an "is typing" animation over the avatar when true.
*/
isTyping: {
type: Boolean,
default: !1
},
/**
* Whether the contact row should display a call button when hovered.
*/
hasCallButton: {
type: Boolean,
default: !0
},
/**
* Text shown when the call button is hovered.
*/
callButtonTooltip: {
type: String,
default: ""
},
/**
* Text shown when the unread count is hovered.
*/
unreadCountTooltip: {
type: String,
default: ""
}
},
emits: [
/**
* Call button clicked
*
* @event call
* @type {PointerEvent | KeyboardEvent}
*/
"call"
],
computed: {
presenceFontColorClass() {
return {
active: "d-recipe-contact-row--active",
busy: "d-recipe-contact-row--busy",
away: "d-recipe-contact-row--away"
}[this.avatarPresence];
},
contactRowListeners() {
return C(this.$attrs);
},
contactDescription() {
return S([this.name, this.presenceText, this.userStatus]);
}
}
}, z = { class: "d-recipe-leftbar-row__status" };
function V(n, s, e, E, F, r) {
const p = a("dt-icon-user"), f = a("dt-avatar"), i = a("dt-emoji-text-wrapper"), _ = a("dt-recipe-general-row");
return o(), u(_, h({
"unread-count": e.unreadCount,
description: r.contactDescription,
"has-unreads": e.hasUnreads,
selected: e.selected,
"has-call-button": e.hasCallButton,
muted: e.muted,
"is-typing": e.isTyping,
"call-button-tooltip": e.callButtonTooltip,
"unread-count-tooltip": e.unreadCountTooltip
}, n.$attrs, { "data-qa": "contact-row" }, b(r.contactRowListeners), {
onCall: s[0] || (s[0] = (y) => n.$emit("call", y))
}), {
left: t(() => [
l(f, {
"full-name": e.name,
"image-src": e.avatarSrc,
color: e.avatarColor,
"image-alt": "",
size: "sm",
seed: e.avatarSeed,
presence: e.avatarPresence
}, x({ _: 2 }, [
e.noInitials ? {
name: "icon",
fn: t(() => [
l(p, { size: "200" })
]),
key: "0"
} : void 0
]), 1032, ["full-name", "image-src", "color", "seed", "presence"])
]),
label: t(() => [
l(i, {
class: "d-recipe-leftbar-row__description",
"data-qa": "dt-recipe-leftbar-row-description",
size: "200"
}, {
default: t(() => [
d(c(e.name), 1)
]),
_: 1
}),
B("div", z, [
e.presenceText ? (o(), T("span", {
key: 0,
"data-qa": "dt-recipe-leftbar-row-presence-text",
class: D(["d-recipe-leftbar-row__meta-context", r.presenceFontColorClass])
}, c(e.presenceText), 3)) : m("", !0),
e.userStatus ? (o(), u(i, {
key: 1,
size: "100",
"element-type": "span",
"data-qa": "dt-recipe-leftbar-row-user-status",
class: "d-recipe-leftbar-row__meta-custom"
}, {
default: t(() => [
d(c(e.userStatus), 1)
]),
_: 1
})) : m("", !0)
])
]),
_: 1
}, 16, ["unread-count", "description", "has-unreads", "selected", "has-call-button", "muted", "is-typing", "call-button-tooltip", "unread-count-tooltip"]);
}
const G = /* @__PURE__ */ k(q, [["render", V]]);
export {
G as default
};
//# sourceMappingURL=contact-row.js.map