I'm trying to get an ArcGIS Layer List component to work with a mapImageLayer where each sublayer can display its own legend instead of having the legend only appear at the top level. The map service has up to 4 sublayers. The closest I got is to get the legend to appear for the top level.

As you can see, the sublayer's legend buttons are grayed out.
This is the code I used:
if (layerList) {
layerList.listItemCreatedFunction = (event: any) => {
const item = event.item
item.open = true
item.panel = {
content: 'legend',
open: false
}
}
Are there good examples of displaying legends for map services with more than 2 levels using ArcGIS Components (not widgets)?