violit 0.0.4.post1__py3-none-any.whl → 0.0.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.
violit/context.py CHANGED
@@ -4,6 +4,7 @@ import contextvars
4
4
  session_ctx = contextvars.ContextVar("session_id", default=None)
5
5
  rendering_ctx = contextvars.ContextVar("rendering_component", default=None)
6
6
  fragment_ctx = contextvars.ContextVar("current_fragment", default=None)
7
+ page_ctx = contextvars.ContextVar("current_page_renderer", default=None)
7
8
  layout_ctx = contextvars.ContextVar("layout_ctx", default="main") # "main" or "sidebar"
8
9
 
9
10
  # Global Reference for App Instance (used for initial theme sync)
violit/state.py CHANGED
@@ -74,3 +74,36 @@ class State:
74
74
 
75
75
  def __repr__(self):
76
76
  return f"State({self.name}, {self.value})"
77
+
78
+ # Reactive Comparison Operators
79
+ def __eq__(self, other): return ComputedState(lambda: self.value == other)
80
+ def __ne__(self, other): return ComputedState(lambda: self.value != other)
81
+ def __lt__(self, other): return ComputedState(lambda: self.value < other)
82
+ def __le__(self, other): return ComputedState(lambda: self.value <= other)
83
+ def __gt__(self, other): return ComputedState(lambda: self.value > other)
84
+ def __ge__(self, other): return ComputedState(lambda: self.value >= other)
85
+
86
+
87
+ class ComputedState:
88
+ """A state derived from other states (e.g. expressions)"""
89
+ def __init__(self, func):
90
+ self.func = func
91
+
92
+ @property
93
+ def value(self):
94
+ return self.func()
95
+
96
+ def __bool__(self):
97
+ return bool(self.value)
98
+
99
+ def __call__(self):
100
+ return self.value
101
+
102
+ # Logical operators for chaining
103
+ def __and__(self, other):
104
+ val_other = other.value if hasattr(other, 'value') else other
105
+ return ComputedState(lambda: self.value and val_other)
106
+
107
+ def __or__(self, other):
108
+ val_other = other.value if hasattr(other, 'value') else other
109
+ return ComputedState(lambda: self.value or val_other)
@@ -1,30 +1,30 @@
1
- """
2
- Violit Widgets Package
3
- Organized widget mixins for the App class
4
- """
5
-
6
- from .text_widgets import TextWidgetsMixin
7
- from .input_widgets import InputWidgetsMixin
8
- from .data_widgets import DataWidgetsMixin
9
- from .chart_widgets import ChartWidgetsMixin
10
- from .media_widgets import MediaWidgetsMixin
11
- from .layout_widgets import LayoutWidgetsMixin
12
- from .status_widgets import StatusWidgetsMixin
13
- from .form_widgets import FormWidgetsMixin
14
- from .chat_widgets import ChatWidgetsMixin
15
- from .card_widgets import CardWidgetsMixin
16
- from .list_widgets import ListWidgetsMixin
17
-
18
- __all__ = [
19
- 'TextWidgetsMixin',
20
- 'InputWidgetsMixin',
21
- 'DataWidgetsMixin',
22
- 'ChartWidgetsMixin',
23
- 'MediaWidgetsMixin',
24
- 'LayoutWidgetsMixin',
25
- 'StatusWidgetsMixin',
26
- 'FormWidgetsMixin',
27
- 'ChatWidgetsMixin',
28
- 'CardWidgetsMixin',
29
- 'ListWidgetsMixin',
30
- ]
1
+ """
2
+ Violit Widgets Package
3
+ Organized widget mixins for the App class
4
+ """
5
+
6
+ from .text_widgets import TextWidgetsMixin
7
+ from .input_widgets import InputWidgetsMixin
8
+ from .data_widgets import DataWidgetsMixin
9
+ from .chart_widgets import ChartWidgetsMixin
10
+ from .media_widgets import MediaWidgetsMixin
11
+ from .layout_widgets import LayoutWidgetsMixin
12
+ from .status_widgets import StatusWidgetsMixin
13
+ from .form_widgets import FormWidgetsMixin
14
+ from .chat_widgets import ChatWidgetsMixin
15
+ from .card_widgets import CardWidgetsMixin
16
+ from .list_widgets import ListWidgetsMixin
17
+
18
+ __all__ = [
19
+ 'TextWidgetsMixin',
20
+ 'InputWidgetsMixin',
21
+ 'DataWidgetsMixin',
22
+ 'ChartWidgetsMixin',
23
+ 'MediaWidgetsMixin',
24
+ 'LayoutWidgetsMixin',
25
+ 'StatusWidgetsMixin',
26
+ 'FormWidgetsMixin',
27
+ 'ChatWidgetsMixin',
28
+ 'CardWidgetsMixin',
29
+ 'ListWidgetsMixin',
30
+ ]