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.
- ex4nicegui/reactive/EChartsComponent/ECharts.js +2 -3
- ex4nicegui/reactive/EChartsComponent/ECharts.py +2 -4
- ex4nicegui/reactive/mermaid/mermaid.py +2 -5
- ex4nicegui/reactive/mixins/flexLayout.py +51 -0
- ex4nicegui/reactive/mixins/value_element.py +27 -0
- ex4nicegui/reactive/officials/card.py +32 -2
- ex4nicegui/reactive/officials/checkbox.py +7 -11
- ex4nicegui/reactive/officials/chip.py +11 -1
- ex4nicegui/reactive/officials/circular_progress.py +7 -11
- ex4nicegui/reactive/officials/color_picker.py +4 -10
- ex4nicegui/reactive/officials/column.py +19 -11
- ex4nicegui/reactive/officials/date.py +4 -11
- ex4nicegui/reactive/officials/dialog.py +4 -11
- ex4nicegui/reactive/officials/echarts.py +9 -7
- ex4nicegui/reactive/officials/expansion.py +4 -11
- ex4nicegui/reactive/officials/input.py +12 -12
- ex4nicegui/reactive/officials/knob.py +4 -13
- ex4nicegui/reactive/officials/linear_progress.py +6 -11
- ex4nicegui/reactive/officials/number.py +7 -11
- ex4nicegui/reactive/officials/radio.py +4 -12
- ex4nicegui/reactive/officials/row.py +18 -11
- ex4nicegui/reactive/officials/slider.py +4 -12
- ex4nicegui/reactive/officials/switch.py +5 -12
- ex4nicegui/reactive/officials/tab_panels.py +4 -8
- ex4nicegui/reactive/officials/tabs.py +4 -9
- ex4nicegui/reactive/officials/textarea.py +4 -10
- {ex4nicegui-0.7.1.dist-info → ex4nicegui-0.8.0.dist-info}/METADATA +153 -118
- {ex4nicegui-0.7.1.dist-info → ex4nicegui-0.8.0.dist-info}/RECORD +30 -28
- {ex4nicegui-0.7.1.dist-info → ex4nicegui-0.8.0.dist-info}/LICENSE +0 -0
- {ex4nicegui-0.7.1.dist-info → ex4nicegui-0.8.0.dist-info}/WHEEL +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import 'echarts'
|
|
1
2
|
import { convertDynamicProperties } from "../../static/utils/dynamic_properties.js";
|
|
2
3
|
|
|
3
4
|
function collectMapRegisterTask() {
|
|
@@ -54,10 +55,8 @@ const mapRegisterTasks = collectMapRegisterTask();
|
|
|
54
55
|
export default {
|
|
55
56
|
template: "<div></div>",
|
|
56
57
|
async mounted() {
|
|
57
|
-
await
|
|
58
|
-
|
|
58
|
+
await new Promise((resolve) => setTimeout(resolve, 0)); // wait for Tailwind classes to be applied
|
|
59
59
|
this.chart = echarts.init(this.$el, this.theme);
|
|
60
|
-
|
|
61
60
|
this.resizeObs = new ResizeObserver(this.chart.resize)
|
|
62
61
|
|
|
63
62
|
// Prevent interruption of chart animations due to resize operations.
|
|
@@ -23,7 +23,7 @@ NG_ROOT = Path(nicegui.__file__).parent / "elements"
|
|
|
23
23
|
libraries = [NG_ROOT / "lib/echarts/echarts.min.js"]
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
class echarts(Element, component="ECharts.js",
|
|
26
|
+
class echarts(Element, component="ECharts.js", dependencies=libraries): # type: ignore
|
|
27
27
|
def __init__(
|
|
28
28
|
self,
|
|
29
29
|
options: Optional[dict] = None,
|
|
@@ -112,7 +112,7 @@ class echarts(Element, component="ECharts.js", libraries=libraries): # type: ig
|
|
|
112
112
|
self.run_method("echarts_on", ui_event_name, query)
|
|
113
113
|
|
|
114
114
|
def run_chart_method(
|
|
115
|
-
self, name: str, *args, timeout: float = 1
|
|
115
|
+
self, name: str, *args, timeout: float = 1
|
|
116
116
|
) -> AwaitableResponse:
|
|
117
117
|
"""Run a method of the JSONEditor instance.
|
|
118
118
|
|
|
@@ -124,7 +124,6 @@ class echarts(Element, component="ECharts.js", libraries=libraries): # type: ig
|
|
|
124
124
|
:param name: name of the method (a prefix ":" indicates that the arguments are JavaScript expressions)
|
|
125
125
|
:param args: arguments to pass to the method (Python objects or JavaScript expressions)
|
|
126
126
|
:param timeout: timeout in seconds (default: 1 second)
|
|
127
|
-
:param check_interval: interval in seconds to check for a response (default: 0.01 seconds)
|
|
128
127
|
|
|
129
128
|
:return: AwaitableResponse that can be awaited to get the result of the method call
|
|
130
129
|
"""
|
|
@@ -133,5 +132,4 @@ class echarts(Element, component="ECharts.js", libraries=libraries): # type: ig
|
|
|
133
132
|
name,
|
|
134
133
|
*args,
|
|
135
134
|
timeout=timeout,
|
|
136
|
-
check_interval=check_interval,
|
|
137
135
|
)
|
|
@@ -10,11 +10,9 @@ NG_ROOT = Path(nicegui.__file__).parent / "elements"
|
|
|
10
10
|
|
|
11
11
|
EX4_LIBS_ROOT = Path(__file__).parent.parent.parent / "libs"
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
dependencies = [
|
|
14
14
|
NG_ROOT / "lib/mermaid/mermaid.esm.min.mjs",
|
|
15
15
|
EX4_LIBS_ROOT / "d3/*.js",
|
|
16
|
-
]
|
|
17
|
-
extra_libraries = [
|
|
18
16
|
NG_ROOT / "lib/mermaid/*.js",
|
|
19
17
|
]
|
|
20
18
|
|
|
@@ -27,8 +25,7 @@ class NodeClickEventArguments(UiEventArguments):
|
|
|
27
25
|
class Mermaid( # type: ignore
|
|
28
26
|
ContentElement,
|
|
29
27
|
component="mermaid.js",
|
|
30
|
-
|
|
31
|
-
extra_libraries=extra_libraries, # type: ignore
|
|
28
|
+
dependencies=dependencies, # type: ignore
|
|
32
29
|
):
|
|
33
30
|
CONTENT_PROP = "content"
|
|
34
31
|
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
from typing import (
|
|
2
|
+
Any,
|
|
3
|
+
Callable,
|
|
4
|
+
Protocol,
|
|
5
|
+
)
|
|
6
|
+
from typing_extensions import Self
|
|
7
|
+
import signe
|
|
8
|
+
from ex4nicegui.utils.signals import to_value, TMaybeRef
|
|
9
|
+
from nicegui import ui
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class FlexWrapMixin(Protocol):
|
|
13
|
+
_ui_signal_on: Callable[[Callable[..., Any]], signe.Effect[None]]
|
|
14
|
+
|
|
15
|
+
@property
|
|
16
|
+
def element(self) -> ui.element:
|
|
17
|
+
...
|
|
18
|
+
|
|
19
|
+
def bind_style(self, classes) -> Self:
|
|
20
|
+
...
|
|
21
|
+
|
|
22
|
+
def bind_wrap(self, value: TMaybeRef[bool]) -> Self:
|
|
23
|
+
return self.bind_style(
|
|
24
|
+
{"flex-wrap": lambda: "wrap" if to_value(value) else "nowrap"}
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
def _bind_specified_props(self, prop: str, value: TMaybeRef[Any]):
|
|
28
|
+
if prop == "wrap":
|
|
29
|
+
return self.bind_wrap(value)
|
|
30
|
+
|
|
31
|
+
return None
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class FlexAlignItemsMixin(Protocol):
|
|
35
|
+
_ui_signal_on: Callable[[Callable[..., Any]], signe.Effect[None]]
|
|
36
|
+
|
|
37
|
+
@property
|
|
38
|
+
def element(self) -> ui.element:
|
|
39
|
+
...
|
|
40
|
+
|
|
41
|
+
def bind_classes(self, classes) -> Self:
|
|
42
|
+
...
|
|
43
|
+
|
|
44
|
+
def bind_align_items(self, value: TMaybeRef[str]):
|
|
45
|
+
return self.bind_classes(lambda: f"items-{to_value(value)}")
|
|
46
|
+
|
|
47
|
+
def _bind_specified_props(self, prop: str, value: TMaybeRef[Any]):
|
|
48
|
+
if prop == "align-items":
|
|
49
|
+
return self.bind_align_items(value)
|
|
50
|
+
|
|
51
|
+
return None
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from typing import Any, Callable, Protocol, Generic, TypeVar
|
|
2
|
+
import signe
|
|
3
|
+
from ex4nicegui.utils.signals import to_value, TMaybeRef
|
|
4
|
+
from nicegui.elements.mixins.value_element import ValueElement
|
|
5
|
+
|
|
6
|
+
T = TypeVar("T", contravariant=True)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ValueElementMixin(Protocol, Generic[T]):
|
|
10
|
+
_ui_signal_on: Callable[[Callable[..., Any]], signe.Effect[None]]
|
|
11
|
+
|
|
12
|
+
@property
|
|
13
|
+
def element(self) -> ValueElement:
|
|
14
|
+
...
|
|
15
|
+
|
|
16
|
+
def bind_value(self, value: TMaybeRef[T]):
|
|
17
|
+
@self._ui_signal_on(value) # type: ignore
|
|
18
|
+
def _():
|
|
19
|
+
self.element.set_value(to_value(value))
|
|
20
|
+
|
|
21
|
+
return self
|
|
22
|
+
|
|
23
|
+
def _bind_specified_props(self, prop: str, value: TMaybeRef[T]):
|
|
24
|
+
if prop == "value":
|
|
25
|
+
return self.bind_value(value)
|
|
26
|
+
|
|
27
|
+
return None
|
|
@@ -1,18 +1,48 @@
|
|
|
1
1
|
from typing import (
|
|
2
2
|
Any,
|
|
3
|
+
Literal,
|
|
4
|
+
Optional,
|
|
3
5
|
)
|
|
4
6
|
from nicegui import ui
|
|
5
7
|
from .base import BindableUi
|
|
8
|
+
from ex4nicegui.reactive.mixins.flexLayout import FlexAlignItemsMixin
|
|
9
|
+
from ex4nicegui.utils.signals import TMaybeRef
|
|
10
|
+
from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
|
|
6
11
|
|
|
7
12
|
|
|
8
|
-
class CardBindableUi(BindableUi[ui.card]):
|
|
13
|
+
class CardBindableUi(BindableUi[ui.card], FlexAlignItemsMixin):
|
|
9
14
|
def __init__(
|
|
10
15
|
self,
|
|
16
|
+
align_items: Optional[
|
|
17
|
+
TMaybeRef[Literal["start", "end", "center", "baseline", "stretch"]]
|
|
18
|
+
] = None,
|
|
11
19
|
) -> None:
|
|
12
|
-
|
|
20
|
+
"""Card
|
|
21
|
+
|
|
22
|
+
This element is based on Quasar's `QCard <https://quasar.dev/vue-components/card>`_ component.
|
|
23
|
+
It provides a container with a dropped shadow.
|
|
24
|
+
|
|
25
|
+
Note:
|
|
26
|
+
In contrast to this element,
|
|
27
|
+
the original QCard has no padding by default and hides outer borders and shadows of nested elements.
|
|
28
|
+
If you want the original behavior, use the `tight` method.
|
|
29
|
+
|
|
30
|
+
:param align_items: alignment of the items in the card ("start", "end", "center", "baseline", or "stretch"; default: `None`)
|
|
31
|
+
"""
|
|
32
|
+
pc = ParameterClassifier(locals(), maybeRefs=["wrap", "align_items"], events=[])
|
|
33
|
+
element = ui.card(**pc.get_values_kws())
|
|
13
34
|
|
|
14
35
|
super().__init__(element)
|
|
15
36
|
|
|
37
|
+
for key, value in pc.get_bindings().items():
|
|
38
|
+
self.bind_prop(key, value) # type: ignore
|
|
39
|
+
|
|
40
|
+
def bind_prop(self, prop: str, value: TMaybeRef):
|
|
41
|
+
if FlexAlignItemsMixin._bind_specified_props(self, prop, value):
|
|
42
|
+
return self
|
|
43
|
+
|
|
44
|
+
return super().bind_prop(prop, value)
|
|
45
|
+
|
|
16
46
|
def __enter__(self):
|
|
17
47
|
self.element.__enter__()
|
|
18
48
|
return self
|
|
@@ -8,15 +8,18 @@ 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, DisableableMixin
|
|
14
|
+
from ex4nicegui.reactive.mixins.value_element import ValueElementMixin
|
|
15
|
+
|
|
15
16
|
|
|
16
17
|
T = TypeVar("T")
|
|
17
18
|
|
|
18
19
|
|
|
19
|
-
class CheckboxBindableUi(
|
|
20
|
+
class CheckboxBindableUi(
|
|
21
|
+
BindableUi[ui.checkbox], DisableableMixin, ValueElementMixin[bool]
|
|
22
|
+
):
|
|
20
23
|
def __init__(
|
|
21
24
|
self,
|
|
22
25
|
text: TMaybeRef[str] = "",
|
|
@@ -44,14 +47,7 @@ class CheckboxBindableUi(BindableUi[ui.checkbox], DisableableMixin):
|
|
|
44
47
|
return self.element.value
|
|
45
48
|
|
|
46
49
|
def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
|
|
47
|
-
if prop
|
|
48
|
-
return self
|
|
50
|
+
if ValueElementMixin._bind_specified_props(self, prop, value):
|
|
51
|
+
return self
|
|
49
52
|
|
|
50
53
|
return super().bind_prop(prop, value)
|
|
51
|
-
|
|
52
|
-
def bind_value(self, value: TGetterOrReadonlyRef[bool]):
|
|
53
|
-
@self._ui_signal_on(value)
|
|
54
|
-
def _():
|
|
55
|
-
self.element.set_value(to_value(value))
|
|
56
|
-
|
|
57
|
-
return self
|
|
@@ -9,12 +9,14 @@ from nicegui import ui
|
|
|
9
9
|
from .base import BindableUi
|
|
10
10
|
from ex4nicegui.reactive.mixins.backgroundColor import BackgroundColorableMixin
|
|
11
11
|
from ex4nicegui.reactive.mixins.textColor import TextColorableMixin
|
|
12
|
+
from ex4nicegui.reactive.mixins.value_element import ValueElementMixin
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
class ChipBindableUi(
|
|
15
16
|
BindableUi[ui.chip],
|
|
16
17
|
BackgroundColorableMixin,
|
|
17
18
|
TextColorableMixin,
|
|
19
|
+
ValueElementMixin[bool],
|
|
18
20
|
):
|
|
19
21
|
def __init__(
|
|
20
22
|
self,
|
|
@@ -29,6 +31,7 @@ class ChipBindableUi(
|
|
|
29
31
|
on_selection_change: Optional[Callable[..., Any]] = None,
|
|
30
32
|
removable: TMaybeRef[bool] = False,
|
|
31
33
|
on_value_change: Optional[Callable[..., Any]] = None,
|
|
34
|
+
value: TMaybeRef[bool] = True,
|
|
32
35
|
) -> None:
|
|
33
36
|
pc = ParameterClassifier(
|
|
34
37
|
locals(),
|
|
@@ -40,11 +43,15 @@ class ChipBindableUi(
|
|
|
40
43
|
"selectable",
|
|
41
44
|
"selected",
|
|
42
45
|
"removable",
|
|
46
|
+
"value",
|
|
43
47
|
],
|
|
48
|
+
v_model=("value", "on_value_change"),
|
|
44
49
|
events=["on_click", "on_selection_change", "on_value_change"],
|
|
45
50
|
)
|
|
46
51
|
|
|
47
|
-
|
|
52
|
+
kws = pc.get_values_kws()
|
|
53
|
+
kws.pop("value", None)
|
|
54
|
+
element = ui.chip(**kws)
|
|
48
55
|
super().__init__(element)
|
|
49
56
|
|
|
50
57
|
for key, value in pc.get_bindings().items():
|
|
@@ -55,6 +62,9 @@ class ChipBindableUi(
|
|
|
55
62
|
return self.element.text
|
|
56
63
|
|
|
57
64
|
def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
|
|
65
|
+
if ValueElementMixin._bind_specified_props(self, prop, value):
|
|
66
|
+
return self
|
|
67
|
+
|
|
58
68
|
if prop == "text":
|
|
59
69
|
return self.bind_text(value)
|
|
60
70
|
|
|
@@ -6,15 +6,18 @@ from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
|
|
|
6
6
|
from ex4nicegui.utils.signals import (
|
|
7
7
|
TGetterOrReadonlyRef,
|
|
8
8
|
_TMaybeRef as TMaybeRef,
|
|
9
|
-
to_value,
|
|
10
9
|
)
|
|
11
10
|
from nicegui import ui
|
|
12
11
|
from .base import BindableUi, DisableableMixin
|
|
13
12
|
from ex4nicegui.reactive.mixins.backgroundColor import BackgroundColorableMixin
|
|
13
|
+
from ex4nicegui.reactive.mixins.value_element import ValueElementMixin
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
class CircularProgressBindableUi(
|
|
17
|
-
BindableUi[ui.circular_progress],
|
|
17
|
+
BindableUi[ui.circular_progress],
|
|
18
|
+
DisableableMixin,
|
|
19
|
+
BackgroundColorableMixin,
|
|
20
|
+
ValueElementMixin[float],
|
|
18
21
|
):
|
|
19
22
|
def __init__(
|
|
20
23
|
self,
|
|
@@ -50,16 +53,9 @@ class CircularProgressBindableUi(
|
|
|
50
53
|
return self.element.value
|
|
51
54
|
|
|
52
55
|
def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
|
|
53
|
-
if prop
|
|
54
|
-
return self
|
|
56
|
+
if ValueElementMixin._bind_specified_props(self, prop, value):
|
|
57
|
+
return self
|
|
55
58
|
if prop == "color":
|
|
56
59
|
return self.bind_color(value)
|
|
57
60
|
|
|
58
61
|
return super().bind_prop(prop, value)
|
|
59
|
-
|
|
60
|
-
def bind_value(self, value: TGetterOrReadonlyRef[float]):
|
|
61
|
-
@self._ui_signal_on(value)
|
|
62
|
-
def _():
|
|
63
|
-
self.element.set_value(to_value(value))
|
|
64
|
-
|
|
65
|
-
return self
|
|
@@ -5,6 +5,7 @@ from typing import (
|
|
|
5
5
|
cast,
|
|
6
6
|
)
|
|
7
7
|
from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
|
|
8
|
+
from ex4nicegui.reactive.mixins.value_element import ValueElementMixin
|
|
8
9
|
|
|
9
10
|
from ex4nicegui.utils.signals import (
|
|
10
11
|
TGetterOrReadonlyRef,
|
|
@@ -18,7 +19,7 @@ from nicegui.events import handle_event
|
|
|
18
19
|
from .base import BindableUi
|
|
19
20
|
|
|
20
21
|
|
|
21
|
-
class ColorPickerBindableUi(BindableUi[ui.color_picker]):
|
|
22
|
+
class ColorPickerBindableUi(BindableUi[ui.color_picker], ValueElementMixin[bool]):
|
|
22
23
|
def __init__(
|
|
23
24
|
self,
|
|
24
25
|
color: TMaybeRef[str] = "",
|
|
@@ -69,8 +70,8 @@ class ColorPickerBindableUi(BindableUi[ui.color_picker]):
|
|
|
69
70
|
return self.element.value
|
|
70
71
|
|
|
71
72
|
def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
|
|
72
|
-
if prop
|
|
73
|
-
return self
|
|
73
|
+
if ValueElementMixin._bind_specified_props(self, prop, value):
|
|
74
|
+
return self
|
|
74
75
|
|
|
75
76
|
return super().bind_prop(prop, value)
|
|
76
77
|
|
|
@@ -81,13 +82,6 @@ class ColorPickerBindableUi(BindableUi[ui.color_picker]):
|
|
|
81
82
|
|
|
82
83
|
return self
|
|
83
84
|
|
|
84
|
-
def bind_value(self, value: TGetterOrReadonlyRef[bool]):
|
|
85
|
-
@self._ui_signal_on(value)
|
|
86
|
-
def _():
|
|
87
|
-
self.element.set_value(to_value(value))
|
|
88
|
-
|
|
89
|
-
return self
|
|
90
|
-
|
|
91
85
|
|
|
92
86
|
class ColorPickerLazyBindableUi(ColorPickerBindableUi):
|
|
93
87
|
def __init__(
|
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
from typing import (
|
|
2
2
|
Any,
|
|
3
|
+
Literal,
|
|
4
|
+
Optional,
|
|
3
5
|
)
|
|
4
6
|
from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
|
|
7
|
+
from ex4nicegui.reactive.mixins.flexLayout import FlexAlignItemsMixin, FlexWrapMixin
|
|
5
8
|
from ex4nicegui.utils.signals import (
|
|
6
|
-
|
|
7
|
-
_TMaybeRef as TMaybeRef,
|
|
9
|
+
TMaybeRef,
|
|
8
10
|
)
|
|
9
11
|
from nicegui import ui
|
|
10
12
|
from .base import BindableUi
|
|
11
13
|
|
|
12
14
|
|
|
13
|
-
class ColumnBindableUi(BindableUi[ui.column]):
|
|
14
|
-
def __init__(
|
|
15
|
-
|
|
15
|
+
class ColumnBindableUi(BindableUi[ui.column], FlexAlignItemsMixin, FlexWrapMixin):
|
|
16
|
+
def __init__(
|
|
17
|
+
self,
|
|
18
|
+
*,
|
|
19
|
+
wrap: TMaybeRef[bool] = True,
|
|
20
|
+
align_items: Optional[
|
|
21
|
+
TMaybeRef[Literal["start", "end", "center", "baseline", "stretch"]]
|
|
22
|
+
] = None,
|
|
23
|
+
) -> None:
|
|
24
|
+
pc = ParameterClassifier(locals(), maybeRefs=["wrap", "align_items"], events=[])
|
|
16
25
|
element = ui.column(**pc.get_values_kws())
|
|
17
26
|
|
|
18
27
|
super().__init__(element)
|
|
@@ -20,15 +29,14 @@ class ColumnBindableUi(BindableUi[ui.column]):
|
|
|
20
29
|
for key, value in pc.get_bindings().items():
|
|
21
30
|
self.bind_prop(key, value) # type: ignore
|
|
22
31
|
|
|
23
|
-
def bind_prop(self, prop: str, value:
|
|
24
|
-
if prop
|
|
25
|
-
return self
|
|
32
|
+
def bind_prop(self, prop: str, value: TMaybeRef):
|
|
33
|
+
if FlexAlignItemsMixin._bind_specified_props(self, prop, value):
|
|
34
|
+
return self
|
|
35
|
+
if FlexWrapMixin._bind_specified_props(self, prop, value):
|
|
36
|
+
return self
|
|
26
37
|
|
|
27
38
|
return super().bind_prop(prop, value)
|
|
28
39
|
|
|
29
|
-
def bind_wrap(self, value: TGetterOrReadonlyRef):
|
|
30
|
-
self.bind_classes({"wrap": value})
|
|
31
|
-
|
|
32
40
|
def __enter__(self):
|
|
33
41
|
self.element.__enter__()
|
|
34
42
|
return self
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
from typing import Any, Callable, List, Optional, TypeVar
|
|
2
2
|
from typing_extensions import TypedDict
|
|
3
3
|
from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
|
|
4
|
+
from ex4nicegui.reactive.mixins.value_element import ValueElementMixin
|
|
4
5
|
|
|
5
6
|
from ex4nicegui.utils.signals import (
|
|
6
7
|
TGetterOrReadonlyRef,
|
|
7
8
|
_TMaybeRef as TMaybeRef,
|
|
8
|
-
to_value,
|
|
9
9
|
)
|
|
10
10
|
from nicegui import ui
|
|
11
11
|
from .base import BindableUi
|
|
@@ -18,7 +18,7 @@ _TDateValue = TypeVar(
|
|
|
18
18
|
)
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
class DateBindableUi(BindableUi[ui.date]):
|
|
21
|
+
class DateBindableUi(BindableUi[ui.date], ValueElementMixin[_TDateValue]):
|
|
22
22
|
def __init__(
|
|
23
23
|
self,
|
|
24
24
|
value: Optional[TMaybeRef[_TDateValue]] = None,
|
|
@@ -63,14 +63,7 @@ class DateBindableUi(BindableUi[ui.date]):
|
|
|
63
63
|
return self.element.value
|
|
64
64
|
|
|
65
65
|
def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
|
|
66
|
-
if prop
|
|
67
|
-
return self
|
|
66
|
+
if ValueElementMixin._bind_specified_props(self, prop, value):
|
|
67
|
+
return self
|
|
68
68
|
|
|
69
69
|
return super().bind_prop(prop, value)
|
|
70
|
-
|
|
71
|
-
def bind_value(self, value: TGetterOrReadonlyRef[bool]):
|
|
72
|
-
@self._ui_signal_on(value)
|
|
73
|
-
def _():
|
|
74
|
-
self.element.set_value(to_value(value))
|
|
75
|
-
|
|
76
|
-
return self
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
|
|
2
|
+
from ex4nicegui.reactive.mixins.value_element import ValueElementMixin
|
|
2
3
|
from ex4nicegui.utils.signals import (
|
|
3
4
|
_TMaybeRef as TMaybeRef,
|
|
4
5
|
is_setter_ref,
|
|
5
|
-
to_value,
|
|
6
6
|
TGetterOrReadonlyRef,
|
|
7
7
|
)
|
|
8
8
|
from nicegui import ui
|
|
9
9
|
from .base import BindableUi
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
class DialogBindableUi(BindableUi[ui.dialog]):
|
|
12
|
+
class DialogBindableUi(BindableUi[ui.dialog], ValueElementMixin[bool]):
|
|
13
13
|
def __init__(
|
|
14
14
|
self,
|
|
15
15
|
*,
|
|
@@ -36,14 +36,7 @@ class DialogBindableUi(BindableUi[ui.dialog]):
|
|
|
36
36
|
return self.element.value
|
|
37
37
|
|
|
38
38
|
def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
|
|
39
|
-
if prop
|
|
40
|
-
return self
|
|
39
|
+
if ValueElementMixin._bind_specified_props(self, prop, value):
|
|
40
|
+
return self
|
|
41
41
|
|
|
42
42
|
return super().bind_prop(prop, value)
|
|
43
|
-
|
|
44
|
-
def bind_value(self, value: TGetterOrReadonlyRef[float]):
|
|
45
|
-
@self._ui_signal_on(value)
|
|
46
|
-
def _():
|
|
47
|
-
self.element.set_value(to_value(value))
|
|
48
|
-
|
|
49
|
-
return self
|
|
@@ -34,7 +34,7 @@ class EChartsBindableUi(BindableUi[echarts]):
|
|
|
34
34
|
|
|
35
35
|
value_kws = pc.get_values_kws()
|
|
36
36
|
|
|
37
|
-
element = echarts(**value_kws).classes("
|
|
37
|
+
element = echarts(**value_kws).classes("nicegui-echart")
|
|
38
38
|
|
|
39
39
|
super().__init__(element) # type: ignore
|
|
40
40
|
|
|
@@ -94,13 +94,14 @@ class EChartsBindableUi(BindableUi[echarts]):
|
|
|
94
94
|
|
|
95
95
|
@classmethod
|
|
96
96
|
def from_pyecharts(cls, chart: TMaybeRef):
|
|
97
|
-
if is_ref(chart):
|
|
97
|
+
if is_ref(chart) or callable(chart):
|
|
98
98
|
|
|
99
99
|
@ref_computed
|
|
100
100
|
def chart_opt():
|
|
101
|
-
|
|
101
|
+
chart_value = to_value(chart)
|
|
102
|
+
if not bool(chart_value):
|
|
102
103
|
return {}
|
|
103
|
-
return PyechartsUtils._chart2opts(
|
|
104
|
+
return PyechartsUtils._chart2opts(chart_value)
|
|
104
105
|
|
|
105
106
|
return cls(chart_opt)
|
|
106
107
|
|
|
@@ -228,7 +229,10 @@ class EChartsBindableUi(BindableUi[echarts]):
|
|
|
228
229
|
return self
|
|
229
230
|
|
|
230
231
|
def run_chart_method(
|
|
231
|
-
self,
|
|
232
|
+
self,
|
|
233
|
+
name: str,
|
|
234
|
+
*args,
|
|
235
|
+
timeout: float = 1,
|
|
232
236
|
) -> AwaitableResponse:
|
|
233
237
|
"""Run a method of the JSONEditor instance.
|
|
234
238
|
|
|
@@ -240,7 +244,6 @@ class EChartsBindableUi(BindableUi[echarts]):
|
|
|
240
244
|
:param name: name of the method (a prefix ":" indicates that the arguments are JavaScript expressions)
|
|
241
245
|
:param args: arguments to pass to the method (Python objects or JavaScript expressions)
|
|
242
246
|
:param timeout: timeout in seconds (default: 1 second)
|
|
243
|
-
:param check_interval: interval in seconds to check for a response (default: 0.01 seconds)
|
|
244
247
|
|
|
245
248
|
:return: AwaitableResponse that can be awaited to get the result of the method call
|
|
246
249
|
"""
|
|
@@ -248,7 +251,6 @@ class EChartsBindableUi(BindableUi[echarts]):
|
|
|
248
251
|
name,
|
|
249
252
|
*args,
|
|
250
253
|
timeout=timeout,
|
|
251
|
-
check_interval=check_interval,
|
|
252
254
|
)
|
|
253
255
|
|
|
254
256
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
from typing import Any, Optional, Callable
|
|
2
2
|
from nicegui import ui
|
|
3
3
|
from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
|
|
4
|
+
from ex4nicegui.reactive.mixins.value_element import ValueElementMixin
|
|
4
5
|
from ex4nicegui.utils.signals import (
|
|
5
6
|
TGetterOrReadonlyRef,
|
|
6
7
|
_TMaybeRef as TMaybeRef,
|
|
7
|
-
to_value,
|
|
8
8
|
)
|
|
9
9
|
from .base import BindableUi
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
class ExpansionBindableUi(BindableUi[ui.expansion]):
|
|
12
|
+
class ExpansionBindableUi(BindableUi[ui.expansion], ValueElementMixin[bool]):
|
|
13
13
|
def __init__(
|
|
14
14
|
self,
|
|
15
15
|
text: Optional[TMaybeRef[str]] = None,
|
|
@@ -46,18 +46,11 @@ class ExpansionBindableUi(BindableUi[ui.expansion]):
|
|
|
46
46
|
return self.element.value
|
|
47
47
|
|
|
48
48
|
def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
|
|
49
|
-
if prop
|
|
50
|
-
return self
|
|
49
|
+
if ValueElementMixin._bind_specified_props(self, prop, value):
|
|
50
|
+
return self
|
|
51
51
|
|
|
52
52
|
return super().bind_prop(prop, value)
|
|
53
53
|
|
|
54
|
-
def bind_value(self, value: TGetterOrReadonlyRef):
|
|
55
|
-
@self._ui_signal_on(value)
|
|
56
|
-
def _():
|
|
57
|
-
self.element.set_value(to_value(value))
|
|
58
|
-
|
|
59
|
-
return self
|
|
60
|
-
|
|
61
54
|
def __enter__(self):
|
|
62
55
|
self.element.__enter__()
|
|
63
56
|
return self
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Any, Callable, List, Optional, Dict, cast
|
|
1
|
+
from typing import Any, Callable, List, Optional, Dict, Union, cast
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
from ex4nicegui.utils.signals import (
|
|
@@ -13,9 +13,14 @@ from nicegui import ui
|
|
|
13
13
|
from nicegui.events import handle_event
|
|
14
14
|
from .base import BindableUi, DisableableMixin
|
|
15
15
|
from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
|
|
16
|
+
from ex4nicegui.reactive.mixins.value_element import ValueElementMixin
|
|
16
17
|
|
|
17
18
|
|
|
18
|
-
class InputBindableUi(
|
|
19
|
+
class InputBindableUi(
|
|
20
|
+
BindableUi[ui.input],
|
|
21
|
+
DisableableMixin,
|
|
22
|
+
ValueElementMixin[str],
|
|
23
|
+
):
|
|
19
24
|
def __init__(
|
|
20
25
|
self,
|
|
21
26
|
label: Optional[TMaybeRef[str]] = None,
|
|
@@ -26,7 +31,9 @@ class InputBindableUi(BindableUi[ui.input], DisableableMixin):
|
|
|
26
31
|
password_toggle_button: TMaybeRef[bool] = False,
|
|
27
32
|
on_change: Optional[Callable[..., Any]] = None,
|
|
28
33
|
autocomplete: Optional[TMaybeRef[List[str]]] = None,
|
|
29
|
-
validation:
|
|
34
|
+
validation: Optional[
|
|
35
|
+
Union[Callable[..., Optional[str]], Dict[str, Callable[..., bool]]]
|
|
36
|
+
] = None,
|
|
30
37
|
) -> None:
|
|
31
38
|
pc = ParameterClassifier(
|
|
32
39
|
locals(),
|
|
@@ -52,20 +59,13 @@ class InputBindableUi(BindableUi[ui.input], DisableableMixin):
|
|
|
52
59
|
self.bind_prop(key, value) # type: ignore
|
|
53
60
|
|
|
54
61
|
def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
|
|
55
|
-
if prop
|
|
56
|
-
return self
|
|
62
|
+
if ValueElementMixin._bind_specified_props(self, prop, value):
|
|
63
|
+
return self
|
|
57
64
|
if prop == "password":
|
|
58
65
|
return self.bind_password(value)
|
|
59
66
|
|
|
60
67
|
return super().bind_prop(prop, value)
|
|
61
68
|
|
|
62
|
-
def bind_value(self, value: TGetterOrReadonlyRef[str]):
|
|
63
|
-
@self._ui_signal_on(value)
|
|
64
|
-
def _():
|
|
65
|
-
self.element.set_value(to_value(value))
|
|
66
|
-
|
|
67
|
-
return self
|
|
68
|
-
|
|
69
69
|
def bind_password(self, password: TGetterOrReadonlyRef[bool]):
|
|
70
70
|
@self._ui_signal_on(password)
|
|
71
71
|
def _():
|