(this.reactions?.map((item: ReactableType) => [item.content, item])).values(),
];
const emojiParts = {
"wy-emoji-icon": true,
"wy-emoji-icon-sm": this.small,
};
const reactionButtons = singleReaction
? html`
${this.reactions && this.reactions?.length > 1
? html` this.handleReactionsClick()}
>
${this.reactions.length}
`
: nothing}
{
void this.handleReaction(singleReaction);
}}
@keydown=${clickOnEnterAndConsumeOnSpace}
@keyup=${clickOnSpace}
title=${msg("React", { desc: "Button action to react" })}
>
${singleReaction}
`
: html`
${groupedReactions.length
? html`
this.handleReactionsClick()}
>
${groupedReactions.map((r) => {
return html`${r.content}`;
})}
${this.reactions && this.reactions?.length > 1
? html`${this.reactions.length}`
: nothing}
`
: nothing}
this.handleClickToggle(e)}
@keydown=${clickOnEnterAndConsumeOnSpace}
@keyup=${clickOnSpace}
title=${msg("React", { desc: "Button action to react" })}
>
this.handleClickToggle(e)}
@keyup=${clickOnEnterAndSpace}
?hidden=${!this.show}
popover=${ifDefined(isPopoverPolyfilled() ? undefined : "auto")}
>
${this.emojis.split(" ").map(
(emoji) =>
html`
{
void this.handleReaction(emoji);
}}
>
${emoji}
`
)}
`;
const reactionSheet = html`
${this.weavy && this.showSheet
? html`
(this.showSheet = false)}>
${msg("Reactions")}
${this.showSheet && fullReactionList && !isPending
? html`
${fullReactionList.data?.map(
(reaction) => html` `
)}
`
: nothing}
`
: nothing}
`;
const lineParts = {
"wy-reactions-line": true,
"wy-reactions-line-reverse": this.lineReverse,
"wy-reactions-line-bottom": this.lineBottom,
"wy-reactions-line-below": this.lineBelow,
};
return this.line || this.lineReverse || this.lineBottom || this.lineBelow
? html`
${reactionButtons}
${reactionSheet}
`
: [reactionButtons, reactionSheet];
}
protected override firstUpdated(_changedProperties: PropertyValueMap) {
this.menuRef.value?.addEventListener(this.menuRef.value.popover ? "toggle" : "click", (e: Event) =>
this.handleClose(e as ToggleEvent)
);
}
override disconnectedCallback(): void {
this._computePositionCleanup?.();
super.disconnectedCallback();
}
}
/**
* Individual reaction item used inside the reactions sheet.
*
* **Used sub components:**
*
* - [``](./ui/wy-item.ts)
* - [``](./ui/wy-avatar.ts)
*
* @csspart wy-emoji-icon - Emoji shown for the reaction item.
*/
@customElement("wy-reaction-item")
export class WyReactionItem extends LitElement {
static override styles = [rebootCss, emojiCss];
protected exportParts = new ShadowPartsController(this);
@property({ attribute: false })
reaction!: ReactableType;
override render() {
return html`
${this.reaction.created_by?.name}
${this.reaction.content}
`;
}
}