@legendapp/spark 0.0.1-next.7 → 0.0.1-next.8
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/package.json +8 -8
- package/schema.json +9 -0
- package/skills/spark/SKILL.md +1 -1
- package/skills/spark/UPGRADING.md +21 -0
- package/vendor/node_modules/@legendapp/spark-ai/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-audio/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-auth-session/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-cli/dist/add-desktop.js +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/build.js +16 -4
- package/vendor/node_modules/@legendapp/spark-cli/dist/create.js +16 -4
- package/vendor/node_modules/@legendapp/spark-cli/dist/init-template.cjs +2 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/macos-release.js +4 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/project.js +10 -4
- package/vendor/node_modules/@legendapp/spark-cli/dist/release-driver.js +35 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/release.json +18 -18
- package/vendor/node_modules/@legendapp/spark-cli/dist/updates.js +18 -8
- package/vendor/node_modules/@legendapp/spark-cli/dist/windows.js +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/package.json +4 -4
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/app.json +5 -1
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/gitignore +2 -1
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/package.json +7 -7
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/app.json +5 -1
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/gitignore +2 -1
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/package.json +8 -8
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/app.json +5 -1
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/gitignore +2 -1
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/package.json +8 -8
- package/vendor/node_modules/@legendapp/spark-clipboard/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-codex/cpp/HybridCodexAppServer.mm +88 -76
- package/vendor/node_modules/@legendapp/spark-codex/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-commands/package.json +5 -5
- package/vendor/node_modules/@legendapp/spark-context-menu/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-desktop-app/RNDesktopApp.podspec +12 -1
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/RNDesktopApp.mm +8 -1
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.h +8 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.mm +84 -21
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkInstance.h +27 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkInstance.mm +207 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkTestDriver.h +44 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkTestDriver.mm +349 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkWindow.mm +3 -1
- package/vendor/node_modules/@legendapp/spark-desktop-app/package.json +1 -1
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/api.ts +39 -6
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/contracts/menu.ts +21 -7
- package/vendor/node_modules/@legendapp/spark-desktop-config/accessibility-state.cjs +50 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/app.plugin.cjs +9 -1
- package/vendor/node_modules/@legendapp/spark-desktop-config/autolinking.cjs +8 -1
- package/vendor/node_modules/@legendapp/spark-desktop-config/config.cjs +1 -1
- package/vendor/node_modules/@legendapp/spark-desktop-config/config.d.cts +7 -1
- package/vendor/node_modules/@legendapp/spark-desktop-config/package.json +4 -4
- package/vendor/node_modules/@legendapp/spark-desktop-config/rtl-scroll-view.cjs +144 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/rtl-text-alignment.cjs +60 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/rtl-text-input-alignment.cjs +112 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/schema.json +9 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/test-driver.cjs +11 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/test-driver.d.cts +2 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/text-input-accessibility.cjs +47 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/updates.cjs +4 -2
- package/vendor/node_modules/@legendapp/spark-desktop-config/validation.cjs +2 -1
- package/vendor/node_modules/@legendapp/spark-desktop-config/windows.plugin.cjs +1 -1
- package/vendor/node_modules/@legendapp/spark-desktop-host/AppDelegate.mm +18 -6
- package/vendor/node_modules/@legendapp/spark-desktop-host/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-desktop-host/windows/application.inc +61 -15
- package/vendor/node_modules/@legendapp/spark-desktop-host/windows/launch.inc +67 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-desktop-windows/RNDesktopWindows.podspec +3 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/RNDesktopWindows.mm +5 -2
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/RNWindowManager.mm +22 -3
- package/vendor/node_modules/@legendapp/spark-desktop-windows/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-documents/package.json +7 -7
- package/vendor/node_modules/@legendapp/spark-drag-drop/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-file-dialog/RNFileDialog.podspec +1 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/ios/RNFileDialog.mm +153 -64
- package/vendor/node_modules/@legendapp/spark-file-dialog/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/index.ts +19 -7
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/native.ts +5 -1
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/options.ts +42 -4
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/types.ts +18 -2
- package/vendor/node_modules/@legendapp/spark-file-system/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/package.json +2 -2
- 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-markdown/src/Markdown.tsx +2 -1
- package/vendor/node_modules/@legendapp/spark-message-dialog/macos/RNDesktopMessageDialog.mm +113 -12
- package/vendor/node_modules/@legendapp/spark-message-dialog/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-message-dialog/src/index.ts +110 -14
- package/vendor/node_modules/@legendapp/spark-native-menu/ios/RNNativeMenu.mm +116 -8
- package/vendor/node_modules/@legendapp/spark-native-menu/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-native-menu/src/api.ts +63 -18
- package/vendor/node_modules/@legendapp/spark-native-menu/src/hooks.ts +9 -3
- package/vendor/node_modules/@legendapp/spark-notifications/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-processes/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-rich-text/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-secure-storage/package.json +2 -2
- 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 +5 -2
- package/vendor/node_modules/@legendapp/spark-sqlite/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-system/macos/RNDesktopSystem.mm +13 -3
- package/vendor/node_modules/@legendapp/spark-system/macos/SparkAppearancePreferences.h +9 -0
- package/vendor/node_modules/@legendapp/spark-system/macos/SparkAppearancePreferences.mm +31 -0
- package/vendor/node_modules/@legendapp/spark-system/macos/SparkDockTile.h +24 -0
- package/vendor/node_modules/@legendapp/spark-system/macos/SparkDockTile.mm +101 -0
- package/vendor/node_modules/@legendapp/spark-system/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-system/src/index.ts +73 -7
- package/vendor/node_modules/@legendapp/spark-tray/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkButton.mm +2 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkLayoutDirection.h +17 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkTextInput.mm +6 -1
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSidebarSplitViewComponent.mm +55 -8
- package/vendor/node_modules/@legendapp/spark-ui/macos/glass-effect-view/RNGlassEffectView.mm +11 -7
- package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSegmentedControl.mm +4 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSelect.mm +4 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/sf-symbol/RNSFSymbol.mm +4 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/sidebar/RNSidebar.mm +77 -14
- package/vendor/node_modules/@legendapp/spark-ui/macos/swipe-actions/RNSwipeActions.mm +31 -7
- package/vendor/node_modules/@legendapp/spark-ui/macos/text-input-search/RNTextInputSearch.mm +25 -1
- package/vendor/node_modules/@legendapp/spark-ui/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/SidebarNativeComponent.ts +5 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/index.tsx +19 -8
- package/vendor/node_modules/@legendapp/spark-updates/macos/RNDesktopUpdates.mm +25 -13
- package/vendor/node_modules/@legendapp/spark-updates/macos/SparkUpdateState.h +39 -0
- package/vendor/node_modules/@legendapp/spark-updates/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-updates/src/index.ts +45 -9
- package/vendor/node_modules/@legendapp/spark-webview/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-window-options/package.json +1 -1
|
@@ -15,15 +15,46 @@ export type TaskbarMenuItem = SupportedTaskbarLeaf;
|
|
|
15
15
|
type LauncherMenuOptions = { items: readonly MenuItem[]; onAction: (event: { type: "action"; itemId: string }) => void };
|
|
16
16
|
export interface DockMenuOptions { items: readonly DockMenuItem[]; onAction: (event: { type: "action"; itemId: string }) => void }
|
|
17
17
|
export interface TaskbarMenuOptions { items: readonly TaskbarMenuItem[]; onAction: (event: { type: "action"; itemId: string }) => void }
|
|
18
|
+
/** Determinate progress has a completed fraction from 0 to 1; paused and error tint the bar. */
|
|
19
|
+
export type AppProgress = { state: "indeterminate" } | { state: "normal" | "paused" | "error"; value: number };
|
|
20
|
+
export type SystemFeature = "appBadge" | "appProgress" | "attention" | "dockMenu" | "taskbarMenu" | "appearancePreferences";
|
|
18
21
|
export interface SystemInfo { osVersion: string; architecture: string; locale: string; dark: boolean; idleSeconds: number; onBattery: boolean; batteryLevel: number | null }
|
|
19
|
-
|
|
22
|
+
/** The user's appearance and accessibility display settings (macOS). Colors are sRGB `#rrggbb`. */
|
|
23
|
+
export interface AppearancePreferences {
|
|
24
|
+
/** System Settings > Appearance. The app can still render otherwise: see getSystemInfo().dark for its effective appearance. */
|
|
25
|
+
appearance: "light" | "dark";
|
|
26
|
+
/** Appearance is Auto: it follows the time of day. */
|
|
27
|
+
automaticAppearance: boolean;
|
|
28
|
+
/** The accent color controls use, in the app's effective appearance. */
|
|
29
|
+
accentColor: string;
|
|
30
|
+
/** The text selection (highlight) color, in the app's effective appearance. */
|
|
31
|
+
highlightColor: string;
|
|
32
|
+
increaseContrast: boolean;
|
|
33
|
+
reduceTransparency: boolean;
|
|
34
|
+
reduceMotion: boolean;
|
|
35
|
+
differentiateWithoutColor: boolean;
|
|
36
|
+
invertColors: boolean;
|
|
37
|
+
/** Keyboard navigation (System Settings > Keyboard), which moves focus between all controls. It has no change event. */
|
|
38
|
+
keyboardNavigation: boolean;
|
|
39
|
+
}
|
|
40
|
+
/** Invalidations: query getSystemInfo() or getAppearancePreferences() again for current values. `systemColorsChanged` and `accessibilityDisplayChanged` are macOS-only. */
|
|
41
|
+
export type SystemEvent = { type: "sleep" | "wake" | "lock" | "unlock" | "powerChanged" | "appearanceChanged" | "displaysChanged" | "systemColorsChanged" | "accessibilityDisplayChanged" };
|
|
20
42
|
export type LoginItemStatus = "enabled" | "disabled" | "requiresApproval" | "notFound" | "unavailable";
|
|
21
43
|
export interface AttentionOptions { kind?: "informational" | "critical" }
|
|
22
44
|
export interface PreventSleepOptions { reason: string; kind?: "display" | "system" }
|
|
23
45
|
let sequence = 0;
|
|
24
46
|
const token = () => `system-${Date.now()}-${++sequence}`;
|
|
25
|
-
|
|
47
|
+
const FEATURES: Record<SystemFeature, readonly string[]> = {
|
|
48
|
+
appBadge: ["macos", "windows"], appProgress: ["macos"], attention: ["macos", "windows"],
|
|
49
|
+
dockMenu: ["macos"], taskbarMenu: ["windows"],
|
|
50
|
+
// Windows appearance preferences are #342.
|
|
51
|
+
appearancePreferences: ["macos"],
|
|
52
|
+
};
|
|
53
|
+
/** Without a feature, whether the system module is usable at all. */
|
|
54
|
+
export function getSystemAvailability(feature?: SystemFeature): Availability {
|
|
55
|
+
if (feature !== undefined && !Object.hasOwn(FEATURES, feature)) throw new SparkError("E_INVALID_ARGUMENT", "Unknown system feature");
|
|
26
56
|
if (Platform.OS !== "macos" && Platform.OS !== "windows") return { available: false, reason: "unsupported-platform" };
|
|
57
|
+
if (feature && !FEATURES[feature].includes(Platform.OS)) return { available: false, reason: "unsupported-platform" };
|
|
27
58
|
return Native ? { available: true } : { available: false, reason: "missing-module" };
|
|
28
59
|
}
|
|
29
60
|
async function call<T>(method: string, args: object, validate: (value: unknown) => value is T): Promise<T> {
|
|
@@ -42,15 +73,50 @@ function isInfo(value: unknown): value is SystemInfo {
|
|
|
42
73
|
return [info.osVersion, info.architecture, info.locale].every(value => typeof value === "string" && value.length > 0) && typeof info.dark === "boolean" && typeof info.onBattery === "boolean" && Number.isFinite(info.idleSeconds) && info.idleSeconds >= 0 && (info.batteryLevel === null || (typeof info.batteryLevel === "number" && Number.isFinite(info.batteryLevel) && info.batteryLevel >= 0 && info.batteryLevel <= 1));
|
|
43
74
|
}
|
|
44
75
|
export function getSystemInfo(): Promise<SystemInfo> { return call("info", {}, isInfo); }
|
|
76
|
+
const HEX = /^#[0-9a-f]{6}$/;
|
|
77
|
+
const PREFERENCE_FLAGS = ["automaticAppearance", "increaseContrast", "reduceTransparency", "reduceMotion", "differentiateWithoutColor", "invertColors", "keyboardNavigation"] as const;
|
|
78
|
+
function isPreferences(value: unknown): value is AppearancePreferences {
|
|
79
|
+
if (!value || typeof value !== "object") return false;
|
|
80
|
+
const preferences = value as AppearancePreferences;
|
|
81
|
+
return (preferences.appearance === "light" || preferences.appearance === "dark") && HEX.test(preferences.accentColor) && HEX.test(preferences.highlightColor)
|
|
82
|
+
&& PREFERENCE_FLAGS.every(key => typeof preferences[key] === "boolean");
|
|
83
|
+
}
|
|
84
|
+
/** The user's appearance and accessibility display settings (macOS). `systemColorsChanged`, `accessibilityDisplayChanged` and `appearanceChanged` invalidate them. */
|
|
85
|
+
export async function getAppearancePreferences(): Promise<AppearancePreferences> {
|
|
86
|
+
const available = getSystemAvailability("appearancePreferences");
|
|
87
|
+
if (!available.available) throw new SparkError(available.reason === "missing-module" ? "E_MODULE_UNAVAILABLE" : "E_UNSUPPORTED_PLATFORM", "Appearance preferences are unavailable");
|
|
88
|
+
return call("preferences", {}, isPreferences);
|
|
89
|
+
}
|
|
45
90
|
export function getLoginItemStatus(): Promise<LoginItemStatus> { return call("loginStatus", {}, (value): value is LoginItemStatus => typeof value === "string" && ["enabled", "disabled", "requiresApproval", "notFound", "unavailable"].includes(value)); }
|
|
46
91
|
export async function setLaunchAtLogin(enabled: boolean): Promise<void> {
|
|
47
92
|
if (typeof enabled !== "boolean") throw new SparkError("E_INVALID_ARGUMENT", "Expected enabled boolean");
|
|
48
93
|
await command("login", { enabled });
|
|
49
94
|
}
|
|
50
|
-
/**
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Dock badge on macOS, taskbar overlay icon on Windows; an empty string clears it. A count (macOS only)
|
|
97
|
+
* is formatted with the user's locale, and 0 clears it.
|
|
98
|
+
*/
|
|
99
|
+
export async function setAppBadge(value: string | number): Promise<void> {
|
|
100
|
+
if (typeof value === "number") {
|
|
101
|
+
if (!Number.isSafeInteger(value) || value < 0) throw new SparkError("E_INVALID_ARGUMENT", "Expected a badge count that is a non-negative integer");
|
|
102
|
+
if (Platform.OS !== "macos") throw new SparkError("E_UNSUPPORTED_PLATFORM", "Badge counts require macOS");
|
|
103
|
+
await command("badge", { count: value });
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (typeof value !== "string" || value.includes("\0")) throw new SparkError("E_INVALID_ARGUMENT", "Expected badge text without NUL");
|
|
107
|
+
await command("badge", { label: value });
|
|
108
|
+
}
|
|
109
|
+
/** Progress on the Dock tile (macOS only); null clears it. */
|
|
110
|
+
export async function setAppProgress(progress: AppProgress | null): Promise<void> {
|
|
111
|
+
if (Platform.OS !== "macos") throw new SparkError("E_UNSUPPORTED_PLATFORM", "App progress requires macOS");
|
|
112
|
+
if (progress === null) { await command("progress", { state: "none" }); return; }
|
|
113
|
+
const state = progress?.state;
|
|
114
|
+
if (state === "indeterminate") { options(progress, ["state"]); await command("progress", { state }); return; }
|
|
115
|
+
if (state !== "normal" && state !== "paused" && state !== "error") throw new SparkError("E_INVALID_ARGUMENT", "Unknown progress state");
|
|
116
|
+
options(progress, ["state", "value"]);
|
|
117
|
+
const { value } = progress as { value: unknown };
|
|
118
|
+
if (typeof value !== "number" || !(value >= 0 && value <= 1)) throw new SparkError("E_INVALID_ARGUMENT", "Progress value must be from 0 to 1");
|
|
119
|
+
await command("progress", { state, value });
|
|
54
120
|
}
|
|
55
121
|
export async function requestAttention(value: AttentionOptions = {}): Promise<AsyncRegistration> {
|
|
56
122
|
options(value, ["kind"]);
|
|
@@ -84,7 +150,7 @@ export function createDockMenu(options: DockMenuOptions): Promise<AsyncRegistrat
|
|
|
84
150
|
export function createTaskbarMenu(options: TaskbarMenuOptions): Promise<AsyncRegistration> { return createLauncherMenu(options, "windows"); }
|
|
85
151
|
export async function onSystemEvent(handler: (event: SystemEvent) => void): Promise<AsyncRegistration> {
|
|
86
152
|
if (typeof handler !== "function") throw new SparkError("E_INVALID_ARGUMENT", "Expected system event handler");
|
|
87
|
-
const types: readonly SystemEvent["type"][] = ["sleep", "wake", "lock", "unlock", "powerChanged", "appearanceChanged", "displaysChanged"];
|
|
153
|
+
const types: readonly SystemEvent["type"][] = ["sleep", "wake", "lock", "unlock", "powerChanged", "appearanceChanged", "displaysChanged", "systemColorsChanged", "accessibilityDisplayChanged"];
|
|
88
154
|
const id = token(); let stopped = false;
|
|
89
155
|
const subscription = onDesktopEvent(event => { if (!stopped && types.includes(event.type as SystemEvent["type"])) handler({ type: event.type as SystemEvent["type"] }); }, { types });
|
|
90
156
|
try { await command("observe", { id }); } catch (error) { subscription.remove(); throw error; }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legendapp/spark-tray",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"react-native": "src/index.ts",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
]
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@legendapp/spark-desktop-app": "0.0.1-next.
|
|
43
|
+
"@legendapp/spark-desktop-app": "0.0.1-next.8"
|
|
44
44
|
},
|
|
45
45
|
"private": true
|
|
46
46
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#import "RNSparkButton.h"
|
|
2
|
+
#import "RNSparkLayoutDirection.h"
|
|
2
3
|
#import <react/renderer/components/RNSparkUISpec/ComponentDescriptors.h>
|
|
3
4
|
#import <react/renderer/components/RNSparkUISpec/EventEmitters.h>
|
|
4
5
|
#import <react/renderer/components/RNSparkUISpec/Props.h>
|
|
@@ -37,6 +38,7 @@ using namespace facebook::react;
|
|
|
37
38
|
- (void)layoutSubviews { [super layoutSubviews]; _button.frame = self.bounds; }
|
|
38
39
|
- (void)updateLayoutMetrics:(const LayoutMetrics &)layoutMetrics oldLayoutMetrics:(const LayoutMetrics &)oldLayoutMetrics {
|
|
39
40
|
[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
|
|
41
|
+
_button.userInterfaceLayoutDirection = RNSparkLayoutDirection(layoutMetrics);
|
|
40
42
|
[self layoutSubviews];
|
|
41
43
|
}
|
|
42
44
|
- (void)prepareForRecycle {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#import <AppKit/AppKit.h>
|
|
2
|
+
#import <react/renderer/core/LayoutMetrics.h>
|
|
3
|
+
|
|
4
|
+
// Fabric resolves each node's layout direction, including one inherited from a React `direction` style.
|
|
5
|
+
// AppKit views take the app's direction instead, so every Spark component view that hosts AppKit views
|
|
6
|
+
// applies this one to them from updateLayoutMetrics.
|
|
7
|
+
static inline NSUserInterfaceLayoutDirection RNSparkLayoutDirection(const facebook::react::LayoutMetrics &layoutMetrics)
|
|
8
|
+
{
|
|
9
|
+
return layoutMetrics.layoutDirection == facebook::react::LayoutDirection::RightToLeft
|
|
10
|
+
? NSUserInterfaceLayoutDirectionRightToLeft : NSUserInterfaceLayoutDirectionLeftToRight;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// AppKit resolves natural text alignment from the app's language, not from the view's direction.
|
|
14
|
+
static inline NSTextAlignment RNSparkLeadingTextAlignment(NSUserInterfaceLayoutDirection direction)
|
|
15
|
+
{
|
|
16
|
+
return direction == NSUserInterfaceLayoutDirectionRightToLeft ? NSTextAlignmentRight : NSTextAlignmentLeft;
|
|
17
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#import "RNSparkTextInput.h"
|
|
2
|
+
#import "RNSparkLayoutDirection.h"
|
|
2
3
|
#import <react/renderer/components/RNSparkUISpec/ComponentDescriptors.h>
|
|
3
4
|
#import <react/renderer/components/RNSparkUISpec/EventEmitters.h>
|
|
4
5
|
#import <react/renderer/components/RNSparkUISpec/Props.h>
|
|
@@ -42,7 +43,11 @@ using namespace facebook::react;
|
|
|
42
43
|
}
|
|
43
44
|
- (void)layoutSubviews { [super layoutSubviews]; _field.frame = self.bounds; }
|
|
44
45
|
- (void)updateLayoutMetrics:(const LayoutMetrics &)layoutMetrics oldLayoutMetrics:(const LayoutMetrics &)oldLayoutMetrics {
|
|
45
|
-
[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
|
|
46
|
+
[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
|
|
47
|
+
NSUserInterfaceLayoutDirection direction = RNSparkLayoutDirection(layoutMetrics);
|
|
48
|
+
_field.alignment = RNSparkLeadingTextAlignment(direction);
|
|
49
|
+
_field.userInterfaceLayoutDirection = direction;
|
|
50
|
+
[self layoutSubviews];
|
|
46
51
|
}
|
|
47
52
|
- (void)prepareForRecycle {
|
|
48
53
|
[_field abortEditing];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#import "RNSidebarSplitViewComponent.h"
|
|
2
|
+
#import "RNSparkLayoutDirection.h"
|
|
2
3
|
|
|
3
4
|
#import <react/renderer/components/RNSparkUISpec/ComponentDescriptors.h>
|
|
4
5
|
#import <react/renderer/components/RNSparkUISpec/EventEmitters.h>
|
|
@@ -934,6 +935,13 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
934
935
|
});
|
|
935
936
|
}
|
|
936
937
|
|
|
938
|
+
// AppKit hosts each pane in its own item wrapper, so a frame in split-view coordinates is converted
|
|
939
|
+
// to the wrapper's. A pane outside the split (the list while it has no column) takes it as is.
|
|
940
|
+
- (void)setPane:(NSView *)pane splitViewFrame:(CGRect)frame
|
|
941
|
+
{
|
|
942
|
+
pane.frame = pane.superview ? [_splitViewController.splitView convertRect:frame toView:pane.superview] : frame;
|
|
943
|
+
}
|
|
944
|
+
|
|
937
945
|
- (BOOL)applyEstimatedSplitViewLayoutForBounds:(CGRect)bounds layoutReady:(BOOL)layoutReady
|
|
938
946
|
{
|
|
939
947
|
if (bounds.size.width <= 0 || bounds.size.height <= 0) {
|
|
@@ -955,11 +963,18 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
955
963
|
listWidth = 0;
|
|
956
964
|
}
|
|
957
965
|
|
|
966
|
+
// The offsets above run from the leading edge, as AppKit's split view lays out panes.
|
|
967
|
+
CGFloat sidebarX = 0;
|
|
968
|
+
if (_splitViewController.splitView.userInterfaceLayoutDirection == NSUserInterfaceLayoutDirectionRightToLeft) {
|
|
969
|
+
sidebarX = bounds.size.width - sidebarWidth;
|
|
970
|
+
listX = bounds.size.width - listX - listWidth;
|
|
971
|
+
contentX = bounds.size.width - contentX - contentWidth;
|
|
972
|
+
}
|
|
958
973
|
_splitViewController.view.frame = bounds;
|
|
959
974
|
_splitViewController.splitView.frame = bounds;
|
|
960
|
-
_sidebarContainer
|
|
961
|
-
_listContainer
|
|
962
|
-
_contentContainer
|
|
975
|
+
[self setPane:_sidebarContainer splitViewFrame:CGRectMake(sidebarX, 0, sidebarWidth, bounds.size.height)];
|
|
976
|
+
[self setPane:_listContainer splitViewFrame:CGRectMake(listX, 0, listWidth, bounds.size.height)];
|
|
977
|
+
[self setPane:_contentContainer splitViewFrame:CGRectMake(contentX, 0, contentWidth, bounds.size.height)];
|
|
963
978
|
|
|
964
979
|
CGRect sidebarBounds = CGRectMake(0, 0, sidebarWidth, bounds.size.height);
|
|
965
980
|
CGRect contentBounds = CGRectMake(0, 0, contentWidth, bounds.size.height);
|
|
@@ -1090,6 +1105,26 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
1090
1105
|
[self publishSplitViewLayoutAllowEstimatedReady:NO];
|
|
1091
1106
|
}
|
|
1092
1107
|
|
|
1108
|
+
// Each item view lays its pane out by its own direction, not the split view's. macOS 26 floats the sidebar
|
|
1109
|
+
// pane in glass inset from the item's outer edge, and places it from the item's direction when the item
|
|
1110
|
+
// moves into a window, so a split already in one is re-hosted to place it again.
|
|
1111
|
+
- (void)updateItemLayoutDirection
|
|
1112
|
+
{
|
|
1113
|
+
NSUserInterfaceLayoutDirection direction = _splitViewController.splitView.userInterfaceLayoutDirection;
|
|
1114
|
+
BOOL changed = NO;
|
|
1115
|
+
for (NSView *item in _splitViewController.splitView.arrangedSubviews) {
|
|
1116
|
+
if (item.userInterfaceLayoutDirection != direction) {
|
|
1117
|
+
item.userInterfaceLayoutDirection = direction;
|
|
1118
|
+
item.needsLayout = YES;
|
|
1119
|
+
changed = YES;
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
if (changed && self.window) {
|
|
1123
|
+
[_splitViewController.view removeFromSuperview];
|
|
1124
|
+
[self addSubview:_splitViewController.view];
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1093
1128
|
- (void)layoutSplitView
|
|
1094
1129
|
{
|
|
1095
1130
|
if (_layingOutSplitView) {
|
|
@@ -1101,6 +1136,7 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
1101
1136
|
_splitViewController.splitView.frame = bounds;
|
|
1102
1137
|
[self updateSplitItemSizing];
|
|
1103
1138
|
[self updateListItem];
|
|
1139
|
+
[self updateItemLayoutDirection];
|
|
1104
1140
|
[self adoptNativeSidebarCollapsed];
|
|
1105
1141
|
if (_contentContainer.bounds.size.width <= 0 ||
|
|
1106
1142
|
_contentContainer.bounds.size.height <= 0 ||
|
|
@@ -1114,6 +1150,15 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
1114
1150
|
[self publishSplitViewLayoutAllowEstimatedReady:YES];
|
|
1115
1151
|
}
|
|
1116
1152
|
|
|
1153
|
+
- (void)invalidatePublishedLayout
|
|
1154
|
+
{
|
|
1155
|
+
_lastSidebarWidth = -1;
|
|
1156
|
+
_lastContentWidth = -1;
|
|
1157
|
+
_lastListWidth = -1;
|
|
1158
|
+
_lastHeight = -1;
|
|
1159
|
+
_lastLayoutReady = NO;
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1117
1162
|
- (void)updateEventEmitter:(const EventEmitter::Shared &)eventEmitter
|
|
1118
1163
|
{
|
|
1119
1164
|
[super updateEventEmitter:eventEmitter];
|
|
@@ -1326,11 +1371,7 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
1326
1371
|
#if TARGET_OS_OSX
|
|
1327
1372
|
_layingOutSplitView = wasLayingOutSplitView;
|
|
1328
1373
|
if (shouldRelayout || shouldRecreateContentTitlebarMaterial || shouldRecreateSidebarTitlebarMaterial) {
|
|
1329
|
-
|
|
1330
|
-
_lastContentWidth = -1;
|
|
1331
|
-
_lastListWidth = -1;
|
|
1332
|
-
_lastHeight = -1;
|
|
1333
|
-
_lastLayoutReady = NO;
|
|
1374
|
+
[self invalidatePublishedLayout];
|
|
1334
1375
|
[self layoutSplitView];
|
|
1335
1376
|
}
|
|
1336
1377
|
#endif
|
|
@@ -1343,6 +1384,12 @@ static char RNSidebarSplitViewStartupKey;
|
|
|
1343
1384
|
|
|
1344
1385
|
#if TARGET_OS_OSX
|
|
1345
1386
|
_currentLayoutMetrics = layoutMetrics;
|
|
1387
|
+
NSUserInterfaceLayoutDirection direction = RNSparkLayoutDirection(layoutMetrics);
|
|
1388
|
+
if (_splitViewController.splitView.userInterfaceLayoutDirection != direction) {
|
|
1389
|
+
// AppKit mirrors the panes and keeps their widths; only their x positions change.
|
|
1390
|
+
_splitViewController.splitView.userInterfaceLayoutDirection = direction;
|
|
1391
|
+
[self invalidatePublishedLayout];
|
|
1392
|
+
}
|
|
1346
1393
|
[self layoutSplitView];
|
|
1347
1394
|
#else
|
|
1348
1395
|
CGFloat sidebarWidth = self.bounds.size.width * 0.26;
|
package/vendor/node_modules/@legendapp/spark-ui/macos/glass-effect-view/RNGlassEffectView.mm
CHANGED
|
@@ -8,14 +8,21 @@
|
|
|
8
8
|
@property (nonatomic, strong) NSColor *tintColor;
|
|
9
9
|
@end
|
|
10
10
|
|
|
11
|
+
// Fabric frames React children from the top-left, so their container must be flipped.
|
|
12
|
+
@interface SparkGlassContentView : NSView
|
|
13
|
+
@end
|
|
14
|
+
@implementation SparkGlassContentView
|
|
15
|
+
- (BOOL)isFlipped { return YES; }
|
|
16
|
+
@end
|
|
17
|
+
|
|
11
18
|
@implementation SparkGlassView {
|
|
12
|
-
|
|
19
|
+
SparkGlassContentView *_contentContainer;
|
|
13
20
|
NSView *_glassEffectView;
|
|
14
21
|
}
|
|
15
22
|
- (instancetype)initWithFrame:(NSRect)frame {
|
|
16
23
|
if ((self = [super initWithFrame:frame])) {
|
|
17
24
|
_glassStyle = @"regular";
|
|
18
|
-
_contentContainer = [[
|
|
25
|
+
_contentContainer = [[SparkGlassContentView alloc] initWithFrame:self.bounds];
|
|
19
26
|
_contentContainer.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
|
|
20
27
|
if (@available(macOS 26.0, *)) {
|
|
21
28
|
NSGlassEffectView *glass = [[NSGlassEffectView alloc] initWithFrame:self.bounds];
|
|
@@ -36,12 +43,9 @@
|
|
|
36
43
|
_contentContainer.frame = self.bounds;
|
|
37
44
|
_glassEffectView.frame = self.bounds;
|
|
38
45
|
}
|
|
39
|
-
- (void)insertReactSubview:(NSView *)subview atIndex:(NSInteger)index {
|
|
40
|
-
[super insertReactSubview:subview atIndex:index];
|
|
41
|
-
[_contentContainer addSubview:subview];
|
|
42
|
-
}
|
|
43
46
|
- (void)didUpdateReactSubviews {
|
|
44
|
-
// React children
|
|
47
|
+
// The glass content view hosts React children in React order; reactSubviews is nil before the first child.
|
|
48
|
+
_contentContainer.subviews = self.reactSubviews ?: @[];
|
|
45
49
|
}
|
|
46
50
|
- (void)setGlassStyle:(NSString *)style {
|
|
47
51
|
_glassStyle = [style copy];
|
package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSegmentedControl.mm
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#import "RNNativeSegmentedControl.h"
|
|
2
|
+
#import "RNSparkLayoutDirection.h"
|
|
2
3
|
|
|
3
4
|
#import <react/renderer/components/RNSparkUISpec/ComponentDescriptors.h>
|
|
4
5
|
#import <react/renderer/components/RNSparkUISpec/EventEmitters.h>
|
|
@@ -183,6 +184,9 @@ using namespace facebook::react;
|
|
|
183
184
|
oldLayoutMetrics:(const LayoutMetrics &)oldLayoutMetrics
|
|
184
185
|
{
|
|
185
186
|
[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
|
|
187
|
+
#if TARGET_OS_OSX
|
|
188
|
+
_segmentedControl.userInterfaceLayoutDirection = RNSparkLayoutDirection(layoutMetrics);
|
|
189
|
+
#endif
|
|
186
190
|
[self layoutSubviews];
|
|
187
191
|
}
|
|
188
192
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#import "RNNativeSelect.h"
|
|
2
|
+
#import "RNSparkLayoutDirection.h"
|
|
2
3
|
|
|
3
4
|
#import <react/renderer/components/RNSparkUISpec/ComponentDescriptors.h>
|
|
4
5
|
#import <react/renderer/components/RNSparkUISpec/EventEmitters.h>
|
|
@@ -169,6 +170,9 @@ using namespace facebook::react;
|
|
|
169
170
|
oldLayoutMetrics:(const LayoutMetrics &)oldLayoutMetrics
|
|
170
171
|
{
|
|
171
172
|
[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
|
|
173
|
+
#if TARGET_OS_OSX
|
|
174
|
+
_popUpButton.userInterfaceLayoutDirection = RNSparkLayoutDirection(layoutMetrics);
|
|
175
|
+
#endif
|
|
172
176
|
[self layoutSubviews];
|
|
173
177
|
}
|
|
174
178
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#import "RNSFSymbol.h"
|
|
2
|
+
#import "RNSparkLayoutDirection.h"
|
|
2
3
|
|
|
3
4
|
#import <react/renderer/components/RNSparkUISpec/ComponentDescriptors.h>
|
|
4
5
|
#import <react/renderer/components/RNSparkUISpec/Props.h>
|
|
@@ -144,6 +145,9 @@ using namespace facebook::react;
|
|
|
144
145
|
oldLayoutMetrics:(const LayoutMetrics &)oldLayoutMetrics
|
|
145
146
|
{
|
|
146
147
|
[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
|
|
148
|
+
#if TARGET_OS_OSX
|
|
149
|
+
_imageView.userInterfaceLayoutDirection = RNSparkLayoutDirection(layoutMetrics);
|
|
150
|
+
#endif
|
|
147
151
|
[self layoutSubviews];
|
|
148
152
|
}
|
|
149
153
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#import "RNSidebar.h"
|
|
2
|
+
#import "RNSparkLayoutDirection.h"
|
|
2
3
|
|
|
3
4
|
#import <react/renderer/components/RNSparkUISpec/ComponentDescriptors.h>
|
|
4
5
|
#import <react/renderer/components/RNSparkUISpec/EventEmitters.h>
|
|
@@ -22,6 +23,25 @@ static NSUserInterfaceItemIdentifier const RNSidebarDataCellIdentifier = @"RNSid
|
|
|
22
23
|
@implementation RNSidebarDataItem
|
|
23
24
|
@end
|
|
24
25
|
|
|
26
|
+
// A data row's title, inset at both ends and centered vertically, aligned to the row's layout direction.
|
|
27
|
+
@interface RNSidebarDataCell : NSTableCellView
|
|
28
|
+
@end
|
|
29
|
+
|
|
30
|
+
@implementation RNSidebarDataCell
|
|
31
|
+
- (void)layoutTitle
|
|
32
|
+
{
|
|
33
|
+
NSTextField *title = self.textField;
|
|
34
|
+
CGFloat height = title.intrinsicContentSize.height;
|
|
35
|
+
title.alignment = RNSparkLeadingTextAlignment(self.userInterfaceLayoutDirection);
|
|
36
|
+
title.frame = NSMakeRect(12, round((NSHeight(self.bounds) - height) / 2), MAX(0, NSWidth(self.bounds) - 24), height);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
- (void)resizeSubviewsWithOldSize:(NSSize)oldSize
|
|
40
|
+
{
|
|
41
|
+
[self layoutTitle];
|
|
42
|
+
}
|
|
43
|
+
@end
|
|
44
|
+
|
|
25
45
|
@interface RNSidebarRowView : NSTableRowView
|
|
26
46
|
@property (nonatomic, assign) BOOL contextHighlighted;
|
|
27
47
|
@end
|
|
@@ -224,7 +244,9 @@ static NSUserInterfaceItemIdentifier const RNSidebarDataCellIdentifier = @"RNSid
|
|
|
224
244
|
CGFloat _defaultRowHeight;
|
|
225
245
|
NSSize _lastReportedSize;
|
|
226
246
|
NSInteger _contextHighlightedRow;
|
|
247
|
+
CGFloat _lastReportedRowWidth;
|
|
227
248
|
BOOL _updatingSelection;
|
|
249
|
+
BOOL _rightToLeft;
|
|
228
250
|
#else
|
|
229
251
|
RCTPlatformView *_placeholderView;
|
|
230
252
|
#endif
|
|
@@ -243,6 +265,8 @@ static NSUserInterfaceItemIdentifier const RNSidebarDataCellIdentifier = @"RNSid
|
|
|
243
265
|
_defaultRowHeight = 28;
|
|
244
266
|
_lastReportedSize = NSZeroSize;
|
|
245
267
|
_contextHighlightedRow = -1;
|
|
268
|
+
_lastReportedRowWidth = 0;
|
|
269
|
+
_rightToLeft = NO;
|
|
246
270
|
self.wantsLayer = YES;
|
|
247
271
|
[self setupSidebar];
|
|
248
272
|
#else
|
|
@@ -278,6 +302,8 @@ static NSUserInterfaceItemIdentifier const RNSidebarDataCellIdentifier = @"RNSid
|
|
|
278
302
|
if (@available(macOS 11.0, *)) {
|
|
279
303
|
_tableView.style = NSTableViewStyleSourceList;
|
|
280
304
|
}
|
|
305
|
+
// Follows the React layout direction (updateLayoutMetrics), not the application's.
|
|
306
|
+
_tableView.userInterfaceLayoutDirection = NSUserInterfaceLayoutDirectionLeftToRight;
|
|
281
307
|
|
|
282
308
|
_tableColumn = [[NSTableColumn alloc] initWithIdentifier:RNSidebarColumnIdentifier];
|
|
283
309
|
_tableColumn.resizingMask = NSTableColumnAutoresizingMask;
|
|
@@ -442,6 +468,25 @@ static NSUserInterfaceItemIdentifier const RNSidebarDataCellIdentifier = @"RNSid
|
|
|
442
468
|
}
|
|
443
469
|
}
|
|
444
470
|
|
|
471
|
+
// React rows are laid out by Yoga, so their width is reported for the Sidebar to apply: the column the
|
|
472
|
+
// source-list table fits inside its clip view, which excludes the row insets and a legacy scroller.
|
|
473
|
+
- (void)reportRowWidthIfNeeded
|
|
474
|
+
{
|
|
475
|
+
CGFloat width = _tableColumn.width;
|
|
476
|
+
const auto eventEmitter = std::static_pointer_cast<const SidebarEventEmitter>(_eventEmitter);
|
|
477
|
+
if (!eventEmitter || width <= 0 || width == _lastReportedRowWidth) {
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
_lastReportedRowWidth = width;
|
|
482
|
+
eventEmitter->onSidebarRowLayout(SidebarEventEmitter::OnSidebarRowLayout{.width = width});
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
- (void)tableViewColumnDidResize:(NSNotification *)notification
|
|
486
|
+
{
|
|
487
|
+
[self reportRowWidthIfNeeded];
|
|
488
|
+
}
|
|
489
|
+
|
|
445
490
|
- (void)mountChildComponentView:(RCTUIView<RCTComponentViewProtocol> *)childComponentView
|
|
446
491
|
index:(NSInteger)index
|
|
447
492
|
{
|
|
@@ -519,15 +564,13 @@ static NSUserInterfaceItemIdentifier const RNSidebarDataCellIdentifier = @"RNSid
|
|
|
519
564
|
return cell;
|
|
520
565
|
}
|
|
521
566
|
|
|
522
|
-
|
|
567
|
+
RNSidebarDataCell *cell = [tableView makeViewWithIdentifier:RNSidebarDataCellIdentifier owner:self];
|
|
523
568
|
if (!cell) {
|
|
524
|
-
cell = [
|
|
569
|
+
cell = [RNSidebarDataCell new];
|
|
525
570
|
cell.identifier = RNSidebarDataCellIdentifier;
|
|
526
571
|
|
|
527
572
|
NSTextField *textField = [NSTextField labelWithString:@""];
|
|
528
|
-
textField.autoresizingMask = NSViewWidthSizable;
|
|
529
573
|
textField.font = [NSFont systemFontOfSize:13 weight:NSFontWeightRegular];
|
|
530
|
-
textField.frame = NSMakeRect(12, 4, 180, MAX(0, _defaultRowHeight - 8));
|
|
531
574
|
textField.lineBreakMode = NSLineBreakByTruncatingTail;
|
|
532
575
|
textField.textColor = NSColor.labelColor;
|
|
533
576
|
|
|
@@ -535,9 +578,9 @@ static NSUserInterfaceItemIdentifier const RNSidebarDataCellIdentifier = @"RNSid
|
|
|
535
578
|
[cell addSubview:textField];
|
|
536
579
|
}
|
|
537
580
|
|
|
538
|
-
|
|
539
|
-
cell.textField.stringValue =
|
|
540
|
-
cell
|
|
581
|
+
cell.userInterfaceLayoutDirection = _tableView.userInterfaceLayoutDirection;
|
|
582
|
+
cell.textField.stringValue = _dataItems[row].title;
|
|
583
|
+
[cell layoutTitle];
|
|
541
584
|
return cell;
|
|
542
585
|
}
|
|
543
586
|
|
|
@@ -577,18 +620,21 @@ static NSUserInterfaceItemIdentifier const RNSidebarDataCellIdentifier = @"RNSid
|
|
|
577
620
|
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
|
578
621
|
{
|
|
579
622
|
const auto &newProps = *std::static_pointer_cast<SidebarProps const>(props);
|
|
580
|
-
|
|
623
|
+
// Fabric mounts (Insert mutations) pass a null oldProps, possibly to a view that was configured
|
|
624
|
+
// before a move; with nothing to diff against, apply every prop.
|
|
625
|
+
const auto previous = std::static_pointer_cast<SidebarProps const>(oldProps);
|
|
581
626
|
|
|
582
627
|
#if TARGET_OS_OSX
|
|
583
628
|
_contentInsetTop = newProps.contentInsetTop;
|
|
584
629
|
_defaultRowHeight = newProps.defaultRowHeight > 0 ? newProps.defaultRowHeight : 28;
|
|
585
|
-
const BOOL
|
|
586
|
-
|
|
630
|
+
const BOOL itemsChanged = !previous || newProps.itemsJson != previous->itemsJson;
|
|
631
|
+
const BOOL rowsChanged = itemsChanged || newProps.defaultRowHeight != previous->defaultRowHeight;
|
|
632
|
+
if (itemsChanged) _dataItems = [self itemsFromJson:newProps.itemsJson];
|
|
587
633
|
_selectedId = [NSString stringWithUTF8String:newProps.selectedId.c_str()];
|
|
588
634
|
_scrollView.contentInsets = NSEdgeInsetsMake(_contentInsetTop, 0, 0, 0);
|
|
589
635
|
if (rowsChanged) [self reloadRows];
|
|
590
|
-
else if (newProps.selectedId != previous
|
|
591
|
-
if (newProps.contentInsetTop != previous
|
|
636
|
+
else if (newProps.selectedId != previous->selectedId || newProps.selectionRevision != previous->selectionRevision) [self updateSelection];
|
|
637
|
+
if (!previous || newProps.contentInsetTop != previous->contentInsetTop) [self setNeedsLayout:YES];
|
|
592
638
|
#endif
|
|
593
639
|
|
|
594
640
|
[super updateProps:props oldProps:oldProps];
|
|
@@ -598,6 +644,20 @@ static NSUserInterfaceItemIdentifier const RNSidebarDataCellIdentifier = @"RNSid
|
|
|
598
644
|
oldLayoutMetrics:(const LayoutMetrics &)oldLayoutMetrics
|
|
599
645
|
{
|
|
600
646
|
[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
|
|
647
|
+
|
|
648
|
+
#if TARGET_OS_OSX
|
|
649
|
+
// Mirror with the React layout direction, which can differ from the application's. The vertical scroller
|
|
650
|
+
// sits on the trailing edge, which is the left in right-to-left layouts.
|
|
651
|
+
const NSUserInterfaceLayoutDirection direction = RNSparkLayoutDirection(layoutMetrics);
|
|
652
|
+
_scrollView.userInterfaceLayoutDirection = direction;
|
|
653
|
+
const BOOL rightToLeft = direction == NSUserInterfaceLayoutDirectionRightToLeft;
|
|
654
|
+
if (rightToLeft != _rightToLeft) {
|
|
655
|
+
_rightToLeft = rightToLeft;
|
|
656
|
+
_tableView.userInterfaceLayoutDirection = direction;
|
|
657
|
+
[self reloadRows];
|
|
658
|
+
}
|
|
659
|
+
#endif
|
|
660
|
+
|
|
601
661
|
[self layoutSubviews];
|
|
602
662
|
}
|
|
603
663
|
|
|
@@ -606,10 +666,12 @@ static NSUserInterfaceItemIdentifier const RNSidebarDataCellIdentifier = @"RNSid
|
|
|
606
666
|
[super layoutSubviews];
|
|
607
667
|
|
|
608
668
|
#if TARGET_OS_OSX
|
|
669
|
+
// The table keeps its column fitted to the clip view; a column as wide as the Sidebar would push the
|
|
670
|
+
// source-list row insets past its trailing edge.
|
|
609
671
|
_scrollView.frame = self.bounds;
|
|
610
|
-
|
|
611
|
-
[_tableView tile];
|
|
672
|
+
[_scrollView tile];
|
|
612
673
|
[self reportLayoutIfNeeded];
|
|
674
|
+
[self reportRowWidthIfNeeded];
|
|
613
675
|
#else
|
|
614
676
|
_placeholderView.frame = self.bounds;
|
|
615
677
|
#endif
|
|
@@ -630,6 +692,7 @@ static NSUserInterfaceItemIdentifier const RNSidebarDataCellIdentifier = @"RNSid
|
|
|
630
692
|
_contentInsetTop = 0;
|
|
631
693
|
_defaultRowHeight = 28;
|
|
632
694
|
_lastReportedSize = NSZeroSize;
|
|
695
|
+
_lastReportedRowWidth = 0;
|
|
633
696
|
_contextHighlightedRow = -1;
|
|
634
697
|
_updatingSelection = NO;
|
|
635
698
|
_scrollView.contentInsets = NSEdgeInsetsZero;
|