ex4nicegui 0.7.1__py3-none-any.whl → 0.8.0__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.
Files changed (30) hide show
  1. ex4nicegui/reactive/EChartsComponent/ECharts.js +2 -3
  2. ex4nicegui/reactive/EChartsComponent/ECharts.py +2 -4
  3. ex4nicegui/reactive/mermaid/mermaid.py +2 -5
  4. ex4nicegui/reactive/mixins/flexLayout.py +51 -0
  5. ex4nicegui/reactive/mixins/value_element.py +27 -0
  6. ex4nicegui/reactive/officials/card.py +32 -2
  7. ex4nicegui/reactive/officials/checkbox.py +7 -11
  8. ex4nicegui/reactive/officials/chip.py +11 -1
  9. ex4nicegui/reactive/officials/circular_progress.py +7 -11
  10. ex4nicegui/reactive/officials/color_picker.py +4 -10
  11. ex4nicegui/reactive/officials/column.py +19 -11
  12. ex4nicegui/reactive/officials/date.py +4 -11
  13. ex4nicegui/reactive/officials/dialog.py +4 -11
  14. ex4nicegui/reactive/officials/echarts.py +9 -7
  15. ex4nicegui/reactive/officials/expansion.py +4 -11
  16. ex4nicegui/reactive/officials/input.py +12 -12
  17. ex4nicegui/reactive/officials/knob.py +4 -13
  18. ex4nicegui/reactive/officials/linear_progress.py +6 -11
  19. ex4nicegui/reactive/officials/number.py +7 -11
  20. ex4nicegui/reactive/officials/radio.py +4 -12
  21. ex4nicegui/reactive/officials/row.py +18 -11
  22. ex4nicegui/reactive/officials/slider.py +4 -12
  23. ex4nicegui/reactive/officials/switch.py +5 -12
  24. ex4nicegui/reactive/officials/tab_panels.py +4 -8
  25. ex4nicegui/reactive/officials/tabs.py +4 -9
  26. ex4nicegui/reactive/officials/textarea.py +4 -10
  27. {ex4nicegui-0.7.1.dist-info → ex4nicegui-0.8.0.dist-info}/METADATA +153 -118
  28. {ex4nicegui-0.7.1.dist-info → ex4nicegui-0.8.0.dist-info}/RECORD +30 -28
  29. {ex4nicegui-0.7.1.dist-info → ex4nicegui-0.8.0.dist-info}/LICENSE +0 -0
  30. {ex4nicegui-0.7.1.dist-info → ex4nicegui-0.8.0.dist-info}/WHEEL +0 -0
@@ -6,18 +6,16 @@ from typing import (
6
6
  from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
7
7
  from ex4nicegui.utils.signals import (
8
8
  _TMaybeRef as TMaybeRef,
9
- to_value,
10
9
  TGetterOrReadonlyRef,
11
10
  )
12
11
  from nicegui import ui
13
12
  from .base import BindableUi, DisableableMixin
14
13
  from ex4nicegui.reactive.mixins.textColor import TextColorableMixin
14
+ from ex4nicegui.reactive.mixins.value_element import ValueElementMixin
15
15
 
16
16
 
17
17
  class KnobBindableUi(
18
- BindableUi[ui.knob],
19
- DisableableMixin,
20
- TextColorableMixin,
18
+ BindableUi[ui.knob], DisableableMixin, TextColorableMixin, ValueElementMixin[float]
21
19
  ):
22
20
  def __init__(
23
21
  self,
@@ -62,16 +60,9 @@ class KnobBindableUi(
62
60
  return self.element.value
63
61
 
64
62
  def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
65
- if prop == "value":
66
- return self.bind_value(value)
63
+ if ValueElementMixin._bind_specified_props(self, prop, value):
64
+ return self
67
65
  if prop == "color":
68
66
  return self.bind_color(value)
69
67
 
70
68
  return super().bind_prop(prop, value)
71
-
72
- def bind_value(self, value: TGetterOrReadonlyRef[float]):
73
- @self._ui_signal_on(value)
74
- def _():
75
- self.element.set_value(to_value(value))
76
-
77
- return self
@@ -5,15 +5,17 @@ from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
5
5
  from ex4nicegui.utils.signals import (
6
6
  TGetterOrReadonlyRef,
7
7
  _TMaybeRef as TMaybeRef,
8
- to_value,
9
8
  )
10
9
  from nicegui import ui
11
10
 
12
11
  from .base import BindableUi
13
12
  from ex4nicegui.reactive.mixins.textColor import TextColorableMixin
13
+ from ex4nicegui.reactive.mixins.value_element import ValueElementMixin
14
14
 
15
15
 
16
- class LinearProgressBindableUi(BindableUi[ui.linear_progress], TextColorableMixin):
16
+ class LinearProgressBindableUi(
17
+ BindableUi[ui.linear_progress], TextColorableMixin, ValueElementMixin[float]
18
+ ):
17
19
  def __init__(
18
20
  self,
19
21
  value: TMaybeRef[float] = 0.0,
@@ -47,17 +49,10 @@ class LinearProgressBindableUi(BindableUi[ui.linear_progress], TextColorableMixi
47
49
  return self.element.value
48
50
 
49
51
  def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
50
- if prop == "value":
51
- return self.bind_value(value)
52
+ if ValueElementMixin._bind_specified_props(self, prop, value):
53
+ return self
52
54
 
53
55
  if prop == "color":
54
56
  return self.bind_color(value)
55
57
 
56
58
  return super().bind_prop(prop, value)
57
-
58
- def bind_value(self, value: TGetterOrReadonlyRef):
59
- @self._ui_signal_on(value)
60
- def _():
61
- self.element.set_value(to_value(value))
62
-
63
- return self
@@ -7,6 +7,7 @@ from typing import (
7
7
  Union,
8
8
  )
9
9
  from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
10
+ from ex4nicegui.reactive.mixins.value_element import ValueElementMixin
10
11
  from ex4nicegui.utils.signals import (
11
12
  TGetterOrReadonlyRef,
12
13
  _TMaybeRef as TMaybeRef,
@@ -22,7 +23,7 @@ def _default_vmodel_args_getter(e):
22
23
  return e.sender.value
23
24
 
24
25
 
25
- class NumberBindableUi(BindableUi[ui.number]):
26
+ class NumberBindableUi(BindableUi[ui.number], ValueElementMixin[Union[float, int]]):
26
27
  def __init__(
27
28
  self,
28
29
  label: Optional[TMaybeRef[str]] = None,
@@ -37,7 +38,9 @@ class NumberBindableUi(BindableUi[ui.number]):
37
38
  suffix: Optional[TMaybeRef[str]] = None,
38
39
  format: Optional[TMaybeRef[str]] = None,
39
40
  on_change: Optional[Callable[..., Any]] = None,
40
- validation: Dict[str, Callable[..., bool]] = {},
41
+ validation: Optional[
42
+ Union[Callable[..., Optional[str]], Dict[str, Callable[..., bool]]]
43
+ ] = None,
41
44
  ) -> None:
42
45
  pc = ParameterClassifier(
43
46
  locals(),
@@ -71,21 +74,14 @@ class NumberBindableUi(BindableUi[ui.number]):
71
74
  return self.element.value
72
75
 
73
76
  def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
74
- if prop == "value":
75
- return self.bind_value(value)
77
+ if ValueElementMixin._bind_specified_props(self, prop, value):
78
+ return self
76
79
 
77
80
  if prop == "precision":
78
81
  return self._bind_precision(value)
79
82
 
80
83
  return super().bind_prop(prop, value)
81
84
 
82
- def bind_value(self, value: TGetterOrReadonlyRef[float]):
83
- @self._ui_signal_on(value)
84
- def _():
85
- self.element.set_value(to_value(value))
86
-
87
- return self
88
-
89
85
  def _bind_precision(self, precision: TGetterOrReadonlyRef[int]):
90
86
  @self._ui_signal_on(precision)
91
87
  def _():
@@ -4,7 +4,6 @@ from typing import (
4
4
  List,
5
5
  Optional,
6
6
  TypeVar,
7
- cast,
8
7
  Dict,
9
8
  Union,
10
9
  )
@@ -15,13 +14,13 @@ from ex4nicegui.utils.signals import (
15
14
  to_value,
16
15
  )
17
16
  from nicegui import ui
18
- from nicegui.elements.mixins.value_element import ValueElement
17
+ from ex4nicegui.reactive.mixins.value_element import ValueElementMixin
19
18
  from .base import BindableUi
20
19
 
21
20
  T = TypeVar("T")
22
21
 
23
22
 
24
- class RadioBindableUi(BindableUi[ui.radio]):
23
+ class RadioBindableUi(BindableUi[ui.radio], ValueElementMixin[Any]):
25
24
  def __init__(
26
25
  self,
27
26
  options: Union[TMaybeRef[List], TMaybeRef[Dict]],
@@ -52,8 +51,8 @@ class RadioBindableUi(BindableUi[ui.radio]):
52
51
  return self.element.value
53
52
 
54
53
  def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
55
- if prop == "value":
56
- return self.bind_value(value)
54
+ if ValueElementMixin._bind_specified_props(self, prop, value):
55
+ return self
57
56
 
58
57
  if prop == "options":
59
58
  return self.bind_options(value)
@@ -66,10 +65,3 @@ class RadioBindableUi(BindableUi[ui.radio]):
66
65
  self.element.set_options(to_value(options))
67
66
 
68
67
  return self
69
-
70
- def bind_value(self, value: TGetterOrReadonlyRef):
71
- @self._ui_signal_on(value)
72
- def _():
73
- cast(ValueElement, self.element).set_value(to_value(value))
74
-
75
- return self
@@ -1,17 +1,25 @@
1
1
  from typing import (
2
2
  Any,
3
+ Literal,
4
+ Optional,
3
5
  )
4
6
  from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
5
- from ex4nicegui.utils.signals import (
6
- _TMaybeRef as TMaybeRef,
7
- )
7
+ from ex4nicegui.reactive.mixins.flexLayout import FlexAlignItemsMixin, FlexWrapMixin
8
+ from ex4nicegui.utils.signals import TMaybeRef
8
9
  from nicegui import ui
9
10
  from .base import BindableUi
10
11
 
11
12
 
12
- class RowBindableUi(BindableUi[ui.row]):
13
- def __init__(self, *, wrap: TMaybeRef[bool] = True) -> None:
14
- pc = ParameterClassifier(locals(), maybeRefs=["wrap"], events=[])
13
+ class RowBindableUi(BindableUi[ui.row], FlexAlignItemsMixin, FlexWrapMixin):
14
+ def __init__(
15
+ self,
16
+ *,
17
+ wrap: TMaybeRef[bool] = True,
18
+ align_items: Optional[
19
+ TMaybeRef[Literal["start", "end", "center", "baseline", "stretch"]]
20
+ ] = None,
21
+ ) -> None:
22
+ pc = ParameterClassifier(locals(), maybeRefs=["wrap", "align_items"], events=[])
15
23
  element = ui.row(**pc.get_values_kws())
16
24
 
17
25
  super().__init__(element)
@@ -19,14 +27,13 @@ class RowBindableUi(BindableUi[ui.row]):
19
27
  self.bind_prop(key, value) # type: ignore
20
28
 
21
29
  def bind_prop(self, prop: str, value: TMaybeRef):
22
- if prop == "wrap":
23
- return self.bind_wrap(value)
30
+ if FlexAlignItemsMixin._bind_specified_props(self, prop, value):
31
+ return self
32
+ if FlexWrapMixin._bind_specified_props(self, prop, value):
33
+ return self
24
34
 
25
35
  return super().bind_prop(prop, value)
26
36
 
27
- def bind_wrap(self, value: TMaybeRef):
28
- self.bind_classes({"wrap": value})
29
-
30
37
  def __enter__(self):
31
38
  self.element.__enter__()
32
39
  return self
@@ -16,14 +16,14 @@ from ex4nicegui.utils.signals import (
16
16
  from nicegui import ui
17
17
  from nicegui.events import handle_event
18
18
  from .base import BindableUi, DisableableMixin
19
+ from ex4nicegui.reactive.mixins.value_element import ValueElementMixin
19
20
 
20
21
 
21
22
  _TSliderValue = TypeVar("_TSliderValue", float, int, None)
22
23
 
23
24
 
24
25
  class SliderBindableUi(
25
- BindableUi[ui.slider],
26
- DisableableMixin,
26
+ BindableUi[ui.slider], DisableableMixin, ValueElementMixin[_TSliderValue]
27
27
  ):
28
28
  def __init__(
29
29
  self,
@@ -59,19 +59,11 @@ class SliderBindableUi(
59
59
  return self.element.value
60
60
 
61
61
  def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
62
- if prop == "value":
63
- return self.bind_value(value)
62
+ if ValueElementMixin._bind_specified_props(self, prop, value):
63
+ return self
64
64
 
65
65
  return super().bind_prop(prop, value)
66
66
 
67
- def bind_value(self, value: TGetterOrReadonlyRef[float]):
68
- @self._ui_signal_on(value)
69
- def _():
70
- self.element.set_value(to_value(value))
71
- self.element.update()
72
-
73
- return self
74
-
75
67
 
76
68
  class LazySliderBindableUi(SliderBindableUi):
77
69
  def __init__(
@@ -8,15 +8,16 @@ from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
8
8
  from ex4nicegui.utils.signals import (
9
9
  TGetterOrReadonlyRef,
10
10
  _TMaybeRef as TMaybeRef,
11
- to_value,
12
11
  )
13
12
  from nicegui import ui
14
13
  from .base import BindableUi
14
+ from ex4nicegui.reactive.mixins.value_element import ValueElementMixin
15
+
15
16
 
16
17
  T = TypeVar("T")
17
18
 
18
19
 
19
- class SwitchBindableUi(BindableUi[ui.switch]):
20
+ class SwitchBindableUi(BindableUi[ui.switch], ValueElementMixin[bool]):
20
21
  def __init__(
21
22
  self,
22
23
  text: TMaybeRef[str] = "",
@@ -47,14 +48,6 @@ class SwitchBindableUi(BindableUi[ui.switch]):
47
48
  return self.element.value
48
49
 
49
50
  def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
50
- if prop == "value":
51
- return self.bind_value(value)
52
-
51
+ if ValueElementMixin._bind_specified_props(self, prop, value):
52
+ return self
53
53
  return super().bind_prop(prop, value)
54
-
55
- def bind_value(self, value: TGetterOrReadonlyRef[bool]):
56
- @self._ui_signal_on(value)
57
- def _():
58
- self.element.set_value(to_value(value))
59
-
60
- return self
@@ -10,9 +10,10 @@ from ex4nicegui.utils.signals import (
10
10
  from ex4nicegui.utils.scheduler import next_tick
11
11
  from nicegui import ui, background_tasks, core
12
12
  from .base import BindableUi
13
+ from ex4nicegui.reactive.mixins.value_element import ValueElementMixin
13
14
 
14
15
 
15
- class TabPanelsBindableUi(BindableUi[ui.tab_panels]):
16
+ class TabPanelsBindableUi(BindableUi[ui.tab_panels], ValueElementMixin[bool]):
16
17
  def __init__(
17
18
  self,
18
19
  value: Optional[TMaybeRef[str]] = None,
@@ -50,16 +51,11 @@ class TabPanelsBindableUi(BindableUi[ui.tab_panels]):
50
51
  return self.element.value
51
52
 
52
53
  def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
53
- if prop == "value":
54
- return self.bind_value(value)
54
+ if ValueElementMixin._bind_specified_props(self, prop, value):
55
+ return self
55
56
 
56
57
  return super().bind_prop(prop, value)
57
58
 
58
- def bind_value(self, value: TGetterOrReadonlyRef):
59
- @self._ui_effect
60
- def _():
61
- self.element.set_value(to_value(value))
62
-
63
59
 
64
60
  class lazy_tab_panel(ui.tab_panel):
65
61
  def __init__(self, name: str) -> None:
@@ -2,14 +2,14 @@ from typing import Any, Callable, Optional
2
2
  from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
3
3
  from ex4nicegui.utils.signals import (
4
4
  TGetterOrReadonlyRef,
5
- to_value,
6
5
  _TMaybeRef as TMaybeRef,
7
6
  )
8
7
  from nicegui import ui
9
8
  from .base import BindableUi
9
+ from ex4nicegui.reactive.mixins.value_element import ValueElementMixin
10
10
 
11
11
 
12
- class TabsBindableUi(BindableUi[ui.tabs]):
12
+ class TabsBindableUi(BindableUi[ui.tabs], ValueElementMixin[str]):
13
13
  def __init__(
14
14
  self,
15
15
  value: Optional[TMaybeRef[str]] = None,
@@ -33,12 +33,7 @@ class TabsBindableUi(BindableUi[ui.tabs]):
33
33
  return self.element.value
34
34
 
35
35
  def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
36
- if prop == "value":
37
- return self.bind_value(value)
36
+ if ValueElementMixin._bind_specified_props(self, prop, value):
37
+ return self
38
38
 
39
39
  return super().bind_prop(prop, value)
40
-
41
- def bind_value(self, value: TGetterOrReadonlyRef):
42
- @self._ui_effect
43
- def _():
44
- self.element.set_value(to_value(value))
@@ -16,9 +16,10 @@ from ex4nicegui.utils.signals import (
16
16
  from nicegui import ui
17
17
  from nicegui.events import handle_event
18
18
  from .base import BindableUi
19
+ from ex4nicegui.reactive.mixins.value_element import ValueElementMixin
19
20
 
20
21
 
21
- class TextareaBindableUi(BindableUi[ui.textarea]):
22
+ class TextareaBindableUi(BindableUi[ui.textarea], ValueElementMixin[str]):
22
23
  def __init__(
23
24
  self,
24
25
  label: Optional[TMaybeRef[str]] = None,
@@ -53,18 +54,11 @@ class TextareaBindableUi(BindableUi[ui.textarea]):
53
54
  return self.element.value
54
55
 
55
56
  def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
56
- if prop == "value":
57
- return self.bind_value(value)
57
+ if ValueElementMixin._bind_specified_props(self, prop, value):
58
+ return self
58
59
 
59
60
  return super().bind_prop(prop, value)
60
61
 
61
- def bind_value(self, value: TGetterOrReadonlyRef[str]):
62
- @self._ui_signal_on(value)
63
- def _():
64
- self.element.set_value(to_value(value))
65
-
66
- return self
67
-
68
62
 
69
63
  class LazyTextareaBindableUi(TextareaBindableUi):
70
64
  def __init__(