@dialpad/dialtone
Version:
Dialpad's Dialtone design system monorepo
220 lines (219 loc) • 5.92 kB
JavaScript
import { safeConcatStrings as w, extractVueListeners as g } from "../../common/utils/index.js";
import { DtIconUser as C } from "@dialpad/dialtone-icons/vue3";
import { resolveComponent as a, createBlock as d, openBlock as o, mergeProps as S, toHandlers as v, withCtx as t, createVNode as s, createElementVNode as h, createTextVNode as u, toDisplayString as c, createElementBlock as x, createCommentVNode as m, normalizeClass as b, createSlots as B } from "vue";
import { _ as D } from "../../_plugin-vue_export-helper-CHgC5LLL.js";
import T from "../emoji-text-wrapper/emoji-text-wrapper.js";
import k from "../general-row/general-row.js";
import R from "../avatar/avatar.js";
const q = {
compatConfig: { MODE: 3 },
name: "DtRecipeContactRow",
components: {
DtAvatar: R,
DtRecipeGeneralRow: k,
DtEmojiTextWrapper: T,
DtIconUser: C
},
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
}
},
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 g(this.$attrs);
},
contactDescription() {
return w([this.name, this.presenceText, this.userStatus]);
}
}
}, z = { class: "d-recipe-leftbar-row__status" };
function V(r, l, e, E, F, n) {
const f = a("dt-icon-user"), p = a("dt-avatar"), i = a("dt-emoji-text-wrapper"), _ = a("dt-recipe-general-row");
return o(), d(_, S({
"unread-count": e.unreadCount,
description: n.contactDescription,
"has-unreads": e.hasUnreads,
selected: e.selected,
"has-call-button": e.hasCallButton,
muted: e.muted,
"is-typing": e.isTyping
}, r.$attrs, { "data-qa": "contact-row" }, v(n.contactRowListeners), {
onCall: l[0] || (l[0] = (y) => r.$emit("call", y))
}), {
left: t(() => [
s(p, {
"full-name": e.name,
"image-src": e.avatarSrc,
color: e.avatarColor,
"image-alt": "",
size: "sm",
seed: e.avatarSeed,
presence: e.avatarPresence
}, B({ _: 2 }, [
e.noInitials ? {
name: "icon",
fn: t(() => [
s(f, { size: "200" })
]),
key: "0"
} : void 0
]), 1032, ["full-name", "image-src", "color", "seed", "presence"])
]),
label: t(() => [
s(i, {
class: "d-recipe-leftbar-row__description",
"data-qa": "dt-recipe-leftbar-row-description",
size: "200"
}, {
default: t(() => [
u(c(e.name), 1)
]),
_: 1
}),
h("div", z, [
e.presenceText ? (o(), x("span", {
key: 0,
"data-qa": "dt-recipe-leftbar-row-presence-text",
class: b(["d-recipe-leftbar-row__meta-context", n.presenceFontColorClass])
}, c(e.presenceText), 3)) : m("", !0),
e.userStatus ? (o(), d(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(() => [
u(c(e.userStatus), 1)
]),
_: 1
})) : m("", !0)
])
]),
_: 1
}, 16, ["unread-count", "description", "has-unreads", "selected", "has-call-button", "muted", "is-typing"]);
}
const G = /* @__PURE__ */ D(q, [["render", V]]);
export {
G as default
};
//# sourceMappingURL=contact-row.js.map