ex4nicegui 0.6.8__py3-none-any.whl → 0.7.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. ex4nicegui/__init__.py +2 -0
  2. ex4nicegui/bi/dataSourceFacade.py +20 -20
  3. ex4nicegui/bi/index.py +20 -23
  4. ex4nicegui/helper/client_instance_locker.py +4 -4
  5. ex4nicegui/reactive/EChartsComponent/ECharts.py +9 -8
  6. ex4nicegui/reactive/__init__.py +12 -0
  7. ex4nicegui/reactive/base.py +433 -0
  8. ex4nicegui/reactive/deferredTask.py +3 -2
  9. ex4nicegui/reactive/mixins/backgroundColor.py +41 -0
  10. ex4nicegui/reactive/mixins/disableable.py +44 -0
  11. ex4nicegui/reactive/mixins/textColor.py +66 -0
  12. ex4nicegui/reactive/officials/aggrid.py +5 -5
  13. ex4nicegui/reactive/officials/base.py +4 -453
  14. ex4nicegui/reactive/officials/button.py +43 -10
  15. ex4nicegui/reactive/officials/checkbox.py +5 -5
  16. ex4nicegui/reactive/officials/chip.py +102 -0
  17. ex4nicegui/reactive/officials/circular_progress.py +9 -7
  18. ex4nicegui/reactive/officials/color_picker.py +7 -7
  19. ex4nicegui/reactive/officials/column.py +5 -5
  20. ex4nicegui/reactive/officials/date.py +5 -5
  21. ex4nicegui/reactive/officials/dialog.py +49 -0
  22. ex4nicegui/reactive/officials/echarts.py +49 -51
  23. ex4nicegui/reactive/officials/expansion.py +5 -5
  24. ex4nicegui/reactive/officials/grid.py +3 -2
  25. ex4nicegui/reactive/officials/icon.py +8 -11
  26. ex4nicegui/reactive/officials/image.py +5 -5
  27. ex4nicegui/reactive/officials/input.py +8 -8
  28. ex4nicegui/reactive/officials/knob.py +9 -5
  29. ex4nicegui/reactive/officials/label.py +8 -15
  30. ex4nicegui/reactive/officials/linear_progress.py +8 -11
  31. ex4nicegui/reactive/officials/number.py +9 -9
  32. ex4nicegui/reactive/officials/radio.py +8 -8
  33. ex4nicegui/reactive/officials/row.py +5 -5
  34. ex4nicegui/reactive/officials/select.py +9 -8
  35. ex4nicegui/reactive/officials/slider.py +6 -6
  36. ex4nicegui/reactive/officials/switch.py +5 -5
  37. ex4nicegui/reactive/officials/tab.py +0 -12
  38. ex4nicegui/reactive/officials/tab_panels.py +113 -7
  39. ex4nicegui/reactive/officials/table.py +13 -13
  40. ex4nicegui/reactive/officials/tabs.py +5 -5
  41. ex4nicegui/reactive/officials/textarea.py +5 -5
  42. ex4nicegui/reactive/officials/tooltip.py +40 -0
  43. ex4nicegui/reactive/q_pagination.py +5 -5
  44. ex4nicegui/reactive/scopedStyle.py +4 -1
  45. ex4nicegui/reactive/systems/color_system.py +132 -0
  46. ex4nicegui/reactive/vfor.js +14 -4
  47. ex4nicegui/reactive/vfor.py +128 -58
  48. ex4nicegui/reactive/view_model.py +160 -0
  49. ex4nicegui/reactive/vmodel.py +42 -12
  50. ex4nicegui/utils/apiEffect.py +5 -1
  51. ex4nicegui/utils/effect.py +3 -2
  52. ex4nicegui/utils/scheduler.py +20 -4
  53. ex4nicegui/utils/signals.py +23 -21
  54. {ex4nicegui-0.6.8.dist-info → ex4nicegui-0.7.0.dist-info}/METADATA +247 -48
  55. {ex4nicegui-0.6.8.dist-info → ex4nicegui-0.7.0.dist-info}/RECORD +57 -50
  56. ex4nicegui/reactive/services/color_service.py +0 -56
  57. {ex4nicegui-0.6.8.dist-info → ex4nicegui-0.7.0.dist-info}/LICENSE +0 -0
  58. {ex4nicegui-0.6.8.dist-info → ex4nicegui-0.7.0.dist-info}/WHEEL +0 -0
@@ -10,10 +10,21 @@ from ex4nicegui.utils.signals import (
10
10
  to_value,
11
11
  )
12
12
  from nicegui import ui
13
- from .base import BindableUi, DisableableMixin
13
+ from .base import (
14
+ BindableUi,
15
+ DisableableMixin,
16
+ )
17
+
18
+ from ex4nicegui.reactive.mixins.backgroundColor import BackgroundColorableMixin
19
+ from ex4nicegui.reactive.mixins.textColor import TextColorableMixin
14
20
 
15
21
 
16
- class ButtonBindableUi(BindableUi[ui.button], DisableableMixin):
22
+ class ButtonBindableUi(
23
+ BindableUi[ui.button],
24
+ DisableableMixin,
25
+ BackgroundColorableMixin,
26
+ TextColorableMixin,
27
+ ):
17
28
  def __init__(
18
29
  self,
19
30
  text: TMaybeRef[str] = "",
@@ -33,28 +44,50 @@ class ButtonBindableUi(BindableUi[ui.button], DisableableMixin):
33
44
  for key, value in pc.get_bindings().items():
34
45
  self.bind_prop(key, value) # type: ignore
35
46
 
36
- def bind_prop(self, prop: str, ref_ui: TGetterOrReadonlyRef):
47
+ def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
37
48
  if prop == "text":
38
- return self.bind_text(ref_ui)
49
+ return self.bind_text(value)
39
50
  if prop == "icon":
40
- return self.bind_icon(ref_ui)
51
+ return self.bind_icon(value)
52
+ if prop == "color":
53
+ return self.bind_color(value)
54
+
55
+ return super().bind_prop(prop, value)
56
+
57
+ def bind_color(self, color: TGetterOrReadonlyRef[str]):
58
+ """Binds the background color of the button.
59
+
60
+ Args:
61
+ color (TGetterOrReadonlyRef[str]): Getter or readonly reference to the color.
41
62
 
42
- return super().bind_prop(prop, ref_ui)
63
+ """
64
+ BackgroundColorableMixin.bind_color(self, color)
65
+ return self
66
+
67
+ def bind_text_color(self, text_color: TGetterOrReadonlyRef[str]):
68
+ """Binds the text color of the button.
69
+
70
+ Args:
71
+ text_color (TGetterOrReadonlyRef[str]): Getter or readonly reference to the color.
72
+
73
+ """
74
+ TextColorableMixin.bind_color(self, text_color)
75
+ return self
43
76
 
44
- def bind_text(self, ref_ui: TGetterOrReadonlyRef):
77
+ def bind_text(self, text: TGetterOrReadonlyRef):
45
78
  @self._ui_effect
46
79
  def _():
47
80
  ele = self.element
48
- ele._props["label"] = to_value(ref_ui)
81
+ ele._props["label"] = to_value(text)
49
82
  ele.update()
50
83
 
51
84
  return self
52
85
 
53
- def bind_icon(self, ref_ui: TGetterOrReadonlyRef[str]):
86
+ def bind_icon(self, icon: TGetterOrReadonlyRef[str]):
54
87
  @self._ui_effect
55
88
  def _():
56
89
  ele = self.element
57
- ele._props["icon"] = to_value(ref_ui)
90
+ ele._props["icon"] = to_value(icon)
58
91
  ele.update()
59
92
 
60
93
  return self
@@ -43,16 +43,16 @@ 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]):
52
+ def bind_value(self, value: TGetterOrReadonlyRef[bool]):
53
53
  @self._ui_effect
54
54
  def _():
55
- self.element.set_value(to_value(ref_ui))
55
+ self.element.set_value(to_value(value))
56
56
  self.element.update()
57
57
 
58
58
  return self
@@ -0,0 +1,102 @@
1
+ from typing import Any, Callable, 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 ChipBindableUi(
15
+ BindableUi[ui.chip],
16
+ BackgroundColorableMixin,
17
+ TextColorableMixin,
18
+ ):
19
+ def __init__(
20
+ self,
21
+ text: TMaybeRef[str] = "",
22
+ *,
23
+ icon: Optional[TMaybeRef[str]] = None,
24
+ color: Optional[TMaybeRef[str]] = "primary",
25
+ text_color: Optional[TMaybeRef[str]] = None,
26
+ on_click: Optional[Callable[..., Any]] = None,
27
+ selectable: TMaybeRef[bool] = False,
28
+ selected: TMaybeRef[bool] = False,
29
+ on_selection_change: Optional[Callable[..., Any]] = None,
30
+ removable: TMaybeRef[bool] = False,
31
+ on_value_change: Optional[Callable[..., Any]] = None,
32
+ ) -> None:
33
+ pc = ParameterClassifier(
34
+ locals(),
35
+ maybeRefs=[
36
+ "text",
37
+ "icon",
38
+ "color",
39
+ "text_color",
40
+ "selectable",
41
+ "selected",
42
+ "removable",
43
+ ],
44
+ events=["on_click", "on_selection_change", "on_value_change"],
45
+ )
46
+
47
+ element = ui.chip(**pc.get_values_kws())
48
+ super().__init__(element)
49
+
50
+ for key, value in pc.get_bindings().items():
51
+ self.bind_prop(key, value) # type: ignore
52
+
53
+ @property
54
+ def text(self):
55
+ return self.element.text
56
+
57
+ def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
58
+ if prop == "text":
59
+ return self.bind_text(value)
60
+
61
+ if prop == "color":
62
+ return self.bind_color(value)
63
+ if prop == "text-color":
64
+ return self.bind_text_color(value)
65
+
66
+ return super().bind_prop(prop, value)
67
+
68
+ def bind_color(self, color: TGetterOrReadonlyRef):
69
+ """Binds the background color property of the chip to a ui element.
70
+
71
+ Args:
72
+ color (TGetterOrReadonlyRef): background color ui element or getter function
73
+
74
+ """
75
+ BackgroundColorableMixin.bind_color(self, color)
76
+ return self
77
+
78
+ def bind_text_color(self, color: TGetterOrReadonlyRef):
79
+ """Binds the text color property of the chip to a ui element.
80
+
81
+ Args:
82
+ color (TGetterOrReadonlyRef): text color ui element or getter function
83
+
84
+
85
+ """
86
+ TextColorableMixin.bind_color(self, color)
87
+ return self
88
+
89
+ def bind_text(self, text: TGetterOrReadonlyRef):
90
+ """Binds the text property of the chip to a ui element.
91
+
92
+ Args:
93
+ text (TGetterOrReadonlyRef): text ui element or getter function
94
+
95
+ """
96
+
97
+ @self._ui_effect
98
+ def _():
99
+ self.element.set_text(str(to_value(text)))
100
+ self.element.update()
101
+
102
+ return self
@@ -10,11 +10,11 @@ from ex4nicegui.utils.signals import (
10
10
  )
11
11
  from nicegui import ui
12
12
  from .base import BindableUi, DisableableMixin
13
+ from ex4nicegui.reactive.mixins.backgroundColor import BackgroundColorableMixin
13
14
 
14
15
 
15
16
  class CircularProgressBindableUi(
16
- BindableUi[ui.circular_progress],
17
- DisableableMixin,
17
+ BindableUi[ui.circular_progress], DisableableMixin, BackgroundColorableMixin
18
18
  ):
19
19
  def __init__(
20
20
  self,
@@ -49,15 +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
+ if prop == "color":
56
+ return self.bind_color(value)
55
57
 
56
- return super().bind_prop(prop, ref_ui)
58
+ return super().bind_prop(prop, value)
57
59
 
58
- def bind_value(self, ref_ui: TGetterOrReadonlyRef[float]):
60
+ def bind_value(self, value: TGetterOrReadonlyRef[float]):
59
61
  @self._ui_effect
60
62
  def _():
61
- self.element.set_value(to_value(ref_ui))
63
+ self.element.set_value(to_value(value))
62
64
 
63
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]):
84
+ def bind_value(self, value: TGetterOrReadonlyRef[bool]):
85
85
  @self._ui_effect
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]):
71
+ def bind_value(self, value: TGetterOrReadonlyRef[bool]):
72
72
  @self._ui_effect
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_effect
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)
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):
54
+ def bind_value(self, value: TGetterOrReadonlyRef):
55
55
  @self._ui_effect
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,7 @@
1
1
  from typing import (
2
2
  Any,
3
3
  Optional,
4
+ Union,
4
5
  )
5
6
 
6
7
  from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
@@ -13,8 +14,8 @@ from ex4nicegui.utils.signals import _TMaybeRef as TMaybeRef
13
14
  class GridBindableUi(BindableUi[ui.grid]):
14
15
  def __init__(
15
16
  self,
16
- rows: Optional[TMaybeRef[int]] = None,
17
- columns: Optional[TMaybeRef[int]] = None,
17
+ rows: Optional[TMaybeRef[Union[int, str]]] = None,
18
+ columns: Optional[TMaybeRef[Union[int, str]]] = None,
18
19
  ) -> None:
19
20
  pc = ParameterClassifier(locals(), maybeRefs=["rows", "columns"], events=[])
20
21
 
@@ -13,10 +13,10 @@ from nicegui.elements.mixins.color_elements import (
13
13
  TextColorElement,
14
14
  )
15
15
  from .base import BindableUi
16
- from ex4nicegui.reactive.services import color_service
16
+ from ex4nicegui.reactive.mixins.textColor import TextColorableMixin
17
17
 
18
18
 
19
- class IconBindableUi(BindableUi[ui.icon]):
19
+ class IconBindableUi(BindableUi[ui.icon], TextColorableMixin):
20
20
  def __init__(
21
21
  self,
22
22
  name: TMaybeRef[str],
@@ -34,23 +34,20 @@ class IconBindableUi(BindableUi[ui.icon]):
34
34
  for key, value in pc.get_bindings().items():
35
35
  self.bind_prop(key, value) # type: ignore
36
36
 
37
- def bind_prop(self, prop: str, ref_ui: TGetterOrReadonlyRef):
37
+ def bind_prop(self, prop: str, value: TGetterOrReadonlyRef):
38
38
  if prop == "name":
39
- return self.bind_name(ref_ui)
39
+ return self.bind_name(value)
40
40
 
41
41
  if prop == "color":
42
- return self.bind_color(ref_ui)
42
+ return self.bind_color(value)
43
43
 
44
- return super().bind_prop(prop, ref_ui)
44
+ return super().bind_prop(prop, value)
45
45
 
46
- def bind_color(self, ref_ui: TGetterOrReadonlyRef):
47
- return color_service.bind_color(self, ref_ui)
48
-
49
- def bind_name(self, ref_ui: TGetterOrReadonlyRef):
46
+ def bind_name(self, name: TGetterOrReadonlyRef):
50
47
  @self._ui_effect
51
48
  def _():
52
49
  ele = cast(TextColorElement, self.element)
53
- ele._props["name"] = to_value(ref_ui)
50
+ ele._props["name"] = to_value(name)
54
51
  ele.update()
55
52
 
56
53
  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]]):
34
+ def bind_source(self, source: TGetterOrReadonlyRef[Union[str, Path]]):
35
35
  @self._ui_effect
36
36
  def _():
37
- self.element.set_source(to_value(ref_ui))
37
+ self.element.set_source(to_value(source))
@@ -51,26 +51,26 @@ 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]):
62
+ def bind_value(self, value: TGetterOrReadonlyRef[str]):
63
63
  @self._ui_effect
64
64
  def _():
65
- self.element.set_value(to_value(ref_ui))
65
+ self.element.set_value(to_value(value))
66
66
  self.element.update()
67
67
 
68
68
  return self
69
69
 
70
- def bind_password(self, ref_ui: TGetterOrReadonlyRef[bool]):
70
+ def bind_password(self, password: TGetterOrReadonlyRef[bool]):
71
71
  @self._ui_effect
72
72
  def _():
73
- self.element._props["type"] = "password" if to_value(ref_ui) else "text"
73
+ self.element._props["type"] = "password" if to_value(password) else "text"
74
74
  self.element.update()
75
75
 
76
76
  return self