streamlit-sortable-multiselect 0.7.5__tar.gz → 0.7.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.
- {streamlit_sortable_multiselect-0.7.5/streamlit_sortable_multiselect.egg-info → streamlit_sortable_multiselect-0.7.7}/PKG-INFO +137 -6
- {streamlit_sortable_multiselect-0.7.5 → streamlit_sortable_multiselect-0.7.7}/README.md +136 -5
- {streamlit_sortable_multiselect-0.7.5 → streamlit_sortable_multiselect-0.7.7}/pyproject.toml +1 -1
- {streamlit_sortable_multiselect-0.7.5 → streamlit_sortable_multiselect-0.7.7}/streamlit_sortable_multiselect/__init__.py +187 -23
- streamlit_sortable_multiselect-0.7.7/streamlit_sortable_multiselect/frontend/build/assets/index-B1hHAom_.css +1 -0
- streamlit_sortable_multiselect-0.7.7/streamlit_sortable_multiselect/frontend/build/assets/index-DD38ua0m.js +67 -0
- {streamlit_sortable_multiselect-0.7.5 → streamlit_sortable_multiselect-0.7.7}/streamlit_sortable_multiselect/frontend/build/index.html +2 -2
- {streamlit_sortable_multiselect-0.7.5 → streamlit_sortable_multiselect-0.7.7/streamlit_sortable_multiselect.egg-info}/PKG-INFO +137 -6
- {streamlit_sortable_multiselect-0.7.5 → streamlit_sortable_multiselect-0.7.7}/streamlit_sortable_multiselect.egg-info/SOURCES.txt +2 -2
- {streamlit_sortable_multiselect-0.7.5 → streamlit_sortable_multiselect-0.7.7}/tests/test_wrapper.py +169 -4
- streamlit_sortable_multiselect-0.7.5/streamlit_sortable_multiselect/frontend/build/assets/index-DGpJ50qI.css +0 -1
- streamlit_sortable_multiselect-0.7.5/streamlit_sortable_multiselect/frontend/build/assets/index-RH2LvVA2.js +0 -67
- {streamlit_sortable_multiselect-0.7.5 → streamlit_sortable_multiselect-0.7.7}/LICENSE +0 -0
- {streamlit_sortable_multiselect-0.7.5 → streamlit_sortable_multiselect-0.7.7}/MANIFEST.in +0 -0
- {streamlit_sortable_multiselect-0.7.5 → streamlit_sortable_multiselect-0.7.7}/setup.cfg +0 -0
- {streamlit_sortable_multiselect-0.7.5 → streamlit_sortable_multiselect-0.7.7}/streamlit_sortable_multiselect.egg-info/dependency_links.txt +0 -0
- {streamlit_sortable_multiselect-0.7.5 → streamlit_sortable_multiselect-0.7.7}/streamlit_sortable_multiselect.egg-info/requires.txt +0 -0
- {streamlit_sortable_multiselect-0.7.5 → streamlit_sortable_multiselect-0.7.7}/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.
|
|
3
|
+
Version: 0.7.7
|
|
4
4
|
Summary: A Streamlit custom component for selecting and reordering multiple string values.
|
|
5
5
|
Author: Kentaro Aoki
|
|
6
6
|
License-Expression: MIT
|
|
@@ -101,10 +101,15 @@ st.write(selected)
|
|
|
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`. |
|
|
103
103
|
| `show_numbers` | `bool` | `False` | Shows 1-based position numbers before selected item labels. |
|
|
104
|
-
| `base_color` | `str \| None` | `None` |
|
|
105
|
-
| `order_colors` | `Mapping[int, str] \| None` | `None` | Per-position
|
|
104
|
+
| `base_color` | `str \| Mapping[str, str] \| None` | `None` | Fallback color for every selected item. See [Colors](#colors). |
|
|
105
|
+
| `order_colors` | `Mapping[int, str \| Mapping[str, str]] \| None` | `None` | Per-position colors. Positive keys count from the top (`1` is first), negative keys count from the bottom (`-1` is last), for example `{1: "#fee2e2", -1: "#dcfce7"}`. |
|
|
106
|
+
| `value_colors` | `Mapping[str, str \| Mapping[str, str]] \| None` | `None` | Per-value colors keyed by option value, for example `{"python": "#3776ab"}`. These follow an item as it is reordered. |
|
|
107
|
+
| `color_palette` | `Sequence[str \| Mapping[str, str]] \| None` | `None` | Colors cycled across selected positions. Position 1 uses the first entry and the palette repeats for longer selections. |
|
|
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
|
+
| `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). |
|
|
106
110
|
| `max_selections` | `int \| None` | `None` | Maximum number of selected items. `None` means no limit. Use `0` to prevent any selections. |
|
|
107
|
-
| `
|
|
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. |
|
|
108
113
|
| `empty_message` | `str` | `"No items selected"` | Message shown where the selected list appears when no items are selected. |
|
|
109
114
|
| `no_options_placeholder` | `str` | `"No more options"` | Placeholder shown when every option is already selected and there are no more options to add. |
|
|
110
115
|
| `selected_position` | `str` | `"bottom"` | Position of the selected item list relative to the search/add input. Use `"bottom"` or `"top"`. |
|
|
@@ -116,6 +121,7 @@ st.write(selected)
|
|
|
116
121
|
| `suggestions_label_path` | `str` | `"label"` | Dot-separated path to each suggestion's display label. |
|
|
117
122
|
| `suggestions_value_path` | `str` | `"value"` | Dot-separated path to each suggestion's returned value. |
|
|
118
123
|
| `suggestions_icon_url_path` | `str \| None` | `"icon_url"` | Optional dot-separated path to each suggestion's icon URL. `None` disables API icons. |
|
|
124
|
+
| `suggestions_color_path` | `str \| None` | `None` | Optional dot-separated path to each suggestion's color. The value may be a CSS color string or a mapping of color fields. `None` disables API colors. |
|
|
119
125
|
| `suggestions_headers` | `Mapping[str, str] \| None` | `None` | HTTP headers sent with suggestions requests. Header values are visible to browser users and must not contain secrets. |
|
|
120
126
|
| `suggestions_min_chars` | `int` | `1` | Minimum trimmed query length before requesting suggestions. Use `0` to allow an empty query. |
|
|
121
127
|
| `suggestions_debounce_ms` | `int` | `300` | Delay in milliseconds between the latest input and the API request. |
|
|
@@ -126,10 +132,133 @@ st.write(selected)
|
|
|
126
132
|
Option dictionaries use this shape:
|
|
127
133
|
|
|
128
134
|
```python
|
|
129
|
-
{
|
|
135
|
+
{
|
|
136
|
+
"label": "Python",
|
|
137
|
+
"value": "python",
|
|
138
|
+
"icon_url": "https://www.python.org/static/favicon.ico",
|
|
139
|
+
"color": "#3776ab",
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
`icon_url` and `color` may be omitted. The returned value is always the `value`, not the display `label`.
|
|
144
|
+
|
|
145
|
+
## Colors
|
|
146
|
+
|
|
147
|
+
Anywhere a color is accepted, pass either a CSS color string or a mapping that sets
|
|
148
|
+
any subset of `background`, `text`, and `border`:
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
"#fee2e2"
|
|
152
|
+
{"background": "#111827", "text": "#facc15", "border": "#f74c00"}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
A string sets the background. When `text` is not set, the component picks black or
|
|
156
|
+
white for readability against the resolved background.
|
|
157
|
+
|
|
158
|
+
Colors come from five sources. Each source contributes a color, and the highest
|
|
159
|
+
ranked source that sets a field wins that field, so a value color that sets only
|
|
160
|
+
`text` still inherits the background from `base_color`:
|
|
161
|
+
|
|
162
|
+
| Source | Set with | Keyed by |
|
|
163
|
+
| --- | --- | --- |
|
|
164
|
+
| `value` | `value_colors` | Option value. Follows the item as it is reordered. |
|
|
165
|
+
| `option` | `color` in an option dictionary, or `suggestions_color_path` | The option itself. |
|
|
166
|
+
| `order` | `order_colors` | Selected position. `1` is first, `-1` is last. |
|
|
167
|
+
| `palette` | `color_palette` | Selected position, cycling through the palette. |
|
|
168
|
+
| `base` | `base_color` | Every selected item. |
|
|
169
|
+
|
|
170
|
+
The default ranking is the table order. Reorder it with `color_priority`; sources you
|
|
171
|
+
leave out keep their default rank, so `color_priority=["order"]` only promotes
|
|
172
|
+
position colors above everything else.
|
|
173
|
+
|
|
174
|
+
When a positive and a negative `order_colors` key address the same slot, such as `1`
|
|
175
|
+
and `-3` in a three item list, the positive key wins. Every color must set at least
|
|
176
|
+
one field: `None` and `{}` are rejected rather than ignored, so a mistyped color
|
|
177
|
+
surfaces as an error instead of silently doing nothing.
|
|
178
|
+
|
|
179
|
+
```python
|
|
180
|
+
selected = sortable_multiselect(
|
|
181
|
+
"Podium",
|
|
182
|
+
options=[
|
|
183
|
+
{"label": "Python", "value": "python", "color": "#3776ab"},
|
|
184
|
+
{"label": "Rust", "value": "rust"},
|
|
185
|
+
{"label": "Go", "value": "go"},
|
|
186
|
+
],
|
|
187
|
+
default=["python", "rust", "go"],
|
|
188
|
+
# Gold, silver, and bronze by position, ranked above each option's own color.
|
|
189
|
+
order_colors={
|
|
190
|
+
1: {"background": "#fde68a", "border": "#f59e0b"},
|
|
191
|
+
2: {"background": "#e5e7eb", "border": "#9ca3af"},
|
|
192
|
+
-1: {"background": "#fed7aa", "border": "#ea580c"},
|
|
193
|
+
},
|
|
194
|
+
color_priority=["order"],
|
|
195
|
+
)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Options that resolve to a color show a small swatch in the options dropdown.
|
|
199
|
+
|
|
200
|
+
Because an option's `value` is its id, `value_colors` binds a color to an item rather
|
|
201
|
+
than to a slot. `examples/color_by_id.py` puts both side by side: two lists holding the
|
|
202
|
+
same items, one colored by position and one colored by id. Dragging an item in each
|
|
203
|
+
shows position colors staying with the slot while id colors travel with the item.
|
|
204
|
+
|
|
205
|
+
## Labels
|
|
206
|
+
|
|
207
|
+
Option labels in the dropdown are shown on one line and cut off with an ellipsis when
|
|
208
|
+
they do not fit. Hovering a cut-off label shows the full text in a tooltip anchored to
|
|
209
|
+
that label, and labels that fit are left without one. Selected item labels wrap onto
|
|
210
|
+
multiple lines instead of being cut off, so they only get a tooltip if surrounding
|
|
211
|
+
styles clip them.
|
|
212
|
+
|
|
213
|
+
The tooltip is drawn by the component rather than by the browser's native `title`, so
|
|
214
|
+
it is styled with the rest of the component, appears after a short delay instead of
|
|
215
|
+
about a second, and flips above or below the label to stay inside the component frame.
|
|
216
|
+
It disappears as soon as the pointer leaves, the list scrolls, or the row it points at
|
|
217
|
+
changes. Screen readers are unaffected either way: a clipped label is cut off visually
|
|
218
|
+
but its full text is always in the DOM.
|
|
219
|
+
|
|
220
|
+
`tooltip_color` restyles it, using the same color form as everything above. A string
|
|
221
|
+
sets the background and the text follows for contrast; a mapping may also set `text`
|
|
222
|
+
and `border`. Because the component renders inside an iframe, this argument is the only
|
|
223
|
+
way to change the tooltip: styles from the surrounding app cannot reach it.
|
|
224
|
+
|
|
225
|
+
```python
|
|
226
|
+
tooltip_color="#1e3a8a" # white text follows
|
|
227
|
+
tooltip_color={"background": "#ffffff", "text": "#111827", "border": "#d1d5db"}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
A light tooltip needs a `border` to separate it from the content behind it. The arrow
|
|
231
|
+
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,
|
|
234
|
+
so the conditional behavior is visible side by side.
|
|
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
|
+
)
|
|
130
256
|
```
|
|
131
257
|
|
|
132
|
-
|
|
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`.
|
|
133
262
|
|
|
134
263
|
## API Suggestions
|
|
135
264
|
|
|
@@ -190,6 +319,8 @@ Run the example app:
|
|
|
190
319
|
|
|
191
320
|
```bash
|
|
192
321
|
streamlit run examples/basic.py
|
|
322
|
+
streamlit run examples/color_by_id.py
|
|
323
|
+
streamlit run examples/tooltip_labels.py
|
|
193
324
|
streamlit run examples/api_suggestions.py
|
|
194
325
|
```
|
|
195
326
|
|
|
@@ -73,10 +73,15 @@ st.write(selected)
|
|
|
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`. |
|
|
75
75
|
| `show_numbers` | `bool` | `False` | Shows 1-based position numbers before selected item labels. |
|
|
76
|
-
| `base_color` | `str \| None` | `None` |
|
|
77
|
-
| `order_colors` | `Mapping[int, str] \| None` | `None` | Per-position
|
|
76
|
+
| `base_color` | `str \| Mapping[str, str] \| None` | `None` | Fallback color for every selected item. See [Colors](#colors). |
|
|
77
|
+
| `order_colors` | `Mapping[int, str \| Mapping[str, str]] \| None` | `None` | Per-position colors. Positive keys count from the top (`1` is first), negative keys count from the bottom (`-1` is last), for example `{1: "#fee2e2", -1: "#dcfce7"}`. |
|
|
78
|
+
| `value_colors` | `Mapping[str, str \| Mapping[str, str]] \| None` | `None` | Per-value colors keyed by option value, for example `{"python": "#3776ab"}`. These follow an item as it is reordered. |
|
|
79
|
+
| `color_palette` | `Sequence[str \| Mapping[str, str]] \| None` | `None` | Colors cycled across selected positions. Position 1 uses the first entry and the palette repeats for longer selections. |
|
|
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
|
+
| `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). |
|
|
78
82
|
| `max_selections` | `int \| None` | `None` | Maximum number of selected items. `None` means no limit. Use `0` to prevent any selections. |
|
|
79
|
-
| `
|
|
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. |
|
|
80
85
|
| `empty_message` | `str` | `"No items selected"` | Message shown where the selected list appears when no items are selected. |
|
|
81
86
|
| `no_options_placeholder` | `str` | `"No more options"` | Placeholder shown when every option is already selected and there are no more options to add. |
|
|
82
87
|
| `selected_position` | `str` | `"bottom"` | Position of the selected item list relative to the search/add input. Use `"bottom"` or `"top"`. |
|
|
@@ -88,6 +93,7 @@ st.write(selected)
|
|
|
88
93
|
| `suggestions_label_path` | `str` | `"label"` | Dot-separated path to each suggestion's display label. |
|
|
89
94
|
| `suggestions_value_path` | `str` | `"value"` | Dot-separated path to each suggestion's returned value. |
|
|
90
95
|
| `suggestions_icon_url_path` | `str \| None` | `"icon_url"` | Optional dot-separated path to each suggestion's icon URL. `None` disables API icons. |
|
|
96
|
+
| `suggestions_color_path` | `str \| None` | `None` | Optional dot-separated path to each suggestion's color. The value may be a CSS color string or a mapping of color fields. `None` disables API colors. |
|
|
91
97
|
| `suggestions_headers` | `Mapping[str, str] \| None` | `None` | HTTP headers sent with suggestions requests. Header values are visible to browser users and must not contain secrets. |
|
|
92
98
|
| `suggestions_min_chars` | `int` | `1` | Minimum trimmed query length before requesting suggestions. Use `0` to allow an empty query. |
|
|
93
99
|
| `suggestions_debounce_ms` | `int` | `300` | Delay in milliseconds between the latest input and the API request. |
|
|
@@ -98,10 +104,133 @@ st.write(selected)
|
|
|
98
104
|
Option dictionaries use this shape:
|
|
99
105
|
|
|
100
106
|
```python
|
|
101
|
-
{
|
|
107
|
+
{
|
|
108
|
+
"label": "Python",
|
|
109
|
+
"value": "python",
|
|
110
|
+
"icon_url": "https://www.python.org/static/favicon.ico",
|
|
111
|
+
"color": "#3776ab",
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
`icon_url` and `color` may be omitted. The returned value is always the `value`, not the display `label`.
|
|
116
|
+
|
|
117
|
+
## Colors
|
|
118
|
+
|
|
119
|
+
Anywhere a color is accepted, pass either a CSS color string or a mapping that sets
|
|
120
|
+
any subset of `background`, `text`, and `border`:
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
"#fee2e2"
|
|
124
|
+
{"background": "#111827", "text": "#facc15", "border": "#f74c00"}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
A string sets the background. When `text` is not set, the component picks black or
|
|
128
|
+
white for readability against the resolved background.
|
|
129
|
+
|
|
130
|
+
Colors come from five sources. Each source contributes a color, and the highest
|
|
131
|
+
ranked source that sets a field wins that field, so a value color that sets only
|
|
132
|
+
`text` still inherits the background from `base_color`:
|
|
133
|
+
|
|
134
|
+
| Source | Set with | Keyed by |
|
|
135
|
+
| --- | --- | --- |
|
|
136
|
+
| `value` | `value_colors` | Option value. Follows the item as it is reordered. |
|
|
137
|
+
| `option` | `color` in an option dictionary, or `suggestions_color_path` | The option itself. |
|
|
138
|
+
| `order` | `order_colors` | Selected position. `1` is first, `-1` is last. |
|
|
139
|
+
| `palette` | `color_palette` | Selected position, cycling through the palette. |
|
|
140
|
+
| `base` | `base_color` | Every selected item. |
|
|
141
|
+
|
|
142
|
+
The default ranking is the table order. Reorder it with `color_priority`; sources you
|
|
143
|
+
leave out keep their default rank, so `color_priority=["order"]` only promotes
|
|
144
|
+
position colors above everything else.
|
|
145
|
+
|
|
146
|
+
When a positive and a negative `order_colors` key address the same slot, such as `1`
|
|
147
|
+
and `-3` in a three item list, the positive key wins. Every color must set at least
|
|
148
|
+
one field: `None` and `{}` are rejected rather than ignored, so a mistyped color
|
|
149
|
+
surfaces as an error instead of silently doing nothing.
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
selected = sortable_multiselect(
|
|
153
|
+
"Podium",
|
|
154
|
+
options=[
|
|
155
|
+
{"label": "Python", "value": "python", "color": "#3776ab"},
|
|
156
|
+
{"label": "Rust", "value": "rust"},
|
|
157
|
+
{"label": "Go", "value": "go"},
|
|
158
|
+
],
|
|
159
|
+
default=["python", "rust", "go"],
|
|
160
|
+
# Gold, silver, and bronze by position, ranked above each option's own color.
|
|
161
|
+
order_colors={
|
|
162
|
+
1: {"background": "#fde68a", "border": "#f59e0b"},
|
|
163
|
+
2: {"background": "#e5e7eb", "border": "#9ca3af"},
|
|
164
|
+
-1: {"background": "#fed7aa", "border": "#ea580c"},
|
|
165
|
+
},
|
|
166
|
+
color_priority=["order"],
|
|
167
|
+
)
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Options that resolve to a color show a small swatch in the options dropdown.
|
|
171
|
+
|
|
172
|
+
Because an option's `value` is its id, `value_colors` binds a color to an item rather
|
|
173
|
+
than to a slot. `examples/color_by_id.py` puts both side by side: two lists holding the
|
|
174
|
+
same items, one colored by position and one colored by id. Dragging an item in each
|
|
175
|
+
shows position colors staying with the slot while id colors travel with the item.
|
|
176
|
+
|
|
177
|
+
## Labels
|
|
178
|
+
|
|
179
|
+
Option labels in the dropdown are shown on one line and cut off with an ellipsis when
|
|
180
|
+
they do not fit. Hovering a cut-off label shows the full text in a tooltip anchored to
|
|
181
|
+
that label, and labels that fit are left without one. Selected item labels wrap onto
|
|
182
|
+
multiple lines instead of being cut off, so they only get a tooltip if surrounding
|
|
183
|
+
styles clip them.
|
|
184
|
+
|
|
185
|
+
The tooltip is drawn by the component rather than by the browser's native `title`, so
|
|
186
|
+
it is styled with the rest of the component, appears after a short delay instead of
|
|
187
|
+
about a second, and flips above or below the label to stay inside the component frame.
|
|
188
|
+
It disappears as soon as the pointer leaves, the list scrolls, or the row it points at
|
|
189
|
+
changes. Screen readers are unaffected either way: a clipped label is cut off visually
|
|
190
|
+
but its full text is always in the DOM.
|
|
191
|
+
|
|
192
|
+
`tooltip_color` restyles it, using the same color form as everything above. A string
|
|
193
|
+
sets the background and the text follows for contrast; a mapping may also set `text`
|
|
194
|
+
and `border`. Because the component renders inside an iframe, this argument is the only
|
|
195
|
+
way to change the tooltip: styles from the surrounding app cannot reach it.
|
|
196
|
+
|
|
197
|
+
```python
|
|
198
|
+
tooltip_color="#1e3a8a" # white text follows
|
|
199
|
+
tooltip_color={"background": "#ffffff", "text": "#111827", "border": "#d1d5db"}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
A light tooltip needs a `border` to separate it from the content behind it. The arrow
|
|
203
|
+
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,
|
|
206
|
+
so the conditional behavior is visible side by side.
|
|
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
|
+
)
|
|
102
228
|
```
|
|
103
229
|
|
|
104
|
-
|
|
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`.
|
|
105
234
|
|
|
106
235
|
## API Suggestions
|
|
107
236
|
|
|
@@ -162,6 +291,8 @@ Run the example app:
|
|
|
162
291
|
|
|
163
292
|
```bash
|
|
164
293
|
streamlit run examples/basic.py
|
|
294
|
+
streamlit run examples/color_by_id.py
|
|
295
|
+
streamlit run examples/tooltip_labels.py
|
|
165
296
|
streamlit run examples/api_suggestions.py
|
|
166
297
|
```
|
|
167
298
|
|
{streamlit_sortable_multiselect-0.7.5 → streamlit_sortable_multiselect-0.7.7}/pyproject.toml
RENAMED
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "streamlit-sortable-multiselect"
|
|
7
|
-
version = "0.7.
|
|
7
|
+
version = "0.7.7"
|
|
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"
|