streamlit-nightly 1.19.1.dev20230308__py2.py3-none-any.whl → 1.20.1.dev20230310__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.
@@ -23,6 +23,7 @@ import imghdr
23
23
  import io
24
24
  import mimetypes
25
25
  import re
26
+ from enum import IntEnum
26
27
  from typing import TYPE_CHECKING, List, Optional, Sequence, Union, cast
27
28
  from urllib.parse import urlparse
28
29
 
@@ -63,6 +64,26 @@ ImageFormat: TypeAlias = Literal["JPEG", "PNG", "GIF"]
63
64
  ImageFormatOrAuto: TypeAlias = Literal[ImageFormat, "auto"]
64
65
 
65
66
 
67
+ class WidthBehaviour(IntEnum):
68
+ """
69
+ Special values that are recognized by the frontend and allow us to change the
70
+ behavior of the displayed image.
71
+ """
72
+
73
+ ORIGINAL = -1
74
+ COLUMN = -2
75
+ AUTO = -3
76
+
77
+
78
+ WidthBehaviour.ORIGINAL.__doc__ = """Display the image at its original width"""
79
+ WidthBehaviour.COLUMN.__doc__ = (
80
+ """Display the image at the width of the column it's in."""
81
+ )
82
+ WidthBehaviour.AUTO.__doc__ = """Display the image at its original width, unless it
83
+ would exceed the width of its column in which case clamp it to
84
+ its column width"""
85
+
86
+
66
87
  class ImageMixin:
67
88
  @gather_metrics("image")
68
89
  def image(
@@ -136,11 +157,11 @@ class ImageMixin:
136
157
  """
137
158
 
138
159
  if use_column_width == "auto" or (use_column_width is None and width is None):
139
- width = -3
160
+ width = WidthBehaviour.AUTO
140
161
  elif use_column_width == "always" or use_column_width == True:
141
- width = -2
162
+ width = WidthBehaviour.COLUMN
142
163
  elif width is None:
143
- width = -1
164
+ width = WidthBehaviour.ORIGINAL
144
165
  elif width <= 0:
145
166
  raise StreamlitAPIException("Image width must be positive.")
146
167
 
@@ -409,7 +430,7 @@ def marshall_images(
409
430
  coordinates: str,
410
431
  image: ImageOrImageList,
411
432
  caption: Optional[Union[str, "npt.NDArray[Any]", List[str]]],
412
- width: int,
433
+ width: Union[int, WidthBehaviour],
413
434
  proto_imgs: ImageListProto,
414
435
  clamp: bool,
415
436
  channels: Channels = "RGB",
@@ -430,12 +451,9 @@ def marshall_images(
430
451
  list of captions (one for each image).
431
452
  width
432
453
  The desired width of the image or images. This parameter will be
433
- passed to the frontend, where it has some special meanings:
434
- -1: "OriginalWidth" (display the image at its original width)
435
- -2: "ColumnWidth" (display the image at the width of the column it's in)
436
- -3: "AutoWidth" (display the image at its original width, unless it
437
- would exceed the width of its column in which case clamp it to
438
- its column width).
454
+ passed to the frontend.
455
+ Positive values set the image width explicitly.
456
+ Negative values has some special. For details, see: `WidthBehaviour`
439
457
  proto_imgs
440
458
  The ImageListProto to fill in.
441
459
  clamp
@@ -488,7 +506,7 @@ def marshall_images(
488
506
  len(images),
489
507
  )
490
508
 
491
- proto_imgs.width = width
509
+ proto_imgs.width = int(width)
492
510
  # Each image in an image list needs to be kept track of at its own coordinates.
493
511
  for coord_suffix, (image, caption) in enumerate(zip(images, captions)):
494
512
  proto_img = proto_imgs.imgs.add()
@@ -40,6 +40,7 @@ class PyplotMixin:
40
40
  self,
41
41
  fig: Optional["Figure"] = None,
42
42
  clear_figure: Optional[bool] = None,
43
+ use_container_width: bool = True,
43
44
  **kwargs: Any,
44
45
  ) -> "DeltaGenerator":
45
46
  """Display a matplotlib.pyplot figure.
@@ -61,6 +62,9 @@ class PyplotMixin:
61
62
  * If `fig` is not set, defaults to `True`. This simulates Jupyter's
62
63
  approach to matplotlib rendering.
63
64
 
65
+ use_container_width : bool
66
+ If True, set the chart width to the column width. Defaults to `True`.
67
+
64
68
  **kwargs : any
65
69
  Arguments to pass to Matplotlib's savefig function.
66
70
 
@@ -103,7 +107,12 @@ class PyplotMixin:
103
107
 
104
108
  image_list_proto = ImageListProto()
105
109
  marshall(
106
- self.dg._get_delta_path_str(), image_list_proto, fig, clear_figure, **kwargs
110
+ self.dg._get_delta_path_str(),
111
+ image_list_proto,
112
+ fig,
113
+ clear_figure,
114
+ use_container_width,
115
+ **kwargs,
107
116
  )
108
117
  return self.dg._enqueue("imgs", image_list_proto)
109
118
 
@@ -118,6 +127,7 @@ def marshall(
118
127
  image_list_proto: ImageListProto,
119
128
  fig: Optional["Figure"] = None,
120
129
  clear_figure: Optional[bool] = True,
130
+ use_container_width: bool = True,
121
131
  **kwargs: Any,
122
132
  ) -> None:
123
133
  try:
@@ -149,11 +159,16 @@ def marshall(
149
159
 
150
160
  image = io.BytesIO()
151
161
  fig.savefig(image, **kwargs)
162
+ image_width = (
163
+ image_utils.WidthBehaviour.COLUMN
164
+ if use_container_width
165
+ else image_utils.WidthBehaviour.ORIGINAL
166
+ )
152
167
  image_utils.marshall_images(
153
168
  coordinates=coordinates,
154
169
  image=image,
155
170
  caption=None,
156
- width=-2,
171
+ width=image_width,
157
172
  proto_imgs=image_list_proto,
158
173
  clamp=False,
159
174
  channels="RGB",
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
  from dataclasses import dataclass
16
- from datetime import date, datetime, time
16
+ from datetime import date, datetime, time, timedelta
17
17
  from textwrap import dedent
18
18
  from typing import TYPE_CHECKING, Any, List, Optional, Sequence, Tuple, Union, cast
19
19
 
@@ -47,6 +47,8 @@ SingleDateValue: TypeAlias = Union[date, datetime, None]
47
47
  DateValue: TypeAlias = Union[SingleDateValue, Sequence[SingleDateValue]]
48
48
  DateWidgetReturn: TypeAlias = Union[date, Tuple[()], Tuple[date], Tuple[date, date]]
49
49
 
50
+ DEFAULT_STEP_MINUTES = 15
51
+
50
52
 
51
53
  def _parse_date_value(value: DateValue) -> Tuple[List[date], bool]:
52
54
  parsed_dates: List[date]
@@ -222,6 +224,7 @@ class TimeWidgetsMixin:
222
224
  *, # keyword-only arguments:
223
225
  disabled: bool = False,
224
226
  label_visibility: LabelVisibility = "visible",
227
+ step: Union[int, timedelta] = timedelta(minutes=DEFAULT_STEP_MINUTES),
225
228
  ) -> time:
226
229
  r"""Display a time input widget.
227
230
 
@@ -277,6 +280,9 @@ class TimeWidgetsMixin:
277
280
  is still empty space for it above the widget (equivalent to label="").
278
281
  If "collapsed", both the label and the space are removed. Default is
279
282
  "visible". This argument can only be supplied by keyword.
283
+ step : int or timedelta
284
+ The stepping interval in seconds. Defaults to 900, i.e. 15 minutes.
285
+ You can also pass a datetime.timedelta object.
280
286
 
281
287
  Returns
282
288
  -------
@@ -307,6 +313,7 @@ class TimeWidgetsMixin:
307
313
  kwargs=kwargs,
308
314
  disabled=disabled,
309
315
  label_visibility=label_visibility,
316
+ step=step,
310
317
  ctx=ctx,
311
318
  )
312
319
 
@@ -322,6 +329,7 @@ class TimeWidgetsMixin:
322
329
  *, # keyword-only arguments:
323
330
  disabled: bool = False,
324
331
  label_visibility: LabelVisibility = "visible",
332
+ step: Union[int, timedelta] = timedelta(minutes=DEFAULT_STEP_MINUTES),
325
333
  ctx: Optional[ScriptRunContext] = None,
326
334
  ) -> time:
327
335
  key = to_key(key)
@@ -348,6 +356,17 @@ class TimeWidgetsMixin:
348
356
  time_input_proto.label = label
349
357
  time_input_proto.default = time.strftime(parsed_time, "%H:%M")
350
358
  time_input_proto.form_id = current_form_id(self.dg)
359
+ if not isinstance(step, (int, timedelta)):
360
+ raise StreamlitAPIException(
361
+ f"`step` can only be `int` or `timedelta` but {type(step)} is provided."
362
+ )
363
+ if isinstance(step, timedelta):
364
+ step = step.seconds
365
+ if step < 60 or step > timedelta(hours=23).seconds:
366
+ raise StreamlitAPIException(
367
+ f"`step` must be between 60 seconds and 23 hours but is currently set to {step} seconds."
368
+ )
369
+ time_input_proto.step = step
351
370
  if help is not None:
352
371
  time_input_proto.help = dedent(help)
353
372
 
@@ -20,7 +20,7 @@ DESCRIPTOR = _descriptor.FileDescriptor(
20
20
  syntax='proto3',
21
21
  serialized_options=None,
22
22
  create_key=_descriptor._internal_create_key,
23
- serialized_pb=b'\n\x1fstreamlit/proto/TimeInput.proto\x1a,streamlit/proto/LabelVisibilityMessage.proto\"\xbd\x01\n\tTimeInput\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(\t\x12\x0c\n\x04help\x18\x04 \x01(\t\x12\x0f\n\x07\x66orm_id\x18\x05 \x01(\t\x12\r\n\x05value\x18\x06 \x01(\t\x12\x11\n\tset_value\x18\x07 \x01(\x08\x12\x10\n\x08\x64isabled\x18\x08 \x01(\x08\x12\x31\n\x10label_visibility\x18\t \x01(\x0b\x32\x17.LabelVisibilityMessageb\x06proto3'
23
+ serialized_pb=b'\n\x1fstreamlit/proto/TimeInput.proto\x1a,streamlit/proto/LabelVisibilityMessage.proto\"\xcb\x01\n\tTimeInput\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(\t\x12\x0c\n\x04help\x18\x04 \x01(\t\x12\x0f\n\x07\x66orm_id\x18\x05 \x01(\t\x12\r\n\x05value\x18\x06 \x01(\t\x12\x11\n\tset_value\x18\x07 \x01(\x08\x12\x10\n\x08\x64isabled\x18\x08 \x01(\x08\x12\x31\n\x10label_visibility\x18\t \x01(\x0b\x32\x17.LabelVisibilityMessage\x12\x0c\n\x04step\x18\n \x01(\x03\x62\x06proto3'
24
24
  ,
25
25
  dependencies=[streamlit_dot_proto_dot_LabelVisibilityMessage__pb2.DESCRIPTOR,])
26
26
 
@@ -98,6 +98,13 @@ _TIMEINPUT = _descriptor.Descriptor(
98
98
  message_type=None, enum_type=None, containing_type=None,
99
99
  is_extension=False, extension_scope=None,
100
100
  serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
101
+ _descriptor.FieldDescriptor(
102
+ name='step', full_name='TimeInput.step', index=9,
103
+ number=10, type=3, cpp_type=2, label=1,
104
+ has_default_value=False, default_value=0,
105
+ message_type=None, enum_type=None, containing_type=None,
106
+ is_extension=False, extension_scope=None,
107
+ serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
101
108
  ],
102
109
  extensions=[
103
110
  ],
@@ -111,7 +118,7 @@ _TIMEINPUT = _descriptor.Descriptor(
111
118
  oneofs=[
112
119
  ],
113
120
  serialized_start=82,
114
- serialized_end=271,
121
+ serialized_end=285,
115
122
  )
116
123
 
117
124
  _TIMEINPUT.fields_by_name['label_visibility'].message_type = streamlit_dot_proto_dot_LabelVisibilityMessage__pb2._LABELVISIBILITYMESSAGE
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "files": {
3
3
  "main.css": "./static/css/main.f4a8738f.css",
4
- "main.js": "./static/js/main.5fdd2bb9.js",
4
+ "main.js": "./static/js/main.cd458b20.js",
5
5
  "static/js/464.53a4cca5.chunk.js": "./static/js/464.53a4cca5.chunk.js",
6
6
  "static/js/248.78592c79.chunk.js": "./static/js/248.78592c79.chunk.js",
7
7
  "static/js/787.35855372.chunk.js": "./static/js/787.35855372.chunk.js",
@@ -11,7 +11,7 @@
11
11
  "static/js/745.5461f47f.chunk.js": "./static/js/745.5461f47f.chunk.js",
12
12
  "static/js/341.0360ab4c.chunk.js": "./static/js/341.0360ab4c.chunk.js",
13
13
  "static/js/187.23c06ae4.chunk.js": "./static/js/187.23c06ae4.chunk.js",
14
- "static/js/491.56b28d4e.chunk.js": "./static/js/491.56b28d4e.chunk.js",
14
+ "static/js/491.0f2b9d6a.chunk.js": "./static/js/491.0f2b9d6a.chunk.js",
15
15
  "static/js/510.7a54dd75.chunk.js": "./static/js/510.7a54dd75.chunk.js",
16
16
  "static/js/429.c723ecb4.chunk.js": "./static/js/429.c723ecb4.chunk.js",
17
17
  "static/js/705.101a6c50.chunk.js": "./static/js/705.101a6c50.chunk.js",
@@ -33,7 +33,7 @@
33
33
  "static/js/511.8119e064.chunk.js": "./static/js/511.8119e064.chunk.js",
34
34
  "static/js/289.481fd42d.chunk.js": "./static/js/289.481fd42d.chunk.js",
35
35
  "static/js/628.032f255e.chunk.js": "./static/js/628.032f255e.chunk.js",
36
- "static/js/227.050a4bd9.chunk.js": "./static/js/227.050a4bd9.chunk.js",
36
+ "static/js/227.087adf66.chunk.js": "./static/js/227.087adf66.chunk.js",
37
37
  "static/js/871.80eecb75.chunk.js": "./static/js/871.80eecb75.chunk.js",
38
38
  "static/js/714.ba8c0399.chunk.js": "./static/js/714.ba8c0399.chunk.js",
39
39
  "static/js/432.67841791.chunk.js": "./static/js/432.67841791.chunk.js",
@@ -140,6 +140,6 @@
140
140
  },
141
141
  "entrypoints": [
142
142
  "static/css/main.f4a8738f.css",
143
- "static/js/main.5fdd2bb9.js"
143
+ "static/js/main.cd458b20.js"
144
144
  ]
145
145
  }
@@ -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"/><title>Streamlit</title><script>window.prerenderReady=!1</script><script src="./vendor/viz/viz-1.8.0.min.js" type="javascript/worker"></script><script src="./vendor/bokeh/bokeh-2.4.3.min.js"></script><script src="./vendor/bokeh/bokeh-widgets-2.4.3.min.js"></script><script src="./vendor/bokeh/bokeh-tables-2.4.3.min.js"></script><script src="./vendor/bokeh/bokeh-api-2.4.3.min.js"></script><script src="./vendor/bokeh/bokeh-gl-2.4.3.min.js"></script><script src="./vendor/bokeh/bokeh-mathjax-2.4.3.min.js"></script><script defer="defer" src="./static/js/main.5fdd2bb9.js"></script><link href="./static/css/main.f4a8738f.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"/><title>Streamlit</title><script>window.prerenderReady=!1</script><script src="./vendor/viz/viz-1.8.0.min.js" type="javascript/worker"></script><script src="./vendor/bokeh/bokeh-2.4.3.min.js"></script><script src="./vendor/bokeh/bokeh-widgets-2.4.3.min.js"></script><script src="./vendor/bokeh/bokeh-tables-2.4.3.min.js"></script><script src="./vendor/bokeh/bokeh-api-2.4.3.min.js"></script><script src="./vendor/bokeh/bokeh-gl-2.4.3.min.js"></script><script src="./vendor/bokeh/bokeh-mathjax-2.4.3.min.js"></script><script defer="defer" src="./static/js/main.cd458b20.js"></script><link href="./static/css/main.f4a8738f.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.webpackChunkstreamlit_browser=self.webpackChunkstreamlit_browser||[]).push([[227],{34227:function(e,t,n){n.r(t),n.d(t,{default:function(){return v}});var r=n(29439),i=n(15671),o=n(43144),a=n(60136),l=n(29388),u=n(47313),s=n(11197),d=n(46332),p=n(65167),m=n(73290),c=n(80213),f=n(64243),h=n(46417),g=function(e){(0,a.Z)(n,e);var t=(0,l.Z)(n);function n(){var e;(0,i.Z)(this,n);for(var o=arguments.length,a=new Array(o),l=0;l<o;l++)a[l]=arguments[l];return(e=t.call.apply(t,[this].concat(a))).formClearHelper=new d.Kz,e.state={value:e.initialValue},e.commitWidgetValue=function(t){e.props.widgetMgr.setStringValue(e.props.element,e.state.value,t)},e.onFormCleared=function(){e.setState((function(e,t){return{value:t.element.default}}),(function(){return e.commitWidgetValue({fromUi:!0})}))},e.handleChange=function(t){var n;n=null===t?e.initialValue:e.dateToString(t),e.setState({value:n},(function(){return e.commitWidgetValue({fromUi:!0})}))},e.stringToDate=function(e){var t=e.split(":").map(Number),n=(0,r.Z)(t,2),i=n[0],o=n[1],a=new Date;return a.setHours(i),a.setMinutes(o),a},e.dateToString=function(e){var t=e.getHours().toString().padStart(2,"0"),n=e.getMinutes().toString().padStart(2,"0");return"".concat(t,":").concat(n)},e}return(0,o.Z)(n,[{key:"initialValue",get:function(){var e=this.props.widgetMgr.getStringValue(this.props.element);return void 0!==e?e:this.props.element.default}},{key:"componentDidMount",value:function(){this.props.element.setValue?this.updateFromProtobuf():this.commitWidgetValue({fromUi:!1})}},{key:"componentDidUpdate",value:function(){this.maybeUpdateFromProtobuf()}},{key:"componentWillUnmount",value:function(){this.formClearHelper.disconnect()}},{key:"maybeUpdateFromProtobuf",value:function(){this.props.element.setValue&&this.updateFromProtobuf()}},{key:"updateFromProtobuf",value:function(){var e=this,t=this.props.element.value;this.props.element.setValue=!1,this.setState({value:t},(function(){e.commitWidgetValue({fromUi:!1})}))}},{key:"render",value:function(){var e,t=this.props,n=t.disabled,r=t.width,i=t.element,o=t.widgetMgr,a={width:r},l={Select:{props:{disabled:n,overrides:{ControlContainer:{style:{borderLeftWidth:"1px",borderRightWidth:"1px",borderTopWidth:"1px",borderBottomWidth:"1px"}},IconsContainer:{style:function(){return{paddingRight:".5rem"}}},ValueContainer:{style:function(){return{paddingRight:".5rem",paddingLeft:".5rem",paddingBottom:".5rem",paddingTop:".5rem"}}},Dropdown:{style:function(){return{paddingTop:0,paddingBottom:0}}},Popover:{props:{overrides:{Body:{style:function(){return{marginTop:"1px"}}}}}}}}}};return this.formClearHelper.manageFormClearListener(o,i.formId,this.onFormCleared),(0,h.jsxs)("div",{className:"stTimeInput",style:a,children:[(0,h.jsx)(p.ON,{label:i.label,disabled:n,labelVisibility:(0,f.iF)(null===(e=i.labelVisibility)||void 0===e?void 0:e.value),children:i.help&&(0,h.jsx)(p.dT,{children:(0,h.jsx)(m.ZP,{content:i.help,placement:c.ug.TOP_RIGHT})})}),(0,h.jsx)(s.Z,{format:"24",value:this.stringToDate(this.state.value),onChange:this.handleChange,overrides:l,creatable:!0,"aria-label":i.label})]})}}]),n}(u.PureComponent),v=g}}]);
1
+ "use strict";(self.webpackChunkstreamlit_browser=self.webpackChunkstreamlit_browser||[]).push([[227],{34227:function(e,t,n){n.r(t),n.d(t,{default:function(){return v}});var r=n(29439),i=n(15671),o=n(43144),a=n(60136),l=n(29388),u=n(47313),s=n(11197),p=n(46332),d=n(65167),m=n(73290),c=n(80213),f=n(64243),h=n(46417),g=function(e){(0,a.Z)(n,e);var t=(0,l.Z)(n);function n(){var e;(0,i.Z)(this,n);for(var o=arguments.length,a=new Array(o),l=0;l<o;l++)a[l]=arguments[l];return(e=t.call.apply(t,[this].concat(a))).formClearHelper=new p.Kz,e.state={value:e.initialValue},e.commitWidgetValue=function(t){e.props.widgetMgr.setStringValue(e.props.element,e.state.value,t)},e.onFormCleared=function(){e.setState((function(e,t){return{value:t.element.default}}),(function(){return e.commitWidgetValue({fromUi:!0})}))},e.handleChange=function(t){var n;n=null===t?e.initialValue:e.dateToString(t),e.setState({value:n},(function(){return e.commitWidgetValue({fromUi:!0})}))},e.stringToDate=function(e){var t=e.split(":").map(Number),n=(0,r.Z)(t,2),i=n[0],o=n[1],a=new Date;return a.setHours(i),a.setMinutes(o),a},e.dateToString=function(e){var t=e.getHours().toString().padStart(2,"0"),n=e.getMinutes().toString().padStart(2,"0");return"".concat(t,":").concat(n)},e}return(0,o.Z)(n,[{key:"initialValue",get:function(){var e=this.props.widgetMgr.getStringValue(this.props.element);return void 0!==e?e:this.props.element.default}},{key:"componentDidMount",value:function(){this.props.element.setValue?this.updateFromProtobuf():this.commitWidgetValue({fromUi:!1})}},{key:"componentDidUpdate",value:function(){this.maybeUpdateFromProtobuf()}},{key:"componentWillUnmount",value:function(){this.formClearHelper.disconnect()}},{key:"maybeUpdateFromProtobuf",value:function(){this.props.element.setValue&&this.updateFromProtobuf()}},{key:"updateFromProtobuf",value:function(){var e=this,t=this.props.element.value;this.props.element.setValue=!1,this.setState({value:t},(function(){e.commitWidgetValue({fromUi:!1})}))}},{key:"render",value:function(){var e,t=this.props,n=t.disabled,r=t.width,i=t.element,o=t.widgetMgr,a={width:r},l={Select:{props:{disabled:n,overrides:{ControlContainer:{style:{borderLeftWidth:"1px",borderRightWidth:"1px",borderTopWidth:"1px",borderBottomWidth:"1px"}},IconsContainer:{style:function(){return{paddingRight:".5rem"}}},ValueContainer:{style:function(){return{paddingRight:".5rem",paddingLeft:".5rem",paddingBottom:".5rem",paddingTop:".5rem"}}},SingleValue:{props:{className:"stTimeInput-timeDisplay"}},Dropdown:{style:function(){return{paddingTop:0,paddingBottom:0}}},Popover:{props:{overrides:{Body:{style:function(){return{marginTop:"1px"}}}}}}}}}};return this.formClearHelper.manageFormClearListener(o,i.formId,this.onFormCleared),(0,h.jsxs)("div",{className:"stTimeInput",style:a,children:[(0,h.jsx)(d.ON,{label:i.label,disabled:n,labelVisibility:(0,f.iF)(null===(e=i.labelVisibility)||void 0===e?void 0:e.value),children:i.help&&(0,h.jsx)(d.dT,{children:(0,h.jsx)(m.ZP,{content:i.help,placement:c.ug.TOP_RIGHT})})}),(0,h.jsx)(s.Z,{format:"24",step:i.step?Number(i.step):900,value:this.stringToDate(this.state.value),onChange:this.handleChange,overrides:l,creatable:!0,"aria-label":i.label})]})}}]),n}(u.PureComponent),v=g}}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunkstreamlit_browser=self.webpackChunkstreamlit_browser||[]).push([[491],{8798:function(t,e,n){"use strict";n.r(e),n.d(e,{default:function(){return H}});var i=n(4942),r=n(15671),a=n(43144),o=n(60136),s=n(29388),c=n(1413),h=n(47313),l=n(59603),u=n(1905),p=n.n(u),d=n(16117),m=n(83985),f=n(80788),w=n(24821),v=n(41043),g=n(49774),x=n(40519),b=n(31186),k=n(96721),Z=n(20024),S=n(21906),y=n(26419),j=n(74165),T=n(15861),V=n(317),C=n(53499),E=n(28664),M=n(31881),O=n.n(M),F=n(81003),L=function(t){(0,o.Z)(n,t);var e=(0,s.Z)(n);function n(){return(0,r.Z)(this,n),e.apply(this,arguments)}return(0,a.Z)(n)}((0,E.Z)(Error)),N=function(t){(0,o.Z)(n,t);var e=(0,s.Z)(n);function n(){return(0,r.Z)(this,n),e.apply(this,arguments)}return(0,a.Z)(n)}((0,E.Z)(Error)),P=function(){function t(){(0,r.Z)(this,t)}return(0,a.Z)(t,null,[{key:"get",value:function(){var e=(0,T.Z)((0,j.Z)().mark((function e(n){var i,r,a;return(0,j.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=n.current,r=i.commandLine,a=i.userMapboxToken,t.token&&t.commandLine===r.toLowerCase()){e.next=10;break}if(""===a){e.next=6;break}t.token=a,e.next=9;break;case 6:return e.next=8,this.fetchToken("https://data.streamlit.io/tokens.json","mapbox");case 8:t.token=e.sent;case 9:t.commandLine=r.toLowerCase();case 10:return e.abrupt("return",t.token);case 11:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"fetchToken",value:function(){var t=(0,T.Z)((0,j.Z)().mark((function t(e,n){var i,r,a;return(0,j.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,O().get(e);case 3:if(i=t.sent,null!=(r=i.data[n])&&""!==r){t.next=7;break}throw new Error('Missing token "'.concat(n,'"'));case 7:return t.abrupt("return",r);case 10:throw t.prev=10,t.t0=t.catch(0),a=(0,F.b)(t.t0),new N("".concat(a.message," (").concat(e,")"));case 14:case"end":return t.stop()}}),t,null,[[0,10]])})));return function(e,n){return t.apply(this,arguments)}}()}]),t}();P.token=void 0,P.commandLine=void 0,P.isRunningLocal=function(){var t=window.location.hostname;return"localhost"===t||"127.0.0.1"===t};var I=n(67861),z=n.n(I),D=n(46135),q=n(46417),A=function(t){var e=t.error,n=t.width,i=t.deltaType;return e instanceof L?(0,q.jsx)(D.Z,{width:n,name:"No Mapbox token provided",message:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)("p",{children:["To use ",(0,q.jsxs)("code",{children:["st.",i]})," or ",(0,q.jsx)("code",{children:"st.map"})," you need to set up a Mapbox access token."]}),(0,q.jsxs)("p",{children:["To get a token, create an account at"," ",(0,q.jsx)("a",{href:"https://mapbox.com",children:"https://mapbox.com"}),". It's free for moderate usage levels!"]}),(0,q.jsxs)("p",{children:["Once you have a token, just set it using the Streamlit config option ",(0,q.jsx)("code",{children:"mapbox.token"})," and don't forget to restart your Streamlit server at this point if it's still running, then reload this tab."]}),(0,q.jsxs)("p",{children:["See"," ",(0,q.jsx)("a",{href:"https://docs.streamlit.io/library/advanced-features/configuration#view-all-configuration-options",children:"our documentation"})," ","for more info on how to set config options."]})]})}):e instanceof N?(0,q.jsx)(D.Z,{width:n,name:"Error fetching Streamlit Mapbox token",message:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)("p",{children:"This app requires an internet connection."}),(0,q.jsx)("p",{children:"Please check your connection and try again."}),(0,q.jsxs)("p",{children:["If you think this is a bug, please file bug report"," ",(0,q.jsx)("a",{href:"https://github.com/streamlit/streamlit/issues/new/choose",children:"here"}),"."]})]})}):(0,q.jsx)(D.Z,{width:n,name:"Error fetching Streamlit Mapbox token",message:e.message})},J=function(t){return function(e){var n=function(n){(0,o.Z)(h,n);var i=(0,s.Z)(h);function h(n){var a;return(0,r.Z)(this,h),(a=i.call(this,n)).initMapboxToken=(0,T.Z)((0,j.Z)().mark((function t(){var e,n;return(0,j.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,P.get(a.props.sessionInfo);case 3:e=t.sent,a.setState({mapboxToken:e,isFetching:!1}),t.next=11;break;case 7:t.prev=7,t.t0=t.catch(0),n=(0,F.b)(t.t0),a.setState({mapboxTokenError:n,isFetching:!1});case 11:case"end":return t.stop()}}),t,null,[[0,7]])}))),a.render=function(){var n=a.state,i=n.mapboxToken,r=n.mapboxTokenError,o=n.isFetching,s=a.props.width;return r?(0,q.jsx)(A,{width:s,error:r,deltaType:t}):o?(0,q.jsx)(V.Z,{body:"Loading...",kind:C.h.INFO,width:s}):(0,q.jsx)(e,(0,c.Z)((0,c.Z)({},a.props),{},{mapboxToken:i,width:s}))},a.state={isFetching:!0,mapboxToken:void 0,mapboxTokenError:void 0},a.initMapboxToken(),a}return(0,a.Z)(h)}(h.PureComponent);return n.displayName="withMapboxToken(".concat(e.displayName||e.name,")"),z()(n,e)}},_=n(64243),B=n(47167),G=(0,B.Z)("div",{target:"e1q4dr931"})((function(t){var e=t.width,n=t.height;return{marginTop:t.theme.spacing.sm,position:"relative",height:n,width:e}}),""),R=(0,B.Z)("div",{target:"e1q4dr930"})((function(t){var e=t.theme;return{position:"absolute",right:"2.625rem",top:e.spacing.md,zIndex:1,"button:not(:disabled)":{background:e.colors.bgColor,"& + button":{borderTopColor:e.colors.secondaryBg},"& span":{filter:(0,f.Iy)(e)?"":"invert(100%)"}}}}),""),W=(n(81627),{classes:(0,c.Z)((0,c.Z)((0,c.Z)((0,c.Z)({},w),x),g),b)});(0,S.fh)([k.w,Z.E]);var X=new v.Z({configuration:W}),$=function(t){(0,o.Z)(n,t);var e=(0,s.Z)(n);function n(){var t;(0,r.Z)(this,n);for(var i=arguments.length,a=new Array(i),o=0;o<i;o++)a[o]=arguments[o];return(t=e.call.apply(e,[this].concat(a))).state={viewState:{bearing:0,pitch:0,zoom:11},initialized:!1,initialViewState:{}},t.componentDidMount=function(){t.setState({initialized:!0})},t.createTooltip=function(e){var n=t.props.element;if(!e||!e.object||!n.tooltip)return!1;var i=JSON.parse(n.tooltip);return i.html?i.html=t.interpolate(e,i.html):i.text=t.interpolate(e,i.text),i},t.interpolate=function(t,e){var n=e.match(/{(.*?)}/g);return n&&n.forEach((function(n){var i=n.substring(1,n.length-1);t.object.hasOwnProperty(i)&&(e=e.replace(n,t.object[i]))})),e},t.onViewStateChange=function(e){var n=e.viewState;t.setState({viewState:n})},t}return(0,a.Z)(n,[{key:"render",value:function(){var t=n.getDeckObject(this.props),e=this.state.viewState;return(0,q.jsx)(G,{className:"stDeckGlJsonChart",width:t.initialViewState.width,height:t.initialViewState.height,children:(0,q.jsxs)(l.Z,{viewState:e,onViewStateChange:this.onViewStateChange,height:t.initialViewState.height,width:t.initialViewState.width,layers:this.state.initialized?t.layers:[],getTooltip:this.createTooltip,ContextProvider:d.X$.Provider,controller:!0,children:[(0,q.jsx)(d.Z3,{height:t.initialViewState.height,width:t.initialViewState.width,mapStyle:t.mapStyle&&("string"===typeof t.mapStyle?t.mapStyle:t.mapStyle[0]),mapboxApiAccessToken:this.props.mapboxToken}),(0,q.jsx)(R,{children:(0,q.jsx)(d.Pv,{className:"zoomButton",showCompass:!1})})]})})}}],[{key:"getDerivedStateFromProps",value:function(t,e){var r=n.getDeckObject(t);if(!p()(r.initialViewState,e.initialViewState)){var a=Object.keys(r.initialViewState).reduce((function(t,n){return r.initialViewState[n]===e.initialViewState[n]?t:(0,c.Z)((0,c.Z)({},t),{},(0,i.Z)({},n,r.initialViewState[n]))}),{});return{viewState:(0,c.Z)((0,c.Z)({},e.viewState),a),initialViewState:r.initialViewState}}return null}}]),n}(h.PureComponent);$.getDeckObject=function(t){var e=t.element,n=t.width,i=t.height,r=t.theme,a=JSON.parse(e.json);if(!(0,_.bb)(a.mapStyle)){var o=(0,f.Iy)(r)?"light":"dark";a.mapStyle="mapbox://styles/mapbox/".concat(o,"-v9")}return i?(a.initialViewState.height=i,a.initialViewState.width=n):(a.initialViewState.height||(a.initialViewState.height=500),e.useContainerWidth&&(a.initialViewState.width=n)),delete a.views,X.convert(a)};var H=(0,m.b)(J("st.pydeck_chart")((0,y.Z)($)))},50413:function(){},30643:function(){},69081:function(){},49125:function(){}}]);