streamlit-component-loader 0.7.12__tar.gz → 0.7.13__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: streamlit-component-loader
3
- Version: 0.7.12
3
+ Version: 0.7.13
4
4
  Summary: Components and Frameworks to give new features to streamlit
5
5
  Home-page: https://github.com/quiradev/streamlit-plugins
6
6
  Author: Victor Quilon Ranera
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: streamlit-component-loader
3
- Version: 0.7.12
3
+ Version: 0.7.13
4
4
  Summary: Components and Frameworks to give new features to streamlit
5
5
  Home-page: https://github.com/quiradev/streamlit-plugins
6
6
  Author: Victor Quilon Ranera
@@ -6,6 +6,8 @@ from typing import TypeVar, Callable, Tuple, Optional
6
6
 
7
7
  import streamlit as st
8
8
 
9
+ LOADER_Z_INDEX = 999999
10
+
9
11
  SHOWCASE2_GLOBAL_STYLES = """
10
12
  <style>
11
13
  a{
@@ -476,7 +478,7 @@ SHOWCASE_GLOBAL_STYLES = """
476
478
  flex-wrap: nowrap;
477
479
  justify-content: center;
478
480
  pointer-events: none;
479
- z-index: 999;
481
+ z-index: LOADER_Z_INDEX_1;
480
482
  }
481
483
 
482
484
  .loader-star {
@@ -2403,7 +2405,7 @@ SHOWCASE_GLOBAL_STYLES = """
2403
2405
  }
2404
2406
  }
2405
2407
  </style>
2406
- """
2408
+ """.replace("LOADER_Z_INDEX", str(LOADER_Z_INDEX)).replace("LOADER_Z_INDEX_1", str(LOADER_Z_INDEX-1))
2407
2409
 
2408
2410
 
2409
2411
  def points_line(**kwargs):
@@ -2431,7 +2433,7 @@ def points_line(**kwargs):
2431
2433
  }
2432
2434
  .container {
2433
2435
  text-align: center;
2434
- z-index: 999;
2436
+ z-index: LOADER_Z_INDEX_1;
2435
2437
  }
2436
2438
  section {
2437
2439
  /* width: 30%; */
@@ -2588,7 +2590,7 @@ def grid_points(**kwargs):
2588
2590
  }
2589
2591
  .container {
2590
2592
  text-align: center;
2591
- z-index: 999;
2593
+ z-index: LOADER_Z_INDEX_1;
2592
2594
  }
2593
2595
  section {
2594
2596
  /* width: 30%; */
@@ -2734,7 +2736,7 @@ def pulse_bars(**kwargs):
2734
2736
  }
2735
2737
  .container {
2736
2738
  text-align: center;
2737
- z-index: 999;
2739
+ z-index: LOADER_Z_INDEX_1;
2738
2740
  }
2739
2741
  section {
2740
2742
  /* width: 30%; */
@@ -2858,7 +2860,7 @@ def pacman_loader(**kwargs):
2858
2860
  }
2859
2861
  .container {
2860
2862
  text-align: center;
2861
- z-index: 999;
2863
+ z-index: LOADER_Z_INDEX_1;
2862
2864
  }
2863
2865
  @keyframes ldio-2h0ei997e6j-1 {
2864
2866
  0% { transform: rotate(0deg) }
@@ -3313,7 +3315,7 @@ def standard_loaders(index=0):
3313
3315
  }
3314
3316
  .container {
3315
3317
  text-align: center;
3316
- z-index: 999;
3318
+ z-index: LOADER_Z_INDEX_1;
3317
3319
  }
3318
3320
  section {
3319
3321
  /* width: 30%; */
@@ -3445,7 +3447,7 @@ def book_loader(**kwargs):
3445
3447
  height: 350px;
3446
3448
  /* background: #000000e6; */
3447
3449
  border-radius: 50%;
3448
- z-index: 1000;
3450
+ z-index: LOADER_Z_INDEX;
3449
3451
  }
3450
3452
  .book-parent:after {
3451
3453
  content: "";
@@ -3456,7 +3458,7 @@ def book_loader(**kwargs):
3456
3458
  height: 100vh;
3457
3459
  background: ||-bcolor-||;
3458
3460
  backdrop-filter: blur(2px);
3459
- z-index: 999;
3461
+ z-index: LOADER_Z_INDEX_1;
3460
3462
  }
3461
3463
  .book-container {
3462
3464
  --duration: 6s;
@@ -3469,7 +3471,7 @@ def book_loader(**kwargs):
3469
3471
  flex-wrap: nowrap;
3470
3472
  align-items: center;
3471
3473
  pointer-events: none;
3472
- z-index: 1000;
3474
+ z-index: LOADER_Z_INDEX;
3473
3475
  }
3474
3476
  .book-container .icon {
3475
3477
  position: absolute;
@@ -4414,18 +4416,29 @@ def get_loader(loader_lib: LoadersLib | Callable[..., Tuple[str, str ,str], ], *
4414
4416
  class BaseLoader(ABC):
4415
4417
  LOADER_KEY = 'loader_container'
4416
4418
 
4417
- def __init__(self, loader_container=None, **kwargs):
4418
- if loader_container is None:
4419
- loader_container = st.container(key=self.LOADER_KEY)
4420
- with loader_container:
4421
- st.markdown(
4422
- f"<style>\ndiv:has(>.st-key-{self.LOADER_KEY}){{\nheight: 0; position: absolute;\n}}\n</style>",
4423
- unsafe_allow_html=True
4424
- )
4419
+ def __init__(self, loader_container_key: Optional[str] = None, **kwargs):
4420
+ if loader_container_key is None:
4421
+ loader_container_key = self.LOADER_KEY
4422
+ self.loader_container_key = loader_container_key
4423
+
4424
+ if "loader_container" in kwargs:
4425
+ loader_container = kwargs["loader_container"]
4426
+ else:
4427
+ loader_container = st.container(key=self.loader_container_key)
4428
+
4429
+ with loader_container:
4430
+ st.markdown(
4431
+ f"<style>\ndiv:has(>.st-key-{self.loader_container_key}){{\nheight: 0; position: absolute;left:0;z-index:{LOADER_Z_INDEX-1}\n}}\n</style>",
4432
+ unsafe_allow_html=True
4433
+ )
4425
4434
  self.loader_container = loader_container
4426
4435
 
4427
4436
  def recreate_loader_with(self, **loader_kwargs) -> "LoaderType":
4428
- return self.__class__(loader_container=self.loader_container, **loader_kwargs)
4437
+ return self.__class__(
4438
+ loader_container_key=self.loader_container_key,
4439
+ loader_container=self.loader_container,
4440
+ **loader_kwargs
4441
+ )
4429
4442
 
4430
4443
  @abstractmethod
4431
4444
  def run_loader(self, **kwargs):
@@ -4440,13 +4453,14 @@ LoaderType = TypeVar('LoaderType', bound=BaseLoader)
4440
4453
 
4441
4454
  class DefaultLoader(BaseLoader):
4442
4455
  def __init__(self,
4443
- loader_container=None,
4456
+ loader_container_key: Optional[str] = None,
4444
4457
  label='', height=256,
4445
4458
  primary_color=None, background_color=None,
4446
4459
  loader_lib: LoadersLib | Callable[..., Tuple[str, str ,str], ] = LoadersLib.book_loader, index=0, loader_lib_kwargs: dict = None,
4447
- sleep_animation_time: float = 0.1
4460
+ sleep_animation_time: float = 0.1,
4461
+ **kwargs
4448
4462
  ):
4449
- super().__init__(loader_container=loader_container)
4463
+ super().__init__(loader_container_key=loader_container_key, **kwargs)
4450
4464
  self.sleep_animation_time = sleep_animation_time
4451
4465
  if primary_color is None:
4452
4466
  if st.get_option('theme.primaryColor') is None:
@@ -4479,10 +4493,10 @@ class DefaultLoader(BaseLoader):
4479
4493
 
4480
4494
  loader_div, loader_style, loader_output_style = get_loader(loader_lib, index=index, **loader_lib_kwargs)
4481
4495
  self.loader_div = loader_div
4482
- self.loader_style = loader_style
4496
+ self.loader_style = loader_style.replace("LOADER_Z_INDEX", str(LOADER_Z_INDEX)).replace("LOADER_Z_INDEX_1", str(LOADER_Z_INDEX-1))
4483
4497
 
4484
4498
  self.element_code = loader_div.replace("||-label-||", label)
4485
- self.element_style = loader_style.replace('||-height-||', height_css)
4499
+ self.element_style = self.loader_style.replace('||-height-||', height_css)
4486
4500
  self.element_style = self.element_style.replace('||-pcolor-||', primary_color)
4487
4501
  self.element_style = self.element_style.replace('||-bcolor-||', background_color)
4488
4502