streamlit-react-components 1.0.2__py3-none-any.whl → 1.0.3__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.
@@ -17,10 +17,16 @@ def stat_card(
17
17
  value: Union[str, int, float],
18
18
  color: str = "blue",
19
19
  icon: str = "",
20
+ planned: Optional[Union[str, int, float]] = None,
21
+ delta: Optional[Union[str, int, float]] = None,
22
+ delta_style: str = "auto",
23
+ delta_thresholds: Optional[Dict[str, float]] = None,
24
+ unit: str = "",
25
+ action: Optional[Dict[str, str]] = None,
20
26
  style: Optional[Dict[str, Any]] = None,
21
27
  class_name: str = "",
22
28
  key: Optional[str] = None,
23
- ) -> None:
29
+ ) -> Optional[str]:
24
30
  """
25
31
  Display a styled statistics card with a label and value.
26
32
 
@@ -30,12 +36,24 @@ def stat_card(
30
36
  color: Accent color - preset name ("blue", "green", "red", "yellow",
31
37
  "purple", "slate") or hex value (e.g., "#94a3b8")
32
38
  icon: Optional emoji or icon to display with the label
39
+ planned: Optional planned/target value to display
40
+ delta: Optional delta/difference value to display
41
+ delta_style: How to style the delta - "auto" (green/red based on sign),
42
+ "neutral" (no color), "percentage" (show as %),
43
+ "inverse" (red for positive, green for negative)
44
+ delta_thresholds: Optional thresholds for delta color based on magnitude
45
+ e.g., {"warning": 10, "danger": 20}
46
+ unit: Unit of measurement (e.g., "kg", "%", "$")
47
+ action: Optional action button config {"id": "...", "label": "..."}
33
48
  style: Inline CSS styles as a dictionary
34
49
  class_name: Tailwind CSS classes
35
50
  key: Unique key for the component
36
51
 
52
+ Returns:
53
+ The action button id if clicked, None otherwise
54
+
37
55
  Example:
38
- # Using preset color
56
+ # Basic usage (backwards compatible)
39
57
  stat_card(
40
58
  label="Within Threshold",
41
59
  value="4",
@@ -43,19 +61,43 @@ def stat_card(
43
61
  style={"minWidth": "150px"}
44
62
  )
45
63
 
46
- # Using hex color
64
+ # With all new features
65
+ clicked = stat_card(
66
+ label="Production Output",
67
+ value=1234,
68
+ planned=1200,
69
+ delta=34,
70
+ delta_style="auto",
71
+ unit="kg",
72
+ color="green",
73
+ icon="📊",
74
+ action={"id": "details", "label": "View Details"}
75
+ )
76
+ if clicked == "details":
77
+ st.write("Details clicked!")
78
+
79
+ # With thresholds
47
80
  stat_card(
48
- label="Custom Color",
49
- value="42",
50
- color="#ff5733"
81
+ label="Defect Rate",
82
+ value=15,
83
+ delta=5,
84
+ delta_style="inverse",
85
+ delta_thresholds={"warning": 3, "danger": 10},
86
+ unit="%"
51
87
  )
52
88
  """
53
- _component(
89
+ return _component(
54
90
  component="stat_card",
55
91
  label=label,
56
92
  value=str(value),
57
93
  color=color,
58
94
  icon=icon,
95
+ planned=str(planned) if planned is not None else None,
96
+ delta=float(delta) if delta is not None else None,
97
+ deltaStyle=delta_style,
98
+ deltaThresholds=delta_thresholds,
99
+ unit=unit,
100
+ action=action,
59
101
  style=style,
60
102
  className=class_name,
61
103
  key=key,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: streamlit-react-components
3
- Version: 1.0.2
3
+ Version: 1.0.3
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
@@ -1,7 +1,7 @@
1
1
  streamlit_react_components/__init__.py,sha256=-m5OJx0vsfzD6k2m_2X8eMQXi9pgkreAuDZJoVWbdJ0,673
2
- streamlit_react_components/_frontend/index.css,sha256=vW-yXHEFGLJUbWgkRewomPA8R3Um6h8kADSJqzEHxIc,26376
2
+ streamlit_react_components/_frontend/index.css,sha256=gN1hj1J5RV7pkO5Ynbl0Z_wTNCUtz9okN_KCJcEfWQU,26413
3
3
  streamlit_react_components/_frontend/index.html,sha256=CjBEtVYlgT_q06BE16EHFrUrJZ6z0MCprrTg7qgAWzw,381
4
- streamlit_react_components/_frontend/index.js,sha256=PxuSp_m4S-N4YTOJj3kEIWHCBcW_L3PPmJN44HHvzOo,5215566
4
+ streamlit_react_components/_frontend/index.js,sha256=UuKRqAIw5EukWf-xcs9iB9SoRAYOWDUFM75mzBe9OQI,5217194
5
5
  streamlit_react_components/common/__init__.py,sha256=xUKaw_X2B2xd6AqW8oLzHupGp-TX3Fij0FjhMNwd-vs,550
6
6
  streamlit_react_components/common/button_group.py,sha256=g38gpR62dQ8KLd3JyANvGonT6tf-tyooIjC6t3O4iH0,2225
7
7
  streamlit_react_components/common/chart_legend.py,sha256=So703OO-sI6SWrSVGKH0OTiI-smr4luqgBtXQ9GwIlI,1377
@@ -10,13 +10,13 @@ streamlit_react_components/common/metric_row.py,sha256=abDfSrLvZO8MK2gglvE98L5U0
10
10
  streamlit_react_components/common/panel.py,sha256=O4URjnK8u9_byFzDO9RAFdpXjzNdxpXY1CX8gEEK1pY,1094
11
11
  streamlit_react_components/common/plotly_chart.py,sha256=px1pITa8GSYl_TTg4KzX81nQy_F-9XwUV_91fR7d0po,9368
12
12
  streamlit_react_components/common/section_header.py,sha256=2sVLWHjHx2WdhbVVLBgs5shwUUbw6lbAKbsAwiwIWpg,2983
13
- streamlit_react_components/common/stat_card.py,sha256=PimCX6Dd18DyfJn6tk0YmrA1zKvAiqeKXdHAKXhxiRQ,1674
13
+ streamlit_react_components/common/stat_card.py,sha256=cNl5Kh8vzg3JbDDfp7TdwZ9HOxyoUw1Vn_Bt3QhMDUM,3415
14
14
  streamlit_react_components/common/step_indicator.py,sha256=araovSL_c5h66PawZBf5IlQbVoxXwE9kD0H10ZopVoU,1370
15
15
  streamlit_react_components/form/__init__.py,sha256=XP9oBEHSwLTNqu88sYm0F_n828yzPStDJl3N62HxVvc,222
16
16
  streamlit_react_components/form/checkbox_group.py,sha256=LbwfyIRKjTnWOB-a4OL2-vJXAJ9QpXhbrbdUz5bBdW4,2100
17
17
  streamlit_react_components/form/form_select.py,sha256=KILKVUO-Elb0nqbTEImxyoGQQrnZ_jft30iJSbY5ksk,1946
18
18
  streamlit_react_components/form/form_slider.py,sha256=4w9h-d-9yAHg3ZqUHCZGzsfUG3lP5OTwVrDo5sZAnfQ,2032
19
- streamlit_react_components-1.0.2.dist-info/METADATA,sha256=lNS5Fsxaii6LY3RlmkRGj-2W-fqQGBUXTpJnRgKY1go,21677
20
- streamlit_react_components-1.0.2.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
21
- streamlit_react_components-1.0.2.dist-info/top_level.txt,sha256=3JFrl15-Uewx3BFMSzqrBufF9GmTS1LDKfShmg0R9VE,27
22
- streamlit_react_components-1.0.2.dist-info/RECORD,,
19
+ streamlit_react_components-1.0.3.dist-info/METADATA,sha256=nAWOVVMnB59BJBDZ3yaQG5Vx5TSlCEVtlEYXPBusvd0,21677
20
+ streamlit_react_components-1.0.3.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
21
+ streamlit_react_components-1.0.3.dist-info/top_level.txt,sha256=3JFrl15-Uewx3BFMSzqrBufF9GmTS1LDKfShmg0R9VE,27
22
+ streamlit_react_components-1.0.3.dist-info/RECORD,,