import type { ReferenceElement } from '@floating-ui/dom'; import { html } from 'lit'; import { popFilterableSimpleMenu } from '../../../_common/components/menu/index.js'; import { DeleteIcon, ExpandFullIcon, MoveLeftIcon, MoveRightIcon, } from '../../../_common/icons/index.js'; import type { PageBlockComponent } from '../../../page-block/types.js'; import { popSideDetail } from '../../common/detail/layout.js'; import type { TableSelectionController } from '../controller/selection.js'; export const openDetail = ( pageElement: PageBlockComponent | null, rowId: string, selection: TableSelectionController ) => { const old = selection.selection; selection.selection = undefined; popSideDetail({ pageElement, view: selection.host.view, rowId: rowId, onClose: () => { selection.selection = old; }, }); }; export const popRowMenu = ( pageElement: PageBlockComponent | null, ele: ReferenceElement, rowId: string, selection: TableSelectionController ) => { popFilterableSimpleMenu(ele, [ { type: 'action', name: 'Expand Row', icon: ExpandFullIcon, select: () => { openDetail(pageElement, rowId, selection); }, }, // { // 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`
${MoveLeftIcon}
`, select: () => { selection.insertRowBefore(rowId); }, }, { type: 'action', name: 'Insert After', icon: html`
${MoveRightIcon}
`, select: () => { selection.insertRowAfter(selection.selection?.groupKey, rowId); }, }, // { // type: 'action', // name: 'Duplicate', // icon: DuplicateIcon, // select: () => { // selection.duplicateRow(rowId); // }, // }, ], }, { type: 'group', name: '', children: () => [ { type: 'action', name: 'Delete Row', class: 'delete-item', icon: DeleteIcon, select: () => { selection.deleteRow(rowId); }, }, ], }, ]); };