import { SignalWatcher, WithDisposable } from '@blocksuite/global/lit'; import { CheckBoxCheckSolidIcon, CheckBoxUnIcon } from '@blocksuite/icons/lit'; import { ShadowlessElement } from '@blocksuite/std'; import { computed, effect } from '@preact/signals-core'; import clsx from 'clsx'; import { nothing } from 'lit'; import { property } from 'lit/decorators.js'; import { html } from 'lit/static-html.js'; import type { VirtualTableViewUILogic } from '../table-view-ui-logic.js'; import type { TableGridCell } from '../types.js'; import * as styles from './row-header-css.js'; export class TableRowHeader extends SignalWatcher( WithDisposable(ShadowlessElement) ) { get view() { return this.tableViewLogic.view; } override connectedCallback(): void { super.connectedCallback(); this.disposables.add( effect(() => { const rowSelected = this.rowSelected$.value; if (rowSelected) { this.parentElement?.classList.add(styles.rowSelectedBg); } else { this.parentElement?.classList.remove(styles.rowSelectedBg); } }) ); this.disposables.addFromEvent(this.parentElement, 'mouseenter', () => { this.gridCell.data.hover$.value = true; }); this.disposables.addFromEvent(this.parentElement, 'mouseleave', () => { this.gridCell.data.hover$.value = false; }); } private readonly selectRow = () => { if (this.view.readonly$.value) { return; } this.selectionController?.toggleRow(this.rowId, this.groupKey); }; get selectionController() { return this.tableViewLogic.selectionController; } get rowSelected$() { return this.gridCell.row.data.selected$; } renderDragHandle = () => { const dragHandlerClass = clsx( styles.dragHandler, this.rowSelected$.value && styles.rowSelectedBg, this.rowHover$.value && styles.show ); return html`