ex4nicegui 0.7.1__py3-none-any.whl → 0.8.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 (50) hide show
  1. ex4nicegui/reactive/EChartsComponent/ECharts.js +2 -3
  2. ex4nicegui/reactive/EChartsComponent/ECharts.py +2 -4
  3. ex4nicegui/reactive/__init__.py +2 -1
  4. ex4nicegui/reactive/base.py +108 -50
  5. ex4nicegui/reactive/mermaid/mermaid.py +2 -5
  6. ex4nicegui/reactive/mixins/backgroundColor.py +4 -8
  7. ex4nicegui/reactive/mixins/disableable.py +4 -8
  8. ex4nicegui/reactive/mixins/flexLayout.py +51 -0
  9. ex4nicegui/reactive/mixins/textColor.py +8 -10
  10. ex4nicegui/reactive/mixins/value_element.py +27 -0
  11. ex4nicegui/reactive/officials/card.py +32 -2
  12. ex4nicegui/reactive/officials/checkbox.py +7 -12
  13. ex4nicegui/reactive/officials/chip.py +11 -1
  14. ex4nicegui/reactive/officials/circular_progress.py +7 -11
  15. ex4nicegui/reactive/officials/color_picker.py +4 -10
  16. ex4nicegui/reactive/officials/column.py +19 -11
  17. ex4nicegui/reactive/officials/date.py +4 -11
  18. ex4nicegui/reactive/officials/dialog.py +4 -11
  19. ex4nicegui/reactive/officials/echarts.py +9 -7
  20. ex4nicegui/reactive/officials/expansion.py +4 -11
  21. ex4nicegui/reactive/officials/input.py +13 -13
  22. ex4nicegui/reactive/officials/knob.py +4 -13
  23. ex4nicegui/reactive/officials/linear_progress.py +6 -11
  24. ex4nicegui/reactive/officials/number.py +7 -11
  25. ex4nicegui/reactive/officials/radio.py +4 -12
  26. ex4nicegui/reactive/officials/row.py +18 -11
  27. ex4nicegui/reactive/officials/slider.py +4 -12
  28. ex4nicegui/reactive/officials/switch.py +5 -12
  29. ex4nicegui/reactive/officials/tab_panels.py +4 -8
  30. ex4nicegui/reactive/officials/tabs.py +4 -9
  31. ex4nicegui/reactive/officials/textarea.py +6 -12
  32. ex4nicegui/reactive/services/reactive_service.py +2 -1
  33. ex4nicegui/reactive/vfor.py +4 -0
  34. ex4nicegui/reactive/view_model.py +147 -6
  35. ex4nicegui/utils/proxy/__init__.py +19 -0
  36. ex4nicegui/utils/proxy/base.py +9 -0
  37. ex4nicegui/utils/proxy/bool.py +58 -0
  38. ex4nicegui/utils/proxy/date.py +88 -0
  39. ex4nicegui/utils/proxy/descriptor.py +126 -0
  40. ex4nicegui/utils/proxy/dict.py +110 -0
  41. ex4nicegui/utils/proxy/float.py +153 -0
  42. ex4nicegui/utils/proxy/int.py +223 -0
  43. ex4nicegui/utils/proxy/list.py +147 -0
  44. ex4nicegui/utils/proxy/string.py +430 -0
  45. ex4nicegui/utils/proxy/utils.py +6 -0
  46. ex4nicegui/utils/signals.py +9 -1
  47. {ex4nicegui-0.7.1.dist-info → ex4nicegui-0.8.1.dist-info}/METADATA +497 -244
  48. {ex4nicegui-0.7.1.dist-info → ex4nicegui-0.8.1.dist-info}/RECORD +50 -37
  49. {ex4nicegui-0.7.1.dist-info → ex4nicegui-0.8.1.dist-info}/LICENSE +0 -0
  50. {ex4nicegui-0.7.1.dist-info → ex4nicegui-0.8.1.dist-info}/WHEEL +0 -0
@@ -0,0 +1,430 @@
1
+ from __future__ import annotations
2
+ from typing import (
3
+ Any,
4
+ Iterable,
5
+ List,
6
+ Optional,
7
+ SupportsIndex,
8
+ Tuple,
9
+ Union,
10
+ overload,
11
+ Iterator,
12
+ )
13
+ from typing_extensions import LiteralString
14
+ import sys
15
+ from . import utils
16
+ from .base import Proxy
17
+
18
+
19
+ class StringProxy(Proxy, str):
20
+ def __new__(cls, value):
21
+ obj = super().__new__(cls, value)
22
+ return obj
23
+
24
+ def __init__(self, string: str):
25
+ from ex4nicegui.utils.signals import to_ref
26
+
27
+ self._ref = to_ref(string)
28
+
29
+ def __str__(self):
30
+ return self._ref.value.__str__()
31
+
32
+ def __repr__(self):
33
+ return self._ref.value.__repr__()
34
+
35
+ @overload
36
+ def capitalize(self: LiteralString) -> LiteralString: ...
37
+ @overload
38
+ def capitalize(self) -> str: ... # type: ignore[misc]
39
+ def capitalize(self) -> str:
40
+ return self._ref.value.capitalize()
41
+
42
+ @overload
43
+ def casefold(self: LiteralString) -> LiteralString: ...
44
+ @overload
45
+ def casefold(self) -> str: ... # type: ignore[misc]
46
+ def casefold(self) -> str:
47
+ return self._ref.value.casefold()
48
+
49
+ @overload
50
+ def center(
51
+ self: LiteralString, width: SupportsIndex, fillchar: LiteralString = " ", /
52
+ ) -> LiteralString: ...
53
+ @overload
54
+ def center(self, width: SupportsIndex, fillchar: str = " ", /) -> str: ... # type: ignore[misc]
55
+ def center(self, width: SupportsIndex, fillchar: str = " ", /) -> str:
56
+ return self._ref.value.center(width, fillchar)
57
+
58
+ def count(
59
+ self,
60
+ sub: str,
61
+ start: Optional[SupportsIndex] = ...,
62
+ end: Optional[SupportsIndex] = ...,
63
+ /,
64
+ ) -> int:
65
+ return self._ref.value.count(sub, start, end)
66
+
67
+ def encode(self, encoding: str = "utf-8", errors: str = "strict") -> bytes:
68
+ return self._ref.value.encode(encoding, errors)
69
+
70
+ def endswith(
71
+ self,
72
+ suffix: Union[str, Tuple[str, ...]],
73
+ start: Optional[SupportsIndex] = ...,
74
+ end: Optional[SupportsIndex] = ...,
75
+ /,
76
+ ) -> bool:
77
+ return self._ref.value.endswith(suffix, start, end)
78
+
79
+ @overload
80
+ def expandtabs(
81
+ self: LiteralString, tabsize: SupportsIndex = 8
82
+ ) -> LiteralString: ...
83
+ @overload
84
+ def expandtabs(self, tabsize: SupportsIndex = 8) -> str: ... # type: ignore[misc]
85
+ def expandtabs(self, tabsize: SupportsIndex = 8) -> str:
86
+ return self._ref.value.expandtabs(tabsize)
87
+
88
+ def find(
89
+ self,
90
+ sub: str,
91
+ start: Optional[SupportsIndex] = ...,
92
+ end: Optional[SupportsIndex] = ...,
93
+ /,
94
+ ) -> int:
95
+ return self._ref.value.find(sub, start, end)
96
+
97
+ @overload
98
+ def format(
99
+ self: LiteralString, *args: LiteralString, **kwargs: LiteralString
100
+ ) -> LiteralString: ...
101
+ @overload
102
+ def format(self, *args: object, **kwargs: object) -> str: ...
103
+ def format(self, *args: object, **kwargs: object) -> str:
104
+ return self._ref.value.format(*args, **kwargs)
105
+
106
+ def format_map(self, mapping, /) -> str:
107
+ return self._ref.value.format_map(mapping)
108
+
109
+ def index(
110
+ self,
111
+ sub: str,
112
+ start: Optional[SupportsIndex] = ...,
113
+ end: Optional[SupportsIndex] = ...,
114
+ /,
115
+ ) -> int:
116
+ return self._ref.value.index(sub, start, end)
117
+
118
+ def isalnum(self) -> bool:
119
+ return self._ref.value.isalnum()
120
+
121
+ def isalpha(self) -> bool:
122
+ return self._ref.value.isalpha()
123
+
124
+ def isascii(self) -> bool:
125
+ return self._ref.value.isascii()
126
+
127
+ def isdecimal(self) -> bool:
128
+ return self._ref.value.isdecimal()
129
+
130
+ def isdigit(self) -> bool:
131
+ return self._ref.value.isdigit()
132
+
133
+ def isidentifier(self) -> bool:
134
+ return self._ref.value.isidentifier()
135
+
136
+ def islower(self) -> bool:
137
+ return self._ref.value.islower()
138
+
139
+ def isnumeric(self) -> bool:
140
+ return self._ref.value.isnumeric()
141
+
142
+ def isprintable(self) -> bool:
143
+ return self._ref.value.isprintable()
144
+
145
+ def isspace(self) -> bool:
146
+ return self._ref.value.isspace()
147
+
148
+ def istitle(self) -> bool:
149
+ return self._ref.value.istitle()
150
+
151
+ def isupper(self) -> bool:
152
+ return self._ref.value.isupper()
153
+
154
+ @overload
155
+ def join(
156
+ self: LiteralString, iterable: Iterable[LiteralString], /
157
+ ) -> LiteralString: ...
158
+ @overload
159
+ def join(self, iterable: Iterable[str], /) -> str: ... # type: ignore[misc]
160
+ def join(self, iterable: Iterable[str]) -> str:
161
+ return self._ref.value.join(iterable)
162
+
163
+ @overload
164
+ def ljust(
165
+ self: LiteralString, width: SupportsIndex, fillchar: LiteralString = " ", /
166
+ ) -> LiteralString: ...
167
+ @overload
168
+ def ljust(self, width: SupportsIndex, fillchar: str = " ", /) -> str: ... # type: ignore[misc]
169
+ def ljust(self, width: SupportsIndex, fillchar: str = " ", /) -> str:
170
+ return self._ref.value.ljust(width, fillchar)
171
+
172
+ @overload
173
+ def lower(self: LiteralString) -> LiteralString: ...
174
+ @overload
175
+ def lower(self) -> str: ... # type: ignore[misc]
176
+ def lower(self) -> str:
177
+ return self._ref.value.lower()
178
+
179
+ @overload
180
+ def lstrip(
181
+ self: LiteralString, chars: Optional[LiteralString] = None, /
182
+ ) -> LiteralString: ...
183
+ @overload
184
+ def lstrip(self, chars: Optional[str] = None, /) -> str: ... # type: ignore[misc]
185
+ def lstrip(self, chars: Optional[str] = None, /) -> str:
186
+ return self._ref.value.lstrip(chars)
187
+
188
+ @overload
189
+ def partition(
190
+ self: LiteralString, sep: LiteralString, /
191
+ ) -> Tuple[LiteralString, LiteralString, LiteralString]: ...
192
+ @overload
193
+ def partition(self, sep: str, /) -> Tuple[str, str, str]: ... # type: ignore[misc]
194
+ def partition(self, sep: str, /) -> Tuple[str, str, str]:
195
+ return self._ref.value.partition(sep)
196
+
197
+ @overload
198
+ def replace(
199
+ self: LiteralString,
200
+ old: LiteralString,
201
+ new: LiteralString,
202
+ /,
203
+ count: SupportsIndex = -1,
204
+ ) -> LiteralString: ...
205
+ @overload
206
+ def replace(self, old: str, new: str, /, count: SupportsIndex = -1) -> str: ... # type: ignore[misc]
207
+ def replace(self, old: str, new: str, /, count: SupportsIndex = -1) -> str:
208
+ return self._ref.value.replace(old, new, count)
209
+
210
+ if sys.version_info >= (3, 13):
211
+
212
+ @overload
213
+ def removeprefix(
214
+ self: LiteralString, prefix: LiteralString, /
215
+ ) -> LiteralString: ...
216
+ @overload
217
+ def removeprefix(self, prefix: str, /) -> str: ... # type: ignore[misc]
218
+ def removeprefix(self, prefix: str, /):
219
+ return self._ref.value.removeprefix(prefix)
220
+
221
+ @overload
222
+ def removesuffix(
223
+ self: LiteralString, suffix: LiteralString, /
224
+ ) -> LiteralString: ...
225
+ @overload
226
+ def removesuffix(self, suffix: str, /) -> str: ... # type: ignore[misc]
227
+ def removesuffix(self, suffix: str, /):
228
+ return self._ref.value.removesuffix(suffix)
229
+
230
+ def rfind(
231
+ self,
232
+ sub: str,
233
+ start: Optional[SupportsIndex] = ...,
234
+ end: Optional[SupportsIndex] = ...,
235
+ /,
236
+ ) -> int:
237
+ return self._ref.value.rfind(sub, start, end)
238
+
239
+ def rindex(
240
+ self,
241
+ sub: str,
242
+ start: Optional[SupportsIndex] = ...,
243
+ end: Optional[SupportsIndex] = ...,
244
+ /,
245
+ ) -> int:
246
+ return self._ref.value.rindex(sub, start, end)
247
+
248
+ @overload
249
+ def rjust(
250
+ self: LiteralString, width: SupportsIndex, fillchar: LiteralString = " ", /
251
+ ) -> LiteralString: ...
252
+ @overload
253
+ def rjust(self, width: SupportsIndex, fillchar: str = " ", /) -> str: ... # type: ignore[misc]
254
+ def rjust(self, width: SupportsIndex, fillchar: str = " ", /) -> str:
255
+ return self._ref.value.rjust(width, fillchar)
256
+
257
+ @overload
258
+ def rpartition(
259
+ self: LiteralString, sep: LiteralString, /
260
+ ) -> Tuple[LiteralString, LiteralString, LiteralString]: ...
261
+ @overload
262
+ def rpartition(self, sep: str, /) -> Tuple[str, str, str]: ... # type: ignore[misc]
263
+ def rpartition(self, sep: str, /) -> Tuple[str, str, str]:
264
+ return self._ref.value.rpartition(sep)
265
+
266
+ @overload
267
+ def rsplit(
268
+ self: LiteralString,
269
+ sep: Optional[LiteralString] = None,
270
+ maxsplit: SupportsIndex = -1,
271
+ ) -> List[LiteralString]: ...
272
+ @overload
273
+ def rsplit(
274
+ self, sep: Optional[str] = None, maxsplit: SupportsIndex = -1
275
+ ) -> List[str]: ... # type: ignore[misc]
276
+ def rsplit(
277
+ self, sep: Optional[str] = None, maxsplit: SupportsIndex = -1
278
+ ) -> List[str]:
279
+ return self._ref.value.rsplit(sep, maxsplit)
280
+
281
+ @overload
282
+ def rstrip(
283
+ self: LiteralString, chars: Optional[LiteralString] = None, /
284
+ ) -> LiteralString: ...
285
+ @overload
286
+ def rstrip(self, chars: Optional[str] = None, /) -> str: ... # type: ignore[misc]
287
+ def rstrip(self, chars: Optional[str] = None, /):
288
+ return self._ref.value.rstrip(chars)
289
+
290
+ @overload
291
+ def split(
292
+ self: LiteralString,
293
+ sep: Optional[LiteralString] = None,
294
+ maxsplit: SupportsIndex = -1,
295
+ ) -> List[LiteralString]: ...
296
+ @overload
297
+ def split(
298
+ self, sep: Optional[str] = None, maxsplit: SupportsIndex = -1
299
+ ) -> List[str]: ... # type: ignore[misc]
300
+ def split(self, sep: Optional[str] = None, maxsplit: SupportsIndex = -1):
301
+ return self._ref.value.split(sep, maxsplit)
302
+
303
+ @overload
304
+ def splitlines(
305
+ self: LiteralString, keepends: bool = False
306
+ ) -> List[LiteralString]: ...
307
+ @overload
308
+ def splitlines(self, keepends: bool = False) -> List[str]: ... # type: ignore[misc]
309
+ def splitlines(self, keepends: bool = False):
310
+ return self._ref.value.splitlines(keepends)
311
+
312
+ def startswith(
313
+ self,
314
+ prefix: Union[str, Tuple[str, ...]],
315
+ start: Optional[SupportsIndex] = ...,
316
+ end: Optional[SupportsIndex] = ...,
317
+ /,
318
+ ) -> bool:
319
+ return self._ref.value.startswith(prefix, start, end)
320
+
321
+ @overload
322
+ def strip(
323
+ self: LiteralString, chars: Optional[LiteralString] = None, /
324
+ ) -> LiteralString: ...
325
+ @overload
326
+ def strip(self, chars: Optional[str] = None, /) -> str: ... # type: ignore[misc]
327
+ def strip(self, chars: Optional[str] = None, /):
328
+ return self._ref.value.strip(chars)
329
+
330
+ @overload
331
+ def swapcase(self: LiteralString) -> LiteralString: ...
332
+ @overload
333
+ def swapcase(self) -> str: ... # type: ignore[misc]
334
+ def swapcase(self):
335
+ return self._ref.value.swapcase()
336
+
337
+ @overload
338
+ def title(self: LiteralString) -> LiteralString: ...
339
+ @overload
340
+ def title(self) -> str: ... # type: ignore[misc]
341
+ def title(self):
342
+ return self._ref.value.title()
343
+
344
+ def translate(self, table, /) -> str:
345
+ return self._ref.value.translate(table)
346
+
347
+ @overload
348
+ def upper(self: LiteralString) -> LiteralString: ...
349
+ @overload
350
+ def upper(self) -> str: ... # type: ignore[misc]
351
+ def upper(self):
352
+ return self._ref.value.upper()
353
+
354
+ @overload
355
+ def zfill(self: LiteralString, width: SupportsIndex, /) -> LiteralString: ...
356
+ @overload
357
+ def zfill(self, width: SupportsIndex, /) -> str: ... # type: ignore[misc]
358
+ def zfill(self, width: SupportsIndex, /):
359
+ return self._ref.value.zfill(width)
360
+
361
+ # 特殊方法
362
+ @overload
363
+ def __add__(self: LiteralString, value: LiteralString, /) -> LiteralString: ...
364
+ @overload
365
+ def __add__(self, value: str, /) -> str: ... # type: ignore[misc]
366
+ def __add__(self, value: str):
367
+ return self._ref.value.__add__(utils.to_value(value))
368
+
369
+ def __contains__(self, key: str, /) -> bool:
370
+ return self._ref.value.__contains__(key)
371
+
372
+ def __eq__(self, value: object, /) -> bool:
373
+ return self._ref.value.__eq__(value)
374
+
375
+ def __ge__(self, value: str, /) -> bool:
376
+ return self._ref.value.__ge__(value)
377
+
378
+ def __getitem__(self, key: Union[SupportsIndex, slice], /) -> str:
379
+ return self._ref.value.__getitem__(key)
380
+
381
+ def __gt__(self, value: str, /) -> bool:
382
+ return self._ref.value.__gt__(value)
383
+
384
+ def __hash__(self) -> int:
385
+ return self._ref.value.__hash__()
386
+
387
+ @overload
388
+ def __iter__(self: LiteralString) -> Iterator[LiteralString]: ...
389
+ @overload
390
+ def __iter__(self) -> Iterator[str]: ... # type: ignore[misc]
391
+ def __iter__(self) -> Iterator[str]:
392
+ return self._ref.value.__iter__()
393
+
394
+ def __le__(self, value: str, /) -> bool:
395
+ return self._ref.value.__le__(value)
396
+
397
+ def __len__(self) -> int:
398
+ return 0 if self._ref.value is None else self._ref.value.__len__()
399
+
400
+ def __lt__(self, value: str, /) -> bool:
401
+ return self._ref.value.__lt__(value)
402
+
403
+ @overload
404
+ def __mod__(
405
+ self: LiteralString, value: Union[LiteralString, Tuple[LiteralString, ...]], /
406
+ ) -> LiteralString: ...
407
+ @overload
408
+ def __mod__(self, value: Any, /) -> str: ...
409
+ def __mod__(self, value: Any):
410
+ return self._ref.value.__mod__(value)
411
+
412
+ @overload
413
+ def __mul__(self: LiteralString, value: SupportsIndex, /) -> LiteralString: ...
414
+ @overload
415
+ def __mul__(self, value: SupportsIndex, /) -> str: ... # type: ignore[misc]
416
+ def __mul__(self, value: SupportsIndex):
417
+ return self._ref.value.__mul__(value)
418
+
419
+ def __ne__(self, value: object, /) -> bool:
420
+ return self._ref.value.__ne__(value)
421
+
422
+ @overload
423
+ def __rmul__(self: LiteralString, value: SupportsIndex, /) -> LiteralString: ...
424
+ @overload
425
+ def __rmul__(self, value: SupportsIndex, /) -> str: ... # type: ignore[misc]
426
+ def __rmul__(self, value: SupportsIndex):
427
+ return self._ref.value.__rmul__(value)
428
+
429
+ def __getnewargs__(self) -> Tuple[str]:
430
+ return self._ref.value.__getnewargs__()
@@ -0,0 +1,6 @@
1
+ from typing import Any
2
+ from .base import Proxy
3
+
4
+
5
+ def to_value(value: Any):
6
+ return value._ref.value if isinstance(value, Proxy) else value
@@ -26,6 +26,10 @@ from .types import (
26
26
  )
27
27
  from .refWrapper import RefWrapper, to_ref_wrapper # noqa: F401
28
28
  from .refComputed import ref_computed # noqa: F401
29
+ from ex4nicegui.utils.proxy import (
30
+ to_ref_if_base_type_proxy,
31
+ to_value_if_base_type_proxy,
32
+ )
29
33
 
30
34
  T = TypeVar("T")
31
35
 
@@ -61,6 +65,7 @@ def to_value(obj: Union[_TMaybeRef[T], RefWrapper]) -> T:
61
65
  to_value(to_ref(1)) # 1
62
66
 
63
67
  """
68
+ obj = to_value_if_base_type_proxy(obj)
64
69
  if is_ref(obj):
65
70
  return obj.value # type: ignore
66
71
  if isinstance(obj, Callable):
@@ -144,6 +149,8 @@ class effect_refreshable:
144
149
  def __init__(self, fn: Callable, refs: _T_effect_refreshable_refs = []) -> None:
145
150
  self._fn = fn
146
151
 
152
+ refs = to_ref_if_base_type_proxy(refs)
153
+
147
154
  if isinstance(refs, Sequence):
148
155
  ref_arg = [ref for ref in refs if self._is_valid_ref(ref)]
149
156
  else:
@@ -188,7 +195,7 @@ class effect_refreshable:
188
195
 
189
196
 
190
197
  def on(
191
- refs: Union[TGetterOrReadonlyRef, RefWrapper, Sequence[TGetterOrReadonlyRef]],
198
+ refs: Union[TGetterOrReadonlyRef, RefWrapper, Sequence[TGetterOrReadonlyRef], Any],
192
199
  onchanges=False,
193
200
  priority_level=1,
194
201
  effect_kws: Optional[Dict[str, Any]] = None,
@@ -212,6 +219,7 @@ def on(
212
219
  if not isinstance(refs, Sequence):
213
220
  refs = [refs] # type: ignore
214
221
 
222
+ refs = (to_ref_if_base_type_proxy(ref) for ref in refs)
215
223
  refs = [(lambda: ref.value) if isinstance(ref, RefWrapper) else ref for ref in refs] # type: ignore
216
224
 
217
225
  effect_kws.update({"priority_level": priority_level})