import { NavIcon } from '../../NavIcon'; import type { RowActionItem } from './RowActionsMenu'; function RowSep() { return |; } /** Icon name from shared icons.json; optional per action key. */ function iconForAction(item: RowActionItem): string { const k = item.key; if (k === 'view') { return 'arrowTopRightOnSquare'; } if (k === 'trash' || k === 'delete_perm' || k === 'delete') { return 'trash'; } if (k === 'restore') { return 'arrowUturnLeft'; } if (k === 'publish') { return 'iconPublish'; } if (k === 'draft') { return 'iconSaveDraft'; } if (k === 'pending') { return 'schedule'; } if (k === 'private') { return 'cog'; } if (k === 'builder' || k === 'edit') { return 'pencil'; } return 'chevronRight'; } const wrapClass = 'inline-flex items-center gap-0.5 rounded px-0.5 py-0.5 text-xs font-normal text-slate-400 transition-colors hover:text-slate-600 focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500/40 focus-visible:ring-offset-1 dark:text-slate-500 dark:hover:text-slate-300 dark:focus-visible:ring-offset-slate-900'; const iconClass = 'h-3 w-3 shrink-0 opacity-70'; function renderItem(item: RowActionItem) { const icon = iconForAction(item); if ('href' in item) { return ( {item.label} ); } return ( ); } /** * WordPress-style row actions under the title cell. Hidden until the table row is hovered * (see {@link DataTable} `group` on rows) or an action is focused. */ export function InlineRowActions({ items, ariaLabel }: { items: RowActionItem[]; ariaLabel?: string }) { if (items.length === 0) { return null; } return (
{items.map((item, i) => ( {i > 0 ? : null} {renderItem(item)} ))}
); }