2323"""
2424from __future__ import annotations
2525
26+ import asyncio
2627import copy
2728import os
2829from typing import (
@@ -261,6 +262,12 @@ def width(self):
261262 def _is_v2 (self ) -> bool :
262263 return True
263264
265+ async def serialise (self , ctx ) -> Dict [str , Any ]:
266+ components = await asyncio .gather (* [
267+ child .serialise (ctx ) for child in self ._children
268+ ])
269+ return self ._to_component_dict (components )
270+
264271 def to_components (self ) -> List [Dict [str , Any ]]:
265272 components = []
266273 for child in sorted (self ._children , key = lambda i : i ._rendered_row or 0 ):
@@ -269,7 +276,9 @@ def to_components(self) -> List[Dict[str, Any]]:
269276
270277 def to_component_dict (self ) -> Dict [str , Any ]:
271278 components = self .to_components ()
279+ return self ._to_component_dict (components )
272280
281+ def _to_component_dict (self , components : List [Dict [str , Any ]]):
273282 colour = None
274283 if self ._colour :
275284 colour = self ._colour if isinstance (self ._colour , int ) else self ._colour .value
@@ -344,11 +353,9 @@ def add_item(self, item: Item[Any]) -> Self:
344353 Maximum number of children has been exceeded (10).
345354 """
346355
347- if len (self ._children ) >= 10 :
348- raise ValueError ('maximum number of children exceeded' )
349356
350- if not isinstance (item , Item ):
351- raise TypeError (f'expected Item not { item .__class__ .__name__ } ' )
357+ # if not isinstance(item, Item):
358+ # raise TypeError(f'expected Item not {item.__class__.__name__}')
352359
353360 self ._children .append (item )
354361
0 commit comments