streambricks 0.2.6__tar.gz → 0.2.7__tar.gz
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.
- {streambricks-0.2.6 → streambricks-0.2.7}/PKG-INFO +1 -1
- {streambricks-0.2.6 → streambricks-0.2.7}/src/streambricks/__init__.py +1 -1
- {streambricks-0.2.6 → streambricks-0.2.7}/src/streambricks/widgets/model_widget.py +45 -3
- {streambricks-0.2.6 → streambricks-0.2.7}/.copier-answers.yml +0 -0
- {streambricks-0.2.6 → streambricks-0.2.7}/.github/FUNDING.yml +0 -0
- {streambricks-0.2.6 → streambricks-0.2.7}/.github/copilot-instructions.md +0 -0
- {streambricks-0.2.6 → streambricks-0.2.7}/.github/dependabot.yml +0 -0
- {streambricks-0.2.6 → streambricks-0.2.7}/.github/workflows/build.yml +0 -0
- {streambricks-0.2.6 → streambricks-0.2.7}/.github/workflows/documentation.yml +0 -0
- {streambricks-0.2.6 → streambricks-0.2.7}/.gitignore +0 -0
- {streambricks-0.2.6 → streambricks-0.2.7}/.pre-commit-config.yaml +0 -0
- {streambricks-0.2.6 → streambricks-0.2.7}/LICENSE +0 -0
- {streambricks-0.2.6 → streambricks-0.2.7}/README.md +0 -0
- {streambricks-0.2.6 → streambricks-0.2.7}/docs/.empty +0 -0
- {streambricks-0.2.6 → streambricks-0.2.7}/duties.py +0 -0
- {streambricks-0.2.6 → streambricks-0.2.7}/mkdocs.yml +0 -0
- {streambricks-0.2.6 → streambricks-0.2.7}/overrides/_dummy.txt +0 -0
- {streambricks-0.2.6 → streambricks-0.2.7}/pyproject.toml +0 -0
- {streambricks-0.2.6 → streambricks-0.2.7}/src/streambricks/helpers.py +0 -0
- {streambricks-0.2.6 → streambricks-0.2.7}/src/streambricks/py.typed +0 -0
- {streambricks-0.2.6 → streambricks-0.2.7}/src/streambricks/state.py +0 -0
- {streambricks-0.2.6 → streambricks-0.2.7}/src/streambricks/widgets/__init__.py +0 -0
- {streambricks-0.2.6 → streambricks-0.2.7}/src/streambricks/widgets/model_selector.py +0 -0
- {streambricks-0.2.6 → streambricks-0.2.7}/src/streambricks/widgets/multi_select.py +0 -0
- {streambricks-0.2.6 → streambricks-0.2.7}/src/streambricks/widgets/type_helpers.py +0 -0
- {streambricks-0.2.6 → streambricks-0.2.7}/tests/__init__.py +0 -0
- {streambricks-0.2.6 → streambricks-0.2.7}/tests/conftest.py +0 -0
- {streambricks-0.2.6 → streambricks-0.2.7}/tests/test_widgets.py +0 -0
|
@@ -260,6 +260,45 @@ def render_secret_str_field(
|
|
|
260
260
|
return SecretStr(text)
|
|
261
261
|
|
|
262
262
|
|
|
263
|
+
def render_datetime_field(
|
|
264
|
+
*,
|
|
265
|
+
key: str,
|
|
266
|
+
value: datetime | None = None,
|
|
267
|
+
label: str | None = None,
|
|
268
|
+
disabled: bool = False,
|
|
269
|
+
help: str | None = None, # noqa: A002
|
|
270
|
+
**field_info: Any,
|
|
271
|
+
) -> datetime:
|
|
272
|
+
"""Render a datetime field using date and time inputs."""
|
|
273
|
+
# Split into date and time components
|
|
274
|
+
current_date = value.date() if value else date.today()
|
|
275
|
+
current_time = value.time() if value else datetime.now().time()
|
|
276
|
+
|
|
277
|
+
# Create columns for date and time
|
|
278
|
+
date_col, time_col = st.columns(2)
|
|
279
|
+
|
|
280
|
+
with date_col:
|
|
281
|
+
selected_date = st.date_input(
|
|
282
|
+
label=f"{label or key} (Date)",
|
|
283
|
+
value=current_date,
|
|
284
|
+
disabled=disabled,
|
|
285
|
+
key=f"{key}_date",
|
|
286
|
+
help=help,
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
with time_col:
|
|
290
|
+
selected_time = st.time_input(
|
|
291
|
+
label=f"{label or key} (Time)",
|
|
292
|
+
value=current_time,
|
|
293
|
+
disabled=disabled,
|
|
294
|
+
key=f"{key}_time",
|
|
295
|
+
help=help,
|
|
296
|
+
)
|
|
297
|
+
|
|
298
|
+
# Combine date and time
|
|
299
|
+
return datetime.combine(selected_date, selected_time)
|
|
300
|
+
|
|
301
|
+
|
|
263
302
|
def render_literal_field(
|
|
264
303
|
*,
|
|
265
304
|
key: str,
|
|
@@ -771,12 +810,13 @@ def render_model_instance_field(
|
|
|
771
810
|
# Mapping of Python types to render functions
|
|
772
811
|
PRIMITIVE_RENDERERS = {
|
|
773
812
|
str: render_str_field,
|
|
813
|
+
bool: render_bool_field,
|
|
774
814
|
int: render_int_field,
|
|
775
815
|
float: render_float_field,
|
|
776
816
|
Decimal: render_float_field,
|
|
777
|
-
bool: render_bool_field,
|
|
778
817
|
date: render_date_field,
|
|
779
818
|
time: render_time_field,
|
|
819
|
+
datetime: render_datetime_field,
|
|
780
820
|
Enum: render_enum_field,
|
|
781
821
|
Literal: render_literal_field,
|
|
782
822
|
SecretStr: render_secret_str_field,
|
|
@@ -906,6 +946,8 @@ def display_value_readonly(value, field_type, key=None):
|
|
|
906
946
|
st.text(str(enum_value.name))
|
|
907
947
|
case bool() as bool_value:
|
|
908
948
|
st.checkbox("", value=bool_value, disabled=True, key=key)
|
|
949
|
+
case datetime():
|
|
950
|
+
st.text(value.strftime("%Y-%m-%d %H:%M:%S"))
|
|
909
951
|
case int() | float() | Decimal() | date() | time() | datetime():
|
|
910
952
|
st.text(str(value))
|
|
911
953
|
case str() as str_value:
|
|
@@ -1075,7 +1117,7 @@ if __name__ == "__main__":
|
|
|
1075
1117
|
status: int | str | bool = 2
|
|
1076
1118
|
"""A field that can be either int, str, or bool."""
|
|
1077
1119
|
|
|
1078
|
-
optional_text:
|
|
1120
|
+
optional_text: bool = True
|
|
1079
1121
|
"""Optional text field."""
|
|
1080
1122
|
|
|
1081
1123
|
tags: list[str] = Field(default_factory=list)
|
|
@@ -1093,7 +1135,7 @@ if __name__ == "__main__":
|
|
|
1093
1135
|
def demo():
|
|
1094
1136
|
st.title("Pydantic Form Demo")
|
|
1095
1137
|
if "model" not in st.session_state:
|
|
1096
|
-
st.session_state.model = TestModel(status=2
|
|
1138
|
+
st.session_state.model = TestModel(status=2)
|
|
1097
1139
|
st.session_state.model = render_model_form(TestModel)
|
|
1098
1140
|
with st.expander("Current Model State", expanded=True):
|
|
1099
1141
|
st.json(st.session_state.model.model_dump_json(indent=2))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|