streamlit-nightly 1.37.2.dev20240824__py2.py3-none-any.whl → 1.37.2.dev20240826__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.
@@ -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\"\xa5\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(\tB3\n\x1c\x63om.snowflake.apps.streamlitB\x13\x44ownloadButtonProtob\x06proto3')
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=206
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "files": {
3
3
  "main.css": "./static/css/main.5513bd04.css",
4
- "main.js": "./static/js/main.771fbdca.js",
4
+ "main.js": "./static/js/main.932be4e4.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
7
  "static/js/2736.3d50ec7f.chunk.js": "./static/js/2736.3d50ec7f.chunk.js",
@@ -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.5e3a04f2.chunk.js": "./static/js/3513.5e3a04f2.chunk.js",
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.9d1e63cc.chunk.js": "./static/js/1074.9d1e63cc.chunk.js",
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.771fbdca.js"
156
+ "static/js/main.932be4e4.js"
157
157
  ]
158
158
  }
@@ -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.771fbdca.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
+ <!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.932be4e4.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:()=>x});var i=s(66845),o=s(91706),r=s(81810),l=s.n(r),n=s(25621),a=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 C 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:n}=t,p=0===n.length||this.props.disabled,b=0===n.length?"No options to select.":t.placeholder,C=n.map(((e,t)=>({label:e,value:t.toString()})));this.formClearHelper.manageFormClearListener(r,t.formId,this.onFormCleared);const x=n.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:C,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:a.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"}},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===x?"readonly":null}},Dropdown:{component:f.Z}}})})]})}}const x=(0,n.b)(C)}}]);
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)}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_streamlit_app=self.webpackChunk_streamlit_app||[]).push([[3513],{33513:(e,t,i)=>{i.r(t),i.d(t,{default:()=>b});var s=i(66845),n=i(25621),l=i(81354),a=i(27446),r=i(9003),o=i(22704),d=i(12596),c=i(66694),u=i(40864);const b=function(e){const{colors:t}=(0,n.u)(),{disabled:i,element:b,widgetMgr:h,width:p,endpoints:m,fragmentId:f}=e,g={width:p},{libConfig:{enforceDownloadInNewTab:w=!1}}=s.useContext(c.E),k="primary"===b.type?l.nW.PRIMARY:l.nW.SECONDARY,x=!b.help||p,A=b.icon.startsWith(":material");return(0,u.jsx)("div",{className:"stDownloadButton","data-testid":"stDownloadButton",style:g,children:(0,u.jsx)(a.t,{help:b.help,children:(0,u.jsxs)(r.ZP,{kind:k,size:l.V5.SMALL,disabled:i,onClick:()=>{h.setTriggerValue(b,{fromUi:!0},f);const e=function(e,t,i){const s=document.createElement("a"),n=e.buildMediaURL(t);return s.setAttribute("href",n),i?s.setAttribute("target","_blank"):s.setAttribute("target","_self"),s.setAttribute("download",""),s}(m,b.url,w);e.click()},fluidWidth:!!b.useContainerWidth&&x,children:[b.icon&&(0,u.jsx)(o.p,{size:A?"lg":"base",margin:A?"0 sm 0 0":"0 md 0 0",color:t.bodyText,iconValue:b.icon}),(0,u.jsx)(d.ZP,{source:b.label,allowHTML:!1,isLabel:!0,largerLabel:!0,disableLinks:!0})]})})})}}}]);