diff --git a/MANIFEST.in b/MANIFEST.in index 5dd2aa4..49d910a 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1 @@ -recursive-include streamlit_searchbox/frontend/build * +recursive-include st_combobox/frontend/build * diff --git a/README.md b/README.md index ccdce3c..9f1af0d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# streamlit-searchbox +# st-combobox - [Installation](#installation) - [Overview](#overview) @@ -15,7 +15,7 @@ A streamlit custom component providing a searchbox with autocomplete. ## Installation ```python -pip install streamlit-searchbox +pip install st-combobox ``` ## Overview diff --git a/streamlit_searchbox/__init__.py b/st_combobox/__init__.py similarity index 93% rename from streamlit_searchbox/__init__.py rename to st_combobox/__init__.py index b0d3a0e..64b577c 100644 --- a/streamlit_searchbox/__init__.py +++ b/st_combobox/__init__.py @@ -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"]: @@ -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 @@ -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: """ @@ -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 @@ -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"] = ( diff --git a/streamlit_searchbox/frontend/.env b/st_combobox/frontend/.env similarity index 100% rename from streamlit_searchbox/frontend/.env rename to st_combobox/frontend/.env diff --git a/streamlit_searchbox/frontend/.prettierrc b/st_combobox/frontend/.prettierrc similarity index 100% rename from streamlit_searchbox/frontend/.prettierrc rename to st_combobox/frontend/.prettierrc diff --git a/streamlit_searchbox/frontend/package.json b/st_combobox/frontend/package.json similarity index 100% rename from streamlit_searchbox/frontend/package.json rename to st_combobox/frontend/package.json diff --git a/streamlit_searchbox/frontend/public/bootstrap.min.css b/st_combobox/frontend/public/bootstrap.min.css similarity index 100% rename from streamlit_searchbox/frontend/public/bootstrap.min.css rename to st_combobox/frontend/public/bootstrap.min.css diff --git a/streamlit_searchbox/frontend/public/index.html b/st_combobox/frontend/public/index.html similarity index 100% rename from streamlit_searchbox/frontend/public/index.html rename to st_combobox/frontend/public/index.html diff --git a/streamlit_searchbox/frontend/src/Searchbox.tsx b/st_combobox/frontend/src/Searchbox.tsx similarity index 100% rename from streamlit_searchbox/frontend/src/Searchbox.tsx rename to st_combobox/frontend/src/Searchbox.tsx diff --git a/streamlit_searchbox/frontend/src/icons/st-arrow.svg b/st_combobox/frontend/src/icons/st-arrow.svg similarity index 100% rename from streamlit_searchbox/frontend/src/icons/st-arrow.svg rename to st_combobox/frontend/src/icons/st-arrow.svg diff --git a/streamlit_searchbox/frontend/src/icons/st-clear.svg b/st_combobox/frontend/src/icons/st-clear.svg similarity index 100% rename from streamlit_searchbox/frontend/src/icons/st-clear.svg rename to st_combobox/frontend/src/icons/st-clear.svg diff --git a/streamlit_searchbox/frontend/src/index.tsx b/st_combobox/frontend/src/index.tsx similarity index 100% rename from streamlit_searchbox/frontend/src/index.tsx rename to st_combobox/frontend/src/index.tsx diff --git a/streamlit_searchbox/frontend/src/react-app-env.d.ts b/st_combobox/frontend/src/react-app-env.d.ts similarity index 100% rename from streamlit_searchbox/frontend/src/react-app-env.d.ts rename to st_combobox/frontend/src/react-app-env.d.ts diff --git a/streamlit_searchbox/frontend/src/styling.tsx b/st_combobox/frontend/src/styling.tsx similarity index 100% rename from streamlit_searchbox/frontend/src/styling.tsx rename to st_combobox/frontend/src/styling.tsx diff --git a/streamlit_searchbox/frontend/tsconfig.json b/st_combobox/frontend/tsconfig.json similarity index 100% rename from streamlit_searchbox/frontend/tsconfig.json rename to st_combobox/frontend/tsconfig.json