streamlit-sortable-multiselect 0.1.1__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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Developer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,9 @@
1
+ include README.md
2
+ include LICENSE
3
+ recursive-include streamlit_sortable_multiselect/frontend/build *
4
+ prune streamlit_sortable_multiselect/frontend/node_modules
5
+ prune streamlit_sortable_multiselect/frontend/src
6
+ exclude streamlit_sortable_multiselect/frontend/package-lock.json
7
+ exclude streamlit_sortable_multiselect/frontend/package.json
8
+ exclude streamlit_sortable_multiselect/frontend/tsconfig.json
9
+ exclude streamlit_sortable_multiselect/frontend/vite.config.ts
@@ -0,0 +1,99 @@
1
+ Metadata-Version: 2.4
2
+ Name: streamlit-sortable-multiselect
3
+ Version: 0.1.1
4
+ Summary: A Streamlit custom component for selecting and reordering multiple string values.
5
+ Author: Developer
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/KentaroAOKI/streamlit-sortable-multiselect
8
+ Project-URL: Repository, https://github.com/KentaroAOKI/streamlit-sortable-multiselect
9
+ Project-URL: Issues, https://github.com/KentaroAOKI/streamlit-sortable-multiselect/issues
10
+ Keywords: streamlit,component,multiselect,sortable,drag-and-drop
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Requires-Python: >=3.9
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: streamlit>=1.30
23
+ Provides-Extra: dev
24
+ Requires-Dist: build>=1.2; extra == "dev"
25
+ Requires-Dist: pytest>=8; extra == "dev"
26
+ Requires-Dist: twine>=6; extra == "dev"
27
+ Dynamic: license-file
28
+
29
+ # streamlit-sortable-multiselect
30
+
31
+ A Streamlit custom component for selecting multiple string values and changing the selected order.
32
+
33
+ ## Install
34
+
35
+ ```bash
36
+ python -m pip install streamlit-sortable-multiselect
37
+ ```
38
+
39
+ For local development:
40
+
41
+ ```bash
42
+ python -m pip install -e ".[dev]"
43
+ ```
44
+
45
+ For frontend development:
46
+
47
+ ```bash
48
+ cd streamlit_sortable_multiselect/frontend
49
+ npm install
50
+ npm run dev
51
+ ```
52
+
53
+ ## Usage
54
+
55
+ ```python
56
+ import streamlit as st
57
+ from streamlit_sortable_multiselect import sortable_multiselect
58
+
59
+ selected = sortable_multiselect(
60
+ "Favorite frameworks",
61
+ options=["Streamlit", "FastAPI", "Django", "Flask"],
62
+ default=["Streamlit"],
63
+ )
64
+
65
+ st.write(selected)
66
+ ```
67
+
68
+ Build the frontend before packaging or using release mode:
69
+
70
+ ```bash
71
+ cd streamlit_sortable_multiselect/frontend
72
+ npm run build
73
+ ```
74
+
75
+ Run the example app:
76
+
77
+ ```bash
78
+ streamlit run examples/basic.py
79
+ ```
80
+
81
+ ## Release
82
+
83
+ Build and check the distribution files:
84
+
85
+ ```bash
86
+ cd streamlit_sortable_multiselect/frontend
87
+ npm install
88
+ npm run build
89
+ cd ../..
90
+ python -m pip install -e ".[dev]"
91
+ python -m build
92
+ python -m twine check dist/*
93
+ ```
94
+
95
+ Upload to PyPI with an API token:
96
+
97
+ ```bash
98
+ python -m twine upload dist/*
99
+ ```
@@ -0,0 +1,71 @@
1
+ # streamlit-sortable-multiselect
2
+
3
+ A Streamlit custom component for selecting multiple string values and changing the selected order.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ python -m pip install streamlit-sortable-multiselect
9
+ ```
10
+
11
+ For local development:
12
+
13
+ ```bash
14
+ python -m pip install -e ".[dev]"
15
+ ```
16
+
17
+ For frontend development:
18
+
19
+ ```bash
20
+ cd streamlit_sortable_multiselect/frontend
21
+ npm install
22
+ npm run dev
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ```python
28
+ import streamlit as st
29
+ from streamlit_sortable_multiselect import sortable_multiselect
30
+
31
+ selected = sortable_multiselect(
32
+ "Favorite frameworks",
33
+ options=["Streamlit", "FastAPI", "Django", "Flask"],
34
+ default=["Streamlit"],
35
+ )
36
+
37
+ st.write(selected)
38
+ ```
39
+
40
+ Build the frontend before packaging or using release mode:
41
+
42
+ ```bash
43
+ cd streamlit_sortable_multiselect/frontend
44
+ npm run build
45
+ ```
46
+
47
+ Run the example app:
48
+
49
+ ```bash
50
+ streamlit run examples/basic.py
51
+ ```
52
+
53
+ ## Release
54
+
55
+ Build and check the distribution files:
56
+
57
+ ```bash
58
+ cd streamlit_sortable_multiselect/frontend
59
+ npm install
60
+ npm run build
61
+ cd ../..
62
+ python -m pip install -e ".[dev]"
63
+ python -m build
64
+ python -m twine check dist/*
65
+ ```
66
+
67
+ Upload to PyPI with an API token:
68
+
69
+ ```bash
70
+ python -m twine upload dist/*
71
+ ```
@@ -0,0 +1,55 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "streamlit-sortable-multiselect"
7
+ version = "0.1.1"
8
+ description = "A Streamlit custom component for selecting and reordering multiple string values."
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ authors = [
12
+ { name = "Developer" },
13
+ ]
14
+ license = "MIT"
15
+ keywords = ["streamlit", "component", "multiselect", "sortable", "drag-and-drop"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Intended Audience :: Developers",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.9",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Programming Language :: Python :: 3.13",
25
+ ]
26
+ dependencies = [
27
+ "streamlit>=1.30",
28
+ ]
29
+
30
+ [project.urls]
31
+ Homepage = "https://github.com/KentaroAOKI/streamlit-sortable-multiselect"
32
+ Repository = "https://github.com/KentaroAOKI/streamlit-sortable-multiselect"
33
+ Issues = "https://github.com/KentaroAOKI/streamlit-sortable-multiselect/issues"
34
+
35
+ [project.optional-dependencies]
36
+ dev = [
37
+ "build>=1.2",
38
+ "pytest>=8",
39
+ "twine>=6",
40
+ ]
41
+
42
+ [tool.setuptools]
43
+ include-package-data = true
44
+
45
+ [tool.setuptools.packages.find]
46
+ include = ["streamlit_sortable_multiselect*"]
47
+
48
+ [tool.setuptools.package-data]
49
+ streamlit_sortable_multiselect = [
50
+ "frontend/build/**/*",
51
+ ]
52
+
53
+ [tool.pytest.ini_options]
54
+ testpaths = ["tests"]
55
+ addopts = "-q"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,102 @@
1
+ """Streamlit sortable multiselect component."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ from pathlib import Path
7
+ from typing import Iterable, Sequence, cast
8
+
9
+ import streamlit.components.v1 as components
10
+
11
+ __version__ = "0.1.1"
12
+ __all__ = ["sortable_multiselect"]
13
+
14
+ _COMPONENT_NAME = "streamlit_sortable_multiselect"
15
+ _DEV_SERVER_URL = "http://localhost:5173"
16
+ _RELEASE = os.environ.get("STREAMLIT_SORTABLE_MULTISELECT_DEV") != "1"
17
+
18
+
19
+ def _declare_component():
20
+ if _RELEASE:
21
+ build_dir = Path(__file__).parent / "frontend" / "build"
22
+ return components.declare_component(_COMPONENT_NAME, path=str(build_dir))
23
+ return components.declare_component(_COMPONENT_NAME, url=_DEV_SERVER_URL)
24
+
25
+
26
+ _component_func = _declare_component()
27
+
28
+
29
+ def _validate_string_sequence(name: str, values: Sequence[str] | None) -> list[str]:
30
+ if values is None:
31
+ return []
32
+ if isinstance(values, str) or not isinstance(values, Iterable):
33
+ raise TypeError(f"{name} must be a sequence of strings.")
34
+
35
+ result = list(values)
36
+ invalid = [value for value in result if not isinstance(value, str)]
37
+ if invalid:
38
+ raise TypeError(f"{name} must contain only strings.")
39
+ return result
40
+
41
+
42
+ def sortable_multiselect(
43
+ label: str,
44
+ options: Sequence[str],
45
+ default: Sequence[str] | None = None,
46
+ placeholder: str = "Select...",
47
+ disabled: bool = False,
48
+ key: str | None = None,
49
+ ) -> list[str]:
50
+ """Select multiple string values and return them in user-defined order.
51
+
52
+ Parameters
53
+ ----------
54
+ label:
55
+ Text label rendered above the component.
56
+ options:
57
+ Available string values.
58
+ default:
59
+ Initially selected values, in the desired initial order.
60
+ placeholder:
61
+ Placeholder text shown in the add-item select control.
62
+ disabled:
63
+ Disable selection and ordering controls.
64
+ key:
65
+ Optional Streamlit component key.
66
+ """
67
+ if not isinstance(label, str):
68
+ raise TypeError("label must be a string.")
69
+ if not isinstance(placeholder, str):
70
+ raise TypeError("placeholder must be a string.")
71
+ if not isinstance(disabled, bool):
72
+ raise TypeError("disabled must be a bool.")
73
+
74
+ option_values = _validate_string_sequence("options", options)
75
+ default_values = _validate_string_sequence("default", default)
76
+
77
+ duplicate_options = sorted({value for value in option_values if option_values.count(value) > 1})
78
+ if duplicate_options:
79
+ raise ValueError("options must not contain duplicate values.")
80
+
81
+ missing_defaults = [value for value in default_values if value not in option_values]
82
+ if missing_defaults:
83
+ missing = ", ".join(repr(value) for value in missing_defaults)
84
+ raise ValueError(f"default contains values not present in options: {missing}.")
85
+
86
+ duplicate_defaults = sorted({value for value in default_values if default_values.count(value) > 1})
87
+ if duplicate_defaults:
88
+ raise ValueError("default must not contain duplicate values.")
89
+
90
+ component_value = _component_func(
91
+ label=label,
92
+ options=option_values,
93
+ default_selected=default_values,
94
+ placeholder=placeholder,
95
+ disabled=disabled,
96
+ key=key,
97
+ default=default_values,
98
+ )
99
+
100
+ if component_value is None:
101
+ return default_values
102
+ return cast(list[str], component_value)