@legendapp/spark 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/init-template.cjs +7 -1
- package/package.json +10 -5
- 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 +116 -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 +85 -0
- package/skills/spark/ui.md +57 -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 +137 -105
- 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 +12 -8
- package/vendor/node_modules/@legendapp/spark-cli/dist/native-patch-preflight.js +35 -7
- 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/release.json +20 -20
- 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/package.json +2 -8
- 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/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 +1 -0
- 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-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 +26 -13
- 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 +418 -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 +5 -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 +63 -13
- package/vendor/node_modules/@legendapp/spark-ui/src/index.android.tsx +12 -7
- package/vendor/node_modules/@legendapp/spark-ui/src/index.ios.tsx +12 -7
- package/vendor/node_modules/@legendapp/spark-ui/src/index.web.tsx +35 -13
- 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/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/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/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 +39 -6
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legendapp/spark-sqlite",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"react-native": "src/index.ts",
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"src"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@legendapp/spark-desktop-app": "0.0.
|
|
12
|
-
"@legendapp/spark-file-system": "0.0.
|
|
11
|
+
"@legendapp/spark-desktop-app": "0.0.4",
|
|
12
|
+
"@legendapp/spark-file-system": "0.0.4"
|
|
13
13
|
},
|
|
14
14
|
"private": true,
|
|
15
15
|
"peerDependencies": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legendapp/spark-system",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"react-native": "src/index.ts",
|
|
@@ -27,20 +27,13 @@
|
|
|
27
27
|
},
|
|
28
28
|
"spark": {
|
|
29
29
|
"sdk": true,
|
|
30
|
-
"nativeModules":
|
|
31
|
-
"NativeDesktopSystem"
|
|
32
|
-
],
|
|
33
|
-
"pod": "RNDesktopSystem",
|
|
34
|
-
"platforms": [
|
|
35
|
-
"macos",
|
|
36
|
-
"windows"
|
|
37
|
-
],
|
|
30
|
+
"nativeModules": true,
|
|
38
31
|
"requires": [
|
|
39
32
|
"@legendapp/spark-desktop-app"
|
|
40
33
|
]
|
|
41
34
|
},
|
|
42
35
|
"dependencies": {
|
|
43
|
-
"@legendapp/spark-desktop-app": "0.0.
|
|
36
|
+
"@legendapp/spark-desktop-app": "0.0.4"
|
|
44
37
|
},
|
|
45
38
|
"private": true
|
|
46
39
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legendapp/spark-tray",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"react-native": "src/index.ts",
|
|
@@ -27,20 +27,13 @@
|
|
|
27
27
|
},
|
|
28
28
|
"spark": {
|
|
29
29
|
"sdk": true,
|
|
30
|
-
"nativeModules":
|
|
31
|
-
"NativeDesktopTray"
|
|
32
|
-
],
|
|
33
|
-
"pod": "RNDesktopTray",
|
|
34
|
-
"platforms": [
|
|
35
|
-
"macos",
|
|
36
|
-
"windows"
|
|
37
|
-
],
|
|
30
|
+
"nativeModules": true,
|
|
38
31
|
"requires": [
|
|
39
32
|
"@legendapp/spark-desktop-app"
|
|
40
33
|
]
|
|
41
34
|
},
|
|
42
35
|
"dependencies": {
|
|
43
|
-
"@legendapp/spark-desktop-app": "0.0.
|
|
36
|
+
"@legendapp/spark-desktop-app": "0.0.4"
|
|
44
37
|
},
|
|
45
38
|
"private": true
|
|
46
39
|
}
|
|
@@ -49,7 +49,8 @@ function validate(options: TrayUpdate, creating = false): Partial<Wire> {
|
|
|
49
49
|
result.imagePath = nativePath(options.image.path, Platform.OS);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
if (options.macos !== undefined
|
|
52
|
+
if (options.macos !== undefined) {
|
|
53
|
+
if (Platform.OS !== "macos") throw new SparkError("E_UNSUPPORTED_OPTION", "macos tray options require macOS");
|
|
53
54
|
if (!options.macos || typeof options.macos !== "object" || Array.isArray(options.macos) || Object.keys(options.macos).some(key => key !== "symbol")) throw new SparkError("E_INVALID_ARGUMENT", "Expected macos tray options");
|
|
54
55
|
const symbol = options.macos.symbol;
|
|
55
56
|
if (symbol != null && (typeof symbol !== "string" || !symbol.trim() || symbol.includes("\0"))) throw new SparkError("E_INVALID_ARGUMENT", "Expected an SF Symbol name or null");
|
|
@@ -7,33 +7,103 @@ using namespace facebook::react;
|
|
|
7
7
|
|
|
8
8
|
@implementation RNSparkButton {
|
|
9
9
|
NSButton *_button;
|
|
10
|
+
SparkButtonVariant _variant;
|
|
11
|
+
NSSize _reportedSize;
|
|
12
|
+
NSString *_symbol;
|
|
13
|
+
NSString *_reportedMissingSymbol;
|
|
10
14
|
}
|
|
11
15
|
- (instancetype)init {
|
|
12
16
|
if (self = [super init]) {
|
|
13
17
|
_props = std::make_shared<const SparkButtonProps>();
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
_button.bezelStyle = NSBezelStyleRounded;
|
|
17
|
-
_button.controlSize = NSControlSizeRegular;
|
|
18
|
-
_button.font = [NSFont systemFontOfSize:NSFont.systemFontSize];
|
|
19
|
-
[self addSubview:_button];
|
|
18
|
+
_variant = SparkButtonVariant::Default;
|
|
19
|
+
[self replaceButton];
|
|
20
20
|
}
|
|
21
21
|
return self;
|
|
22
22
|
}
|
|
23
23
|
- (BOOL)isFlipped { return YES; }
|
|
24
|
+
// Checkboxes and disclosure buttons are different NSButton configurations; a fresh button avoids
|
|
25
|
+
// carrying one variant's images, bezel or button type into another.
|
|
26
|
+
- (void)replaceButton {
|
|
27
|
+
[_button removeFromSuperview];
|
|
28
|
+
if (_variant == SparkButtonVariant::Checkbox) {
|
|
29
|
+
_button = [NSButton checkboxWithTitle:@"" target:self action:@selector(pressed:)];
|
|
30
|
+
} else {
|
|
31
|
+
_button = [NSButton buttonWithTitle:@"" target:self action:@selector(pressed:)];
|
|
32
|
+
if (_variant == SparkButtonVariant::Disclosure) {
|
|
33
|
+
_button.bezelStyle = NSBezelStylePushDisclosure;
|
|
34
|
+
[_button setButtonType:NSButtonTypePushOnPushOff];
|
|
35
|
+
_button.imagePosition = NSImageOnly;
|
|
36
|
+
} else {
|
|
37
|
+
_button.buttonType = NSButtonTypeMomentaryPushIn;
|
|
38
|
+
_button.bezelStyle = NSBezelStyleRounded;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
_button.controlSize = NSControlSizeRegular;
|
|
42
|
+
_button.font = [NSFont systemFontOfSize:NSFont.systemFontSize];
|
|
43
|
+
_button.frame = self.bounds;
|
|
44
|
+
_reportedSize = NSZeroSize;
|
|
45
|
+
_symbol = nil;
|
|
46
|
+
[self addSubview:_button];
|
|
47
|
+
}
|
|
24
48
|
- (void)pressed:(id)sender {
|
|
25
49
|
if (!_button.enabled) return;
|
|
26
50
|
auto emitter = std::static_pointer_cast<const SparkButtonEventEmitter>(_eventEmitter);
|
|
27
51
|
if (emitter) emitter->onButtonPress({});
|
|
28
52
|
}
|
|
53
|
+
- (void)reportIntrinsicSize {
|
|
54
|
+
auto emitter = std::static_pointer_cast<const SparkButtonEventEmitter>(_eventEmitter);
|
|
55
|
+
NSSize size = _button.intrinsicContentSize;
|
|
56
|
+
size = NSMakeSize(ceil(size.width), ceil(size.height));
|
|
57
|
+
if (!emitter || NSEqualSizes(size, _reportedSize)) return;
|
|
58
|
+
_reportedSize = size;
|
|
59
|
+
SparkButtonEventEmitter::OnIntrinsicSize event;
|
|
60
|
+
event.width = size.width;
|
|
61
|
+
event.height = size.height;
|
|
62
|
+
emitter->onIntrinsicSize(event);
|
|
63
|
+
}
|
|
64
|
+
// A missing symbol is reported once per name, also when the emitter arrives after the props.
|
|
65
|
+
- (void)reportMissingSymbol {
|
|
66
|
+
auto emitter = std::static_pointer_cast<const SparkButtonEventEmitter>(_eventEmitter);
|
|
67
|
+
if (!emitter || _symbol.length == 0 || _button.image || [_reportedMissingSymbol isEqual:_symbol]) return;
|
|
68
|
+
_reportedMissingSymbol = _symbol;
|
|
69
|
+
SparkButtonEventEmitter::OnSymbolError event;
|
|
70
|
+
event.name = _symbol.UTF8String;
|
|
71
|
+
event.message = [NSString stringWithFormat:@"SF Symbol '%@' is not available on this system", _symbol].UTF8String;
|
|
72
|
+
emitter->onSymbolError(event);
|
|
73
|
+
}
|
|
29
74
|
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps {
|
|
30
75
|
const auto &value = *std::static_pointer_cast<const SparkButtonProps>(props);
|
|
31
|
-
|
|
76
|
+
if (value.variant != _variant) { _variant = value.variant; [self replaceButton]; }
|
|
77
|
+
NSControlSize controlSize = value.controlSize == SparkButtonControlSize::Mini ? NSControlSizeMini : value.controlSize == SparkButtonControlSize::Small ? NSControlSizeSmall : NSControlSizeRegular;
|
|
78
|
+
if (_button.controlSize != controlSize) {
|
|
79
|
+
_button.controlSize = controlSize;
|
|
80
|
+
_button.font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:controlSize]];
|
|
81
|
+
}
|
|
82
|
+
NSString *symbol = [NSString stringWithUTF8String:value.symbol.c_str()];
|
|
83
|
+
if (![symbol isEqual:_symbol]) {
|
|
84
|
+
_symbol = symbol;
|
|
85
|
+
_reportedMissingSymbol = nil;
|
|
86
|
+
_button.image = symbol.length ? [NSImage imageWithSystemSymbolName:symbol accessibilityDescription:nil] : nil;
|
|
87
|
+
_button.imagePosition = _button.image ? NSImageLeading : NSNoImage;
|
|
88
|
+
}
|
|
89
|
+
NSString *title = [NSString stringWithUTF8String:value.title.c_str()];
|
|
90
|
+
// A disclosure button draws only its chevron; its title names it for accessibility.
|
|
91
|
+
_button.title = _variant == SparkButtonVariant::Disclosure ? @"" : title;
|
|
32
92
|
_button.enabled = !value.disabled;
|
|
33
|
-
_button.bordered =
|
|
34
|
-
|
|
93
|
+
if (_variant != SparkButtonVariant::Checkbox) _button.bordered = _variant != SparkButtonVariant::Borderless;
|
|
94
|
+
// Checkbox and disclosure state is controlled: each render (and each press acknowledgment) restores it.
|
|
95
|
+
if (_variant == SparkButtonVariant::Checkbox || _variant == SparkButtonVariant::Disclosure) _button.state = value.checked ? NSControlStateValueOn : NSControlStateValueOff;
|
|
96
|
+
NSString *label = [NSString stringWithUTF8String:value.accessibilityLabel.c_str()];
|
|
97
|
+
_button.accessibilityLabel = label.length ? label : title;
|
|
35
98
|
_button.accessibilityIdentifier = [NSString stringWithUTF8String:value.testId.c_str()];
|
|
36
99
|
[super updateProps:props oldProps:oldProps];
|
|
100
|
+
[self reportMissingSymbol];
|
|
101
|
+
[self reportIntrinsicSize];
|
|
102
|
+
}
|
|
103
|
+
- (void)updateEventEmitter:(EventEmitter::Shared const &)eventEmitter {
|
|
104
|
+
[super updateEventEmitter:eventEmitter];
|
|
105
|
+
[self reportMissingSymbol];
|
|
106
|
+
[self reportIntrinsicSize];
|
|
37
107
|
}
|
|
38
108
|
- (void)layoutSubviews { [super layoutSubviews]; _button.frame = self.bounds; }
|
|
39
109
|
- (void)updateLayoutMetrics:(const LayoutMetrics &)layoutMetrics oldLayoutMetrics:(const LayoutMetrics &)oldLayoutMetrics {
|
|
@@ -43,12 +113,10 @@ using namespace facebook::react;
|
|
|
43
113
|
}
|
|
44
114
|
- (void)prepareForRecycle {
|
|
45
115
|
[super prepareForRecycle];
|
|
46
|
-
_button.title = @"";
|
|
47
|
-
_button.enabled = YES;
|
|
48
|
-
_button.bordered = YES;
|
|
49
|
-
_button.accessibilityIdentifier = nil; _button.accessibilityLabel = nil;
|
|
50
|
-
_button.highlighted = NO;
|
|
51
116
|
if (self.window.firstResponder == _button) [self.window makeFirstResponder:nil];
|
|
117
|
+
_variant = SparkButtonVariant::Default;
|
|
118
|
+
_reportedMissingSymbol = nil;
|
|
119
|
+
[self replaceButton];
|
|
52
120
|
}
|
|
53
121
|
+ (ComponentDescriptorProvider)componentDescriptorProvider { return concreteComponentDescriptorProvider<SparkButtonComponentDescriptor>(); }
|
|
54
122
|
@end
|
|
@@ -4,9 +4,32 @@
|
|
|
4
4
|
#import <react/renderer/components/RNSparkUISpec/EventEmitters.h>
|
|
5
5
|
#import <react/renderer/components/RNSparkUISpec/Props.h>
|
|
6
6
|
using namespace facebook::react;
|
|
7
|
+
// NSTextView has no public placeholder, so an empty view draws its own in the placeholder text color.
|
|
8
|
+
@interface RNSparkPlaceholderTextView : NSTextView
|
|
9
|
+
@property (nonatomic, copy) NSString *placeholder;
|
|
10
|
+
@end
|
|
11
|
+
@implementation RNSparkPlaceholderTextView
|
|
12
|
+
- (void)setPlaceholder:(NSString *)placeholder { _placeholder = [placeholder copy]; self.needsDisplay = YES; }
|
|
13
|
+
- (void)drawRect:(NSRect)dirtyRect {
|
|
14
|
+
[super drawRect:dirtyRect];
|
|
15
|
+
if (self.string.length > 0 || _placeholder.length == 0) return;
|
|
16
|
+
NSMutableParagraphStyle *paragraph = [NSMutableParagraphStyle new];
|
|
17
|
+
paragraph.alignment = self.alignment;
|
|
18
|
+
paragraph.baseWritingDirection = self.baseWritingDirection;
|
|
19
|
+
CGFloat padding = self.textContainer.lineFragmentPadding;
|
|
20
|
+
NSRect rect = NSInsetRect(self.bounds, self.textContainerInset.width + padding, self.textContainerInset.height);
|
|
21
|
+
[_placeholder drawInRect:rect withAttributes:@{ NSFontAttributeName: self.font ?: [NSFont systemFontOfSize:NSFont.systemFontSize], NSForegroundColorAttributeName: NSColor.placeholderTextColor, NSParagraphStyleAttributeName: paragraph }];
|
|
22
|
+
}
|
|
23
|
+
- (BOOL)becomeFirstResponder { self.needsDisplay = YES; return [super becomeFirstResponder]; }
|
|
24
|
+
@end
|
|
25
|
+
|
|
7
26
|
@implementation RNSparkTextInput {
|
|
8
27
|
NSTextField *_field;
|
|
28
|
+
NSScrollView *_scrollView;
|
|
29
|
+
RNSparkPlaceholderTextView *_textView;
|
|
30
|
+
NSUndoManager *_undoManager;
|
|
9
31
|
BOOL _initialized;
|
|
32
|
+
BOOL _multiline;
|
|
10
33
|
int _eventCount;
|
|
11
34
|
}
|
|
12
35
|
- (instancetype)init {
|
|
@@ -18,41 +41,101 @@ using namespace facebook::react;
|
|
|
18
41
|
_field.cell.scrollable = YES;
|
|
19
42
|
_field.cell.wraps = NO;
|
|
20
43
|
_field.cell.usesSingleLineMode = YES;
|
|
44
|
+
_scrollView = [NSScrollView new];
|
|
45
|
+
_scrollView.borderType = NSBezelBorder;
|
|
46
|
+
_scrollView.hasVerticalScroller = YES;
|
|
47
|
+
_scrollView.autohidesScrollers = YES;
|
|
48
|
+
_textView = [[RNSparkPlaceholderTextView alloc] initWithFrame:NSZeroRect];
|
|
49
|
+
_textView.delegate = self;
|
|
50
|
+
_textView.richText = NO;
|
|
51
|
+
_textView.allowsUndo = YES;
|
|
52
|
+
_textView.font = [NSFont systemFontOfSize:NSFont.systemFontSize];
|
|
53
|
+
_textView.textContainerInset = NSMakeSize(2, 4);
|
|
54
|
+
_textView.minSize = NSZeroSize;
|
|
55
|
+
_textView.maxSize = NSMakeSize(CGFLOAT_MAX, CGFLOAT_MAX);
|
|
56
|
+
_textView.textContainer.containerSize = NSMakeSize(0, CGFLOAT_MAX);
|
|
57
|
+
_textView.verticallyResizable = YES;
|
|
58
|
+
_textView.horizontallyResizable = NO;
|
|
59
|
+
_textView.autoresizingMask = NSViewWidthSizable;
|
|
60
|
+
_textView.textContainer.widthTracksTextView = YES;
|
|
61
|
+
_textView.automaticQuoteSubstitutionEnabled = NO;
|
|
62
|
+
_textView.automaticDashSubstitutionEnabled = NO;
|
|
63
|
+
_scrollView.documentView = _textView;
|
|
64
|
+
_undoManager = [NSUndoManager new];
|
|
21
65
|
[self addSubview:_field];
|
|
22
66
|
}
|
|
23
67
|
return self;
|
|
24
68
|
}
|
|
25
69
|
- (BOOL)isFlipped { return YES; }
|
|
26
|
-
- (
|
|
27
|
-
|
|
70
|
+
- (NSString *)currentText { return _multiline ? _textView.string : _field.stringValue; }
|
|
71
|
+
- (void)setCurrentText:(NSString *)text {
|
|
72
|
+
// The view keeps its own undo stack, cleared here: typing records hold ranges in the replaced text.
|
|
73
|
+
if (_multiline) { _textView.string = text; [_undoManager removeAllActions]; _textView.needsDisplay = YES; }
|
|
74
|
+
else _field.stringValue = text;
|
|
75
|
+
}
|
|
76
|
+
- (void)textChanged {
|
|
77
|
+
if (_multiline ? !_textView.editable : !_field.enabled) return;
|
|
28
78
|
++_eventCount;
|
|
29
79
|
const auto emitter = std::static_pointer_cast<const SparkTextInputEventEmitter>(_eventEmitter);
|
|
30
|
-
if (emitter) emitter->onTextChange({ .text =
|
|
80
|
+
if (emitter) emitter->onTextChange({ .text = self.currentText.UTF8String ?: "", .eventCount = _eventCount });
|
|
81
|
+
}
|
|
82
|
+
- (void)controlTextDidChange:(NSNotification *)notification { [self textChanged]; }
|
|
83
|
+
- (void)textDidChange:(NSNotification *)notification { [self textChanged]; }
|
|
84
|
+
- (NSUndoManager *)undoManagerForTextView:(NSTextView *)view { return _undoManager; }
|
|
85
|
+
// Switching between one line and several keeps the text and swaps the AppKit view.
|
|
86
|
+
- (void)setMultiline:(BOOL)multiline {
|
|
87
|
+
if (multiline == _multiline) return;
|
|
88
|
+
NSString *text = self.currentText;
|
|
89
|
+
[_field abortEditing];
|
|
90
|
+
if (_textView.window.firstResponder == _textView) [_textView.window makeFirstResponder:nil];
|
|
91
|
+
_multiline = multiline;
|
|
92
|
+
[(multiline ? (NSView *)_field : _scrollView) removeFromSuperview];
|
|
93
|
+
[self addSubview:multiline ? (NSView *)_scrollView : _field];
|
|
94
|
+
[self setCurrentText:text];
|
|
95
|
+
[self layoutSubviews];
|
|
31
96
|
}
|
|
32
97
|
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps {
|
|
33
98
|
const auto &value = *std::static_pointer_cast<const SparkTextInputProps>(props);
|
|
34
|
-
|
|
99
|
+
[self setMultiline:value.multiline];
|
|
100
|
+
if (!_initialized) { [self setCurrentText:[NSString stringWithUTF8String:value.defaultText.c_str()]]; _initialized = YES; }
|
|
35
101
|
if (value.controlled && value.eventCount >= _eventCount) {
|
|
36
102
|
NSString *text = [NSString stringWithUTF8String:value.text.c_str()];
|
|
37
|
-
if (![
|
|
103
|
+
if (![self.currentText isEqualToString:text]) [self setCurrentText:text];
|
|
38
104
|
}
|
|
105
|
+
NSString *placeholder = [NSString stringWithUTF8String:value.placeholder.c_str()];
|
|
106
|
+
_field.placeholderString = placeholder.length ? placeholder : nil;
|
|
107
|
+
_textView.placeholder = placeholder;
|
|
39
108
|
_field.enabled = !value.disabled;
|
|
40
|
-
|
|
41
|
-
|
|
109
|
+
_textView.editable = !value.disabled;
|
|
110
|
+
_textView.textColor = value.disabled ? NSColor.disabledControlTextColor : NSColor.textColor;
|
|
111
|
+
NSView *control = _multiline ? (NSView *)_textView : _field;
|
|
112
|
+
_field.accessibilityIdentifier = _textView.accessibilityIdentifier = nil;
|
|
113
|
+
_field.accessibilityLabel = _textView.accessibilityLabel = nil;
|
|
114
|
+
control.accessibilityIdentifier = [NSString stringWithUTF8String:value.testId.c_str()];
|
|
115
|
+
control.accessibilityLabel = [NSString stringWithUTF8String:value.accessibilityLabel.c_str()];
|
|
116
|
+
_textView.accessibilityPlaceholderValue = placeholder.length ? placeholder : nil;
|
|
42
117
|
[super updateProps:props oldProps:oldProps];
|
|
43
118
|
}
|
|
44
|
-
- (void)layoutSubviews {
|
|
119
|
+
- (void)layoutSubviews {
|
|
120
|
+
[super layoutSubviews];
|
|
121
|
+
_field.frame = self.bounds;
|
|
122
|
+
_scrollView.frame = self.bounds;
|
|
123
|
+
_textView.frame = NSMakeRect(0, 0, _scrollView.contentSize.width, MAX(NSHeight(_textView.frame), _scrollView.contentSize.height));
|
|
124
|
+
}
|
|
45
125
|
- (void)updateLayoutMetrics:(const LayoutMetrics &)layoutMetrics oldLayoutMetrics:(const LayoutMetrics &)oldLayoutMetrics {
|
|
46
126
|
[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
|
|
47
127
|
NSUserInterfaceLayoutDirection direction = RNSparkLayoutDirection(layoutMetrics);
|
|
48
|
-
_field.alignment = RNSparkLeadingTextAlignment(direction);
|
|
49
|
-
_field.userInterfaceLayoutDirection = direction;
|
|
128
|
+
_field.alignment = _textView.alignment = RNSparkLeadingTextAlignment(direction);
|
|
129
|
+
_field.userInterfaceLayoutDirection = _textView.userInterfaceLayoutDirection = direction;
|
|
130
|
+
_textView.baseWritingDirection = direction == NSUserInterfaceLayoutDirectionRightToLeft ? NSWritingDirectionRightToLeft : NSWritingDirectionLeftToRight;
|
|
50
131
|
[self layoutSubviews];
|
|
51
132
|
}
|
|
52
133
|
- (void)prepareForRecycle {
|
|
53
134
|
[_field abortEditing];
|
|
135
|
+
[self setMultiline:NO];
|
|
54
136
|
[super prepareForRecycle];
|
|
55
|
-
_initialized = NO; _eventCount = 0; _field.enabled = YES; _field.stringValue = @""; _field.accessibilityIdentifier = nil; _field.accessibilityLabel = nil;
|
|
137
|
+
_initialized = NO; _eventCount = 0; _field.enabled = YES; _field.stringValue = @""; _field.placeholderString = nil; _field.accessibilityIdentifier = nil; _field.accessibilityLabel = nil;
|
|
138
|
+
_textView.string = @""; [_undoManager removeAllActions]; _textView.placeholder = nil; _textView.editable = YES; _textView.accessibilityIdentifier = nil; _textView.accessibilityLabel = nil;
|
|
56
139
|
}
|
|
57
140
|
+ (ComponentDescriptorProvider)componentDescriptorProvider { return concreteComponentDescriptorProvider<SparkTextInputComponentDescriptor>(); }
|
|
58
141
|
@end
|