import type { ReferenceElement } from '@floating-ui/dom'; import { html } from 'lit'; import { popFilterableSimpleMenu } from '../../_common/components/menu/index.js'; import { ArrowRightBigIcon, DeleteIcon, ExpandFullIcon, MoveLeftIcon, MoveRightIcon, } from '../../_common/icons/index.js'; import type { PageBlockComponent } from '../../index.js'; import { popSideDetail } from '../common/detail/layout.js'; import type { KanbanSelectionController } from './controller/selection.js'; export const openDetail = ( pageElement: PageBlockComponent | null, rowId: string, selection: KanbanSelectionController ) => { const old = selection.selection; selection.selection = undefined; popSideDetail({ pageElement, view: selection.view, rowId: rowId, onClose: () => { selection.selection = old; }, }); }; export const popCardMenu = ( pageElement: PageBlockComponent | null, ele: ReferenceElement, rowId: string, selection: KanbanSelectionController ) => { popFilterableSimpleMenu(ele, [ { type: 'action', name: 'Expand Card', icon: ExpandFullIcon, select: () => { openDetail(pageElement, rowId, selection); }, }, { type: 'sub-menu', name: 'Move To', icon: ArrowRightBigIcon, options: { input: { search: true, }, items: selection.view.groupHelper?.groups .filter(v => { const cardSelection = selection.selection; if (cardSelection?.selectionType === 'card') { return v.key !== cardSelection?.cards[0].groupKey; } return false; }) .map(group => { return { type: 'action', name: group.value != null ? group.name : 'Ungroup', select: () => { selection.moveCard(rowId, group.key); }, }; }) ?? [], }, }, // { // type: 'group', // name: '', // children: () => [ // { // type: 'action', // name: 'Copy', // icon: CopyIcon, // select: () => { // //TODO // }, // }, // { // type: 'action', // name: 'Paste', // icon: PasteIcon, // select: () => { // //TODO // }, // }, // ], // }, { type: 'group', name: '', children: () => [ { type: 'action', name: 'Insert Before', icon: html`