// SPDX-FileCopyrightText: 2024 John Livingston // // SPDX-License-Identifier: AGPL-3.0-only import type { ChannelEmojisElement } from '../channel-emojis' import type { DynamicFormHeader, DynamicFormSchema } from '../../../lib/elements/dynamic-table-form' import { maxEmojisPerChannel } from 'shared/lib/emojis' import { ptTr } from '../../../lib/directives/translation' import { html, TemplateResult } from 'lit' export function tplChannelEmojis (el: ChannelEmojisElement): TemplateResult { const tableHeaderList: DynamicFormHeader = { sn: { colName: ptTr(LOC_LIVECHAT_EMOJIS_SHORTNAME), description: ptTr(LOC_LIVECHAT_EMOJIS_SHORTNAME_DESC), headerClassList: ['peertube-livechat-emojis-col-sn'] }, url: { colName: ptTr(LOC_LIVECHAT_EMOJIS_FILE), description: ptTr(LOC_LIVECHAT_EMOJIS_FILE_DESC), headerClassList: ['peertube-livechat-emojis-col-file'] } } const tableSchema: DynamicFormSchema = { sn: { inputType: 'text', default: '' }, url: { inputType: 'image-file', default: '', colClassList: ['peertube-livechat-emojis-col-file'] } } return html`

${el.channelEmojisConfiguration?.channel.displayName} ${el.channelEmojisConfiguration?.channel.name}

${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_EMOJIS_DESC)}

${ el.channelEmojisConfiguration?.emojis?.customEmojis?.length ? html` ` : '' } ${ (el.channelEmojisConfiguration?.emojis?.customEmojis?.length ?? 0) < maxEmojisPerChannel ? html` ` : '' }
{ el.resetValidation(e) if (el.channelEmojisConfiguration) { el.channelEmojisConfiguration.emojis.customEmojis = e.detail // Fixing missing ':' for shortnames: for (const desc of el.channelEmojisConfiguration.emojis.customEmojis) { if (desc.sn === '') { continue } if (!desc.sn.startsWith(':')) { desc.sn = ':' + desc.sn } if (!desc.sn.endsWith(':')) { desc.sn += ':' } } el.requestUpdate('channelEmojisConfiguration') } } } >
` }