@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.
- package/init-template.cjs +7 -1
- package/package.json +11 -6
- package/patches/dependencies.json +4 -4
- package/patches/react-native-mmkv@4.3.2.patch +2 -2
- package/patches/react-native-nitro-zxing@0.3.1.patch +22 -0
- package/patches/registry.json +615 -0
- package/patches/workspace/expo-audio@55.0.18.patch +159 -0
- package/patches/workspace/op-engineering-op-sqlite@18.2.1.patch +796 -0
- package/patches/workspace/react-native-nitro-modules@0.37.0.patch +1348 -0
- package/patches/workspace/react-native-runtimes-core@0.1.0-alpha.2.patch +276 -0
- package/patches/workspace/react-native-webview@16.0.0.patch +208 -0
- package/postinstall.cjs +10 -1
- package/skills/spark/SKILL.md +37 -4
- package/skills/spark/UPGRADING.md +174 -1
- package/skills/spark/ai-customize.md +39 -0
- package/skills/spark/app-and-documents.md +56 -0
- package/skills/spark/external-libraries.md +87 -0
- package/skills/spark/files.md +64 -0
- package/skills/spark/integrations.md +69 -0
- package/skills/spark/keyboard.md +54 -0
- package/skills/spark/library-compat.md +76 -0
- package/skills/spark/menus-tray-dock.md +83 -0
- package/skills/spark/storage-settings.md +59 -0
- package/skills/spark/ui.md +83 -0
- package/skills/spark/windows.md +91 -0
- package/ui-popover.ts +1 -0
- package/ui-progress.ts +1 -0
- package/ui-sheet.ts +1 -0
- package/ui-split-view.ts +1 -0
- package/ui-table.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-ai/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-audio/package.json +3 -13
- package/vendor/node_modules/@legendapp/spark-auth-session/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-cli/dist/add-desktop.js +5 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/build.js +157 -106
- package/vendor/node_modules/@legendapp/spark-cli/dist/cli-arguments.js +4 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/commands.js +16 -7
- package/vendor/node_modules/@legendapp/spark-cli/dist/dependency-pins.js +19 -3
- package/vendor/node_modules/@legendapp/spark-cli/dist/dev-command.js +2 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/dev.js +3 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/enriched-html-pins.js +2 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/errors.js +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/index.js +57 -9
- package/vendor/node_modules/@legendapp/spark-cli/dist/init-template.cjs +12 -2
- package/vendor/node_modules/@legendapp/spark-cli/dist/init-template.d.cts +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/metro.cjs +1 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/migrate.js +65 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/migration-helpers.cjs +4 -4
- package/vendor/node_modules/@legendapp/spark-cli/dist/migration-helpers.d.cts +2 -2
- package/vendor/node_modules/@legendapp/spark-cli/dist/migrations.cjs +15 -8
- package/vendor/node_modules/@legendapp/spark-cli/dist/native-patch-preflight.js +35 -7
- package/vendor/node_modules/@legendapp/spark-cli/dist/package.js +4 -8
- package/vendor/node_modules/@legendapp/spark-cli/dist/patch.js +92 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/project-version.js +12 -4
- package/vendor/node_modules/@legendapp/spark-cli/dist/project.js +8 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/publish-directory.js +32 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/release-app.js +139 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/release.json +17 -17
- package/vendor/node_modules/@legendapp/spark-cli/dist/signing.js +61 -41
- package/vendor/node_modules/@legendapp/spark-cli/dist/upgrade.js +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/windows.js +3 -0
- package/vendor/node_modules/@legendapp/spark-cli/package.json +5 -4
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-clipboard/macos/RNDesktopClipboard.mm +1 -1
- package/vendor/node_modules/@legendapp/spark-clipboard/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-clipboard/src/desktop.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-codex/package.json +3 -7
- package/vendor/node_modules/@legendapp/spark-commands/package.json +5 -5
- package/vendor/node_modules/@legendapp/spark-context-menu/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.h +3 -1
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.mm +51 -10
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkStorage.h +4 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkStorage.mm +82 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkTestDriver.h +2 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkTestDriver.mm +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/package.json +2 -8
- package/vendor/node_modules/@legendapp/spark-desktop-config/app.plugin.cjs +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/config.cjs +6 -8
- package/vendor/node_modules/@legendapp/spark-desktop-config/identity.cjs +2 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.cjs +300 -71
- package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.d.cts +7 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-desktop-config/patch-registry.cjs +318 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/patch-registry.d.cts +20 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/rpaths.cjs +20 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/rpaths.d.cts +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/validation.cjs +66 -9
- package/vendor/node_modules/@legendapp/spark-desktop-config/windows.plugin.cjs +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-host/AppDelegate.mm +17 -5
- package/vendor/node_modules/@legendapp/spark-desktop-host/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-desktop-links/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/RNDesktopWindows.mm +7 -2
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/RNWindowManager.mm +235 -240
- package/vendor/node_modules/@legendapp/spark-desktop-windows/package.json +4 -11
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/api.ts +9 -3
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/macos-adapter.ts +7 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/types.ts +32 -3
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/validation.ts +28 -11
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/createWindowsNavigator.tsx +15 -3
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/primaryWindowLifecycle.ts +12 -3
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/usePrimaryWindowLifecycle.ts +2 -1
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/useWindowFocusEffect.ts +4 -1
- package/vendor/node_modules/@legendapp/spark-documents/package.json +7 -7
- package/vendor/node_modules/@legendapp/spark-drag-drop/macos/RNDesktopDragView.mm +77 -17
- package/vendor/node_modules/@legendapp/spark-drag-drop/package.json +3 -8
- package/vendor/node_modules/@legendapp/spark-drag-drop/src/DesktopDragViewNativeComponent.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-drag-drop/src/contracts.ts +13 -4
- package/vendor/node_modules/@legendapp/spark-drag-drop/src/index.tsx +5 -3
- package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/SparkDragDrop.h +6 -1
- package/vendor/node_modules/@legendapp/spark-expo-compat/metro.cjs +44 -0
- package/vendor/node_modules/@legendapp/spark-expo-compat/package.json +20 -0
- package/vendor/node_modules/@legendapp/spark-expo-compat/src/clipboard.ts +40 -0
- package/vendor/node_modules/@legendapp/spark-expo-compat/src/document-picker.ts +52 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/options.ts +5 -2
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/types.ts +3 -3
- package/vendor/node_modules/@legendapp/spark-file-system/macos/RNDesktopFileSystem.mm +1 -1
- package/vendor/node_modules/@legendapp/spark-file-system/package.json +3 -11
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-html/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-markdown/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-message-dialog/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-message-dialog/src/index.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-native-menu/package.json +3 -9
- package/vendor/node_modules/@legendapp/spark-native-menu/src/hooks.ts +4 -0
- package/vendor/node_modules/@legendapp/spark-notifications/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-processes/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-rich-text/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-secure-storage/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-settings/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-settings-ui/package.json +4 -4
- package/vendor/node_modules/@legendapp/spark-settings-ui/src/index.tsx +122 -334
- package/vendor/node_modules/@legendapp/spark-settings-ui/src/rows.tsx +183 -0
- package/vendor/node_modules/@legendapp/spark-sqlite/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-system/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-tray/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-tray/src/index.ts +2 -1
- package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkButton.mm +82 -14
- package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkTextInput.h +1 -1
- package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkTextInput.mm +94 -11
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSidebarSplitViewComponent.mm +235 -18
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkPaneSplitView.h +17 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkPaneSplitView.mm +216 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkSplitViewComponent.h +4 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkSplitViewComponent.mm +212 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkSplitViewUpdates.h +6 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSegmentedControl.mm +28 -13
- package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSelect.mm +17 -1
- package/vendor/node_modules/@legendapp/spark-ui/macos/popover/RNSparkPopover.h +9 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/popover/RNSparkPopover.mm +126 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/progress/RNSparkProgressIndicator.h +9 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/progress/RNSparkProgressIndicator.mm +66 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/radio-group/RNSparkRadioGroup.h +9 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/radio-group/RNSparkRadioGroup.mm +118 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/sf-symbol/RNSFSymbol.mm +4 -12
- package/vendor/node_modules/@legendapp/spark-ui/macos/sheet/RNSparkSheet.h +9 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/sheet/RNSparkSheet.mm +109 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/sidebar/RNSidebar.mm +438 -102
- package/vendor/node_modules/@legendapp/spark-ui/macos/table/RNSparkTable.h +9 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/table/RNSparkTable.mm +179 -0
- package/vendor/node_modules/@legendapp/spark-ui/package.json +9 -8
- package/vendor/node_modules/@legendapp/spark-ui/src/SparkButtonNativeComponent.ts +10 -2
- package/vendor/node_modules/@legendapp/spark-ui/src/SparkTextInputNativeComponent.ts +2 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SidebarSplitViewNativeComponent.ts +9 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SplitView.tsx +99 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SplitViewNativeComponent.ts +29 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/index.tsx +34 -17
- package/vendor/node_modules/@legendapp/spark-ui/src/availability.ts +6 -4
- package/vendor/node_modules/@legendapp/spark-ui/src/checkbox-unavailable.tsx +20 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/control.ts +24 -3
- package/vendor/node_modules/@legendapp/spark-ui/src/desktop.tsx +72 -20
- package/vendor/node_modules/@legendapp/spark-ui/src/index.android.tsx +18 -12
- package/vendor/node_modules/@legendapp/spark-ui/src/index.ios.tsx +21 -15
- package/vendor/node_modules/@legendapp/spark-ui/src/index.web.tsx +40 -16
- package/vendor/node_modules/@legendapp/spark-ui/src/mobile-input.tsx +2 -2
- package/vendor/node_modules/@legendapp/spark-ui/src/native-select/NativeSegmentedControlNativeComponent.ts +3 -1
- package/vendor/node_modules/@legendapp/spark-ui/src/native-select/NativeSelectNativeComponent.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/popover/PopoverNativeComponent.ts +20 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/popover/index.tsx +45 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/progress/ProgressIndicatorNativeComponent.ts +13 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/progress/index.tsx +32 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/radio-group/RadioGroupNativeComponent.ts +17 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/select.ts +4 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/sheet/SheetNativeComponent.ts +15 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/sheet/index.tsx +38 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/SidebarItemNativeComponent.ts +9 -1
- package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/SidebarNativeComponent.ts +17 -2
- package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/index.tsx +106 -22
- package/vendor/node_modules/@legendapp/spark-ui/src/switch.tsx +13 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/table/TableNativeComponent.ts +22 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/table/index.tsx +118 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/types.ts +52 -7
- package/vendor/node_modules/@legendapp/spark-ui/uniwind.ts +3 -1
- package/vendor/node_modules/@legendapp/spark-ui/uniwind.web.ts +2 -1
- package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/SparkUI.h +46 -15
- package/vendor/node_modules/@legendapp/spark-updates/package.json +3 -9
- package/vendor/node_modules/@legendapp/spark-webview/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-window-options/package.json +1 -1
- /package/{settings-window.ts → ui-settings.ts} +0 -0
package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkPaneSplitView.mm
ADDED
|
@@ -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
|
package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkSplitViewComponent.mm
ADDED
|
@@ -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 ¤t = _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
|
package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSegmentedControl.mm
CHANGED
|
@@ -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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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,8 +157,17 @@ 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()];
|
|
170
|
+
_segmentedControl.accessibilityHelp = [NSString stringWithUTF8String:newProps.accessibilityHint.c_str()];
|
|
158
171
|
_segmentedControl.accessibilityIdentifier = [NSString stringWithUTF8String:newProps.testId.c_str()];
|
|
159
172
|
#endif
|
|
160
173
|
[super updateProps:props oldProps:oldProps];
|
|
@@ -165,11 +178,13 @@ using namespace facebook::react;
|
|
|
165
178
|
[super prepareForRecycle];
|
|
166
179
|
#if TARGET_OS_OSX
|
|
167
180
|
_values = @[];
|
|
181
|
+
_labels = @[];
|
|
168
182
|
_segmentsJson = @"";
|
|
169
183
|
_value = @"";
|
|
170
184
|
_isUpdatingSelection = NO;
|
|
171
185
|
_segmentedControl.segmentCount = 0;
|
|
172
186
|
_segmentedControl.enabled = YES;
|
|
187
|
+
_segmentedControl.accessibilityHelp = nil;
|
|
173
188
|
_segmentedControl.accessibilityLabel = nil; _segmentedControl.accessibilityIdentifier = nil;
|
|
174
189
|
#endif
|
|
175
190
|
}
|
|
@@ -140,11 +140,15 @@ using namespace facebook::react;
|
|
|
140
140
|
[self selectValue:_value];
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
+
_popUpButton.bordered = !newProps.borderless;
|
|
144
|
+
((NSPopUpButtonCell *)_popUpButton.cell).arrowPosition = NSPopUpArrowAtCenter;
|
|
143
145
|
_popUpButton.enabled = newProps.enabled;
|
|
144
146
|
_popUpButton.accessibilityLabel = [NSString stringWithUTF8String:newProps.accessibilityLabel.c_str()];
|
|
147
|
+
_popUpButton.accessibilityHelp = [NSString stringWithUTF8String:newProps.accessibilityHint.c_str()];
|
|
145
148
|
_popUpButton.accessibilityIdentifier = [NSString stringWithUTF8String:newProps.testId.c_str()];
|
|
146
149
|
#endif
|
|
147
150
|
[super updateProps:props oldProps:oldProps];
|
|
151
|
+
[self layoutSubviews];
|
|
148
152
|
}
|
|
149
153
|
|
|
150
154
|
- (void)prepareForRecycle
|
|
@@ -156,6 +160,8 @@ using namespace facebook::react;
|
|
|
156
160
|
_isUpdatingSelection = NO;
|
|
157
161
|
[_popUpButton removeAllItems];
|
|
158
162
|
_popUpButton.enabled = YES;
|
|
163
|
+
_popUpButton.bordered = YES;
|
|
164
|
+
_popUpButton.accessibilityHelp = nil;
|
|
159
165
|
_popUpButton.accessibilityLabel = nil; _popUpButton.accessibilityIdentifier = nil;
|
|
160
166
|
#endif
|
|
161
167
|
}
|
|
@@ -163,7 +169,17 @@ using namespace facebook::react;
|
|
|
163
169
|
- (void)layoutSubviews
|
|
164
170
|
{
|
|
165
171
|
[super layoutSubviews];
|
|
166
|
-
|
|
172
|
+
CGRect frame = self.bounds;
|
|
173
|
+
#if TARGET_OS_OSX
|
|
174
|
+
if (!_popUpButton.isBordered) {
|
|
175
|
+
CGFloat width = _popUpButton.intrinsicContentSize.width;
|
|
176
|
+
if (width > 0 && width < NSWidth(frame)) {
|
|
177
|
+
if (_popUpButton.userInterfaceLayoutDirection == NSUserInterfaceLayoutDirectionLeftToRight) frame.origin.x = NSMaxX(frame) - width;
|
|
178
|
+
frame.size.width = width;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
#endif
|
|
182
|
+
_popUpButton.frame = frame;
|
|
167
183
|
}
|
|
168
184
|
|
|
169
185
|
- (void)updateLayoutMetrics:(const LayoutMetrics &)layoutMetrics
|