@legendapp/spark 0.0.3 → 0.0.5

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 (202) hide show
  1. package/init-template.cjs +7 -1
  2. package/package.json +11 -6
  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 +174 -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 +59 -0
  24. package/skills/spark/ui.md +83 -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 +157 -106
  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 +15 -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/package.js +4 -8
  53. package/vendor/node_modules/@legendapp/spark-cli/dist/patch.js +92 -0
  54. package/vendor/node_modules/@legendapp/spark-cli/dist/project-version.js +12 -4
  55. package/vendor/node_modules/@legendapp/spark-cli/dist/project.js +8 -1
  56. package/vendor/node_modules/@legendapp/spark-cli/dist/publish-directory.js +32 -0
  57. package/vendor/node_modules/@legendapp/spark-cli/dist/release-app.js +139 -0
  58. package/vendor/node_modules/@legendapp/spark-cli/dist/release.json +17 -17
  59. package/vendor/node_modules/@legendapp/spark-cli/dist/signing.js +61 -41
  60. package/vendor/node_modules/@legendapp/spark-cli/dist/upgrade.js +1 -1
  61. package/vendor/node_modules/@legendapp/spark-cli/dist/windows.js +3 -0
  62. package/vendor/node_modules/@legendapp/spark-cli/package.json +5 -4
  63. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/package.json +2 -2
  64. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/package.json +2 -2
  65. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/package.json +2 -2
  66. package/vendor/node_modules/@legendapp/spark-clipboard/macos/RNDesktopClipboard.mm +1 -1
  67. package/vendor/node_modules/@legendapp/spark-clipboard/package.json +3 -10
  68. package/vendor/node_modules/@legendapp/spark-clipboard/src/desktop.ts +1 -0
  69. package/vendor/node_modules/@legendapp/spark-codex/package.json +3 -7
  70. package/vendor/node_modules/@legendapp/spark-commands/package.json +5 -5
  71. package/vendor/node_modules/@legendapp/spark-context-menu/package.json +3 -10
  72. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.h +3 -1
  73. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.mm +51 -10
  74. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkStorage.h +4 -0
  75. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkStorage.mm +82 -0
  76. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkTestDriver.h +2 -0
  77. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkTestDriver.mm +1 -0
  78. package/vendor/node_modules/@legendapp/spark-desktop-app/package.json +2 -8
  79. package/vendor/node_modules/@legendapp/spark-desktop-config/app.plugin.cjs +1 -0
  80. package/vendor/node_modules/@legendapp/spark-desktop-config/config.cjs +6 -8
  81. package/vendor/node_modules/@legendapp/spark-desktop-config/identity.cjs +2 -0
  82. package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.cjs +300 -71
  83. package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.d.cts +7 -0
  84. package/vendor/node_modules/@legendapp/spark-desktop-config/package.json +3 -3
  85. package/vendor/node_modules/@legendapp/spark-desktop-config/patch-registry.cjs +318 -0
  86. package/vendor/node_modules/@legendapp/spark-desktop-config/patch-registry.d.cts +20 -0
  87. package/vendor/node_modules/@legendapp/spark-desktop-config/rpaths.cjs +20 -0
  88. package/vendor/node_modules/@legendapp/spark-desktop-config/rpaths.d.cts +1 -0
  89. package/vendor/node_modules/@legendapp/spark-desktop-config/validation.cjs +66 -9
  90. package/vendor/node_modules/@legendapp/spark-desktop-config/windows.plugin.cjs +1 -0
  91. package/vendor/node_modules/@legendapp/spark-desktop-host/AppDelegate.mm +17 -5
  92. package/vendor/node_modules/@legendapp/spark-desktop-host/package.json +2 -2
  93. package/vendor/node_modules/@legendapp/spark-desktop-links/package.json +3 -10
  94. package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/package.json +3 -10
  95. package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/RNDesktopWindows.mm +7 -2
  96. package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/RNWindowManager.mm +235 -240
  97. package/vendor/node_modules/@legendapp/spark-desktop-windows/package.json +4 -11
  98. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/api.ts +9 -3
  99. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/macos-adapter.ts +7 -0
  100. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/types.ts +32 -3
  101. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/validation.ts +28 -11
  102. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/createWindowsNavigator.tsx +15 -3
  103. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/primaryWindowLifecycle.ts +12 -3
  104. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/usePrimaryWindowLifecycle.ts +2 -1
  105. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/useWindowFocusEffect.ts +4 -1
  106. package/vendor/node_modules/@legendapp/spark-documents/package.json +7 -7
  107. package/vendor/node_modules/@legendapp/spark-drag-drop/macos/RNDesktopDragView.mm +77 -17
  108. package/vendor/node_modules/@legendapp/spark-drag-drop/package.json +3 -8
  109. package/vendor/node_modules/@legendapp/spark-drag-drop/src/DesktopDragViewNativeComponent.ts +1 -0
  110. package/vendor/node_modules/@legendapp/spark-drag-drop/src/contracts.ts +13 -4
  111. package/vendor/node_modules/@legendapp/spark-drag-drop/src/index.tsx +5 -3
  112. package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/SparkDragDrop.h +6 -1
  113. package/vendor/node_modules/@legendapp/spark-expo-compat/metro.cjs +44 -0
  114. package/vendor/node_modules/@legendapp/spark-expo-compat/package.json +20 -0
  115. package/vendor/node_modules/@legendapp/spark-expo-compat/src/clipboard.ts +40 -0
  116. package/vendor/node_modules/@legendapp/spark-expo-compat/src/document-picker.ts +52 -0
  117. package/vendor/node_modules/@legendapp/spark-file-dialog/package.json +3 -10
  118. package/vendor/node_modules/@legendapp/spark-file-dialog/src/options.ts +5 -2
  119. package/vendor/node_modules/@legendapp/spark-file-dialog/src/types.ts +3 -3
  120. package/vendor/node_modules/@legendapp/spark-file-system/macos/RNDesktopFileSystem.mm +1 -1
  121. package/vendor/node_modules/@legendapp/spark-file-system/package.json +3 -11
  122. package/vendor/node_modules/@legendapp/spark-global-shortcuts/package.json +3 -10
  123. package/vendor/node_modules/@legendapp/spark-html/package.json +2 -2
  124. package/vendor/node_modules/@legendapp/spark-markdown/package.json +2 -2
  125. package/vendor/node_modules/@legendapp/spark-message-dialog/package.json +3 -10
  126. package/vendor/node_modules/@legendapp/spark-message-dialog/src/index.ts +1 -0
  127. package/vendor/node_modules/@legendapp/spark-native-menu/package.json +3 -9
  128. package/vendor/node_modules/@legendapp/spark-native-menu/src/hooks.ts +4 -0
  129. package/vendor/node_modules/@legendapp/spark-notifications/package.json +3 -10
  130. package/vendor/node_modules/@legendapp/spark-processes/package.json +3 -10
  131. package/vendor/node_modules/@legendapp/spark-rich-text/package.json +2 -2
  132. package/vendor/node_modules/@legendapp/spark-secure-storage/package.json +3 -10
  133. package/vendor/node_modules/@legendapp/spark-settings/package.json +3 -3
  134. package/vendor/node_modules/@legendapp/spark-settings-ui/package.json +4 -4
  135. package/vendor/node_modules/@legendapp/spark-settings-ui/src/index.tsx +122 -334
  136. package/vendor/node_modules/@legendapp/spark-settings-ui/src/rows.tsx +183 -0
  137. package/vendor/node_modules/@legendapp/spark-sqlite/package.json +3 -3
  138. package/vendor/node_modules/@legendapp/spark-system/package.json +3 -10
  139. package/vendor/node_modules/@legendapp/spark-tray/package.json +3 -10
  140. package/vendor/node_modules/@legendapp/spark-tray/src/index.ts +2 -1
  141. package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkButton.mm +82 -14
  142. package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkTextInput.h +1 -1
  143. package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkTextInput.mm +94 -11
  144. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSidebarSplitViewComponent.mm +235 -18
  145. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkPaneSplitView.h +17 -0
  146. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkPaneSplitView.mm +216 -0
  147. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkSplitViewComponent.h +4 -0
  148. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkSplitViewComponent.mm +212 -0
  149. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkSplitViewUpdates.h +6 -0
  150. package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSegmentedControl.mm +28 -13
  151. package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSelect.mm +17 -1
  152. package/vendor/node_modules/@legendapp/spark-ui/macos/popover/RNSparkPopover.h +9 -0
  153. package/vendor/node_modules/@legendapp/spark-ui/macos/popover/RNSparkPopover.mm +126 -0
  154. package/vendor/node_modules/@legendapp/spark-ui/macos/progress/RNSparkProgressIndicator.h +9 -0
  155. package/vendor/node_modules/@legendapp/spark-ui/macos/progress/RNSparkProgressIndicator.mm +66 -0
  156. package/vendor/node_modules/@legendapp/spark-ui/macos/radio-group/RNSparkRadioGroup.h +9 -0
  157. package/vendor/node_modules/@legendapp/spark-ui/macos/radio-group/RNSparkRadioGroup.mm +118 -0
  158. package/vendor/node_modules/@legendapp/spark-ui/macos/sf-symbol/RNSFSymbol.mm +4 -12
  159. package/vendor/node_modules/@legendapp/spark-ui/macos/sheet/RNSparkSheet.h +9 -0
  160. package/vendor/node_modules/@legendapp/spark-ui/macos/sheet/RNSparkSheet.mm +109 -0
  161. package/vendor/node_modules/@legendapp/spark-ui/macos/sidebar/RNSidebar.mm +438 -102
  162. package/vendor/node_modules/@legendapp/spark-ui/macos/table/RNSparkTable.h +9 -0
  163. package/vendor/node_modules/@legendapp/spark-ui/macos/table/RNSparkTable.mm +179 -0
  164. package/vendor/node_modules/@legendapp/spark-ui/package.json +9 -8
  165. package/vendor/node_modules/@legendapp/spark-ui/src/SparkButtonNativeComponent.ts +10 -2
  166. package/vendor/node_modules/@legendapp/spark-ui/src/SparkTextInputNativeComponent.ts +2 -0
  167. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SidebarSplitViewNativeComponent.ts +9 -0
  168. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SplitView.tsx +99 -0
  169. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SplitViewNativeComponent.ts +29 -0
  170. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/index.tsx +34 -17
  171. package/vendor/node_modules/@legendapp/spark-ui/src/availability.ts +6 -4
  172. package/vendor/node_modules/@legendapp/spark-ui/src/checkbox-unavailable.tsx +20 -0
  173. package/vendor/node_modules/@legendapp/spark-ui/src/control.ts +24 -3
  174. package/vendor/node_modules/@legendapp/spark-ui/src/desktop.tsx +72 -20
  175. package/vendor/node_modules/@legendapp/spark-ui/src/index.android.tsx +18 -12
  176. package/vendor/node_modules/@legendapp/spark-ui/src/index.ios.tsx +21 -15
  177. package/vendor/node_modules/@legendapp/spark-ui/src/index.web.tsx +40 -16
  178. package/vendor/node_modules/@legendapp/spark-ui/src/mobile-input.tsx +2 -2
  179. package/vendor/node_modules/@legendapp/spark-ui/src/native-select/NativeSegmentedControlNativeComponent.ts +3 -1
  180. package/vendor/node_modules/@legendapp/spark-ui/src/native-select/NativeSelectNativeComponent.ts +1 -0
  181. package/vendor/node_modules/@legendapp/spark-ui/src/popover/PopoverNativeComponent.ts +20 -0
  182. package/vendor/node_modules/@legendapp/spark-ui/src/popover/index.tsx +45 -0
  183. package/vendor/node_modules/@legendapp/spark-ui/src/progress/ProgressIndicatorNativeComponent.ts +13 -0
  184. package/vendor/node_modules/@legendapp/spark-ui/src/progress/index.tsx +32 -0
  185. package/vendor/node_modules/@legendapp/spark-ui/src/radio-group/RadioGroupNativeComponent.ts +17 -0
  186. package/vendor/node_modules/@legendapp/spark-ui/src/select.ts +4 -0
  187. package/vendor/node_modules/@legendapp/spark-ui/src/sheet/SheetNativeComponent.ts +15 -0
  188. package/vendor/node_modules/@legendapp/spark-ui/src/sheet/index.tsx +38 -0
  189. package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/SidebarItemNativeComponent.ts +9 -1
  190. package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/SidebarNativeComponent.ts +17 -2
  191. package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/index.tsx +106 -22
  192. package/vendor/node_modules/@legendapp/spark-ui/src/switch.tsx +13 -0
  193. package/vendor/node_modules/@legendapp/spark-ui/src/table/TableNativeComponent.ts +22 -0
  194. package/vendor/node_modules/@legendapp/spark-ui/src/table/index.tsx +118 -0
  195. package/vendor/node_modules/@legendapp/spark-ui/src/types.ts +52 -7
  196. package/vendor/node_modules/@legendapp/spark-ui/uniwind.ts +3 -1
  197. package/vendor/node_modules/@legendapp/spark-ui/uniwind.web.ts +2 -1
  198. package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/SparkUI.h +46 -15
  199. package/vendor/node_modules/@legendapp/spark-updates/package.json +3 -9
  200. package/vendor/node_modules/@legendapp/spark-webview/package.json +2 -2
  201. package/vendor/node_modules/@legendapp/spark-window-options/package.json +1 -1
  202. /package/{settings-window.ts → ui-settings.ts} +0 -0
@@ -0,0 +1,9 @@
1
+ #import <React/RCTViewComponentView.h>
2
+ #import <AppKit/AppKit.h>
3
+
4
+ NS_ASSUME_NONNULL_BEGIN
5
+
6
+ @interface RNSparkTable : RCTViewComponentView
7
+ @end
8
+
9
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,179 @@
1
+ #import "RNSparkTable.h"
2
+ #import "RNSparkLayoutDirection.h"
3
+ #import <react/renderer/components/RNSparkUISpec/ComponentDescriptors.h>
4
+ #import <react/renderer/components/RNSparkUISpec/EventEmitters.h>
5
+ #import <react/renderer/components/RNSparkUISpec/Props.h>
6
+ using namespace facebook::react;
7
+
8
+ static NSUserInterfaceItemIdentifier const RNSparkTableCellIdentifier = @"RNSparkTableCell";
9
+
10
+ static id RNSparkTableJSON(const std::string &json, Class expected) {
11
+ NSData *data = [NSData dataWithBytes:json.data() length:json.size()];
12
+ id value = data.length ? [NSJSONSerialization JSONObjectWithData:data options:0 error:nil] : nil;
13
+ return [value isKindOfClass:expected] ? value : nil;
14
+ }
15
+
16
+ // An NSTableView with a header and text columns. AppKit asks only for the visible rows' cells and reuses them, so
17
+ // long tables stay cheap; the rows themselves arrive as one JSON array of { id, values }.
18
+ @interface RNSparkTable () <NSTableViewDataSource, NSTableViewDelegate>
19
+ @end
20
+ @implementation RNSparkTable {
21
+ NSScrollView *_scrollView;
22
+ NSTableView *_tableView;
23
+ NSArray<NSDictionary *> *_columns;
24
+ NSArray<NSDictionary *> *_rows;
25
+ NSDictionary<NSString *, NSNumber *> *_rowIndexes;
26
+ BOOL _applyingSelection;
27
+ }
28
+ - (instancetype)init {
29
+ if (self = [super init]) {
30
+ _props = std::make_shared<const SparkTableProps>();
31
+ _columns = @[];
32
+ _rows = @[];
33
+ _rowIndexes = @{};
34
+ _tableView = [[NSTableView alloc] initWithFrame:NSZeroRect];
35
+ _tableView.style = NSTableViewStyleFullWidth;
36
+ _tableView.columnAutoresizingStyle = NSTableViewUniformColumnAutoresizingStyle;
37
+ _tableView.allowsColumnReordering = NO;
38
+ _tableView.allowsColumnResizing = YES;
39
+ _tableView.allowsEmptySelection = YES;
40
+ _tableView.dataSource = self;
41
+ _tableView.delegate = self;
42
+ _tableView.target = self;
43
+ _tableView.doubleAction = @selector(rowDoubleClicked:);
44
+ _scrollView = [[NSScrollView alloc] initWithFrame:NSZeroRect];
45
+ _scrollView.documentView = _tableView;
46
+ _scrollView.hasVerticalScroller = YES;
47
+ _scrollView.hasHorizontalScroller = NO;
48
+ _scrollView.autohidesScrollers = YES;
49
+ _scrollView.drawsBackground = YES;
50
+ [self addSubview:_scrollView];
51
+ }
52
+ return self;
53
+ }
54
+ - (BOOL)isFlipped { return YES; }
55
+ - (void)layoutSubviews { [super layoutSubviews]; _scrollView.frame = self.bounds; }
56
+
57
+ - (void)applyColumns:(NSArray<NSDictionary *> *)columns {
58
+ _columns = columns;
59
+ for (NSTableColumn *column in [_tableView.tableColumns copy]) [_tableView removeTableColumn:column];
60
+ for (NSDictionary *config in columns) {
61
+ NSTableColumn *column = [[NSTableColumn alloc] initWithIdentifier:config[@"id"]];
62
+ column.title = config[@"title"] ?: @"";
63
+ column.headerToolTip = column.title;
64
+ column.minWidth = [config[@"minWidth"] isKindOfClass:NSNumber.class] ? [config[@"minWidth"] doubleValue] : 40;
65
+ column.maxWidth = [config[@"maxWidth"] isKindOfClass:NSNumber.class] ? [config[@"maxWidth"] doubleValue] : CGFLOAT_MAX;
66
+ // A column with a width keeps it as the table resizes; the others share the remaining width.
67
+ BOOL fixed = [config[@"width"] isKindOfClass:NSNumber.class];
68
+ if (fixed) column.width = [config[@"width"] doubleValue];
69
+ column.resizingMask = fixed ? NSTableColumnUserResizingMask : NSTableColumnUserResizingMask | NSTableColumnAutoresizingMask;
70
+ NSString *alignment = config[@"alignment"];
71
+ column.headerCell.alignment = [alignment isEqual:@"trailing"] ? NSTextAlignmentRight : [alignment isEqual:@"center"] ? NSTextAlignmentCenter : NSTextAlignmentNatural;
72
+ [_tableView addTableColumn:column];
73
+ }
74
+ }
75
+ - (void)applyRows:(NSArray<NSDictionary *> *)rows {
76
+ _rows = rows;
77
+ NSMutableDictionary *indexes = [NSMutableDictionary dictionaryWithCapacity:rows.count];
78
+ [rows enumerateObjectsUsingBlock:^(NSDictionary *row, NSUInteger index, BOOL *) { indexes[row[@"id"]] = @(index); }];
79
+ _rowIndexes = indexes;
80
+ _applyingSelection = YES;
81
+ [_tableView reloadData];
82
+ _applyingSelection = NO;
83
+ }
84
+ - (void)applySelection:(NSArray<NSString *> *)ids {
85
+ NSMutableIndexSet *indexes = [NSMutableIndexSet new];
86
+ for (NSString *rowId in ids) if (NSNumber *index = _rowIndexes[rowId]) [indexes addIndex:index.unsignedIntegerValue];
87
+ if ([indexes isEqualToIndexSet:_tableView.selectedRowIndexes]) return;
88
+ _applyingSelection = YES;
89
+ [_tableView selectRowIndexes:indexes byExtendingSelection:NO];
90
+ _applyingSelection = NO;
91
+ }
92
+
93
+ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps {
94
+ const auto &next = *std::static_pointer_cast<const SparkTableProps>(props);
95
+ const auto &previous = *std::static_pointer_cast<const SparkTableProps>(_props);
96
+ if (next.columnsJson != previous.columnsJson) [self applyColumns:RNSparkTableJSON(next.columnsJson, NSArray.class) ?: @[]];
97
+ if (next.rowsJson != previous.rowsJson || next.columnsJson != previous.columnsJson) [self applyRows:RNSparkTableJSON(next.rowsJson, NSArray.class) ?: @[]];
98
+ _tableView.allowsMultipleSelection = next.allowsMultipleSelection;
99
+ _tableView.usesAlternatingRowBackgroundColors = next.alternatingRows;
100
+ _tableView.gridStyleMask = next.alternatingRows ? NSTableViewGridNone : NSTableViewSolidVerticalGridLineMask;
101
+ _tableView.headerView = next.headerVisible ? (_tableView.headerView ?: [NSTableHeaderView new]) : nil;
102
+ if (next.rowHeight > 0) { _tableView.rowSizeStyle = NSTableViewRowSizeStyleCustom; _tableView.rowHeight = next.rowHeight; }
103
+ else _tableView.rowSizeStyle = NSTableViewRowSizeStyleDefault;
104
+ _tableView.accessibilityLabel = next.accessibilityLabel.empty() ? nil : [NSString stringWithUTF8String:next.accessibilityLabel.c_str()];
105
+ [super updateProps:props oldProps:oldProps];
106
+ // Applied last, after rows reload: the parent's selection wins, and a revision snaps back a rejected click.
107
+ [self applySelection:RNSparkTableJSON(next.selectedIdsJson, NSArray.class) ?: @[]];
108
+ }
109
+ - (void)updateLayoutMetrics:(const LayoutMetrics &)layoutMetrics oldLayoutMetrics:(const LayoutMetrics &)oldLayoutMetrics {
110
+ [super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
111
+ _tableView.userInterfaceLayoutDirection = RNSparkLayoutDirection(layoutMetrics);
112
+ [self layoutSubviews];
113
+ }
114
+
115
+ - (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView { return (NSInteger)_rows.count; }
116
+ - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
117
+ NSTableCellView *cell = [tableView makeViewWithIdentifier:RNSparkTableCellIdentifier owner:self];
118
+ if (!cell) {
119
+ cell = [NSTableCellView new];
120
+ cell.identifier = RNSparkTableCellIdentifier;
121
+ NSTextField *field = [NSTextField labelWithString:@""];
122
+ field.lineBreakMode = NSLineBreakByTruncatingTail;
123
+ field.translatesAutoresizingMaskIntoConstraints = NO;
124
+ [field setContentCompressionResistancePriority:NSLayoutPriorityDefaultLow forOrientation:NSLayoutConstraintOrientationHorizontal];
125
+ [cell addSubview:field];
126
+ cell.textField = field;
127
+ [NSLayoutConstraint activateConstraints:@[
128
+ [field.leadingAnchor constraintEqualToAnchor:cell.leadingAnchor constant:2],
129
+ [field.trailingAnchor constraintEqualToAnchor:cell.trailingAnchor constant:-2],
130
+ [field.centerYAnchor constraintEqualToAnchor:cell.centerYAnchor],
131
+ ]];
132
+ }
133
+ NSDictionary *column = nil;
134
+ for (NSDictionary *candidate in _columns) if ([candidate[@"id"] isEqual:tableColumn.identifier]) { column = candidate; break; }
135
+ NSDictionary *values = row >= 0 && row < (NSInteger)_rows.count ? _rows[row][@"values"] : nil;
136
+ id value = [values isKindOfClass:NSDictionary.class] ? values[tableColumn.identifier] : nil;
137
+ cell.textField.stringValue = [value isKindOfClass:NSString.class] ? value : @"";
138
+ NSString *alignment = column[@"alignment"];
139
+ cell.textField.alignment = [alignment isEqual:@"trailing"] ? NSTextAlignmentRight : [alignment isEqual:@"center"] ? NSTextAlignmentCenter : NSTextAlignmentNatural;
140
+ cell.textField.font = [column[@"monospacedDigits"] boolValue] ? [NSFont monospacedDigitSystemFontOfSize:NSFont.systemFontSize weight:NSFontWeightRegular] : [NSFont systemFontOfSize:NSFont.systemFontSize];
141
+ cell.textField.textColor = [column[@"secondary"] boolValue] ? NSColor.secondaryLabelColor : NSColor.labelColor;
142
+ return cell;
143
+ }
144
+ - (void)tableViewSelectionDidChange:(NSNotification *)notification {
145
+ if (_applyingSelection) return;
146
+ NSMutableArray<NSString *> *ids = [NSMutableArray new];
147
+ [_tableView.selectedRowIndexes enumerateIndexesUsingBlock:^(NSUInteger index, BOOL *) { if (index < self->_rows.count) [ids addObject:self->_rows[index][@"id"]]; }];
148
+ NSInteger focused = _tableView.selectedRow;
149
+ NSString *rowId = focused >= 0 && focused < (NSInteger)_rows.count ? _rows[focused][@"id"] : @"";
150
+ NSData *data = [NSJSONSerialization dataWithJSONObject:ids options:0 error:nil];
151
+ const auto emitter = std::static_pointer_cast<const SparkTableEventEmitter>(_eventEmitter);
152
+ if (emitter) emitter->onTableSelectionChange({ .id = rowId.UTF8String, .idsJson = std::string((const char *)data.bytes, data.length) });
153
+ }
154
+ - (void)tableViewColumnDidResize:(NSNotification *)notification {
155
+ const auto &props = *std::static_pointer_cast<const SparkTableProps>(_props);
156
+ if (!props.reportsColumnResize || !_tableView.headerView) return;
157
+ NSInteger index = _tableView.headerView.resizedColumn;
158
+ NSArray<NSTableColumn *> *columns = _tableView.tableColumns;
159
+ if (index < 0 || index >= (NSInteger)columns.count) return;
160
+ NSTableColumn *column = notification.userInfo[@"NSTableColumn"];
161
+ if (column != columns[index]) return;
162
+ const auto emitter = std::static_pointer_cast<const SparkTableEventEmitter>(_eventEmitter);
163
+ if (emitter) emitter->onTableColumnResize({ .id = column.identifier.UTF8String, .width = column.width });
164
+ }
165
+ - (void)rowDoubleClicked:(id)sender {
166
+ NSInteger row = _tableView.clickedRow;
167
+ if (row < 0 || row >= (NSInteger)_rows.count) return;
168
+ const auto emitter = std::static_pointer_cast<const SparkTableEventEmitter>(_eventEmitter);
169
+ if (emitter) emitter->onTableDoubleClick({ .id = [_rows[row][@"id"] UTF8String] });
170
+ }
171
+ - (void)prepareForRecycle {
172
+ [super prepareForRecycle];
173
+ _props = std::make_shared<const SparkTableProps>();
174
+ [self applyColumns:@[]];
175
+ [self applyRows:@[]];
176
+ [_tableView scrollPoint:NSZeroPoint];
177
+ }
178
+ + (ComponentDescriptorProvider)componentDescriptorProvider { return concreteComponentDescriptorProvider<SparkTableComponentDescriptor>(); }
179
+ @end
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/spark-ui",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "license": "MIT",
5
5
  "main": "src/index",
6
6
  "react-native": "src/index",
@@ -39,10 +39,16 @@
39
39
  "componentProvider": {
40
40
  "SparkButton": "RNSparkButton",
41
41
  "SparkTextInput": "RNSparkTextInput",
42
+ "SparkSplitView": "RNSparkSplitViewComponent",
42
43
  "SidebarSplitView": "RNSidebarSplitViewComponent",
43
44
  "Sidebar": "RNSidebar",
44
45
  "SidebarItem": "RNSidebarItem",
45
46
  "SFSymbol": "RNSFSymbol",
47
+ "SparkProgressIndicator": "RNSparkProgressIndicator",
48
+ "SparkRadioGroup": "RNSparkRadioGroup",
49
+ "SparkPopover": "RNSparkPopover",
50
+ "SparkTable": "RNSparkTable",
51
+ "SparkSheet": "RNSparkSheet",
46
52
  "SwipeActions": "RNSwipeActions",
47
53
  "NativeSelect": "RNNativeSelect",
48
54
  "NativeSegmentedControl": "RNNativeSegmentedControl",
@@ -58,17 +64,12 @@
58
64
  },
59
65
  "spark": {
60
66
  "sdk": true,
61
- "nativeModules": [],
62
- "pod": "RNSparkUI",
63
- "platforms": [
64
- "macos",
65
- "windows"
66
- ]
67
+ "nativeModules": true
67
68
  },
68
69
  "private": true,
69
70
  "dependencies": {
70
71
  "clsx": "^2.1.1",
71
72
  "tailwind-merge": "^3.4.0",
72
- "@legendapp/spark-desktop-app": "0.0.3"
73
+ "@legendapp/spark-desktop-app": "0.0.5"
73
74
  }
74
75
  }
@@ -1,12 +1,20 @@
1
1
  import type { HostComponent, ViewProps } from "react-native";
2
- import type { DirectEventHandler, WithDefault } from "react-native/Libraries/Types/CodegenTypes";
2
+ import type { DirectEventHandler, Double, Int32, WithDefault } from "react-native/Libraries/Types/CodegenTypes";
3
3
  import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
4
4
 
5
5
  export interface NativeProps extends ViewProps {
6
6
  onUnavailable?: DirectEventHandler<Readonly<{ message: string }>>;
7
7
  title: string;
8
8
  disabled?: WithDefault<boolean, false>;
9
- variant?: WithDefault<"default" | "bordered" | "borderless", "default">;
9
+ variant?: WithDefault<"default" | "bordered" | "borderless" | "checkbox" | "disclosure", "default">;
10
+ /** Checkbox value or disclosure expansion; re-applied whenever checkedRevision changes. */
11
+ checked?: WithDefault<boolean, false>;
12
+ checkedRevision?: Int32;
13
+ /** SF Symbol name shown before the title; empty for none. */
14
+ symbol?: string;
15
+ controlSize?: WithDefault<"regular" | "small" | "mini", "regular">;
16
+ onSymbolError?: DirectEventHandler<Readonly<{ name: string; message: string }>>;
10
17
  onButtonPress?: DirectEventHandler<Readonly<{}>>;
18
+ onIntrinsicSize?: DirectEventHandler<Readonly<{ width: Double; height: Double }>>;
11
19
  }
12
20
  export default codegenNativeComponent<NativeProps>("SparkButton") as HostComponent<NativeProps>;
@@ -7,6 +7,8 @@ export interface NativeProps extends ViewProps {
7
7
  text?: string;
8
8
  controlled?: WithDefault<boolean, false>;
9
9
  disabled?: WithDefault<boolean, false>;
10
+ placeholder?: string;
11
+ multiline?: WithDefault<boolean, false>;
10
12
  eventCount?: Int32;
11
13
  onTextChange?: DirectEventHandler<Readonly<{ text: string; eventCount: Int32 }>>;
12
14
  }
@@ -8,6 +8,10 @@ export type SidebarSplitViewResizeEvent = Readonly<{
8
8
  contentX: Double;
9
9
  contentY: Double;
10
10
  height: Double;
11
+ inspectorHeight: Double;
12
+ inspectorWidth: Double;
13
+ inspectorX: Double;
14
+ inspectorY: Double;
11
15
  isLayoutReady: boolean;
12
16
  isVertical: boolean;
13
17
  listHeight: Double;
@@ -31,9 +35,14 @@ export interface NativeProps extends ViewProps {
31
35
  contentTitlebarOverlayColor?: string;
32
36
  contentTitlebarOverlayOpacity?: Double;
33
37
  contentMinWidth?: Double;
38
+ hasInspector?: boolean;
34
39
  hasList?: boolean;
40
+ inspectorCollapsed?: boolean;
41
+ inspectorMinWidth?: Double;
42
+ inspectorWidth?: Double;
35
43
  listMinWidth?: Double;
36
44
  listWidth?: Double;
45
+ onInspectorCollapsedChange?: DirectEventHandler<SidebarSplitViewCollapsedChangeEvent>;
37
46
  onSidebarCollapsedChange?: DirectEventHandler<SidebarSplitViewCollapsedChangeEvent>;
38
47
  onSplitViewDidResize?: DirectEventHandler<SidebarSplitViewResizeEvent>;
39
48
  sidebarCollapsed?: boolean;
@@ -0,0 +1,99 @@
1
+ import { useMemo, useRef, useState, type ReactNode } from "react";
2
+ import { View, type NativeSyntheticEvent } from "react-native";
3
+ import { SparkError } from "@legendapp/spark-desktop-app/src/contracts";
4
+ import { useControl } from "../control";
5
+ import { callback, finite, identifier, macosViewAvailability, type SpecializedViewProps } from "../specialized";
6
+ import NativeSplitView, { type SplitViewLayoutEvent } from "./SplitViewNativeComponent";
7
+
8
+ export interface SplitViewPane {
9
+ id: string;
10
+ content: ReactNode;
11
+ initialSize?: number;
12
+ minSize?: number;
13
+ maxSize?: number;
14
+ }
15
+
16
+ export interface SplitViewProps extends Omit<SpecializedViewProps, "children"> {
17
+ panes: readonly SplitViewPane[];
18
+ children?: never;
19
+ orientation?: "horizontal" | "vertical";
20
+ dividerStyle?: "thin" | "thick" | "paneSplitter";
21
+ onResize?: (sizes: readonly number[]) => void;
22
+ }
23
+
24
+ function matches(layout: SplitViewLayoutEvent, horizontal: boolean, panes: readonly { id: string }[]) {
25
+ return layout.horizontal === horizontal
26
+ && layout.panes.length === panes.length
27
+ && layout.panes.every((frame, index) => frame.id === panes[index].id);
28
+ }
29
+
30
+ export function SplitView({ panes, children, orientation = "horizontal", dividerStyle = "thin", onResize, onError, ref, ...props }: SplitViewProps) {
31
+ if (children !== undefined) throw new SparkError("E_INVALID_ARGUMENT", "Pass split-view content through panes");
32
+ if (orientation !== "horizontal" && orientation !== "vertical") throw new SparkError("E_INVALID_ARGUMENT", "Invalid split-view orientation");
33
+ if (!["thin", "thick", "paneSplitter"].includes(dividerStyle)) throw new SparkError("E_INVALID_ARGUMENT", "Invalid split-view divider style");
34
+ callback(onResize, "resize");
35
+ const sizing = useMemo(() => {
36
+ if (!Array.isArray(panes)) throw new SparkError("E_INVALID_ARGUMENT", "Expected split-view panes");
37
+ const ids = new Set<string>();
38
+ return Array.from(panes as readonly SplitViewPane[], pane => {
39
+ if (!pane || typeof pane !== "object") throw new SparkError("E_INVALID_ARGUMENT", "Invalid split-view pane");
40
+ const { id, minSize = 0, maxSize, initialSize } = pane;
41
+ identifier(id, "split-view pane ID");
42
+ if (ids.has(id)) throw new SparkError("E_INVALID_ARGUMENT", `Duplicate split-view pane ID: ${id}`);
43
+ ids.add(id);
44
+ finite(minSize, "minimum pane size");
45
+ if (maxSize !== undefined) finite(maxSize, "maximum pane size", minSize);
46
+ if (initialSize !== undefined) finite(initialSize, "initial pane size", minSize, maxSize);
47
+ return { id, minSize, maxSize: maxSize ?? -1, initialSize: initialSize ?? -1 };
48
+ });
49
+ }, [panes]);
50
+ const control = useControl({ onError, ref }, macosViewAvailability("SparkSplitView"));
51
+ const horizontal = orientation === "horizontal";
52
+ const [layout, setLayout] = useState<SplitViewLayoutEvent>();
53
+ const reported = useRef<{ layout: SplitViewLayoutEvent; sizes: readonly number[] } | undefined>(undefined);
54
+
55
+ function resize({ nativeEvent }: NativeSyntheticEvent<SplitViewLayoutEvent>) {
56
+ if (!control.active()) return;
57
+ try {
58
+ if (typeof nativeEvent?.horizontal !== "boolean" || typeof nativeEvent.rightToLeft !== "boolean" || !Array.isArray(nativeEvent.panes)) throw new Error("Expected pane frames");
59
+ for (const { id, x, y, width, height } of nativeEvent.panes) {
60
+ identifier(id);
61
+ finite(x, "pane x"); finite(y, "pane y"); finite(width, "pane width"); finite(height, "pane height");
62
+ }
63
+ } catch (cause) {
64
+ control.error(new SparkError("E_INVALID_DATA", "Invalid split-view layout", { cause }));
65
+ return;
66
+ }
67
+ if (!matches(nativeEvent, horizontal, sizing)) return;
68
+ setLayout(nativeEvent);
69
+ if (!onResize) return;
70
+ const sizes = nativeEvent.panes.map(frame => horizontal ? frame.width : frame.height);
71
+ const last = reported.current;
72
+ if (!last || !matches(last.layout, horizontal, sizing) || sizes.some((size, index) => size !== last.sizes[index])) {
73
+ reported.current = { layout: nativeEvent, sizes };
74
+ onResize(sizes);
75
+ }
76
+ }
77
+
78
+ if (control.failed) {
79
+ return <View {...props} ref={control.ref} style={[{ flexDirection: horizontal ? "row" : "column" }, props.style]}>
80
+ {panes.map(({ id, content, initialSize, minSize, maxSize }) => <View key={id} style={horizontal
81
+ ? { flexBasis: initialSize ?? 0, flexGrow: 1, flexShrink: 1, minWidth: minSize, maxWidth: maxSize }
82
+ : { flexBasis: initialSize ?? 0, flexGrow: 1, flexShrink: 1, minHeight: minSize, maxHeight: maxSize }}>{content}</View>)}
83
+ </View>;
84
+ }
85
+
86
+ const current = layout && matches(layout, horizontal, sizing) ? layout : undefined;
87
+ return <NativeSplitView {...props} ref={control.ref} horizontal={horizontal} dividerStyle={dividerStyle} panes={sizing} onSplitViewLayout={resize}>
88
+ {panes.map(({ id, content }, index) => {
89
+ const frame = current?.panes[index];
90
+ return <View key={id} collapsable={false} style={{
91
+ position: "absolute",
92
+ [current?.rightToLeft ? "end" : "start"]: frame?.x ?? 0,
93
+ top: frame?.y ?? 0,
94
+ width: frame?.width ?? 0,
95
+ height: frame?.height ?? 0,
96
+ }}>{content}</View>;
97
+ })}
98
+ </NativeSplitView>;
99
+ }
@@ -0,0 +1,29 @@
1
+ import { codegenNativeComponent, type CodegenTypes, type HostComponent, type ViewProps } from "react-native";
2
+
3
+ type PaneSizing = Readonly<{
4
+ id: string;
5
+ initialSize: CodegenTypes.Double;
6
+ minSize: CodegenTypes.Double;
7
+ maxSize: CodegenTypes.Double;
8
+ }>;
9
+
10
+ export type SplitViewLayoutEvent = Readonly<{
11
+ horizontal: boolean;
12
+ rightToLeft: boolean;
13
+ panes: {
14
+ id: string;
15
+ x: CodegenTypes.Double;
16
+ y: CodegenTypes.Double;
17
+ width: CodegenTypes.Double;
18
+ height: CodegenTypes.Double;
19
+ }[];
20
+ }>;
21
+
22
+ export interface NativeProps extends ViewProps {
23
+ horizontal?: CodegenTypes.WithDefault<boolean, true>;
24
+ dividerStyle?: string;
25
+ panes?: ReadonlyArray<PaneSizing>;
26
+ onSplitViewLayout?: CodegenTypes.DirectEventHandler<SplitViewLayoutEvent>;
27
+ }
28
+
29
+ export default codegenNativeComponent<NativeProps>("SparkSplitView") as HostComponent<NativeProps>;
@@ -6,9 +6,10 @@ import { appearance, callback, finite, macosViewAvailability, type SpecializedVi
6
6
  import NativeSplitView from "./SidebarSplitViewNativeComponent";
7
7
  export type SidebarSplitViewAppearance = "system" | "light" | "dark";
8
8
  export type SidebarSplitViewTitlebarMaterial = "none" | "glass" | "titlebar" | "headerView" | "hudWindow" | "sidebar" | "windowBackground";
9
- export interface SidebarSplitViewPaneMetrics { contentHeight: number; contentWidth: number; sidebarHeight: number; sidebarWidth: number; listHeight?: number; listWidth?: number }
10
- export interface SidebarSplitViewPaneOrigins { sidebarX: number; sidebarY: number; contentX: number; contentY: number; listX: number; listY: number }
11
- export interface SidebarSplitViewResizeEvent extends SidebarSplitViewPaneMetrics, SidebarSplitViewPaneOrigins { listHeight: number; listWidth: number; height: number; phase: "provisional" | "ready" }
9
+ export interface SidebarSplitViewPaneMetrics { contentHeight: number; contentWidth: number; sidebarHeight: number; sidebarWidth: number; listHeight?: number; listWidth?: number; inspectorHeight?: number; inspectorWidth?: number }
10
+ export interface SidebarSplitViewPaneOrigins { sidebarX: number; sidebarY: number; contentX: number; contentY: number; listX: number; listY: number; inspectorX: number; inspectorY: number }
11
+ /** A pane that is absent or collapsed reports a zero width and height. */
12
+ export interface SidebarSplitViewResizeEvent extends SidebarSplitViewPaneMetrics, SidebarSplitViewPaneOrigins { listHeight: number; listWidth: number; inspectorHeight: number; inspectorWidth: number; height: number; phase: "provisional" | "ready" }
12
13
  export interface SplitViewTitleBarOverlay { color: string; opacity?: number }
13
14
  export interface SplitViewTitleBarOptions {
14
15
  content?: { height?: number; material?: SidebarSplitViewTitlebarMaterial; overlay?: SplitViewTitleBarOverlay };
@@ -26,6 +27,14 @@ export interface SidebarSplitViewProps extends Omit<SpecializedViewProps, "child
26
27
  sidebarWidth?: number;
27
28
  listMinWidth?: number;
28
29
  listWidth?: number;
30
+ /** Optional trailing inspector pane (AppKit's inspector split item, as in Xcode or Keynote). The user can collapse it; `toggleInspector:` in a menu or toolbar does too. */
31
+ inspector?: ReactNode;
32
+ /** Defaults to 220. */
33
+ inspectorMinWidth?: number;
34
+ /** Initial inspector width; afterwards the user's drag owns it. Defaults to `inspectorMinWidth`. */
35
+ inspectorWidth?: number;
36
+ /** Applied when its value changes, like `sidebarCollapsed`. */
37
+ inspectorCollapsed?: boolean;
29
38
  sidebarCollapsed?: boolean;
30
39
  /** Used only for initial layout, before native measurements arrive. */
31
40
  initialPaneMetrics?: SidebarSplitViewPaneMetrics;
@@ -33,15 +42,17 @@ export interface SidebarSplitViewProps extends Omit<SpecializedViewProps, "child
33
42
  onResize?: (event: SidebarSplitViewResizeEvent) => void;
34
43
  /** Fires when AppKit collapses or expands the sidebar itself (View > Hide Sidebar, the toolbar button). Not called for `sidebarCollapsed` changes. */
35
44
  onSidebarCollapsedChange?: (collapsed: boolean) => void;
45
+ /** Fires when AppKit collapses or expands the inspector itself (the user, `toggleInspector:`). Not called for `inspectorCollapsed` changes. */
46
+ onInspectorCollapsedChange?: (collapsed: boolean) => void;
36
47
  }
37
48
  export function getSplitViewAvailability() { return macosViewAvailability("SidebarSplitView"); }
38
49
  function metrics(value: SidebarSplitViewPaneMetrics) {
39
50
  if (!value || typeof value !== "object") throw new SparkError("E_INVALID_ARGUMENT", "Expected pane metrics");
40
51
  for (const key of ["contentHeight", "contentWidth", "sidebarHeight", "sidebarWidth"] as const) finite(value[key], key);
41
- for (const key of ["listHeight", "listWidth"] as const) if (value[key] !== undefined) finite(value[key], key);
52
+ for (const key of ["listHeight", "listWidth", "inspectorHeight", "inspectorWidth"] as const) if (value[key] !== undefined) finite(value[key], key);
42
53
  }
43
- const paneKeys = ["contentHeight", "contentWidth", "sidebarHeight", "sidebarWidth", "listHeight", "listWidth", "sidebarX", "sidebarY", "contentX", "contentY", "listX", "listY"] as const;
44
- const originKeys = ["sidebarX", "sidebarY", "contentX", "contentY", "listX", "listY"] as const;
54
+ const paneKeys = ["contentHeight", "contentWidth", "sidebarHeight", "sidebarWidth", "listHeight", "listWidth", "inspectorHeight", "inspectorWidth", "sidebarX", "sidebarY", "contentX", "contentY", "listX", "listY", "inspectorX", "inspectorY"] as const;
55
+ const originKeys = ["sidebarX", "sidebarY", "contentX", "contentY", "listX", "listY", "inspectorX", "inspectorY"] as const;
45
56
  function keys(value: unknown, allowed: readonly string[]) {
46
57
  if (!value || typeof value !== "object" || Array.isArray(value)) throw new SparkError("E_INVALID_ARGUMENT", "Expected title-bar options");
47
58
  for (const key of Object.keys(value)) if (!allowed.includes(key)) throw new SparkError("E_UNSUPPORTED_OPTION", `Unknown title-bar option: ${key}`);
@@ -52,11 +63,15 @@ function overlay(value?: SplitViewTitleBarOverlay) {
52
63
  if (typeof value.color !== "string" || !/^#(?:[\da-f]{6}|[\da-f]{8})$/i.test(value.color)) throw new SparkError("E_INVALID_ARGUMENT", "Expected #RRGGBB or #RRGGBBAA title-bar color");
53
64
  if (value.opacity !== undefined) finite(value.opacity, "overlay opacity", 0, 1);
54
65
  }
55
- export function SidebarSplitView({ sidebar, content, list, children, appearance: theme = "system", contentMinWidth = 320, sidebarMinWidth = 180, sidebarWidth, listMinWidth = 240, listWidth, sidebarCollapsed = false, initialPaneMetrics, titleBar = {}, onResize, onSidebarCollapsedChange, ref, onError, ...props }: SidebarSplitViewProps) {
66
+ export function SidebarSplitView({ sidebar, content, list, children, appearance: theme = "system", contentMinWidth = 320, sidebarMinWidth = 180, sidebarWidth, listMinWidth = 240, listWidth, inspector, inspectorMinWidth = 220, inspectorWidth, inspectorCollapsed = false, sidebarCollapsed = false, initialPaneMetrics, titleBar = {}, onResize, onSidebarCollapsedChange, onInspectorCollapsedChange, ref, onError, ...props }: SidebarSplitViewProps) {
56
67
  appearance(theme); finite(contentMinWidth, "minimum content width"); finite(sidebarMinWidth, "minimum sidebar width"); finite(listMinWidth, "minimum list width");
57
68
  if (sidebarWidth !== undefined) finite(sidebarWidth, "sidebar width", sidebarMinWidth);
58
69
  if (listWidth !== undefined) finite(listWidth, "list width", listMinWidth);
59
- const hasList = list !== undefined && list !== null && typeof list !== "boolean" && list !== "";
70
+ finite(inspectorMinWidth, "minimum inspector width");
71
+ if (inspectorWidth !== undefined) finite(inspectorWidth, "inspector width", inspectorMinWidth);
72
+ const present = (pane: ReactNode) => pane !== undefined && pane !== null && typeof pane !== "boolean" && pane !== "";
73
+ const hasList = present(list), hasInspector = present(inspector);
74
+ if (typeof inspectorCollapsed !== "boolean") throw new SparkError("E_INVALID_ARGUMENT", "inspectorCollapsed must be a boolean");
60
75
  if (typeof sidebarCollapsed !== "boolean" || children !== undefined) throw new SparkError("E_INVALID_ARGUMENT", "Use named sidebar/content panes and a boolean collapsed state");
61
76
  if (initialPaneMetrics !== undefined) metrics(initialPaneMetrics);
62
77
  keys(titleBar, ["content", "sidebar"]);
@@ -65,32 +80,34 @@ export function SidebarSplitView({ sidebar, content, list, children, appearance:
65
80
  overlay(titleBar.content?.overlay); overlay(titleBar.sidebar?.overlay);
66
81
  const material = titleBar.content?.material ?? "none";
67
82
  if (!["none", "glass", "titlebar", "headerView", "hudWindow", "sidebar", "windowBackground"].includes(material)) throw new SparkError("E_INVALID_ARGUMENT", "Invalid title-bar material");
68
- callback(onResize, "resize"); callback(onSidebarCollapsedChange, "sidebar collapsed change");
83
+ callback(onResize, "resize"); callback(onSidebarCollapsedChange, "sidebar collapsed change"); callback(onInspectorCollapsedChange, "inspector collapsed change");
69
84
  const control = useControl({ ref, onError }, getSplitViewAvailability());
70
85
  const [paneMetrics, setPaneMetrics] = useState<SidebarSplitViewPaneMetrics & Partial<SidebarSplitViewPaneOrigins> | undefined>(() => initialPaneMetrics ? { ...initialPaneMetrics } : undefined);
71
86
  function resize(event: NativeSyntheticEvent<SidebarSplitViewPaneMetrics & SidebarSplitViewPaneOrigins & { height: number; isLayoutReady: boolean }>) {
72
87
  if (!control.active()) return;
73
88
  let value: SidebarSplitViewResizeEvent;
74
89
  try {
75
- const data = event?.nativeEvent; metrics(data); finite(data.listHeight, "list height"); finite(data.listWidth, "list width"); for (const key of originKeys) finite(data[key], key, -Infinity); finite(data.height, "height");
90
+ const data = event?.nativeEvent; metrics(data); finite(data.listHeight, "list height"); finite(data.listWidth, "list width"); finite(data.inspectorHeight!, "inspector height"); finite(data.inspectorWidth!, "inspector width"); for (const key of originKeys) finite(data[key], key, -Infinity); finite(data.height, "height");
76
91
  if (typeof data.isLayoutReady !== "boolean") throw new Error("Expected layout readiness");
77
- value = { contentHeight: data.contentHeight, contentWidth: data.contentWidth, sidebarHeight: data.sidebarHeight, sidebarWidth: data.sidebarWidth, listHeight: data.listHeight, listWidth: data.listWidth, sidebarX: data.sidebarX, sidebarY: data.sidebarY, contentX: data.contentX, contentY: data.contentY, listX: data.listX, listY: data.listY, height: data.height, phase: data.isLayoutReady ? "ready" : "provisional" };
92
+ value = { contentHeight: data.contentHeight, contentWidth: data.contentWidth, sidebarHeight: data.sidebarHeight, sidebarWidth: data.sidebarWidth, listHeight: data.listHeight, listWidth: data.listWidth, inspectorHeight: data.inspectorHeight!, inspectorWidth: data.inspectorWidth!, sidebarX: data.sidebarX, sidebarY: data.sidebarY, contentX: data.contentX, contentY: data.contentY, listX: data.listX, listY: data.listY, inspectorX: data.inspectorX, inspectorY: data.inspectorY, height: data.height, phase: data.isLayoutReady ? "ready" : "provisional" };
78
93
  } catch (cause) { control.error(new SparkError("E_INVALID_DATA", "Invalid split-view layout", { cause })); return; }
79
94
  setPaneMetrics(current => current && paneKeys.every(key => current[key] === value[key]) ? current : value);
80
95
  onResize?.(value);
81
96
  }
82
- function collapsedChange(event: NativeSyntheticEvent<{ collapsed: boolean }>) {
97
+ const collapsedChange = (pane: string, listener?: (collapsed: boolean) => void) => (event: NativeSyntheticEvent<{ collapsed: boolean }>) => {
83
98
  if (!control.active()) return;
84
99
  const collapsed = event?.nativeEvent?.collapsed;
85
- if (typeof collapsed !== "boolean") { control.error(new SparkError("E_INVALID_DATA", "Invalid sidebar collapsed state")); return; }
86
- onSidebarCollapsedChange?.(collapsed);
87
- }
88
- if (control.failed) return <View {...props} ref={control.ref} style={[{ flexDirection: "row" }, props.style]}>{sidebarCollapsed ? null : sidebar}{list}{content}</View>;
89
- return <NativeSplitView {...props} ref={control.ref} appearance={theme} contentMinWidth={contentMinWidth} sidebarMinWidth={sidebarMinWidth} sidebarWidth={sidebarWidth} hasList={hasList} listMinWidth={listMinWidth} listWidth={listWidth} sidebarCollapsed={sidebarCollapsed} onSplitViewDidResize={resize} onSidebarCollapsedChange={collapsedChange}
100
+ if (typeof collapsed !== "boolean") { control.error(new SparkError("E_INVALID_DATA", `Invalid ${pane} collapsed state`)); return; }
101
+ listener?.(collapsed);
102
+ };
103
+ if (control.failed) return <View {...props} ref={control.ref} style={[{ flexDirection: "row" }, props.style]}>{sidebarCollapsed ? null : sidebar}{list}{content}{inspectorCollapsed ? null : inspector}</View>;
104
+ return <NativeSplitView {...props} ref={control.ref} appearance={theme} contentMinWidth={contentMinWidth} sidebarMinWidth={sidebarMinWidth} sidebarWidth={sidebarWidth} hasList={hasList} listMinWidth={listMinWidth} listWidth={listWidth} sidebarCollapsed={sidebarCollapsed} onSplitViewDidResize={resize} onSidebarCollapsedChange={collapsedChange("sidebar", onSidebarCollapsedChange)}
105
+ hasInspector={hasInspector} inspectorMinWidth={inspectorMinWidth} inspectorWidth={inspectorWidth} inspectorCollapsed={inspectorCollapsed} onInspectorCollapsedChange={collapsedChange("inspector", onInspectorCollapsedChange)}
90
106
  contentTitlebarHeight={titleBar.content?.height ?? 0} contentTitlebarMaterial={material} contentTitlebarOverlayColor={titleBar.content?.overlay?.color} contentTitlebarOverlayOpacity={titleBar.content?.overlay?.opacity ?? (titleBar.content?.overlay ? 1 : 0)}
91
107
  sidebarTitlebarOverlayColor={titleBar.sidebar?.overlay?.color} sidebarTitlebarOverlayOpacity={titleBar.sidebar?.overlay?.opacity ?? (titleBar.sidebar?.overlay ? 1 : 0)}>
92
108
  <View key="sidebar" style={{ position: "absolute", top: paneMetrics?.sidebarY ?? 0, left: paneMetrics?.sidebarX ?? 0, minWidth: 0, height: paneMetrics?.sidebarHeight, width: paneMetrics?.sidebarWidth ?? (sidebarCollapsed ? 0 : sidebarWidth ?? sidebarMinWidth) }}>{sidebar}</View>
93
109
  <View key="content" style={{ position: "absolute", top: paneMetrics?.contentY ?? 0, left: paneMetrics?.contentX ?? 0, minWidth: 0, overflow: "hidden", height: paneMetrics?.contentHeight, width: paneMetrics?.contentWidth }}>{content}</View>
94
110
  {hasList ? <View key="list" style={{ position: "absolute", top: paneMetrics?.listY ?? 0, left: paneMetrics?.listX ?? 0, minWidth: 0, height: paneMetrics?.listHeight, width: paneMetrics?.listWidth ?? listWidth ?? listMinWidth }}>{list}</View> : null}
111
+ {hasInspector ? <View key="inspector" style={{ position: "absolute", top: paneMetrics?.inspectorY ?? 0, left: paneMetrics?.inspectorX ?? 0, minWidth: 0, height: paneMetrics?.inspectorHeight, width: paneMetrics?.inspectorWidth ?? (inspectorCollapsed ? 0 : inspectorWidth ?? inspectorMinWidth) }}>{inspector}</View> : null}
95
112
  </NativeSplitView>;
96
113
  }
@@ -1,10 +1,12 @@
1
1
  import { Platform, UIManager } from "react-native";
2
2
  import { SparkError, type Availability } from "@legendapp/spark-desktop-app/src/contracts";
3
+ import { controlKinds, unsupportedPlatform } from "./control";
3
4
  import type { ControlKind } from "./types";
4
5
  export function getControlAvailability(control: ControlKind): Availability {
5
- const names: Record<ControlKind, string> = { button: "SparkButton", "text-input": "SparkTextInput", select: Platform.OS === "windows" ? "SparkSelect" : "NativeSelect", "segmented-control": "NativeSegmentedControl" };
6
- if (!Object.hasOwn(names, control)) throw new SparkError("E_INVALID_ARGUMENT", "Unknown control kind");
7
- if (Platform.OS !== "macos" && Platform.OS !== "windows") return { available: false, reason: "unsupported-platform" };
8
- if (Platform.OS === "windows" && control === "segmented-control") return { available: false, reason: "unsupported-platform" };
6
+ if (!controlKinds.includes(control)) throw new SparkError("E_INVALID_ARGUMENT", "Unknown control kind");
7
+ if (Platform.OS !== "macos" && Platform.OS !== "windows") return unsupportedPlatform;
8
+ if (Platform.OS === "windows" && (control === "segmented-control" || control === "radio-group")) return unsupportedPlatform;
9
+ if (control === "switch") return { available: true };
10
+ const names = { button: "SparkButton", "text-input": "SparkTextInput", select: Platform.OS === "windows" ? "SparkSelect" : "NativeSelect", "segmented-control": "NativeSegmentedControl", checkbox: "SparkButton", "radio-group": "SparkRadioGroup" };
9
11
  return UIManager.hasViewManagerConfig(names[control]) ? { available: true } : { available: false, reason: "missing-module" };
10
12
  }
@@ -0,0 +1,20 @@
1
+ import { Text, View } from "react-native";
2
+ import type { Availability } from "@legendapp/spark-desktop-app/src/contracts";
3
+ import { useControl, validateCheckbox, validateRadioGroup } from "./control";
4
+ import type { CheckboxProps, ControlRef, RadioGroupProps } from "./types";
5
+ /** The disabled fallback where a platform has no checkbox backend; useControl reports why through onError. */
6
+ export function UnavailableCheckbox({ availability, ...props }: CheckboxProps & { availability: Availability }) {
7
+ validateCheckbox(props);
8
+ const control = useControl(props, availability);
9
+ return <View ref={control.ref} style={props.style} testID={props.testID} accessible accessibilityRole="checkbox" accessibilityLabel={props.accessibilityLabel ?? props.children} accessibilityState={{ checked: props.value, disabled: true }}><Text>{props.children}</Text></View>;
10
+ }
11
+ /** The disabled fallback for RadioGroup: the options as text, the selected one marked for accessibility. */
12
+ export function UnavailableRadioGroup({ availability, ...props }: RadioGroupProps & { availability: Availability }) {
13
+ validateRadioGroup(props);
14
+ return <RadioGroupFallback {...props} controlRef={useControl(props, availability).ref} />;
15
+ }
16
+ export function RadioGroupFallback({ controlRef, ...props }: RadioGroupProps & { controlRef: (value: ControlRef | null) => void }) {
17
+ return <View ref={controlRef} style={[{ flexDirection: props.orientation === "horizontal" ? "row" : "column", gap: 6 }, props.style]} testID={props.testID} accessibilityRole="radiogroup" accessibilityLabel={props.accessibilityLabel}>
18
+ {props.options.map(option => <Text key={option.value} accessibilityRole="radio" accessibilityState={{ checked: option.value === props.value, disabled: true }}>{option.label}</Text>)}
19
+ </View>;
20
+ }
@@ -1,6 +1,7 @@
1
1
  import { useCallback, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState } from "react";
2
2
  import { SparkError, type Availability } from "@legendapp/spark-desktop-app/src/contracts";
3
- import type { ButtonProps, ControlProps, ControlRef, TextInputProps } from "./types";
3
+ import { selectionIndex } from "./select";
4
+ import type { ButtonProps, CheckboxProps, ControlProps, ControlRef, RadioGroupProps, SegmentedControlProps, TextInputProps } from "./types";
4
5
  export type MeasureTarget = ControlRef | null;
5
6
  export function useControl(props: ControlProps, availability: Availability = { available: true }) {
6
7
  const { disabled = false, onError = console.error } = props;
@@ -27,10 +28,30 @@ export function useControl(props: ControlProps, availability: Availability = { a
27
28
  setFailed(true); error(new SparkError("E_UNAVAILABLE", event.nativeEvent.message));
28
29
  }
29
30
  const ref = useCallback((value: MeasureTarget) => { target.current = value; }, []);
30
- return { ref, disabled, failed: failed || !availability.available, error, unavailable, active: () => mounted.current && !disabled && !failed && availability.available };
31
+ return { ref, disabled, failed: failed || !availability.available, error, unavailable, mounted: () => mounted.current, active: () => mounted.current && !disabled && !failed && availability.available };
31
32
  }
33
+ export const controlKinds = ["button", "text-input", "select", "segmented-control", "checkbox", "radio-group", "switch"] as const;
34
+ export const unsupportedPlatform: Availability = { available: false, reason: "unsupported-platform" };
32
35
  export function validateButton(props: ButtonProps) {
33
- if (typeof props.children !== "string" || !props.children.length || (props.onPress !== undefined && typeof props.onPress !== "function") || (props.variant !== undefined && !["default", "bordered", "borderless"].includes(props.variant))) throw new SparkError("E_INVALID_ARGUMENT", "Invalid button options");
36
+ if (typeof props.children !== "string" || !props.children.length || (props.onPress !== undefined && typeof props.onPress !== "function") || (props.variant !== undefined && !["default", "bordered", "borderless", "disclosure"].includes(props.variant))) throw new SparkError("E_INVALID_ARGUMENT", "Invalid button options");
37
+ if ((props.variant === "disclosure") !== (props.expanded !== undefined) || (props.expanded !== undefined && typeof props.expanded !== "boolean")) throw new SparkError("E_INVALID_ARGUMENT", "Disclosure buttons require a boolean expanded; other buttons do not take it");
38
+ if (props.symbol !== undefined && (typeof props.symbol !== "string" || !props.symbol.length || props.symbol.includes("\0") || props.variant === "disclosure")) throw new SparkError("E_INVALID_ARGUMENT", "A button symbol is a nonempty SF Symbol name, and disclosure buttons take none");
39
+ if (props.size !== undefined && !["regular", "small", "mini"].includes(props.size)) throw new SparkError("E_INVALID_ARGUMENT", "Invalid button size");
40
+ }
41
+ /** Button options only AppKit (and, for `size`, the web) can honor. */
42
+ export function macosButton(props: ButtonProps) {
43
+ return props.variant === "disclosure" || props.symbol !== undefined || (props.size !== undefined && props.size !== "regular");
44
+ }
45
+ export function validateCheckbox(props: CheckboxProps) {
46
+ if (typeof props.value !== "boolean" || typeof props.onValueChange !== "function" || (props.children !== undefined && (typeof props.children !== "string" || !props.children.length))) throw new SparkError("E_INVALID_ARGUMENT", "Invalid checkbox options");
47
+ if (props.children === undefined && !props.accessibilityLabel) throw new SparkError("E_INVALID_ARGUMENT", "A checkbox without a label requires accessibilityLabel");
48
+ }
49
+ export function validateSegmented(props: SegmentedControlProps) {
50
+ if ((props.size !== undefined && !["regular", "small"].includes(props.size)) || (props.distribution !== undefined && !["fit", "fill"].includes(props.distribution))) throw new SparkError("E_INVALID_ARGUMENT", "Invalid segmented control options");
51
+ }
52
+ export function validateRadioGroup(props: RadioGroupProps) {
53
+ selectionIndex(props.options, props.value);
54
+ if (typeof props.onValueChange !== "function" || (props.orientation !== undefined && !["vertical", "horizontal"].includes(props.orientation)) || (props.size !== undefined && !["regular", "small", "mini"].includes(props.size))) throw new SparkError("E_INVALID_ARGUMENT", "Invalid radio group options");
34
55
  }
35
56
  export function useTextValue(props: TextInputProps) {
36
57
  const controlled = props.value !== undefined;