pythonnative 0.15.0__py3-none-any.whl → 0.16.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.
pythonnative/__init__.py CHANGED
@@ -51,36 +51,55 @@ Example:
51
51
  ```
52
52
  """
53
53
 
54
- __version__ = "0.15.0"
54
+ __version__ = "0.16.0"
55
55
 
56
56
  from . import sdk
57
57
  from .alerts import Alert
58
- from .animated import Animated, AnimatedValue
58
+ from .animated import Animated, AnimatedValue, use_animated_value
59
59
  from .components import (
60
60
  ActivityIndicator,
61
+ ActivityIndicatorProps,
61
62
  Button,
63
+ ButtonProps,
62
64
  Column,
63
65
  ErrorBoundary,
64
66
  FlatList,
67
+ Fragment,
65
68
  Image,
69
+ ImageProps,
66
70
  KeyboardAvoidingView,
71
+ KeyboardAvoidingViewProps,
67
72
  Modal,
73
+ ModalProps,
68
74
  Picker,
75
+ PickerProps,
69
76
  Pressable,
77
+ PressableProps,
70
78
  ProgressBar,
79
+ ProgressBarProps,
71
80
  RefreshControl,
72
81
  Row,
73
82
  SafeAreaView,
83
+ SafeAreaViewProps,
74
84
  ScrollView,
85
+ ScrollViewProps,
75
86
  SectionList,
76
87
  Slider,
88
+ SliderProps,
77
89
  Spacer,
90
+ SpacerProps,
78
91
  StatusBar,
92
+ StatusBarProps,
79
93
  Switch,
94
+ SwitchProps,
80
95
  Text,
81
96
  TextInput,
97
+ TextInputProps,
98
+ TextProps,
82
99
  View,
100
+ ViewProps,
83
101
  WebView,
102
+ WebViewProps,
84
103
  )
85
104
  from .element import Element
86
105
  from .hooks import (
@@ -88,6 +107,7 @@ from .hooks import (
88
107
  batch_updates,
89
108
  component,
90
109
  create_context,
110
+ memo,
91
111
  use_callback,
92
112
  use_context,
93
113
  use_effect,
@@ -152,6 +172,7 @@ __all__ = [
152
172
  "Column",
153
173
  "ErrorBoundary",
154
174
  "FlatList",
175
+ "Fragment",
155
176
  "Image",
156
177
  "KeyboardAvoidingView",
157
178
  "Modal",
@@ -171,6 +192,25 @@ __all__ = [
171
192
  "TextInput",
172
193
  "View",
173
194
  "WebView",
195
+ # Built-in Props dataclasses
196
+ "ActivityIndicatorProps",
197
+ "ButtonProps",
198
+ "ImageProps",
199
+ "KeyboardAvoidingViewProps",
200
+ "ModalProps",
201
+ "PickerProps",
202
+ "PressableProps",
203
+ "ProgressBarProps",
204
+ "SafeAreaViewProps",
205
+ "ScrollViewProps",
206
+ "SliderProps",
207
+ "SpacerProps",
208
+ "StatusBarProps",
209
+ "SwitchProps",
210
+ "TextInputProps",
211
+ "TextProps",
212
+ "ViewProps",
213
+ "WebViewProps",
174
214
  # Core
175
215
  "Element",
176
216
  "create_screen",
@@ -178,6 +218,7 @@ __all__ = [
178
218
  "batch_updates",
179
219
  "component",
180
220
  "create_context",
221
+ "memo",
181
222
  "use_callback",
182
223
  "use_context",
183
224
  "use_effect",
@@ -225,6 +266,7 @@ __all__ = [
225
266
  # Animation
226
267
  "Animated",
227
268
  "AnimatedValue",
269
+ "use_animated_value",
228
270
  # Imperative
229
271
  "Alert",
230
272
  # Native modules
pythonnative/animated.py CHANGED
@@ -661,7 +661,45 @@ class _AnimatedNamespace:
661
661
  Animated = _AnimatedNamespace()
662
662
 
663
663
 
664
+ def use_animated_value(initial: float = 0.0) -> AnimatedValue:
665
+ """Return an [`AnimatedValue`][pythonnative.AnimatedValue] with a stable identity across renders.
666
+
667
+ Convenience wrapper for the common pattern
668
+ ``pn.use_memo(lambda: AnimatedValue(initial), [])``. The same
669
+ instance is returned on every render of the same component, so
670
+ you can drive it from event handlers without recreating it.
671
+
672
+ Args:
673
+ initial: The starting numeric value.
674
+
675
+ Returns:
676
+ A mount-stable [`AnimatedValue`][pythonnative.AnimatedValue].
677
+
678
+ Example:
679
+ ```python
680
+ import pythonnative as pn
681
+
682
+ @pn.component
683
+ def FadeIn():
684
+ opacity = pn.use_animated_value(0.0)
685
+
686
+ def fade_in():
687
+ pn.Animated.timing(opacity, to=1.0, duration=300).start()
688
+
689
+ pn.use_effect(lambda: fade_in(), [])
690
+ return pn.Animated.View(
691
+ pn.Text("Hello"),
692
+ style=pn.style(opacity=opacity),
693
+ )
694
+ ```
695
+ """
696
+ from .hooks import use_memo
697
+
698
+ return use_memo(lambda: AnimatedValue(initial), [])
699
+
700
+
664
701
  __all__ = [
665
702
  "AnimatedValue",
666
703
  "Animated",
704
+ "use_animated_value",
667
705
  ]