12
12
from .. import class_name as _class_name
13
13
from .. import events
14
14
from .. import types as _types
15
+ from ..base import BaseModel
15
16
from .display import Details , Display
16
17
from .forms import (
17
18
Form ,
69
70
)
70
71
71
72
72
- class Text (_p . BaseModel , extra = 'forbid' ):
73
+ class Text (BaseModel , extra = 'forbid' ):
73
74
"""Text component that displays a string."""
74
75
75
76
text : str
@@ -79,7 +80,7 @@ class Text(_p.BaseModel, extra='forbid'):
79
80
"""The type of the component. Always 'Text'."""
80
81
81
82
82
- class Paragraph (_p . BaseModel , extra = 'forbid' ):
83
+ class Paragraph (BaseModel , extra = 'forbid' ):
83
84
"""Paragraph component that displays a string as a paragraph."""
84
85
85
86
text : str
@@ -92,7 +93,7 @@ class Paragraph(_p.BaseModel, extra='forbid'):
92
93
"""The type of the component. Always 'Paragraph'."""
93
94
94
95
95
- class PageTitle (_p . BaseModel , extra = 'forbid' ):
96
+ class PageTitle (BaseModel , extra = 'forbid' ):
96
97
"""Sets the title of the HTML page via the `document.title` property."""
97
98
98
99
text : str
@@ -102,7 +103,7 @@ class PageTitle(_p.BaseModel, extra='forbid'):
102
103
"""The type of the component. Always 'PageTitle'."""
103
104
104
105
105
- class Div (_p . BaseModel , extra = 'forbid' ):
106
+ class Div (BaseModel , extra = 'forbid' ):
106
107
"""A generic container component."""
107
108
108
109
components : '_t.List[AnyComponent]'
@@ -115,7 +116,7 @@ class Div(_p.BaseModel, extra='forbid'):
115
116
"""The type of the component. Always 'Div'."""
116
117
117
118
118
- class Page (_p . BaseModel , extra = 'forbid' ):
119
+ class Page (BaseModel , extra = 'forbid' ):
119
120
"""Similar to `container` in many UI frameworks, this acts as a root component for most pages."""
120
121
121
122
components : '_t.List[AnyComponent]'
@@ -128,7 +129,7 @@ class Page(_p.BaseModel, extra='forbid'):
128
129
"""The type of the component. Always 'Page'."""
129
130
130
131
131
- class Heading (_p . BaseModel , extra = 'forbid' ):
132
+ class Heading (BaseModel , extra = 'forbid' ):
132
133
"""Heading component."""
133
134
134
135
text : str
@@ -137,7 +138,7 @@ class Heading(_p.BaseModel, extra='forbid'):
137
138
level : _t .Literal [1 , 2 , 3 , 4 , 5 , 6 ] = 1
138
139
"""The level of the heading. 1 is the largest, 6 is the smallest."""
139
140
140
- html_id : _t .Union [str , None ] = _p . Field ( default = None , serialization_alias = 'htmlId' )
141
+ html_id : _t .Union [str , None ] = None
141
142
"""Optional HTML ID to apply to the heading's HTML component."""
142
143
143
144
class_name : _class_name .ClassNameField = None
@@ -169,7 +170,7 @@ def __get_pydantic_json_schema__(
169
170
"""
170
171
171
172
172
- class Markdown (_p . BaseModel , extra = 'forbid' ):
173
+ class Markdown (BaseModel , extra = 'forbid' ):
173
174
"""Markdown component that renders markdown text."""
174
175
175
176
text : str
@@ -185,7 +186,7 @@ class Markdown(_p.BaseModel, extra='forbid'):
185
186
"""The type of the component. Always 'Markdown'."""
186
187
187
188
188
- class Code (_p . BaseModel , extra = 'forbid' ):
189
+ class Code (BaseModel , extra = 'forbid' ):
189
190
"""Code component that renders code with syntax highlighting."""
190
191
191
192
text : str
@@ -204,7 +205,7 @@ class Code(_p.BaseModel, extra='forbid'):
204
205
"""The type of the component. Always 'Code'."""
205
206
206
207
207
- class Json (_p . BaseModel , extra = 'forbid' ):
208
+ class Json (BaseModel , extra = 'forbid' ):
208
209
"""JSON component that renders JSON data."""
209
210
210
211
value : _types .JsonData
@@ -217,18 +218,16 @@ class Json(_p.BaseModel, extra='forbid'):
217
218
"""The type of the component. Always 'JSON'."""
218
219
219
220
220
- class Button (_p . BaseModel , extra = 'forbid' ):
221
+ class Button (BaseModel , extra = 'forbid' ):
221
222
"""Button component."""
222
223
223
224
text : str
224
225
"""The text to display on the button."""
225
226
226
- on_click : _t .Union [events .AnyEvent , None ] = _p . Field ( default = None , serialization_alias = 'onClick' )
227
+ on_click : _t .Union [events .AnyEvent , None ] = None
227
228
"""Optional event to trigger when the button is clicked."""
228
229
229
- html_type : _t .Union [_t .Literal ['button' , 'reset' , 'submit' ], None ] = _p .Field (
230
- default = None , serialization_alias = 'htmlType'
231
- )
230
+ html_type : _t .Union [_t .Literal ['button' , 'reset' , 'submit' ], None ] = None
232
231
"""Optional HTML type of the button. If None, defaults to 'button'."""
233
232
234
233
named_style : _class_name .NamedStyleField = None
@@ -241,13 +240,13 @@ class Button(_p.BaseModel, extra='forbid'):
241
240
"""The type of the component. Always 'Button'."""
242
241
243
242
244
- class Link (_p . BaseModel , extra = 'forbid' ):
243
+ class Link (BaseModel , extra = 'forbid' ):
245
244
"""Link component."""
246
245
247
246
components : '_t.List[AnyComponent]'
248
247
"""List of components to render attached to the link."""
249
248
250
- on_click : _t .Union [events .AnyEvent , None ] = _p . Field ( default = None , serialization_alias = 'onClick' )
249
+ on_click : _t .Union [events .AnyEvent , None ] = None
251
250
"""Optional event to trigger when the link is clicked."""
252
251
253
252
mode : _t .Union [_t .Literal ['navbar' , 'footer' , 'tabs' , 'vertical' , 'pagination' ], None ] = None
@@ -266,7 +265,7 @@ class Link(_p.BaseModel, extra='forbid'):
266
265
"""The type of the component. Always 'Link'."""
267
266
268
267
269
- class LinkList (_p . BaseModel , extra = 'forbid' ):
268
+ class LinkList (BaseModel , extra = 'forbid' ):
270
269
"""List of Link components."""
271
270
272
271
links : _t .List [Link ]
@@ -282,19 +281,19 @@ class LinkList(_p.BaseModel, extra='forbid'):
282
281
"""The type of the component. Always 'LinkList'."""
283
282
284
283
285
- class Navbar (_p . BaseModel , extra = 'forbid' ):
284
+ class Navbar (BaseModel , extra = 'forbid' ):
286
285
"""Navbar component used for moving between pages."""
287
286
288
287
title : _t .Union [str , None ] = None
289
288
"""Optional title to display in the navbar."""
290
289
291
- title_event : _t .Union [events .AnyEvent , None ] = _p . Field ( default = None , serialization_alias = 'titleEvent' )
290
+ title_event : _t .Union [events .AnyEvent , None ] = None
292
291
"""Optional event to trigger when the title is clicked. Often used to navigate to the home page."""
293
292
294
- start_links : _t .List [Link ] = _p . Field ( default = [], serialization_alias = 'startLinks' )
293
+ start_links : _t .List [Link ] = []
295
294
"""List of links to render at the start of the navbar."""
296
295
297
- end_links : _t .List [Link ] = _p . Field ( default = [], serialization_alias = 'endLinks' )
296
+ end_links : _t .List [Link ] = []
298
297
"""List of links to render at the end of the navbar."""
299
298
300
299
class_name : _class_name .ClassNameField = None
@@ -313,13 +312,13 @@ def __get_pydantic_json_schema__(
313
312
return json_schema
314
313
315
314
316
- class Footer (_p . BaseModel , extra = 'forbid' ):
315
+ class Footer (BaseModel , extra = 'forbid' ):
317
316
"""Footer component."""
318
317
319
318
links : _t .List [Link ]
320
319
"""List of links to render in the footer."""
321
320
322
- extra_text : _t .Union [str , None ] = _p . Field ( default = None , serialization_alias = 'extraText' )
321
+ extra_text : _t .Union [str , None ] = None
323
322
"""Optional extra text to display in the footer."""
324
323
325
324
class_name : _class_name .ClassNameField = None
@@ -329,7 +328,7 @@ class Footer(_p.BaseModel, extra='forbid'):
329
328
"""The type of the component. Always 'Footer'."""
330
329
331
330
332
- class Modal (_p . BaseModel , extra = 'forbid' ):
331
+ class Modal (BaseModel , extra = 'forbid' ):
333
332
"""Modal component that displays a modal dialog."""
334
333
335
334
title : str
@@ -341,10 +340,10 @@ class Modal(_p.BaseModel, extra='forbid'):
341
340
footer : '_t.Union[_t.List[AnyComponent], None]' = None
342
341
"""Optional list of components to render in the modal footer."""
343
342
344
- open_trigger : _t .Union [events .PageEvent , None ] = _p . Field ( default = None , serialization_alias = 'openTrigger' )
343
+ open_trigger : _t .Union [events .PageEvent , None ] = None
345
344
"""Optional event to trigger when the modal is opened."""
346
345
347
- open_context : _t .Union [events .ContextType , None ] = _p . Field ( default = None , serialization_alias = 'openContext' )
346
+ open_context : _t .Union [events .ContextType , None ] = None
348
347
"""Optional context to pass to the open trigger event."""
349
348
350
349
class_name : _class_name .ClassNameField = None
@@ -354,13 +353,13 @@ class Modal(_p.BaseModel, extra='forbid'):
354
353
"""The type of the component. Always 'Modal'."""
355
354
356
355
357
- class ServerLoad (_p . BaseModel , extra = 'forbid' ):
356
+ class ServerLoad (BaseModel , extra = 'forbid' ):
358
357
"""A component that will be replaced by the server with the component returned by the given URL."""
359
358
360
359
path : str
361
360
"""The URL to load the component from."""
362
361
363
- load_trigger : _t .Union [events .PageEvent , None ] = _p . Field ( default = None , serialization_alias = 'loadTrigger' )
362
+ load_trigger : _t .Union [events .PageEvent , None ] = None
364
363
"""Optional event to trigger when the component is loaded."""
365
364
366
365
components : '_t.Union[_t.List[AnyComponent], None]' = None
@@ -369,7 +368,7 @@ class ServerLoad(_p.BaseModel, extra='forbid'):
369
368
sse : _t .Union [bool , None ] = None
370
369
"""Optional flag to enable server-sent events (SSE) for the server load."""
371
370
372
- sse_retry : _t .Union [int , None ] = _p . Field ( default = None , serialization_alias = 'sseRetry' )
371
+ sse_retry : _t .Union [int , None ] = None
373
372
"""Optional time in milliseconds to retry the SSE connection."""
374
373
375
374
method : _t .Union [_t .Literal ['GET' , 'POST' , 'PATCH' , 'PUT' , 'DELETE' ], None ] = None
@@ -379,7 +378,7 @@ class ServerLoad(_p.BaseModel, extra='forbid'):
379
378
"""The type of the component. Always 'ServerLoad'."""
380
379
381
380
382
- class Image (_p . BaseModel , extra = 'forbid' ):
381
+ class Image (BaseModel , extra = 'forbid' ):
383
382
"""Image container component."""
384
383
385
384
src : str
@@ -406,15 +405,15 @@ class Image(_p.BaseModel, extra='forbid'):
406
405
'unsafe-url' ,
407
406
],
408
407
None ,
409
- ] = _p . Field ( None , serialization_alias = 'referrerPolicy' )
408
+ ] = None
410
409
"""Optional referrer policy for the image. Specifies what information to send when fetching the image.
411
410
412
411
For more info, see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy."""
413
412
414
413
loading : _t .Union [_t .Literal ['eager' , 'lazy' ], None ] = None
415
414
"""Optional loading strategy for the image."""
416
415
417
- on_click : _t .Union [events .AnyEvent , None ] = _p . Field ( default = None , serialization_alias = 'onClick' )
416
+ on_click : _t .Union [events .AnyEvent , None ] = None
418
417
"""Optional event to trigger when the image is clicked."""
419
418
420
419
class_name : _class_name .ClassNameField = None
@@ -424,7 +423,7 @@ class Image(_p.BaseModel, extra='forbid'):
424
423
"""The type of the component. Always 'Image'."""
425
424
426
425
427
- class Iframe (_p . BaseModel , extra = 'forbid' ):
426
+ class Iframe (BaseModel , extra = 'forbid' ):
428
427
"""Iframe component that displays content from a URL."""
429
428
430
429
src : _p .HttpUrl
@@ -452,7 +451,7 @@ class Iframe(_p.BaseModel, extra='forbid'):
452
451
"""The type of the component. Always 'Iframe'."""
453
452
454
453
455
- class Video (_p . BaseModel , extra = 'forbid' ):
454
+ class Video (BaseModel , extra = 'forbid' ):
456
455
"""Video component that displays a video or multiple videos."""
457
456
458
457
sources : _t .List [_p .AnyUrl ]
@@ -486,7 +485,7 @@ class Video(_p.BaseModel, extra='forbid'):
486
485
"""The type of the component. Always 'Video'."""
487
486
488
487
489
- class FireEvent (_p . BaseModel , extra = 'forbid' ):
488
+ class FireEvent (BaseModel , extra = 'forbid' ):
490
489
"""Fire an event."""
491
490
492
491
event : events .AnyEvent
@@ -499,7 +498,7 @@ class FireEvent(_p.BaseModel, extra='forbid'):
499
498
"""The type of the component. Always 'FireEvent'."""
500
499
501
500
502
- class Error (_p . BaseModel , extra = 'forbid' ):
501
+ class Error (BaseModel , extra = 'forbid' ):
503
502
"""Utility component used to display an error."""
504
503
505
504
title : str
@@ -508,7 +507,7 @@ class Error(_p.BaseModel, extra='forbid'):
508
507
description : str
509
508
"""The description of the error."""
510
509
511
- status_code : _t .Union [int , None ] = _p . Field ( None , serialization_alias = 'statusCode' )
510
+ status_code : _t .Union [int , None ] = None
512
511
"""Optional status code of the error."""
513
512
514
513
class_name : _class_name .ClassNameField = None
@@ -527,7 +526,7 @@ def __get_pydantic_json_schema__(
527
526
return json_schema
528
527
529
528
530
- class Spinner (_p . BaseModel , extra = 'forbid' ):
529
+ class Spinner (BaseModel , extra = 'forbid' ):
531
530
"""Spinner component that displays a loading spinner."""
532
531
533
532
text : _t .Union [str , None ] = None
@@ -540,7 +539,7 @@ class Spinner(_p.BaseModel, extra='forbid'):
540
539
"""The type of the component. Always 'Spinner'."""
541
540
542
541
543
- class Toast (_p . BaseModel , extra = 'forbid' ):
542
+ class Toast (BaseModel , extra = 'forbid' ):
544
543
"""Toast component that displays a toast message (small temporary message)."""
545
544
546
545
title : str
@@ -566,10 +565,10 @@ class Toast(_p.BaseModel, extra='forbid'):
566
565
] = None
567
566
"""Optional position of the toast."""
568
567
569
- open_trigger : _t .Union [events .PageEvent , None ] = _p . Field ( default = None , serialization_alias = 'openTrigger' )
568
+ open_trigger : _t .Union [events .PageEvent , None ] = None
570
569
"""Optional event to trigger when the toast is opened."""
571
570
572
- open_context : _t .Union [events .ContextType , None ] = _p . Field ( default = None , serialization_alias = 'openContext' )
571
+ open_context : _t .Union [events .ContextType , None ] = None
573
572
"""Optional context to pass to the open trigger event."""
574
573
575
574
class_name : _class_name .ClassNameField = None
@@ -579,13 +578,13 @@ class Toast(_p.BaseModel, extra='forbid'):
579
578
"""The type of the component. Always 'Toast'."""
580
579
581
580
582
- class Custom (_p . BaseModel , extra = 'forbid' ):
581
+ class Custom (BaseModel , extra = 'forbid' ):
583
582
"""Custom component that allows for special data to be rendered."""
584
583
585
584
data : _types .JsonData
586
585
"""The data to render in the custom component."""
587
586
588
- sub_type : str = _p . Field ( serialization_alias = 'subType' )
587
+ sub_type : str
589
588
"""The sub-type of the custom component."""
590
589
591
590
library : _t .Union [str , None ] = None
0 commit comments