Automatically delete a component when another is no longer there (Configuration publisher)

I would like a component to be deleted automatically when another is not there, is it possible?

 

with configuration publisher I can make component B appear when A is there or make B disappear when A is there.

but I would like to make the B disappear when the A is not there. on the other hand I would like to have the choice to make the B appear or not (at my choice) when the A is there

Is it possible?