Metadata-Version: 2.1
Name: streamlit-js-eval
Version: 0.0.13
Summary: A custom Streamlit component to evaluate arbitrary Javascript expressions.
Home-page: https://github.com/aghasemi/streamlit_js_eval
Author: Alireza Ghasemi
Author-email: ghasemi.a.ir@gmail.com
Keywords: Python,Streamlit,JavaScript
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE

# Streamlit-JS-Eval

[![Downloads](https://pepy.tech/badge/streamlit-js-eval)](https://pepy.tech/badge/streamlit-js-eval)

SJE is a minima custom Streamlit component, built to evaluate arbitrary Javascript expressions and return the result. It can become useful in doing certain functionalities which are _simple_ things in JavaScript, but unavailable or difficult to do in Streamlit. Examples include cookie management, writing to clipboard, getting device width (e.g. to check if we are on a mobile device), getting browser language, sharing something through Android's share feature, knowing user agent, etc. See [MDN docs](https://developer.mozilla.org/en-US/docs/Web/API) for more information about Web APIs. 

## Example

```python
st.write(f"Screen width is {streamlit_js_eval(js_expressions='screen.width', want_output = True, key = 'SCR')}")
```
`key` is an arbitrary but unique string, required by Streamlit components API for each call to `streamlit_js_eval`.

### Common JavaScript functionalities

Some more common functionalities are already implemented as Python functions. Examples include:

```python
# Returns user's location after asking for permission when the user clicks the generated link with the given tex
location = get_geolocation('Get my location')
# The URL parts of the page
location_json = get_page_location()
```

See `streamlit_js_eval/__init__.py` for more functions.
