@onekeyfe/react-native-native-list 3.0.105

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 (181) hide show
  1. package/README.md +342 -0
  2. package/android/CMakeLists.txt +20 -0
  3. package/android/build.gradle +105 -0
  4. package/android/gradle.properties +4 -0
  5. package/android/src/main/AndroidManifest.xml +1 -0
  6. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  7. package/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +125 -0
  8. package/android/src/main/java/com/onekey/nativelist/NativeListAdapter.kt +165 -0
  9. package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +147 -0
  10. package/android/src/main/java/com/onekey/nativelist/NativeListPackage.kt +25 -0
  11. package/android/src/main/java/com/onekey/nativelist/NativeListRowView.kt +2939 -0
  12. package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +1794 -0
  13. package/common/fonts/Roobert-Bold.ttf +0 -0
  14. package/common/fonts/Roobert-Medium.ttf +0 -0
  15. package/common/fonts/Roobert-Regular.ttf +0 -0
  16. package/common/fonts/Roobert-SemiBold.ttf +0 -0
  17. package/docs/DESIGN.md +129 -0
  18. package/ios/HybridNativeList.swift +131 -0
  19. package/ios/NativeListCell.swift +2858 -0
  20. package/ios/NativeListDesignAssets.swift +110 -0
  21. package/ios/NativeListModels.swift +215 -0
  22. package/ios/RNCNativeListView.swift +1737 -0
  23. package/ios/Resources/NativeListIcons.xcassets/Contents.json +1 -0
  24. package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/Contents.json +1 -0
  25. package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/icon.svg +1 -0
  26. package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/Contents.json +1 -0
  27. package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/icon.svg +1 -0
  28. package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/Contents.json +1 -0
  29. package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/icon.svg +1 -0
  30. package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/Contents.json +1 -0
  31. package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/icon.svg +1 -0
  32. package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/Contents.json +1 -0
  33. package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/icon.svg +1 -0
  34. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/Contents.json +1 -0
  35. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/icon.svg +1 -0
  36. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/Contents.json +1 -0
  37. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/icon.svg +1 -0
  38. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/Contents.json +1 -0
  39. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/icon.svg +1 -0
  40. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/Contents.json +1 -0
  41. package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/icon.svg +1 -0
  42. package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/Contents.json +1 -0
  43. package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/icon.svg +1 -0
  44. package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/Contents.json +1 -0
  45. package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/icon.svg +1 -0
  46. package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/Contents.json +1 -0
  47. package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/icon.svg +1 -0
  48. package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/Contents.json +1 -0
  49. package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/icon.svg +1 -0
  50. package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/Contents.json +1 -0
  51. package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/icon.svg +1 -0
  52. package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/Contents.json +1 -0
  53. package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/icon.svg +1 -0
  54. package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/Contents.json +1 -0
  55. package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/icon.svg +1 -0
  56. package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/Contents.json +1 -0
  57. package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/icon.svg +1 -0
  58. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/Contents.json +1 -0
  59. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/icon.svg +1 -0
  60. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/Contents.json +1 -0
  61. package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/icon.svg +1 -0
  62. package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/Contents.json +1 -0
  63. package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/icon.svg +1 -0
  64. package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/Contents.json +1 -0
  65. package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/icon.svg +1 -0
  66. package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/Contents.json +1 -0
  67. package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/icon.svg +1 -0
  68. package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/Contents.json +1 -0
  69. package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/icon.svg +1 -0
  70. package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/Contents.json +1 -0
  71. package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/icon.svg +1 -0
  72. package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/Contents.json +1 -0
  73. package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/icon.svg +1 -0
  74. package/lib/module/NativeList.js +183 -0
  75. package/lib/module/NativeList.nitro.js +4 -0
  76. package/lib/module/NativeList.types.js +4 -0
  77. package/lib/module/NativeList.web.js +167 -0
  78. package/lib/module/index.js +6 -0
  79. package/lib/module/models.js +2 -0
  80. package/lib/module/package.json +1 -0
  81. package/lib/module/scrolling.js +121 -0
  82. package/lib/module/selection.js +85 -0
  83. package/lib/module/validation.js +562 -0
  84. package/lib/module/web/NativeListWebEngine.js +2238 -0
  85. package/lib/nitrogen/generated/.gitattributes +1 -0
  86. package/lib/nitrogen/generated/android/c++/JFunc_void_std__string.hpp +76 -0
  87. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +201 -0
  88. package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +84 -0
  89. package/lib/nitrogen/generated/android/c++/JNativeListScrollAlignment.hpp +64 -0
  90. package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +104 -0
  91. package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.hpp +54 -0
  92. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/Func_void_std__string.kt +78 -0
  93. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +177 -0
  94. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/NativeListScrollAlignment.kt +25 -0
  95. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/nativelistOnLoad.kt +35 -0
  96. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/views/HybridNativeListManager.kt +96 -0
  97. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/views/HybridNativeListStateUpdater.kt +23 -0
  98. package/lib/nitrogen/generated/android/nativelist+autolinking.cmake +83 -0
  99. package/lib/nitrogen/generated/android/nativelist+autolinking.gradle +27 -0
  100. package/lib/nitrogen/generated/android/nativelistOnLoad.cpp +58 -0
  101. package/lib/nitrogen/generated/android/nativelistOnLoad.hpp +34 -0
  102. package/lib/nitrogen/generated/ios/NativeListModule+autolinking.rb +62 -0
  103. package/lib/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Bridge.cpp +41 -0
  104. package/lib/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Bridge.hpp +91 -0
  105. package/lib/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Umbrella.hpp +49 -0
  106. package/lib/nitrogen/generated/ios/NativeListModuleAutolinking.mm +33 -0
  107. package/lib/nitrogen/generated/ios/NativeListModuleAutolinking.swift +26 -0
  108. package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.cpp +11 -0
  109. package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +180 -0
  110. package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +180 -0
  111. package/lib/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
  112. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +69 -0
  113. package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +447 -0
  114. package/lib/nitrogen/generated/ios/swift/NativeListScrollAlignment.swift +48 -0
  115. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +43 -0
  116. package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +87 -0
  117. package/lib/nitrogen/generated/shared/c++/NativeListScrollAlignment.hpp +84 -0
  118. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +46 -0
  119. package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +103 -0
  120. package/lib/nitrogen/generated/shared/json/NativeListConfig.json +16 -0
  121. package/lib/typescript/package.json +1 -0
  122. package/lib/typescript/src/NativeList.d.ts +18 -0
  123. package/lib/typescript/src/NativeList.nitro.d.ts +29 -0
  124. package/lib/typescript/src/NativeList.types.d.ts +87 -0
  125. package/lib/typescript/src/NativeList.web.d.ts +19 -0
  126. package/lib/typescript/src/index.d.ts +7 -0
  127. package/lib/typescript/src/models.d.ts +456 -0
  128. package/lib/typescript/src/scrolling.d.ts +32 -0
  129. package/lib/typescript/src/selection.d.ts +27 -0
  130. package/lib/typescript/src/validation.d.ts +7 -0
  131. package/lib/typescript/src/web/NativeListWebEngine.d.ts +203 -0
  132. package/nitro.json +23 -0
  133. package/nitrogen/generated/.gitattributes +1 -0
  134. package/nitrogen/generated/android/c++/JFunc_void_std__string.hpp +76 -0
  135. package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +201 -0
  136. package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +84 -0
  137. package/nitrogen/generated/android/c++/JNativeListScrollAlignment.hpp +64 -0
  138. package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +104 -0
  139. package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.hpp +54 -0
  140. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/Func_void_std__string.kt +78 -0
  141. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +177 -0
  142. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/NativeListScrollAlignment.kt +25 -0
  143. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/nativelistOnLoad.kt +35 -0
  144. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/views/HybridNativeListManager.kt +96 -0
  145. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/views/HybridNativeListStateUpdater.kt +23 -0
  146. package/nitrogen/generated/android/nativelist+autolinking.cmake +83 -0
  147. package/nitrogen/generated/android/nativelist+autolinking.gradle +27 -0
  148. package/nitrogen/generated/android/nativelistOnLoad.cpp +58 -0
  149. package/nitrogen/generated/android/nativelistOnLoad.hpp +34 -0
  150. package/nitrogen/generated/ios/NativeListModule+autolinking.rb +62 -0
  151. package/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Bridge.cpp +41 -0
  152. package/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Bridge.hpp +91 -0
  153. package/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Umbrella.hpp +49 -0
  154. package/nitrogen/generated/ios/NativeListModuleAutolinking.mm +33 -0
  155. package/nitrogen/generated/ios/NativeListModuleAutolinking.swift +26 -0
  156. package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.cpp +11 -0
  157. package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +180 -0
  158. package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +180 -0
  159. package/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
  160. package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +69 -0
  161. package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +447 -0
  162. package/nitrogen/generated/ios/swift/NativeListScrollAlignment.swift +48 -0
  163. package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +43 -0
  164. package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +87 -0
  165. package/nitrogen/generated/shared/c++/NativeListScrollAlignment.hpp +84 -0
  166. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +46 -0
  167. package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +103 -0
  168. package/nitrogen/generated/shared/json/NativeListConfig.json +16 -0
  169. package/package.json +126 -0
  170. package/react-native-native-list.podspec +38 -0
  171. package/react-native.config.js +19 -0
  172. package/src/NativeList.nitro.ts +48 -0
  173. package/src/NativeList.tsx +298 -0
  174. package/src/NativeList.types.ts +125 -0
  175. package/src/NativeList.web.tsx +258 -0
  176. package/src/index.ts +35 -0
  177. package/src/models.ts +604 -0
  178. package/src/scrolling.ts +189 -0
  179. package/src/selection.ts +159 -0
  180. package/src/validation.ts +877 -0
  181. package/src/web/NativeListWebEngine.ts +3767 -0
@@ -0,0 +1,87 @@
1
+ ///
2
+ /// HybridNativeListSpec.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/HybridObject.hpp>)
11
+ #include <NitroModules/HybridObject.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+
16
+ // Forward declaration of `NativeListScrollAlignment` to properly resolve imports.
17
+ namespace margelo::nitro::nativelist { enum class NativeListScrollAlignment; }
18
+
19
+ #include <string>
20
+ #include <functional>
21
+ #include <optional>
22
+ #include "NativeListScrollAlignment.hpp"
23
+
24
+ namespace margelo::nitro::nativelist {
25
+
26
+ using namespace margelo::nitro;
27
+
28
+ /**
29
+ * An abstract base class for `NativeList`
30
+ * Inherit this class to create instances of `HybridNativeListSpec` in C++.
31
+ * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
32
+ * @example
33
+ * ```cpp
34
+ * class HybridNativeList: public HybridNativeListSpec {
35
+ * public:
36
+ * HybridNativeList(...): HybridObject(TAG) { ... }
37
+ * // ...
38
+ * };
39
+ * ```
40
+ */
41
+ class HybridNativeListSpec: public virtual HybridObject {
42
+ public:
43
+ // Constructor
44
+ explicit HybridNativeListSpec(): HybridObject(TAG) { }
45
+
46
+ // Destructor
47
+ ~HybridNativeListSpec() override = default;
48
+
49
+ public:
50
+ // Properties
51
+ virtual std::string getSnapshotJson() = 0;
52
+ virtual void setSnapshotJson(const std::string& snapshotJson) = 0;
53
+ virtual std::optional<std::function<void(const std::string& /* payloadJson */)>> getOnRowAction() = 0;
54
+ virtual void setOnRowAction(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onRowAction) = 0;
55
+ virtual std::optional<std::function<void(const std::string& /* payloadJson */)>> getOnActionAnchorInvalidated() = 0;
56
+ virtual void setOnActionAnchorInvalidated(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onActionAnchorInvalidated) = 0;
57
+ virtual std::optional<std::function<void(const std::string& /* payloadJson */)>> getOnSelectionDelta() = 0;
58
+ virtual void setOnSelectionDelta(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onSelectionDelta) = 0;
59
+ virtual std::optional<std::function<void(const std::string& /* payloadJson */)>> getOnReorder() = 0;
60
+ virtual void setOnReorder(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onReorder) = 0;
61
+ virtual std::optional<std::function<void(const std::string& /* payloadJson */)>> getOnEndReached() = 0;
62
+ virtual void setOnEndReached(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onEndReached) = 0;
63
+ virtual std::optional<std::function<void(const std::string& /* payloadJson */)>> getOnVisibleRangeChanged() = 0;
64
+ virtual void setOnVisibleRangeChanged(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onVisibleRangeChanged) = 0;
65
+
66
+ public:
67
+ // Methods
68
+ virtual void applySnapshot(const std::string& snapshotJson) = 0;
69
+ virtual void applyPatches(const std::string& patchesJson) = 0;
70
+ virtual void reconcileSelection(const std::string& selectedKeysJson) = 0;
71
+ virtual void scrollToKey(const std::string& key, bool animated, NativeListScrollAlignment alignment, double viewPosition, double viewOffset) = 0;
72
+ virtual void scrollToIndex(double index, bool animated, NativeListScrollAlignment alignment, double viewPosition, double viewOffset) = 0;
73
+ virtual void scrollToOffset(double offset, bool animated) = 0;
74
+ virtual void scrollToEnd(bool animated) = 0;
75
+ virtual void setActionAnchorState(const std::string& stateJson) = 0;
76
+ virtual void setRefreshing(bool refreshing) = 0;
77
+
78
+ protected:
79
+ // Hybrid Setup
80
+ void loadHybridMethods() override;
81
+
82
+ protected:
83
+ // Tag for logging
84
+ static constexpr auto TAG = "NativeList";
85
+ };
86
+
87
+ } // namespace margelo::nitro::nativelist
@@ -0,0 +1,84 @@
1
+ ///
2
+ /// NativeListScrollAlignment.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/NitroHash.hpp>)
11
+ #include <NitroModules/NitroHash.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
16
+ #include <NitroModules/JSIConverter.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
21
+ #include <NitroModules/NitroDefines.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+ namespace margelo::nitro::nativelist {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (NativeListScrollAlignment).
30
+ */
31
+ enum class NativeListScrollAlignment {
32
+ START SWIFT_NAME(start) = 0,
33
+ CENTER SWIFT_NAME(center) = 1,
34
+ END SWIFT_NAME(end) = 2,
35
+ NEAREST SWIFT_NAME(nearest) = 3,
36
+ } CLOSED_ENUM;
37
+
38
+ } // namespace margelo::nitro::nativelist
39
+
40
+ namespace margelo::nitro {
41
+
42
+ // C++ NativeListScrollAlignment <> JS NativeListScrollAlignment (union)
43
+ template <>
44
+ struct JSIConverter<margelo::nitro::nativelist::NativeListScrollAlignment> final {
45
+ static inline margelo::nitro::nativelist::NativeListScrollAlignment fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
46
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
47
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
48
+ case hashString("start"): return margelo::nitro::nativelist::NativeListScrollAlignment::START;
49
+ case hashString("center"): return margelo::nitro::nativelist::NativeListScrollAlignment::CENTER;
50
+ case hashString("end"): return margelo::nitro::nativelist::NativeListScrollAlignment::END;
51
+ case hashString("nearest"): return margelo::nitro::nativelist::NativeListScrollAlignment::NEAREST;
52
+ default: [[unlikely]]
53
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum NativeListScrollAlignment - invalid value!");
54
+ }
55
+ }
56
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::nativelist::NativeListScrollAlignment arg) {
57
+ switch (arg) {
58
+ case margelo::nitro::nativelist::NativeListScrollAlignment::START: return JSIConverter<std::string>::toJSI(runtime, "start");
59
+ case margelo::nitro::nativelist::NativeListScrollAlignment::CENTER: return JSIConverter<std::string>::toJSI(runtime, "center");
60
+ case margelo::nitro::nativelist::NativeListScrollAlignment::END: return JSIConverter<std::string>::toJSI(runtime, "end");
61
+ case margelo::nitro::nativelist::NativeListScrollAlignment::NEAREST: return JSIConverter<std::string>::toJSI(runtime, "nearest");
62
+ default: [[unlikely]]
63
+ throw std::invalid_argument("Cannot convert NativeListScrollAlignment to JS - invalid value: "
64
+ + std::to_string(static_cast<int>(arg)) + "!");
65
+ }
66
+ }
67
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
68
+ if (!value.isString()) {
69
+ return false;
70
+ }
71
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
72
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
73
+ case hashString("start"):
74
+ case hashString("center"):
75
+ case hashString("end"):
76
+ case hashString("nearest"):
77
+ return true;
78
+ default:
79
+ return false;
80
+ }
81
+ }
82
+ };
83
+
84
+ } // namespace margelo::nitro
@@ -0,0 +1,46 @@
1
+ ///
2
+ /// HybridNativeListComponent.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "HybridNativeListComponent.hpp"
9
+
10
+ #include <NitroModules/NitroHash.hpp>
11
+ #include <NitroModules/ReactProp.hpp>
12
+
13
+ namespace margelo::nitro::nativelist::views {
14
+
15
+ using namespace facebook;
16
+
17
+ extern const char HybridNativeListComponentName[] = "NativeList";
18
+
19
+ HybridNativeListProps::HybridNativeListProps(const react::PropsParserContext& context,
20
+ const HybridNativeListProps& sourceProps,
21
+ const react::RawProps& rawProps):
22
+ react::ViewProps(context, sourceProps, rawProps, filterObjectKeys),
23
+ snapshotJson(nitro::ReactProp<std::string>::fromRawValue("NativeList", "snapshotJson", rawProps, sourceProps.snapshotJson)),
24
+ onRowAction(nitro::ReactProp<std::optional<std::function<void(const std::string& /* payloadJson */)>>>::fromRawValue("NativeList", "onRowAction", rawProps, sourceProps.onRowAction)),
25
+ onActionAnchorInvalidated(nitro::ReactProp<std::optional<std::function<void(const std::string& /* payloadJson */)>>>::fromRawValue("NativeList", "onActionAnchorInvalidated", rawProps, sourceProps.onActionAnchorInvalidated)),
26
+ onSelectionDelta(nitro::ReactProp<std::optional<std::function<void(const std::string& /* payloadJson */)>>>::fromRawValue("NativeList", "onSelectionDelta", rawProps, sourceProps.onSelectionDelta)),
27
+ onReorder(nitro::ReactProp<std::optional<std::function<void(const std::string& /* payloadJson */)>>>::fromRawValue("NativeList", "onReorder", rawProps, sourceProps.onReorder)),
28
+ onEndReached(nitro::ReactProp<std::optional<std::function<void(const std::string& /* payloadJson */)>>>::fromRawValue("NativeList", "onEndReached", rawProps, sourceProps.onEndReached)),
29
+ onVisibleRangeChanged(nitro::ReactProp<std::optional<std::function<void(const std::string& /* payloadJson */)>>>::fromRawValue("NativeList", "onVisibleRangeChanged", rawProps, sourceProps.onVisibleRangeChanged)),
30
+ hybridRef(nitro::ReactProp<std::optional<std::function<void(const std::shared_ptr<HybridNativeListSpec>& /* ref */)>>>::fromRawValue("NativeList", "hybridRef", rawProps, sourceProps.hybridRef)) { }
31
+
32
+ bool HybridNativeListProps::filterObjectKeys(const std::string& propName) {
33
+ switch (hashString(propName)) {
34
+ case hashString("snapshotJson"): return true;
35
+ case hashString("onRowAction"): return true;
36
+ case hashString("onActionAnchorInvalidated"): return true;
37
+ case hashString("onSelectionDelta"): return true;
38
+ case hashString("onReorder"): return true;
39
+ case hashString("onEndReached"): return true;
40
+ case hashString("onVisibleRangeChanged"): return true;
41
+ case hashString("hybridRef"): return true;
42
+ default: return false;
43
+ }
44
+ }
45
+
46
+ } // namespace margelo::nitro::nativelist::views
@@ -0,0 +1,103 @@
1
+ ///
2
+ /// HybridNativeListComponent.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <NitroModules/ReactProp.hpp>
11
+ #include <NitroModules/ViewComponentDescriptor.hpp>
12
+ #include <NitroModules/ViewPropsHolderState.hpp>
13
+ #include <react/renderer/components/view/ConcreteViewShadowNode.h>
14
+ #include <react/renderer/components/view/ViewProps.h>
15
+ #include <react/renderer/core/PropsParserContext.h>
16
+ #include <react/renderer/core/RawProps.h>
17
+
18
+ #include <string>
19
+
20
+ #include <string>
21
+ #include <functional>
22
+ #include <optional>
23
+ #include <memory>
24
+ #include "HybridNativeListSpec.hpp"
25
+
26
+ namespace margelo::nitro::nativelist::views {
27
+
28
+ using namespace facebook;
29
+
30
+ /**
31
+ * The name of the actual native View.
32
+ */
33
+ extern const char HybridNativeListComponentName[];
34
+
35
+ /**
36
+ * Props for the "NativeList" View.
37
+ */
38
+ class HybridNativeListProps final: public react::ViewProps {
39
+ public:
40
+ HybridNativeListProps() = default;
41
+ HybridNativeListProps(const react::PropsParserContext& context,
42
+ const HybridNativeListProps& sourceProps,
43
+ const react::RawProps& rawProps);
44
+
45
+ public:
46
+ nitro::ReactProp<std::string> snapshotJson;
47
+ nitro::ReactProp<std::optional<std::function<void(const std::string& /* payloadJson */)>>> onRowAction;
48
+ nitro::ReactProp<std::optional<std::function<void(const std::string& /* payloadJson */)>>> onActionAnchorInvalidated;
49
+ nitro::ReactProp<std::optional<std::function<void(const std::string& /* payloadJson */)>>> onSelectionDelta;
50
+ nitro::ReactProp<std::optional<std::function<void(const std::string& /* payloadJson */)>>> onReorder;
51
+ nitro::ReactProp<std::optional<std::function<void(const std::string& /* payloadJson */)>>> onEndReached;
52
+ nitro::ReactProp<std::optional<std::function<void(const std::string& /* payloadJson */)>>> onVisibleRangeChanged;
53
+ nitro::ReactProp<std::optional<std::function<void(const std::shared_ptr<HybridNativeListSpec>& /* ref */)>>> hybridRef;
54
+
55
+ [[nodiscard]]
56
+ bool hasSameProps(const HybridNativeListProps& other) const noexcept {
57
+ return snapshotJson.hasSameValue(other.snapshotJson) &&
58
+ onRowAction.hasSameValue(other.onRowAction) &&
59
+ onActionAnchorInvalidated.hasSameValue(other.onActionAnchorInvalidated) &&
60
+ onSelectionDelta.hasSameValue(other.onSelectionDelta) &&
61
+ onReorder.hasSameValue(other.onReorder) &&
62
+ onEndReached.hasSameValue(other.onEndReached) &&
63
+ onVisibleRangeChanged.hasSameValue(other.onVisibleRangeChanged) &&
64
+ hybridRef.hasSameValue(other.hybridRef);
65
+ }
66
+
67
+ [[nodiscard]]
68
+ bool hasAnyProvidedProps() const noexcept {
69
+ return snapshotJson.isProvided() ||
70
+ onRowAction.isProvided() ||
71
+ onActionAnchorInvalidated.isProvided() ||
72
+ onSelectionDelta.isProvided() ||
73
+ onReorder.isProvided() ||
74
+ onEndReached.isProvided() ||
75
+ onVisibleRangeChanged.isProvided() ||
76
+ hybridRef.isProvided();
77
+ }
78
+
79
+ private:
80
+ static bool filterObjectKeys(const std::string& propName);
81
+ };
82
+
83
+ /**
84
+ * State for the "NativeList" View.
85
+ */
86
+ using HybridNativeListState = nitro::ViewPropsHolderState<HybridNativeListProps>;
87
+
88
+ /**
89
+ * The Shadow Node for the "NativeList" View.
90
+ */
91
+ using HybridNativeListShadowNode = react::ConcreteViewShadowNode<HybridNativeListComponentName /* "HybridNativeList" */,
92
+ HybridNativeListProps /* custom props */,
93
+ react::ViewEventEmitter /* default */,
94
+ HybridNativeListState /* custom state */>;
95
+
96
+ /**
97
+ * The Component Descriptor for the "NativeList" View.
98
+ */
99
+ using HybridNativeListComponentDescriptor = nitro::ViewComponentDescriptor<HybridNativeListShadowNode>;
100
+
101
+ /* The actual view for "NativeList" needs to be implemented in platform-specific code. */
102
+
103
+ } // namespace margelo::nitro::nativelist::views
@@ -0,0 +1,16 @@
1
+ {
2
+ "uiViewClassName": "NativeList",
3
+ "supportsRawText": false,
4
+ "bubblingEventTypes": {},
5
+ "directEventTypes": {},
6
+ "validAttributes": {
7
+ "snapshotJson": true,
8
+ "onRowAction": true,
9
+ "onActionAnchorInvalidated": true,
10
+ "onSelectionDelta": true,
11
+ "onReorder": true,
12
+ "onEndReached": true,
13
+ "onVisibleRangeChanged": true,
14
+ "hybridRef": true
15
+ }
16
+ }
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import type { NativeListProps } from './NativeList.types';
3
+ export type { NativeListProps, NativeListRef } from './NativeList.types';
4
+ export type { ActionAnchorState, ScrollAlignment, ScrollPositionOptions, ScrollToEndParams, ScrollToIndexFailedInfo, ScrollToIndexParams, ScrollToItemParams, ScrollToKeyParams, ScrollToLocationParams, ScrollToOffsetParams, } from './NativeList.types';
5
+ export declare const NativeList: React.ForwardRefExoticComponent<NativeListProps & React.RefAttributes<Readonly<{
6
+ applySnapshot(snapshot: import("./models").NativeListSnapshot): void;
7
+ applyPatches(patches: readonly import("./models").RowPatch[]): void;
8
+ reconcileSelection(selectedKeys: readonly string[]): void;
9
+ scrollToKey: (paramsOrKey: import("./NativeList.types").ScrollToKeyParams | string, animated?: boolean, alignment?: import("./NativeList.types").ScrollAlignment) => void;
10
+ scrollToIndex: (paramsOrIndex: import("./NativeList.types").ScrollToIndexParams | number, animated?: boolean, alignment?: import("./NativeList.types").ScrollAlignment) => void;
11
+ scrollToItem(params: import("./NativeList.types").ScrollToItemParams): void;
12
+ scrollToOffset(params: import("./NativeList.types").ScrollToOffsetParams): void;
13
+ scrollToEnd(params?: import("./NativeList.types").ScrollToEndParams): void;
14
+ scrollToLocation(params: import("./NativeList.types").ScrollToLocationParams): void;
15
+ setActionAnchorState(state: import("./NativeList.types").ActionAnchorState): void;
16
+ setRefreshing(refreshing: boolean): void;
17
+ }>>>;
18
+ //# sourceMappingURL=NativeList.d.ts.map
@@ -0,0 +1,29 @@
1
+ import type { HybridView, HybridViewMethods, HybridViewProps } from 'react-native-nitro-modules';
2
+ /**
3
+ * Nitro owns only the React Native host boundary. Snapshot diffing, layout,
4
+ * recycling, selection, and scrolling remain native UICollectionView /
5
+ * RecyclerView work.
6
+ */
7
+ export interface NativeListNativeProps extends HybridViewProps {
8
+ snapshotJson: string;
9
+ onRowAction?: (payloadJson: string) => void;
10
+ onActionAnchorInvalidated?: (payloadJson: string) => void;
11
+ onSelectionDelta?: (payloadJson: string) => void;
12
+ onReorder?: (payloadJson: string) => void;
13
+ onEndReached?: (payloadJson: string) => void;
14
+ onVisibleRangeChanged?: (payloadJson: string) => void;
15
+ }
16
+ export type NativeListScrollAlignment = 'start' | 'center' | 'end' | 'nearest';
17
+ export interface NativeListMethods extends HybridViewMethods {
18
+ applySnapshot(snapshotJson: string): void;
19
+ applyPatches(patchesJson: string): void;
20
+ reconcileSelection(selectedKeysJson: string): void;
21
+ scrollToKey(key: string, animated: boolean, alignment: NativeListScrollAlignment, viewPosition: number, viewOffset: number): void;
22
+ scrollToIndex(index: number, animated: boolean, alignment: NativeListScrollAlignment, viewPosition: number, viewOffset: number): void;
23
+ scrollToOffset(offset: number, animated: boolean): void;
24
+ scrollToEnd(animated: boolean): void;
25
+ setActionAnchorState(stateJson: string): void;
26
+ setRefreshing(refreshing: boolean): void;
27
+ }
28
+ export type NativeList = HybridView<NativeListNativeProps, NativeListMethods>;
29
+ //# sourceMappingURL=NativeList.nitro.d.ts.map
@@ -0,0 +1,87 @@
1
+ import type { ViewProps } from 'react-native';
2
+ import type { ActionAnchorInvalidatedEvent, EndReachedEvent, NativeListSnapshot, ReorderEvent, RowActionEvent, RowModel, RowPatch, SelectionDeltaEvent, VisibleRangeChangedEvent } from './models';
3
+ export type ActionAnchorState = Readonly<{
4
+ token: string;
5
+ open: boolean;
6
+ restoreFocus?: boolean;
7
+ }>;
8
+ export type ScrollAlignment = 'start' | 'center' | 'end' | 'nearest';
9
+ export type ScrollPositionOptions = Readonly<{
10
+ animated?: boolean;
11
+ alignment?: ScrollAlignment;
12
+ viewPosition?: number;
13
+ viewOffset?: number;
14
+ }>;
15
+ export type ScrollToIndexParams = ScrollPositionOptions & Readonly<{
16
+ index: number;
17
+ }>;
18
+ export type ScrollToKeyParams = ScrollPositionOptions & Readonly<{
19
+ key: string;
20
+ }>;
21
+ export type ScrollToItemParams = ScrollPositionOptions & Readonly<{
22
+ item: RowModel;
23
+ }>;
24
+ export type ScrollToOffsetParams = Readonly<{
25
+ offset: number;
26
+ animated?: boolean;
27
+ }>;
28
+ export type ScrollToEndParams = Readonly<{
29
+ animated?: boolean;
30
+ }>;
31
+ export type ScrollToLocationParams = ScrollPositionOptions & Readonly<{
32
+ sectionIndex: number;
33
+ itemIndex: number;
34
+ }>;
35
+ export type ScrollToIndexFailedInfo = Readonly<{
36
+ index: number;
37
+ itemCount: number;
38
+ highestMeasuredFrameIndex: number;
39
+ averageItemLength: number;
40
+ reason: 'index-out-of-range' | 'section-out-of-range' | 'item-out-of-range' | 'item-not-found';
41
+ }>;
42
+ type InitialScrollProps = Readonly<{
43
+ initialScrollIndex?: never;
44
+ initialScrollKey?: never;
45
+ initialScrollViewPosition?: never;
46
+ initialScrollViewOffset?: never;
47
+ }> | Readonly<{
48
+ initialScrollIndex: number;
49
+ initialScrollKey?: never;
50
+ initialScrollViewPosition?: number;
51
+ initialScrollViewOffset?: number;
52
+ }> | Readonly<{
53
+ initialScrollIndex?: never;
54
+ initialScrollKey: string;
55
+ initialScrollViewPosition?: number;
56
+ initialScrollViewOffset?: number;
57
+ }>;
58
+ type ScrollToIndex = (paramsOrIndex: ScrollToIndexParams | number, animated?: boolean, alignment?: ScrollAlignment) => void;
59
+ type ScrollToKey = (paramsOrKey: ScrollToKeyParams | string, animated?: boolean, alignment?: ScrollAlignment) => void;
60
+ export type NativeListRef = Readonly<{
61
+ applySnapshot(snapshot: NativeListSnapshot): void;
62
+ applyPatches(patches: readonly RowPatch[]): void;
63
+ reconcileSelection(selectedKeys: readonly string[]): void;
64
+ scrollToKey: ScrollToKey;
65
+ scrollToIndex: ScrollToIndex;
66
+ scrollToItem(params: ScrollToItemParams): void;
67
+ scrollToOffset(params: ScrollToOffsetParams): void;
68
+ scrollToEnd(params?: ScrollToEndParams): void;
69
+ scrollToLocation(params: ScrollToLocationParams): void;
70
+ setActionAnchorState(state: ActionAnchorState): void;
71
+ setRefreshing(refreshing: boolean): void;
72
+ }>;
73
+ export type NativeListProps = Omit<ViewProps, 'children'> & Readonly<{
74
+ snapshot: NativeListSnapshot;
75
+ /** Web only. Defaults to true and is ignored by the native host. */
76
+ webVirtualizationEnabled?: boolean;
77
+ onRowAction?: (event: RowActionEvent) => void;
78
+ onActionAnchorInvalidated?: (event: ActionAnchorInvalidatedEvent) => void;
79
+ onSelectionDelta?: (event: SelectionDeltaEvent) => void;
80
+ onReorder?: (event: ReorderEvent) => void;
81
+ onEndReached?: (event: EndReachedEvent) => void;
82
+ onVisibleRangeChanged?: (event: VisibleRangeChangedEvent) => void;
83
+ onRefresh?: () => void;
84
+ onScrollToIndexFailed?: (info: ScrollToIndexFailedInfo) => void;
85
+ }> & InitialScrollProps;
86
+ export {};
87
+ //# sourceMappingURL=NativeList.types.d.ts.map
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import type { NativeListProps } from './NativeList.types';
3
+ import type { NativeListSnapshot } from './models';
4
+ export type { NativeListProps, NativeListRef } from './NativeList.types';
5
+ export type { ActionAnchorState, ScrollAlignment, ScrollPositionOptions, ScrollToEndParams, ScrollToIndexFailedInfo, ScrollToIndexParams, ScrollToItemParams, ScrollToKeyParams, ScrollToLocationParams, ScrollToOffsetParams, } from './NativeList.types';
6
+ export declare const NativeList: React.ForwardRefExoticComponent<NativeListProps & React.RefAttributes<Readonly<{
7
+ applySnapshot(snapshot: NativeListSnapshot): void;
8
+ applyPatches(patches: readonly import("./models").RowPatch[]): void;
9
+ reconcileSelection(selectedKeys: readonly string[]): void;
10
+ scrollToKey: (paramsOrKey: import("./NativeList.types").ScrollToKeyParams | string, animated?: boolean, alignment?: import("./NativeList.types").ScrollAlignment) => void;
11
+ scrollToIndex: (paramsOrIndex: import("./NativeList.types").ScrollToIndexParams | number, animated?: boolean, alignment?: import("./NativeList.types").ScrollAlignment) => void;
12
+ scrollToItem(params: import("./NativeList.types").ScrollToItemParams): void;
13
+ scrollToOffset(params: import("./NativeList.types").ScrollToOffsetParams): void;
14
+ scrollToEnd(params?: import("./NativeList.types").ScrollToEndParams): void;
15
+ scrollToLocation(params: import("./NativeList.types").ScrollToLocationParams): void;
16
+ setActionAnchorState(state: import("./NativeList.types").ActionAnchorState): void;
17
+ setRefreshing(refreshing: boolean): void;
18
+ }>>>;
19
+ //# sourceMappingURL=NativeList.web.d.ts.map
@@ -0,0 +1,7 @@
1
+ export { NativeList } from './NativeList';
2
+ export type { ActionAnchorState, NativeListProps, NativeListRef, ScrollAlignment, ScrollPositionOptions, ScrollToEndParams, ScrollToIndexFailedInfo, ScrollToIndexParams, ScrollToItemParams, ScrollToKeyParams, ScrollToLocationParams, ScrollToOffsetParams, } from './NativeList';
3
+ export type * from './models';
4
+ export { applyRowPatches, serializePatches, serializeSnapshot, validatePatches, validateSnapshot, } from './validation';
5
+ export { checkboxStateForKeys, checkboxStateForSection, isSelectableRow, reduceSelection, selectionStateFromSnapshot, } from './selection';
6
+ export type { SelectionAction, SelectionResult, SelectionState, } from './selection';
7
+ //# sourceMappingURL=index.d.ts.map