ex4nicegui 0.8.0__py3-none-any.whl → 0.8.2__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 +9 -1
- ex4nicegui/reactive/EChartsComponent/ECharts.py +4 -5
- ex4nicegui/reactive/__init__.py +2 -1
- ex4nicegui/reactive/base.py +108 -50
- ex4nicegui/reactive/mixins/backgroundColor.py +4 -8
- ex4nicegui/reactive/mixins/disableable.py +4 -8
- ex4nicegui/reactive/mixins/textColor.py +8 -10
- ex4nicegui/reactive/officials/checkbox.py +0 -1
- ex4nicegui/reactive/officials/echarts.py +15 -1
- ex4nicegui/reactive/officials/input.py +1 -1
- ex4nicegui/reactive/officials/textarea.py +2 -2
- ex4nicegui/reactive/services/reactive_service.py +2 -1
- ex4nicegui/reactive/vfor.py +4 -0
- ex4nicegui/reactive/view_model.py +147 -6
- ex4nicegui/utils/proxy/__init__.py +19 -0
- ex4nicegui/utils/proxy/base.py +9 -0
- ex4nicegui/utils/proxy/bool.py +58 -0
- ex4nicegui/utils/proxy/date.py +88 -0
- ex4nicegui/utils/proxy/descriptor.py +126 -0
- ex4nicegui/utils/proxy/dict.py +110 -0
- ex4nicegui/utils/proxy/float.py +153 -0
- ex4nicegui/utils/proxy/int.py +223 -0
- ex4nicegui/utils/proxy/list.py +147 -0
- ex4nicegui/utils/proxy/string.py +420 -0
- ex4nicegui/utils/proxy/utils.py +6 -0
- ex4nicegui/utils/signals.py +9 -1
- {ex4nicegui-0.8.0.dist-info → ex4nicegui-0.8.2.dist-info}/METADATA +508 -290
- {ex4nicegui-0.8.0.dist-info → ex4nicegui-0.8.2.dist-info}/RECORD +30 -19
- {ex4nicegui-0.8.0.dist-info → ex4nicegui-0.8.2.dist-info}/LICENSE +0 -0
- {ex4nicegui-0.8.0.dist-info → ex4nicegui-0.8.2.dist-info}/WHEEL +0 -0
|
@@ -56,7 +56,8 @@ export default {
|
|
|
56
56
|
template: "<div></div>",
|
|
57
57
|
async mounted() {
|
|
58
58
|
await new Promise((resolve) => setTimeout(resolve, 0)); // wait for Tailwind classes to be applied
|
|
59
|
-
|
|
59
|
+
|
|
60
|
+
this.chart = echarts.init(this.$el, this.theme, this.initOptions);
|
|
60
61
|
this.resizeObs = new ResizeObserver(this.chart.resize)
|
|
61
62
|
|
|
62
63
|
// Prevent interruption of chart animations due to resize operations.
|
|
@@ -84,6 +85,11 @@ export default {
|
|
|
84
85
|
}
|
|
85
86
|
});
|
|
86
87
|
|
|
88
|
+
if (this.eventTasks) {
|
|
89
|
+
for (const [eventName, query] of Object.entries(this.eventTasks)) {
|
|
90
|
+
this.echarts_on(eventName, query);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
87
93
|
},
|
|
88
94
|
beforeDestroy() {
|
|
89
95
|
this.chart.dispose();
|
|
@@ -116,6 +122,8 @@ export default {
|
|
|
116
122
|
props: {
|
|
117
123
|
options: Object | undefined,
|
|
118
124
|
theme: String | Object | undefined,
|
|
125
|
+
initOptions: Object | undefined,
|
|
119
126
|
code: String | undefined,
|
|
127
|
+
eventTasks: Object | undefined,
|
|
120
128
|
},
|
|
121
129
|
};
|
|
@@ -16,7 +16,6 @@ import nicegui
|
|
|
16
16
|
from .types import (
|
|
17
17
|
_T_event_name,
|
|
18
18
|
)
|
|
19
|
-
from ex4nicegui.reactive.deferredTask import DeferredTask
|
|
20
19
|
from .utils import get_bound_event_args, create_event_handler_args
|
|
21
20
|
|
|
22
21
|
NG_ROOT = Path(nicegui.__file__).parent / "elements"
|
|
@@ -28,9 +27,9 @@ class echarts(Element, component="ECharts.js", dependencies=libraries): # type:
|
|
|
28
27
|
self,
|
|
29
28
|
options: Optional[dict] = None,
|
|
30
29
|
code: Optional[str] = None,
|
|
30
|
+
init_options: Optional[dict] = None,
|
|
31
31
|
) -> None:
|
|
32
32
|
super().__init__()
|
|
33
|
-
self.__deferred_task = DeferredTask()
|
|
34
33
|
|
|
35
34
|
if (options is None) and (bool(code) is False):
|
|
36
35
|
raise ValueError("At least one of options and code must be valid.")
|
|
@@ -45,6 +44,8 @@ class echarts(Element, component="ECharts.js", dependencies=libraries): # type:
|
|
|
45
44
|
|
|
46
45
|
self._props["options"] = options
|
|
47
46
|
self._props["code"] = code
|
|
47
|
+
self._props["initOptions"] = init_options
|
|
48
|
+
self._props["eventTasks"] = {}
|
|
48
49
|
|
|
49
50
|
def update_chart(
|
|
50
51
|
self,
|
|
@@ -107,9 +108,7 @@ class echarts(Element, component="ECharts.js", dependencies=libraries): # type:
|
|
|
107
108
|
ui_event_name = f"chart:{event_name}"
|
|
108
109
|
super().on(ui_event_name, org_handler, args=get_bound_event_args(event_name))
|
|
109
110
|
|
|
110
|
-
|
|
111
|
-
def _():
|
|
112
|
-
self.run_method("echarts_on", ui_event_name, query)
|
|
111
|
+
self._props["eventTasks"][ui_event_name] = query
|
|
113
112
|
|
|
114
113
|
def run_chart_method(
|
|
115
114
|
self, name: str, *args, timeout: float = 1
|
ex4nicegui/reactive/__init__.py
CHANGED
|
@@ -70,7 +70,7 @@ from .mermaid.mermaid import Mermaid as mermaid
|
|
|
70
70
|
from .officials.dialog import DialogBindableUi as dialog
|
|
71
71
|
from .vfor import vfor, VforStore
|
|
72
72
|
from .vmodel import vmodel
|
|
73
|
-
from .view_model import ViewModel, var, cached_var
|
|
73
|
+
from .view_model import ViewModel, var, cached_var, list_var
|
|
74
74
|
|
|
75
75
|
pagination = q_pagination
|
|
76
76
|
|
|
@@ -97,6 +97,7 @@ __all__ = [
|
|
|
97
97
|
"ViewModel",
|
|
98
98
|
"var",
|
|
99
99
|
"cached_var",
|
|
100
|
+
"list_var",
|
|
100
101
|
"html",
|
|
101
102
|
"aggrid",
|
|
102
103
|
"button",
|
ex4nicegui/reactive/base.py
CHANGED
|
@@ -48,6 +48,8 @@ _T_bind_classes_type = Union[
|
|
|
48
48
|
_T_bind_classes_type_ref_dict,
|
|
49
49
|
_T_bind_classes_type_single,
|
|
50
50
|
_T_bind_classes_type_array,
|
|
51
|
+
Dict[str, TMaybeRef[bool]],
|
|
52
|
+
List[str],
|
|
51
53
|
]
|
|
52
54
|
|
|
53
55
|
|
|
@@ -150,6 +152,56 @@ class BindableUi(Generic[TWidget]):
|
|
|
150
152
|
"""
|
|
151
153
|
return self.element.remove(element)
|
|
152
154
|
|
|
155
|
+
@overload
|
|
156
|
+
def bind_props(self, props: Dict[str, TMaybeRef[Any]]) -> Self: ...
|
|
157
|
+
|
|
158
|
+
@overload
|
|
159
|
+
def bind_props(self, props: TMaybeRef[str]) -> Self: ...
|
|
160
|
+
|
|
161
|
+
def bind_props(self, props: Union[Dict[str, TMaybeRef[Any]], TMaybeRef[str]]):
|
|
162
|
+
"""data binding is manipulating an element's props
|
|
163
|
+
|
|
164
|
+
Args:
|
|
165
|
+
props (Union[Dict[str, TMaybeRef[Any]], TMaybeRef[str]]): dict of prop name and ref value
|
|
166
|
+
|
|
167
|
+
## usage
|
|
168
|
+
|
|
169
|
+
.. code-block:: python
|
|
170
|
+
outlined = to_ref(True)
|
|
171
|
+
size = to_ref("xs")
|
|
172
|
+
|
|
173
|
+
def props_str():
|
|
174
|
+
return f'{"flat" if flat.value else ""} {"size=" + size.value}'
|
|
175
|
+
|
|
176
|
+
rxui.button("click me").bind_props(props_str)
|
|
177
|
+
rxui.button("click me").bind_props({
|
|
178
|
+
"outlined": outlined,
|
|
179
|
+
"size": size,
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
"""
|
|
183
|
+
if isinstance(props, dict):
|
|
184
|
+
|
|
185
|
+
def props_str():
|
|
186
|
+
props_dict = (
|
|
187
|
+
f"""{name if isinstance(raw_value,bool) else f"{name}='{raw_value}'"}"""
|
|
188
|
+
for name, value in props.items()
|
|
189
|
+
if (raw_value := to_value(value))
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
return " ".join(props_dict)
|
|
193
|
+
|
|
194
|
+
self._bind_props_for_str_fn(props_str)
|
|
195
|
+
else:
|
|
196
|
+
self._bind_props_for_str_fn(props)
|
|
197
|
+
|
|
198
|
+
return self
|
|
199
|
+
|
|
200
|
+
def _bind_props_for_str_fn(self, props_str: TMaybeRef[str]):
|
|
201
|
+
@self._ui_signal_on(props_str, onchanges=False, deep=False)
|
|
202
|
+
def _(state: WatchedState):
|
|
203
|
+
self.props(add=state.current, remove=state.previous)
|
|
204
|
+
|
|
153
205
|
def bind_prop(self, prop: str, value: TGetterOrReadonlyRef[Any]):
|
|
154
206
|
"""data binding is manipulating an element's property
|
|
155
207
|
|
|
@@ -179,7 +231,7 @@ class BindableUi(Generic[TWidget]):
|
|
|
179
231
|
|
|
180
232
|
return self
|
|
181
233
|
|
|
182
|
-
def bind_visible(self, value:
|
|
234
|
+
def bind_visible(self, value: TMaybeRef[bool]):
|
|
183
235
|
@self._ui_effect
|
|
184
236
|
def _():
|
|
185
237
|
element = cast(ui.element, self.element)
|
|
@@ -187,7 +239,7 @@ class BindableUi(Generic[TWidget]):
|
|
|
187
239
|
|
|
188
240
|
return self
|
|
189
241
|
|
|
190
|
-
def bind_not_visible(self, value:
|
|
242
|
+
def bind_not_visible(self, value: TMaybeRef[bool]):
|
|
191
243
|
return self.bind_visible(lambda: not to_value(value))
|
|
192
244
|
|
|
193
245
|
def on(
|
|
@@ -216,26 +268,28 @@ class BindableUi(Generic[TWidget]):
|
|
|
216
268
|
cast(ui.element, self.element).clear()
|
|
217
269
|
|
|
218
270
|
@overload
|
|
219
|
-
def bind_classes(self, classes: Dict[str, TGetterOrReadonlyRef[bool]]) -> Self:
|
|
220
|
-
|
|
271
|
+
def bind_classes(self, classes: Dict[str, TGetterOrReadonlyRef[bool]]) -> Self: ...
|
|
272
|
+
|
|
273
|
+
@overload
|
|
274
|
+
def bind_classes(self, classes: Dict[str, TMaybeRef[bool]]) -> Self: ...
|
|
221
275
|
|
|
222
276
|
@overload
|
|
223
|
-
def bind_classes(self, classes: TGetterOrReadonlyRef[Dict[str, bool]]) -> Self:
|
|
224
|
-
...
|
|
277
|
+
def bind_classes(self, classes: TGetterOrReadonlyRef[Dict[str, bool]]) -> Self: ...
|
|
225
278
|
|
|
226
279
|
@overload
|
|
227
|
-
def bind_classes(self, classes: List[TGetterOrReadonlyRef[str]]) -> Self:
|
|
228
|
-
...
|
|
280
|
+
def bind_classes(self, classes: List[TGetterOrReadonlyRef[str]]) -> Self: ...
|
|
229
281
|
|
|
230
282
|
@overload
|
|
231
|
-
def bind_classes(self, classes:
|
|
232
|
-
|
|
283
|
+
def bind_classes(self, classes: List[str]) -> Self: ...
|
|
284
|
+
|
|
285
|
+
@overload
|
|
286
|
+
def bind_classes(self, classes: TGetterOrReadonlyRef[str]) -> Self: ...
|
|
233
287
|
|
|
234
288
|
def bind_classes(self, classes: _T_bind_classes_type) -> Self:
|
|
235
289
|
"""data binding is manipulating an element's class list
|
|
236
290
|
|
|
237
|
-
@see - https://github.com/CrystalWindSnake/ex4nicegui/blob/main/README.en.md#
|
|
238
|
-
@中文文档 - https://gitee.com/carson_add/ex4nicegui/tree/main
|
|
291
|
+
@see - https://github.com/CrystalWindSnake/ex4nicegui/blob/main/README.en.md#bind_classes
|
|
292
|
+
@中文文档 - https://gitee.com/carson_add/ex4nicegui/tree/main/#bind_classes
|
|
239
293
|
|
|
240
294
|
Args:
|
|
241
295
|
classes (_T_bind_classes_type): dict of refs | ref to dict | str ref | list of refs
|
|
@@ -271,52 +325,51 @@ class BindableUi(Generic[TWidget]):
|
|
|
271
325
|
|
|
272
326
|
"""
|
|
273
327
|
if isinstance(classes, dict):
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
self.classes(add=name)
|
|
280
|
-
else:
|
|
281
|
-
self.classes(remove=name)
|
|
328
|
+
self._bind_classes_for_str_fn(
|
|
329
|
+
lambda: " ".join(
|
|
330
|
+
name for name, value in classes.items() if to_value(value)
|
|
331
|
+
)
|
|
332
|
+
)
|
|
282
333
|
|
|
334
|
+
elif isinstance(classes, list):
|
|
335
|
+
self._bind_classes_for_str_fn(
|
|
336
|
+
lambda: " ".join(to_value(c) for c in classes)
|
|
337
|
+
)
|
|
283
338
|
elif is_ref(classes) or isinstance(classes, Callable):
|
|
284
339
|
ref_obj = to_value(classes) # type: ignore
|
|
285
340
|
|
|
286
341
|
if isinstance(ref_obj, dict):
|
|
287
342
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
self.classes(remove=name)
|
|
295
|
-
else:
|
|
296
|
-
self._bind_single_class(cast(_T_bind_classes_type_single, classes))
|
|
343
|
+
def classes_str():
|
|
344
|
+
return " ".join(
|
|
345
|
+
name
|
|
346
|
+
for name, value in to_value(classes).items() # type: ignore
|
|
347
|
+
if to_value(value)
|
|
348
|
+
)
|
|
297
349
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
350
|
+
self._bind_classes_for_str_fn(classes_str)
|
|
351
|
+
|
|
352
|
+
else:
|
|
353
|
+
self._bind_classes_for_str_fn(classes) # type: ignore
|
|
301
354
|
|
|
302
355
|
return self
|
|
303
356
|
|
|
304
|
-
def
|
|
305
|
-
|
|
357
|
+
def _bind_classes_for_str_fn(self, classes_str: TGetterOrReadonlyRef[str]):
|
|
358
|
+
@self._ui_signal_on(classes_str, onchanges=False, deep=False)
|
|
359
|
+
def _(state: WatchedState):
|
|
360
|
+
self.classes(add=state.current, remove=state.previous)
|
|
306
361
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
self.classes(add=state.current, remove=state.previous)
|
|
310
|
-
else:
|
|
311
|
-
self.classes(class_name) # type: ignore
|
|
362
|
+
@overload
|
|
363
|
+
def bind_style(self, style: TMaybeRef[str]) -> Self: ...
|
|
312
364
|
|
|
313
|
-
|
|
365
|
+
@overload
|
|
366
|
+
def bind_style(self, style: Dict[str, TMaybeRef[Any]]) -> Self: ...
|
|
314
367
|
|
|
315
|
-
def bind_style(self, style: Dict[str,
|
|
368
|
+
def bind_style(self, style: Union[TMaybeRef[str], Dict[str, TMaybeRef[Any]]]):
|
|
316
369
|
"""data binding is manipulating an element's style
|
|
317
370
|
|
|
318
|
-
@see - https://github.com/CrystalWindSnake/ex4nicegui/blob/main/README.en.md#
|
|
319
|
-
@中文文档 - https://gitee.com/carson_add/ex4nicegui/tree/main/#
|
|
371
|
+
@see - https://github.com/CrystalWindSnake/ex4nicegui/blob/main/README.en.md#bind_style
|
|
372
|
+
@中文文档 - https://gitee.com/carson_add/ex4nicegui/tree/main/#bind_style
|
|
320
373
|
|
|
321
374
|
Args:
|
|
322
375
|
style (Dict[str, Union[ReadonlyRef[str], Ref[str]]]): dict of style name and ref value
|
|
@@ -337,16 +390,21 @@ class BindableUi(Generic[TWidget]):
|
|
|
337
390
|
|
|
338
391
|
"""
|
|
339
392
|
if isinstance(style, dict):
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
393
|
+
self._bind_style_for_str_fn(
|
|
394
|
+
lambda: ";".join(
|
|
395
|
+
f"{name}:{to_value(value)}" for name, value in style.items()
|
|
396
|
+
)
|
|
397
|
+
)
|
|
398
|
+
else:
|
|
399
|
+
self._bind_style_for_str_fn(style)
|
|
347
400
|
|
|
348
401
|
return self
|
|
349
402
|
|
|
403
|
+
def _bind_style_for_str_fn(self, style_str: TMaybeRef[str]):
|
|
404
|
+
@self._ui_signal_on(style_str, onchanges=False, deep=False)
|
|
405
|
+
def _(state: WatchedState):
|
|
406
|
+
self.style(add=state.current, remove=state.previous)
|
|
407
|
+
|
|
350
408
|
def scoped_style(self, selector: str, style: Union[str, Path]):
|
|
351
409
|
"""add scoped style to the element
|
|
352
410
|
|
|
@@ -5,10 +5,7 @@ from typing import (
|
|
|
5
5
|
)
|
|
6
6
|
|
|
7
7
|
import signe
|
|
8
|
-
from ex4nicegui.utils.signals import
|
|
9
|
-
TGetterOrReadonlyRef,
|
|
10
|
-
WatchedState,
|
|
11
|
-
)
|
|
8
|
+
from ex4nicegui.utils.signals import WatchedState, TMaybeRef
|
|
12
9
|
from nicegui import ui
|
|
13
10
|
from ex4nicegui.reactive.systems import color_system
|
|
14
11
|
|
|
@@ -17,10 +14,9 @@ class BackgroundColorableMixin(Protocol):
|
|
|
17
14
|
_ui_signal_on: Callable[[Callable[..., Any]], signe.Effect[None]]
|
|
18
15
|
|
|
19
16
|
@property
|
|
20
|
-
def element(self) -> ui.element:
|
|
21
|
-
...
|
|
17
|
+
def element(self) -> ui.element: ...
|
|
22
18
|
|
|
23
|
-
def _bind_background_color(self, value:
|
|
19
|
+
def _bind_background_color(self, value: TMaybeRef[str]):
|
|
24
20
|
@self._ui_signal_on(value, onchanges=False) # type: ignore
|
|
25
21
|
def _(state: WatchedState):
|
|
26
22
|
if state.previous is not None:
|
|
@@ -30,7 +26,7 @@ class BackgroundColorableMixin(Protocol):
|
|
|
30
26
|
|
|
31
27
|
self.element.update()
|
|
32
28
|
|
|
33
|
-
def bind_color(self, color:
|
|
29
|
+
def bind_color(self, color: TMaybeRef[str]):
|
|
34
30
|
"""bind color to the element
|
|
35
31
|
|
|
36
32
|
Args:
|
|
@@ -8,10 +8,7 @@ from typing import (
|
|
|
8
8
|
)
|
|
9
9
|
|
|
10
10
|
import signe
|
|
11
|
-
from ex4nicegui.utils.signals import
|
|
12
|
-
TGetterOrReadonlyRef,
|
|
13
|
-
to_value,
|
|
14
|
-
)
|
|
11
|
+
from ex4nicegui.utils.signals import to_value, TMaybeRef
|
|
15
12
|
from nicegui.elements.mixins.disableable_element import DisableableElement
|
|
16
13
|
|
|
17
14
|
|
|
@@ -22,10 +19,9 @@ class DisableableMixin(Protocol):
|
|
|
22
19
|
_ui_effect: Callable[[Callable[..., Any]], signe.Effect[None]]
|
|
23
20
|
|
|
24
21
|
@property
|
|
25
|
-
def element(self) -> DisableableElement:
|
|
26
|
-
...
|
|
22
|
+
def element(self) -> DisableableElement: ...
|
|
27
23
|
|
|
28
|
-
def bind_enabled(self, value:
|
|
24
|
+
def bind_enabled(self, value: TMaybeRef[bool]):
|
|
29
25
|
@self._ui_effect
|
|
30
26
|
def _():
|
|
31
27
|
raw_value = to_value(value)
|
|
@@ -34,7 +30,7 @@ class DisableableMixin(Protocol):
|
|
|
34
30
|
|
|
35
31
|
return self
|
|
36
32
|
|
|
37
|
-
def bind_disable(self, value:
|
|
33
|
+
def bind_disable(self, value: TMaybeRef[bool]):
|
|
38
34
|
@self._ui_effect
|
|
39
35
|
def _():
|
|
40
36
|
raw_value = not to_value(value)
|
|
@@ -9,6 +9,7 @@ import signe
|
|
|
9
9
|
from ex4nicegui.utils.signals import (
|
|
10
10
|
TGetterOrReadonlyRef,
|
|
11
11
|
WatchedState,
|
|
12
|
+
TMaybeRef,
|
|
12
13
|
)
|
|
13
14
|
from nicegui import ui
|
|
14
15
|
from ex4nicegui.reactive.systems import color_system
|
|
@@ -18,10 +19,9 @@ class TextColorableMixin(Protocol):
|
|
|
18
19
|
_ui_signal_on: Callable[[Callable[[TGetterOrReadonlyRef[str]], Any]], signe.Effect]
|
|
19
20
|
|
|
20
21
|
@property
|
|
21
|
-
def element(self) -> ui.element:
|
|
22
|
-
...
|
|
22
|
+
def element(self) -> ui.element: ...
|
|
23
23
|
|
|
24
|
-
def _bind_text_color(self, color:
|
|
24
|
+
def _bind_text_color(self, color: TMaybeRef[str]):
|
|
25
25
|
@self._ui_signal_on(color, onchanges=False) # type: ignore
|
|
26
26
|
def _(state: WatchedState):
|
|
27
27
|
if state.previous is not None:
|
|
@@ -31,7 +31,7 @@ class TextColorableMixin(Protocol):
|
|
|
31
31
|
|
|
32
32
|
self.element.update()
|
|
33
33
|
|
|
34
|
-
def bind_color(self, color:
|
|
34
|
+
def bind_color(self, color: TMaybeRef[str]):
|
|
35
35
|
"""bind text color to the element
|
|
36
36
|
|
|
37
37
|
Args:
|
|
@@ -46,16 +46,14 @@ class HtmlTextColorableMixin(Protocol):
|
|
|
46
46
|
_ui_signal_on: Callable[[Callable[[TGetterOrReadonlyRef[str]], Any]], signe.Effect]
|
|
47
47
|
|
|
48
48
|
@property
|
|
49
|
-
def element(self) -> ui.element:
|
|
50
|
-
...
|
|
49
|
+
def element(self) -> ui.element: ...
|
|
51
50
|
|
|
52
|
-
def bind_style(self, style: Dict[str,
|
|
53
|
-
...
|
|
51
|
+
def bind_style(self, style: Dict[str, TMaybeRef[Any]]): ...
|
|
54
52
|
|
|
55
|
-
def _bind_text_color(self, value:
|
|
53
|
+
def _bind_text_color(self, value: TMaybeRef[str]):
|
|
56
54
|
return self.bind_style({"color": value})
|
|
57
55
|
|
|
58
|
-
def bind_color(self, color:
|
|
56
|
+
def bind_color(self, color: TMaybeRef[str]):
|
|
59
57
|
"""bind text color to the element
|
|
60
58
|
|
|
61
59
|
Args:
|
|
@@ -27,9 +27,23 @@ class EChartsBindableUi(BindableUi[echarts]):
|
|
|
27
27
|
options: Optional[TMaybeRef[Dict]] = None,
|
|
28
28
|
not_merge: TMaybeRef[Union[bool, None]] = None,
|
|
29
29
|
code: Optional[str] = None,
|
|
30
|
+
init_options: Optional[Dict] = None,
|
|
30
31
|
) -> None:
|
|
32
|
+
"""Create a new ECharts instance.
|
|
33
|
+
|
|
34
|
+
@see - https://github.com/CrystalWindSnake/ex4nicegui/blob/main/README.en.md#rxuiecharts
|
|
35
|
+
@中文文档 - https://gitee.com/carson_add/ex4nicegui#rxuiecharts
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
options (Optional[TMaybeRef[Dict]], optional): echart options. Defaults to None.
|
|
39
|
+
not_merge (TMaybeRef[Union[bool, None]], optional): merge options when chart update. Defaults to None.
|
|
40
|
+
code (Optional[str], optional): javascript code to initialize echart. Defaults to None.
|
|
41
|
+
init_options (Optional[Dict], optional): echart initialization options. Defaults to None.
|
|
42
|
+
"""
|
|
31
43
|
pc = ParameterClassifier(
|
|
32
|
-
locals(),
|
|
44
|
+
locals(),
|
|
45
|
+
maybeRefs=["options", "code", "init_options"],
|
|
46
|
+
exclude=["not_merge"],
|
|
33
47
|
)
|
|
34
48
|
|
|
35
49
|
value_kws = pc.get_values_kws()
|
|
@@ -90,7 +90,7 @@ class LazyInputBindableUi(InputBindableUi):
|
|
|
90
90
|
password_toggle_button: TMaybeRef[bool] = False,
|
|
91
91
|
on_change: Optional[Callable[..., Any]] = None,
|
|
92
92
|
autocomplete: Optional[TMaybeRef[List[str]]] = None,
|
|
93
|
-
validation: Dict[str, Callable[..., bool]] =
|
|
93
|
+
validation: Optional[Dict[str, Callable[..., bool]]] = None,
|
|
94
94
|
) -> None:
|
|
95
95
|
org_value = value
|
|
96
96
|
is_setter_value = is_setter_ref(value)
|
|
@@ -27,7 +27,7 @@ class TextareaBindableUi(BindableUi[ui.textarea], ValueElementMixin[str]):
|
|
|
27
27
|
placeholder: Optional[TMaybeRef[str]] = None,
|
|
28
28
|
value: TMaybeRef[str] = "",
|
|
29
29
|
on_change: Optional[Callable[..., Any]] = None,
|
|
30
|
-
validation: Dict[str, Callable[..., bool]] =
|
|
30
|
+
validation: Optional[Dict[str, Callable[..., bool]]] = None,
|
|
31
31
|
) -> None:
|
|
32
32
|
pc = ParameterClassifier(
|
|
33
33
|
locals(),
|
|
@@ -68,7 +68,7 @@ class LazyTextareaBindableUi(TextareaBindableUi):
|
|
|
68
68
|
placeholder: Optional[TMaybeRef[str]] = None,
|
|
69
69
|
value: TMaybeRef[str] = "",
|
|
70
70
|
on_change: Optional[Callable[..., Any]] = None,
|
|
71
|
-
validation: Dict[str, Callable[..., bool]] =
|
|
71
|
+
validation: Optional[Dict[str, Callable[..., bool]]] = None,
|
|
72
72
|
) -> None:
|
|
73
73
|
org_value = value
|
|
74
74
|
is_setter_value = is_setter_ref(value)
|
|
@@ -15,6 +15,7 @@ from ex4nicegui.reactive.systems.reactive_system import (
|
|
|
15
15
|
convert_kws_ref2value,
|
|
16
16
|
inject_method,
|
|
17
17
|
)
|
|
18
|
+
from ex4nicegui.utils.proxy import is_base_type_proxy
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
class ParameterClassifier:
|
|
@@ -34,7 +35,7 @@ class ParameterClassifier:
|
|
|
34
35
|
exclude.append(extend_kws)
|
|
35
36
|
|
|
36
37
|
self._args: Dict[str, Any] = {
|
|
37
|
-
k: v
|
|
38
|
+
k: v._ref if is_base_type_proxy(v) else v
|
|
38
39
|
for k, v in args.items()
|
|
39
40
|
if k != "self" and k[0] != "_" and (k not in exclude)
|
|
40
41
|
}
|
ex4nicegui/reactive/vfor.py
CHANGED
|
@@ -28,6 +28,8 @@ from dataclasses import dataclass
|
|
|
28
28
|
from signe.core.scope import Scope
|
|
29
29
|
from ex4nicegui.reactive.systems.object_system import get_attribute
|
|
30
30
|
from ex4nicegui.reactive.empty import Empty
|
|
31
|
+
from ex4nicegui.utils.proxy import to_ref_if_base_type_proxy
|
|
32
|
+
|
|
31
33
|
|
|
32
34
|
_T = TypeVar("_T")
|
|
33
35
|
_T_data = Union[List[Any], TGetterOrReadonlyRef[List[Any]], RefWrapper]
|
|
@@ -178,6 +180,8 @@ class vfor(Generic[_T]):
|
|
|
178
180
|
*,
|
|
179
181
|
key: Optional[Union[str, Callable[[int, Any], Any]]] = None,
|
|
180
182
|
) -> None:
|
|
183
|
+
data = to_ref_if_base_type_proxy(data)
|
|
184
|
+
|
|
181
185
|
self._data = to_ref_wrapper(lambda: data) if is_reactive(data) else data
|
|
182
186
|
self._get_key = vfor.index_key
|
|
183
187
|
self._transition_props = {}
|