Coverage for src / lexigram / ui / core / slot.py: 100%

13 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-08-10 04:11 +0800

1"""Slot/Outlet component for polymorphic asChild rendering.""" 

2 

3from __future__ import annotations 

4 

5from typing import Any 

6 

7from lexigram.ui.core.base import Component 

8 

9 

10class Slot(Component): 

11 """Renders its children directly without wrapping in a DOM node. 

12 

13 Used internally by the ``asChild`` pattern to forward children 

14 through a parent component that delegates rendering. 

15 """ 

16 

17 def __init__(self, children: Any = None, **kwargs: Any) -> None: 

18 super().__init__(**kwargs) 

19 self._slot_children = children 

20 

21 def render(self) -> str: 

22 if self._slot_children is None: 

23 return "" 

24 if isinstance(self._slot_children, Component): 

25 return self._slot_children.render() 

26 return str(self._slot_children)