How about this, you could base the amount of space a wrap box hungrily consumes in its container on the number of children it has, this can be adjusted dynamically, or manually:
Just a mockup, the math for this can be improved, clamping the min / max size could be useful here.


