streamlit-nightly 1.33.1.dev20240417__py2.py3-none-any.whl → 1.33.1.dev20240418__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/elements/widgets/multiselect.py +9 -5
- streamlit/elements/widgets/number_input.py +5 -0
- streamlit/elements/widgets/radio.py +5 -0
- streamlit/elements/widgets/selectbox.py +5 -0
- streamlit/elements/widgets/text_widgets.py +9 -0
- streamlit/elements/widgets/time_widgets.py +23 -9
- streamlit/runtime/caching/cache_data_api.py +8 -2
- streamlit/runtime/caching/cache_resource_api.py +8 -2
- streamlit/runtime/caching/cache_utils.py +26 -9
- streamlit/static/asset-manifest.json +3 -3
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/43.b0aa5759.chunk.js +1 -0
- streamlit/static/static/js/{main.f215a056.js → main.81ad100d.js} +2 -2
- {streamlit_nightly-1.33.1.dev20240417.dist-info → streamlit_nightly-1.33.1.dev20240418.dist-info}/METADATA +3 -3
- {streamlit_nightly-1.33.1.dev20240417.dist-info → streamlit_nightly-1.33.1.dev20240418.dist-info}/RECORD +20 -20
- streamlit/static/static/js/43.05a14cc7.chunk.js +0 -1
- /streamlit/static/static/js/{main.f215a056.js.LICENSE.txt → main.81ad100d.js.LICENSE.txt} +0 -0
- {streamlit_nightly-1.33.1.dev20240417.data → streamlit_nightly-1.33.1.dev20240418.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.33.1.dev20240417.dist-info → streamlit_nightly-1.33.1.dev20240418.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.33.1.dev20240417.dist-info → streamlit_nightly-1.33.1.dev20240418.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.33.1.dev20240417.dist-info → streamlit_nightly-1.33.1.dev20240418.dist-info}/top_level.txt +0 -0
@@ -83,15 +83,19 @@ def _check_and_convert_to_indices(
|
|
83
83
|
default_values, "pandas.core.series.Series"
|
84
84
|
):
|
85
85
|
default_values = list(cast(Sequence[Any], default_values))
|
86
|
-
elif
|
87
|
-
default_values
|
88
|
-
|
86
|
+
elif (
|
87
|
+
isinstance(default_values, (tuple, set))
|
88
|
+
or default_values
|
89
|
+
and default_values not in opt
|
90
|
+
):
|
89
91
|
default_values = list(default_values)
|
90
|
-
|
92
|
+
else:
|
93
|
+
default_values = [default_values]
|
91
94
|
for value in default_values:
|
92
95
|
if value not in opt:
|
93
96
|
raise StreamlitAPIException(
|
94
|
-
"
|
97
|
+
f"The default value '{value}' is part of the options. "
|
98
|
+
"Please make sure that every default values also exists in the options."
|
95
99
|
)
|
96
100
|
|
97
101
|
return [opt.index(value) for value in default_values]
|
@@ -37,6 +37,7 @@ from streamlit.runtime.state import (
|
|
37
37
|
WidgetArgs,
|
38
38
|
WidgetCallback,
|
39
39
|
WidgetKwargs,
|
40
|
+
get_session_state,
|
40
41
|
register_widget,
|
41
42
|
)
|
42
43
|
from streamlit.runtime.state.common import compute_widget_id
|
@@ -323,6 +324,10 @@ class NumberInputMixin:
|
|
323
324
|
f"\n`step` has {type(step).__name__} type."
|
324
325
|
)
|
325
326
|
|
327
|
+
session_state = get_session_state().filtered_state
|
328
|
+
if key is not None and key in session_state and session_state[key] is None:
|
329
|
+
value = None
|
330
|
+
|
326
331
|
if value == "min":
|
327
332
|
if min_value is not None:
|
328
333
|
value = min_value
|
@@ -34,6 +34,7 @@ from streamlit.runtime.state import (
|
|
34
34
|
WidgetArgs,
|
35
35
|
WidgetCallback,
|
36
36
|
WidgetKwargs,
|
37
|
+
get_session_state,
|
37
38
|
register_widget,
|
38
39
|
)
|
39
40
|
from streamlit.runtime.state.common import compute_widget_id, save_for_app_testing
|
@@ -293,6 +294,10 @@ class RadioMixin:
|
|
293
294
|
f"Radio captions must be strings. Passed type: {type(caption).__name__}"
|
294
295
|
)
|
295
296
|
|
297
|
+
session_state = get_session_state().filtered_state
|
298
|
+
if key is not None and key in session_state and session_state[key] is None:
|
299
|
+
index = None
|
300
|
+
|
296
301
|
radio_proto = RadioProto()
|
297
302
|
radio_proto.id = id
|
298
303
|
radio_proto.label = label
|
@@ -33,6 +33,7 @@ from streamlit.runtime.state import (
|
|
33
33
|
WidgetArgs,
|
34
34
|
WidgetCallback,
|
35
35
|
WidgetKwargs,
|
36
|
+
get_session_state,
|
36
37
|
register_widget,
|
37
38
|
)
|
38
39
|
from streamlit.runtime.state.common import compute_widget_id, save_for_app_testing
|
@@ -262,6 +263,10 @@ class SelectboxMixin:
|
|
262
263
|
"Selectbox index must be between 0 and length of options"
|
263
264
|
)
|
264
265
|
|
266
|
+
session_state = get_session_state().filtered_state
|
267
|
+
if key is not None and key in session_state and session_state[key] is None:
|
268
|
+
index = None
|
269
|
+
|
265
270
|
selectbox_proto = SelectboxProto()
|
266
271
|
selectbox_proto.id = id
|
267
272
|
selectbox_proto.label = label
|
@@ -34,6 +34,7 @@ from streamlit.runtime.state import (
|
|
34
34
|
WidgetArgs,
|
35
35
|
WidgetCallback,
|
36
36
|
WidgetKwargs,
|
37
|
+
get_session_state,
|
37
38
|
register_widget,
|
38
39
|
)
|
39
40
|
from streamlit.runtime.state.common import compute_widget_id
|
@@ -278,6 +279,10 @@ class TextWidgetsMixin:
|
|
278
279
|
page=ctx.page_script_hash if ctx else None,
|
279
280
|
)
|
280
281
|
|
282
|
+
session_state = get_session_state().filtered_state
|
283
|
+
if key is not None and key in session_state and session_state[key] is None:
|
284
|
+
value = None
|
285
|
+
|
281
286
|
text_input_proto = TextInputProto()
|
282
287
|
text_input_proto.id = id
|
283
288
|
text_input_proto.label = label
|
@@ -538,6 +543,10 @@ class TextWidgetsMixin:
|
|
538
543
|
page=ctx.page_script_hash if ctx else None,
|
539
544
|
)
|
540
545
|
|
546
|
+
session_state = get_session_state().filtered_state
|
547
|
+
if key is not None and key in session_state and session_state[key] is None:
|
548
|
+
value = None
|
549
|
+
|
541
550
|
text_area_proto = TextAreaProto()
|
542
551
|
text_area_proto.id = id
|
543
552
|
text_area_proto.label = label
|
@@ -21,6 +21,7 @@ from typing import (
|
|
21
21
|
TYPE_CHECKING,
|
22
22
|
Any,
|
23
23
|
Final,
|
24
|
+
List,
|
24
25
|
Literal,
|
25
26
|
Sequence,
|
26
27
|
Tuple,
|
@@ -79,7 +80,6 @@ def _parse_date_value(
|
|
79
80
|
if value == "today":
|
80
81
|
parsed_dates = [datetime.now().date()]
|
81
82
|
elif value == "default_value_today":
|
82
|
-
# Set value default.
|
83
83
|
parsed_dates = [datetime.now().date()]
|
84
84
|
elif isinstance(value, datetime):
|
85
85
|
parsed_dates = [value.date()]
|
@@ -159,17 +159,27 @@ class _DateInputValues:
|
|
159
159
|
max_value: SingleDateValue,
|
160
160
|
) -> _DateInputValues:
|
161
161
|
parsed_value, is_range = _parse_date_value(value=value)
|
162
|
+
parsed_min = _parse_min_date(
|
163
|
+
min_value=min_value,
|
164
|
+
parsed_dates=parsed_value,
|
165
|
+
)
|
166
|
+
parsed_max = _parse_max_date(
|
167
|
+
max_value=max_value,
|
168
|
+
parsed_dates=parsed_value,
|
169
|
+
)
|
170
|
+
|
171
|
+
if value == "default_value_today":
|
172
|
+
v = cast(List[date], parsed_value)[0]
|
173
|
+
if v < parsed_min:
|
174
|
+
parsed_value = [parsed_min]
|
175
|
+
if v > parsed_max:
|
176
|
+
parsed_value = [parsed_max]
|
177
|
+
|
162
178
|
return cls(
|
163
179
|
value=parsed_value,
|
164
180
|
is_range=is_range,
|
165
|
-
min=
|
166
|
-
|
167
|
-
parsed_dates=parsed_value,
|
168
|
-
),
|
169
|
-
max=_parse_max_date(
|
170
|
-
max_value=max_value,
|
171
|
-
parsed_dates=parsed_value,
|
172
|
-
),
|
181
|
+
min=parsed_min,
|
182
|
+
max=parsed_max,
|
173
183
|
)
|
174
184
|
|
175
185
|
def __post_init__(self) -> None:
|
@@ -449,6 +459,10 @@ class TimeWidgetsMixin:
|
|
449
459
|
)
|
450
460
|
del value
|
451
461
|
|
462
|
+
session_state = get_session_state().filtered_state
|
463
|
+
if key is not None and key in session_state and session_state[key] is None:
|
464
|
+
parsed_time = None
|
465
|
+
|
452
466
|
time_input_proto = TimeInputProto()
|
453
467
|
time_input_proto.id = id
|
454
468
|
time_input_proto.label = label
|
@@ -513,6 +513,9 @@ class CacheDataAPI:
|
|
513
513
|
... # Fetch data from _db_connection here, and then clean it up.
|
514
514
|
... return data
|
515
515
|
...
|
516
|
+
>>> fetch_and_clean_data.clear(_db_connection, 50)
|
517
|
+
>>> # Clear the cached entry for the arguments provided.
|
518
|
+
>>>
|
516
519
|
>>> fetch_and_clean_data.clear()
|
517
520
|
>>> # Clear all cached entries for this function.
|
518
521
|
|
@@ -701,8 +704,11 @@ class DataCache(Cache):
|
|
701
704
|
|
702
705
|
self.storage.set(key, pickled_entry)
|
703
706
|
|
704
|
-
def _clear(self) -> None:
|
705
|
-
|
707
|
+
def _clear(self, key: str | None = None) -> None:
|
708
|
+
if not key:
|
709
|
+
self.storage.clear()
|
710
|
+
else:
|
711
|
+
self.storage.delete(key)
|
706
712
|
|
707
713
|
def _read_multi_results_from_storage(self, key: str) -> MultiCacheResults:
|
708
714
|
"""Look up the results from storage and ensure it has the right type.
|
@@ -384,6 +384,9 @@ class CacheResourceAPI:
|
|
384
384
|
... # Create a database connection object that points to the URL.
|
385
385
|
... return connection
|
386
386
|
...
|
387
|
+
>>> fetch_and_clean_data.clear(_sessionmaker, "https://streamlit.io/")
|
388
|
+
>>> # Clear the cached entry for the arguments provided.
|
389
|
+
>>>
|
387
390
|
>>> get_database_session.clear()
|
388
391
|
>>> # Clear all cached entries for this function.
|
389
392
|
|
@@ -549,9 +552,12 @@ class ResourceCache(Cache):
|
|
549
552
|
multi_results.results[widget_key] = result
|
550
553
|
self._mem_cache[key] = multi_results
|
551
554
|
|
552
|
-
def _clear(self) -> None:
|
555
|
+
def _clear(self, key: str | None = None) -> None:
|
553
556
|
with self._mem_cache_lock:
|
554
|
-
|
557
|
+
if key is None:
|
558
|
+
self._mem_cache.clear()
|
559
|
+
elif key in self._mem_cache:
|
560
|
+
del self._mem_cache[key]
|
555
561
|
|
556
562
|
def get_stats(self) -> list[CacheStat]:
|
557
563
|
# Shallow clone our cache. Computing item sizes is potentially
|
@@ -102,14 +102,19 @@ class Cache:
|
|
102
102
|
with self._value_locks_lock:
|
103
103
|
return self._value_locks[value_key]
|
104
104
|
|
105
|
-
def clear(self):
|
106
|
-
"""Clear
|
105
|
+
def clear(self, key: str | None = None):
|
106
|
+
"""Clear values from this cache.
|
107
|
+
If no argument is passed, all items are cleared from the cache.
|
108
|
+
A key can be passed to clear that key from the cache only."""
|
107
109
|
with self._value_locks_lock:
|
108
|
-
|
109
|
-
|
110
|
+
if not key:
|
111
|
+
self._value_locks.clear()
|
112
|
+
elif key in self._value_locks:
|
113
|
+
del self._value_locks[key]
|
114
|
+
self._clear(key=key)
|
110
115
|
|
111
116
|
@abstractmethod
|
112
|
-
def _clear(self) -> None:
|
117
|
+
def _clear(self, key: str | None = None) -> None:
|
113
118
|
"""Subclasses must implement this to perform cache-clearing logic."""
|
114
119
|
raise NotImplementedError
|
115
120
|
|
@@ -154,7 +159,7 @@ def make_cached_func_wrapper(info: CachedFuncInfo) -> Callable[..., Any]:
|
|
154
159
|
value otherwise.
|
155
160
|
|
156
161
|
The wrapper also has a `clear` function that can be called to clear
|
157
|
-
all of the wrapper's cached values.
|
162
|
+
some or all of the wrapper's cached values.
|
158
163
|
"""
|
159
164
|
cached_func = CachedFunc(info)
|
160
165
|
|
@@ -303,10 +308,22 @@ class CachedFunc:
|
|
303
308
|
return_value=computed_value, func=self._info.func
|
304
309
|
)
|
305
310
|
|
306
|
-
def clear(self):
|
307
|
-
"""Clear the wrapped function's associated cache.
|
311
|
+
def clear(self, *args, **kwargs):
|
312
|
+
"""Clear the wrapped function's associated cache.
|
313
|
+
If no arguments are passed, clear the cache of all values.
|
314
|
+
If args/kwargs are provided, clear the cached value for these arguments only."""
|
308
315
|
cache = self._info.get_function_cache(self._function_key)
|
309
|
-
|
316
|
+
if args or kwargs:
|
317
|
+
key = _make_value_key(
|
318
|
+
cache_type=self._info.cache_type,
|
319
|
+
func=self._info.func,
|
320
|
+
func_args=args,
|
321
|
+
func_kwargs=kwargs,
|
322
|
+
hash_funcs=self._info.hash_funcs,
|
323
|
+
)
|
324
|
+
else:
|
325
|
+
key = None
|
326
|
+
cache.clear(key=key)
|
310
327
|
|
311
328
|
|
312
329
|
def _make_value_key(
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"files": {
|
3
3
|
"main.css": "./static/css/main.bf304093.css",
|
4
|
-
"main.js": "./static/js/main.
|
4
|
+
"main.js": "./static/js/main.81ad100d.js",
|
5
5
|
"static/js/9336.2d95d840.chunk.js": "./static/js/9336.2d95d840.chunk.js",
|
6
6
|
"static/js/9330.d29313d4.chunk.js": "./static/js/9330.d29313d4.chunk.js",
|
7
7
|
"static/js/7217.d970c074.chunk.js": "./static/js/7217.d970c074.chunk.js",
|
@@ -9,7 +9,7 @@
|
|
9
9
|
"static/css/3092.95a45cfe.chunk.css": "./static/css/3092.95a45cfe.chunk.css",
|
10
10
|
"static/js/3092.152fd2b7.chunk.js": "./static/js/3092.152fd2b7.chunk.js",
|
11
11
|
"static/css/43.e3b876c5.chunk.css": "./static/css/43.e3b876c5.chunk.css",
|
12
|
-
"static/js/43.
|
12
|
+
"static/js/43.b0aa5759.chunk.js": "./static/js/43.b0aa5759.chunk.js",
|
13
13
|
"static/js/8427.d30dffe1.chunk.js": "./static/js/8427.d30dffe1.chunk.js",
|
14
14
|
"static/js/7323.2808d029.chunk.js": "./static/js/7323.2808d029.chunk.js",
|
15
15
|
"static/js/4185.935c68ec.chunk.js": "./static/js/4185.935c68ec.chunk.js",
|
@@ -152,6 +152,6 @@
|
|
152
152
|
},
|
153
153
|
"entrypoints": [
|
154
154
|
"static/css/main.bf304093.css",
|
155
|
-
"static/js/main.
|
155
|
+
"static/js/main.81ad100d.js"
|
156
156
|
]
|
157
157
|
}
|
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.81ad100d.js"></script><link href="./static/css/main.bf304093.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";(self.webpackChunk_streamlit_app=self.webpackChunk_streamlit_app||[]).push([[43],{10043:(t,e,o)=>{o.r(e),o.d(e,{default:()=>W});var n=o(66845),i=o(25621),a=o(41558),s=o(95199),r=o(60784),l=o(23849),d=o(62622),c=o(63765),h=o(28391),g=o(96825),u=o.n(g),m=o(99394),f=o.n(m),p=o(92627);function b(t,e){const o={font:e.genericFonts.bodyFont,background:e.colors.bgColor,fieldTitle:"verbal",autosize:{type:"fit",contains:"padding"},title:{align:"left",anchor:"start",color:e.colors.headingColor,titleFontStyle:"normal",fontWeight:e.fontWeights.bold,fontSize:e.fontSizes.smPx+2,orient:"top",offset:26},header:{titleFontWeight:e.fontWeights.normal,titleFontSize:e.fontSizes.mdPx,titleColor:(0,p.Xy)(e),titleFontStyle:"normal",labelFontSize:e.fontSizes.twoSmPx,labelFontWeight:e.fontWeights.normal,labelColor:(0,p.Xy)(e),labelFontStyle:"normal"},axis:{labelFontSize:e.fontSizes.twoSmPx,labelFontWeight:e.fontWeights.normal,labelColor:(0,p.Xy)(e),labelFontStyle:"normal",titleFontWeight:e.fontWeights.normal,titleFontSize:e.fontSizes.smPx,titleColor:(0,p.Xy)(e),titleFontStyle:"normal",ticks:!1,gridColor:(0,p.ny)(e),domain:!1,domainWidth:1,domainColor:(0,p.ny)(e),labelFlush:!0,labelFlushOffset:1,labelBound:!1,labelLimit:100,titlePadding:e.spacing.lgPx,labelPadding:e.spacing.lgPx,labelSeparation:e.spacing.twoXSPx,labelOverlap:!0},legend:{labelFontSize:e.fontSizes.smPx,labelFontWeight:e.fontWeights.normal,labelColor:(0,p.Xy)(e),titleFontSize:e.fontSizes.smPx,titleFontWeight:e.fontWeights.normal,titleFontStyle:"normal",titleColor:(0,p.Xy)(e),titlePadding:5,labelPadding:e.spacing.lgPx,columnPadding:e.spacing.smPx,rowPadding:e.spacing.twoXSPx,padding:7,symbolStrokeWidth:4},range:{category:(0,p.iY)(e),diverging:(0,p.ru)(e),ramp:(0,p.Gy)(e),heatmap:(0,p.Gy)(e)},view:{columns:1,strokeWidth:0,stroke:"transparent",continuousHeight:350,continuousWidth:400,discreteHeight:350,discreteWidth:{step:20}},concat:{columns:1},facet:{columns:1},mark:{tooltip:!0,...(0,p.Iy)(e)?{color:"#0068C9"}:{color:"#83C9FF"}},bar:{binSpacing:e.spacing.twoXSPx,discreteBandSize:{band:.85}},axisDiscrete:{grid:!1},axisXPoint:{grid:!1},axisTemporal:{grid:!1},axisXBand:{grid:!1}};return t?f()({},o,t,((t,e)=>Array.isArray(e)?e:void 0)):o}const y=(0,o(1515).Z)("div",{target:"egd2k5h0"})((t=>{let{theme:e,useContainerWidth:o,isFullScreen:n}=t;return{width:o||n?"100%":"auto",height:n?"100%":"auto","&.vega-embed":{"&:hover summary, .vega-embed:focus summary":{background:"transparent"},"&.has-actions":{paddingRight:0},".vega-actions":{zIndex:e.zIndices.popupMenu,backgroundColor:e.colors.bgColor,boxShadow:"rgb(0 0 0 / 16%) 0px 4px 16px",border:"1px solid ".concat(e.colors.fadedText10),a:{fontFamily:e.genericFonts.bodyFont,fontWeight:e.fontWeights.normal,fontSize:e.fontSizes.md,margin:0,padding:"".concat(e.spacing.twoXS," ").concat(e.spacing.twoXL),color:e.colors.bodyText},"a:hover":{backgroundColor:e.colors.secondaryBg,color:e.colors.bodyText},":before":{content:"none"},":after":{content:"none"}},summary:{opacity:0,height:"auto",zIndex:e.zIndices.menuButton,border:"none",boxShadow:"none",borderRadius:e.radii.lg,color:e.colors.fadedText10,backgroundColor:"transparent",transition:"opacity 300ms 150ms,transform 300ms 150ms","&:active, &:focus-visible, &:hover":{border:"none",boxShadow:"none",color:e.colors.bodyText,opacity:"1 !important",background:e.colors.darkenedBgMix25}}}}}),"");var w=o(40864);const v={DATAFRAME_INDEX:"(index)"},x="source",S=new Set([h.GI.DatetimeIndex,h.GI.Float64Index,h.GI.Int64Index,h.GI.RangeIndex,h.GI.UInt64Index]);class F extends n.PureComponent{constructor(){super(...arguments),this.vegaView=void 0,this.vegaFinalizer=void 0,this.defaultDataName=x,this.element=null,this.state={error:void 0},this.finalizeView=()=>{this.vegaFinalizer&&this.vegaFinalizer(),this.vegaFinalizer=void 0,this.vegaView=void 0},this.generateSpec=()=>{var t,e;const{element:o,theme:n,isFullScreen:i,width:a,height:s}=this.props,r=JSON.parse(o.spec),{useContainerWidth:l}=o;if("streamlit"===o.vegaLiteTheme?r.config=b(r.config,n):"streamlit"===(null===(t=r.usermeta)||void 0===t||null===(e=t.embedOptions)||void 0===e?void 0:e.theme)?(r.config=b(r.config,n),r.usermeta.embedOptions.theme=void 0):r.config=function(t,e){const{colors:o,fontSizes:n,genericFonts:i}=e,a={labelFont:i.bodyFont,titleFont:i.bodyFont,labelFontSize:n.twoSmPx,titleFontSize:n.twoSmPx},s={background:o.bgColor,axis:{labelColor:o.bodyText,titleColor:o.bodyText,gridColor:(0,p.ny)(e),...a},legend:{labelColor:o.bodyText,titleColor:o.bodyText,...a},title:{color:o.bodyText,subtitleColor:o.bodyText,...a},header:{labelColor:o.bodyText,titleColor:o.bodyText,...a},view:{stroke:(0,p.ny)(e),continuousHeight:350,continuousWidth:400,discreteHeight:350,discreteWidth:{step:20}},mark:{tooltip:!0}};return t?u()({},s,t):s}(r.config,n),i?(r.width=a,r.height=s,"vconcat"in r&&r.vconcat.forEach((t=>{t.width=a}))):l&&(r.width=a,"vconcat"in r&&r.vconcat.forEach((t=>{t.width=a}))),r.padding||(r.padding={}),null==r.padding.bottom&&(r.padding.bottom=20),r.datasets)throw new Error("Datasets should not be passed as part of the spec");return r}}async componentDidMount(){try{await this.createView()}catch(t){const e=(0,c.b)(t);this.setState({error:e})}}componentWillUnmount(){this.finalizeView()}async componentDidUpdate(t){const{element:e,theme:o}=t,{element:n,theme:i}=this.props,a=e.spec,{spec:s}=n;if(!this.vegaView||a!==s||o!==i||t.width!==this.props.width||t.height!==this.props.height||t.element.vegaLiteTheme!==this.props.element.vegaLiteTheme){(0,l.ji)("Vega spec changed.");try{await this.createView()}catch(u){const t=(0,c.b)(u);this.setState({error:t})}return}const r=e.data,{data:d}=n;(r||d)&&this.updateData(this.defaultDataName,r,d);const h=z(e)||{},g=z(n)||{};for(const[l,c]of Object.entries(g)){const t=l||this.defaultDataName,e=h[t];this.updateData(t,e,c)}for(const l of Object.keys(h))g.hasOwnProperty(l)||l===this.defaultDataName||this.updateData(l,null,null);this.vegaView.resize().runAsync()}updateData(t,e,o){if(!this.vegaView)throw new Error("Chart has not been drawn yet");if(!o||0===o.data.numRows){return void(this.vegaView._runtime.data.hasOwnProperty(t)&&this.vegaView.remove(t,s.truthy))}if(!e||0===e.data.numRows)return void this.vegaView.insert(t,C(o));const{dataRows:n,dataColumns:i}=e.dimensions,{dataRows:a,dataColumns:r}=o.dimensions;if(function(t,e,o,n,i,a){if(o!==a)return!1;if(e>=i)return!1;if(0===e)return!1;const s=a-1,r=e-1;if(t.getDataValue(0,s)!==n.getDataValue(0,s)||t.getDataValue(r,s)!==n.getDataValue(r,s))return!1;return!0}(e,n,i,o,a,r))n<a&&this.vegaView.insert(t,C(o,n));else{const e=s.changeset().remove(s.truthy).insert(C(o));this.vegaView.change(t,e),(0,l.ji)("Had to clear the ".concat(t," dataset before inserting data through Vega view."))}}async createView(){if((0,l.ji)("Creating a new Vega view."),!this.element)throw Error("Element missing.");this.finalizeView();const t=this.props.element,e=this.generateSpec(),o={ast:!0,expr:r.N,tooltip:{disableDefaultStyle:!0},defaultStyle:!1,forceActionsMenu:!0},{vgSpec:n,view:i,finalize:s}=await(0,a.ZP)(this.element,e,o);this.vegaView=i,this.vegaFinalizer=s;const d=function(t){const e=z(t);if(null==e)return null;const o={};for(const[n,i]of Object.entries(e))o[n]=C(i);return o}(t),c=d?Object.keys(d):[];if(1===c.length){const[t]=c;this.defaultDataName=t}else 0===c.length&&n.data&&(this.defaultDataName=x);const h=function(t){const e=t.data;if(!e||0===e.data.numRows)return null;return C(e)}(t);if(h&&i.insert(this.defaultDataName,h),d)for(const[a,r]of Object.entries(d))i.insert(a,r);await i.runAsync(),this.vegaView.resize().runAsync()}render(){if(this.state.error)throw this.state.error;return(0,w.jsx)(y,{"data-testid":"stArrowVegaLiteChart",useContainerWidth:this.props.element.useContainerWidth,isFullScreen:this.props.isFullScreen,ref:t=>{this.element=t}})}}function z(t){var e;if(0===(null===(e=t.datasets)||void 0===e?void 0:e.length))return null;const o={};return t.datasets.forEach((t=>{if(!t)return;const e=t.hasName?t.name:null;o[e]=t.data})),o}function C(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(t.isEmpty())return[];const o=[],{dataRows:n,dataColumns:i}=t.dimensions,a=h.fu.getTypeName(t.types.index[0]),s=S.has(a);for(let r=e;r<n;r++){const e={};if(s){const o=t.getIndexValue(r,0);e[v.DATAFRAME_INDEX]="bigint"===typeof o?Number(o):o}for(let o=0;o<i;o++){const n=t.getDataValue(r,o),i=t.types.data[o],a=h.fu.getTypeName(i);if("datetimetz"!==a&&(n instanceof Date||Number.isFinite(n))&&(a.startsWith("datetime")||"date"===a)){const i=60*new Date(n).getTimezoneOffset()*1e3;e[t.columns[0][o]]=n.valueOf()+i}else e[t.columns[0][o]]="bigint"===typeof n?Number(n):n}o.push(e)}return o}const W=(0,i.b)((0,d.Z)(F))}}]);
|