import { unsafeCSSVarV2 } from '@blocksuite/affine-shared/theme'; import { IS_MOBILE } from '@blocksuite/global/env'; import { MoreHorizontalIcon, PlusIcon } from '@blocksuite/icons/lit'; import { nothing } from 'lit'; import { html } from 'lit/static-html.js'; import { renderUniLit } from '../utils/uni-component/uni-component.js'; import type { Group } from './trait.js'; import type { GroupRenderProps } from './types.js'; function GroupHeaderCount(group: Group) { const cards = group.rows; if (!cards.length) { return; } return html`
${cards.length}
`; } const GroupTitleMobile = ( groupData: Group, ops: { readonly: boolean; clickAdd: (evt: MouseEvent) => void; clickOps: (evt: MouseEvent) => void; } ) => { const type = groupData.tType; if (!type) return nothing; const icon = groupData.value == null ? '' : html` `; const props: GroupRenderProps = { group: groupData, readonly: ops.readonly, }; const showColumnName = groupData.property.type$.value === 'checkbox'; const columnName = showColumnName ? html`${groupData.property.name$.value}` : nothing; return html`
${icon} ${renderUniLit(groupData.view, props)} ${columnName} ${GroupHeaderCount(groupData)}
${ops.readonly ? nothing : html`
${PlusIcon()}
${MoreHorizontalIcon()}
`} `; }; export const GroupTitle = ( groupData: Group, ops: { readonly: boolean; clickAdd: (evt: MouseEvent) => void; clickOps: (evt: MouseEvent) => void; } ) => { if (IS_MOBILE) { return GroupTitleMobile(groupData, ops); } const type = groupData.tType; if (!type) return nothing; const icon = groupData.value == null ? '' : html` `; const props: GroupRenderProps = { group: groupData, readonly: ops.readonly, }; const showColumnName = groupData.property.type$.value === 'checkbox'; const columnName = showColumnName ? html`${groupData.property.name$.value}` : nothing; return html`
${icon} ${renderUniLit(groupData.view, props)} ${columnName} ${GroupHeaderCount(groupData)}
${ops.readonly ? nothing : html`
${PlusIcon()}
${MoreHorizontalIcon()}
`} `; };