st-copy-button 0.0.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.
@@ -0,0 +1,25 @@
1
+ MIT License
2
+
3
+ For st-copy-button:
4
+ Copyright (c) 2025 James Young
5
+
6
+ For portions derived from st-copy-to-clipboard:
7
+ Copyright (c) 2023 Sasmitha Manathunga
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
@@ -0,0 +1,56 @@
1
+ Metadata-Version: 2.1
2
+ Name: st-copy-button
3
+ Version: 0.0.7
4
+ Summary: A simple Streamlit component for copying text to the user's clipboard with one click.
5
+ Home-page: https://gitlab.com/james.young2/st-copy-button
6
+ License: MIT
7
+ Keywords: streamlit,component,clipboard
8
+ Author: James Young
9
+ Author-email: james.young@ramseysolutions.com
10
+ Requires-Python: >=3.9.8,<4.0.0
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Requires-Dist: flake8 (>=7.1.2,<8.0.0)
18
+ Requires-Dist: setuptools (>=75.8.0,<76.0.0)
19
+ Requires-Dist: streamlit (>=1.31.0,<2.0.0)
20
+ Requires-Dist: twine (>=6.1.0,<7.0.0)
21
+ Requires-Dist: wheel (>=0.45.1,<0.46.0)
22
+ Project-URL: Repository, https://gitlab.com/james.young2/st-copy-button
23
+ Description-Content-Type: text/markdown
24
+
25
+ # st-copy-button
26
+
27
+ A simple Streamlit component for copying text to the user's clipboard with one click.
28
+
29
+ Contains portions derived from mmz-001's st-copy-to-clipboard component.
30
+
31
+ ## Installation instructions
32
+
33
+ ```sh
34
+ pip install st-copy-button
35
+ ```
36
+
37
+ ## Usage instructions
38
+
39
+ > Note: The clipboard API is only available in secure contexts (HTTPS)
40
+
41
+ ```python
42
+ import streamlit as st
43
+ from st_copy_button import st_copy_button
44
+
45
+ # Basic usage
46
+ st_copy_button("Copy this to clipboard")
47
+
48
+ # With custom labels
49
+ st_copy_button(
50
+ text="Custom text",
51
+ before_copy_label="📋 Push to copy",
52
+ after_copy_label="✅ Text copied!",
53
+ show_text=True
54
+ )
55
+ ```
56
+
@@ -0,0 +1,31 @@
1
+ # st-copy-button
2
+
3
+ A simple Streamlit component for copying text to the user's clipboard with one click.
4
+
5
+ Contains portions derived from mmz-001's st-copy-to-clipboard component.
6
+
7
+ ## Installation instructions
8
+
9
+ ```sh
10
+ pip install st-copy-button
11
+ ```
12
+
13
+ ## Usage instructions
14
+
15
+ > Note: The clipboard API is only available in secure contexts (HTTPS)
16
+
17
+ ```python
18
+ import streamlit as st
19
+ from st_copy_button import st_copy_button
20
+
21
+ # Basic usage
22
+ st_copy_button("Copy this to clipboard")
23
+
24
+ # With custom labels
25
+ st_copy_button(
26
+ text="Custom text",
27
+ before_copy_label="📋 Push to copy",
28
+ after_copy_label="✅ Text copied!",
29
+ show_text=True
30
+ )
31
+ ```
@@ -0,0 +1,43 @@
1
+ [tool.poetry]
2
+ name = "st-copy-button"
3
+ version = "0.0.7"
4
+ description = "A simple Streamlit component for copying text to the user's clipboard with one click."
5
+ authors = ["James Young <james.young@ramseysolutions.com>"]
6
+ license = "MIT"
7
+ readme = "README.md"
8
+ homepage = "https://gitlab.com/james.young2/st-copy-button"
9
+ repository = "https://gitlab.com/james.young2/st-copy-button"
10
+ keywords = ["streamlit", "component", "clipboard"]
11
+ packages = [{ include = "st_copy_button" }]
12
+ include = [
13
+ "st_copy_button/frontend/build/*",
14
+ "st_copy_button/frontend/build/static/*",
15
+ "st_copy_button/frontend/build/static/js/*",
16
+ "st_copy_button/frontend/build/static/css/*",
17
+ ]
18
+
19
+ [tool.poetry.dependencies]
20
+ python = "^3.9.8"
21
+ streamlit = "^1.31.0"
22
+ setuptools = "^75.8.0"
23
+ wheel = "^0.45.1"
24
+ twine = "^6.1.0"
25
+ flake8 = "^7.1.2"
26
+
27
+ [tool.poetry.group.dev.dependencies]
28
+ pytest = "^8.2.0"
29
+ pytest-asyncio = "^0.25.3"
30
+ playwright = "^1.48.0"
31
+ requests = "^2.31.0"
32
+ pytest-playwright-snapshot = "^1.0"
33
+ pytest-rerunfailures = "^12.0"
34
+ flake8 = "^7.1.2"
35
+
36
+ [tool.pytest.ini_options]
37
+ asyncio_default_fixture_loop_scope = "function"
38
+ addopts = "-ra --reruns 3"
39
+ testpaths = ["tests"]
40
+
41
+ [build-system]
42
+ requires = ["poetry-core~=1.0"]
43
+ build-backend = "poetry.core.masonry.api"
@@ -0,0 +1,53 @@
1
+ import os
2
+ import streamlit.components.v1 as components
3
+
4
+ _RELEASE = True
5
+
6
+ if not _RELEASE:
7
+ _component_func = components.declare_component(
8
+ "st_copy_button",
9
+ url="http://localhost:3001",
10
+ )
11
+ else:
12
+ parent_dir = os.path.dirname(os.path.abspath(__file__))
13
+ build_dir = os.path.join(parent_dir, "frontend/build")
14
+ _component_func = components.declare_component(
15
+ "st_copy_button", path=build_dir
16
+ )
17
+
18
+
19
+ def st_copy_button(
20
+ text: str,
21
+ before_copy_label: str = "📋",
22
+ after_copy_label: str = "✅",
23
+ show_text: bool = False,
24
+ key=None
25
+ ):
26
+ """Create a button that copies text to the user's clipboard when clicked.
27
+
28
+ Parameters
29
+ ----------
30
+ text: str
31
+ The text to be copied to the clipboard.
32
+ before_copy_label: str
33
+ The button label before copying occurs. Defaults to "📋".
34
+ after_copy_label: str
35
+ The button label after copying occurs. Defaults to "✅".
36
+ show_text: bool
37
+ If True, displays the text to be copied as a second, also clickable
38
+ button, to the left of the first.
39
+ key: str or None
40
+ An optional key that uniquely identifies this component.
41
+
42
+ Returns
43
+ -------
44
+ component_value
45
+ """
46
+ component_value = _component_func(
47
+ text=text,
48
+ before_copy_label=before_copy_label,
49
+ after_copy_label=after_copy_label,
50
+ show_text=show_text,
51
+ key=key,
52
+ )
53
+ return component_value
@@ -0,0 +1,35 @@
1
+ import streamlit as st
2
+ from st_copy_button import st_copy_button
3
+
4
+ st.subheader("Copy to Clipboard Component Demo")
5
+
6
+ # Basic Example
7
+ st.write("### Basic Example")
8
+ text = st.text_input("Enter text to copy", value="Hello World")
9
+ copied = st_copy_button(text, key="basic")
10
+ if copied is None: # Convert None to False initially
11
+ copied = False
12
+ st.write(f"Text copied: {copied}")
13
+
14
+ # Custom Labels
15
+ st.write("### Custom Labels")
16
+ copied_custom = st_copy_button(
17
+ text,
18
+ before_copy_label="📋 Push to copy",
19
+ after_copy_label="✅ Text copied!",
20
+ key="custom"
21
+ )
22
+ if copied_custom is None:
23
+ copied_custom = False
24
+ st.write(f"Text copied: {copied_custom}")
25
+
26
+ # With Visible Text
27
+ st.write("### With Visible Text")
28
+ copied_visible = st_copy_button(
29
+ text,
30
+ show_text=True,
31
+ key="visible"
32
+ )
33
+ if copied_visible is None:
34
+ copied_visible = False
35
+ st.write(f"Text copied: {copied_visible}")
@@ -0,0 +1,6 @@
1
+ # Run the component's dev server on :3001
2
+ # (The Streamlit dev server already runs on :3000)
3
+ PORT=3001
4
+
5
+ # Don't automatically open the web browser on `npm run start`.
6
+ BROWSER=none
@@ -0,0 +1,5 @@
1
+ {
2
+ "endOfLine": "lf",
3
+ "semi": false,
4
+ "trailingComma": "es5"
5
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "files": {
3
+ "main.js": "./static/js/main.105053e0.js",
4
+ "index.html": "./index.html",
5
+ "main.105053e0.js.map": "./static/js/main.105053e0.js.map"
6
+ },
7
+ "entrypoints": [
8
+ "static/js/main.105053e0.js"
9
+ ]
10
+ }