import { menu, popFilterableSimpleMenu, popupTargetFromElement, } from '@blocksuite/affine-components/context-menu'; import { SignalWatcher, WithDisposable } from '@blocksuite/global/lit'; import { AddCursorIcon } from '@blocksuite/icons/lit'; import { ShadowlessElement } from '@blocksuite/std'; import { css, nothing } from 'lit'; import { property } from 'lit/decorators.js'; import { repeat } from 'lit/directives/repeat.js'; import { html } from 'lit/static-html.js'; import { GroupTitle } from '../../../core/group-by/group-title.js'; import type { Group } from '../../../core/group-by/trait.js'; import { dragHandler } from '../../../core/utils/wc-dnd/dnd-context.js'; import type { MobileKanbanViewUILogic } from './kanban-view-ui-logic.js'; const styles = css` mobile-kanban-group { width: 260px; flex-shrink: 0; border-radius: 8px; display: flex; flex-direction: column; } .mobile-group-header { height: 32px; padding: 6px 4px; display: flex; align-items: center; justify-content: space-between; gap: 8px; overflow: hidden; } .mobile-group-body { margin-top: 4px; display: flex; flex-direction: column; padding: 0 4px; gap: 12px; } .mobile-add-card { display: flex; align-items: center; padding: 4px; border-radius: 4px; font-size: var(--data-view-cell-text-size); line-height: var(--data-view-cell-text-line-height); color: var(--affine-text-secondary-color); } `; export class MobileKanbanGroup extends SignalWatcher( WithDisposable(ShadowlessElement) ) { static override styles = styles; private readonly clickAddCard = () => { this.view.addCard('end', this.group.key); this.requestUpdate(); }; private readonly clickAddCardInStart = () => { this.view.addCard('start', this.group.key); this.requestUpdate(); }; private readonly clickGroupOptions = (e: MouseEvent) => { const ele = e.currentTarget as HTMLElement; popFilterableSimpleMenu(popupTargetFromElement(ele), [ menu.group({ items: [ menu.action({ name: 'Ungroup', hide: () => this.group.value == null, select: () => { this.group.rows.forEach(row => { this.group.manager.removeFromGroup(row.rowId, this.group.key); }); this.requestUpdate(); }, }), menu.action({ name: 'Delete Cards', select: () => { this.view.rowsDelete(this.group.rows.map(row => row.rowId)); this.requestUpdate(); }, }), ], }), ]); }; override render() { const cards = this.group.rows; return html`
${GroupTitle(this.group, { readonly: this.view.readonly$.value, clickAdd: this.clickAddCardInStart, clickOps: this.clickGroupOptions, })}
${repeat( cards, row => row.rowId, row => { return html` `; } )} ${this.view.readonly$.value ? nothing : html`
${AddCursorIcon()}
Add
`}
`; } @property({ attribute: false }) accessor group!: Group; @property({ attribute: false }) accessor kanbanViewLogic!: MobileKanbanViewUILogic; get view() { return this.kanbanViewLogic.view; } } declare global { interface HTMLElementTagNameMap { 'mobile-kanban-group': MobileKanbanGroup; } }