streamlit-react-components 1.8.1.5__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.
@@ -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
- on_change: Optional callback function called when a button is clicked
40
- args: Optional tuple of args to pass to on_change callback
41
- kwargs: Optional dict of kwargs to pass to on_change callback
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 on_change is used)
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
- # Using preset colors
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 on_change callback if a button was clicked
89
- if on_change and key:
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
- # Only fire callback if value actually changed (not on first render)
94
- if prev_value is not None and result != prev_value:
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
@@ -86,8 +86,8 @@ def data_table(
86
86
  prev_key = f"_data_table_prev_{key}"
87
87
  prev_value = st.session_state.get(prev_key)
88
88
 
89
- # Only fire callback if value actually changed (not on first render)
90
- if prev_value is not None and result != prev_value:
89
+ # Only fire callback if a row was clicked (result not None) and it's different from previous
90
+ if result is not None and result != prev_value:
91
91
  on_change(*(args or ()), **(kwargs or {}))
92
92
 
93
93
  # Always update previous value
@@ -72,8 +72,8 @@ def step_indicator(
72
72
  prev_key = f"_step_indicator_prev_{key}"
73
73
  prev_value = st.session_state.get(prev_key)
74
74
 
75
- # Only fire callback if value actually changed (not on first render)
76
- if prev_value is not None and result != prev_value:
75
+ # Only fire callback if a step was clicked (result not None) and it's different from previous
76
+ if result is not None and result != prev_value:
77
77
  on_change(*(args or ()), **(kwargs or {}))
78
78
 
79
79
  # 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.5
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
@@ -6,23 +6,23 @@ 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=CVUrFyLsybF2XiCKvzdxGRH7g4lzfsxEg9zqU80gkEg,3554
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
- streamlit_react_components/common/data_table.py,sha256=XdNvszJhAWC7K4E5GSAn8jXN8Xpkv04HnZU5V0I8Qc0,3463
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
13
13
  streamlit_react_components/common/panel.py,sha256=iMcB5RF0SnU4yZHsvQQRuiNPnwQ6m8Epi56k2ziSjR8,1541
14
14
  streamlit_react_components/common/plotly_chart.py,sha256=YHY5kNBdyoEwNeJ4JPDh9DWDkN3zq8YgIncIMyu285A,9815
15
15
  streamlit_react_components/common/section_header.py,sha256=zgEW9Jlj48kiRB3_mYLk3a_oK7w55gnia_laMar_hOk,3430
16
16
  streamlit_react_components/common/smart_chart.py,sha256=kYzdPTpgdJLfX6CUXuT8fUMRubN1DRZ9Zej-XFFgje4,20068
17
17
  streamlit_react_components/common/stat_card.py,sha256=-C-73nglpPFbtliK7JfZLQExc9N1wYsyTjDsTXHVjKQ,4758
18
- streamlit_react_components/common/step_indicator.py,sha256=lsVDnIOOmbgNuIQgzG6u1R5nAszhJhkO8i5B5P05h8k,2697
18
+ streamlit_react_components/common/step_indicator.py,sha256=0W2Lm8BHspA2jNX12AgoLVwgEysoSjSwl015W0RqkUI,2718
19
19
  streamlit_react_components/form/__init__.py,sha256=urk_QJxnOrlMoHBTbCUGfjwxCbNs5lTFIoexUYB4AsA,349
20
20
  streamlit_react_components/form/checkbox_group.py,sha256=P3UJ0JrPpkx_yMDy0bzEt7VyIEmG1iB847a9-TKfPbA,4219
21
21
  streamlit_react_components/form/form_date_slider.py,sha256=FpKvY7uV5uTsLcjOQwPX_IQL97I4Jg7t-e-RVf1329Y,5801
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.5.dist-info/METADATA,sha256=ib2hFFZ1gAy5pO--4mIZnxKYt7ZzeUeOHQY-tayCiPE,21679
26
- streamlit_react_components-1.8.1.5.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
27
- streamlit_react_components-1.8.1.5.dist-info/top_level.txt,sha256=3JFrl15-Uewx3BFMSzqrBufF9GmTS1LDKfShmg0R9VE,27
28
- streamlit_react_components-1.8.1.5.dist-info/RECORD,,
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,,