@legendapp/spark 0.0.3 → 0.0.4

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 (186) hide show
  1. package/init-template.cjs +7 -1
  2. package/package.json +10 -5
  3. package/patches/dependencies.json +4 -4
  4. package/patches/react-native-mmkv@4.3.2.patch +2 -2
  5. package/patches/react-native-nitro-zxing@0.3.1.patch +22 -0
  6. package/patches/registry.json +615 -0
  7. package/patches/workspace/expo-audio@55.0.18.patch +159 -0
  8. package/patches/workspace/op-engineering-op-sqlite@18.2.1.patch +796 -0
  9. package/patches/workspace/react-native-nitro-modules@0.37.0.patch +1348 -0
  10. package/patches/workspace/react-native-runtimes-core@0.1.0-alpha.2.patch +276 -0
  11. package/patches/workspace/react-native-webview@16.0.0.patch +208 -0
  12. package/postinstall.cjs +10 -1
  13. package/skills/spark/SKILL.md +37 -4
  14. package/skills/spark/UPGRADING.md +116 -1
  15. package/skills/spark/ai-customize.md +39 -0
  16. package/skills/spark/app-and-documents.md +56 -0
  17. package/skills/spark/external-libraries.md +87 -0
  18. package/skills/spark/files.md +64 -0
  19. package/skills/spark/integrations.md +69 -0
  20. package/skills/spark/keyboard.md +54 -0
  21. package/skills/spark/library-compat.md +76 -0
  22. package/skills/spark/menus-tray-dock.md +83 -0
  23. package/skills/spark/storage-settings.md +85 -0
  24. package/skills/spark/ui.md +57 -0
  25. package/skills/spark/windows.md +91 -0
  26. package/ui-popover.ts +1 -0
  27. package/ui-progress.ts +1 -0
  28. package/ui-sheet.ts +1 -0
  29. package/ui-split-view.ts +1 -0
  30. package/ui-table.ts +1 -0
  31. package/vendor/node_modules/@legendapp/spark-ai/package.json +3 -3
  32. package/vendor/node_modules/@legendapp/spark-audio/package.json +3 -13
  33. package/vendor/node_modules/@legendapp/spark-auth-session/package.json +3 -10
  34. package/vendor/node_modules/@legendapp/spark-cli/dist/add-desktop.js +5 -0
  35. package/vendor/node_modules/@legendapp/spark-cli/dist/build.js +137 -105
  36. package/vendor/node_modules/@legendapp/spark-cli/dist/cli-arguments.js +4 -1
  37. package/vendor/node_modules/@legendapp/spark-cli/dist/commands.js +16 -7
  38. package/vendor/node_modules/@legendapp/spark-cli/dist/dependency-pins.js +19 -3
  39. package/vendor/node_modules/@legendapp/spark-cli/dist/dev-command.js +2 -0
  40. package/vendor/node_modules/@legendapp/spark-cli/dist/dev.js +3 -0
  41. package/vendor/node_modules/@legendapp/spark-cli/dist/enriched-html-pins.js +2 -0
  42. package/vendor/node_modules/@legendapp/spark-cli/dist/errors.js +1 -1
  43. package/vendor/node_modules/@legendapp/spark-cli/dist/index.js +57 -9
  44. package/vendor/node_modules/@legendapp/spark-cli/dist/init-template.cjs +12 -2
  45. package/vendor/node_modules/@legendapp/spark-cli/dist/init-template.d.cts +1 -1
  46. package/vendor/node_modules/@legendapp/spark-cli/dist/metro.cjs +1 -0
  47. package/vendor/node_modules/@legendapp/spark-cli/dist/migrate.js +65 -0
  48. package/vendor/node_modules/@legendapp/spark-cli/dist/migration-helpers.cjs +4 -4
  49. package/vendor/node_modules/@legendapp/spark-cli/dist/migration-helpers.d.cts +2 -2
  50. package/vendor/node_modules/@legendapp/spark-cli/dist/migrations.cjs +12 -8
  51. package/vendor/node_modules/@legendapp/spark-cli/dist/native-patch-preflight.js +35 -7
  52. package/vendor/node_modules/@legendapp/spark-cli/dist/patch.js +92 -0
  53. package/vendor/node_modules/@legendapp/spark-cli/dist/project-version.js +12 -4
  54. package/vendor/node_modules/@legendapp/spark-cli/dist/project.js +8 -1
  55. package/vendor/node_modules/@legendapp/spark-cli/dist/release.json +20 -20
  56. package/vendor/node_modules/@legendapp/spark-cli/dist/upgrade.js +1 -1
  57. package/vendor/node_modules/@legendapp/spark-cli/dist/windows.js +3 -0
  58. package/vendor/node_modules/@legendapp/spark-cli/package.json +5 -4
  59. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/package.json +2 -2
  60. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/package.json +2 -2
  61. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/package.json +2 -2
  62. package/vendor/node_modules/@legendapp/spark-clipboard/macos/RNDesktopClipboard.mm +1 -1
  63. package/vendor/node_modules/@legendapp/spark-clipboard/package.json +3 -10
  64. package/vendor/node_modules/@legendapp/spark-clipboard/src/desktop.ts +1 -0
  65. package/vendor/node_modules/@legendapp/spark-codex/package.json +3 -7
  66. package/vendor/node_modules/@legendapp/spark-commands/package.json +5 -5
  67. package/vendor/node_modules/@legendapp/spark-context-menu/package.json +3 -10
  68. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.h +3 -1
  69. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.mm +51 -10
  70. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkStorage.h +4 -0
  71. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkStorage.mm +82 -0
  72. package/vendor/node_modules/@legendapp/spark-desktop-app/package.json +2 -8
  73. package/vendor/node_modules/@legendapp/spark-desktop-config/config.cjs +6 -8
  74. package/vendor/node_modules/@legendapp/spark-desktop-config/identity.cjs +2 -0
  75. package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.cjs +300 -71
  76. package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.d.cts +7 -0
  77. package/vendor/node_modules/@legendapp/spark-desktop-config/package.json +3 -3
  78. package/vendor/node_modules/@legendapp/spark-desktop-config/patch-registry.cjs +318 -0
  79. package/vendor/node_modules/@legendapp/spark-desktop-config/patch-registry.d.cts +20 -0
  80. package/vendor/node_modules/@legendapp/spark-desktop-config/validation.cjs +66 -9
  81. package/vendor/node_modules/@legendapp/spark-desktop-config/windows.plugin.cjs +1 -0
  82. package/vendor/node_modules/@legendapp/spark-desktop-host/AppDelegate.mm +1 -0
  83. package/vendor/node_modules/@legendapp/spark-desktop-host/package.json +2 -2
  84. package/vendor/node_modules/@legendapp/spark-desktop-links/package.json +3 -10
  85. package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/package.json +3 -10
  86. package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/RNDesktopWindows.mm +7 -2
  87. package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/RNWindowManager.mm +235 -240
  88. package/vendor/node_modules/@legendapp/spark-desktop-windows/package.json +4 -11
  89. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/api.ts +9 -3
  90. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/macos-adapter.ts +7 -0
  91. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/types.ts +32 -3
  92. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/validation.ts +28 -11
  93. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/createWindowsNavigator.tsx +15 -3
  94. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/primaryWindowLifecycle.ts +12 -3
  95. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/usePrimaryWindowLifecycle.ts +2 -1
  96. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/useWindowFocusEffect.ts +4 -1
  97. package/vendor/node_modules/@legendapp/spark-documents/package.json +7 -7
  98. package/vendor/node_modules/@legendapp/spark-drag-drop/macos/RNDesktopDragView.mm +77 -17
  99. package/vendor/node_modules/@legendapp/spark-drag-drop/package.json +3 -8
  100. package/vendor/node_modules/@legendapp/spark-drag-drop/src/DesktopDragViewNativeComponent.ts +1 -0
  101. package/vendor/node_modules/@legendapp/spark-drag-drop/src/contracts.ts +13 -4
  102. package/vendor/node_modules/@legendapp/spark-drag-drop/src/index.tsx +5 -3
  103. package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/SparkDragDrop.h +6 -1
  104. package/vendor/node_modules/@legendapp/spark-expo-compat/metro.cjs +44 -0
  105. package/vendor/node_modules/@legendapp/spark-expo-compat/package.json +20 -0
  106. package/vendor/node_modules/@legendapp/spark-expo-compat/src/clipboard.ts +40 -0
  107. package/vendor/node_modules/@legendapp/spark-expo-compat/src/document-picker.ts +52 -0
  108. package/vendor/node_modules/@legendapp/spark-file-dialog/package.json +3 -10
  109. package/vendor/node_modules/@legendapp/spark-file-dialog/src/options.ts +5 -2
  110. package/vendor/node_modules/@legendapp/spark-file-dialog/src/types.ts +3 -3
  111. package/vendor/node_modules/@legendapp/spark-file-system/macos/RNDesktopFileSystem.mm +1 -1
  112. package/vendor/node_modules/@legendapp/spark-file-system/package.json +3 -11
  113. package/vendor/node_modules/@legendapp/spark-global-shortcuts/package.json +3 -10
  114. package/vendor/node_modules/@legendapp/spark-html/package.json +2 -2
  115. package/vendor/node_modules/@legendapp/spark-markdown/package.json +2 -2
  116. package/vendor/node_modules/@legendapp/spark-message-dialog/package.json +3 -10
  117. package/vendor/node_modules/@legendapp/spark-message-dialog/src/index.ts +1 -0
  118. package/vendor/node_modules/@legendapp/spark-native-menu/package.json +3 -9
  119. package/vendor/node_modules/@legendapp/spark-native-menu/src/hooks.ts +4 -0
  120. package/vendor/node_modules/@legendapp/spark-notifications/package.json +3 -10
  121. package/vendor/node_modules/@legendapp/spark-processes/package.json +3 -10
  122. package/vendor/node_modules/@legendapp/spark-rich-text/package.json +2 -2
  123. package/vendor/node_modules/@legendapp/spark-secure-storage/package.json +3 -10
  124. package/vendor/node_modules/@legendapp/spark-settings/package.json +3 -3
  125. package/vendor/node_modules/@legendapp/spark-settings-ui/package.json +4 -4
  126. package/vendor/node_modules/@legendapp/spark-sqlite/package.json +3 -3
  127. package/vendor/node_modules/@legendapp/spark-system/package.json +3 -10
  128. package/vendor/node_modules/@legendapp/spark-tray/package.json +3 -10
  129. package/vendor/node_modules/@legendapp/spark-tray/src/index.ts +2 -1
  130. package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkButton.mm +82 -14
  131. package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkTextInput.h +1 -1
  132. package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkTextInput.mm +94 -11
  133. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSidebarSplitViewComponent.mm +235 -18
  134. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkPaneSplitView.h +17 -0
  135. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkPaneSplitView.mm +216 -0
  136. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkSplitViewComponent.h +4 -0
  137. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkSplitViewComponent.mm +212 -0
  138. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkSplitViewUpdates.h +6 -0
  139. package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSegmentedControl.mm +26 -13
  140. package/vendor/node_modules/@legendapp/spark-ui/macos/popover/RNSparkPopover.h +9 -0
  141. package/vendor/node_modules/@legendapp/spark-ui/macos/popover/RNSparkPopover.mm +126 -0
  142. package/vendor/node_modules/@legendapp/spark-ui/macos/progress/RNSparkProgressIndicator.h +9 -0
  143. package/vendor/node_modules/@legendapp/spark-ui/macos/progress/RNSparkProgressIndicator.mm +66 -0
  144. package/vendor/node_modules/@legendapp/spark-ui/macos/radio-group/RNSparkRadioGroup.h +9 -0
  145. package/vendor/node_modules/@legendapp/spark-ui/macos/radio-group/RNSparkRadioGroup.mm +118 -0
  146. package/vendor/node_modules/@legendapp/spark-ui/macos/sf-symbol/RNSFSymbol.mm +4 -12
  147. package/vendor/node_modules/@legendapp/spark-ui/macos/sheet/RNSparkSheet.h +9 -0
  148. package/vendor/node_modules/@legendapp/spark-ui/macos/sheet/RNSparkSheet.mm +109 -0
  149. package/vendor/node_modules/@legendapp/spark-ui/macos/sidebar/RNSidebar.mm +418 -102
  150. package/vendor/node_modules/@legendapp/spark-ui/macos/table/RNSparkTable.h +9 -0
  151. package/vendor/node_modules/@legendapp/spark-ui/macos/table/RNSparkTable.mm +179 -0
  152. package/vendor/node_modules/@legendapp/spark-ui/package.json +9 -8
  153. package/vendor/node_modules/@legendapp/spark-ui/src/SparkButtonNativeComponent.ts +10 -2
  154. package/vendor/node_modules/@legendapp/spark-ui/src/SparkTextInputNativeComponent.ts +2 -0
  155. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SidebarSplitViewNativeComponent.ts +9 -0
  156. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SplitView.tsx +99 -0
  157. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SplitViewNativeComponent.ts +29 -0
  158. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/index.tsx +34 -17
  159. package/vendor/node_modules/@legendapp/spark-ui/src/availability.ts +5 -4
  160. package/vendor/node_modules/@legendapp/spark-ui/src/checkbox-unavailable.tsx +20 -0
  161. package/vendor/node_modules/@legendapp/spark-ui/src/control.ts +24 -3
  162. package/vendor/node_modules/@legendapp/spark-ui/src/desktop.tsx +63 -13
  163. package/vendor/node_modules/@legendapp/spark-ui/src/index.android.tsx +12 -7
  164. package/vendor/node_modules/@legendapp/spark-ui/src/index.ios.tsx +12 -7
  165. package/vendor/node_modules/@legendapp/spark-ui/src/index.web.tsx +35 -13
  166. package/vendor/node_modules/@legendapp/spark-ui/src/mobile-input.tsx +2 -2
  167. package/vendor/node_modules/@legendapp/spark-ui/src/native-select/NativeSegmentedControlNativeComponent.ts +3 -1
  168. package/vendor/node_modules/@legendapp/spark-ui/src/popover/PopoverNativeComponent.ts +20 -0
  169. package/vendor/node_modules/@legendapp/spark-ui/src/popover/index.tsx +45 -0
  170. package/vendor/node_modules/@legendapp/spark-ui/src/progress/ProgressIndicatorNativeComponent.ts +13 -0
  171. package/vendor/node_modules/@legendapp/spark-ui/src/progress/index.tsx +32 -0
  172. package/vendor/node_modules/@legendapp/spark-ui/src/radio-group/RadioGroupNativeComponent.ts +17 -0
  173. package/vendor/node_modules/@legendapp/spark-ui/src/sheet/SheetNativeComponent.ts +15 -0
  174. package/vendor/node_modules/@legendapp/spark-ui/src/sheet/index.tsx +38 -0
  175. package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/SidebarItemNativeComponent.ts +9 -1
  176. package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/SidebarNativeComponent.ts +17 -2
  177. package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/index.tsx +106 -22
  178. package/vendor/node_modules/@legendapp/spark-ui/src/table/TableNativeComponent.ts +22 -0
  179. package/vendor/node_modules/@legendapp/spark-ui/src/table/index.tsx +118 -0
  180. package/vendor/node_modules/@legendapp/spark-ui/src/types.ts +39 -6
  181. package/vendor/node_modules/@legendapp/spark-ui/uniwind.ts +3 -1
  182. package/vendor/node_modules/@legendapp/spark-ui/uniwind.web.ts +2 -1
  183. package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/SparkUI.h +46 -15
  184. package/vendor/node_modules/@legendapp/spark-updates/package.json +3 -9
  185. package/vendor/node_modules/@legendapp/spark-webview/package.json +2 -2
  186. package/vendor/node_modules/@legendapp/spark-window-options/package.json +1 -1
@@ -0,0 +1,216 @@
1
+ #import "RNSparkPaneSplitView.h"
2
+ #include <algorithm>
3
+ #include <limits>
4
+ #include <unordered_map>
5
+
6
+ namespace {
7
+
8
+ struct SizeLimits {
9
+ CGFloat min;
10
+ CGFloat max;
11
+ };
12
+
13
+ CGFloat extent(NSRect frame, BOOL horizontal)
14
+ {
15
+ return horizontal ? NSWidth(frame) : NSHeight(frame);
16
+ }
17
+
18
+ CGFloat end(NSRect frame, BOOL horizontal)
19
+ {
20
+ return horizontal ? NSMaxX(frame) : NSMaxY(frame);
21
+ }
22
+
23
+ std::vector<SizeLimits> limitsFor(const std::vector<RNSparkSplitPaneSizing> &panes, CGFloat available)
24
+ {
25
+ std::vector<SizeLimits> limits;
26
+ CGFloat minTotal = 0;
27
+ CGFloat maxTotal = 0;
28
+ for (const auto &pane : panes) {
29
+ CGFloat max = pane.maxSize >= 0 ? pane.maxSize : std::numeric_limits<CGFloat>::infinity();
30
+ limits.push_back({pane.minSize, max});
31
+ minTotal += pane.minSize;
32
+ maxTotal += max;
33
+ }
34
+ if (minTotal > available) {
35
+ // A window can be smaller than the sum of the minima. Compress them proportionally until it grows again.
36
+ CGFloat largestMin = std::ranges::max(limits, {}, &SizeLimits::min).min;
37
+ CGFloat scaledTotal = 0;
38
+ for (auto &limit : limits) scaledTotal += limit.min / largestMin;
39
+ for (auto &limit : limits) limit.min = (limit.min / largestMin) * (available / scaledTotal);
40
+ } else if (!limits.empty() && maxTotal < available) {
41
+ limits.back().max += available - maxTotal;
42
+ }
43
+ return limits;
44
+ }
45
+
46
+ std::vector<CGFloat> fitSizes(const std::vector<CGFloat> &preferences, const std::vector<SizeLimits> &limits, CGFloat available)
47
+ {
48
+ std::vector<CGFloat> sizes;
49
+ CGFloat remainder = available;
50
+ size_t unspecified = 0;
51
+ for (size_t i = 0; i < preferences.size(); ++i) {
52
+ CGFloat preferred = preferences[i];
53
+ if (preferred < 0) ++unspecified;
54
+ CGFloat size = std::clamp(preferred, limits[i].min, std::min(limits[i].max, available));
55
+ sizes.push_back(size);
56
+ remainder -= size;
57
+ }
58
+ for (size_t i = 0; i < sizes.size(); ++i) {
59
+ if (preferences[i] >= 0) continue;
60
+ CGFloat growth = std::clamp(remainder / unspecified--, CGFloat{0}, limits[i].max - sizes[i]);
61
+ sizes[i] += growth;
62
+ remainder -= growth;
63
+ }
64
+ // The last pane absorbs remaining space first, then each preceding pane up to its bounds.
65
+ for (size_t i = sizes.size(); i > 0; --i) {
66
+ size_t index = i - 1;
67
+ CGFloat change = std::clamp(remainder, limits[index].min - sizes[index], limits[index].max - sizes[index]);
68
+ sizes[index] += change;
69
+ remainder -= change;
70
+ }
71
+ return sizes;
72
+ }
73
+
74
+ }
75
+
76
+ @interface RNSparkPaneSplitView () <NSSplitViewDelegate>
77
+ @end
78
+
79
+ @implementation RNSparkPaneSplitView {
80
+ std::vector<RNSparkSplitPaneSizing> _panes;
81
+ std::unordered_map<std::string, CGFloat> _preferredSizes;
82
+ std::vector<SizeLimits> _limits;
83
+ BOOL _applyingFrames;
84
+ BOOL _trackingDivider;
85
+ }
86
+
87
+ - (instancetype)initWithFrame:(NSRect)frame
88
+ {
89
+ if (self = [super initWithFrame:frame]) {
90
+ self.delegate = self;
91
+ self.arrangesAllSubviews = NO;
92
+ self.userInterfaceLayoutDirection = NSUserInterfaceLayoutDirectionLeftToRight;
93
+ }
94
+ return self;
95
+ }
96
+
97
+ - (BOOL)isFlipped { return YES; }
98
+
99
+ - (CGFloat)dividerThickness
100
+ {
101
+ size_t count = self.arrangedSubviews.count;
102
+ return count > 1 ? MIN(super.dividerThickness, extent(self.bounds, self.vertical) / (count - 1)) : super.dividerThickness;
103
+ }
104
+
105
+ - (NSColor *)dividerColor
106
+ {
107
+ return self.dividerStyle == NSSplitViewDividerStyleThin ? NSColor.separatorColor : super.dividerColor;
108
+ }
109
+
110
+ - (void)configurePanes:(const std::vector<RNSparkSplitPaneSizing> &)panes
111
+ horizontal:(BOOL)horizontal
112
+ dividerStyle:(NSSplitViewDividerStyle)style
113
+ {
114
+ _applyingFrames = YES;
115
+ if (horizontal != self.vertical) {
116
+ _preferredSizes.clear();
117
+ } else {
118
+ std::unordered_map<std::string, CGFloat> retained;
119
+ for (const auto &pane : panes) {
120
+ if (auto existing = _preferredSizes.find(pane.id); existing != _preferredSizes.end()) {
121
+ retained.emplace(pane.id, existing->second);
122
+ }
123
+ }
124
+ _preferredSizes.swap(retained);
125
+ }
126
+ _panes = panes;
127
+ self.vertical = horizontal;
128
+ self.dividerStyle = style;
129
+ _applyingFrames = NO;
130
+ [self adjustSubviews];
131
+ }
132
+
133
+ - (void)adjustSubviews
134
+ {
135
+ NSArray<NSView *> *views = self.arrangedSubviews;
136
+ if (_applyingFrames || views.count != _panes.size()) return;
137
+ _applyingFrames = YES;
138
+
139
+ NSRect bounds = self.bounds;
140
+ BOOL horizontal = self.vertical;
141
+ CGFloat divider = self.dividerThickness;
142
+ CGFloat available = MAX(0, extent(bounds, horizontal) - divider * (views.count ? views.count - 1 : 0));
143
+ _limits = limitsFor(_panes, available);
144
+ std::vector<CGFloat> preferences;
145
+ for (const auto &pane : _panes) {
146
+ auto existing = _preferredSizes.find(pane.id);
147
+ preferences.push_back(existing != _preferredSizes.end() ? existing->second : pane.initialSize);
148
+ }
149
+ auto sizes = fitSizes(preferences, _limits, available);
150
+ CGFloat origin = 0;
151
+ for (NSUInteger i = 0; i < views.count; ++i) {
152
+ CGFloat size = sizes[i];
153
+ views[i].frame = horizontal ? NSMakeRect(origin, 0, size, NSHeight(bounds)) : NSMakeRect(0, origin, NSWidth(bounds), size);
154
+ _preferredSizes.try_emplace(_panes[i].id, preferences[i]);
155
+ origin += size + divider;
156
+ }
157
+ _applyingFrames = NO;
158
+ [self.window invalidateCursorRectsForView:self];
159
+ [self setNeedsDisplay:YES];
160
+ if (self.onLayout) self.onLayout();
161
+ }
162
+
163
+ - (void)splitView:(NSSplitView *)splitView resizeSubviewsWithOldSize:(NSSize)oldSize
164
+ {
165
+ [self adjustSubviews];
166
+ }
167
+
168
+ - (CGFloat)splitView:(NSSplitView *)splitView constrainMinCoordinate:(CGFloat)minimum ofSubviewAt:(NSInteger)index
169
+ {
170
+ NSArray<NSView *> *views = self.arrangedSubviews;
171
+ if (index < 0 || index + 1 >= (NSInteger)_limits.size() || views.count != _limits.size()) return minimum;
172
+ CGFloat adjacentEnd = end(views[index + 1].frame, self.vertical);
173
+ return MAX(minimum + _limits[index].min, adjacentEnd - self.dividerThickness - _limits[index + 1].max);
174
+ }
175
+
176
+ - (CGFloat)splitView:(NSSplitView *)splitView constrainMaxCoordinate:(CGFloat)maximum ofSubviewAt:(NSInteger)index
177
+ {
178
+ NSArray<NSView *> *views = self.arrangedSubviews;
179
+ if (index < 0 || index + 1 >= (NSInteger)_limits.size() || views.count != _limits.size()) return maximum;
180
+ CGFloat leadingOrigin = end(views[index].frame, self.vertical) - extent(views[index].frame, self.vertical);
181
+ return MIN(maximum - _limits[index + 1].min, leadingOrigin + _limits[index].max);
182
+ }
183
+
184
+ - (void)splitViewDidResizeSubviews:(NSNotification *)notification
185
+ {
186
+ NSArray<NSView *> *views = self.arrangedSubviews;
187
+ if (_applyingFrames || !_trackingDivider || views.count != _panes.size()) return;
188
+ for (NSUInteger i = 0; i < views.count; ++i) {
189
+ _preferredSizes[_panes[i].id] = extent(views[i].frame, self.vertical);
190
+ }
191
+ if (self.onLayout) self.onLayout();
192
+ }
193
+
194
+ - (void)setPosition:(CGFloat)position ofDividerAtIndex:(NSInteger)index
195
+ {
196
+ BOOL tracking = _trackingDivider;
197
+ _trackingDivider = YES;
198
+ [super setPosition:position ofDividerAtIndex:index];
199
+ _trackingDivider = tracking;
200
+ }
201
+
202
+ - (void)mouseDown:(NSEvent *)event
203
+ {
204
+ _trackingDivider = YES;
205
+ [super mouseDown:event];
206
+ _trackingDivider = NO;
207
+ }
208
+
209
+ - (NSView *)hitTest:(NSPoint)point
210
+ {
211
+ if (_trackingDivider) {
212
+ return NSPointInRect([self convertPoint:point fromView:self.superview], self.bounds) ? self : nil;
213
+ }
214
+ return [super hitTest:point];
215
+ }
216
+ @end
@@ -0,0 +1,4 @@
1
+ #import <React/RCTViewComponentView.h>
2
+
3
+ @interface RNSparkSplitViewComponent : RCTViewComponentView
4
+ @end
@@ -0,0 +1,212 @@
1
+ #import "RNSparkSplitViewComponent.h"
2
+ #import "RNSparkLayoutDirection.h"
3
+ #import "RNSparkPaneSplitView.h"
4
+ #import "RNSparkSplitViewUpdates.h"
5
+
6
+ #import <react/renderer/components/RNSparkUISpec/ComponentDescriptors.h>
7
+ #import <react/renderer/components/RNSparkUISpec/EventEmitters.h>
8
+ #import <react/renderer/components/RNSparkUISpec/Props.h>
9
+ #import <react/renderer/components/RNSparkUISpec/RCTComponentViewHelpers.h>
10
+ #import <QuartzCore/QuartzCore.h>
11
+
12
+ using namespace facebook::react;
13
+
14
+ @interface RNSparkSplitPaneHost : NSView
15
+ @end
16
+
17
+ @implementation RNSparkSplitPaneHost
18
+ - (BOOL)isFlipped { return YES; }
19
+
20
+ - (void)didAddSubview:(NSView *)subview
21
+ {
22
+ [super didAddSubview:subview];
23
+ subview.postsFrameChangedNotifications = YES;
24
+ [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(childFrameChanged:)
25
+ name:NSViewFrameDidChangeNotification object:subview];
26
+ [self setBoundsOrigin:subview.frame.origin];
27
+ }
28
+
29
+ - (void)willRemoveSubview:(NSView *)subview
30
+ {
31
+ [NSNotificationCenter.defaultCenter removeObserver:self name:NSViewFrameDidChangeNotification object:subview];
32
+ [super willRemoveSubview:subview];
33
+ }
34
+
35
+ // Fabric measures the child in split-view coordinates. Cancel its origin inside this native host.
36
+ - (void)childFrameChanged:(NSNotification *)notification
37
+ {
38
+ [self setBoundsOrigin:((NSView *)notification.object).frame.origin];
39
+ }
40
+ @end
41
+
42
+ @interface RNSparkSplitViewComponent () <RCTSparkSplitViewViewProtocol>
43
+ @end
44
+
45
+ @implementation RNSparkSplitViewComponent {
46
+ RNSparkPaneSplitView *_splitView;
47
+ NSMutableArray<RNSparkSplitPaneHost *> *_hosts;
48
+ std::shared_ptr<const SparkSplitViewProps> _appliedProps;
49
+ NSArray<NSValue *> *_publishedFrames;
50
+ BOOL _rightToLeft;
51
+ BOOL _updateScheduled;
52
+ BOOL _applyingConfiguration;
53
+ }
54
+
55
+ - (instancetype)initWithFrame:(CGRect)frame
56
+ {
57
+ if (self = [super initWithFrame:frame]) {
58
+ _props = std::make_shared<const SparkSplitViewProps>();
59
+ _hosts = [NSMutableArray new];
60
+ _splitView = [[RNSparkPaneSplitView alloc] initWithFrame:self.bounds];
61
+ _splitView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
62
+ __weak RNSparkSplitViewComponent *weakSelf = self;
63
+ _splitView.onLayout = ^{ [weakSelf publishLayout]; };
64
+ [self addSubview:_splitView];
65
+ }
66
+ return self;
67
+ }
68
+
69
+ - (BOOL)isFlipped { return YES; }
70
+
71
+ - (void)publishLayout
72
+ {
73
+ if (_applyingConfiguration || !_appliedProps || !_eventEmitter || NSIsEmptyRect(_splitView.bounds)) return;
74
+ NSArray<NSView *> *panes = _splitView.arrangedSubviews;
75
+ NSMutableArray<NSValue *> *frames = [NSMutableArray arrayWithCapacity:panes.count];
76
+ for (NSView *pane in panes) [frames addObject:[NSValue valueWithRect:pane.frame]];
77
+ if ([_publishedFrames isEqualToArray:frames]) return;
78
+ _publishedFrames = frames;
79
+
80
+ SparkSplitViewEventEmitter::OnSplitViewLayout event{
81
+ .horizontal = _appliedProps->horizontal,
82
+ .rightToLeft = static_cast<bool>(_rightToLeft),
83
+ };
84
+ for (NSUInteger i = 0; i < frames.count; ++i) {
85
+ NSRect frame = frames[i].rectValue;
86
+ event.panes.push_back({
87
+ .id = _appliedProps->panes[i].id,
88
+ .x = NSMinX(frame),
89
+ .y = NSMinY(frame),
90
+ .width = NSWidth(frame),
91
+ .height = NSHeight(frame),
92
+ });
93
+ }
94
+ std::static_pointer_cast<const SparkSplitViewEventEmitter>(_eventEmitter)->onSplitViewLayout(std::move(event));
95
+ }
96
+
97
+ - (void)applyConfiguration
98
+ {
99
+ auto props = std::static_pointer_cast<const SparkSplitViewProps>(_props);
100
+ if (props->panes.size() != _hosts.count) return;
101
+
102
+ BOOL changed = !_appliedProps || props->horizontal != _appliedProps->horizontal
103
+ || props->dividerStyle != _appliedProps->dividerStyle || props->panes.size() != _appliedProps->panes.size();
104
+ if (!changed) {
105
+ for (size_t i = 0; i < props->panes.size(); ++i) {
106
+ const auto &next = props->panes[i];
107
+ const auto &current = _appliedProps->panes[i];
108
+ if (next.id != current.id || next.minSize != current.minSize || next.maxSize != current.maxSize) {
109
+ changed = YES;
110
+ break;
111
+ }
112
+ }
113
+ }
114
+ _appliedProps = props;
115
+ if (!changed && [_splitView.arrangedSubviews isEqualToArray:_hosts]) {
116
+ [self publishLayout];
117
+ return;
118
+ }
119
+
120
+ _publishedFrames = nil;
121
+ _applyingConfiguration = YES;
122
+ for (NSView *arranged in _splitView.arrangedSubviews) {
123
+ if (![_hosts containsObject:arranged]) [arranged removeFromSuperview];
124
+ }
125
+ for (NSUInteger index = 0; index < _hosts.count; ++index) {
126
+ NSArray<NSView *> *arranged = _splitView.arrangedSubviews;
127
+ if (index >= arranged.count || arranged[index] != _hosts[index]) {
128
+ [_splitView insertArrangedSubview:_hosts[index] atIndex:index];
129
+ }
130
+ }
131
+ std::vector<RNSparkSplitPaneSizing> panes;
132
+ for (const auto &pane : props->panes) panes.push_back({pane.id, pane.initialSize, pane.minSize, pane.maxSize});
133
+ NSSplitViewDividerStyle style = NSSplitViewDividerStyleThin;
134
+ if (props->dividerStyle == "thick") style = NSSplitViewDividerStyleThick;
135
+ if (props->dividerStyle == "paneSplitter") style = NSSplitViewDividerStylePaneSplitter;
136
+ _applyingConfiguration = NO;
137
+ [_splitView configurePanes:panes horizontal:props->horizontal dividerStyle:style];
138
+ }
139
+
140
+ - (void)scheduleConfiguration
141
+ {
142
+ if (_updateScheduled) return;
143
+ _updateScheduled = YES;
144
+ __weak RNSparkSplitViewComponent *weakSelf = self;
145
+ RNSparkScheduleSplitViewUpdate(^{ [weakSelf flushConfiguration]; });
146
+ }
147
+
148
+ - (void)flushConfiguration
149
+ {
150
+ _updateScheduled = NO;
151
+ [self applyConfiguration];
152
+ }
153
+
154
+ - (void)mountChildComponentView:(RCTUIView<RCTComponentViewProtocol> *)child index:(NSInteger)index
155
+ {
156
+ RNSparkSplitPaneHost *host = [RNSparkSplitPaneHost new];
157
+ host.wantsLayer = YES;
158
+ host.layer.masksToBounds = YES;
159
+ [host addSubview:child];
160
+ [_hosts insertObject:host atIndex:index];
161
+ [self scheduleConfiguration];
162
+ }
163
+
164
+ - (void)unmountChildComponentView:(RCTUIView<RCTComponentViewProtocol> *)child index:(NSInteger)index
165
+ {
166
+ [child removeFromSuperview];
167
+ [_hosts removeObjectAtIndex:index];
168
+ [self scheduleConfiguration];
169
+ }
170
+
171
+ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps
172
+ {
173
+ [super updateProps:props oldProps:oldProps];
174
+ [self scheduleConfiguration];
175
+ }
176
+
177
+ - (void)updateEventEmitter:(const EventEmitter::Shared &)eventEmitter
178
+ {
179
+ if (!_eventEmitter) _publishedFrames = nil;
180
+ [super updateEventEmitter:eventEmitter];
181
+ [self scheduleConfiguration];
182
+ }
183
+
184
+ - (void)updateLayoutMetrics:(const LayoutMetrics &)layoutMetrics oldLayoutMetrics:(const LayoutMetrics &)oldLayoutMetrics
185
+ {
186
+ [super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
187
+ BOOL rightToLeft = RNSparkLayoutDirection(layoutMetrics) == NSUserInterfaceLayoutDirectionRightToLeft;
188
+ if (_rightToLeft != rightToLeft) {
189
+ _rightToLeft = rightToLeft;
190
+ _publishedFrames = nil;
191
+ }
192
+ _splitView.frame = self.bounds;
193
+ [self publishLayout];
194
+ }
195
+
196
+ - (void)prepareForRecycle
197
+ {
198
+ [super prepareForRecycle];
199
+ for (NSView *host in _splitView.arrangedSubviews) [host removeFromSuperview];
200
+ [_hosts removeAllObjects];
201
+ _publishedFrames = nil;
202
+ _appliedProps.reset();
203
+ _props = std::make_shared<const SparkSplitViewProps>();
204
+ _rightToLeft = NO;
205
+ [_splitView configurePanes:{} horizontal:YES dividerStyle:NSSplitViewDividerStyleThin];
206
+ }
207
+
208
+ + (ComponentDescriptorProvider)componentDescriptorProvider
209
+ {
210
+ return concreteComponentDescriptorProvider<SparkSplitViewComponentDescriptor>();
211
+ }
212
+ @end
@@ -0,0 +1,6 @@
1
+ #import <AppKit/AppKit.h>
2
+
3
+ static inline void RNSparkScheduleSplitViewUpdate(dispatch_block_t update)
4
+ {
5
+ [NSRunLoop.mainRunLoop performInModes:@[NSDefaultRunLoopMode, NSModalPanelRunLoopMode] block:update];
6
+ }
@@ -17,6 +17,7 @@ using namespace facebook::react;
17
17
  NSArray<NSString *> *_values;
18
18
  NSString *_segmentsJson;
19
19
  NSString *_value;
20
+ NSArray<NSString *> *_labels;
20
21
  BOOL _isUpdatingSelection;
21
22
  #else
22
23
  UIView *_segmentedControl;
@@ -29,11 +30,14 @@ using namespace facebook::react;
29
30
  _props = std::make_shared<const NativeSegmentedControlProps>();
30
31
  #if TARGET_OS_OSX
31
32
  _values = @[];
33
+ _labels = @[];
32
34
  _segmentsJson = @"";
33
35
  _value = @"";
34
36
  _segmentedControl = [[NSSegmentedControl alloc] initWithFrame:NSZeroRect];
35
37
  _segmentedControl.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
36
38
  _segmentedControl.controlSize = NSControlSizeRegular;
39
+ _segmentedControl.font = [NSFont systemFontOfSize:NSFont.systemFontSize];
40
+ _segmentedControl.segmentDistribution = NSSegmentDistributionFit;
37
41
  _segmentedControl.segmentStyle = NSSegmentStyleAutomatic;
38
42
  _segmentedControl.trackingMode = NSSegmentSwitchTrackingSelectOne;
39
43
  _segmentedControl.target = self;
@@ -85,22 +89,22 @@ using namespace facebook::react;
85
89
  }
86
90
 
87
91
  _values = values;
92
+ _labels = labels;
88
93
  _segmentedControl.segmentCount = labels.count;
94
+ for (NSInteger index = 0; index < labels.count; index += 1) [_segmentedControl setLabel:labels[index] forSegment:index];
95
+ [self sizeSegments];
96
+ }
89
97
 
90
- CGFloat totalWidth = 0;
91
- NSFont *font = _segmentedControl.font ?: [NSFont systemFontOfSize:[NSFont systemFontSize]];
92
- for (NSInteger index = 0; index < labels.count; index += 1) {
93
- NSString *label = labels[index];
94
- [_segmentedControl setLabel:label forSegment:index];
95
- CGFloat segmentWidth = MAX(64, [label sizeWithAttributes:@{NSFontAttributeName: font}].width + 28);
96
- [_segmentedControl setWidth:segmentWidth forSegment:index];
97
- totalWidth += segmentWidth;
98
+ // Fit gives each segment its label's width; fill shares the control's whole width equally.
99
+ - (void)sizeSegments
100
+ {
101
+ BOOL fill = _segmentedControl.segmentDistribution == NSSegmentDistributionFillEqually;
102
+ BOOL small = _segmentedControl.controlSize == NSControlSizeSmall;
103
+ NSFont *font = _segmentedControl.font;
104
+ for (NSInteger index = 0; index < _labels.count; index += 1) {
105
+ CGFloat fitWidth = MAX(small ? 48 : 64, [_labels[index] sizeWithAttributes:@{NSFontAttributeName: font}].width + (small ? 20 : 28));
106
+ [_segmentedControl setWidth:fill ? 0 : fitWidth forSegment:index];
98
107
  }
99
-
100
- CGRect frame = _segmentedControl.frame;
101
- frame.size.width = totalWidth;
102
- frame.size.height = MAX(28, _segmentedControl.fittingSize.height);
103
- _segmentedControl.frame = frame;
104
108
  }
105
109
 
106
110
  - (void)selectValue:(NSString *)value
@@ -153,6 +157,14 @@ using namespace facebook::react;
153
157
  [self selectValue:_value];
154
158
  }
155
159
 
160
+ NSControlSize controlSize = newProps.controlSize == NativeSegmentedControlControlSize::Small ? NSControlSizeSmall : NSControlSizeRegular;
161
+ NSSegmentDistribution distribution = newProps.distribution == NativeSegmentedControlDistribution::Fill ? NSSegmentDistributionFillEqually : NSSegmentDistributionFit;
162
+ if (controlSize != _segmentedControl.controlSize || distribution != _segmentedControl.segmentDistribution) {
163
+ _segmentedControl.controlSize = controlSize;
164
+ _segmentedControl.font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:controlSize]];
165
+ _segmentedControl.segmentDistribution = distribution;
166
+ [self sizeSegments];
167
+ }
156
168
  _segmentedControl.enabled = newProps.enabled;
157
169
  _segmentedControl.accessibilityLabel = [NSString stringWithUTF8String:newProps.accessibilityLabel.c_str()];
158
170
  _segmentedControl.accessibilityIdentifier = [NSString stringWithUTF8String:newProps.testId.c_str()];
@@ -165,6 +177,7 @@ using namespace facebook::react;
165
177
  [super prepareForRecycle];
166
178
  #if TARGET_OS_OSX
167
179
  _values = @[];
180
+ _labels = @[];
168
181
  _segmentsJson = @"";
169
182
  _value = @"";
170
183
  _isUpdatingSelection = NO;
@@ -0,0 +1,9 @@
1
+ #import <React/RCTViewComponentView.h>
2
+ #import <AppKit/AppKit.h>
3
+
4
+ NS_ASSUME_NONNULL_BEGIN
5
+
6
+ @interface RNSparkPopover : RCTViewComponentView
7
+ @end
8
+
9
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,126 @@
1
+ #import "RNSparkPopover.h"
2
+ #import "RNSparkLayoutDirection.h"
3
+ #import <React/RCTSurfaceTouchHandler.h>
4
+ #import <react/renderer/components/RNSparkUISpec/ComponentDescriptors.h>
5
+ #import <react/renderer/components/RNSparkUISpec/EventEmitters.h>
6
+ #import <react/renderer/components/RNSparkUISpec/Props.h>
7
+ using namespace facebook::react;
8
+
9
+ @interface RNSparkPopoverContentView : NSView
10
+ @end
11
+ @implementation RNSparkPopoverContentView
12
+ - (BOOL)isFlipped { return YES; }
13
+ @end
14
+
15
+ // The first React child (the anchor) stays in this view; the second (the content) moves into an
16
+ // NSPopover shown relative to this view. The content keeps its own touch handler, since the
17
+ // surface's handler only sees its own window.
18
+ @interface RNSparkPopover () <NSPopoverDelegate>
19
+ @end
20
+ @implementation RNSparkPopover {
21
+ NSPopover *_popover;
22
+ RNSparkPopoverContentView *_contentView;
23
+ RCTSurfaceTouchHandler *_touchHandler;
24
+ NSView *_content;
25
+ BOOL _visible;
26
+ BOOL _closingFromProps;
27
+ NSSize _contentSize;
28
+ NSRect _anchorRect;
29
+ SparkPopoverEdge _edge;
30
+ }
31
+ - (instancetype)init {
32
+ if (self = [super init]) {
33
+ _props = std::make_shared<const SparkPopoverProps>();
34
+ _contentView = [[RNSparkPopoverContentView alloc] initWithFrame:NSZeroRect];
35
+ NSViewController *controller = [NSViewController new];
36
+ controller.view = _contentView;
37
+ _popover = [NSPopover new];
38
+ _popover.contentViewController = controller;
39
+ _popover.delegate = self;
40
+ _touchHandler = [RCTSurfaceTouchHandler new];
41
+ [_touchHandler attachToView:_contentView];
42
+ }
43
+ return self;
44
+ }
45
+ - (BOOL)isFlipped { return YES; }
46
+ - (void)mountChildComponentView:(RCTUIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index {
47
+ if (index == 1) {
48
+ _content = childComponentView;
49
+ [_contentView addSubview:childComponentView];
50
+ return;
51
+ }
52
+ [super mountChildComponentView:childComponentView index:index];
53
+ }
54
+ - (void)unmountChildComponentView:(RCTUIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index {
55
+ if (childComponentView == _content) {
56
+ [childComponentView removeFromSuperview];
57
+ _content = nil;
58
+ return;
59
+ }
60
+ [super unmountChildComponentView:childComponentView index:index];
61
+ }
62
+ - (NSRect)positioningRect {
63
+ return _anchorRect.size.width > 0 || _anchorRect.size.height > 0 ? _anchorRect : self.bounds;
64
+ }
65
+ - (NSRectEdge)preferredEdge {
66
+ BOOL rtl = self.userInterfaceLayoutDirection == NSUserInterfaceLayoutDirectionRightToLeft;
67
+ switch (_edge) {
68
+ case SparkPopoverEdge::Top: return NSRectEdgeMinY;
69
+ case SparkPopoverEdge::Leading: return rtl ? NSRectEdgeMaxX : NSRectEdgeMinX;
70
+ case SparkPopoverEdge::Trailing: return rtl ? NSRectEdgeMinX : NSRectEdgeMaxX;
71
+ default: return NSRectEdgeMaxY;
72
+ }
73
+ }
74
+ - (void)updatePresentation {
75
+ BOOL show = _visible && _contentSize.width > 0 && _contentSize.height > 0 && self.window != nil;
76
+ if (!show) {
77
+ if (_popover.shown && !_closingFromProps) { _closingFromProps = YES; [_popover performClose:nil]; }
78
+ return;
79
+ }
80
+ if (_closingFromProps) return; // popoverDidClose: shows it again once the close animation ends
81
+ if (!NSEqualSizes(_popover.contentSize, _contentSize)) _popover.contentSize = _contentSize;
82
+ if (_popover.shown) {
83
+ if (!NSEqualRects(_popover.positioningRect, self.positioningRect)) _popover.positioningRect = self.positioningRect;
84
+ return;
85
+ }
86
+ [_popover showRelativeToRect:self.positioningRect ofView:self preferredEdge:self.preferredEdge];
87
+ }
88
+ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps {
89
+ const auto &next = *std::static_pointer_cast<const SparkPopoverProps>(props);
90
+ _visible = next.visible;
91
+ _contentSize = NSMakeSize(MAX(0, next.contentWidth), MAX(0, next.contentHeight));
92
+ _anchorRect = NSMakeRect(next.anchorX, next.anchorY, MAX(0, next.anchorWidth), MAX(0, next.anchorHeight));
93
+ _edge = next.edge;
94
+ _popover.behavior = next.behavior == SparkPopoverBehavior::Semitransient ? NSPopoverBehaviorSemitransient
95
+ : next.behavior == SparkPopoverBehavior::ApplicationDefined ? NSPopoverBehaviorApplicationDefined : NSPopoverBehaviorTransient;
96
+ [super updateProps:props oldProps:oldProps];
97
+ [self updatePresentation];
98
+ }
99
+ - (void)updateLayoutMetrics:(const LayoutMetrics &)layoutMetrics oldLayoutMetrics:(const LayoutMetrics &)oldLayoutMetrics {
100
+ [super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
101
+ self.userInterfaceLayoutDirection = RNSparkLayoutDirection(layoutMetrics);
102
+ if (_popover.shown) _popover.positioningRect = self.positioningRect;
103
+ }
104
+ - (void)viewDidMoveToWindow {
105
+ [super viewDidMoveToWindow];
106
+ [self updatePresentation];
107
+ }
108
+ - (void)popoverDidClose:(NSNotification *)notification {
109
+ if (_closingFromProps) {
110
+ _closingFromProps = NO;
111
+ [self updatePresentation];
112
+ return;
113
+ }
114
+ if (!_visible) return;
115
+ auto emitter = std::static_pointer_cast<const SparkPopoverEventEmitter>(_eventEmitter);
116
+ if (emitter) emitter->onClose({});
117
+ }
118
+ - (void)prepareForRecycle {
119
+ _visible = NO;
120
+ [self updatePresentation];
121
+ _contentSize = NSZeroSize;
122
+ _anchorRect = NSZeroRect;
123
+ [super prepareForRecycle];
124
+ }
125
+ + (ComponentDescriptorProvider)componentDescriptorProvider { return concreteComponentDescriptorProvider<SparkPopoverComponentDescriptor>(); }
126
+ @end
@@ -0,0 +1,9 @@
1
+ #import <React/RCTViewComponentView.h>
2
+ #import <AppKit/AppKit.h>
3
+
4
+ NS_ASSUME_NONNULL_BEGIN
5
+
6
+ @interface RNSparkProgressIndicator : RCTViewComponentView
7
+ @end
8
+
9
+ NS_ASSUME_NONNULL_END