ex4nicegui 0.2.3__py3-none-any.whl → 0.2.5__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 +1 -1
- ex4nicegui/reactive/__index.py +1 -31
- ex4nicegui/reactive/officials/__init__.py +37 -0
- ex4nicegui/reactive/officials/aggrid.py +81 -0
- ex4nicegui/reactive/officials/base.py +167 -0
- ex4nicegui/reactive/officials/button.py +86 -0
- ex4nicegui/reactive/officials/card.py +59 -0
- ex4nicegui/reactive/officials/checkbox.py +68 -0
- ex4nicegui/reactive/officials/color_picker.py +101 -0
- ex4nicegui/reactive/officials/date.py +85 -0
- ex4nicegui/reactive/officials/drawer.py +88 -0
- ex4nicegui/reactive/officials/echarts.py +70 -0
- ex4nicegui/reactive/officials/html.py +66 -0
- ex4nicegui/reactive/officials/icon.py +62 -0
- ex4nicegui/reactive/officials/image.py +54 -0
- ex4nicegui/reactive/officials/input.py +116 -0
- ex4nicegui/reactive/officials/label.py +67 -0
- ex4nicegui/reactive/officials/radio.py +80 -0
- ex4nicegui/reactive/officials/row.py +21 -0
- ex4nicegui/reactive/officials/select.py +93 -0
- ex4nicegui/reactive/officials/slider.py +97 -0
- ex4nicegui/reactive/officials/switch.py +72 -0
- ex4nicegui/reactive/officials/table.py +144 -0
- ex4nicegui/reactive/officials/textarea.py +103 -0
- ex4nicegui/reactive/officials/upload.py +78 -0
- ex4nicegui/reactive/officials/utils.py +11 -0
- {ex4nicegui-0.2.3.dist-info → ex4nicegui-0.2.5.dist-info}/METADATA +1 -1
- ex4nicegui-0.2.5.dist-info/RECORD +56 -0
- ex4nicegui/reactive/officials.py +0 -1585
- ex4nicegui-0.2.3.dist-info/RECORD +0 -33
- {ex4nicegui-0.2.3.data → ex4nicegui-0.2.5.data}/data/ECharts/ECharts.js +0 -0
- {ex4nicegui-0.2.3.data → ex4nicegui-0.2.5.data}/data/UseDraggable/UseDraggable.js +0 -0
- {ex4nicegui-0.2.3.data → ex4nicegui-0.2.5.data}/data/useMouse/UseMouse.js +0 -0
- {ex4nicegui-0.2.3.dist-info → ex4nicegui-0.2.5.dist-info}/LICENSE +0 -0
- {ex4nicegui-0.2.3.dist-info → ex4nicegui-0.2.5.dist-info}/WHEEL +0 -0
- {ex4nicegui-0.2.3.dist-info → ex4nicegui-0.2.5.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from typing import (
|
|
2
|
+
Any,
|
|
3
|
+
)
|
|
4
|
+
from nicegui import ui
|
|
5
|
+
from .base import BindableUi
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class RowBindableUi(BindableUi[ui.row]):
|
|
9
|
+
def __init__(
|
|
10
|
+
self,
|
|
11
|
+
) -> None:
|
|
12
|
+
element = ui.row()
|
|
13
|
+
|
|
14
|
+
super().__init__(element)
|
|
15
|
+
|
|
16
|
+
def __enter__(self):
|
|
17
|
+
self.element.__enter__()
|
|
18
|
+
return self
|
|
19
|
+
|
|
20
|
+
def __exit__(self, *_: Any):
|
|
21
|
+
self.element.__exit__(*_)
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
from typing import (
|
|
2
|
+
Any,
|
|
3
|
+
Callable,
|
|
4
|
+
List,
|
|
5
|
+
Optional,
|
|
6
|
+
TypeVar,
|
|
7
|
+
cast,
|
|
8
|
+
Dict,
|
|
9
|
+
Union,
|
|
10
|
+
)
|
|
11
|
+
from signe import effect
|
|
12
|
+
from ex4nicegui.utils.signals import (
|
|
13
|
+
ReadonlyRef,
|
|
14
|
+
is_ref,
|
|
15
|
+
_TMaybeRef as TMaybeRef,
|
|
16
|
+
)
|
|
17
|
+
from nicegui import ui
|
|
18
|
+
from nicegui.elements.mixins.value_element import ValueElement
|
|
19
|
+
from .base import SingleValueBindableUi
|
|
20
|
+
from .utils import _convert_kws_ref2value
|
|
21
|
+
|
|
22
|
+
T = TypeVar("T")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class SelectBindableUi(SingleValueBindableUi[T, ui.select]):
|
|
26
|
+
@staticmethod
|
|
27
|
+
def _setup_(binder: "SelectBindableUi"):
|
|
28
|
+
def onValueChanged(e):
|
|
29
|
+
binder._ref.value = e.args["label"] # type: ignore
|
|
30
|
+
|
|
31
|
+
@effect
|
|
32
|
+
def _():
|
|
33
|
+
binder.element.value = binder.value
|
|
34
|
+
|
|
35
|
+
binder.element.on("update:modelValue", handler=onValueChanged)
|
|
36
|
+
|
|
37
|
+
def __init__(
|
|
38
|
+
self,
|
|
39
|
+
options: Union[TMaybeRef[List], TMaybeRef[Dict]],
|
|
40
|
+
*,
|
|
41
|
+
label: Optional[TMaybeRef[str]] = None,
|
|
42
|
+
value: TMaybeRef[Any] = None,
|
|
43
|
+
on_change: Optional[Callable[..., Any]] = None,
|
|
44
|
+
with_input: TMaybeRef[bool] = False,
|
|
45
|
+
multiple: TMaybeRef[bool] = False,
|
|
46
|
+
clearable: TMaybeRef[bool] = False,
|
|
47
|
+
) -> None:
|
|
48
|
+
kws = {
|
|
49
|
+
"options": options,
|
|
50
|
+
"label": label,
|
|
51
|
+
"value": value,
|
|
52
|
+
"on_change": on_change,
|
|
53
|
+
"with_input": with_input,
|
|
54
|
+
"multiple": multiple,
|
|
55
|
+
"clearable": clearable,
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
value_kws = _convert_kws_ref2value(kws)
|
|
59
|
+
|
|
60
|
+
element = ui.select(**value_kws)
|
|
61
|
+
element.classes("min-w-[10rem]")
|
|
62
|
+
|
|
63
|
+
super().__init__(value, element)
|
|
64
|
+
|
|
65
|
+
for key, value in kws.items():
|
|
66
|
+
if is_ref(value):
|
|
67
|
+
self.bind_prop(key, value)
|
|
68
|
+
|
|
69
|
+
SelectBindableUi._setup_(self)
|
|
70
|
+
|
|
71
|
+
def bind_prop(self, prop: str, ref_ui: ReadonlyRef):
|
|
72
|
+
if prop == "value":
|
|
73
|
+
return self.bind_text(ref_ui)
|
|
74
|
+
|
|
75
|
+
if prop == "options":
|
|
76
|
+
return self.bind_options(ref_ui)
|
|
77
|
+
|
|
78
|
+
return super().bind_prop(prop, ref_ui)
|
|
79
|
+
|
|
80
|
+
def bind_options(self, ref_ui: ReadonlyRef):
|
|
81
|
+
@effect
|
|
82
|
+
def _():
|
|
83
|
+
self.element.options = ref_ui.value
|
|
84
|
+
self.element.update()
|
|
85
|
+
|
|
86
|
+
return self
|
|
87
|
+
|
|
88
|
+
def bind_text(self, ref_ui: ReadonlyRef):
|
|
89
|
+
@effect
|
|
90
|
+
def _():
|
|
91
|
+
cast(ValueElement, self.element).on_value_change(ref_ui.value)
|
|
92
|
+
|
|
93
|
+
return self
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
from typing import (
|
|
2
|
+
Any,
|
|
3
|
+
Callable,
|
|
4
|
+
Optional,
|
|
5
|
+
TypeVar,
|
|
6
|
+
)
|
|
7
|
+
from signe import effect
|
|
8
|
+
from ex4nicegui.utils.signals import (
|
|
9
|
+
ReadonlyRef,
|
|
10
|
+
is_ref,
|
|
11
|
+
_TMaybeRef as TMaybeRef,
|
|
12
|
+
)
|
|
13
|
+
from nicegui import ui
|
|
14
|
+
from .base import SingleValueBindableUi
|
|
15
|
+
from .utils import _convert_kws_ref2value
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
_TSliderValue = TypeVar("_TSliderValue", float, int, None)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class SliderBindableUi(SingleValueBindableUi[Optional[_TSliderValue], ui.slider]):
|
|
22
|
+
def __init__(
|
|
23
|
+
self,
|
|
24
|
+
min: TMaybeRef[_TSliderValue],
|
|
25
|
+
max: TMaybeRef[_TSliderValue],
|
|
26
|
+
step: TMaybeRef[_TSliderValue] = 1.0,
|
|
27
|
+
value: Optional[TMaybeRef[_TSliderValue]] = None,
|
|
28
|
+
on_change: Optional[Callable[..., Any]] = None,
|
|
29
|
+
) -> None:
|
|
30
|
+
kws = {
|
|
31
|
+
"min": min,
|
|
32
|
+
"max": max,
|
|
33
|
+
"step": step,
|
|
34
|
+
"value": value,
|
|
35
|
+
"on_change": on_change,
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
value_kws = _convert_kws_ref2value(kws)
|
|
39
|
+
|
|
40
|
+
element = ui.slider(**value_kws).props("label label-always switch-label-side")
|
|
41
|
+
|
|
42
|
+
super().__init__(value, element) # type: ignore
|
|
43
|
+
|
|
44
|
+
for key, value in kws.items():
|
|
45
|
+
if is_ref(value) and key != "value":
|
|
46
|
+
self.bind_prop(key, value) # type: ignore
|
|
47
|
+
|
|
48
|
+
self._ex_setup()
|
|
49
|
+
|
|
50
|
+
def _ex_setup(self):
|
|
51
|
+
ele = self.element
|
|
52
|
+
|
|
53
|
+
@effect
|
|
54
|
+
def _():
|
|
55
|
+
ele.value = self.value
|
|
56
|
+
|
|
57
|
+
def onModelValueChanged(e):
|
|
58
|
+
self._ref.value = e.args # type: ignore
|
|
59
|
+
|
|
60
|
+
ele.on("update:modelValue", handler=onModelValueChanged)
|
|
61
|
+
|
|
62
|
+
def bind_prop(self, prop: str, ref_ui: ReadonlyRef):
|
|
63
|
+
if prop == "value":
|
|
64
|
+
return self.bind_value(ref_ui)
|
|
65
|
+
|
|
66
|
+
return super().bind_prop(prop, ref_ui)
|
|
67
|
+
|
|
68
|
+
def bind_value(self, ref_ui: ReadonlyRef[float]):
|
|
69
|
+
@effect
|
|
70
|
+
def _():
|
|
71
|
+
self.element.on_value_change(ref_ui.value)
|
|
72
|
+
|
|
73
|
+
return self
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class LazySliderBindableUi(SliderBindableUi):
|
|
77
|
+
def __init__(
|
|
78
|
+
self,
|
|
79
|
+
min: TMaybeRef[_TSliderValue],
|
|
80
|
+
max: TMaybeRef[_TSliderValue],
|
|
81
|
+
step: TMaybeRef[_TSliderValue] = 1,
|
|
82
|
+
value: Optional[TMaybeRef[_TSliderValue]] = None,
|
|
83
|
+
on_change: Optional[Callable[..., Any]] = None,
|
|
84
|
+
) -> None:
|
|
85
|
+
super().__init__(min, max, step, value, on_change)
|
|
86
|
+
|
|
87
|
+
def _ex_setup(self):
|
|
88
|
+
ele = self.element
|
|
89
|
+
|
|
90
|
+
@effect
|
|
91
|
+
def _():
|
|
92
|
+
ele.value = self.value
|
|
93
|
+
|
|
94
|
+
def onValueChanged():
|
|
95
|
+
self._ref.value = ele.value
|
|
96
|
+
|
|
97
|
+
ele.on("change", onValueChanged)
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
from typing import (
|
|
2
|
+
Any,
|
|
3
|
+
Callable,
|
|
4
|
+
Optional,
|
|
5
|
+
TypeVar,
|
|
6
|
+
cast,
|
|
7
|
+
)
|
|
8
|
+
from signe import effect
|
|
9
|
+
from ex4nicegui.utils.signals import (
|
|
10
|
+
ReadonlyRef,
|
|
11
|
+
is_ref,
|
|
12
|
+
_TMaybeRef as TMaybeRef,
|
|
13
|
+
)
|
|
14
|
+
from nicegui import ui
|
|
15
|
+
from nicegui.elements.mixins.value_element import ValueElement
|
|
16
|
+
from .base import SingleValueBindableUi
|
|
17
|
+
from .utils import _convert_kws_ref2value
|
|
18
|
+
|
|
19
|
+
T = TypeVar("T")
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class SwitchBindableUi(SingleValueBindableUi[bool, ui.switch]):
|
|
23
|
+
@staticmethod
|
|
24
|
+
def _setup_(binder: "SwitchBindableUi"):
|
|
25
|
+
def onValueChanged(e):
|
|
26
|
+
ele._send_update_on_value_change = ele.LOOPBACK
|
|
27
|
+
cur_value = ele._event_args_to_value(e)
|
|
28
|
+
ele.set_value(cur_value)
|
|
29
|
+
ele._send_update_on_value_change = True
|
|
30
|
+
binder._ref.value = cur_value
|
|
31
|
+
|
|
32
|
+
ele = cast(ValueElement, binder.element)
|
|
33
|
+
|
|
34
|
+
@effect
|
|
35
|
+
def _():
|
|
36
|
+
ele.value = binder.value
|
|
37
|
+
|
|
38
|
+
ele.on("update:modelValue", onValueChanged, [None], throttle=0) # type: ignore
|
|
39
|
+
|
|
40
|
+
def __init__(
|
|
41
|
+
self,
|
|
42
|
+
text: TMaybeRef[str] = "",
|
|
43
|
+
*,
|
|
44
|
+
value: TMaybeRef[bool] = False,
|
|
45
|
+
on_change: Optional[Callable[..., Any]] = None,
|
|
46
|
+
) -> None:
|
|
47
|
+
kws = {"text": text, "value": value, "on_change": on_change}
|
|
48
|
+
|
|
49
|
+
value_kws = _convert_kws_ref2value(kws)
|
|
50
|
+
|
|
51
|
+
element = ui.switch(**value_kws)
|
|
52
|
+
|
|
53
|
+
super().__init__(value, element)
|
|
54
|
+
|
|
55
|
+
for key, value in kws.items():
|
|
56
|
+
if is_ref(value):
|
|
57
|
+
self.bind_prop(key, value) # type: ignore
|
|
58
|
+
|
|
59
|
+
SwitchBindableUi._setup_(self)
|
|
60
|
+
|
|
61
|
+
def bind_prop(self, prop: str, ref_ui: ReadonlyRef):
|
|
62
|
+
if prop == "value":
|
|
63
|
+
return self.bind_value(ref_ui)
|
|
64
|
+
|
|
65
|
+
return super().bind_prop(prop, ref_ui)
|
|
66
|
+
|
|
67
|
+
def bind_value(self, ref_ui: ReadonlyRef[bool]):
|
|
68
|
+
@effect
|
|
69
|
+
def _():
|
|
70
|
+
self.element.on_value_change(ref_ui.value)
|
|
71
|
+
|
|
72
|
+
return self
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
from typing import (
|
|
2
|
+
Any,
|
|
3
|
+
Callable,
|
|
4
|
+
List,
|
|
5
|
+
Optional,
|
|
6
|
+
Dict,
|
|
7
|
+
)
|
|
8
|
+
from typing_extensions import Literal
|
|
9
|
+
import ex4nicegui.utils.common as utils_common
|
|
10
|
+
from signe import effect
|
|
11
|
+
from ex4nicegui.utils.signals import (
|
|
12
|
+
ReadonlyRef,
|
|
13
|
+
is_ref,
|
|
14
|
+
ref_computed,
|
|
15
|
+
_TMaybeRef as TMaybeRef,
|
|
16
|
+
)
|
|
17
|
+
from nicegui import ui
|
|
18
|
+
from .base import BindableUi
|
|
19
|
+
from .utils import _convert_kws_ref2value
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class TableBindableUi(BindableUi[ui.table]):
|
|
23
|
+
def __init__(
|
|
24
|
+
self,
|
|
25
|
+
columns: TMaybeRef[List[Dict]],
|
|
26
|
+
rows: TMaybeRef[List[Dict]],
|
|
27
|
+
row_key: TMaybeRef[str] = "id",
|
|
28
|
+
title: Optional[TMaybeRef[str]] = None,
|
|
29
|
+
selection: Optional[TMaybeRef[Literal["single", "multiple"]]] = None,
|
|
30
|
+
pagination: Optional[TMaybeRef[int]] = 15,
|
|
31
|
+
on_select: Optional[Callable[..., Any]] = None,
|
|
32
|
+
) -> None:
|
|
33
|
+
kws = {
|
|
34
|
+
"columns": columns,
|
|
35
|
+
"rows": rows,
|
|
36
|
+
"row_key": row_key,
|
|
37
|
+
"title": title,
|
|
38
|
+
"selection": selection,
|
|
39
|
+
"pagination": pagination,
|
|
40
|
+
"on_select": on_select,
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
value_kws = _convert_kws_ref2value(kws)
|
|
44
|
+
|
|
45
|
+
element = ui.table(**value_kws)
|
|
46
|
+
|
|
47
|
+
super().__init__(element)
|
|
48
|
+
|
|
49
|
+
for key, value in kws.items():
|
|
50
|
+
if is_ref(value):
|
|
51
|
+
self.bind_prop(key, value) # type: ignore
|
|
52
|
+
|
|
53
|
+
@staticmethod
|
|
54
|
+
def from_pandas(df: TMaybeRef):
|
|
55
|
+
if is_ref(df):
|
|
56
|
+
|
|
57
|
+
@ref_computed
|
|
58
|
+
def cp_convert_df():
|
|
59
|
+
return utils_common.convert_dataframe(df.value)
|
|
60
|
+
|
|
61
|
+
@ref_computed
|
|
62
|
+
def cp_rows():
|
|
63
|
+
return cp_convert_df.value.to_dict("records")
|
|
64
|
+
|
|
65
|
+
@ref_computed
|
|
66
|
+
def cp_cols():
|
|
67
|
+
return [
|
|
68
|
+
{
|
|
69
|
+
"name": col,
|
|
70
|
+
"label": col,
|
|
71
|
+
"field": col,
|
|
72
|
+
}
|
|
73
|
+
for col in cp_convert_df.value.columns
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
return TableBindableUi(cp_cols, cp_rows)
|
|
77
|
+
|
|
78
|
+
df = utils_common.convert_dataframe(df)
|
|
79
|
+
rows = df.to_dict("records")
|
|
80
|
+
|
|
81
|
+
cols = [
|
|
82
|
+
{
|
|
83
|
+
"name": col,
|
|
84
|
+
"label": col,
|
|
85
|
+
"field": col,
|
|
86
|
+
}
|
|
87
|
+
for col in df.columns
|
|
88
|
+
]
|
|
89
|
+
return TableBindableUi(cols, rows)
|
|
90
|
+
|
|
91
|
+
def bind_prop(self, prop: str, ref_ui: ReadonlyRef):
|
|
92
|
+
if prop == "dataframe":
|
|
93
|
+
return self.bind_dataframe(ref_ui)
|
|
94
|
+
|
|
95
|
+
if prop == "rows":
|
|
96
|
+
return self.bind_rows(ref_ui)
|
|
97
|
+
|
|
98
|
+
if prop == "columns":
|
|
99
|
+
return self.bind_columns(ref_ui)
|
|
100
|
+
|
|
101
|
+
return super().bind_prop(prop, ref_ui)
|
|
102
|
+
|
|
103
|
+
def bind_dataframe(self, ref_df: ReadonlyRef):
|
|
104
|
+
@ref_computed
|
|
105
|
+
def cp_converted_df():
|
|
106
|
+
df = ref_df.value
|
|
107
|
+
return utils_common.convert_dataframe(df)
|
|
108
|
+
|
|
109
|
+
@ref_computed
|
|
110
|
+
def cp_rows():
|
|
111
|
+
return cp_converted_df.value.to_dict("records")
|
|
112
|
+
|
|
113
|
+
@ref_computed
|
|
114
|
+
def cp_cols():
|
|
115
|
+
return [
|
|
116
|
+
{
|
|
117
|
+
"name": col,
|
|
118
|
+
"label": col,
|
|
119
|
+
"field": col,
|
|
120
|
+
}
|
|
121
|
+
for col in cp_converted_df.value.columns
|
|
122
|
+
]
|
|
123
|
+
|
|
124
|
+
self.bind_rows(cp_rows).bind_columns(cp_cols)
|
|
125
|
+
|
|
126
|
+
return self
|
|
127
|
+
|
|
128
|
+
def bind_rows(self, ref_ui: ReadonlyRef[List[Dict]]):
|
|
129
|
+
@effect
|
|
130
|
+
def _():
|
|
131
|
+
ele = self.element
|
|
132
|
+
ele._props["rows"] = ref_ui.value
|
|
133
|
+
ele.update()
|
|
134
|
+
|
|
135
|
+
return self
|
|
136
|
+
|
|
137
|
+
def bind_columns(self, ref_ui: ReadonlyRef[List[Dict]]):
|
|
138
|
+
@effect
|
|
139
|
+
def _():
|
|
140
|
+
ele = self.element
|
|
141
|
+
ele._props["columns"] = ref_ui.value
|
|
142
|
+
ele.update()
|
|
143
|
+
|
|
144
|
+
return self
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
from typing import (
|
|
2
|
+
Any,
|
|
3
|
+
Callable,
|
|
4
|
+
Optional,
|
|
5
|
+
Dict,
|
|
6
|
+
)
|
|
7
|
+
from signe import effect
|
|
8
|
+
from ex4nicegui.utils.signals import (
|
|
9
|
+
ReadonlyRef,
|
|
10
|
+
is_ref,
|
|
11
|
+
_TMaybeRef as TMaybeRef,
|
|
12
|
+
)
|
|
13
|
+
from nicegui import ui
|
|
14
|
+
from .base import SingleValueBindableUi
|
|
15
|
+
from .utils import _convert_kws_ref2value
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class TextareaBindableUi(SingleValueBindableUi[str, ui.textarea]):
|
|
19
|
+
def __init__(
|
|
20
|
+
self,
|
|
21
|
+
label: Optional[TMaybeRef[str]] = None,
|
|
22
|
+
*,
|
|
23
|
+
placeholder: Optional[TMaybeRef[str]] = None,
|
|
24
|
+
value: TMaybeRef[str] = "",
|
|
25
|
+
on_change: Optional[Callable[..., Any]] = None,
|
|
26
|
+
validation: Dict[str, Callable[..., bool]] = {},
|
|
27
|
+
) -> None:
|
|
28
|
+
kws = {
|
|
29
|
+
"label": label,
|
|
30
|
+
"placeholder": placeholder,
|
|
31
|
+
"value": value,
|
|
32
|
+
"validation": validation,
|
|
33
|
+
"on_change": on_change,
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
value_kws = _convert_kws_ref2value(kws)
|
|
37
|
+
|
|
38
|
+
element = ui.textarea(**value_kws)
|
|
39
|
+
|
|
40
|
+
super().__init__(value, element)
|
|
41
|
+
|
|
42
|
+
for key, value in kws.items():
|
|
43
|
+
if is_ref(value) and key != "value":
|
|
44
|
+
self.bind_prop(key, value) # type: ignore
|
|
45
|
+
|
|
46
|
+
self._ex_setup()
|
|
47
|
+
|
|
48
|
+
def _ex_setup(self):
|
|
49
|
+
ele = self.element
|
|
50
|
+
|
|
51
|
+
@effect
|
|
52
|
+
def _():
|
|
53
|
+
ele.value = self.value
|
|
54
|
+
|
|
55
|
+
def onModelValueChanged(e):
|
|
56
|
+
self._ref.value = e.args # type: ignore
|
|
57
|
+
|
|
58
|
+
ele.on("update:modelValue", handler=onModelValueChanged)
|
|
59
|
+
|
|
60
|
+
def bind_prop(self, prop: str, ref_ui: ReadonlyRef):
|
|
61
|
+
if prop == "value":
|
|
62
|
+
return self.bind_value(ref_ui)
|
|
63
|
+
|
|
64
|
+
return super().bind_prop(prop, ref_ui)
|
|
65
|
+
|
|
66
|
+
def bind_value(self, ref_ui: ReadonlyRef[bool]):
|
|
67
|
+
@effect
|
|
68
|
+
def _():
|
|
69
|
+
self.element.on_value_change(ref_ui.value)
|
|
70
|
+
|
|
71
|
+
return self
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class LazyTextareaBindableUi(TextareaBindableUi):
|
|
75
|
+
def __init__(
|
|
76
|
+
self,
|
|
77
|
+
label: Optional[TMaybeRef[str]] = None,
|
|
78
|
+
*,
|
|
79
|
+
placeholder: Optional[TMaybeRef[str]] = None,
|
|
80
|
+
value: TMaybeRef[str] = "",
|
|
81
|
+
on_change: Optional[Callable[..., Any]] = None,
|
|
82
|
+
validation: Dict[str, Callable[..., bool]] = {},
|
|
83
|
+
) -> None:
|
|
84
|
+
super().__init__(
|
|
85
|
+
label,
|
|
86
|
+
placeholder=placeholder,
|
|
87
|
+
value=value,
|
|
88
|
+
on_change=on_change,
|
|
89
|
+
validation=validation,
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
def _ex_setup(self):
|
|
93
|
+
ele = self.element
|
|
94
|
+
|
|
95
|
+
@effect
|
|
96
|
+
def _():
|
|
97
|
+
ele.value = self.value
|
|
98
|
+
|
|
99
|
+
def onValueChanged():
|
|
100
|
+
self._ref.value = ele.value
|
|
101
|
+
|
|
102
|
+
ele.on("blur", onValueChanged)
|
|
103
|
+
ele.on("keyup.enter", onValueChanged)
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
from typing import (
|
|
2
|
+
Any,
|
|
3
|
+
Callable,
|
|
4
|
+
Optional,
|
|
5
|
+
)
|
|
6
|
+
from nicegui import events as ng_events
|
|
7
|
+
from ex4nicegui.utils.signals import (
|
|
8
|
+
is_ref,
|
|
9
|
+
_TMaybeRef as TMaybeRef,
|
|
10
|
+
)
|
|
11
|
+
from nicegui import ui
|
|
12
|
+
from .base import SingleValueBindableUi
|
|
13
|
+
from .utils import _convert_kws_ref2value
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class UploadResult:
|
|
17
|
+
def __init__(self, content: bytes = bytes(), name="", type=""):
|
|
18
|
+
self.content = content
|
|
19
|
+
self.name = name
|
|
20
|
+
self.type = type
|
|
21
|
+
|
|
22
|
+
def get_bytes(self):
|
|
23
|
+
return self.content
|
|
24
|
+
|
|
25
|
+
@property
|
|
26
|
+
def ready(self):
|
|
27
|
+
return len(self.content) > 0
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class UploadBindableUi(SingleValueBindableUi[UploadResult, ui.upload]):
|
|
31
|
+
@staticmethod
|
|
32
|
+
def _setup_(binder: "UploadBindableUi"):
|
|
33
|
+
def on_upload(e: ng_events.UploadEventArguments):
|
|
34
|
+
binder._ref.value = UploadResult(e.content.read(), e.name, e.type)
|
|
35
|
+
|
|
36
|
+
binder._on_upload_callbacks.append(on_upload)
|
|
37
|
+
|
|
38
|
+
def __init__(
|
|
39
|
+
self,
|
|
40
|
+
multiple: TMaybeRef[bool] = False,
|
|
41
|
+
max_file_size: Optional[TMaybeRef[int]] = None,
|
|
42
|
+
max_total_size: Optional[TMaybeRef[int]] = None,
|
|
43
|
+
max_files: Optional[TMaybeRef[int]] = None,
|
|
44
|
+
on_upload: Optional[Callable[..., Any]] = None,
|
|
45
|
+
on_rejected: Optional[Callable[..., Any]] = None,
|
|
46
|
+
label: TMaybeRef[str] = "",
|
|
47
|
+
auto_upload: TMaybeRef[bool] = False,
|
|
48
|
+
) -> None:
|
|
49
|
+
kws = {
|
|
50
|
+
"multiple": multiple,
|
|
51
|
+
"max_file_size": max_file_size,
|
|
52
|
+
"max_total_size": max_total_size,
|
|
53
|
+
"max_files": max_files,
|
|
54
|
+
"on_rejected": on_rejected,
|
|
55
|
+
"label": label,
|
|
56
|
+
"auto_upload": auto_upload,
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
value_kws = _convert_kws_ref2value(kws)
|
|
60
|
+
|
|
61
|
+
self._on_upload_callbacks = []
|
|
62
|
+
|
|
63
|
+
def _on_upload(e: ng_events.UploadEventArguments):
|
|
64
|
+
for fn in self._on_upload_callbacks:
|
|
65
|
+
fn(e)
|
|
66
|
+
|
|
67
|
+
if on_upload:
|
|
68
|
+
self._on_upload_callbacks.append(on_upload)
|
|
69
|
+
|
|
70
|
+
element = ui.upload(**value_kws, on_upload=_on_upload)
|
|
71
|
+
|
|
72
|
+
super().__init__(UploadResult(), element) # type: ignore
|
|
73
|
+
|
|
74
|
+
for key, value in kws.items():
|
|
75
|
+
if is_ref(value):
|
|
76
|
+
self.bind_prop(key, value) # type: ignore
|
|
77
|
+
|
|
78
|
+
UploadBindableUi._setup_(self)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
ex4nicegui/__init__.py,sha256=4xyvzRK07ynZjy0C1_dE5ukPivAbX_jA8E0pU2nNflc,337
|
|
2
|
+
ex4nicegui/layout/__init__.py,sha256=YoqBfyScFcWBw8EA77HygHMEc1O5AoQuOHLi6GcXtos,31
|
|
3
|
+
ex4nicegui/layout/gridbox.py,sha256=SWxh62B3q_VrCUNOuVdS1h2SO0zaJy5HFNk1WPNVzAs,2378
|
|
4
|
+
ex4nicegui/reactive/__index.py,sha256=lrR9-goihDlK9zHoPoQGBG62GSlD9_Ry4iR9HAwvZMk,366
|
|
5
|
+
ex4nicegui/reactive/__init__.py,sha256=NZUgvItxqqgzHKrt4oGZnxxV9dlEudGiv4J3fhJdvdQ,24
|
|
6
|
+
ex4nicegui/reactive/drawer.py,sha256=NWMq2gnalpYAU8tT0DwGN5l8n7fuMxTIWxOfr2QvFIA,1356
|
|
7
|
+
ex4nicegui/reactive/local_file_picker.py,sha256=DWNzm_IP02sY-nZWN6WEWJxlwpABW6tNLZ7HA9E88B4,6093
|
|
8
|
+
ex4nicegui/reactive/q_pagination.py,sha256=ITXBrjLnI1a5bz3Rbn7j8lZs9UJaFuMHrM9_FW_V7NA,1217
|
|
9
|
+
ex4nicegui/reactive/rxui.py,sha256=NZUgvItxqqgzHKrt4oGZnxxV9dlEudGiv4J3fhJdvdQ,24
|
|
10
|
+
ex4nicegui/reactive/usePagination.py,sha256=IP1NeLxaH3413KTEjtbyuzq0FVdtnKQsTZqM-W7iEgY,2468
|
|
11
|
+
ex4nicegui/reactive/ECharts/ECharts.js,sha256=ndIGgYm2dztdexPTVX3Eu7NP8pHIO_kcaNpGV861N_k,1581614
|
|
12
|
+
ex4nicegui/reactive/ECharts/ECharts.py,sha256=5hDkDNdfOtXEKJpQyDlL_jEnVv2hH61jJeLV79ZxDMY,2550
|
|
13
|
+
ex4nicegui/reactive/ECharts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
+
ex4nicegui/reactive/UseDraggable/UseDraggable.js,sha256=ogP12fzt-8AHQq1WePA7CzyLvfz2yINTug9rKdTPChw,4857
|
|
15
|
+
ex4nicegui/reactive/UseDraggable/UseDraggable.py,sha256=6urdtCp9XruJKTIlGeJ-8N2CIbmmEKQJmLYwKCrffm0,2888
|
|
16
|
+
ex4nicegui/reactive/UseDraggable/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
|
+
ex4nicegui/reactive/officials/__init__.py,sha256=kbcBw9EQLd5ygKPmJ708-gKhmFpljFkTecsw-R3tPHQ,1330
|
|
18
|
+
ex4nicegui/reactive/officials/aggrid.py,sha256=f70pjKM1snjaDGPZ2EceLcdPI43BzaClurZjr43Tg08,2345
|
|
19
|
+
ex4nicegui/reactive/officials/base.py,sha256=E8n2f2OWzlfxDyb7kn76CnRVaz7b15BlhbKvWO9rDmU,4292
|
|
20
|
+
ex4nicegui/reactive/officials/button.py,sha256=vbp_cCw8mOf9lWn-_YZJWvzuzY-zI0Gy1sGgg0qd9Pw,2250
|
|
21
|
+
ex4nicegui/reactive/officials/card.py,sha256=8-tBwm3xfVybolQ87i8lAYUpBV6FdaVdeSH6xu0736U,1275
|
|
22
|
+
ex4nicegui/reactive/officials/checkbox.py,sha256=s9qJPgJ7w9OdcQaxUe0fWynSb0svCwLisrvX5DvK6p8,1769
|
|
23
|
+
ex4nicegui/reactive/officials/color_picker.py,sha256=s6zUBkCAqAnBnoLWS3bXFIqmCK5iLiQv8VdY_x33H7w,2744
|
|
24
|
+
ex4nicegui/reactive/officials/date.py,sha256=4muMUxoXwV_OYBoe-ucB5g20msT2zjbiyfGNZbKPdoU,2700
|
|
25
|
+
ex4nicegui/reactive/officials/drawer.py,sha256=7XqP8UmkvgxglV1-vUwbo5Sx2Fz7CPr1UqBfriEagDE,2443
|
|
26
|
+
ex4nicegui/reactive/officials/echarts.py,sha256=OfSIk_u_K2gSXWqY3RCZF9QRFdRzw7T_X5okC1oCsvg,1783
|
|
27
|
+
ex4nicegui/reactive/officials/html.py,sha256=7CQWKu_t3MdDJX21fTC3xTMAOcg0gKZrKJsaSCpZ0e4,1687
|
|
28
|
+
ex4nicegui/reactive/officials/icon.py,sha256=NAEPIH-KREMcAszhpd7dOY8uEgrpMxu0Yq5igFTBQZY,1600
|
|
29
|
+
ex4nicegui/reactive/officials/image.py,sha256=tD5lVxWmQ8i9pFBP1AFqJlFCi2QMPd_SwNXEVxS367A,1440
|
|
30
|
+
ex4nicegui/reactive/officials/input.py,sha256=taDseaxPapG4_eyTx3gDPxxexpyrnvX-rOvLupJS08E,3337
|
|
31
|
+
ex4nicegui/reactive/officials/label.py,sha256=hxNefNSLWKTbDV3cfyT35dqiQJfZfHkhQFKxCcjQLwY,1756
|
|
32
|
+
ex4nicegui/reactive/officials/radio.py,sha256=cgCm6zC_0lsvUQHX5LxAB7TNmhkC-GLNaOmbrgbCw-M,2080
|
|
33
|
+
ex4nicegui/reactive/officials/row.py,sha256=ZBPITfHbJmAdAWuIZFl2H1XFS9pJam57PJ_zDZWhueE,404
|
|
34
|
+
ex4nicegui/reactive/officials/select.py,sha256=yU9mq58lAp7GiXUwvVLb1KqOzLOYz97KjDSg0jFtuZs,2482
|
|
35
|
+
ex4nicegui/reactive/officials/slider.py,sha256=cBbJb2Wn4v2aZIhr_oKLTs0JDlXyPbtv6KAeVFEQQL8,2607
|
|
36
|
+
ex4nicegui/reactive/officials/switch.py,sha256=ercV2teK0NHSMyDSHWIMf3NigHZ1IvbhNXUZwNglKo8,1979
|
|
37
|
+
ex4nicegui/reactive/officials/table.py,sha256=MzdFtT3sXv1ORRWPndFKXlMa9G8G3s61pwn_lOS4EWs,3903
|
|
38
|
+
ex4nicegui/reactive/officials/textarea.py,sha256=gXa1rZB83n5AN8Uy8IvFGjKrTQZ-3bXlgkBqe6_xP2A,2728
|
|
39
|
+
ex4nicegui/reactive/officials/upload.py,sha256=uk5qfgGXIV8ThTR7hg5IUdOYRT9iQedogJnrVIK69z0,2337
|
|
40
|
+
ex4nicegui/reactive/officials/utils.py,sha256=9Kbhw7jFPGRyGQ6jN8GgWg2FISz-Ee4dbZtgK44PTzs,205
|
|
41
|
+
ex4nicegui/reactive/useMouse/UseMouse.js,sha256=6FjcYozJK5zFwK1kBP8JlfMyTUwKVK3k_0wSdhapaZs,2722
|
|
42
|
+
ex4nicegui/reactive/useMouse/UseMouse.py,sha256=2CbYCOtZ57HHaWtpS7_gMS4Bz9bS57AP5LaBaANTUy8,2580
|
|
43
|
+
ex4nicegui/reactive/useMouse/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
44
|
+
ex4nicegui/tools/__init__.py,sha256=Ue6ATQC9BuQlJEcs2JnuFXZh4DYh9twKc4F7zpIPhjE,40
|
|
45
|
+
ex4nicegui/tools/debug.py,sha256=HCKlVzhHx5av-983ADgwgMkScKwTreSluLA7uikGYa0,4887
|
|
46
|
+
ex4nicegui/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
47
|
+
ex4nicegui/utils/common.py,sha256=5fsaOkoj-Ild1LGsInZXra66gJLVoVcZGAIG6YOeM6E,430
|
|
48
|
+
ex4nicegui/utils/signals.py,sha256=Dwvb0Anansa0N1ZH2Ko0yCX9o-QHKbXOYEtvdrtde9g,4807
|
|
49
|
+
ex4nicegui-0.2.5.data/data/ECharts/ECharts.js,sha256=ndIGgYm2dztdexPTVX3Eu7NP8pHIO_kcaNpGV861N_k,1581614
|
|
50
|
+
ex4nicegui-0.2.5.data/data/UseDraggable/UseDraggable.js,sha256=ogP12fzt-8AHQq1WePA7CzyLvfz2yINTug9rKdTPChw,4857
|
|
51
|
+
ex4nicegui-0.2.5.data/data/useMouse/UseMouse.js,sha256=6FjcYozJK5zFwK1kBP8JlfMyTUwKVK3k_0wSdhapaZs,2722
|
|
52
|
+
ex4nicegui-0.2.5.dist-info/LICENSE,sha256=0KDDElS2dl-HIsWvbpy8ywbLzJMBFzXLev57LnMIZXs,1094
|
|
53
|
+
ex4nicegui-0.2.5.dist-info/METADATA,sha256=3X6ce9N-HT53GqwMhycJCV_LExVkx2TYFinhBOh5mxI,583
|
|
54
|
+
ex4nicegui-0.2.5.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
|
|
55
|
+
ex4nicegui-0.2.5.dist-info/top_level.txt,sha256=VFwMiO9AFjj5rfLMJwN1ipLRASk9fJXB8tM6DNrpvPQ,11
|
|
56
|
+
ex4nicegui-0.2.5.dist-info/RECORD,,
|