ex4nicegui 0.6.9__py3-none-any.whl → 0.7.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. ex4nicegui/bi/dataSourceFacade.py +20 -20
  2. ex4nicegui/bi/index.py +20 -23
  3. ex4nicegui/reactive/EChartsComponent/ECharts.py +9 -8
  4. ex4nicegui/reactive/__init__.py +14 -0
  5. ex4nicegui/reactive/base.py +64 -55
  6. ex4nicegui/reactive/mixins/backgroundColor.py +5 -5
  7. ex4nicegui/reactive/mixins/disableable.py +8 -8
  8. ex4nicegui/reactive/mixins/textColor.py +10 -10
  9. ex4nicegui/reactive/officials/aggrid.py +5 -5
  10. ex4nicegui/reactive/officials/avatar.py +86 -0
  11. ex4nicegui/reactive/officials/badge.py +102 -0
  12. ex4nicegui/reactive/officials/button.py +15 -15
  13. ex4nicegui/reactive/officials/checkbox.py +6 -7
  14. ex4nicegui/reactive/officials/chip.py +6 -7
  15. ex4nicegui/reactive/officials/circular_progress.py +7 -7
  16. ex4nicegui/reactive/officials/color_picker.py +8 -8
  17. ex4nicegui/reactive/officials/column.py +5 -5
  18. ex4nicegui/reactive/officials/date.py +6 -6
  19. ex4nicegui/reactive/officials/dialog.py +49 -0
  20. ex4nicegui/reactive/officials/echarts.py +49 -51
  21. ex4nicegui/reactive/officials/expansion.py +6 -6
  22. ex4nicegui/reactive/officials/icon.py +7 -13
  23. ex4nicegui/reactive/officials/image.py +6 -6
  24. ex4nicegui/reactive/officials/input.py +10 -11
  25. ex4nicegui/reactive/officials/knob.py +7 -7
  26. ex4nicegui/reactive/officials/label.py +11 -9
  27. ex4nicegui/reactive/officials/linear_progress.py +7 -7
  28. ex4nicegui/reactive/officials/number.py +10 -10
  29. ex4nicegui/reactive/officials/radio.py +10 -10
  30. ex4nicegui/reactive/officials/row.py +5 -5
  31. ex4nicegui/reactive/officials/select.py +11 -10
  32. ex4nicegui/reactive/officials/slider.py +6 -6
  33. ex4nicegui/reactive/officials/switch.py +6 -7
  34. ex4nicegui/reactive/officials/tab.py +0 -12
  35. ex4nicegui/reactive/officials/tab_panels.py +5 -5
  36. ex4nicegui/reactive/officials/table.py +13 -13
  37. ex4nicegui/reactive/officials/tabs.py +5 -5
  38. ex4nicegui/reactive/officials/textarea.py +6 -6
  39. ex4nicegui/reactive/officials/toggle.py +88 -0
  40. ex4nicegui/reactive/officials/tooltip.py +40 -0
  41. ex4nicegui/reactive/q_pagination.py +5 -5
  42. ex4nicegui/reactive/systems/reactive_system.py +2 -2
  43. ex4nicegui/reactive/vfor.js +14 -4
  44. ex4nicegui/reactive/vfor.py +128 -58
  45. ex4nicegui/reactive/view_model.py +160 -0
  46. ex4nicegui/reactive/vmodel.py +42 -12
  47. ex4nicegui/utils/signals.py +23 -21
  48. {ex4nicegui-0.6.9.dist-info → ex4nicegui-0.7.1.dist-info}/METADATA +223 -48
  49. {ex4nicegui-0.6.9.dist-info → ex4nicegui-0.7.1.dist-info}/RECORD +51 -45
  50. {ex4nicegui-0.6.9.dist-info → ex4nicegui-0.7.1.dist-info}/LICENSE +0 -0
  51. {ex4nicegui-0.6.9.dist-info → ex4nicegui-0.7.1.dist-info}/WHEEL +0 -0
@@ -0,0 +1,102 @@
1
+ from typing import Optional
2
+ from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
3
+ from ex4nicegui.utils.signals import (
4
+ TGetterOrReadonlyRef,
5
+ to_value,
6
+ _TMaybeRef as TMaybeRef,
7
+ )
8
+ from nicegui import ui
9
+ from .base import BindableUi
10
+ from ex4nicegui.reactive.mixins.backgroundColor import BackgroundColorableMixin
11
+ from ex4nicegui.reactive.mixins.textColor import TextColorableMixin
12
+
13
+
14
+ class BadgeBindableUi(
15
+ BindableUi[ui.badge],
16
+ BackgroundColorableMixin,
17
+ TextColorableMixin,
18
+ ):
19
+ def __init__(
20
+ self,
21
+ text: TMaybeRef[str] = "",
22
+ *,
23
+ color: Optional[TMaybeRef[str]] = "primary",
24
+ text_color: Optional[TMaybeRef[str]] = None,
25
+ outline: TMaybeRef[bool] = False,
26
+ ) -> None:
27
+ """Badge
28
+
29
+ A badge element wrapping Quasar's
30
+ `QBadge <https://quasar.dev/vue-components/badge>`_ component.
31
+
32
+ :param text: the initial value of the text field
33
+ :param color: the color name for component (either a Quasar, Tailwind, or CSS color or `None`, default: "primary")
34
+ :param text_color: text color (either a Quasar, Tailwind, or CSS color or `None`, default: `None`)
35
+ :param outline: use 'outline' design (colored text and borders only) (default: False)
36
+ """
37
+ pc = ParameterClassifier(
38
+ locals(),
39
+ maybeRefs=[
40
+ "text",
41
+ "color",
42
+ "text_color",
43
+ "outline",
44
+ ],
45
+ events=[],
46
+ )
47
+
48
+ element = ui.badge(**pc.get_values_kws())
49
+ super().__init__(element)
50
+
51
+ for key, value in pc.get_bindings().items():
52
+ self.bind_prop(key, value) # type: ignore
53
+
54
+ @property
55
+ def text(self):
56
+ return self.element.text
57
+
58
+ def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
59
+ if prop == "text":
60
+ return self.bind_text(value)
61
+
62
+ if prop == "color":
63
+ return self.bind_color(value)
64
+ if prop == "text-color":
65
+ return self.bind_text_color(value)
66
+
67
+ return super().bind_prop(prop, value)
68
+
69
+ def bind_color(self, color: TGetterOrReadonlyRef):
70
+ """Binds the background color property of the chip to a ui element.
71
+
72
+ Args:
73
+ color (TGetterOrReadonlyRef): background color ui element or getter function
74
+
75
+ """
76
+ BackgroundColorableMixin.bind_color(self, color)
77
+ return self
78
+
79
+ def bind_text_color(self, color: TGetterOrReadonlyRef):
80
+ """Binds the text color property of the chip to a ui element.
81
+
82
+ Args:
83
+ color (TGetterOrReadonlyRef): text color ui element or getter function
84
+
85
+
86
+ """
87
+ TextColorableMixin.bind_color(self, color)
88
+ return self
89
+
90
+ def bind_text(self, text: TGetterOrReadonlyRef):
91
+ """Binds the text property of the chip to a ui element.
92
+
93
+ Args:
94
+ text (TGetterOrReadonlyRef): text ui element or getter function
95
+
96
+ """
97
+
98
+ @self._ui_signal_on(text)
99
+ def _():
100
+ self.element.set_text(str(to_value(text)))
101
+
102
+ return self
@@ -44,50 +44,50 @@ class ButtonBindableUi(
44
44
  for key, value in pc.get_bindings().items():
45
45
  self.bind_prop(key, value) # type: ignore
46
46
 
47
- def bind_prop(self, prop: str, ref_ui: TGetterOrReadonlyRef):
47
+ def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
48
48
  if prop == "text":
49
- return self.bind_text(ref_ui)
49
+ return self.bind_text(value)
50
50
  if prop == "icon":
51
- return self.bind_icon(ref_ui)
51
+ return self.bind_icon(value)
52
52
  if prop == "color":
53
- return self.bind_color(ref_ui)
53
+ return self.bind_color(value)
54
54
 
55
- return super().bind_prop(prop, ref_ui)
55
+ return super().bind_prop(prop, value)
56
56
 
57
- def bind_color(self, ref_ui: TGetterOrReadonlyRef[str]):
57
+ def bind_color(self, color: TGetterOrReadonlyRef[str]):
58
58
  """Binds the background color of the button.
59
59
 
60
60
  Args:
61
- ref_ui (TGetterOrReadonlyRef[str]): Getter or readonly reference to the color.
61
+ color (TGetterOrReadonlyRef[str]): Getter or readonly reference to the color.
62
62
 
63
63
  """
64
- BackgroundColorableMixin.bind_color(self, ref_ui)
64
+ BackgroundColorableMixin.bind_color(self, color)
65
65
  return self
66
66
 
67
- def bind_text_color(self, ref_ui: TGetterOrReadonlyRef[str]):
67
+ def bind_text_color(self, text_color: TGetterOrReadonlyRef[str]):
68
68
  """Binds the text color of the button.
69
69
 
70
70
  Args:
71
- ref_ui (TGetterOrReadonlyRef[str]): Getter or readonly reference to the color.
71
+ text_color (TGetterOrReadonlyRef[str]): Getter or readonly reference to the color.
72
72
 
73
73
  """
74
- TextColorableMixin.bind_color(self, ref_ui)
74
+ TextColorableMixin.bind_color(self, text_color)
75
75
  return self
76
76
 
77
- def bind_text(self, ref_ui: TGetterOrReadonlyRef):
77
+ def bind_text(self, text: TGetterOrReadonlyRef):
78
78
  @self._ui_effect
79
79
  def _():
80
80
  ele = self.element
81
- ele._props["label"] = to_value(ref_ui)
81
+ ele._props["label"] = to_value(text)
82
82
  ele.update()
83
83
 
84
84
  return self
85
85
 
86
- def bind_icon(self, ref_ui: TGetterOrReadonlyRef[str]):
86
+ def bind_icon(self, icon: TGetterOrReadonlyRef[str]):
87
87
  @self._ui_effect
88
88
  def _():
89
89
  ele = self.element
90
- ele._props["icon"] = to_value(ref_ui)
90
+ ele._props["icon"] = to_value(icon)
91
91
  ele.update()
92
92
 
93
93
  return self
@@ -43,16 +43,15 @@ class CheckboxBindableUi(BindableUi[ui.checkbox], DisableableMixin):
43
43
  def value(self):
44
44
  return self.element.value
45
45
 
46
- def bind_prop(self, prop: str, ref_ui: TGetterOrReadonlyRef):
46
+ def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
47
47
  if prop == "value":
48
- return self.bind_value(ref_ui)
48
+ return self.bind_value(value)
49
49
 
50
- return super().bind_prop(prop, ref_ui)
50
+ return super().bind_prop(prop, value)
51
51
 
52
- def bind_value(self, ref_ui: TGetterOrReadonlyRef[bool]):
53
- @self._ui_effect
52
+ def bind_value(self, value: TGetterOrReadonlyRef[bool]):
53
+ @self._ui_signal_on(value)
54
54
  def _():
55
- self.element.set_value(to_value(ref_ui))
56
- self.element.update()
55
+ self.element.set_value(to_value(value))
57
56
 
58
57
  return self
@@ -54,16 +54,16 @@ class ChipBindableUi(
54
54
  def text(self):
55
55
  return self.element.text
56
56
 
57
- def bind_prop(self, prop: str, ref_ui: TGetterOrReadonlyRef):
57
+ def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
58
58
  if prop == "text":
59
- return self.bind_text(ref_ui)
59
+ return self.bind_text(value)
60
60
 
61
61
  if prop == "color":
62
- return self.bind_color(ref_ui)
62
+ return self.bind_color(value)
63
63
  if prop == "text-color":
64
- return self.bind_text_color(ref_ui)
64
+ return self.bind_text_color(value)
65
65
 
66
- return super().bind_prop(prop, ref_ui)
66
+ return super().bind_prop(prop, value)
67
67
 
68
68
  def bind_color(self, color: TGetterOrReadonlyRef):
69
69
  """Binds the background color property of the chip to a ui element.
@@ -94,9 +94,8 @@ class ChipBindableUi(
94
94
 
95
95
  """
96
96
 
97
- @self._ui_effect
97
+ @self._ui_signal_on(text)
98
98
  def _():
99
99
  self.element.set_text(str(to_value(text)))
100
- self.element.update()
101
100
 
102
101
  return self
@@ -49,17 +49,17 @@ class CircularProgressBindableUi(
49
49
  def value(self):
50
50
  return self.element.value
51
51
 
52
- def bind_prop(self, prop: str, ref_ui: TGetterOrReadonlyRef):
52
+ def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
53
53
  if prop == "value":
54
- return self.bind_value(ref_ui)
54
+ return self.bind_value(value)
55
55
  if prop == "color":
56
- return self.bind_color(ref_ui)
56
+ return self.bind_color(value)
57
57
 
58
- return super().bind_prop(prop, ref_ui)
58
+ return super().bind_prop(prop, value)
59
59
 
60
- def bind_value(self, ref_ui: TGetterOrReadonlyRef[float]):
61
- @self._ui_effect
60
+ def bind_value(self, value: TGetterOrReadonlyRef[float]):
61
+ @self._ui_signal_on(value)
62
62
  def _():
63
- self.element.set_value(to_value(ref_ui))
63
+ self.element.set_value(to_value(value))
64
64
 
65
65
  return self
@@ -68,23 +68,23 @@ class ColorPickerBindableUi(BindableUi[ui.color_picker]):
68
68
  def value(self):
69
69
  return self.element.value
70
70
 
71
- def bind_prop(self, prop: str, ref_ui: TGetterOrReadonlyRef):
71
+ def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
72
72
  if prop == "value":
73
- return self.bind_value(ref_ui)
73
+ return self.bind_value(value)
74
74
 
75
- return super().bind_prop(prop, ref_ui)
75
+ return super().bind_prop(prop, value)
76
76
 
77
- def bind_color(self, ref_ui: TGetterOrReadonlyRef[str]):
77
+ def bind_color(self, color: TGetterOrReadonlyRef[str]):
78
78
  @self._ui_effect
79
79
  def _():
80
- self.element.set_color(to_value(ref_ui))
80
+ self.element.set_color(to_value(color))
81
81
 
82
82
  return self
83
83
 
84
- def bind_value(self, ref_ui: TGetterOrReadonlyRef[bool]):
85
- @self._ui_effect
84
+ def bind_value(self, value: TGetterOrReadonlyRef[bool]):
85
+ @self._ui_signal_on(value)
86
86
  def _():
87
- self.element.set_value(to_value(ref_ui))
87
+ self.element.set_value(to_value(value))
88
88
 
89
89
  return self
90
90
 
@@ -20,14 +20,14 @@ class ColumnBindableUi(BindableUi[ui.column]):
20
20
  for key, value in pc.get_bindings().items():
21
21
  self.bind_prop(key, value) # type: ignore
22
22
 
23
- def bind_prop(self, prop: str, ref_ui: TGetterOrReadonlyRef):
23
+ def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
24
24
  if prop == "wrap":
25
- return self.bind_wrap(ref_ui)
25
+ return self.bind_wrap(value)
26
26
 
27
- return super().bind_prop(prop, ref_ui)
27
+ return super().bind_prop(prop, value)
28
28
 
29
- def bind_wrap(self, ref_ui: TGetterOrReadonlyRef):
30
- self.bind_classes({"wrap": ref_ui})
29
+ def bind_wrap(self, value: TGetterOrReadonlyRef):
30
+ self.bind_classes({"wrap": value})
31
31
 
32
32
  def __enter__(self):
33
33
  self.element.__enter__()
@@ -62,15 +62,15 @@ class DateBindableUi(BindableUi[ui.date]):
62
62
  def value(self):
63
63
  return self.element.value
64
64
 
65
- def bind_prop(self, prop: str, ref_ui: TGetterOrReadonlyRef):
65
+ def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
66
66
  if prop == "value":
67
- return self.bind_value(ref_ui)
67
+ return self.bind_value(value)
68
68
 
69
- return super().bind_prop(prop, ref_ui)
69
+ return super().bind_prop(prop, value)
70
70
 
71
- def bind_value(self, ref_ui: TGetterOrReadonlyRef[bool]):
72
- @self._ui_effect
71
+ def bind_value(self, value: TGetterOrReadonlyRef[bool]):
72
+ @self._ui_signal_on(value)
73
73
  def _():
74
- self.element.set_value(to_value(ref_ui))
74
+ self.element.set_value(to_value(value))
75
75
 
76
76
  return self
@@ -0,0 +1,49 @@
1
+ from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
2
+ from ex4nicegui.utils.signals import (
3
+ _TMaybeRef as TMaybeRef,
4
+ is_setter_ref,
5
+ to_value,
6
+ TGetterOrReadonlyRef,
7
+ )
8
+ from nicegui import ui
9
+ from .base import BindableUi
10
+
11
+
12
+ class DialogBindableUi(BindableUi[ui.dialog]):
13
+ def __init__(
14
+ self,
15
+ *,
16
+ value: TMaybeRef[bool] = False,
17
+ ) -> None:
18
+ pc = ParameterClassifier(locals(), maybeRefs=["value"])
19
+
20
+ value_kws = pc.get_values_kws()
21
+ element = ui.dialog(**value_kws)
22
+ super().__init__(element) # type: ignore
23
+
24
+ if is_setter_ref(value):
25
+
26
+ def on_value_change():
27
+ value.value = element.value # type: ignore
28
+
29
+ element.on_value_change(on_value_change)
30
+
31
+ for key, value in pc.get_bindings().items():
32
+ self.bind_prop(key, value) # type: ignore
33
+
34
+ @property
35
+ def value(self):
36
+ return self.element.value
37
+
38
+ def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
39
+ if prop == "value":
40
+ return self.bind_value(value)
41
+
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
@@ -119,31 +119,30 @@ class EChartsBindableUi(BindableUi[echarts]):
119
119
 
120
120
  ## Examples
121
121
 
122
- ```python
123
- rxui.echarts.from_javascript(
124
- r'''(myChart) => {
125
- option = {...};
126
- myChart.setOption(option);
127
- }
128
- ''')
129
- ```
122
+ .. code-block:: python
123
+ rxui.echarts.from_javascript(
124
+ r'''(myChart) => {
125
+ option = {...};
126
+ myChart.setOption(option);
127
+ }
128
+ ''')
130
129
 
131
130
  """
132
131
  if isinstance(code, Path):
133
132
  code = code.read_text("utf8")
134
133
  return cls(code=code)
135
134
 
136
- def bind_prop(self, prop: str, ref_ui: TGetterOrReadonlyRef):
135
+ def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
137
136
  if prop == "options":
138
- return self.bind_options(ref_ui)
137
+ return self.bind_options(value)
139
138
 
140
- return super().bind_prop(prop, ref_ui)
139
+ return super().bind_prop(prop, value)
141
140
 
142
- def bind_options(self, ref_ui: TGetterOrReadonlyRef[Dict]):
143
- @self._ui_signal_on(ref_ui)
141
+ def bind_options(self, options: TGetterOrReadonlyRef[Dict]):
142
+ @self._ui_signal_on(options, deep=True)
144
143
  def _():
145
144
  ele = self.element
146
- ele.update_options(to_raw(to_value(ref_ui)), self.__update_setting)
145
+ ele.update_options(to_raw(to_value(options)), self.__update_setting)
147
146
  ele.update()
148
147
 
149
148
  return self
@@ -171,58 +170,57 @@ class EChartsBindableUi(BindableUi[echarts]):
171
170
  ---
172
171
 
173
172
  ### click event:
174
- ```python
175
- bar = rxui.echarts(opts)
176
173
 
177
- def on_click(e):
178
- ui.notify(f"on_click:{e}")
174
+ .. code-block:: python
175
+ bar = rxui.echarts(opts)
176
+
177
+ def on_click(e):
178
+ ui.notify(f"on_click:{e}")
179
179
 
180
- bar.on("click", on_click)
181
- ```
180
+ bar.on("click", on_click)
182
181
 
183
182
  ---
184
183
 
185
184
  ### Use query to trigger callback of the specified component:
186
185
 
187
- ```python
188
- ...
189
- def on_line_click(e):
190
- ui.notify(e)
186
+ .. code-block:: python
187
+ ...
188
+ def on_line_click(e):
189
+ ui.notify(e)
190
+
191
+ bar.on("click", on_line_click,query='series.line')
191
192
 
192
- bar.on("click", on_line_click,query='series.line')
193
- ```
194
193
 
195
194
  ---
196
195
  ### only trigger for specified series
197
- ```python
198
-
199
- opts = {
200
- "xAxis": {"type": "value", "boundaryGap": [0, 0.01]},
201
- "yAxis": {
202
- "type": "category",
203
- "data": ["Brazil", "Indonesia", "USA", "India", "China", "World"],
204
- },
205
- "series": [
206
- {
207
- "name": "first",
208
- "type": "bar",
209
- "data": [18203, 23489, 29034, 104970, 131744, 630230],
210
- },
211
- {
212
- "name": "second",
213
- "type": "bar",
214
- "data": [19325, 23438, 31000, 121594, 134141, 681807],
196
+
197
+ .. code-block:: python
198
+ opts = {
199
+ "xAxis": {"type": "value", "boundaryGap": [0, 0.01]},
200
+ "yAxis": {
201
+ "type": "category",
202
+ "data": ["Brazil", "Indonesia", "USA", "India", "China", "World"],
215
203
  },
216
- ],
217
- }
204
+ "series": [
205
+ {
206
+ "name": "first",
207
+ "type": "bar",
208
+ "data": [18203, 23489, 29034, 104970, 131744, 630230],
209
+ },
210
+ {
211
+ "name": "second",
212
+ "type": "bar",
213
+ "data": [19325, 23438, 31000, 121594, 134141, 681807],
214
+ },
215
+ ],
216
+ }
218
217
 
219
- bar = rxui.echarts(opts)
218
+ bar = rxui.echarts(opts)
220
219
 
221
- def on_first_series_mouseover(e):
222
- ui.notify(f"on_first_series_mouseover:{e}")
220
+ def on_first_series_mouseover(e):
221
+ ui.notify(f"on_first_series_mouseover:{e}")
223
222
 
224
- bar.on("mouseover", on_first_series_mouseover, query={"seriesName": "first"})
225
- ```
223
+ bar.on("mouseover", on_first_series_mouseover, query={"seriesName": "first"})
226
224
 
227
225
  ---
228
226
  """
@@ -45,16 +45,16 @@ class ExpansionBindableUi(BindableUi[ui.expansion]):
45
45
  def value(self):
46
46
  return self.element.value
47
47
 
48
- def bind_prop(self, prop: str, ref_ui: TGetterOrReadonlyRef):
48
+ def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
49
49
  if prop == "value":
50
- return self.bind_value(ref_ui)
50
+ return self.bind_value(value)
51
51
 
52
- return super().bind_prop(prop, ref_ui)
52
+ return super().bind_prop(prop, value)
53
53
 
54
- def bind_value(self, ref_ui: TGetterOrReadonlyRef):
55
- @self._ui_effect
54
+ def bind_value(self, value: TGetterOrReadonlyRef):
55
+ @self._ui_signal_on(value)
56
56
  def _():
57
- self.element.set_value(to_value(ref_ui))
57
+ self.element.set_value(to_value(value))
58
58
 
59
59
  return self
60
60
 
@@ -1,6 +1,5 @@
1
1
  from typing import (
2
2
  Optional,
3
- cast,
4
3
  )
5
4
  from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
6
5
  from ex4nicegui.utils.signals import (
@@ -9,9 +8,6 @@ from ex4nicegui.utils.signals import (
9
8
  to_value,
10
9
  )
11
10
  from nicegui import ui
12
- from nicegui.elements.mixins.color_elements import (
13
- TextColorElement,
14
- )
15
11
  from .base import BindableUi
16
12
  from ex4nicegui.reactive.mixins.textColor import TextColorableMixin
17
13
 
@@ -34,20 +30,18 @@ class IconBindableUi(BindableUi[ui.icon], TextColorableMixin):
34
30
  for key, value in pc.get_bindings().items():
35
31
  self.bind_prop(key, value) # type: ignore
36
32
 
37
- def bind_prop(self, prop: str, ref_ui: TGetterOrReadonlyRef):
33
+ def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
38
34
  if prop == "name":
39
- return self.bind_name(ref_ui)
35
+ return self.bind_name(value)
40
36
 
41
37
  if prop == "color":
42
- return self.bind_color(ref_ui)
38
+ return self.bind_color(value)
43
39
 
44
- return super().bind_prop(prop, ref_ui)
40
+ return super().bind_prop(prop, value)
45
41
 
46
- def bind_name(self, ref_ui: TGetterOrReadonlyRef):
47
- @self._ui_effect
42
+ def bind_name(self, name: TGetterOrReadonlyRef):
43
+ @self._ui_signal_on(name)
48
44
  def _():
49
- ele = cast(TextColorElement, self.element)
50
- ele._props["name"] = to_value(ref_ui)
51
- ele.update()
45
+ self.element.set_name(to_value(name))
52
46
 
53
47
  return self
@@ -25,13 +25,13 @@ class ImageBindableUi(BindableUi[ui.image]):
25
25
  for key, value in pc.get_bindings().items():
26
26
  self.bind_prop(key, value) # type: ignore
27
27
 
28
- def bind_prop(self, prop: str, ref_ui: TGetterOrReadonlyRef):
28
+ def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
29
29
  if prop == "source":
30
- return self.bind_source(ref_ui)
30
+ return self.bind_source(value)
31
31
 
32
- return super().bind_prop(prop, ref_ui)
32
+ return super().bind_prop(prop, value)
33
33
 
34
- def bind_source(self, ref_ui: TGetterOrReadonlyRef[Union[str, Path]]):
35
- @self._ui_effect
34
+ def bind_source(self, source: TGetterOrReadonlyRef[Union[str, Path]]):
35
+ @self._ui_signal_on(source, deep=False)
36
36
  def _():
37
- self.element.set_source(to_value(ref_ui))
37
+ self.element.set_source(to_value(source))
@@ -51,26 +51,25 @@ class InputBindableUi(BindableUi[ui.input], DisableableMixin):
51
51
  for key, value in pc.get_bindings().items():
52
52
  self.bind_prop(key, value) # type: ignore
53
53
 
54
- def bind_prop(self, prop: str, ref_ui: TGetterOrReadonlyRef):
54
+ def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
55
55
  if prop == "value":
56
- return self.bind_value(ref_ui)
56
+ return self.bind_value(value)
57
57
  if prop == "password":
58
- return self.bind_password(ref_ui)
58
+ return self.bind_password(value)
59
59
 
60
- return super().bind_prop(prop, ref_ui)
60
+ return super().bind_prop(prop, value)
61
61
 
62
- def bind_value(self, ref_ui: TGetterOrReadonlyRef[str]):
63
- @self._ui_effect
62
+ def bind_value(self, value: TGetterOrReadonlyRef[str]):
63
+ @self._ui_signal_on(value)
64
64
  def _():
65
- self.element.set_value(to_value(ref_ui))
66
- self.element.update()
65
+ self.element.set_value(to_value(value))
67
66
 
68
67
  return self
69
68
 
70
- def bind_password(self, ref_ui: TGetterOrReadonlyRef[bool]):
71
- @self._ui_effect
69
+ def bind_password(self, password: TGetterOrReadonlyRef[bool]):
70
+ @self._ui_signal_on(password)
72
71
  def _():
73
- self.element._props["type"] = "password" if to_value(ref_ui) else "text"
72
+ self.element._props["type"] = "password" if to_value(password) else "text"
74
73
  self.element.update()
75
74
 
76
75
  return self