dara-components 1.16.22__py3-none-any.whl → 1.16.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/common/__init__.py +2 -1
- dara/components/common/radio_group.py +22 -9
- dara/components/umd/dara.components.umd.js +43698 -43503
- {dara_components-1.16.22.dist-info → dara_components-1.16.23.dist-info}/METADATA +3 -3
- {dara_components-1.16.22.dist-info → dara_components-1.16.23.dist-info}/RECORD +7 -7
- {dara_components-1.16.22.dist-info → dara_components-1.16.23.dist-info}/LICENSE +0 -0
- {dara_components-1.16.22.dist-info → dara_components-1.16.23.dist-info}/WHEEL +0 -0
|
@@ -54,7 +54,7 @@ from dara.components.common.modal import Modal
|
|
|
54
54
|
from dara.components.common.overlay import Overlay
|
|
55
55
|
from dara.components.common.paragraph import Paragraph
|
|
56
56
|
from dara.components.common.progress_bar import ProgressBar
|
|
57
|
-
from dara.components.common.radio_group import RadioGroup
|
|
57
|
+
from dara.components.common.radio_group import RadioGroup, RadioItem
|
|
58
58
|
from dara.components.common.select import ListSection, Select
|
|
59
59
|
from dara.components.common.slider import Slider
|
|
60
60
|
from dara.components.common.spacer import Spacer
|
|
@@ -110,6 +110,7 @@ __all__ = [
|
|
|
110
110
|
'Stack',
|
|
111
111
|
'Switch',
|
|
112
112
|
'RadioGroup',
|
|
113
|
+
'RadioItem',
|
|
113
114
|
'Text',
|
|
114
115
|
'Textarea',
|
|
115
116
|
'Tab',
|
|
@@ -18,14 +18,20 @@ limitations under the License.
|
|
|
18
18
|
from typing import Any, List, Optional, Union
|
|
19
19
|
|
|
20
20
|
from pydantic import field_validator
|
|
21
|
+
from typing_extensions import TypedDict
|
|
21
22
|
|
|
22
23
|
from dara.components.common.base_component import FormComponent
|
|
23
|
-
from dara.components.common.utils import Item
|
|
24
24
|
from dara.core.base_definitions import Action
|
|
25
|
+
from dara.core.definitions import ComponentInstance
|
|
25
26
|
from dara.core.interactivity import NonDataVariable, UrlVariable, Variable
|
|
26
27
|
from dara.core.visual.components.types import Direction
|
|
27
28
|
|
|
28
29
|
|
|
30
|
+
class RadioItem(TypedDict):
|
|
31
|
+
value: Any
|
|
32
|
+
label: Union[str, ComponentInstance]
|
|
33
|
+
|
|
34
|
+
|
|
29
35
|
class RadioGroup(FormComponent):
|
|
30
36
|
"""
|
|
31
37
|

|
|
@@ -37,7 +43,7 @@ class RadioGroup(FormComponent):
|
|
|
37
43
|
|
|
38
44
|
```python
|
|
39
45
|
from dara.core import Variable
|
|
40
|
-
from dara.components
|
|
46
|
+
from dara.components import RadioGroup, RadioItem, Text
|
|
41
47
|
|
|
42
48
|
value_var_str = Variable('first')
|
|
43
49
|
|
|
@@ -49,9 +55,18 @@ class RadioGroup(FormComponent):
|
|
|
49
55
|
|
|
50
56
|
value_var_num = Variable(1)
|
|
51
57
|
|
|
52
|
-
# or as an `
|
|
58
|
+
# or as an `RadioItem` list
|
|
59
|
+
RadioGroup(
|
|
60
|
+
items=[RadioItem(label='first',value=1), Item(label='second',value=2)],
|
|
61
|
+
value=value_var_num,
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
# or as an `RadioItem` list with arbitrary components
|
|
53
65
|
RadioGroup(
|
|
54
|
-
items=[
|
|
66
|
+
items=[
|
|
67
|
+
RadioItem(label=Text(text='first', color='red'), value=1),
|
|
68
|
+
RadioItem(label=Text(text='second', color='blue'), value=2)
|
|
69
|
+
],
|
|
55
70
|
value=value_var_num,
|
|
56
71
|
)
|
|
57
72
|
```
|
|
@@ -76,7 +91,7 @@ class RadioGroup(FormComponent):
|
|
|
76
91
|
:param id: the key to be used if this component is within a form
|
|
77
92
|
"""
|
|
78
93
|
|
|
79
|
-
items: Union[List[
|
|
94
|
+
items: Union[List[RadioItem], List[str], NonDataVariable]
|
|
80
95
|
value: Optional[Union[Variable[Any], UrlVariable[Any]]] = None
|
|
81
96
|
list_styling: Optional[bool] = False
|
|
82
97
|
onchange: Optional[Action] = None
|
|
@@ -85,11 +100,9 @@ class RadioGroup(FormComponent):
|
|
|
85
100
|
|
|
86
101
|
@field_validator('items', mode='before')
|
|
87
102
|
@classmethod
|
|
88
|
-
def validate_items(cls, items: Any) -> Union[List[
|
|
103
|
+
def validate_items(cls, items: Any) -> Union[List[RadioItem], NonDataVariable]:
|
|
89
104
|
if isinstance(items, NonDataVariable):
|
|
90
105
|
return items
|
|
91
|
-
if not isinstance(items, list):
|
|
92
|
-
raise ValueError('Items must be passed as a list to the RadioGroup component')
|
|
93
106
|
if len(items) == 0:
|
|
94
107
|
raise ValueError('Items list is empty, you must provide at least one item')
|
|
95
|
-
return [
|
|
108
|
+
return [RadioItem(value=item, label=item) if isinstance(item, str) else item for item in items]
|