Skip to content

Commit

Permalink
rename folder + add feature
Browse files Browse the repository at this point in the history
  • Loading branch information
hoggatt committed Sep 13, 2023
1 parent e519912 commit 8274ca7
Show file tree
Hide file tree
Showing 15 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
recursive-include streamlit_searchbox/frontend/build *
recursive-include st_combobox/frontend/build *
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# streamlit-searchbox
# st-combobox

- [Installation](#installation)
- [Overview](#overview)
Expand All @@ -15,7 +15,7 @@ A streamlit custom component providing a searchbox with autocomplete.
## Installation

```python
pip install streamlit-searchbox
pip install st-combobox
```

## Overview
Expand Down
9 changes: 7 additions & 2 deletions streamlit_searchbox/__init__.py → st_combobox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def _process_search(
search_function: Callable[[str], List[any]],
key: str,
searchterm: str,
rerun_on_update: str
) -> bool:
# nothing changed, avoid new search
if searchterm == st.session_state[key]["search"]:
Expand Down Expand Up @@ -73,7 +74,8 @@ def _get_value(value: any) -> any:
# used for proper return types
st.session_state[key]["options_real_type"] = [_get_value(v) for v in search_results]

st.experimental_rerun()
if rerun_on_update:
st.experimental_rerun()


@wrap_inactive_session
Expand All @@ -84,6 +86,7 @@ def st_searchbox(
default: any = None,
clear_on_submit: bool = False,
key: str = "searchbox",
rerun_on_update: bool = False,
**kwargs,
) -> any:
"""
Expand All @@ -103,6 +106,8 @@ def st_searchbox(
Remove suggestions on select. Defaults to False.
key (str, optional):
Streamlit session key. Defaults to "searchbox".
rerun_on_update (bool, optional):
Rerun the search function on each keystroke. Defaults to True.
Returns:
any: based on user selection
Expand Down Expand Up @@ -139,7 +144,7 @@ def st_searchbox(

if interaction == "search":
# triggers rerun, no ops afterwards executed
_process_search(search_function, key, value)
_process_search(search_function, key, value, rerun_on_update)

if interaction == "submit":
st.session_state[key]["result"] = (
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 8274ca7

Please sign in to comment.