import { nothing } from 'lit'; import { html } from 'lit/static-html.js'; import { renderUniLit } from '../../../_common/components/uni-component/uni-component.js'; import { MoreHorizontalIcon, PlusIcon } from '../../../_common/icons/index.js'; import type { GroupData } from './helper.js'; import type { GroupRenderProps } from './matcher.js'; function GroupHeaderCount(group: GroupData) { const cards = group.rows; if (!cards.length) { return; } return html`
${cards.length}
`; } export function GroupTitle( groupData: GroupData, ops: { readonly: boolean; clickAdd: (evt: MouseEvent) => void; clickOps: (evt: MouseEvent) => void; } ) { const data = groupData.helper.groupConfig(); if (!data) return nothing; const icon = groupData.value == null ? '' : html` `; const props: GroupRenderProps = { value: groupData.value, data: groupData.helper.data, updateData: groupData.helper.updateData, updateValue: value => groupData.helper.updateValue(groupData.rows, value), readonly: ops.readonly, }; return html`
${icon} ${renderUniLit(data.view, props)} ${GroupHeaderCount(groupData)}
${ops.readonly ? nothing : html`
${PlusIcon}
${MoreHorizontalIcon}
`} `; }