-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy path__init__.py
More file actions
96 lines (82 loc) · 3.13 KB
/
__init__.py
File metadata and controls
96 lines (82 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
from __future__ import annotations
from typing import Any, Literal
from gradio.events import EventListener
from ....utils.dev import ModelScopeLayoutComponent, resolve_frontend_dir
from .error_boundary import AntdAlertErrorBoundary
class AntdAlert(ModelScopeLayoutComponent):
"""
Ant Design: https://ant.design/components/alert
"""
ErrorBoundary = AntdAlertErrorBoundary
EVENTS = [
EventListener("close",
callback=lambda block: block._internal.update(
bind_close_event=True)),
EventListener("click",
callback=lambda block: block._internal.update(
bind_click_event=True)),
EventListener("closable_close",
callback=lambda block: block._internal.update(
bind_closable_close_event=True))
]
# supported slots
SLOTS = ['action', 'closable.closeIcon', 'description', 'icon', 'message']
def __init__(
self,
additional_props: dict | None = None,
*,
variant: Literal['filled', 'outlined'] | None = None,
action: str | None = None,
after_close: str | None = None,
banner: bool | None = None,
closable: bool | dict | None = None,
description: str | None = None,
icon: str | None = None,
message: str | None = None,
show_icon: bool | None = None,
type: Literal['success', 'info', 'warning', 'error'] | None = None,
root_class_name: str | None = None,
class_names: dict | str | None = None,
styles: dict | str | None = None,
as_item: str | None = None,
_internal: None = None,
# gradio properties
visible: bool = True,
elem_id: str | None = None,
elem_classes: list[str] | str | None = None,
elem_style: dict | None = None,
render: bool = True,
**kwargs):
super().__init__(visible=visible,
elem_id=elem_id,
elem_classes=elem_classes,
render=render,
as_item=as_item,
elem_style=elem_style,
**kwargs)
self.class_names = class_names
self.styles = styles
self.additional_props = additional_props
self.variant = variant
self.action = action
self.after_close = after_close
self.banner = banner
self.closable = closable
self.description = description
self.icon = icon
self.message = message
self.show_icon = show_icon
self.type = type
self.root_class_name = root_class_name
FRONTEND_DIR = resolve_frontend_dir("alert")
@property
def skip_api(self):
return True
def preprocess(self, payload: None) -> None:
return payload
def postprocess(self, value: None) -> None:
return value
def example_payload(self) -> Any:
return None
def example_value(self) -> Any:
return None