mirror of
https://github.com/django-components/django-components.git
synced 2025-09-26 23:49:07 +00:00
feat: component URL (#1088)
* feat: allow to set defaults * refactor: remove input validation and link to it * feat: component URL * refactor: fix linter errors * refactor: fix linter errors + update examples to use Component.View..get * docs: update comment * refactor: revert change to hash_comp_cls * docs: update comment
This commit is contained in:
parent
3555411f1e
commit
a49f5e51dd
37 changed files with 987 additions and 314 deletions
|
@ -60,7 +60,9 @@ from django_components.extension import (
|
|||
OnComponentInputContext,
|
||||
extensions,
|
||||
)
|
||||
from django_components.extensions.view import ViewFn
|
||||
from django_components.extensions.defaults import ComponentDefaults
|
||||
from django_components.extensions.url import ComponentUrl
|
||||
from django_components.extensions.view import ComponentView, ViewFn
|
||||
from django_components.node import BaseNode
|
||||
from django_components.perfutil.component import ComponentRenderer, component_context_cache, component_post_render
|
||||
from django_components.perfutil.provide import register_provide_reference, unregister_provide_reference
|
||||
|
@ -570,6 +572,19 @@ class Component(
|
|||
"""
|
||||
pass
|
||||
|
||||
# #####################################
|
||||
# EXTENSIONS
|
||||
# #####################################
|
||||
|
||||
# NOTE: These are the classes and instances added by defaults extensions. These fields
|
||||
# are actually set at runtime, and so here they are only marked for typing.
|
||||
Defaults: Type[ComponentDefaults]
|
||||
defaults: ComponentDefaults
|
||||
View: Type[ComponentView]
|
||||
view: ComponentView
|
||||
Url: Type[ComponentUrl]
|
||||
url: ComponentUrl
|
||||
|
||||
# #####################################
|
||||
# MISC
|
||||
# #####################################
|
||||
|
@ -899,6 +914,8 @@ class Component(
|
|||
def as_view(cls, **initkwargs: Any) -> ViewFn:
|
||||
"""
|
||||
Shortcut for calling `Component.View.as_view` and passing component instance to it.
|
||||
|
||||
Read more on [Component views and URLs](../../concepts/fundamentals/component_views_urls).
|
||||
"""
|
||||
|
||||
# NOTE: `Component.View` may not be available at the time that URLs are being
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue