streamlit-sortable-multiselect 0.7.6__tar.gz → 0.7.8__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.
Files changed (18) hide show
  1. {streamlit_sortable_multiselect-0.7.6/streamlit_sortable_multiselect.egg-info → streamlit_sortable_multiselect-0.7.8}/PKG-INFO +31 -3
  2. {streamlit_sortable_multiselect-0.7.6 → streamlit_sortable_multiselect-0.7.8}/README.md +30 -2
  3. {streamlit_sortable_multiselect-0.7.6 → streamlit_sortable_multiselect-0.7.8}/pyproject.toml +1 -1
  4. {streamlit_sortable_multiselect-0.7.6 → streamlit_sortable_multiselect-0.7.8}/streamlit_sortable_multiselect/__init__.py +10 -1
  5. streamlit_sortable_multiselect-0.7.8/streamlit_sortable_multiselect/frontend/build/assets/index-9M_rp0G-.js +67 -0
  6. streamlit_sortable_multiselect-0.7.8/streamlit_sortable_multiselect/frontend/build/assets/index-B1hHAom_.css +1 -0
  7. {streamlit_sortable_multiselect-0.7.6 → streamlit_sortable_multiselect-0.7.8}/streamlit_sortable_multiselect/frontend/build/index.html +2 -2
  8. {streamlit_sortable_multiselect-0.7.6 → streamlit_sortable_multiselect-0.7.8/streamlit_sortable_multiselect.egg-info}/PKG-INFO +31 -3
  9. {streamlit_sortable_multiselect-0.7.6 → streamlit_sortable_multiselect-0.7.8}/streamlit_sortable_multiselect.egg-info/SOURCES.txt +2 -2
  10. {streamlit_sortable_multiselect-0.7.6 → streamlit_sortable_multiselect-0.7.8}/tests/test_wrapper.py +34 -1
  11. streamlit_sortable_multiselect-0.7.6/streamlit_sortable_multiselect/frontend/build/assets/index-B3sxegjX.js +0 -67
  12. streamlit_sortable_multiselect-0.7.6/streamlit_sortable_multiselect/frontend/build/assets/index-CJc6AEWC.css +0 -1
  13. {streamlit_sortable_multiselect-0.7.6 → streamlit_sortable_multiselect-0.7.8}/LICENSE +0 -0
  14. {streamlit_sortable_multiselect-0.7.6 → streamlit_sortable_multiselect-0.7.8}/MANIFEST.in +0 -0
  15. {streamlit_sortable_multiselect-0.7.6 → streamlit_sortable_multiselect-0.7.8}/setup.cfg +0 -0
  16. {streamlit_sortable_multiselect-0.7.6 → streamlit_sortable_multiselect-0.7.8}/streamlit_sortable_multiselect.egg-info/dependency_links.txt +0 -0
  17. {streamlit_sortable_multiselect-0.7.6 → streamlit_sortable_multiselect-0.7.8}/streamlit_sortable_multiselect.egg-info/requires.txt +0 -0
  18. {streamlit_sortable_multiselect-0.7.6 → streamlit_sortable_multiselect-0.7.8}/streamlit_sortable_multiselect.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: streamlit-sortable-multiselect
3
- Version: 0.7.6
3
+ Version: 0.7.8
4
4
  Summary: A Streamlit custom component for selecting and reordering multiple string values.
5
5
  Author: Kentaro Aoki
6
6
  License-Expression: MIT
@@ -96,7 +96,7 @@ st.write(selected)
96
96
  | --- | --- | --- | --- |
97
97
  | `label` | `str` | required | Label displayed above the component. |
98
98
  | `options` | `Sequence[str \| Mapping[str, Any]]` | required | Available options. Each option can be a plain string, or a dictionary with `label`, `value`, and optional `icon_url`. Option values must be unique. |
99
- | `default` | `Sequence[str] \| None` | `None` | Initially selected values, in the initial order. Values must exist in `options` and must not contain duplicates. |
99
+ | `default` | `Sequence[str] \| None` | `None` | Initially selected values, in the initial order. Changing the values or their order replaces the current selection. Values must exist in `options` and must not contain duplicates. |
100
100
  | `placeholder` | `str` | `"Select..."` | Placeholder shown in the search/add input when options are available. |
101
101
  | `disabled` | `bool` | `False` | Disables searching, selecting, removing, dragging, and move buttons. |
102
102
  | `show_move_buttons` | `bool` | `True` | Shows up/down buttons on selected items. Drag sorting remains available unless `disabled=True`. |
@@ -108,7 +108,8 @@ st.write(selected)
108
108
  | `color_priority` | `Sequence[str] \| None` | `None` | Ranking of the color sources `"value"`, `"option"`, `"order"`, `"palette"`, and `"base"`. Omitted sources keep their default rank. |
109
109
  | `tooltip_color` | `str \| Mapping[str, str] \| None` | `None` | Color of the tooltip shown for labels that do not fit. `None` uses the built-in dark tooltip. See [Labels](#labels). |
110
110
  | `max_selections` | `int \| None` | `None` | Maximum number of selected items. `None` means no limit. Use `0` to prevent any selections. |
111
- | `max_selections_placeholder` | `str` | `"Selection limit reached"` | Placeholder shown when `max_selections` has been reached. This takes precedence over `placeholder` and `no_options_placeholder`. |
111
+ | `single_select_display` | `bool` | `False` | With `max_selections=1`, displays the selected item inside the search control and replaces it when another option is selected. |
112
+ | `max_selections_placeholder` | `str` | `"Selection limit reached"` | Placeholder shown when `max_selections` has been reached. This takes precedence over `placeholder` and `no_options_placeholder`, except in single-selection display mode. |
112
113
  | `empty_message` | `str` | `"No items selected"` | Message shown where the selected list appears when no items are selected. |
113
114
  | `no_options_placeholder` | `str` | `"No more options"` | Placeholder shown when every option is already selected and there are no more options to add. |
114
115
  | `selected_position` | `str` | `"bottom"` | Position of the selected item list relative to the search/add input. Use `"bottom"` or `"top"`. |
@@ -232,6 +233,33 @@ picks up both the background and the border, so it stays attached either way.
232
233
  `examples/tooltip_labels.py` shows the same options in a narrow list and a wide one,
233
234
  so the conditional behavior is visible side by side.
234
235
 
236
+ ## Single Selection Display
237
+
238
+ Set `single_select_display=True` together with `max_selections=1` to keep the selected
239
+ item inside the search control. The external selected-item list is not rendered in this
240
+ mode. The item keeps its label, icon, resolved colors, optional number, and truncated
241
+ label tooltip. Because no external selected list is rendered, `selected_position`,
242
+ `empty_message`, and `show_move_buttons` do not affect this mode.
243
+
244
+ ```python
245
+ selected = sortable_multiselect(
246
+ "Primary language",
247
+ options=[
248
+ {"label": "Python", "value": "python", "icon_url": "https://www.python.org/static/favicon.ico"},
249
+ {"label": "TypeScript", "value": "typescript"},
250
+ {"label": "Rust", "value": "rust"},
251
+ ],
252
+ default=["python"],
253
+ max_selections=1,
254
+ single_select_display=True,
255
+ )
256
+ ```
257
+
258
+ The input remains available after a selection. Opening the choices and selecting a new
259
+ option replaces the current value instead of adding another one. Use the remove button
260
+ inside the selected item to clear it. `single_select_display=True` without
261
+ `max_selections=1` raises `ValueError`.
262
+
235
263
  ## API Suggestions
236
264
 
237
265
  Set `suggestions_api_url` to request suggestions as the user types. Static `options` that match the query are shown first, followed by API results. Duplicate `value` entries prefer the static option.
@@ -68,7 +68,7 @@ st.write(selected)
68
68
  | --- | --- | --- | --- |
69
69
  | `label` | `str` | required | Label displayed above the component. |
70
70
  | `options` | `Sequence[str \| Mapping[str, Any]]` | required | Available options. Each option can be a plain string, or a dictionary with `label`, `value`, and optional `icon_url`. Option values must be unique. |
71
- | `default` | `Sequence[str] \| None` | `None` | Initially selected values, in the initial order. Values must exist in `options` and must not contain duplicates. |
71
+ | `default` | `Sequence[str] \| None` | `None` | Initially selected values, in the initial order. Changing the values or their order replaces the current selection. Values must exist in `options` and must not contain duplicates. |
72
72
  | `placeholder` | `str` | `"Select..."` | Placeholder shown in the search/add input when options are available. |
73
73
  | `disabled` | `bool` | `False` | Disables searching, selecting, removing, dragging, and move buttons. |
74
74
  | `show_move_buttons` | `bool` | `True` | Shows up/down buttons on selected items. Drag sorting remains available unless `disabled=True`. |
@@ -80,7 +80,8 @@ st.write(selected)
80
80
  | `color_priority` | `Sequence[str] \| None` | `None` | Ranking of the color sources `"value"`, `"option"`, `"order"`, `"palette"`, and `"base"`. Omitted sources keep their default rank. |
81
81
  | `tooltip_color` | `str \| Mapping[str, str] \| None` | `None` | Color of the tooltip shown for labels that do not fit. `None` uses the built-in dark tooltip. See [Labels](#labels). |
82
82
  | `max_selections` | `int \| None` | `None` | Maximum number of selected items. `None` means no limit. Use `0` to prevent any selections. |
83
- | `max_selections_placeholder` | `str` | `"Selection limit reached"` | Placeholder shown when `max_selections` has been reached. This takes precedence over `placeholder` and `no_options_placeholder`. |
83
+ | `single_select_display` | `bool` | `False` | With `max_selections=1`, displays the selected item inside the search control and replaces it when another option is selected. |
84
+ | `max_selections_placeholder` | `str` | `"Selection limit reached"` | Placeholder shown when `max_selections` has been reached. This takes precedence over `placeholder` and `no_options_placeholder`, except in single-selection display mode. |
84
85
  | `empty_message` | `str` | `"No items selected"` | Message shown where the selected list appears when no items are selected. |
85
86
  | `no_options_placeholder` | `str` | `"No more options"` | Placeholder shown when every option is already selected and there are no more options to add. |
86
87
  | `selected_position` | `str` | `"bottom"` | Position of the selected item list relative to the search/add input. Use `"bottom"` or `"top"`. |
@@ -204,6 +205,33 @@ picks up both the background and the border, so it stays attached either way.
204
205
  `examples/tooltip_labels.py` shows the same options in a narrow list and a wide one,
205
206
  so the conditional behavior is visible side by side.
206
207
 
208
+ ## Single Selection Display
209
+
210
+ Set `single_select_display=True` together with `max_selections=1` to keep the selected
211
+ item inside the search control. The external selected-item list is not rendered in this
212
+ mode. The item keeps its label, icon, resolved colors, optional number, and truncated
213
+ label tooltip. Because no external selected list is rendered, `selected_position`,
214
+ `empty_message`, and `show_move_buttons` do not affect this mode.
215
+
216
+ ```python
217
+ selected = sortable_multiselect(
218
+ "Primary language",
219
+ options=[
220
+ {"label": "Python", "value": "python", "icon_url": "https://www.python.org/static/favicon.ico"},
221
+ {"label": "TypeScript", "value": "typescript"},
222
+ {"label": "Rust", "value": "rust"},
223
+ ],
224
+ default=["python"],
225
+ max_selections=1,
226
+ single_select_display=True,
227
+ )
228
+ ```
229
+
230
+ The input remains available after a selection. Opening the choices and selecting a new
231
+ option replaces the current value instead of adding another one. Use the remove button
232
+ inside the selected item to clear it. `single_select_display=True` without
233
+ `max_selections=1` raises `ValueError`.
234
+
207
235
  ## API Suggestions
208
236
 
209
237
  Set `suggestions_api_url` to request suggestions as the user types. Static `options` that match the query are shown first, followed by API results. Duplicate `value` entries prefer the static option.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "streamlit-sortable-multiselect"
7
- version = "0.7.6"
7
+ version = "0.7.8"
8
8
  description = "A Streamlit custom component for selecting and reordering multiple string values."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -9,7 +9,7 @@ from urllib.parse import urlparse
9
9
 
10
10
  import streamlit.components.v1 as components
11
11
 
12
- __version__ = "0.7.6"
12
+ __version__ = "0.7.8"
13
13
  __all__ = ["COLOR_FIELDS", "COLOR_SOURCES", "ColorValue", "sortable_multiselect"]
14
14
 
15
15
  _COMPONENT_NAME = "streamlit_sortable_multiselect"
@@ -296,6 +296,7 @@ def sortable_multiselect(
296
296
  base_color: ColorValue | None = None,
297
297
  order_colors: Mapping[int, ColorValue] | None = None,
298
298
  max_selections: int | None = None,
299
+ single_select_display: bool = False,
299
300
  max_selections_placeholder: str = "Selection limit reached",
300
301
  empty_message: str = "No items selected",
301
302
  no_options_placeholder: str = "No more options",
@@ -347,6 +348,9 @@ def sortable_multiselect(
347
348
  the top (1 is first), negative keys count from the bottom (-1 is last).
348
349
  max_selections:
349
350
  Maximum number of selected items. None means no limit.
351
+ single_select_display:
352
+ Display the selected item inside the search control and replace it when
353
+ another option is selected. Requires max_selections=1.
350
354
  max_selections_placeholder:
351
355
  Placeholder text shown when the maximum selection count is reached.
352
356
  empty_message:
@@ -418,6 +422,8 @@ def sortable_multiselect(
418
422
  raise TypeError("show_move_buttons must be a bool.")
419
423
  if not isinstance(show_numbers, bool):
420
424
  raise TypeError("show_numbers must be a bool.")
425
+ if not isinstance(single_select_display, bool):
426
+ raise TypeError("single_select_display must be a bool.")
421
427
 
422
428
  base_color_value = None if base_color is None else _require_color("base_color", base_color)
423
429
  tooltip_color_value = (
@@ -431,6 +437,8 @@ def sortable_multiselect(
431
437
  color_palette_values = _validate_color_palette(color_palette)
432
438
  color_priority_values = _validate_color_priority(color_priority)
433
439
  max_selection_count = _validate_max_selections(max_selections)
440
+ if single_select_display and max_selection_count != 1:
441
+ raise ValueError("single_select_display requires max_selections=1.")
434
442
  icon_size_value = _validate_icon_size(icon_size)
435
443
  options_max_height_value = _validate_options_max_height(options_max_height)
436
444
  suggestions_api_url_value = _validate_suggestions_api_url(suggestions_api_url)
@@ -508,6 +516,7 @@ def sortable_multiselect(
508
516
  color_priority=color_priority_values,
509
517
  tooltip_color=tooltip_color_value,
510
518
  max_selections=max_selection_count,
519
+ single_select_display=single_select_display,
511
520
  max_selections_placeholder=max_selections_placeholder,
512
521
  empty_message=empty_message,
513
522
  no_options_placeholder=no_options_placeholder,