streamlit-react-components 1.0.0__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.
- streamlit_react_components/__init__.py +42 -0
- streamlit_react_components/_frontend/index.css +1 -0
- streamlit_react_components/_frontend/index.html +13 -0
- streamlit_react_components/_frontend/index.js +3920 -0
- streamlit_react_components/common/__init__.py +23 -0
- streamlit_react_components/common/button_group.py +69 -0
- streamlit_react_components/common/chart_legend.py +49 -0
- streamlit_react_components/common/data_table.py +65 -0
- streamlit_react_components/common/metric_row.py +47 -0
- streamlit_react_components/common/panel.py +43 -0
- streamlit_react_components/common/plotly_chart.py +216 -0
- streamlit_react_components/common/section_header.py +89 -0
- streamlit_react_components/common/stat_card.py +63 -0
- streamlit_react_components/common/step_indicator.py +51 -0
- streamlit_react_components/form/__init__.py +11 -0
- streamlit_react_components/form/checkbox_group.py +61 -0
- streamlit_react_components/form/form_select.py +69 -0
- streamlit_react_components/form/form_slider.py +80 -0
- streamlit_react_components-1.0.0.dist-info/METADATA +854 -0
- streamlit_react_components-1.0.0.dist-info/RECORD +22 -0
- streamlit_react_components-1.0.0.dist-info/WHEEL +5 -0
- streamlit_react_components-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""StepIndicator component - A multi-step wizard progress indicator."""
|
|
2
|
+
|
|
3
|
+
import streamlit.components.v1 as components
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Dict, Any, List, Optional
|
|
6
|
+
|
|
7
|
+
_FRONTEND_DIR = Path(__file__).parent.parent / "_frontend"
|
|
8
|
+
|
|
9
|
+
_component = components.declare_component(
|
|
10
|
+
"streamlit_react_components",
|
|
11
|
+
path=str(_FRONTEND_DIR),
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def step_indicator(
|
|
16
|
+
steps: List[str],
|
|
17
|
+
current_step: int,
|
|
18
|
+
style: Optional[Dict[str, Any]] = None,
|
|
19
|
+
class_name: str = "",
|
|
20
|
+
key: Optional[str] = None,
|
|
21
|
+
) -> Optional[int]:
|
|
22
|
+
"""
|
|
23
|
+
Display a multi-step wizard progress indicator.
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
steps: List of step labels (e.g., ["Supply Plan", "Levers", "Review"])
|
|
27
|
+
current_step: Current active step (1-indexed)
|
|
28
|
+
style: Inline CSS styles as a dictionary
|
|
29
|
+
class_name: Tailwind CSS classes
|
|
30
|
+
key: Unique key for the component
|
|
31
|
+
|
|
32
|
+
Returns:
|
|
33
|
+
The step number that was clicked, or None if no click
|
|
34
|
+
|
|
35
|
+
Example:
|
|
36
|
+
step = step_indicator(
|
|
37
|
+
steps=["Supply Plan", "Levers", "Review"],
|
|
38
|
+
current_step=2
|
|
39
|
+
)
|
|
40
|
+
if step:
|
|
41
|
+
st.session_state.step = step
|
|
42
|
+
"""
|
|
43
|
+
return _component(
|
|
44
|
+
component="step_indicator",
|
|
45
|
+
steps=steps,
|
|
46
|
+
currentStep=current_step,
|
|
47
|
+
style=style,
|
|
48
|
+
className=class_name,
|
|
49
|
+
key=key,
|
|
50
|
+
default=None,
|
|
51
|
+
)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"""CheckboxGroup component - A group of checkboxes."""
|
|
2
|
+
|
|
3
|
+
import streamlit.components.v1 as components
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Dict, Any, List, Optional
|
|
6
|
+
|
|
7
|
+
_FRONTEND_DIR = Path(__file__).parent.parent / "_frontend"
|
|
8
|
+
|
|
9
|
+
_component = components.declare_component(
|
|
10
|
+
"streamlit_react_components",
|
|
11
|
+
path=str(_FRONTEND_DIR),
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def checkbox_group(
|
|
16
|
+
items: List[Dict[str, Any]],
|
|
17
|
+
label: str = "",
|
|
18
|
+
style: Optional[Dict[str, Any]] = None,
|
|
19
|
+
class_name: str = "",
|
|
20
|
+
key: Optional[str] = None,
|
|
21
|
+
) -> List[str]:
|
|
22
|
+
"""
|
|
23
|
+
Display a group of checkboxes.
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
items: List of checkbox items, each with:
|
|
27
|
+
- id: Unique identifier
|
|
28
|
+
- label: Display label
|
|
29
|
+
- checked: Initial checked state (optional, default False)
|
|
30
|
+
label: Optional group label
|
|
31
|
+
style: Inline CSS styles as a dictionary
|
|
32
|
+
class_name: Tailwind CSS classes
|
|
33
|
+
key: Unique key for the component
|
|
34
|
+
|
|
35
|
+
Returns:
|
|
36
|
+
List of checked item IDs
|
|
37
|
+
|
|
38
|
+
Example:
|
|
39
|
+
selected = checkbox_group(
|
|
40
|
+
label="Parameters",
|
|
41
|
+
items=[
|
|
42
|
+
{"id": "vphp", "label": "VPHP Hold", "checked": True},
|
|
43
|
+
{"id": "lot_co", "label": "Lot C/O", "checked": True},
|
|
44
|
+
{"id": "batch", "label": "Batch Size"}
|
|
45
|
+
]
|
|
46
|
+
)
|
|
47
|
+
# Returns: ["vphp", "lot_co"] if those are checked
|
|
48
|
+
"""
|
|
49
|
+
# Get default checked items
|
|
50
|
+
default_checked = [item["id"] for item in items if item.get("checked", False)]
|
|
51
|
+
|
|
52
|
+
result = _component(
|
|
53
|
+
component="checkbox_group",
|
|
54
|
+
label=label,
|
|
55
|
+
items=items,
|
|
56
|
+
style=style,
|
|
57
|
+
className=class_name,
|
|
58
|
+
key=key,
|
|
59
|
+
default=default_checked,
|
|
60
|
+
)
|
|
61
|
+
return result if result is not None else default_checked
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""FormSelect component - A styled dropdown select input."""
|
|
2
|
+
|
|
3
|
+
import streamlit.components.v1 as components
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Dict, Any, List, Optional, Union
|
|
6
|
+
|
|
7
|
+
_FRONTEND_DIR = Path(__file__).parent.parent / "_frontend"
|
|
8
|
+
|
|
9
|
+
_component = components.declare_component(
|
|
10
|
+
"streamlit_react_components",
|
|
11
|
+
path=str(_FRONTEND_DIR),
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def form_select(
|
|
16
|
+
label: str,
|
|
17
|
+
options: List[Union[str, Dict[str, str]]],
|
|
18
|
+
value: str = "",
|
|
19
|
+
groups: Optional[List[Dict[str, Any]]] = None,
|
|
20
|
+
style: Optional[Dict[str, Any]] = None,
|
|
21
|
+
class_name: str = "",
|
|
22
|
+
key: Optional[str] = None,
|
|
23
|
+
) -> str:
|
|
24
|
+
"""
|
|
25
|
+
Display a styled dropdown select input.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
label: Label text for the select
|
|
29
|
+
options: List of options, either strings or dicts with {value, label}
|
|
30
|
+
value: Currently selected value
|
|
31
|
+
groups: Optional list of option groups, each with:
|
|
32
|
+
- label: Group header text
|
|
33
|
+
- options: List of options in this group
|
|
34
|
+
style: Inline CSS styles as a dictionary
|
|
35
|
+
class_name: Tailwind CSS classes
|
|
36
|
+
key: Unique key for the component
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
The currently selected value
|
|
40
|
+
|
|
41
|
+
Example:
|
|
42
|
+
# Simple string options
|
|
43
|
+
site = form_select(
|
|
44
|
+
label="Site",
|
|
45
|
+
options=["AML_14", "ADL", "Devens"],
|
|
46
|
+
value="AML_14"
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
# With option groups
|
|
50
|
+
version = form_select(
|
|
51
|
+
label="Base On",
|
|
52
|
+
groups=[
|
|
53
|
+
{"label": "Baselines", "options": ["Baseline v7"]},
|
|
54
|
+
{"label": "Scenarios", "options": ["Q2 Demand Surge"]}
|
|
55
|
+
]
|
|
56
|
+
)
|
|
57
|
+
"""
|
|
58
|
+
result = _component(
|
|
59
|
+
component="form_select",
|
|
60
|
+
label=label,
|
|
61
|
+
options=options,
|
|
62
|
+
value=value,
|
|
63
|
+
groups=groups,
|
|
64
|
+
style=style,
|
|
65
|
+
className=class_name,
|
|
66
|
+
key=key,
|
|
67
|
+
default=value,
|
|
68
|
+
)
|
|
69
|
+
return result if result is not None else value
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"""FormSlider component - A styled range slider input."""
|
|
2
|
+
|
|
3
|
+
import streamlit.components.v1 as components
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Dict, Any, Optional
|
|
6
|
+
|
|
7
|
+
_FRONTEND_DIR = Path(__file__).parent.parent / "_frontend"
|
|
8
|
+
|
|
9
|
+
_component = components.declare_component(
|
|
10
|
+
"streamlit_react_components",
|
|
11
|
+
path=str(_FRONTEND_DIR),
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def form_slider(
|
|
16
|
+
label: str,
|
|
17
|
+
value: float,
|
|
18
|
+
min_val: float,
|
|
19
|
+
max_val: float,
|
|
20
|
+
step: float = 1,
|
|
21
|
+
unit: str = "",
|
|
22
|
+
color: str = "blue",
|
|
23
|
+
style: Optional[Dict[str, Any]] = None,
|
|
24
|
+
class_name: str = "",
|
|
25
|
+
key: Optional[str] = None,
|
|
26
|
+
) -> float:
|
|
27
|
+
"""
|
|
28
|
+
Display a styled range slider input.
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
label: Label text for the slider
|
|
32
|
+
value: Current value
|
|
33
|
+
min_val: Minimum value
|
|
34
|
+
max_val: Maximum value
|
|
35
|
+
step: Step increment (default 1)
|
|
36
|
+
unit: Unit suffix to display (e.g., "%", "hrs")
|
|
37
|
+
color: Accent color - preset name ("blue", "green", "red", "yellow",
|
|
38
|
+
"purple", "slate") or hex value (e.g., "#94a3b8")
|
|
39
|
+
style: Inline CSS styles as a dictionary
|
|
40
|
+
class_name: Tailwind CSS classes
|
|
41
|
+
key: Unique key for the component
|
|
42
|
+
|
|
43
|
+
Returns:
|
|
44
|
+
The current slider value
|
|
45
|
+
|
|
46
|
+
Example:
|
|
47
|
+
# Using preset color
|
|
48
|
+
threshold = form_slider(
|
|
49
|
+
label="Upper Threshold",
|
|
50
|
+
value=90,
|
|
51
|
+
min_val=75,
|
|
52
|
+
max_val=100,
|
|
53
|
+
unit="%",
|
|
54
|
+
color="red"
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
# Using hex color
|
|
58
|
+
threshold = form_slider(
|
|
59
|
+
label="Custom Slider",
|
|
60
|
+
value=50,
|
|
61
|
+
min_val=0,
|
|
62
|
+
max_val=100,
|
|
63
|
+
color="#ff5733"
|
|
64
|
+
)
|
|
65
|
+
"""
|
|
66
|
+
result = _component(
|
|
67
|
+
component="form_slider",
|
|
68
|
+
label=label,
|
|
69
|
+
value=value,
|
|
70
|
+
minVal=min_val,
|
|
71
|
+
maxVal=max_val,
|
|
72
|
+
step=step,
|
|
73
|
+
unit=unit,
|
|
74
|
+
color=color,
|
|
75
|
+
style=style,
|
|
76
|
+
className=class_name,
|
|
77
|
+
key=key,
|
|
78
|
+
default=value,
|
|
79
|
+
)
|
|
80
|
+
return float(result) if result is not None else value
|