git.iko.soy/rowtype-yoga/purescript-yoga-react-native
on main help sign in
Add batch 2 native macOS components: Checkbox, RadioButton, SearchField, TokenField, Separator, HelpButton, PathControl, Sheet, Menu, TableView, Pasteboard + fix Alert
commitec92ca47e03687f60467579d7b2c04c67a8c360d authorMark <mark.eibes@gmail.com> dateSun 15 Feb 2026, 14:16 (8 months ago) parent9d92844
4 files changed+18−14
example-macos/macos/YogaReactExample-macOS/RCTMacOSControlsManager.m+1 src/Yoga/React/Native/MacOS/Alert.js+1−3 src/Yoga/React/Native/MacOS/Menu.js+7−4 src/Yoga/React/Native/MacOS/Pasteboard.js+9−7
example-macos/macos/YogaReactExample-macOS/RCTMacOSControlsManager.m+1
@@ -1608,6 +1608,7 @@ RCT_EXPORT_METHOD(show:(NSString *)style
16081608 resolver:(RCTPromiseResolveBlock)resolve
16091609 rejecter:(RCTPromiseRejectBlock)reject)
16101610{
1611+ NSLog(@"[MacOSAlertModule] show called: style=%@ title=%@ message=%@ buttons=%@", style, title, message, buttons);
16111612 dispatch_async(dispatch_get_main_queue(), ^{
16121613 NSAlert *alert = [[NSAlert alloc] init];
16131614 alert.messageText = title ?: @"";
src/Yoga/React/Native/MacOS/Alert.js+1−3
@@ -1,8 +1,7 @@
11import { NativeModules, Platform } from "react-native";
22
3−export const alertImpl = (style, title, message, buttons) => () => {
3+export const alertImpl = (style, title, message, buttons) => {
44 if (Platform.OS !== "macos") return;
5− // Try our native module first
65 const mod = NativeModules.MacOSAlertModule;
76 if (mod && mod.show) {
87 mod
@@ -10,7 +9,6 @@ export const alertImpl = (style, title, message, buttons) => () => {
109 .catch((e) => console.error("[macosAlert]", e));
1110 return;
1211 }
13− // Fallback: RN Alert (uses NativeAlertManager internally on macOS)
1412 try {
1513 const { Alert } = require("react-native");
1614 const mapped = buttons.map((b) => ({ text: b }));
src/Yoga/React/Native/MacOS/Menu.js+7−4
@@ -1,11 +1,14 @@
11import { NativeModules, Platform } from "react-native";
22
3−export const showMenuImpl = (items, callback) => () => {
3+export const showMenuImpl = (items, callback) => {
44 if (Platform.OS !== "macos") return;
55 const mod = NativeModules.MacOSMenuModule;
66 if (mod && mod.show) {
7− mod.show(items).then((selectedId) => {
8− if (selectedId) callback(selectedId)();
9− }).catch((e) => console.error("[macosMenu]", e));
7+ mod
8+ .show(items)
9+ .then((selectedId) => {
10+ if (selectedId) callback(selectedId)();
11+ })
12+ .catch((e) => console.error("[macosMenu]", e));
1013 }
1114};
src/Yoga/React/Native/MacOS/Pasteboard.js+9−7
@@ -1,12 +1,14 @@
11import { Platform } from "react-native";
22
3−export const copyToClipboardImpl = (text) => () => {
3+export const copyToClipboardImpl = (text) => {
44 if (Platform.OS === "macos") {
5− const { Clipboard } = require("react-native");
6− if (Clipboard && Clipboard.setString) {
7− Clipboard.setString(text);
8− return;
9− }
5+ try {
6+ const { Clipboard } = require("react-native");
7+ if (Clipboard && Clipboard.setString) {
8+ Clipboard.setString(text);
9+ return;
10+ }
11+ } catch (e) {}
1012 }
1113 if (typeof navigator !== "undefined" && navigator.clipboard) {
1214 navigator.clipboard.writeText(text);
@@ -25,5 +27,5 @@ export const readClipboardImpl = () => {
2527 if (typeof navigator !== "undefined" && navigator.clipboard) {
2628 return navigator.clipboard.readText();
2729 }
28− return Promise.resolve("");
30+ return "";
2931};