dara-components 1.21.9__py3-none-any.whl → 1.21.23__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dara/components/__init__.py +2 -1
- dara/components/common/accordion.py +11 -17
- dara/components/common/anchor.py +6 -5
- dara/components/common/base_component.py +5 -5
- dara/components/common/bullet_list.py +1 -3
- dara/components/common/button.py +11 -6
- dara/components/common/button_bar.py +6 -6
- dara/components/common/card.py +3 -5
- dara/components/common/carousel.py +5 -5
- dara/components/common/checkbox_group.py +8 -8
- dara/components/common/code.py +3 -3
- dara/components/common/component_select_list.py +6 -8
- dara/components/common/datepicker.py +6 -6
- dara/components/common/dropdown_menu.py +9 -9
- dara/components/common/dropzone.py +11 -14
- dara/components/common/form.py +3 -5
- dara/components/common/form_page.py +2 -4
- dara/components/common/grid.py +13 -13
- dara/components/common/heading.py +2 -3
- dara/components/common/icon.py +1 -3
- dara/components/common/if_cmp.py +8 -8
- dara/components/common/input.py +5 -7
- dara/components/common/label.py +3 -5
- dara/components/common/markdown.py +2 -4
- dara/components/common/overlay.py +1 -3
- dara/components/common/progress_bar.py +2 -4
- dara/components/common/radio_group.py +8 -8
- dara/components/common/select.py +10 -10
- dara/components/common/slider.py +11 -11
- dara/components/common/spacer.py +2 -4
- dara/components/common/stack.py +3 -4
- dara/components/common/switch.py +3 -5
- dara/components/common/tabbed_card.py +2 -4
- dara/components/common/table.py +38 -34
- dara/components/common/text.py +3 -5
- dara/components/common/textarea.py +5 -5
- dara/components/common/time_utils.py +1 -2
- dara/components/common/tooltip.py +3 -5
- dara/components/common/utils.py +22 -22
- dara/components/graphs/components/base_graph_component.py +19 -19
- dara/components/graphs/components/causal_graph_viewer.py +2 -4
- dara/components/graphs/components/edge_encoder.py +13 -13
- dara/components/graphs/components/node_hierarchy_builder.py +12 -12
- dara/components/graphs/definitions.py +21 -16
- dara/components/graphs/graph_layout.py +36 -37
- dara/components/plotting/bokeh/bokeh.py +5 -5
- dara/components/plotting/bokeh/utils.py +1 -3
- dara/components/plotting/plotly/plotly.py +8 -8
- dara/components/plotting/plotly/themes.py +3 -3
- dara/components/smart/chat/config.py +1 -1
- dara/components/smart/chat/types.py +3 -5
- dara/components/smart/code_editor/code_editor.py +2 -2
- dara/components/smart/code_editor/util.py +4 -4
- dara/components/smart/data_slicer/data_slicer.py +4 -6
- dara/components/smart/data_slicer/data_slicer_modal.py +1 -3
- dara/components/smart/data_slicer/extension/data_slicer_filter.py +2 -3
- dara/components/smart/data_slicer/extension/filter_status_button.py +1 -3
- dara/components/smart/data_slicer/utils/core.py +14 -14
- dara/components/smart/data_slicer/utils/data_preview.py +1 -3
- dara/components/smart/hierarchy.py +5 -5
- dara/components/umd/dara.components.umd.js +116 -38
- {dara_components-1.21.9.dist-info → dara_components-1.21.23.dist-info}/METADATA +4 -5
- dara_components-1.21.23.dist-info/RECORD +87 -0
- dara_components-1.21.9.dist-info/RECORD +0 -87
- {dara_components-1.21.9.dist-info → dara_components-1.21.23.dist-info}/LICENSE +0 -0
- {dara_components-1.21.9.dist-info → dara_components-1.21.23.dist-info}/WHEEL +0 -0
dara/components/__init__.py
CHANGED
|
@@ -17,6 +17,7 @@ limitations under the License.
|
|
|
17
17
|
# ruff: noqa: F401, F403
|
|
18
18
|
|
|
19
19
|
from importlib.metadata import version
|
|
20
|
+
from inspect import isclass
|
|
20
21
|
|
|
21
22
|
from pydantic import BaseModel
|
|
22
23
|
|
|
@@ -33,7 +34,7 @@ __version__ = version('dara-components')
|
|
|
33
34
|
|
|
34
35
|
for symbol in list(globals().values()):
|
|
35
36
|
try:
|
|
36
|
-
if issubclass(symbol, BaseModel) and symbol is not BaseModel:
|
|
37
|
+
if isclass(symbol) and issubclass(symbol, BaseModel) and symbol is not BaseModel:
|
|
37
38
|
symbol.model_rebuild()
|
|
38
39
|
except Exception as e:
|
|
39
40
|
from dara.core.logging import dev_logger
|
|
@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
|
|
|
15
15
|
limitations under the License.
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
|
-
from typing import Any
|
|
18
|
+
from typing import Any
|
|
19
19
|
|
|
20
20
|
from pydantic import field_validator
|
|
21
21
|
|
|
@@ -79,9 +79,9 @@ class AccordionItem(BaseModel):
|
|
|
79
79
|
:param content: Optional content to render
|
|
80
80
|
"""
|
|
81
81
|
|
|
82
|
-
badge:
|
|
83
|
-
label:
|
|
84
|
-
content:
|
|
82
|
+
badge: ItemBadge | None = None
|
|
83
|
+
label: str | ComponentInstance
|
|
84
|
+
content: ComponentInstance | None = None
|
|
85
85
|
|
|
86
86
|
|
|
87
87
|
class Accordion(LayoutComponent):
|
|
@@ -245,28 +245,22 @@ class Accordion(LayoutComponent):
|
|
|
245
245
|
:param onchange: An action to triggered when the component's state changes
|
|
246
246
|
"""
|
|
247
247
|
|
|
248
|
-
initial:
|
|
249
|
-
value:
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
List[int],
|
|
254
|
-
]
|
|
255
|
-
] = 0
|
|
256
|
-
onchange: Optional[Action] = None
|
|
257
|
-
items: List[AccordionItem]
|
|
258
|
-
multi: Optional[bool] = True
|
|
248
|
+
initial: int | list[int] | None = 0
|
|
249
|
+
value: Variable[int | list[int]] | int | list[int] | None = 0
|
|
250
|
+
onchange: Action | None = None
|
|
251
|
+
items: list[AccordionItem]
|
|
252
|
+
multi: bool | None = True
|
|
259
253
|
|
|
260
254
|
@field_validator('initial', mode='before')
|
|
261
255
|
@classmethod
|
|
262
|
-
def validate_initial(cls, initial: Any) ->
|
|
256
|
+
def validate_initial(cls, initial: Any) -> int | list[int]:
|
|
263
257
|
if initial is not None:
|
|
264
258
|
dev_logger.warning("Accordion's initial prop is now deprecated, please use value instead.")
|
|
265
259
|
return initial
|
|
266
260
|
|
|
267
261
|
@field_validator('items', mode='before')
|
|
268
262
|
@classmethod
|
|
269
|
-
def validate_items(cls, items: Any) ->
|
|
263
|
+
def validate_items(cls, items: Any) -> list[AccordionItem]:
|
|
270
264
|
if not isinstance(items, list):
|
|
271
265
|
raise ValueError('AccordionItems must be passed as a list to the Accordion component')
|
|
272
266
|
if len(items) == 0:
|
dara/components/common/anchor.py
CHANGED
|
@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
|
|
|
15
15
|
limitations under the License.
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
|
-
from
|
|
18
|
+
from typing_extensions import deprecated
|
|
19
19
|
|
|
20
20
|
from dara.components.common.base_component import (
|
|
21
21
|
ContentComponent,
|
|
@@ -27,6 +27,7 @@ from dara.core.definitions import discover
|
|
|
27
27
|
from dara.core.interactivity import AnyVariable, DerivedVariable, Variable
|
|
28
28
|
|
|
29
29
|
|
|
30
|
+
@deprecated('Use `dara.core.Link` instead')
|
|
30
31
|
@discover
|
|
31
32
|
class Anchor(ModifierComponent):
|
|
32
33
|
"""
|
|
@@ -60,17 +61,17 @@ class Anchor(ModifierComponent):
|
|
|
60
61
|
:param new_tab: whether to open the link in a new tab
|
|
61
62
|
"""
|
|
62
63
|
|
|
63
|
-
href:
|
|
64
|
-
name:
|
|
64
|
+
href: str | None = None
|
|
65
|
+
name: str | None = None
|
|
65
66
|
clean: bool = False
|
|
66
67
|
new_tab: bool = False
|
|
67
68
|
|
|
68
|
-
def __init__(self, child:
|
|
69
|
+
def __init__(self, child: ContentComponent | str | Variable[str] | DerivedVariable[str], **kwargs):
|
|
69
70
|
if isinstance(child, (ContentComponent, Variable, DerivedVariable, str)) is False:
|
|
70
71
|
raise LayoutError(f'Only a single ContentComponent may be passed as an Anchors child, passed : {child}')
|
|
71
72
|
|
|
72
73
|
# Handle a string or Variable being passed directly to an anchor
|
|
73
74
|
if isinstance(child, (str, AnyVariable)):
|
|
74
75
|
child = Text(child)
|
|
75
|
-
parsed_args:
|
|
76
|
+
parsed_args: list[ContentComponent] = [child]
|
|
76
77
|
super().__init__(*parsed_args, **kwargs)
|
|
@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
|
|
|
15
15
|
limitations under the License.
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
|
-
from typing import Literal
|
|
18
|
+
from typing import Literal
|
|
19
19
|
|
|
20
20
|
from pydantic import ConfigDict
|
|
21
21
|
|
|
@@ -57,7 +57,7 @@ class BaseDashboardComponent(StyledComponentInstance):
|
|
|
57
57
|
# Define JS module on the base component so we don't have to repeat that on each component
|
|
58
58
|
js_module = '@darajs/components'
|
|
59
59
|
|
|
60
|
-
def __init__(self, *args:
|
|
60
|
+
def __init__(self, *args: ComponentInstance | None, **kwargs):
|
|
61
61
|
if len(args) > 0 and len(kwargs.get('children') or []) == 0:
|
|
62
62
|
kwargs['children'] = list(arg for arg in args if arg is not None)
|
|
63
63
|
|
|
@@ -78,9 +78,9 @@ class LayoutComponent(BaseDashboardComponent):
|
|
|
78
78
|
:param align: the align-items value to be passed to the component
|
|
79
79
|
"""
|
|
80
80
|
|
|
81
|
-
position:
|
|
81
|
+
position: str | None = 'relative'
|
|
82
82
|
|
|
83
|
-
justify:
|
|
83
|
+
justify: JustifyContent | None = None
|
|
84
84
|
|
|
85
85
|
def append(self, component: ComponentInstance):
|
|
86
86
|
"""
|
|
@@ -138,4 +138,4 @@ class FormComponent(InteractiveComponent):
|
|
|
138
138
|
A subset of InteractiveComponents which must subscribe to the Form context.
|
|
139
139
|
"""
|
|
140
140
|
|
|
141
|
-
id:
|
|
141
|
+
id: str | None = None
|
|
@@ -15,8 +15,6 @@ See the License for the specific language governing permissions and
|
|
|
15
15
|
limitations under the License.
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
|
-
from typing import List, Union
|
|
19
|
-
|
|
20
18
|
from dara.components.common.base_component import ContentComponent
|
|
21
19
|
from dara.core.interactivity import DerivedVariable, Variable
|
|
22
20
|
|
|
@@ -42,5 +40,5 @@ class BulletList(ContentComponent):
|
|
|
42
40
|
:param numbered: Boolean, if True then number the bullets
|
|
43
41
|
"""
|
|
44
42
|
|
|
45
|
-
items:
|
|
43
|
+
items: list[str] | Variable | DerivedVariable
|
|
46
44
|
numbered: bool = False
|
dara/components/common/button.py
CHANGED
|
@@ -16,7 +16,7 @@ limitations under the License.
|
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
18
|
from enum import Enum
|
|
19
|
-
from typing import
|
|
19
|
+
from typing import cast
|
|
20
20
|
|
|
21
21
|
from dara.components.common.base_component import LayoutComponent
|
|
22
22
|
from dara.components.common.text import Text
|
|
@@ -110,6 +110,10 @@ class Button(LayoutComponent):
|
|
|
110
110
|
```
|
|
111
111
|
|
|
112
112
|
:param disabled: A variable, condition, or bool to disabled the button when true
|
|
113
|
+
:param loading: A variable, condition, or bool to set the button to a loading state, showing a spinner.
|
|
114
|
+
By default, the button will automatically be set to loading=True while the onclick action is running,
|
|
115
|
+
equivalent to `Button(..., onclick=my_action, loading=my_action.loading)`. You can opt out of this behaviour by
|
|
116
|
+
simply setting `loading=False`.
|
|
113
117
|
:param onclick: An Action that is triggered by clicking the button
|
|
114
118
|
:param icon: An optional icon to display, see dara.core.css.get_icon for details
|
|
115
119
|
:param styling: A style of the button, can be 'primary', 'secondary', 'error', 'plain' or 'ghost'
|
|
@@ -119,15 +123,16 @@ class Button(LayoutComponent):
|
|
|
119
123
|
:param stop_click_propagation: Whether to stop the click event from propagating to the parent element, defaults to true
|
|
120
124
|
"""
|
|
121
125
|
|
|
122
|
-
disabled:
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
+
disabled: Condition | ClientVariable | bool | None = None
|
|
127
|
+
loading: Condition | ClientVariable | bool | None = None
|
|
128
|
+
onclick: Action | None = None
|
|
129
|
+
icon: str | None = None
|
|
130
|
+
styling: ButtonStyle | None = None
|
|
126
131
|
outline: bool = False
|
|
127
132
|
stop_click_propagation: bool = True
|
|
128
133
|
|
|
129
134
|
def __init__(
|
|
130
|
-
self, children:
|
|
135
|
+
self, children: str | ComponentInstance | ClientVariable, styling: ButtonStyle | None = None, **kwargs
|
|
131
136
|
):
|
|
132
137
|
child = children
|
|
133
138
|
style = styling if styling is not None else ButtonStyle.PRIMARY
|
|
@@ -16,7 +16,7 @@ limitations under the License.
|
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
18
|
from enum import Enum
|
|
19
|
-
from typing import Any
|
|
19
|
+
from typing import Any
|
|
20
20
|
|
|
21
21
|
from pydantic import field_validator
|
|
22
22
|
|
|
@@ -106,15 +106,15 @@ class ButtonBar(FormComponent):
|
|
|
106
106
|
:param styling: A style of the ButtonBar, can be 'primary' or 'secondary'
|
|
107
107
|
"""
|
|
108
108
|
|
|
109
|
-
items:
|
|
110
|
-
value:
|
|
111
|
-
onchange:
|
|
112
|
-
id:
|
|
109
|
+
items: list[Item]
|
|
110
|
+
value: Variable | None = None
|
|
111
|
+
onchange: Action | None = None
|
|
112
|
+
id: str | None = None
|
|
113
113
|
styling: ButtonBarStyle = ButtonBarStyle.PRIMARY
|
|
114
114
|
|
|
115
115
|
@field_validator('items', mode='before')
|
|
116
116
|
@classmethod
|
|
117
|
-
def validate_items(cls, items: Any) ->
|
|
117
|
+
def validate_items(cls, items: Any) -> list[Item]:
|
|
118
118
|
if not isinstance(items, list):
|
|
119
119
|
raise ValueError('Items must be passed as a list to the button bar component')
|
|
120
120
|
if len(items) == 0:
|
dara/components/common/card.py
CHANGED
|
@@ -15,8 +15,6 @@ See the License for the specific language governing permissions and
|
|
|
15
15
|
limitations under the License.
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
|
-
from typing import Optional, Union
|
|
19
|
-
|
|
20
18
|
from dara.components.common.base_component import LayoutComponent
|
|
21
19
|
from dara.core import ClientVariable
|
|
22
20
|
from dara.core.definitions import ComponentInstance
|
|
@@ -53,9 +51,9 @@ class Card(LayoutComponent):
|
|
|
53
51
|
:param align: How to align the content of the card, accepts any flexbox alignments
|
|
54
52
|
"""
|
|
55
53
|
|
|
56
|
-
subtitle:
|
|
57
|
-
title:
|
|
54
|
+
subtitle: str | ClientVariable | None = None
|
|
55
|
+
title: str | ClientVariable | None = None
|
|
58
56
|
accent: bool = False
|
|
59
57
|
|
|
60
|
-
def __init__(self, *args:
|
|
58
|
+
def __init__(self, *args: ComponentInstance | None, **kwargs):
|
|
61
59
|
super().__init__(*args, **kwargs)
|
|
@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
|
|
|
15
15
|
limitations under the License.
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
|
-
from typing import Any
|
|
18
|
+
from typing import Any
|
|
19
19
|
|
|
20
20
|
from pydantic import field_validator
|
|
21
21
|
|
|
@@ -118,13 +118,13 @@ class Carousel(ContentComponent):
|
|
|
118
118
|
:param onchange: Action triggered when the component changes states
|
|
119
119
|
"""
|
|
120
120
|
|
|
121
|
-
items:
|
|
122
|
-
value:
|
|
123
|
-
onchange:
|
|
121
|
+
items: list[CarouselItem] | ClientVariable
|
|
122
|
+
value: Variable[int] | None = None
|
|
123
|
+
onchange: Action | None = None
|
|
124
124
|
|
|
125
125
|
@field_validator('items', mode='before')
|
|
126
126
|
@classmethod
|
|
127
|
-
def validate_items(cls, items: Any) ->
|
|
127
|
+
def validate_items(cls, items: Any) -> list[CarouselItem] | ClientVariable:
|
|
128
128
|
if isinstance(items, ClientVariable):
|
|
129
129
|
return items
|
|
130
130
|
if not isinstance(items, list):
|
|
@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
|
|
|
15
15
|
limitations under the License.
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
|
-
from typing import Any
|
|
18
|
+
from typing import Any
|
|
19
19
|
|
|
20
20
|
from pydantic import field_validator
|
|
21
21
|
|
|
@@ -97,17 +97,17 @@ class CheckboxGroup(FormComponent):
|
|
|
97
97
|
:param id: the key to be used if this component is within a form
|
|
98
98
|
"""
|
|
99
99
|
|
|
100
|
-
items:
|
|
101
|
-
select_max:
|
|
102
|
-
select_min:
|
|
100
|
+
items: list[Item] | ClientVariable
|
|
101
|
+
select_max: int | None = None
|
|
102
|
+
select_min: int | None = None
|
|
103
103
|
list_styling: bool = False
|
|
104
|
-
value:
|
|
105
|
-
onchange:
|
|
106
|
-
id:
|
|
104
|
+
value: Variable[Any] | None = None
|
|
105
|
+
onchange: Action | None = None
|
|
106
|
+
id: str | None = None
|
|
107
107
|
|
|
108
108
|
@field_validator('items', mode='before')
|
|
109
109
|
@classmethod
|
|
110
|
-
def validate_items(cls, items: Any) ->
|
|
110
|
+
def validate_items(cls, items: Any) -> list[Item] | ClientVariable:
|
|
111
111
|
if isinstance(items, ClientVariable):
|
|
112
112
|
return items
|
|
113
113
|
if not isinstance(items, list):
|
dara/components/common/code.py
CHANGED
|
@@ -16,7 +16,7 @@ limitations under the License.
|
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
18
|
from enum import Enum
|
|
19
|
-
from typing import ClassVar
|
|
19
|
+
from typing import ClassVar
|
|
20
20
|
|
|
21
21
|
from dara.components.common.base_component import ContentComponent
|
|
22
22
|
from dara.core.interactivity import ClientVariable
|
|
@@ -67,8 +67,8 @@ class Code(ContentComponent):
|
|
|
67
67
|
:param language: The language to use for code highlighting
|
|
68
68
|
"""
|
|
69
69
|
|
|
70
|
-
code:
|
|
71
|
-
theme:
|
|
70
|
+
code: str | ClientVariable
|
|
71
|
+
theme: Themes | None = None
|
|
72
72
|
language: str = 'python'
|
|
73
73
|
|
|
74
74
|
Themes: ClassVar[ThemesType] = Themes
|
|
@@ -15,8 +15,6 @@ See the License for the specific language governing permissions and
|
|
|
15
15
|
limitations under the License.
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
|
-
from typing import List, Optional, Union
|
|
19
|
-
|
|
20
18
|
from dara.components.common.base_component import LayoutComponent
|
|
21
19
|
from dara.core.base_definitions import Action
|
|
22
20
|
from dara.core.base_definitions import DaraBaseModel as BaseModel
|
|
@@ -26,7 +24,7 @@ from dara.core.interactivity import Variable
|
|
|
26
24
|
|
|
27
25
|
class ComponentItem(BaseModel):
|
|
28
26
|
title: str
|
|
29
|
-
subtitle:
|
|
27
|
+
subtitle: str | None = None
|
|
30
28
|
component: ComponentInstanceType
|
|
31
29
|
|
|
32
30
|
|
|
@@ -62,8 +60,8 @@ class ComponentSelectList(LayoutComponent):
|
|
|
62
60
|
:param selected_items: The initial selected items, can be an list if multiSelect is true otherwise a string. This takes the titles of the items as value.
|
|
63
61
|
"""
|
|
64
62
|
|
|
65
|
-
items:
|
|
66
|
-
items_per_row:
|
|
67
|
-
multi_select:
|
|
68
|
-
on_select:
|
|
69
|
-
selected_items:
|
|
63
|
+
items: list[ComponentItem]
|
|
64
|
+
items_per_row: int | None = None
|
|
65
|
+
multi_select: bool | None = None
|
|
66
|
+
on_select: Action | None = None
|
|
67
|
+
selected_items: Variable[str | list[str]] | None = None
|
|
@@ -16,7 +16,7 @@ limitations under the License.
|
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
18
|
from datetime import datetime
|
|
19
|
-
from typing import Any
|
|
19
|
+
from typing import Any
|
|
20
20
|
|
|
21
21
|
from dara.components.common.base_component import FormComponent
|
|
22
22
|
from dara.core.base_definitions import Action
|
|
@@ -93,12 +93,12 @@ class Datepicker(FormComponent):
|
|
|
93
93
|
:param id: the key to be used if this component is within a form
|
|
94
94
|
"""
|
|
95
95
|
|
|
96
|
-
value:
|
|
96
|
+
value: Variable[Any] | None = None
|
|
97
97
|
date_format: str = 'dd/MM/yyyy'
|
|
98
98
|
enable_time: bool = False
|
|
99
|
-
max_date:
|
|
100
|
-
min_date:
|
|
99
|
+
max_date: datetime | None = None
|
|
100
|
+
min_date: datetime | None = None
|
|
101
101
|
range: bool = False
|
|
102
102
|
select_close: bool = True
|
|
103
|
-
onchange:
|
|
104
|
-
id:
|
|
103
|
+
onchange: Action | None = None
|
|
104
|
+
id: str | None = None
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Any
|
|
1
|
+
from typing import Any
|
|
2
2
|
|
|
3
3
|
from typing_extensions import TypedDict
|
|
4
4
|
|
|
@@ -8,22 +8,22 @@ from dara.core import Action, ClientVariable, ComponentInstance
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class MenuItem(TypedDict, total=False):
|
|
11
|
-
label:
|
|
11
|
+
label: str | ComponentInstance
|
|
12
12
|
"""the label of the menu item"""
|
|
13
13
|
|
|
14
|
-
icon:
|
|
14
|
+
icon: str | None
|
|
15
15
|
"""optional icon to show next to the label, use get_icon() helper"""
|
|
16
16
|
|
|
17
|
-
style:
|
|
17
|
+
style: dict[str, Any] | None
|
|
18
18
|
"""optional style to apply to the menu item"""
|
|
19
19
|
|
|
20
|
-
prevent_close:
|
|
20
|
+
prevent_close: bool | None
|
|
21
21
|
"""optional flag to prevent the menu from closing when the item is clicked"""
|
|
22
22
|
|
|
23
|
-
before:
|
|
23
|
+
before: ComponentInstance | None
|
|
24
24
|
"""optional component to show before the label"""
|
|
25
25
|
|
|
26
|
-
after:
|
|
26
|
+
after: ComponentInstance | None
|
|
27
27
|
"""optional component to show after the label"""
|
|
28
28
|
|
|
29
29
|
|
|
@@ -157,5 +157,5 @@ class DropdownMenu(BaseDashboardComponent):
|
|
|
157
157
|
|
|
158
158
|
button: Button
|
|
159
159
|
onclick: Action
|
|
160
|
-
menu_items:
|
|
161
|
-
footer:
|
|
160
|
+
menu_items: list[list[MenuItem]] | ClientVariable
|
|
161
|
+
footer: ComponentInstance | None = None
|
|
@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
|
|
|
15
15
|
limitations under the License.
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
|
-
from
|
|
18
|
+
from collections.abc import Callable
|
|
19
19
|
from uuid import uuid4
|
|
20
20
|
|
|
21
21
|
from pandas import DataFrame
|
|
@@ -25,10 +25,7 @@ from dara.core.base_definitions import Action, UploadResolverDef
|
|
|
25
25
|
from dara.core.definitions import StyledComponentInstance
|
|
26
26
|
from dara.core.interactivity import ServerVariable
|
|
27
27
|
|
|
28
|
-
DropzoneResolver =
|
|
29
|
-
Callable[[bytes, str], DataFrame],
|
|
30
|
-
Callable[[bytes, str], None],
|
|
31
|
-
]
|
|
28
|
+
DropzoneResolver = Callable[[bytes, str], DataFrame] | Callable[[bytes, str], None]
|
|
32
29
|
|
|
33
30
|
|
|
34
31
|
class UploadDropzone(StyledComponentInstance):
|
|
@@ -66,21 +63,21 @@ class UploadDropzone(StyledComponentInstance):
|
|
|
66
63
|
|
|
67
64
|
js_module = '@darajs/components'
|
|
68
65
|
|
|
69
|
-
accept:
|
|
70
|
-
target:
|
|
71
|
-
resolver:
|
|
72
|
-
on_drop:
|
|
66
|
+
accept: str | None = None
|
|
67
|
+
target: ServerVariable | None = None
|
|
68
|
+
resolver: DropzoneResolver | None = None
|
|
69
|
+
on_drop: Action | None = None
|
|
73
70
|
enable_paste: bool = False
|
|
74
71
|
|
|
75
72
|
model_config = ConfigDict(extra='allow')
|
|
76
73
|
|
|
77
74
|
def __init__(
|
|
78
75
|
self,
|
|
79
|
-
target:
|
|
80
|
-
resolver:
|
|
81
|
-
on_drop:
|
|
82
|
-
accept:
|
|
83
|
-
enable_paste:
|
|
76
|
+
target: ServerVariable | None = None,
|
|
77
|
+
resolver: DropzoneResolver | None = None,
|
|
78
|
+
on_drop: Action | None = None,
|
|
79
|
+
accept: str | None = None,
|
|
80
|
+
enable_paste: bool | None = False,
|
|
84
81
|
**kwargs,
|
|
85
82
|
):
|
|
86
83
|
from dara.core.interactivity.any_data_variable import upload
|
dara/components/common/form.py
CHANGED
|
@@ -15,8 +15,6 @@ See the License for the specific language governing permissions and
|
|
|
15
15
|
limitations under the License.
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
|
-
from typing import List, Optional
|
|
19
|
-
|
|
20
18
|
from pydantic import field_validator
|
|
21
19
|
|
|
22
20
|
from dara.components.common.base_component import LayoutComponent
|
|
@@ -82,12 +80,12 @@ class Form(LayoutComponent):
|
|
|
82
80
|
:param align: How to align the content of the form, accepts any flexbox alignments
|
|
83
81
|
"""
|
|
84
82
|
|
|
85
|
-
value:
|
|
86
|
-
onsubmit:
|
|
83
|
+
value: Variable[dict] | None = None
|
|
84
|
+
onsubmit: Action | None = None
|
|
87
85
|
|
|
88
86
|
@field_validator('children')
|
|
89
87
|
@classmethod
|
|
90
|
-
def validate_children_pages(cls, children:
|
|
88
|
+
def validate_children_pages(cls, children: list[ComponentInstance]) -> list[ComponentInstance]:
|
|
91
89
|
# Make sure if FormPage is included, non-pages are not direct children of the Form
|
|
92
90
|
page_found = False
|
|
93
91
|
non_page_found = False
|
|
@@ -15,8 +15,6 @@ See the License for the specific language governing permissions and
|
|
|
15
15
|
limitations under the License.
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
|
-
from typing import List, Optional
|
|
19
|
-
|
|
20
18
|
from pydantic import field_validator
|
|
21
19
|
|
|
22
20
|
from dara.components.common.base_component import FormComponent
|
|
@@ -50,11 +48,11 @@ class FormPage(FormComponent):
|
|
|
50
48
|
:param title: The title of the form page
|
|
51
49
|
"""
|
|
52
50
|
|
|
53
|
-
title:
|
|
51
|
+
title: str | None = None
|
|
54
52
|
|
|
55
53
|
@field_validator('children')
|
|
56
54
|
@classmethod
|
|
57
|
-
def validate_children(cls, children:
|
|
55
|
+
def validate_children(cls, children: list[ComponentInstance]) -> list[ComponentInstance]:
|
|
58
56
|
for c in children:
|
|
59
57
|
if isinstance(c, FormPage):
|
|
60
58
|
raise TypeError('FormPage detected inside another FormPage, nesting is disallowed')
|
dara/components/common/grid.py
CHANGED
|
@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
|
|
|
15
15
|
limitations under the License.
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
|
-
from typing import ClassVar
|
|
18
|
+
from typing import ClassVar
|
|
19
19
|
|
|
20
20
|
from dara.components.common.base_component import LayoutComponent
|
|
21
21
|
from dara.core.base_definitions import DaraBaseModel as BaseModel
|
|
@@ -24,11 +24,11 @@ from dara.core.visual.components.types import Direction
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
class ScreenBreakpoints(BaseModel):
|
|
27
|
-
xs:
|
|
28
|
-
sm:
|
|
29
|
-
md:
|
|
30
|
-
lg:
|
|
31
|
-
xl:
|
|
27
|
+
xs: int | None = None
|
|
28
|
+
sm: int | None = None
|
|
29
|
+
md: int | None = None
|
|
30
|
+
lg: int | None = None
|
|
31
|
+
xl: int | None = None
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
class Column(LayoutComponent):
|
|
@@ -67,11 +67,11 @@ class Column(LayoutComponent):
|
|
|
67
67
|
|
|
68
68
|
# TODO: :param order: optional number denoting the order of priority of the columns, with 1 being first to appear, and 12 the last to be added.
|
|
69
69
|
|
|
70
|
-
span:
|
|
71
|
-
offset:
|
|
70
|
+
span: int | ScreenBreakpoints | None = None
|
|
71
|
+
offset: int | ScreenBreakpoints | None = None
|
|
72
72
|
direction: Direction = Direction.HORIZONTAL
|
|
73
73
|
|
|
74
|
-
def __init__(self, *args:
|
|
74
|
+
def __init__(self, *args: ComponentInstance | None, **kwargs):
|
|
75
75
|
super().__init__(*args, **kwargs)
|
|
76
76
|
|
|
77
77
|
|
|
@@ -99,9 +99,9 @@ class Row(LayoutComponent):
|
|
|
99
99
|
:param align: How to align the content of the row, accepts any flexbox alignments
|
|
100
100
|
"""
|
|
101
101
|
|
|
102
|
-
column_gap:
|
|
102
|
+
column_gap: int | None = None
|
|
103
103
|
|
|
104
|
-
def __init__(self, *args:
|
|
104
|
+
def __init__(self, *args: ComponentInstance | None, **kwargs):
|
|
105
105
|
super().__init__(*args, **kwargs)
|
|
106
106
|
|
|
107
107
|
|
|
@@ -120,14 +120,14 @@ class Grid(LayoutComponent):
|
|
|
120
120
|
"""
|
|
121
121
|
|
|
122
122
|
row_gap: str = '0.75rem'
|
|
123
|
-
breakpoints:
|
|
123
|
+
breakpoints: ScreenBreakpoints | None = ScreenBreakpoints()
|
|
124
124
|
|
|
125
125
|
Column: ClassVar[ColumnType] = Column
|
|
126
126
|
Row: ClassVar[RowType] = Row
|
|
127
127
|
Breakpoints: ClassVar[type[ScreenBreakpoints]] = ScreenBreakpoints
|
|
128
128
|
|
|
129
129
|
# Dummy init that just passes through arguments to superclass, fixes Pylance complaining about types
|
|
130
|
-
def __init__(self, *args:
|
|
130
|
+
def __init__(self, *args: ComponentInstance | None, **kwargs):
|
|
131
131
|
"""
|
|
132
132
|
Grid Layout provides a flexbox grid with a twelve column system.
|
|
133
133
|
Rows will automatically calculate their widths and wrap on the page as needed.
|
|
@@ -16,7 +16,6 @@ limitations under the License.
|
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
18
|
import re
|
|
19
|
-
from typing import Union
|
|
20
19
|
|
|
21
20
|
from dara.components.common.base_component import ContentComponent
|
|
22
21
|
from dara.core.interactivity import ClientVariable
|
|
@@ -69,7 +68,7 @@ class Heading(ContentComponent):
|
|
|
69
68
|
:param level: The level of heading to display, defaults to 1
|
|
70
69
|
"""
|
|
71
70
|
|
|
72
|
-
heading:
|
|
71
|
+
heading: str | ClientVariable
|
|
73
72
|
level: int = 1
|
|
74
73
|
|
|
75
74
|
@property
|
|
@@ -78,5 +77,5 @@ class Heading(ContentComponent):
|
|
|
78
77
|
raise ValueError('Heading anchor name cannot be accessed directly from a variable')
|
|
79
78
|
return re.sub(r'\s+', '-', self.heading.lower())
|
|
80
79
|
|
|
81
|
-
def __init__(self, heading:
|
|
80
|
+
def __init__(self, heading: str | ClientVariable, **kwargs):
|
|
82
81
|
super().__init__(heading=heading, **kwargs)
|
dara/components/common/icon.py
CHANGED
|
@@ -15,8 +15,6 @@ See the License for the specific language governing permissions and
|
|
|
15
15
|
limitations under the License.
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
|
-
from typing import Optional
|
|
19
|
-
|
|
20
18
|
from dara.components.common.base_component import ContentComponent
|
|
21
19
|
|
|
22
20
|
|
|
@@ -65,4 +63,4 @@ class Icon(ContentComponent):
|
|
|
65
63
|
"""
|
|
66
64
|
|
|
67
65
|
icon: str
|
|
68
|
-
color:
|
|
66
|
+
color: str | None = None
|