streamlit-nightly 1.37.2.dev20240825__py2.py3-none-any.whl → 1.38.1.dev20240827__py2.py3-none-any.whl
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/commands/logo.py +21 -0
- streamlit/elements/form.py +20 -0
- streamlit/elements/widgets/button.py +25 -1
- streamlit/proto/DownloadButton_pb2.py +2 -2
- streamlit/proto/DownloadButton_pb2.pyi +4 -1
- streamlit/proto/Logo_pb2.py +2 -2
- streamlit/proto/Logo_pb2.pyi +4 -1
- streamlit/static/asset-manifest.json +6 -6
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/{1074.9d1e63cc.chunk.js → 1074.034b60a3.chunk.js} +1 -1
- streamlit/static/static/js/{2736.3d50ec7f.chunk.js → 2736.b4e8b86f.chunk.js} +2 -2
- streamlit/static/static/js/3301.1b5f076e.chunk.js +17 -0
- streamlit/static/static/js/3513.dc55835d.chunk.js +1 -0
- streamlit/static/static/js/{main.771fbdca.js → main.9cb0a6dc.js} +5 -5
- {streamlit_nightly-1.37.2.dev20240825.dist-info → streamlit_nightly-1.38.1.dev20240827.dist-info}/METADATA +2 -2
- {streamlit_nightly-1.37.2.dev20240825.dist-info → streamlit_nightly-1.38.1.dev20240827.dist-info}/RECORD +21 -21
- {streamlit_nightly-1.37.2.dev20240825.dist-info → streamlit_nightly-1.38.1.dev20240827.dist-info}/WHEEL +1 -1
- streamlit/static/static/js/3301.7379a9fd.chunk.js +0 -17
- streamlit/static/static/js/3513.5e3a04f2.chunk.js +0 -1
- /streamlit/static/static/js/{main.771fbdca.js.LICENSE.txt → main.9cb0a6dc.js.LICENSE.txt} +0 -0
- {streamlit_nightly-1.37.2.dev20240825.data → streamlit_nightly-1.38.1.dev20240827.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.37.2.dev20240825.dist-info → streamlit_nightly-1.38.1.dev20240827.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.37.2.dev20240825.dist-info → streamlit_nightly-1.38.1.dev20240827.dist-info}/top_level.txt +0 -0
streamlit/commands/logo.py
CHANGED
@@ -16,6 +16,8 @@
|
|
16
16
|
|
17
17
|
from __future__ import annotations
|
18
18
|
|
19
|
+
from typing import Literal
|
20
|
+
|
19
21
|
from streamlit import url_util
|
20
22
|
from streamlit.elements.image import AtomicImage, WidthBehaviour, image_to_url
|
21
23
|
from streamlit.errors import StreamlitAPIException
|
@@ -32,6 +34,7 @@ def _invalid_logo_text(field_name: str):
|
|
32
34
|
def logo(
|
33
35
|
image: AtomicImage,
|
34
36
|
*, # keyword-only args:
|
37
|
+
size: Literal["small", "medium", "large"] = "medium",
|
35
38
|
link: str | None = None,
|
36
39
|
icon_image: AtomicImage | None = None,
|
37
40
|
) -> None:
|
@@ -58,6 +61,9 @@ def logo(
|
|
58
61
|
Streamlit scales the image to a height of 24 pixels and a maximum
|
59
62
|
width of 240 pixels. Use images with an aspect ratio of 10:1 or less to
|
60
63
|
avoid distortion.
|
64
|
+
size: "small", "medium", or "large"
|
65
|
+
The size of the image displayed in the upper-left corner of the app and its
|
66
|
+
sidebar. The default is ``"medium"``.
|
61
67
|
link : str or None
|
62
68
|
The external URL to open when a user clicks on the logo. The URL must
|
63
69
|
start with "\\http://" or "\\https://". If ``link`` is ``None`` (default),
|
@@ -151,4 +157,19 @@ def logo(
|
|
151
157
|
except Exception as ex:
|
152
158
|
raise StreamlitAPIException(_invalid_logo_text("icon_image")) from ex
|
153
159
|
|
160
|
+
def validate_size(size):
|
161
|
+
if isinstance(size, str):
|
162
|
+
image_size = size.lower()
|
163
|
+
valid_sizes = ["small", "medium", "large"]
|
164
|
+
|
165
|
+
if image_size in valid_sizes:
|
166
|
+
return image_size
|
167
|
+
|
168
|
+
raise StreamlitAPIException(
|
169
|
+
f'The size argument to st.logo must be "small", "medium", or "large". \n'
|
170
|
+
f"The argument passed was {size}."
|
171
|
+
)
|
172
|
+
|
173
|
+
fwd_msg.logo.size = validate_size(size)
|
174
|
+
|
154
175
|
ctx.enqueue(fwd_msg)
|
streamlit/elements/form.py
CHANGED
@@ -177,6 +177,7 @@ class FormMixin:
|
|
177
177
|
kwargs: WidgetKwargs | None = None,
|
178
178
|
*, # keyword-only arguments:
|
179
179
|
type: Literal["primary", "secondary"] = "secondary",
|
180
|
+
icon: str | None = None,
|
180
181
|
disabled: bool = False,
|
181
182
|
use_container_width: bool = False,
|
182
183
|
) -> bool:
|
@@ -209,6 +210,22 @@ class FormMixin:
|
|
209
210
|
An optional string that specifies the button type. Can be "primary" for a
|
210
211
|
button with additional emphasis or "secondary" for a normal button. Defaults
|
211
212
|
to "secondary".
|
213
|
+
icon : str or None
|
214
|
+
An optional emoji or icon to display next to the button label. If ``icon``
|
215
|
+
is ``None`` (default), no icon is displayed. If ``icon`` is a
|
216
|
+
string, the following options are valid:
|
217
|
+
|
218
|
+
* A single-character emoji. For example, you can set ``icon="🚨"``
|
219
|
+
or ``icon="🔥"``. Emoji short codes are not supported.
|
220
|
+
|
221
|
+
* An icon from the Material Symbols library (rounded style) in the
|
222
|
+
format ``":material/icon_name:"`` where "icon_name" is the name
|
223
|
+
of the icon in snake case.
|
224
|
+
|
225
|
+
For example, ``icon=":material/thumb_up:"`` will display the
|
226
|
+
Thumb Up icon. Find additional icons in the `Material Symbols \
|
227
|
+
<https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
|
228
|
+
font library.
|
212
229
|
disabled : bool
|
213
230
|
An optional boolean, which disables the button if set to True. The
|
214
231
|
default is False.
|
@@ -243,6 +260,7 @@ class FormMixin:
|
|
243
260
|
args=args,
|
244
261
|
kwargs=kwargs,
|
245
262
|
type=type,
|
263
|
+
icon=icon,
|
246
264
|
disabled=disabled,
|
247
265
|
use_container_width=use_container_width,
|
248
266
|
ctx=ctx,
|
@@ -257,6 +275,7 @@ class FormMixin:
|
|
257
275
|
kwargs: WidgetKwargs | None = None,
|
258
276
|
*, # keyword-only arguments:
|
259
277
|
type: Literal["primary", "secondary"] = "secondary",
|
278
|
+
icon: str | None = None,
|
260
279
|
disabled: bool = False,
|
261
280
|
use_container_width: bool = False,
|
262
281
|
ctx: ScriptRunContext | None = None,
|
@@ -272,6 +291,7 @@ class FormMixin:
|
|
272
291
|
args=args,
|
273
292
|
kwargs=kwargs,
|
274
293
|
type=type,
|
294
|
+
icon=icon,
|
275
295
|
disabled=disabled,
|
276
296
|
use_container_width=use_container_width,
|
277
297
|
ctx=ctx,
|
@@ -225,6 +225,7 @@ class ButtonMixin:
|
|
225
225
|
kwargs: WidgetKwargs | None = None,
|
226
226
|
*, # keyword-only arguments:
|
227
227
|
type: Literal["primary", "secondary"] = "secondary",
|
228
|
+
icon: str | None = None,
|
228
229
|
disabled: bool = False,
|
229
230
|
use_container_width: bool = False,
|
230
231
|
) -> bool:
|
@@ -299,6 +300,23 @@ class ButtonMixin:
|
|
299
300
|
button with additional emphasis or "secondary" for a normal button. Defaults
|
300
301
|
to "secondary".
|
301
302
|
|
303
|
+
icon : str or None
|
304
|
+
An optional emoji or icon to display next to the button label. If ``icon``
|
305
|
+
is ``None`` (default), no icon is displayed. If ``icon`` is a
|
306
|
+
string, the following options are valid:
|
307
|
+
|
308
|
+
* A single-character emoji. For example, you can set ``icon="🚨"``
|
309
|
+
or ``icon="🔥"``. Emoji short codes are not supported.
|
310
|
+
|
311
|
+
* An icon from the Material Symbols library (rounded style) in the
|
312
|
+
format ``":material/icon_name:"`` where "icon_name" is the name
|
313
|
+
of the icon in snake case.
|
314
|
+
|
315
|
+
For example, ``icon=":material/thumb_up:"`` will display the
|
316
|
+
Thumb Up icon. Find additional icons in the `Material Symbols \
|
317
|
+
<https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
|
318
|
+
font library.
|
319
|
+
|
302
320
|
disabled : bool
|
303
321
|
An optional boolean, which disables the download button if set to
|
304
322
|
True. The default is False.
|
@@ -388,8 +406,9 @@ class ButtonMixin:
|
|
388
406
|
on_click=on_click,
|
389
407
|
args=args,
|
390
408
|
kwargs=kwargs,
|
391
|
-
disabled=disabled,
|
392
409
|
type=type,
|
410
|
+
icon=icon,
|
411
|
+
disabled=disabled,
|
393
412
|
use_container_width=use_container_width,
|
394
413
|
ctx=ctx,
|
395
414
|
)
|
@@ -609,6 +628,7 @@ class ButtonMixin:
|
|
609
628
|
kwargs: WidgetKwargs | None = None,
|
610
629
|
*, # keyword-only arguments:
|
611
630
|
type: Literal["primary", "secondary"] = "secondary",
|
631
|
+
icon: str | None = None,
|
612
632
|
disabled: bool = False,
|
613
633
|
use_container_width: bool = False,
|
614
634
|
ctx: ScriptRunContext | None = None,
|
@@ -627,6 +647,7 @@ class ButtonMixin:
|
|
627
647
|
"download_button",
|
628
648
|
user_key=key,
|
629
649
|
label=label,
|
650
|
+
icon=icon,
|
630
651
|
file_name=file_name,
|
631
652
|
mime=mime,
|
632
653
|
key=key,
|
@@ -655,6 +676,9 @@ class ButtonMixin:
|
|
655
676
|
if help is not None:
|
656
677
|
download_button_proto.help = dedent(help)
|
657
678
|
|
679
|
+
if icon is not None:
|
680
|
+
download_button_proto.icon = validate_icon_or_emoji(icon)
|
681
|
+
|
658
682
|
serde = ButtonSerde()
|
659
683
|
|
660
684
|
button_state = register_widget(
|
@@ -14,7 +14,7 @@ _sym_db = _symbol_database.Default()
|
|
14
14
|
|
15
15
|
|
16
16
|
|
17
|
-
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n$streamlit/proto/DownloadButton.proto\"\
|
17
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n$streamlit/proto/DownloadButton.proto\"\xb3\x01\n\x0e\x44ownloadButton\x12\n\n\x02id\x18\x01 \x01(\t\x12\r\n\x05label\x18\x02 \x01(\t\x12\x0f\n\x07\x64\x65\x66\x61ult\x18\x03 \x01(\x08\x12\x0c\n\x04help\x18\x04 \x01(\t\x12\x0f\n\x07\x66orm_id\x18\x05 \x01(\t\x12\x0b\n\x03url\x18\x06 \x01(\t\x12\x10\n\x08\x64isabled\x18\x07 \x01(\x08\x12\x1b\n\x13use_container_width\x18\x08 \x01(\x08\x12\x0c\n\x04type\x18\t \x01(\t\x12\x0c\n\x04icon\x18\n \x01(\tB3\n\x1c\x63om.snowflake.apps.streamlitB\x13\x44ownloadButtonProtob\x06proto3')
|
18
18
|
|
19
19
|
_globals = globals()
|
20
20
|
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
@@ -23,5 +23,5 @@ if not _descriptor._USE_C_DESCRIPTORS:
|
|
23
23
|
_globals['DESCRIPTOR']._loaded_options = None
|
24
24
|
_globals['DESCRIPTOR']._serialized_options = b'\n\034com.snowflake.apps.streamlitB\023DownloadButtonProto'
|
25
25
|
_globals['_DOWNLOADBUTTON']._serialized_start=41
|
26
|
-
_globals['_DOWNLOADBUTTON']._serialized_end=
|
26
|
+
_globals['_DOWNLOADBUTTON']._serialized_end=220
|
27
27
|
# @@protoc_insertion_point(module_scope)
|
@@ -37,6 +37,7 @@ class DownloadButton(google.protobuf.message.Message):
|
|
37
37
|
DISABLED_FIELD_NUMBER: builtins.int
|
38
38
|
USE_CONTAINER_WIDTH_FIELD_NUMBER: builtins.int
|
39
39
|
TYPE_FIELD_NUMBER: builtins.int
|
40
|
+
ICON_FIELD_NUMBER: builtins.int
|
40
41
|
id: builtins.str
|
41
42
|
label: builtins.str
|
42
43
|
default: builtins.bool
|
@@ -46,6 +47,7 @@ class DownloadButton(google.protobuf.message.Message):
|
|
46
47
|
disabled: builtins.bool
|
47
48
|
use_container_width: builtins.bool
|
48
49
|
type: builtins.str
|
50
|
+
icon: builtins.str
|
49
51
|
def __init__(
|
50
52
|
self,
|
51
53
|
*,
|
@@ -58,7 +60,8 @@ class DownloadButton(google.protobuf.message.Message):
|
|
58
60
|
disabled: builtins.bool = ...,
|
59
61
|
use_container_width: builtins.bool = ...,
|
60
62
|
type: builtins.str = ...,
|
63
|
+
icon: builtins.str = ...,
|
61
64
|
) -> None: ...
|
62
|
-
def ClearField(self, field_name: typing.Literal["default", b"default", "disabled", b"disabled", "form_id", b"form_id", "help", b"help", "id", b"id", "label", b"label", "type", b"type", "url", b"url", "use_container_width", b"use_container_width"]) -> None: ...
|
65
|
+
def ClearField(self, field_name: typing.Literal["default", b"default", "disabled", b"disabled", "form_id", b"form_id", "help", b"help", "icon", b"icon", "id", b"id", "label", b"label", "type", b"type", "url", b"url", "use_container_width", b"use_container_width"]) -> None: ...
|
63
66
|
|
64
67
|
global___DownloadButton = DownloadButton
|
streamlit/proto/Logo_pb2.py
CHANGED
@@ -14,7 +14,7 @@ _sym_db = _symbol_database.Default()
|
|
14
14
|
|
15
15
|
|
16
16
|
|
17
|
-
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1astreamlit/proto/Logo.proto\"
|
17
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1astreamlit/proto/Logo.proto\"E\n\x04Logo\x12\r\n\x05image\x18\x01 \x01(\t\x12\x0c\n\x04link\x18\x02 \x01(\t\x12\x12\n\nicon_image\x18\x03 \x01(\t\x12\x0c\n\x04size\x18\x04 \x01(\tB)\n\x1c\x63om.snowflake.apps.streamlitB\tLogoProtob\x06proto3')
|
18
18
|
|
19
19
|
_globals = globals()
|
20
20
|
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
@@ -23,5 +23,5 @@ if not _descriptor._USE_C_DESCRIPTORS:
|
|
23
23
|
_globals['DESCRIPTOR']._loaded_options = None
|
24
24
|
_globals['DESCRIPTOR']._serialized_options = b'\n\034com.snowflake.apps.streamlitB\tLogoProto'
|
25
25
|
_globals['_LOGO']._serialized_start=30
|
26
|
-
_globals['_LOGO']._serialized_end=
|
26
|
+
_globals['_LOGO']._serialized_end=99
|
27
27
|
# @@protoc_insertion_point(module_scope)
|
streamlit/proto/Logo_pb2.pyi
CHANGED
@@ -33,16 +33,19 @@ class Logo(google.protobuf.message.Message):
|
|
33
33
|
IMAGE_FIELD_NUMBER: builtins.int
|
34
34
|
LINK_FIELD_NUMBER: builtins.int
|
35
35
|
ICON_IMAGE_FIELD_NUMBER: builtins.int
|
36
|
+
SIZE_FIELD_NUMBER: builtins.int
|
36
37
|
image: builtins.str
|
37
38
|
link: builtins.str
|
38
39
|
icon_image: builtins.str
|
40
|
+
size: builtins.str
|
39
41
|
def __init__(
|
40
42
|
self,
|
41
43
|
*,
|
42
44
|
image: builtins.str = ...,
|
43
45
|
link: builtins.str = ...,
|
44
46
|
icon_image: builtins.str = ...,
|
47
|
+
size: builtins.str = ...,
|
45
48
|
) -> None: ...
|
46
|
-
def ClearField(self, field_name: typing.Literal["icon_image", b"icon_image", "image", b"image", "link", b"link"]) -> None: ...
|
49
|
+
def ClearField(self, field_name: typing.Literal["icon_image", b"icon_image", "image", b"image", "link", b"link", "size", b"size"]) -> None: ...
|
47
50
|
|
48
51
|
global___Logo = Logo
|
@@ -1,11 +1,11 @@
|
|
1
1
|
{
|
2
2
|
"files": {
|
3
3
|
"main.css": "./static/css/main.5513bd04.css",
|
4
|
-
"main.js": "./static/js/main.
|
4
|
+
"main.js": "./static/js/main.9cb0a6dc.js",
|
5
5
|
"static/js/9336.3e046ad7.chunk.js": "./static/js/9336.3e046ad7.chunk.js",
|
6
6
|
"static/js/9330.32e8a53a.chunk.js": "./static/js/9330.32e8a53a.chunk.js",
|
7
|
-
"static/js/2736.
|
8
|
-
"static/js/3301.
|
7
|
+
"static/js/2736.b4e8b86f.chunk.js": "./static/js/2736.b4e8b86f.chunk.js",
|
8
|
+
"static/js/3301.1b5f076e.chunk.js": "./static/js/3301.1b5f076e.chunk.js",
|
9
9
|
"static/css/8148.93909c7e.chunk.css": "./static/css/8148.93909c7e.chunk.css",
|
10
10
|
"static/js/8148.8bd2f9d3.chunk.js": "./static/js/8148.8bd2f9d3.chunk.js",
|
11
11
|
"static/css/5441.c24b25fa.chunk.css": "./static/css/5441.c24b25fa.chunk.css",
|
@@ -22,14 +22,14 @@
|
|
22
22
|
"static/js/178.ddebe26b.chunk.js": "./static/js/178.ddebe26b.chunk.js",
|
23
23
|
"static/js/1792.61097259.chunk.js": "./static/js/1792.61097259.chunk.js",
|
24
24
|
"static/js/1116.85ec79d5.chunk.js": "./static/js/1116.85ec79d5.chunk.js",
|
25
|
-
"static/js/3513.
|
25
|
+
"static/js/3513.dc55835d.chunk.js": "./static/js/3513.dc55835d.chunk.js",
|
26
26
|
"static/js/7602.a6e1d802.chunk.js": "./static/js/7602.a6e1d802.chunk.js",
|
27
27
|
"static/js/6013.b6375a8d.chunk.js": "./static/js/6013.b6375a8d.chunk.js",
|
28
28
|
"static/js/4335.b166a7b6.chunk.js": "./static/js/4335.b166a7b6.chunk.js",
|
29
29
|
"static/js/4177.e5631c43.chunk.js": "./static/js/4177.e5631c43.chunk.js",
|
30
30
|
"static/js/1451.7ff31fc7.chunk.js": "./static/js/1451.7ff31fc7.chunk.js",
|
31
31
|
"static/js/2634.4e2535ee.chunk.js": "./static/js/2634.4e2535ee.chunk.js",
|
32
|
-
"static/js/1074.
|
32
|
+
"static/js/1074.034b60a3.chunk.js": "./static/js/1074.034b60a3.chunk.js",
|
33
33
|
"static/js/8477.90b06bd9.chunk.js": "./static/js/8477.90b06bd9.chunk.js",
|
34
34
|
"static/js/6853.a1c4fa00.chunk.js": "./static/js/6853.a1c4fa00.chunk.js",
|
35
35
|
"static/js/4477.568118b6.chunk.js": "./static/js/4477.568118b6.chunk.js",
|
@@ -153,6 +153,6 @@
|
|
153
153
|
},
|
154
154
|
"entrypoints": [
|
155
155
|
"static/css/main.5513bd04.css",
|
156
|
-
"static/js/main.
|
156
|
+
"static/js/main.9cb0a6dc.js"
|
157
157
|
]
|
158
158
|
}
|
streamlit/static/index.html
CHANGED
@@ -1 +1 @@
|
|
1
|
-
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><link rel="shortcut icon" href="./favicon.png"/><link rel="preload" href="./static/media/SourceSansPro-Regular.0d69e5ff5e92ac64a0c9.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-SemiBold.abed79cd0df1827e18cf.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-Bold.118dea98980e20a81ced.woff2" as="font" type="font/woff2" crossorigin><title>Streamlit</title><script>window.prerenderReady=!1</script><script defer="defer" src="./static/js/main.
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><link rel="shortcut icon" href="./favicon.png"/><link rel="preload" href="./static/media/SourceSansPro-Regular.0d69e5ff5e92ac64a0c9.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-SemiBold.abed79cd0df1827e18cf.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-Bold.118dea98980e20a81ced.woff2" as="font" type="font/woff2" crossorigin><title>Streamlit</title><script>window.prerenderReady=!1</script><script defer="defer" src="./static/js/main.9cb0a6dc.js"></script><link href="./static/css/main.5513bd04.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";(self.webpackChunk_streamlit_app=self.webpackChunk_streamlit_app||[]).push([[1074],{87814:(e,t,s)=>{s.d(t,{K:()=>o});var i=s(50641);class o{constructor(){this.formClearListener=void 0,this.lastWidgetMgr=void 0,this.lastFormId=void 0}manageFormClearListener(e,t,s){(0,i.bb)(this.formClearListener)&&this.lastWidgetMgr===e&&this.lastFormId===t||(this.disconnect(),(0,i.bM)(t)&&(this.formClearListener=e.addFormClearedListener(t,s),this.lastWidgetMgr=e,this.lastFormId=t))}disconnect(){var e;null===(e=this.formClearListener)||void 0===e||e.disconnect(),this.formClearListener=void 0,this.lastWidgetMgr=void 0,this.lastFormId=void 0}}},91074:(e,t,s)=>{s.r(t),s.d(t,{default:()=>
|
1
|
+
"use strict";(self.webpackChunk_streamlit_app=self.webpackChunk_streamlit_app||[]).push([[1074],{87814:(e,t,s)=>{s.d(t,{K:()=>o});var i=s(50641);class o{constructor(){this.formClearListener=void 0,this.lastWidgetMgr=void 0,this.lastFormId=void 0}manageFormClearListener(e,t,s){(0,i.bb)(this.formClearListener)&&this.lastWidgetMgr===e&&this.lastFormId===t||(this.disconnect(),(0,i.bM)(t)&&(this.formClearListener=e.addFormClearedListener(t,s),this.lastWidgetMgr=e,this.lastFormId=t))}disconnect(){var e;null===(e=this.formClearListener)||void 0===e||e.disconnect(),this.formClearListener=void 0,this.lastWidgetMgr=void 0,this.lastFormId=void 0}}},91074:(e,t,s)=>{s.r(t),s.d(t,{default:()=>C});var i=s(66845),o=s(91706),r=s(81810),l=s.n(r),a=s(25621),n=s(90481),d=s(91034),h=s(12576),p=s(87814),c=s(98478),m=s(86659);const u=(0,s(1515).Z)("div",{target:"e6zijwc0"})((e=>{let{theme:t}=e;return{"span[aria-disabled='true']":{background:t.colors.fadedText05}}}),"");var g=s(8879),v=s(68411),f=s(7978),b=s(97965),S=s(50641),y=s(40864);class x extends i.PureComponent{constructor(){super(...arguments),this.formClearHelper=new p.K,this.state={value:this.initialValue},this.commitWidgetValue=e=>{const{widgetMgr:t,element:s,fragmentId:i}=this.props;t.setIntArrayValue(s,this.state.value,e,i)},this.onFormCleared=()=>{this.setState(((e,t)=>({value:t.element.default})),(()=>this.commitWidgetValue({fromUi:!0})))},this.onChange=e=>{this.props.element.maxSelections&&"select"===e.type&&this.state.value.length>=this.props.element.maxSelections||this.setState(this.generateNewState(e),(()=>{this.commitWidgetValue({fromUi:!0})}))},this.filterOptions=(e,t)=>{if(this.overMaxSelections())return[];const s=e.filter((e=>!this.state.value.includes(Number(e.value))));return(0,b.HX)(s,t)}}overMaxSelections(){return this.props.element.maxSelections>0&&this.state.value.length>=this.props.element.maxSelections}getNoResultsMsg(){const{maxSelections:e}=this.props.element,{value:t}=this.state;if(0===e)return"No results";if(t.length===e){return`You can only select up to ${e} ${1!==e?"options":"option"}. Remove an option first.`}return"No results"}get initialValue(){const e=this.props.widgetMgr.getIntArrayValue(this.props.element);return void 0!==e?e:this.props.element.default}componentDidMount(){this.props.element.setValue?this.updateFromProtobuf():this.commitWidgetValue({fromUi:!1})}componentDidUpdate(){this.maybeUpdateFromProtobuf()}componentWillUnmount(){this.formClearHelper.disconnect()}maybeUpdateFromProtobuf(){const{setValue:e}=this.props.element;e&&this.updateFromProtobuf()}updateFromProtobuf(){const{value:e}=this.props.element;this.props.element.setValue=!1,this.setState({value:e},(()=>{this.commitWidgetValue({fromUi:!1})}))}get valueFromState(){return this.state.value.map((e=>{const t=this.props.element.options[e];return{value:e.toString(),label:t}}))}generateNewState(e){const t=()=>{var t;const s=null===(t=e.option)||void 0===t?void 0:t.value;return parseInt(s,10)};switch(e.type){case"remove":return{value:l()(this.state.value,t())};case"clear":return{value:[]};case"select":return{value:this.state.value.concat([t()])};default:throw new Error(`State transition is unknown: ${e.type}`)}}render(){var e;const{element:t,theme:s,width:i,widgetMgr:r}=this.props,l={width:i},{options:a}=t,p=0===a.length||this.props.disabled,b=0===a.length?"No options to select.":t.placeholder,x=a.map(((e,t)=>({label:e,value:t.toString()})));this.formClearHelper.manageFormClearListener(r,t.formId,this.onFormCleared);const C=a.length>10;return(0,y.jsxs)("div",{className:"stMultiSelect","data-testid":"stMultiSelect",style:l,children:[(0,y.jsx)(c.O,{label:t.label,disabled:p,labelVisibility:(0,S.iF)(null===(e=t.labelVisibility)||void 0===e?void 0:e.value),children:t.help&&(0,y.jsx)(m.dT,{children:(0,y.jsx)(g.Z,{content:t.help,placement:v.u.TOP_RIGHT})})}),(0,y.jsx)(u,{children:(0,y.jsx)(d.Z,{options:x,labelKey:"label",valueKey:"value","aria-label":t.label,placeholder:b,type:h.wD.select,multi:!0,onChange:this.onChange,value:this.valueFromState,disabled:p,size:"compact",noResultsMsg:this.getNoResultsMsg(),filterOptions:this.filterOptions,closeOnSelect:!1,overrides:{SelectArrow:{component:n.Z,props:{overrides:{Svg:{style:()=>({width:s.iconSizes.xl,height:s.iconSizes.xl})}}}},IconsContainer:{style:()=>({paddingRight:s.spacing.sm})},ControlContainer:{style:{minHeight:s.sizes.minElementHeight,borderLeftWidth:s.sizes.borderWidth,borderRightWidth:s.sizes.borderWidth,borderTopWidth:s.sizes.borderWidth,borderBottomWidth:s.sizes.borderWidth}},Placeholder:{style:()=>({flex:"inherit"})},ValueContainer:{style:()=>({paddingLeft:s.spacing.sm,paddingTop:s.spacing.none,paddingBottom:s.spacing.none,paddingRight:s.spacing.none})},ClearIcon:{props:{overrides:{Svg:{style:{color:s.colors.darkGray,transform:"scale(1.5)",width:s.spacing.twoXL,":hover":{fill:s.colors.bodyText}}}}}},SearchIcon:{style:{color:s.colors.darkGray}},Tag:{props:{overrides:{Root:{style:{borderTopLeftRadius:s.radii.md,borderTopRightRadius:s.radii.md,borderBottomRightRadius:s.radii.md,borderBottomLeftRadius:s.radii.md,fontSize:s.fontSizes.sm,paddingLeft:s.spacing.sm,marginLeft:s.spacing.none,marginRight:s.spacing.sm,height:"28px",maxWidth:`calc(100% - ${s.spacing.lg})`}},Action:{style:{paddingLeft:0}},ActionIcon:{props:{overrides:{Svg:{style:{width:"10px",height:"10px"}}}}},Text:{style:{fontSize:s.fontSizes.md}}}}},MultiValue:{props:{overrides:{Root:{style:{fontSize:s.fontSizes.sm}}}}},Input:{props:{readOnly:o.tq&&!1===C?"readonly":null}},Dropdown:{component:f.Z}}})})]})}}const C=(0,a.b)(x)}}]);
|