ex4nicegui 0.6.7__py3-none-any.whl → 0.6.8__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/__init__.py +10 -6
- ex4nicegui/gsap/__init__.py +11 -0
- ex4nicegui/helper/__init__.py +4 -0
- ex4nicegui/helper/client_instance_locker.py +31 -0
- ex4nicegui/reactive/local_file_picker.py +1 -2
- ex4nicegui/reactive/officials/aggrid.py +4 -4
- ex4nicegui/reactive/officials/base.py +188 -86
- ex4nicegui/reactive/officials/button.py +1 -1
- ex4nicegui/reactive/officials/checkbox.py +2 -3
- ex4nicegui/reactive/officials/circular_progress.py +2 -3
- ex4nicegui/reactive/officials/color_picker.py +3 -4
- ex4nicegui/reactive/officials/column.py +1 -1
- ex4nicegui/reactive/officials/date.py +2 -3
- ex4nicegui/reactive/officials/drawer.py +2 -3
- ex4nicegui/reactive/officials/echarts.py +2 -3
- ex4nicegui/reactive/officials/expansion.py +2 -3
- ex4nicegui/reactive/officials/grid.py +1 -1
- ex4nicegui/reactive/officials/html.py +1 -3
- ex4nicegui/reactive/officials/icon.py +5 -6
- ex4nicegui/reactive/officials/image.py +2 -4
- ex4nicegui/reactive/officials/input.py +4 -6
- ex4nicegui/reactive/officials/knob.py +2 -4
- ex4nicegui/reactive/officials/label.py +1 -1
- ex4nicegui/reactive/officials/linear_progress.py +5 -6
- ex4nicegui/reactive/officials/number.py +3 -6
- ex4nicegui/reactive/officials/radio.py +3 -5
- ex4nicegui/reactive/officials/row.py +1 -1
- ex4nicegui/reactive/officials/select.py +3 -5
- ex4nicegui/reactive/officials/slider.py +3 -5
- ex4nicegui/reactive/officials/switch.py +2 -4
- ex4nicegui/reactive/officials/tab.py +1 -1
- ex4nicegui/reactive/officials/tab_panel.py +1 -1
- ex4nicegui/reactive/officials/tab_panels.py +1 -1
- ex4nicegui/reactive/officials/table.py +7 -6
- ex4nicegui/reactive/officials/tabs.py +1 -1
- ex4nicegui/reactive/officials/textarea.py +3 -5
- ex4nicegui/reactive/officials/upload.py +2 -2
- ex4nicegui/reactive/q_pagination.py +2 -2
- ex4nicegui/reactive/scopedStyle.js +55 -0
- ex4nicegui/reactive/scopedStyle.py +22 -0
- ex4nicegui/reactive/services/color_service.py +56 -0
- ex4nicegui/reactive/services/pandas_service.py +31 -0
- ex4nicegui/reactive/{utils.py → services/reactive_service.py} +9 -67
- ex4nicegui/reactive/systems/color_system.py +25 -0
- ex4nicegui/reactive/systems/object_system.py +33 -0
- ex4nicegui/reactive/systems/reactive_system.py +21 -0
- ex4nicegui/reactive/useMouse/UseMouse.py +4 -4
- ex4nicegui/reactive/usePagination.py +1 -1
- ex4nicegui/reactive/vfor.py +1 -2
- ex4nicegui/reactive/vmodel.py +1 -1
- ex4nicegui/utils/refComputed.py +147 -0
- ex4nicegui/utils/refWrapper.py +57 -0
- ex4nicegui/utils/signals.py +51 -192
- ex4nicegui/utils/types.py +16 -0
- ex4nicegui/version.py +3 -0
- {ex4nicegui-0.6.7.dist-info → ex4nicegui-0.6.8.dist-info}/METADATA +33 -4
- {ex4nicegui-0.6.7.dist-info → ex4nicegui-0.6.8.dist-info}/RECORD +59 -53
- ex4nicegui/reactive/EChartsComponent/__init__.py +0 -0
- ex4nicegui/reactive/UseDraggable/__init__.py +0 -0
- ex4nicegui/reactive/dropZone/__init__.py +0 -0
- ex4nicegui/reactive/mermaid/__init__.py +0 -0
- ex4nicegui/reactive/officials/__init__.py +0 -1
- ex4nicegui/reactive/officials/utils.py +0 -11
- ex4nicegui/reactive/useMouse/__init__.py +0 -0
- {ex4nicegui-0.6.7.dist-info → ex4nicegui-0.6.8.dist-info}/LICENSE +0 -0
- {ex4nicegui-0.6.7.dist-info → ex4nicegui-0.6.8.dist-info}/WHEEL +0 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
from typing import Any, Optional, Callable
|
|
2
2
|
from nicegui import ui
|
|
3
|
-
from ex4nicegui.reactive.
|
|
4
|
-
from ex4nicegui.utils.apiEffect import ui_effect
|
|
3
|
+
from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
|
|
5
4
|
from ex4nicegui.utils.signals import (
|
|
6
5
|
TGetterOrReadonlyRef,
|
|
7
6
|
_TMaybeRef as TMaybeRef,
|
|
@@ -53,7 +52,7 @@ class ExpansionBindableUi(BindableUi[ui.expansion]):
|
|
|
53
52
|
return super().bind_prop(prop, ref_ui)
|
|
54
53
|
|
|
55
54
|
def bind_value(self, ref_ui: TGetterOrReadonlyRef):
|
|
56
|
-
@
|
|
55
|
+
@self._ui_effect
|
|
57
56
|
def _():
|
|
58
57
|
self.element.set_value(to_value(ref_ui))
|
|
59
58
|
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
from ex4nicegui.utils.apiEffect import ui_effect
|
|
2
|
-
|
|
3
1
|
from ex4nicegui.utils.signals import (
|
|
4
2
|
_TMaybeRef as TMaybeRef,
|
|
5
3
|
to_value,
|
|
@@ -20,7 +18,7 @@ class html(BindableUi[HtmlComponent]):
|
|
|
20
18
|
|
|
21
19
|
super().__init__(element)
|
|
22
20
|
|
|
23
|
-
@
|
|
21
|
+
@self._ui_effect
|
|
24
22
|
def _():
|
|
25
23
|
element._props["content"] = to_value(content)
|
|
26
24
|
element.update()
|
|
@@ -2,9 +2,7 @@ from typing import (
|
|
|
2
2
|
Optional,
|
|
3
3
|
cast,
|
|
4
4
|
)
|
|
5
|
-
from ex4nicegui.reactive.
|
|
6
|
-
from ex4nicegui.utils.apiEffect import ui_effect
|
|
7
|
-
|
|
5
|
+
from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
|
|
8
6
|
from ex4nicegui.utils.signals import (
|
|
9
7
|
TGetterOrReadonlyRef,
|
|
10
8
|
_TMaybeRef as TMaybeRef,
|
|
@@ -14,7 +12,8 @@ from nicegui import ui
|
|
|
14
12
|
from nicegui.elements.mixins.color_elements import (
|
|
15
13
|
TextColorElement,
|
|
16
14
|
)
|
|
17
|
-
from .base import BindableUi
|
|
15
|
+
from .base import BindableUi
|
|
16
|
+
from ex4nicegui.reactive.services import color_service
|
|
18
17
|
|
|
19
18
|
|
|
20
19
|
class IconBindableUi(BindableUi[ui.icon]):
|
|
@@ -45,10 +44,10 @@ class IconBindableUi(BindableUi[ui.icon]):
|
|
|
45
44
|
return super().bind_prop(prop, ref_ui)
|
|
46
45
|
|
|
47
46
|
def bind_color(self, ref_ui: TGetterOrReadonlyRef):
|
|
48
|
-
return
|
|
47
|
+
return color_service.bind_color(self, ref_ui)
|
|
49
48
|
|
|
50
49
|
def bind_name(self, ref_ui: TGetterOrReadonlyRef):
|
|
51
|
-
@
|
|
50
|
+
@self._ui_effect
|
|
52
51
|
def _():
|
|
53
52
|
ele = cast(TextColorElement, self.element)
|
|
54
53
|
ele._props["name"] = to_value(ref_ui)
|
|
@@ -2,9 +2,7 @@ from pathlib import Path
|
|
|
2
2
|
from typing import (
|
|
3
3
|
Union,
|
|
4
4
|
)
|
|
5
|
-
from ex4nicegui.reactive.
|
|
6
|
-
from ex4nicegui.utils.apiEffect import ui_effect
|
|
7
|
-
|
|
5
|
+
from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
|
|
8
6
|
from ex4nicegui.utils.signals import (
|
|
9
7
|
TGetterOrReadonlyRef,
|
|
10
8
|
_TMaybeRef as TMaybeRef,
|
|
@@ -34,6 +32,6 @@ class ImageBindableUi(BindableUi[ui.image]):
|
|
|
34
32
|
return super().bind_prop(prop, ref_ui)
|
|
35
33
|
|
|
36
34
|
def bind_source(self, ref_ui: TGetterOrReadonlyRef[Union[str, Path]]):
|
|
37
|
-
@
|
|
35
|
+
@self._ui_effect
|
|
38
36
|
def _():
|
|
39
37
|
self.element.set_source(to_value(ref_ui))
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
from typing import Any, Callable, List, Optional, Dict, cast
|
|
2
|
-
from ex4nicegui.utils.apiEffect import ui_effect
|
|
3
2
|
|
|
4
3
|
|
|
5
4
|
from ex4nicegui.utils.signals import (
|
|
6
5
|
TGetterOrReadonlyRef,
|
|
7
6
|
Ref,
|
|
8
7
|
_TMaybeRef as TMaybeRef,
|
|
9
|
-
effect,
|
|
10
8
|
is_setter_ref,
|
|
11
9
|
to_value,
|
|
12
10
|
)
|
|
@@ -14,7 +12,7 @@ from ex4nicegui.utils.signals import (
|
|
|
14
12
|
from nicegui import ui
|
|
15
13
|
from nicegui.events import handle_event
|
|
16
14
|
from .base import BindableUi, DisableableMixin
|
|
17
|
-
from ex4nicegui.reactive.
|
|
15
|
+
from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
|
|
18
16
|
|
|
19
17
|
|
|
20
18
|
class InputBindableUi(BindableUi[ui.input], DisableableMixin):
|
|
@@ -62,7 +60,7 @@ class InputBindableUi(BindableUi[ui.input], DisableableMixin):
|
|
|
62
60
|
return super().bind_prop(prop, ref_ui)
|
|
63
61
|
|
|
64
62
|
def bind_value(self, ref_ui: TGetterOrReadonlyRef[str]):
|
|
65
|
-
@
|
|
63
|
+
@self._ui_effect
|
|
66
64
|
def _():
|
|
67
65
|
self.element.set_value(to_value(ref_ui))
|
|
68
66
|
self.element.update()
|
|
@@ -70,7 +68,7 @@ class InputBindableUi(BindableUi[ui.input], DisableableMixin):
|
|
|
70
68
|
return self
|
|
71
69
|
|
|
72
70
|
def bind_password(self, ref_ui: TGetterOrReadonlyRef[bool]):
|
|
73
|
-
@
|
|
71
|
+
@self._ui_effect
|
|
74
72
|
def _():
|
|
75
73
|
self.element._props["type"] = "password" if to_value(ref_ui) else "text"
|
|
76
74
|
self.element.update()
|
|
@@ -116,7 +114,7 @@ class LazyInputBindableUi(InputBindableUi):
|
|
|
116
114
|
|
|
117
115
|
ele = self.element
|
|
118
116
|
|
|
119
|
-
@
|
|
117
|
+
@self._ui_effect
|
|
120
118
|
def _():
|
|
121
119
|
ele.value = ref.value
|
|
122
120
|
|
|
@@ -3,9 +3,7 @@ from typing import (
|
|
|
3
3
|
Callable,
|
|
4
4
|
Optional,
|
|
5
5
|
)
|
|
6
|
-
from ex4nicegui.reactive.
|
|
7
|
-
from ex4nicegui.utils.apiEffect import ui_effect
|
|
8
|
-
|
|
6
|
+
from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
|
|
9
7
|
from ex4nicegui.utils.signals import (
|
|
10
8
|
_TMaybeRef as TMaybeRef,
|
|
11
9
|
to_value,
|
|
@@ -68,7 +66,7 @@ class KnobBindableUi(
|
|
|
68
66
|
return super().bind_prop(prop, ref_ui)
|
|
69
67
|
|
|
70
68
|
def bind_value(self, ref_ui: TGetterOrReadonlyRef[float]):
|
|
71
|
-
@
|
|
69
|
+
@self._ui_effect
|
|
72
70
|
def _():
|
|
73
71
|
self.element.set_value(to_value(ref_ui))
|
|
74
72
|
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
from typing import (
|
|
2
2
|
Optional,
|
|
3
3
|
)
|
|
4
|
-
from ex4nicegui.reactive.
|
|
5
|
-
from ex4nicegui.utils.apiEffect import ui_effect
|
|
6
|
-
|
|
4
|
+
from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
|
|
7
5
|
from ex4nicegui.utils.signals import (
|
|
8
6
|
TGetterOrReadonlyRef,
|
|
9
7
|
_TMaybeRef as TMaybeRef,
|
|
@@ -11,7 +9,8 @@ from ex4nicegui.utils.signals import (
|
|
|
11
9
|
)
|
|
12
10
|
from nicegui import ui
|
|
13
11
|
|
|
14
|
-
from .base import BindableUi
|
|
12
|
+
from .base import BindableUi
|
|
13
|
+
from ex4nicegui.reactive.services import color_service
|
|
15
14
|
|
|
16
15
|
|
|
17
16
|
class LinearProgressBindableUi(BindableUi[ui.linear_progress]):
|
|
@@ -57,10 +56,10 @@ class LinearProgressBindableUi(BindableUi[ui.linear_progress]):
|
|
|
57
56
|
return super().bind_prop(prop, ref_ui)
|
|
58
57
|
|
|
59
58
|
def bind_color(self, ref_ui: TGetterOrReadonlyRef):
|
|
60
|
-
return
|
|
59
|
+
return color_service.bind_color(self, ref_ui)
|
|
61
60
|
|
|
62
61
|
def bind_value(self, ref_ui: TGetterOrReadonlyRef):
|
|
63
|
-
@
|
|
62
|
+
@self._ui_effect
|
|
64
63
|
def _():
|
|
65
64
|
self.element.set_value(to_value(ref_ui))
|
|
66
65
|
|
|
@@ -6,14 +6,11 @@ from typing import (
|
|
|
6
6
|
Dict,
|
|
7
7
|
Union,
|
|
8
8
|
)
|
|
9
|
-
from ex4nicegui.reactive.
|
|
10
|
-
from ex4nicegui.utils.apiEffect import ui_effect
|
|
11
|
-
|
|
9
|
+
from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
|
|
12
10
|
from ex4nicegui.utils.signals import (
|
|
13
11
|
TGetterOrReadonlyRef,
|
|
14
12
|
_TMaybeRef as TMaybeRef,
|
|
15
13
|
to_value,
|
|
16
|
-
on,
|
|
17
14
|
)
|
|
18
15
|
from nicegui import ui
|
|
19
16
|
from .base import BindableUi
|
|
@@ -83,14 +80,14 @@ class NumberBindableUi(BindableUi[ui.number]):
|
|
|
83
80
|
return super().bind_prop(prop, ref_ui)
|
|
84
81
|
|
|
85
82
|
def bind_value(self, ref_ui: TGetterOrReadonlyRef[float]):
|
|
86
|
-
@
|
|
83
|
+
@self._ui_effect
|
|
87
84
|
def _():
|
|
88
85
|
self.element.set_value(to_value(ref_ui))
|
|
89
86
|
|
|
90
87
|
return self
|
|
91
88
|
|
|
92
89
|
def _bind_precision(self, ref_ui: TGetterOrReadonlyRef[int]):
|
|
93
|
-
@
|
|
90
|
+
@self._ui_signal_on(ref_ui, onchanges=True)
|
|
94
91
|
def _():
|
|
95
92
|
self.element.precision = to_value(ref_ui)
|
|
96
93
|
self.element.sanitize()
|
|
@@ -8,9 +8,7 @@ from typing import (
|
|
|
8
8
|
Dict,
|
|
9
9
|
Union,
|
|
10
10
|
)
|
|
11
|
-
from ex4nicegui.reactive.
|
|
12
|
-
from ex4nicegui.utils.apiEffect import ui_effect
|
|
13
|
-
|
|
11
|
+
from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
|
|
14
12
|
from ex4nicegui.utils.signals import (
|
|
15
13
|
TGetterOrReadonlyRef,
|
|
16
14
|
_TMaybeRef as TMaybeRef,
|
|
@@ -63,14 +61,14 @@ class RadioBindableUi(BindableUi[ui.radio]):
|
|
|
63
61
|
return super().bind_prop(prop, ref_ui)
|
|
64
62
|
|
|
65
63
|
def bind_options(self, ref_ui: TGetterOrReadonlyRef):
|
|
66
|
-
@
|
|
64
|
+
@self._ui_effect
|
|
67
65
|
def _():
|
|
68
66
|
self.element.set_options(to_value(ref_ui))
|
|
69
67
|
|
|
70
68
|
return self
|
|
71
69
|
|
|
72
70
|
def bind_value(self, ref_ui: TGetterOrReadonlyRef):
|
|
73
|
-
@
|
|
71
|
+
@self._ui_effect
|
|
74
72
|
def _():
|
|
75
73
|
cast(ValueElement, self.element).set_value(to_value(ref_ui))
|
|
76
74
|
|
|
@@ -8,9 +8,7 @@ from typing import (
|
|
|
8
8
|
Dict,
|
|
9
9
|
Union,
|
|
10
10
|
)
|
|
11
|
-
from ex4nicegui.reactive.
|
|
12
|
-
from ex4nicegui.utils.apiEffect import ui_effect
|
|
13
|
-
|
|
11
|
+
from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
|
|
14
12
|
from ex4nicegui.utils.signals import (
|
|
15
13
|
TGetterOrReadonlyRef,
|
|
16
14
|
_TMaybeRef as TMaybeRef,
|
|
@@ -85,14 +83,14 @@ class SelectBindableUi(BindableUi[ui.select]):
|
|
|
85
83
|
return super().bind_prop(prop, ref_ui)
|
|
86
84
|
|
|
87
85
|
def bind_options(self, ref_ui: TGetterOrReadonlyRef):
|
|
88
|
-
@
|
|
86
|
+
@self._ui_effect()
|
|
89
87
|
def _():
|
|
90
88
|
self.element.set_options(to_value(ref_ui))
|
|
91
89
|
|
|
92
90
|
return self
|
|
93
91
|
|
|
94
92
|
def bind_value(self, ref_ui: TGetterOrReadonlyRef):
|
|
95
|
-
@
|
|
93
|
+
@self._ui_effect()
|
|
96
94
|
def _():
|
|
97
95
|
cast(ValueElement, self.element).set_value(to_value(ref_ui) or None)
|
|
98
96
|
|
|
@@ -5,9 +5,7 @@ from typing import (
|
|
|
5
5
|
TypeVar,
|
|
6
6
|
cast,
|
|
7
7
|
)
|
|
8
|
-
from ex4nicegui.reactive.
|
|
9
|
-
from ex4nicegui.utils.apiEffect import ui_effect
|
|
10
|
-
|
|
8
|
+
from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
|
|
11
9
|
from ex4nicegui.utils.signals import (
|
|
12
10
|
TGetterOrReadonlyRef,
|
|
13
11
|
Ref,
|
|
@@ -67,7 +65,7 @@ class SliderBindableUi(
|
|
|
67
65
|
return super().bind_prop(prop, ref_ui)
|
|
68
66
|
|
|
69
67
|
def bind_value(self, ref_ui: TGetterOrReadonlyRef[float]):
|
|
70
|
-
@
|
|
68
|
+
@self._ui_effect
|
|
71
69
|
def _():
|
|
72
70
|
self.element.set_value(to_value(ref_ui))
|
|
73
71
|
self.element.update()
|
|
@@ -95,7 +93,7 @@ class LazySliderBindableUi(SliderBindableUi):
|
|
|
95
93
|
ref = cast(Ref, org_value)
|
|
96
94
|
ele = self.element
|
|
97
95
|
|
|
98
|
-
@
|
|
96
|
+
@self._ui_effect
|
|
99
97
|
def _():
|
|
100
98
|
ele.value = ref.value
|
|
101
99
|
|
|
@@ -4,9 +4,7 @@ from typing import (
|
|
|
4
4
|
Optional,
|
|
5
5
|
TypeVar,
|
|
6
6
|
)
|
|
7
|
-
from ex4nicegui.reactive.
|
|
8
|
-
from ex4nicegui.utils.apiEffect import ui_effect
|
|
9
|
-
|
|
7
|
+
from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
|
|
10
8
|
from ex4nicegui.utils.signals import (
|
|
11
9
|
TGetterOrReadonlyRef,
|
|
12
10
|
_TMaybeRef as TMaybeRef,
|
|
@@ -56,7 +54,7 @@ class SwitchBindableUi(BindableUi[ui.switch]):
|
|
|
56
54
|
return super().bind_prop(prop, ref_ui)
|
|
57
55
|
|
|
58
56
|
def bind_value(self, ref_ui: TGetterOrReadonlyRef[bool]):
|
|
59
|
-
@
|
|
57
|
+
@self._ui_effect
|
|
60
58
|
def _():
|
|
61
59
|
self.element.set_value(to_value(ref_ui))
|
|
62
60
|
|
|
@@ -6,18 +6,19 @@ from typing import (
|
|
|
6
6
|
Dict,
|
|
7
7
|
)
|
|
8
8
|
from typing_extensions import Literal
|
|
9
|
-
from ex4nicegui.reactive.
|
|
9
|
+
from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
|
|
10
|
+
from ex4nicegui.reactive.services.pandas_service import dataframe2col_str
|
|
11
|
+
|
|
10
12
|
import ex4nicegui.utils.common as utils_common
|
|
11
13
|
from ex4nicegui.utils.signals import (
|
|
12
14
|
TGetterOrReadonlyRef,
|
|
13
|
-
|
|
15
|
+
TReadonlyRef,
|
|
14
16
|
is_ref,
|
|
15
17
|
ref_computed,
|
|
16
18
|
to_ref,
|
|
17
19
|
_TMaybeRef as TMaybeRef,
|
|
18
20
|
to_value,
|
|
19
21
|
to_raw,
|
|
20
|
-
on,
|
|
21
22
|
RefWrapper,
|
|
22
23
|
)
|
|
23
24
|
from nicegui import ui
|
|
@@ -67,7 +68,7 @@ class TableBindableUi(BindableUi[ui.table]):
|
|
|
67
68
|
|
|
68
69
|
self._arg_selection = selection
|
|
69
70
|
self._arg_row_key = row_key
|
|
70
|
-
self._selection_ref:
|
|
71
|
+
self._selection_ref: TReadonlyRef[List[Any]] = to_ref([]) # type: ignore
|
|
71
72
|
|
|
72
73
|
def on_selection(_):
|
|
73
74
|
self._selection_ref.value = self.element.selected # type: ignore
|
|
@@ -182,7 +183,7 @@ class TableBindableUi(BindableUi[ui.table]):
|
|
|
182
183
|
return self
|
|
183
184
|
|
|
184
185
|
def bind_rows(self, ref_ui: TGetterOrReadonlyRef[List[Dict]]):
|
|
185
|
-
@
|
|
186
|
+
@self._ui_signal_on(ref_ui, deep=True)
|
|
186
187
|
def _():
|
|
187
188
|
ele = self.element
|
|
188
189
|
ele._props["rows"] = list(to_raw(to_value(ref_ui)))
|
|
@@ -191,7 +192,7 @@ class TableBindableUi(BindableUi[ui.table]):
|
|
|
191
192
|
return self
|
|
192
193
|
|
|
193
194
|
def bind_columns(self, ref_ui: TGetterOrReadonlyRef[List[Dict]]):
|
|
194
|
-
@
|
|
195
|
+
@self._ui_signal_on(ref_ui, deep=True)
|
|
195
196
|
def _():
|
|
196
197
|
ele = self.element
|
|
197
198
|
ele._props["columns"] = list(to_raw(to_value(ref_ui)))
|
|
@@ -5,13 +5,11 @@ from typing import (
|
|
|
5
5
|
Dict,
|
|
6
6
|
cast,
|
|
7
7
|
)
|
|
8
|
-
from ex4nicegui.reactive.
|
|
9
|
-
from ex4nicegui.utils.apiEffect import ui_effect
|
|
8
|
+
from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
|
|
10
9
|
from ex4nicegui.utils.signals import (
|
|
11
10
|
TGetterOrReadonlyRef,
|
|
12
11
|
Ref,
|
|
13
12
|
_TMaybeRef as TMaybeRef,
|
|
14
|
-
effect,
|
|
15
13
|
is_setter_ref,
|
|
16
14
|
to_value,
|
|
17
15
|
)
|
|
@@ -61,7 +59,7 @@ class TextareaBindableUi(BindableUi[ui.textarea]):
|
|
|
61
59
|
return super().bind_prop(prop, ref_ui)
|
|
62
60
|
|
|
63
61
|
def bind_value(self, ref_ui: TGetterOrReadonlyRef[str]):
|
|
64
|
-
@
|
|
62
|
+
@self._ui_effect
|
|
65
63
|
def _():
|
|
66
64
|
self.element.set_value(to_value(ref_ui))
|
|
67
65
|
|
|
@@ -95,7 +93,7 @@ class LazyTextareaBindableUi(TextareaBindableUi):
|
|
|
95
93
|
ref = cast(Ref, org_value)
|
|
96
94
|
ele = self.element
|
|
97
95
|
|
|
98
|
-
@
|
|
96
|
+
@self._ui_effect
|
|
99
97
|
def _():
|
|
100
98
|
ele.value = ref.value
|
|
101
99
|
|
|
@@ -11,7 +11,7 @@ from ex4nicegui.utils.signals import (
|
|
|
11
11
|
from nicegui import ui
|
|
12
12
|
from nicegui.events import handle_event
|
|
13
13
|
from .base import BindableUi
|
|
14
|
-
from .
|
|
14
|
+
from ex4nicegui.reactive.systems.reactive_system import convert_kws_ref2value
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
class UploadResult:
|
|
@@ -57,7 +57,7 @@ class UploadBindableUi(BindableUi[ui.upload]):
|
|
|
57
57
|
"auto_upload": auto_upload,
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
value_kws =
|
|
60
|
+
value_kws = convert_kws_ref2value(kws)
|
|
61
61
|
|
|
62
62
|
self._on_upload_callbacks = []
|
|
63
63
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
from typing import Any, Optional, Callable
|
|
2
|
-
from ex4nicegui.reactive.
|
|
2
|
+
from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
|
|
3
3
|
from ex4nicegui.utils.signals import (
|
|
4
4
|
TGetterOrReadonlyRef,
|
|
5
5
|
to_value,
|
|
6
|
-
|
|
6
|
+
TMaybeRef,
|
|
7
7
|
)
|
|
8
8
|
from nicegui import ui
|
|
9
9
|
from ex4nicegui.reactive.officials.base import BindableUi
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
|
|
2
|
+
const REGEX_NEWLINE = /[\r\n]/g;
|
|
3
|
+
const REGEX_START_SPACES = /^\s+/gm;
|
|
4
|
+
|
|
5
|
+
function getClasses(id) {
|
|
6
|
+
return `ex4ng-scoped-style-${id}`;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function removeInvalidChars(str) {
|
|
10
|
+
str = str.replace(REGEX_START_SPACES, '');
|
|
11
|
+
return str.replace(REGEX_NEWLINE, '');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function appendCSS(styleElement, cssText) {
|
|
15
|
+
// 获取已有的 CSS 内容
|
|
16
|
+
let existingCSS = styleElement.textContent || '';
|
|
17
|
+
|
|
18
|
+
// 如果已有的 CSS 内容不为空,添加一个空行作为分隔符
|
|
19
|
+
if (existingCSS.trim() !== '') {
|
|
20
|
+
existingCSS += '\n';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// 拼接新的 CSS 内容
|
|
24
|
+
existingCSS += cssText;
|
|
25
|
+
|
|
26
|
+
// 将新的 CSS 内容设置回 style 标签
|
|
27
|
+
styleElement.textContent = existingCSS;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default {
|
|
31
|
+
template: `<template></template>`,
|
|
32
|
+
methods: {
|
|
33
|
+
createStyle(id, css) {
|
|
34
|
+
css = removeInvalidChars(css);
|
|
35
|
+
|
|
36
|
+
const classes = getClasses(id);
|
|
37
|
+
const target = document.querySelector(`style.${classes}`);
|
|
38
|
+
if (target) {
|
|
39
|
+
appendCSS(target, css);
|
|
40
|
+
} else {
|
|
41
|
+
const style = document.createElement('style');
|
|
42
|
+
style.classList.add(classes);
|
|
43
|
+
style.innerHTML = css;
|
|
44
|
+
document.head.appendChild(style);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
removeStyle(id) {
|
|
48
|
+
const classes = getClasses(id);
|
|
49
|
+
const target = document.querySelector(`style.${classes}`);
|
|
50
|
+
if (target) {
|
|
51
|
+
target.remove();
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from nicegui.element import Element
|
|
2
|
+
from ex4nicegui.helper import client_instance_locker
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class ScopedStyle(Element, component="scopedStyle.js"):
|
|
6
|
+
pass
|
|
7
|
+
|
|
8
|
+
@staticmethod
|
|
9
|
+
def get():
|
|
10
|
+
return _scoped_style_factory.get_object()
|
|
11
|
+
|
|
12
|
+
def create_style(self, element: Element, css: str):
|
|
13
|
+
element_id = f"c{element.id}"
|
|
14
|
+
|
|
15
|
+
self.run_method("createStyle", element_id, css)
|
|
16
|
+
|
|
17
|
+
def remove_style(self, element: Element):
|
|
18
|
+
element_id = f"c{element.id}"
|
|
19
|
+
self.run_method("removeStyle", element_id)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
_scoped_style_factory = client_instance_locker.ClientInstanceLocker(ScopedStyle)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from typing import TYPE_CHECKING, Literal, cast
|
|
3
|
+
from ex4nicegui.utils.signals import to_value
|
|
4
|
+
from nicegui.elements.mixins.color_elements import (
|
|
5
|
+
TextColorElement,
|
|
6
|
+
QUASAR_COLORS,
|
|
7
|
+
TAILWIND_COLORS,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
if TYPE_CHECKING:
|
|
11
|
+
from ex4nicegui.reactive.officials.base import BindableUi
|
|
12
|
+
from ex4nicegui import TGetterOrReadonlyRef
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
_color_sys_type = Literal["QUASAR", "TAILWIND", "STYLE"]
|
|
16
|
+
_color_attr_name = "data-ex4ng-color"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def bind_color(bindable_ui: BindableUi, ref_ui: TGetterOrReadonlyRef):
|
|
20
|
+
@bindable_ui._ui_effect
|
|
21
|
+
def _():
|
|
22
|
+
ele = cast(TextColorElement, bindable_ui.element)
|
|
23
|
+
color = to_value(ref_ui)
|
|
24
|
+
|
|
25
|
+
# get exists color
|
|
26
|
+
# e.g 'QUASAR:red'
|
|
27
|
+
pre_color = ele._props.get(_color_attr_name) # type: str | None
|
|
28
|
+
if pre_color:
|
|
29
|
+
color_sys, value = pre_color.split(":") # type: ignore
|
|
30
|
+
color_sys: _color_sys_type
|
|
31
|
+
|
|
32
|
+
if color_sys == "QUASAR":
|
|
33
|
+
del ele._props[ele.TEXT_COLOR_PROP]
|
|
34
|
+
elif color_sys == "TAILWIND":
|
|
35
|
+
ele.classes(remove=value)
|
|
36
|
+
else:
|
|
37
|
+
del ele._style["color"]
|
|
38
|
+
|
|
39
|
+
cur_sys: _color_sys_type = "STYLE"
|
|
40
|
+
cur_color = color
|
|
41
|
+
|
|
42
|
+
if color in QUASAR_COLORS:
|
|
43
|
+
ele._props[ele.TEXT_COLOR_PROP] = color
|
|
44
|
+
cur_sys = "QUASAR"
|
|
45
|
+
elif color in TAILWIND_COLORS:
|
|
46
|
+
cur_color = f"text-{color}"
|
|
47
|
+
ele.classes(replace=cur_color)
|
|
48
|
+
cur_sys = "TAILWIND"
|
|
49
|
+
elif color is not None:
|
|
50
|
+
ele._style["color"] = color
|
|
51
|
+
|
|
52
|
+
ele._props[_color_attr_name] = f"{cur_sys}:{color}"
|
|
53
|
+
|
|
54
|
+
ele.update()
|
|
55
|
+
|
|
56
|
+
return bindable_ui
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
try:
|
|
2
|
+
import pandas as pd
|
|
3
|
+
except ImportError:
|
|
4
|
+
pass
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def dataframe2col_str(df, copy=True):
|
|
8
|
+
if isinstance(df.columns, pd.MultiIndex):
|
|
9
|
+
raise ValueError(
|
|
10
|
+
"MultiIndex columns are not supported. "
|
|
11
|
+
"You can convert them to strings using something like "
|
|
12
|
+
'`df.columns = ["_".join(col) for col in df.columns.values]`.'
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
date_cols = df.columns[df.dtypes == "datetime64[ns]"]
|
|
16
|
+
time_cols = df.columns[df.dtypes == "timedelta64[ns]"]
|
|
17
|
+
complex_cols = df.columns[df.dtypes == "complex128"]
|
|
18
|
+
period_cols = df.columns[df.dtypes == "period[M]"]
|
|
19
|
+
if (
|
|
20
|
+
len(date_cols) != 0
|
|
21
|
+
or len(time_cols) != 0
|
|
22
|
+
or len(complex_cols) != 0
|
|
23
|
+
or len(period_cols) != 0
|
|
24
|
+
):
|
|
25
|
+
df = df.copy() if copy else df
|
|
26
|
+
df[date_cols] = df[date_cols].astype(str)
|
|
27
|
+
df[time_cols] = df[time_cols].astype(str)
|
|
28
|
+
df[complex_cols] = df[complex_cols].astype(str)
|
|
29
|
+
df[period_cols] = df[period_cols].astype(str)
|
|
30
|
+
|
|
31
|
+
return df
|