/** * NodePalette — horizontal draggable/clickable action bar above the canvas, * grouped by module. */ import { __ } from '@wordpress/i18n'; import { toast } from '../../common/Toast'; import { actionIcon } from './utils/icons'; import { PALETTE_MIME } from './WorkflowCanvas'; const NodePalette = ( { actions, onAdd } ) => { const groups = {}; ( actions || [] ).forEach( ( a ) => { const mod = a.module || __( 'General', 'ai-marketing-expert' ); ( groups[ mod ] = groups[ mod ] || [] ).push( a ); } ); // AI modules first, then alphabetical. const moduleOrder = [ 'AI', __( 'General', 'ai-marketing-expert' ) ]; const sortedGroups = Object.entries( groups ).sort( ( [ a ], [ b ] ) => { const idxA = moduleOrder.indexOf( a ); const idxB = moduleOrder.indexOf( b ); if ( idxA !== -1 && idxB !== -1 ) return idxA - idxB; if ( idxA !== -1 ) return -1; if ( idxB !== -1 ) return 1; return a.localeCompare( b ); } ); const handleClick = ( a ) => { if ( a.available === false ) { return; } onAdd( a.type ); }; return (

{ __( 'Steps', 'ai-marketing-expert' ) }

{ __( 'Drag onto the canvas or click to add.', 'ai-marketing-expert' ) }

{ sortedGroups.map( ( [ mod, items ] ) => (
{ mod }
{ items.map( ( a ) => { const unavailable = a.available === false; return ( ); } ) }
) ) }
); }; export default NodePalette;