All this work comes from Marty Schoch's bleve-explorer UI, but was moved here for increased reusability.