streamlit-react-components 1.7.4__py3-none-any.whl → 1.8.1.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 +3 -1
- streamlit_react_components/_frontend/index.css +1 -1
- streamlit_react_components/_frontend/index.js +101 -101
- streamlit_react_components/form/__init__.py +2 -0
- streamlit_react_components/form/form_date_slider.py +147 -0
- {streamlit_react_components-1.7.4.dist-info → streamlit_react_components-1.8.1.0.dist-info}/METADATA +1 -1
- {streamlit_react_components-1.7.4.dist-info → streamlit_react_components-1.8.1.0.dist-info}/RECORD +9 -8
- {streamlit_react_components-1.7.4.dist-info → streamlit_react_components-1.8.1.0.dist-info}/WHEEL +0 -0
- {streamlit_react_components-1.7.4.dist-info → streamlit_react_components-1.8.1.0.dist-info}/top_level.txt +0 -0
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
from .form_select import form_select
|
|
4
4
|
from .form_slider import form_slider
|
|
5
|
+
from .form_date_slider import form_date_slider
|
|
5
6
|
from .checkbox_group import checkbox_group
|
|
6
7
|
from .radio_group import radio_group
|
|
7
8
|
|
|
8
9
|
__all__ = [
|
|
9
10
|
"form_select",
|
|
10
11
|
"form_slider",
|
|
12
|
+
"form_date_slider",
|
|
11
13
|
"checkbox_group",
|
|
12
14
|
"radio_group",
|
|
13
15
|
]
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"""FormDateSlider component - A date slider with optional range selection."""
|
|
2
|
+
|
|
3
|
+
import streamlit.components.v1 as components
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from datetime import date, timedelta
|
|
6
|
+
from typing import Dict, Any, Optional, Union, Tuple
|
|
7
|
+
|
|
8
|
+
_FRONTEND_DIR = Path(__file__).parent.parent / "_frontend"
|
|
9
|
+
|
|
10
|
+
_component = components.declare_component(
|
|
11
|
+
"streamlit_react_components",
|
|
12
|
+
path=str(_FRONTEND_DIR),
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def form_date_slider(
|
|
17
|
+
label: str,
|
|
18
|
+
min_val: date,
|
|
19
|
+
max_val: date,
|
|
20
|
+
value: Union[date, Tuple[date, date]],
|
|
21
|
+
step_type: Optional[str] = "month",
|
|
22
|
+
step: Optional[timedelta] = None,
|
|
23
|
+
format: str = "YYYY-MM",
|
|
24
|
+
color: str = "blue",
|
|
25
|
+
style: Optional[Dict[str, Any]] = None,
|
|
26
|
+
class_name: str = "",
|
|
27
|
+
theme: Optional[Dict[str, Any]] = None,
|
|
28
|
+
defer_update: bool = False,
|
|
29
|
+
key: Optional[str] = None,
|
|
30
|
+
) -> Union[date, Tuple[date, date]]:
|
|
31
|
+
"""
|
|
32
|
+
Display a date slider with single or range selection.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
label: Label text for the slider
|
|
36
|
+
min_val: Minimum selectable date
|
|
37
|
+
max_val: Maximum selectable date
|
|
38
|
+
value: Current value - single date or tuple of (start, end) for range mode
|
|
39
|
+
step_type: Step granularity - "month", "quarter", "year", "week", "day", or None
|
|
40
|
+
When set to a calendar unit, snaps to boundaries (e.g., 1st of month).
|
|
41
|
+
When "day" or None, uses the `step` timedelta parameter.
|
|
42
|
+
step: Step increment as timedelta (only used when step_type is "day" or None)
|
|
43
|
+
Defaults to timedelta(days=1)
|
|
44
|
+
format: Display format string - "YYYY-MM", "YYYY-MM-DD", "MMM YYYY", etc.
|
|
45
|
+
color: Accent color - preset name or hex value
|
|
46
|
+
style: Inline CSS styles as a dictionary
|
|
47
|
+
class_name: Tailwind CSS classes
|
|
48
|
+
theme: Optional theme dictionary. If None, uses active global theme.
|
|
49
|
+
defer_update: If True, don't trigger Streamlit rerun on change.
|
|
50
|
+
key: Unique key for the component
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
Single date if value was a date, or tuple (start, end) if value was a tuple
|
|
54
|
+
|
|
55
|
+
Example:
|
|
56
|
+
# Monthly range selection
|
|
57
|
+
start, end = form_date_slider(
|
|
58
|
+
label="Date Range",
|
|
59
|
+
min_val=date(2024, 1, 1),
|
|
60
|
+
max_val=date(2025, 12, 31),
|
|
61
|
+
value=(date(2024, 3, 1), date(2024, 9, 1)),
|
|
62
|
+
step_type="month",
|
|
63
|
+
format="YYYY-MM",
|
|
64
|
+
key="date_range"
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
# Single month selection
|
|
68
|
+
selected = form_date_slider(
|
|
69
|
+
label="Select Month",
|
|
70
|
+
min_val=date(2024, 1, 1),
|
|
71
|
+
max_val=date(2025, 12, 31),
|
|
72
|
+
value=date(2024, 6, 1),
|
|
73
|
+
step_type="month",
|
|
74
|
+
format="YYYY-MM",
|
|
75
|
+
key="single_month"
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
# Daily stepping with custom interval
|
|
79
|
+
selected = form_date_slider(
|
|
80
|
+
label="Select Date",
|
|
81
|
+
min_val=date(2024, 1, 1),
|
|
82
|
+
max_val=date(2024, 12, 31),
|
|
83
|
+
value=date(2024, 6, 15),
|
|
84
|
+
step_type="day",
|
|
85
|
+
step=timedelta(days=7), # Weekly steps
|
|
86
|
+
format="YYYY-MM-DD",
|
|
87
|
+
key="weekly_date"
|
|
88
|
+
)
|
|
89
|
+
"""
|
|
90
|
+
# Determine if range mode based on value type
|
|
91
|
+
is_range = isinstance(value, (tuple, list))
|
|
92
|
+
|
|
93
|
+
# Convert dates to ISO strings
|
|
94
|
+
min_val_str = min_val.isoformat()
|
|
95
|
+
max_val_str = max_val.isoformat()
|
|
96
|
+
|
|
97
|
+
if is_range:
|
|
98
|
+
value_data = [value[0].isoformat(), value[1].isoformat()]
|
|
99
|
+
default_data = value_data
|
|
100
|
+
else:
|
|
101
|
+
value_data = value.isoformat()
|
|
102
|
+
default_data = value_data
|
|
103
|
+
|
|
104
|
+
# Convert step timedelta to days if provided
|
|
105
|
+
step_days = None
|
|
106
|
+
if step is not None:
|
|
107
|
+
step_days = step.days
|
|
108
|
+
elif step_type in ("day", None):
|
|
109
|
+
step_days = 1 # Default to 1 day
|
|
110
|
+
|
|
111
|
+
# Resolve theme (None = use global, False = disable)
|
|
112
|
+
from ..themes import get_active_theme
|
|
113
|
+
resolved_theme = None
|
|
114
|
+
if theme is not False:
|
|
115
|
+
resolved_theme = theme if theme is not None else get_active_theme()
|
|
116
|
+
|
|
117
|
+
result = _component(
|
|
118
|
+
component="form_date_slider",
|
|
119
|
+
label=label,
|
|
120
|
+
minVal=min_val_str,
|
|
121
|
+
maxVal=max_val_str,
|
|
122
|
+
value=value_data,
|
|
123
|
+
stepType=step_type,
|
|
124
|
+
stepDays=step_days,
|
|
125
|
+
format=format,
|
|
126
|
+
color=color,
|
|
127
|
+
style=style,
|
|
128
|
+
className=class_name,
|
|
129
|
+
theme=resolved_theme,
|
|
130
|
+
deferUpdate=defer_update,
|
|
131
|
+
componentKey=key,
|
|
132
|
+
key=key,
|
|
133
|
+
default=default_data,
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
# Parse result back to date objects
|
|
137
|
+
if result is None:
|
|
138
|
+
return value
|
|
139
|
+
|
|
140
|
+
if is_range:
|
|
141
|
+
if isinstance(result, (list, tuple)) and len(result) == 2:
|
|
142
|
+
return (date.fromisoformat(result[0]), date.fromisoformat(result[1]))
|
|
143
|
+
return value
|
|
144
|
+
else:
|
|
145
|
+
if isinstance(result, str):
|
|
146
|
+
return date.fromisoformat(result)
|
|
147
|
+
return value
|
{streamlit_react_components-1.7.4.dist-info → streamlit_react_components-1.8.1.0.dist-info}/RECORD
RENAMED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
streamlit_react_components/__init__.py,sha256=
|
|
1
|
+
streamlit_react_components/__init__.py,sha256=JXkDquePuBCkfzO7zA97cteHK3TiPlL84n1Fs6S1DJc,1123
|
|
2
2
|
streamlit_react_components/styled_container.py,sha256=wtCiEC-cc1lUredDquG8jcccZYW86eKNrUZtWD6mw84,6063
|
|
3
3
|
streamlit_react_components/tailwind.py,sha256=2UDnKnHWmY3CWyfyEc-jHbznepjPi9Zy5Ugi0UsIDBQ,47953
|
|
4
4
|
streamlit_react_components/themes.py,sha256=zAp314i-WZMP5WZjOKrFoKmTd84tLyuyICKOJAz4rB0,35225
|
|
5
|
-
streamlit_react_components/_frontend/index.css,sha256=
|
|
5
|
+
streamlit_react_components/_frontend/index.css,sha256=nGAyY9oe87Ayha6-wUCCA2wQFWWhVw0NRGOU_D5P9h4,30364
|
|
6
6
|
streamlit_react_components/_frontend/index.html,sha256=CjBEtVYlgT_q06BE16EHFrUrJZ6z0MCprrTg7qgAWzw,381
|
|
7
|
-
streamlit_react_components/_frontend/index.js,sha256=
|
|
7
|
+
streamlit_react_components/_frontend/index.js,sha256=u50wRx2cKA2-WmyxDqbqfkdHoP6OWguKWHH5is8FnQ4,5232872
|
|
8
8
|
streamlit_react_components/common/__init__.py,sha256=l5BfFZdqjrdLG3sJnJrgahEiTgoBX92_aE0wp2tn_w0,606
|
|
9
9
|
streamlit_react_components/common/button_group.py,sha256=TlOmJRCPEb4MWMmKKiTe2a8ENElC_YB83mHp_WCFDas,2672
|
|
10
10
|
streamlit_react_components/common/chart_legend.py,sha256=ylul6Os5A89S8fIJs7XpBdIk6uWijg_zwR1eB7u9wSw,1824
|
|
@@ -16,12 +16,13 @@ streamlit_react_components/common/section_header.py,sha256=zgEW9Jlj48kiRB3_mYLk3
|
|
|
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
18
|
streamlit_react_components/common/step_indicator.py,sha256=RjoBdgWrhrUc2Rs5lTxs_4ocBuMJDI8ELNIQE_0Y7js,1817
|
|
19
|
-
streamlit_react_components/form/__init__.py,sha256=
|
|
19
|
+
streamlit_react_components/form/__init__.py,sha256=urk_QJxnOrlMoHBTbCUGfjwxCbNs5lTFIoexUYB4AsA,349
|
|
20
20
|
streamlit_react_components/form/checkbox_group.py,sha256=yF2g991jPwOIk28ugyJ8T7-K2kQnCUXdymmIxzuV74g,3325
|
|
21
|
+
streamlit_react_components/form/form_date_slider.py,sha256=YB--bP0M_qgfcCyZ5A7AAYhgMIEXVtntC4vEmoTZh6U,4819
|
|
21
22
|
streamlit_react_components/form/form_select.py,sha256=bzrfFtE8gtMszqL77hUa4TBa5LvUI88RxcNhwt1ojx0,3021
|
|
22
23
|
streamlit_react_components/form/form_slider.py,sha256=vK8iqlWNnly0UiSdI71fxkjNZK0ZJlUC8DCkjBcULmI,3143
|
|
23
24
|
streamlit_react_components/form/radio_group.py,sha256=1mL6FOhBfiPQSV6owUl7rcl0AgR5xIE-RmfiKPb-fVk,3217
|
|
24
|
-
streamlit_react_components-1.
|
|
25
|
-
streamlit_react_components-1.
|
|
26
|
-
streamlit_react_components-1.
|
|
27
|
-
streamlit_react_components-1.
|
|
25
|
+
streamlit_react_components-1.8.1.0.dist-info/METADATA,sha256=YGtvHznc9QS-R2_QT3mf-LLefvpdyoZCt0lBZ5-MxsU,21679
|
|
26
|
+
streamlit_react_components-1.8.1.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
27
|
+
streamlit_react_components-1.8.1.0.dist-info/top_level.txt,sha256=3JFrl15-Uewx3BFMSzqrBufF9GmTS1LDKfShmg0R9VE,27
|
|
28
|
+
streamlit_react_components-1.8.1.0.dist-info/RECORD,,
|
{streamlit_react_components-1.7.4.dist-info → streamlit_react_components-1.8.1.0.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|