mirror of
https://github.com/django-components/django-components.git
synced 2025-08-08 00:07:59 +00:00
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:
parent
944bef2d95
commit
107284f474
14 changed files with 217 additions and 15 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue