15
15
from ..base import BaseModel
16
16
from .display import Details , Display
17
17
from .forms import (
18
+ BaseForm ,
18
19
Form ,
19
20
FormField ,
20
21
FormFieldBoolean ,
@@ -103,7 +104,7 @@ class PageTitle(BaseModel, extra='forbid'):
103
104
"""The type of the component. Always 'PageTitle'."""
104
105
105
106
106
- class Div (BaseModel , extra = 'forbid' ):
107
+ class Div (BaseModel , defer_build = True , extra = 'forbid' ):
107
108
"""A generic container component."""
108
109
109
110
components : '_t.List[AnyComponent]'
@@ -116,7 +117,7 @@ class Div(BaseModel, extra='forbid'):
116
117
"""The type of the component. Always 'Div'."""
117
118
118
119
119
- class Page (BaseModel , extra = 'forbid' ):
120
+ class Page (BaseModel , defer_build = True , extra = 'forbid' ):
120
121
"""Similar to `container` in many UI frameworks, this acts as a root component for most pages."""
121
122
122
123
components : '_t.List[AnyComponent]'
@@ -240,7 +241,7 @@ class Button(BaseModel, extra='forbid'):
240
241
"""The type of the component. Always 'Button'."""
241
242
242
243
243
- class Link (BaseModel , extra = 'forbid' ):
244
+ class Link (BaseModel , defer_build = True , extra = 'forbid' ):
244
245
"""Link component."""
245
246
246
247
components : '_t.List[AnyComponent]'
@@ -328,7 +329,7 @@ class Footer(BaseModel, extra='forbid'):
328
329
"""The type of the component. Always 'Footer'."""
329
330
330
331
331
- class Modal (BaseModel , extra = 'forbid' ):
332
+ class Modal (BaseModel , defer_build = True , extra = 'forbid' ):
332
333
"""Modal component that displays a modal dialog."""
333
334
334
335
title : str
@@ -353,7 +354,7 @@ class Modal(BaseModel, extra='forbid'):
353
354
"""The type of the component. Always 'Modal'."""
354
355
355
356
356
- class ServerLoad (BaseModel , extra = 'forbid' ):
357
+ class ServerLoad (BaseModel , defer_build = True , extra = 'forbid' ):
357
358
"""A component that will be replaced by the server with the component returned by the given URL."""
358
359
359
360
path : str
@@ -539,7 +540,7 @@ class Spinner(BaseModel, extra='forbid'):
539
540
"""The type of the component. Always 'Spinner'."""
540
541
541
542
542
- class Toast (BaseModel , extra = 'forbid' ):
543
+ class Toast (BaseModel , defer_build = True , extra = 'forbid' ):
543
544
"""Toast component that displays a toast message (small temporary message)."""
544
545
545
546
title : str
@@ -636,3 +637,14 @@ class Custom(BaseModel, extra='forbid'):
636
637
"""Union of all components.
637
638
638
639
Pydantic discriminator field is set to 'type' to allow for efficient serialization and deserialization of the components."""
640
+
641
+ # Rebuild models:
642
+ BaseForm .model_rebuild (_types_namespace = {'AnyComponent' : AnyComponent })
643
+ Form .model_rebuild (_types_namespace = {'AnyComponent' : AnyComponent })
644
+ ModelForm .model_rebuild (_types_namespace = {'AnyComponent' : AnyComponent })
645
+ Div .model_rebuild (_types_namespace = {'AnyComponent' : AnyComponent })
646
+ Page .model_rebuild (_types_namespace = {'AnyComponent' : AnyComponent })
647
+ Link .model_rebuild (_types_namespace = {'AnyComponent' : AnyComponent })
648
+ Modal .model_rebuild (_types_namespace = {'AnyComponent' : AnyComponent })
649
+ ServerLoad .model_rebuild (_types_namespace = {'AnyComponent' : AnyComponent })
650
+ Toast .model_rebuild (_types_namespace = {'AnyComponent' : AnyComponent })
0 commit comments