feat: registry.has(); helpers to get all components and registries; access component from ext class (#1030)

* feat: registry.has(); helpers to get all components and registries; access component from ext class

* refactor: add missing import
This commit is contained in:
Juro Oravec 2025-03-18 11:30:53 +01:00 committed by GitHub
parent 944bef2d95
commit 107284f474
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 217 additions and 15 deletions

View file

@ -111,7 +111,7 @@ CssDataType = TypeVar("CssDataType", bound=Mapping[str, Any])
# NOTE: `ReferenceType` is NOT a generic pre-3.9
if sys.version_info >= (3, 9):
AllComponents = List[ReferenceType["Component"]]
AllComponents = List[ReferenceType[Type["Component"]]]
else:
AllComponents = List[ReferenceType]
@ -120,6 +120,16 @@ else:
ALL_COMPONENTS: AllComponents = []
def all_components() -> List[Type["Component"]]:
"""Get a list of all created [`Component`](../api#django_components.Component) classes."""
components: List[Type["Component"]] = []
for comp_ref in ALL_COMPONENTS:
comp = comp_ref()
if comp is not None:
components.append(comp)
return components
@dataclass(frozen=True)
class RenderInput(Generic[ArgsType, KwargsType, SlotsType]):
context: Context