streamlit-react-components 1.8.1.6__py3-none-any.whl → 1.8.1.7__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/common/button_group.py +21 -22
- {streamlit_react_components-1.8.1.6.dist-info → streamlit_react_components-1.8.1.7.dist-info}/METADATA +1 -1
- {streamlit_react_components-1.8.1.6.dist-info → streamlit_react_components-1.8.1.7.dist-info}/RECORD +5 -5
- {streamlit_react_components-1.8.1.6.dist-info → streamlit_react_components-1.8.1.7.dist-info}/WHEEL +0 -0
- {streamlit_react_components-1.8.1.6.dist-info → streamlit_react_components-1.8.1.7.dist-info}/top_level.txt +0 -0
|
@@ -15,6 +15,7 @@ _component = components.declare_component(
|
|
|
15
15
|
|
|
16
16
|
def button_group(
|
|
17
17
|
buttons: List[Dict[str, Any]],
|
|
18
|
+
on_click: Optional[Callable] = None,
|
|
18
19
|
on_change: Optional[Callable] = None,
|
|
19
20
|
args: Optional[tuple] = None,
|
|
20
21
|
kwargs: Optional[Dict[str, Any]] = None,
|
|
@@ -36,38 +37,32 @@ def button_group(
|
|
|
36
37
|
- disabled: Whether button is disabled (optional)
|
|
37
38
|
- style: Inline CSS styles dict for this button (optional)
|
|
38
39
|
- className: Tailwind CSS classes for this button (optional)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
on_click: Optional callback fired on every click. Receives (button_id, *args, **kwargs)
|
|
41
|
+
on_change: Optional callback fired only when a different button is clicked.
|
|
42
|
+
Receives (*args, **kwargs)
|
|
43
|
+
args: Optional tuple of args to pass to callbacks
|
|
44
|
+
kwargs: Optional dict of kwargs to pass to callbacks
|
|
42
45
|
style: Inline CSS styles as a dictionary
|
|
43
46
|
class_name: Tailwind CSS classes
|
|
44
47
|
theme: Optional theme dictionary. If None, uses active global theme.
|
|
45
48
|
Set to False to disable theming for this component.
|
|
46
|
-
key: Unique key for the component (required if
|
|
49
|
+
key: Unique key for the component (required if callbacks are used)
|
|
47
50
|
|
|
48
51
|
Returns:
|
|
49
52
|
The ID of the clicked button, or None if no click
|
|
50
53
|
|
|
51
54
|
Example:
|
|
52
|
-
|
|
55
|
+
def handle_click(button_id):
|
|
56
|
+
st.write(f"Clicked: {button_id}")
|
|
57
|
+
|
|
53
58
|
clicked = button_group(
|
|
54
59
|
buttons=[
|
|
55
|
-
{"id": "view", "icon": "👁️"},
|
|
56
|
-
{"id": "edit", "icon": "✏️"},
|
|
57
60
|
{"id": "approve", "icon": "✓", "color": "green"},
|
|
58
61
|
{"id": "reject", "icon": "✕", "color": "red"}
|
|
59
|
-
]
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
# Using hex colors and custom styling
|
|
63
|
-
clicked = button_group(
|
|
64
|
-
buttons=[
|
|
65
|
-
{"id": "custom", "icon": "🎨", "color": "#ff5733"},
|
|
66
|
-
{"id": "styled", "label": "Styled", "style": {"padding": "12px"}}
|
|
67
|
-
]
|
|
62
|
+
],
|
|
63
|
+
on_click=handle_click,
|
|
64
|
+
key="my_buttons"
|
|
68
65
|
)
|
|
69
|
-
if clicked == "approve":
|
|
70
|
-
approve_item()
|
|
71
66
|
"""
|
|
72
67
|
# Resolve theme (None = use global, False = disable)
|
|
73
68
|
from ..themes import get_active_theme
|
|
@@ -85,13 +80,17 @@ def button_group(
|
|
|
85
80
|
default=None,
|
|
86
81
|
)
|
|
87
82
|
|
|
88
|
-
# Execute
|
|
89
|
-
if
|
|
83
|
+
# Execute callbacks if a button was clicked
|
|
84
|
+
if key and result is not None:
|
|
90
85
|
prev_key = f"_button_group_prev_{key}"
|
|
91
86
|
prev_value = st.session_state.get(prev_key)
|
|
92
87
|
|
|
93
|
-
#
|
|
94
|
-
if
|
|
88
|
+
# on_click fires on every click, with button_id as first arg
|
|
89
|
+
if on_click:
|
|
90
|
+
on_click(result, *(args or ()), **(kwargs or {}))
|
|
91
|
+
|
|
92
|
+
# on_change fires only when a different button is clicked
|
|
93
|
+
if on_change and result != prev_value:
|
|
95
94
|
on_change(*(args or ()), **(kwargs or {}))
|
|
96
95
|
|
|
97
96
|
# Always update previous value
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: streamlit-react-components
|
|
3
|
-
Version: 1.8.1.
|
|
3
|
+
Version: 1.8.1.7
|
|
4
4
|
Summary: Reusable React-based Streamlit components with Tailwind CSS styling
|
|
5
5
|
License: MIT
|
|
6
6
|
Project-URL: Homepage, https://github.com/your-org/streamlit-react-components
|
{streamlit_react_components-1.8.1.6.dist-info → streamlit_react_components-1.8.1.7.dist-info}/RECORD
RENAMED
|
@@ -6,7 +6,7 @@ streamlit_react_components/_frontend/index.css,sha256=nGAyY9oe87Ayha6-wUCCA2wQFW
|
|
|
6
6
|
streamlit_react_components/_frontend/index.html,sha256=CjBEtVYlgT_q06BE16EHFrUrJZ6z0MCprrTg7qgAWzw,381
|
|
7
7
|
streamlit_react_components/_frontend/index.js,sha256=K0w0MmanmChWxCP_brj60ot2DFfFM8jIboBNAYzmOtQ,5233921
|
|
8
8
|
streamlit_react_components/common/__init__.py,sha256=l5BfFZdqjrdLG3sJnJrgahEiTgoBX92_aE0wp2tn_w0,606
|
|
9
|
-
streamlit_react_components/common/button_group.py,sha256=
|
|
9
|
+
streamlit_react_components/common/button_group.py,sha256=pCBsGHuovxN4wKzu5B-SDRO0MECqKJy8MnCgeIkPgK8,3536
|
|
10
10
|
streamlit_react_components/common/chart_legend.py,sha256=ylul6Os5A89S8fIJs7XpBdIk6uWijg_zwR1eB7u9wSw,1824
|
|
11
11
|
streamlit_react_components/common/data_table.py,sha256=EzJqaIKmg5lPnjb3bWFIFoSGY6C1cpau5bBZYNKCk_Y,3483
|
|
12
12
|
streamlit_react_components/common/metric_row.py,sha256=84KmKq_ECJ6kTozDSVTVVxN0G5TyGEgtDzl4V_bilAc,1704
|
|
@@ -22,7 +22,7 @@ streamlit_react_components/form/form_date_slider.py,sha256=FpKvY7uV5uTsLcjOQwPX_
|
|
|
22
22
|
streamlit_react_components/form/form_select.py,sha256=bJFyN9at6nTyDcev_7l7pYDW_KhXHG2D7lSfNxPIPTQ,3964
|
|
23
23
|
streamlit_react_components/form/form_slider.py,sha256=ZL1fCLCfanolmxOzuEQo28D1WYFy17uH0EuwbFwD7f8,4020
|
|
24
24
|
streamlit_react_components/form/radio_group.py,sha256=ktmB37APMLiaUJGmP38hlA6I_diPyexkcNGXCvDXjw8,4098
|
|
25
|
-
streamlit_react_components-1.8.1.
|
|
26
|
-
streamlit_react_components-1.8.1.
|
|
27
|
-
streamlit_react_components-1.8.1.
|
|
28
|
-
streamlit_react_components-1.8.1.
|
|
25
|
+
streamlit_react_components-1.8.1.7.dist-info/METADATA,sha256=xcuGDSzXWkfMfjZ71G12S5v6rH68f1booX_LvJiF7zI,21679
|
|
26
|
+
streamlit_react_components-1.8.1.7.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
27
|
+
streamlit_react_components-1.8.1.7.dist-info/top_level.txt,sha256=3JFrl15-Uewx3BFMSzqrBufF9GmTS1LDKfShmg0R9VE,27
|
|
28
|
+
streamlit_react_components-1.8.1.7.dist-info/RECORD,,
|
{streamlit_react_components-1.8.1.6.dist-info → streamlit_react_components-1.8.1.7.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|