@legendapp/spark 0.0.1-next.2 → 0.0.1-next.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/LICENSE +21 -0
- package/README.md +10 -4
- package/ai-codex.ts +1 -0
- package/ai.ts +1 -0
- package/app-documents.ts +1 -0
- package/camera.ts +13 -0
- package/config-plugin.d.cts +2 -0
- package/contracts.ts +2 -0
- package/diagnostics.ts +1 -0
- package/expo-config.d.cts +1 -0
- package/metro.cjs +4 -1
- package/metro.d.cts +12 -0
- package/native.cjs +3 -1
- package/native.d.cts +6 -0
- package/package.json +93 -15
- package/patches/camera/react-native-nitro-image.patch +320 -0
- package/patches/camera/react-native-nitro-modules.patch +50 -0
- package/patches/camera/react-native-vision-camera.patch +2662 -0
- package/patches/camera/upstream.json +22 -0
- package/patches/dependencies.json +8 -0
- package/patches/react-native-enriched-markdown@1.0.2.patch +8684 -0
- package/postinstall.cjs +1 -0
- package/schema.json +276 -58
- package/settings-observable.ts +1 -0
- package/settings-window.ts +1 -0
- package/shortcuts-commands.ts +1 -0
- package/shortcuts-keyboard.ts +3 -0
- package/ui-classnames.ts +1 -0
- package/ui-glass.ts +1 -0
- package/ui-search.ts +1 -0
- package/ui-sidebar.ts +1 -0
- package/ui-split-view.ts +1 -0
- package/ui-swipe.ts +1 -0
- package/ui-symbol.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-ai/package.json +19 -0
- package/vendor/node_modules/@legendapp/spark-ai/src/availability.ts +17 -0
- package/vendor/node_modules/@legendapp/spark-ai/src/index.ts +15 -0
- package/vendor/node_modules/@legendapp/spark-ai/src/invocations.ts +34 -0
- package/vendor/node_modules/@legendapp/spark-ai/src/output.ts +62 -0
- package/vendor/node_modules/@legendapp/spark-ai/src/run.ts +12 -0
- package/vendor/node_modules/@legendapp/spark-ai/src/types.ts +16 -0
- package/vendor/node_modules/@legendapp/spark-audio/macos/RNSparkAudio.h +2 -1
- package/vendor/node_modules/@legendapp/spark-audio/macos/RNSparkAudio.mm +126 -24
- package/vendor/node_modules/@legendapp/spark-audio/package.json +5 -2
- package/vendor/node_modules/@legendapp/spark-audio/src/NativeSparkAudio.ts +5 -1
- package/vendor/node_modules/@legendapp/spark-audio/src/desktop.ts +36 -32
- package/vendor/node_modules/@legendapp/spark-audio/src/events.ts +11 -0
- package/vendor/node_modules/@legendapp/spark-audio/src/hooks.ts +65 -0
- package/vendor/node_modules/@legendapp/spark-audio/src/index.web.ts +92 -33
- package/vendor/node_modules/@legendapp/spark-audio/src/media-session-unavailable.ts +6 -4
- package/vendor/node_modules/@legendapp/spark-audio/src/media-session.ts +52 -19
- package/vendor/node_modules/@legendapp/spark-audio/src/media-session.web.ts +18 -10
- package/vendor/node_modules/@legendapp/spark-audio/src/media-types.ts +40 -13
- package/vendor/node_modules/@legendapp/spark-audio/src/mobile.ts +40 -32
- package/vendor/node_modules/@legendapp/spark-audio/src/player.ts +97 -0
- package/vendor/node_modules/@legendapp/spark-audio/src/status-listeners.ts +21 -15
- package/vendor/node_modules/@legendapp/spark-audio/src/types.ts +9 -4
- package/vendor/node_modules/@legendapp/spark-audio/windows/SparkAudio/SparkAudio.h +67 -20
- package/vendor/node_modules/@legendapp/spark-auth-session/package.json +4 -3
- package/vendor/node_modules/@legendapp/spark-auth-session/src/core.ts +60 -42
- package/vendor/node_modules/@legendapp/spark-auth-session/src/index.ts +28 -12
- package/vendor/node_modules/@legendapp/spark-auth-session/src/mobile.ts +97 -41
- package/vendor/node_modules/@legendapp/spark-auth-session/src/types.ts +20 -9
- package/vendor/node_modules/@legendapp/spark-cli/dist/add-desktop.js +50 -7
- package/vendor/node_modules/@legendapp/spark-cli/dist/build-mode.js +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/build.js +145 -59
- package/vendor/node_modules/@legendapp/spark-cli/dist/cli-arguments.js +61 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/commands.js +10 -4
- package/vendor/node_modules/@legendapp/spark-cli/dist/create.js +37 -8
- package/vendor/node_modules/@legendapp/spark-cli/dist/credentials.js +86 -25
- package/vendor/node_modules/@legendapp/spark-cli/dist/dependency-pins.js +132 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/dev-command.js +13 -4
- package/vendor/node_modules/@legendapp/spark-cli/dist/dev.js +13 -10
- package/vendor/node_modules/@legendapp/spark-cli/dist/errors.js +100 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/examples.js +2 -2
- package/vendor/node_modules/@legendapp/spark-cli/dist/expo-dev-patch.cjs +4 -2
- package/vendor/node_modules/@legendapp/spark-cli/dist/expo-metro.cjs +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/expo-native.cjs +5 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/expo-node.js +3 -3
- package/vendor/node_modules/@legendapp/spark-cli/dist/helpers.js +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/index.js +52 -44
- package/vendor/node_modules/@legendapp/spark-cli/dist/json.js +16 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/local.js +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/metro.cjs +26 -5
- package/vendor/node_modules/@legendapp/spark-cli/dist/native-metadata.js +26 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/native-patch-preflight.js +86 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/native-preparation.js +88 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/notary-profiles.js +75 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/package.js +4 -2
- package/vendor/node_modules/@legendapp/spark-cli/dist/platform.js +16 -2
- package/vendor/node_modules/@legendapp/spark-cli/dist/process.js +7 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/project.js +90 -32
- package/vendor/node_modules/@legendapp/spark-cli/dist/release.js +86 -5
- package/vendor/node_modules/@legendapp/spark-cli/dist/release.json +23 -18
- package/vendor/node_modules/@legendapp/spark-cli/dist/runner-install.js +145 -31
- package/vendor/node_modules/@legendapp/spark-cli/dist/signing.js +4 -3
- package/vendor/node_modules/@legendapp/spark-cli/dist/universal.cjs +2 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/updates.js +41 -4
- package/vendor/node_modules/@legendapp/spark-cli/dist/windows.js +5 -9
- package/vendor/node_modules/@legendapp/spark-cli/package.json +7 -6
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/App.tsx +6 -12
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/desktop.config.json +5 -3
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/package.json +12 -10
- package/vendor/node_modules/@legendapp/spark-cli/templates/diff-lite/Git.macos.tsx +2 -2
- package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/Integration.macos.tsx +23 -21
- package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/Integration.windows.tsx +23 -21
- package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/io.desktop.ts +11 -8
- package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/io.macos.ts +3 -3
- package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/Lifecycle.desktop.tsx +8 -14
- package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/OpenFiles.desktop.tsx +5 -10
- package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/io.desktop.ts +11 -8
- package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/io.macos.ts +3 -3
- package/vendor/node_modules/@legendapp/spark-cli/templates/music-lite/assets.desktop.ts +2 -2
- package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/Activation.desktop.tsx +2 -2
- package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/Desktop.desktop.ts +37 -15
- package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/session.ts +5 -6
- package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/window-session.ts +5 -4
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/desktop.config.json +5 -3
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/metro.config.js +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/package.json +14 -12
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/react-native.config.js +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/package.json +14 -12
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/react-native.config.js +1 -1
- package/vendor/node_modules/@legendapp/spark-clipboard/macos/RNDesktopClipboard.mm +10 -16
- package/vendor/node_modules/@legendapp/spark-clipboard/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-clipboard/src/NativeDesktopClipboard.ts +1 -1
- package/vendor/node_modules/@legendapp/spark-clipboard/src/desktop.ts +55 -31
- package/vendor/node_modules/@legendapp/spark-clipboard/src/expo.ts +21 -11
- package/vendor/node_modules/@legendapp/spark-clipboard/src/options.ts +8 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/src/types.ts +10 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard/SparkClipboard.h +38 -15
- package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard/SparkClipboard.vcxproj +2 -0
- package/vendor/node_modules/@legendapp/spark-codex/RNCodex.podspec +22 -0
- package/vendor/node_modules/@legendapp/spark-codex/cpp/HybridCodexAppServer.hpp +23 -0
- package/vendor/node_modules/@legendapp/spark-codex/cpp/HybridCodexAppServer.mm +1529 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitro.json +21 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/.gitattributes +1 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/ios/RNCodex+autolinking.rb +62 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/ios/RNCodex-Swift-Cxx-Bridge.cpp +17 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/ios/RNCodex-Swift-Cxx-Bridge.hpp +27 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/ios/RNCodex-Swift-Cxx-Umbrella.hpp +38 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/ios/RNCodexAutolinking.mm +35 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/ios/RNCodexAutolinking.swift +16 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/shared/c++/CodexAvailability.hpp +95 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/shared/c++/CodexRunResult.hpp +99 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/shared/c++/HybridCodexAppServerSpec.cpp +24 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/shared/c++/HybridCodexAppServerSpec.hpp +71 -0
- package/vendor/node_modules/@legendapp/spark-codex/package.json +35 -0
- package/vendor/node_modules/@legendapp/spark-codex/react-native.config.js +11 -0
- package/vendor/node_modules/@legendapp/spark-codex/src/Codex.nitro.ts +30 -0
- package/vendor/node_modules/@legendapp/spark-codex/src/index.ts +65 -0
- package/vendor/node_modules/@legendapp/spark-codex/src/native.ts +6 -0
- package/vendor/node_modules/@legendapp/spark-commands/package.json +21 -0
- package/vendor/node_modules/@legendapp/spark-commands/src/bindings.ts +90 -0
- package/vendor/node_modules/@legendapp/spark-commands/src/index.tsx +400 -0
- package/vendor/node_modules/@legendapp/spark-commands/src/router.ts +138 -0
- package/vendor/node_modules/@legendapp/spark-commands/src/storage.ts +20 -0
- package/vendor/node_modules/@legendapp/spark-context-menu/macos/RNContextMenu.mm +7 -8
- package/vendor/node_modules/@legendapp/spark-context-menu/package.json +4 -3
- package/vendor/node_modules/@legendapp/spark-context-menu/src/NativeContextMenu.ts +1 -1
- package/vendor/node_modules/@legendapp/spark-context-menu/src/index.ts +26 -26
- package/vendor/node_modules/@legendapp/spark-context-menu/windows/SparkContextMenu/SparkContextMenu.h +3 -2
- package/vendor/node_modules/@legendapp/spark-desktop-app/RNDesktopApp.podspec +2 -1
- package/vendor/node_modules/@legendapp/spark-desktop-app/cpp/SparkBinaryJSI.hpp +89 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/cpp/SparkBinaryWindows.hpp +22 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/RNDesktopApp.mm +13 -7
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkBinaryJSI.h +48 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.h +4 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.mm +33 -33
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktopError.h +20 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkLifecycle.h +26 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkLifecycle.mm +49 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkQuitCoordinator.h +9 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkQuitCoordinator.mm +70 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkWindow.mm +9 -6
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/recent-documents/RNRecentDocumentController.mm +55 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/package.json +5 -3
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/NativeDesktopApp.ts +1 -1
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/api.ts +86 -40
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/contracts/accelerator.ts +40 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/contracts/index.ts +56 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/contracts/menu.ts +116 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/contracts/native-buffer.ts +22 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/contracts/path.ts +24 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/events.ts +75 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/index.ts +2 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/index.windows.ts +2 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/open-requests.ts +43 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/restoration.ts +11 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/transport.ts +10 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/app.plugin.cjs +10 -5
- package/vendor/node_modules/@legendapp/spark-desktop-config/app.plugin.d.cts +3 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/autolinking.cjs +35 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/config.cjs +18 -3
- package/vendor/node_modules/@legendapp/spark-desktop-config/config.d.cts +89 -9
- package/vendor/node_modules/@legendapp/spark-desktop-config/expo.cjs +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/expo.d.cts +3 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/identity.cjs +3 -2
- package/vendor/node_modules/@legendapp/spark-desktop-config/lifecycle.cjs +20 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.cjs +106 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.d.cts +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/package.json +7 -5
- package/vendor/node_modules/@legendapp/spark-desktop-config/schema.json +276 -58
- package/vendor/node_modules/@legendapp/spark-desktop-config/updates.cjs +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/validation.cjs +35 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/windows.plugin.cjs +2 -1
- package/vendor/node_modules/@legendapp/spark-desktop-host/AppDelegate.mm +129 -11
- package/vendor/node_modules/@legendapp/spark-desktop-host/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-desktop-host/windows/application.inc +277 -121
- package/vendor/node_modules/@legendapp/spark-desktop-links/common/AuthLoopback.h +5 -7
- package/vendor/node_modules/@legendapp/spark-desktop-links/macos/RNDesktopLinks.mm +10 -9
- package/vendor/node_modules/@legendapp/spark-desktop-links/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-desktop-links/src/NativeDesktopLinks.ts +1 -1
- package/vendor/node_modules/@legendapp/spark-desktop-links/src/api.ts +27 -33
- package/vendor/node_modules/@legendapp/spark-desktop-links/src/expo.ts +3 -4
- package/vendor/node_modules/@legendapp/spark-desktop-links/src/native.ts +9 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/windows/SparkLinks/SparkLinks.h +22 -22
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/RNDesktopShortcuts.podspec +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/macos/RNDesktopShortcuts.mm +1 -1
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/macos/keyboard-manager/RNKeyboardManager.h +9 -0
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/macos/keyboard-manager/RNKeyboardManager.mm +307 -0
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/package.json +8 -5
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/src/NativeDesktopShortcuts.ts +1 -1
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/src/api.ts +39 -14
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/src/keyboard-manager/NativeKeyboardManager.ts +12 -0
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/src/keyboard-manager/codes.ts +108 -0
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/src/keyboard-manager/index.ts +99 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/RNDesktopWindows.podspec +2 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/RNDesktopWindows.mm +229 -103
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/SparkWindowGeometry.h +63 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/LegendWindowRegistry.h +20 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/LegendWindowRegistry.mm +27 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/RNWindowManager.h +12 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/RNWindowManager.mm +3169 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/RNWindowManagerStartup.mm +31 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/SidebarStartupFallbacks.mm +14 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/package.json +10 -6
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/NativeDesktopWindowManager.ts +1 -1
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/api.ts +146 -70
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/diagnostics.ts +17 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/index.ts +3 -1
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/index.windows.ts +3 -1
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/macos-adapter.ts +53 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/macos.ts +51 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/transport.ts +41 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/types.ts +140 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/validation.ts +162 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/window-manager/NativeWindowManager.ts +28 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/WindowProvider.tsx +20 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/createWindowsNavigator.tsx +78 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/index.ts +6 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/primaryWindowLifecycle.ts +34 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/types.ts +11 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/usePrimaryWindowLifecycle.ts +18 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/useWindowFocusEffect.ts +17 -0
- package/vendor/node_modules/@legendapp/spark-documents/package.json +22 -0
- package/vendor/node_modules/@legendapp/spark-documents/src/controller.ts +97 -0
- package/vendor/node_modules/@legendapp/spark-documents/src/documentTransition.ts +13 -0
- package/vendor/node_modules/@legendapp/spark-documents/src/hooks.ts +139 -0
- package/vendor/node_modules/@legendapp/spark-documents/src/index.tsx +50 -0
- package/vendor/node_modules/@legendapp/spark-documents/src/reload.ts +39 -0
- package/vendor/node_modules/@legendapp/spark-documents/src/requests.ts +15 -0
- package/vendor/node_modules/@legendapp/spark-drag-drop/package.json +4 -3
- package/vendor/node_modules/@legendapp/spark-drag-drop/src/DesktopDragViewNativeComponent.ts +1 -1
- package/vendor/node_modules/@legendapp/spark-drag-drop/src/contracts.ts +73 -18
- package/vendor/node_modules/@legendapp/spark-drag-drop/src/index.tsx +58 -15
- package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/SparkDragDrop.h +14 -8
- package/vendor/node_modules/@legendapp/spark-file-dialog/ios/RNFileDialog.mm +34 -121
- package/vendor/node_modules/@legendapp/spark-file-dialog/package.json +12 -5
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/NativeFileDialog.ts +1 -5
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/index.ts +19 -84
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/native.ts +12 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/options.ts +34 -14
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/types.ts +26 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/windows/SparkFileDialog/SparkFileDialog.h +42 -58
- package/vendor/node_modules/@legendapp/spark-file-system/RNDesktopFileSystem.podspec +1 -0
- package/vendor/node_modules/@legendapp/spark-file-system/macos/RNDesktopFileSystem.mm +32 -21
- package/vendor/node_modules/@legendapp/spark-file-system/macos/SparkFileMutations.h +24 -0
- package/vendor/node_modules/@legendapp/spark-file-system/macos/SparkFileMutations.mm +215 -0
- package/vendor/node_modules/@legendapp/spark-file-system/macos/file-scanner/RNFileScanner.h +9 -0
- package/vendor/node_modules/@legendapp/spark-file-system/macos/file-scanner/RNFileScanner.mm +82 -0
- package/vendor/node_modules/@legendapp/spark-file-system/macos/file-scanner/RNFileScannerCore.h +47 -0
- package/vendor/node_modules/@legendapp/spark-file-system/macos/file-scanner/RNFileScannerCore.mm +306 -0
- package/vendor/node_modules/@legendapp/spark-file-system/package.json +8 -6
- package/vendor/node_modules/@legendapp/spark-file-system/src/NativeDesktopFileSystem.ts +1 -1
- package/vendor/node_modules/@legendapp/spark-file-system/src/file-scanner/NativeFileScanner.ts +11 -0
- package/vendor/node_modules/@legendapp/spark-file-system/src/file-scanner/index.ts +93 -0
- package/vendor/node_modules/@legendapp/spark-file-system/src/handles.ts +48 -14
- package/vendor/node_modules/@legendapp/spark-file-system/src/index.ts +134 -45
- package/vendor/node_modules/@legendapp/spark-file-system/src/path.ts +1 -9
- package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/SparkFileSystem.h +102 -26
- package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/SparkFileSystem.vcxproj +2 -0
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/RNDesktopGlobalShortcuts.podspec +1 -0
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/macos/RNDesktopGlobalShortcuts.mm +7 -4
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/package.json +4 -3
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/src/NativeDesktopGlobalShortcuts.ts +1 -1
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/src/index.ts +39 -10
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/SparkGlobalShortcuts/SparkGlobalShortcuts.h +5 -4
- package/vendor/node_modules/@legendapp/spark-message-dialog/macos/RNDesktopMessageDialog.mm +2 -2
- package/vendor/node_modules/@legendapp/spark-message-dialog/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-message-dialog/src/NativeDesktopMessageDialog.ts +1 -1
- package/vendor/node_modules/@legendapp/spark-message-dialog/src/index.ts +48 -11
- package/vendor/node_modules/@legendapp/spark-native-menu/ios/RNNativeMenu.mm +141 -609
- package/vendor/node_modules/@legendapp/spark-native-menu/package.json +9 -4
- package/vendor/node_modules/@legendapp/spark-native-menu/src/NativeMenu.ts +2 -7
- package/vendor/node_modules/@legendapp/spark-native-menu/src/api.ts +76 -121
- package/vendor/node_modules/@legendapp/spark-native-menu/src/hooks.ts +97 -0
- package/vendor/node_modules/@legendapp/spark-native-menu/src/windows-menus.ts +43 -37
- package/vendor/node_modules/@legendapp/spark-notifications/macos/RNDesktopNotifications.mm +75 -30
- package/vendor/node_modules/@legendapp/spark-notifications/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-notifications/src/NativeDesktopNotifications.ts +1 -1
- package/vendor/node_modules/@legendapp/spark-notifications/src/index.ts +130 -42
- package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications/SparkNotifications.h +51 -8
- package/vendor/node_modules/@legendapp/spark-processes/macos/RNDesktopProcesses.mm +94 -21
- package/vendor/node_modules/@legendapp/spark-processes/package.json +4 -3
- package/vendor/node_modules/@legendapp/spark-processes/src/NativeDesktopProcesses.ts +1 -1
- package/vendor/node_modules/@legendapp/spark-processes/src/index.ts +124 -28
- package/vendor/node_modules/@legendapp/spark-processes/src/types.ts +34 -0
- package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses/SparkProcesses.h +83 -34
- package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses/SparkProcesses.vcxproj +2 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/macos/RNDesktopSecureStorage.mm +49 -40
- package/vendor/node_modules/@legendapp/spark-secure-storage/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-secure-storage/src/NativeDesktopSecureStorage.ts +1 -1
- package/vendor/node_modules/@legendapp/spark-secure-storage/src/desktop.ts +16 -14
- package/vendor/node_modules/@legendapp/spark-secure-storage/src/expo.ts +0 -1
- package/vendor/node_modules/@legendapp/spark-secure-storage/src/options.ts +3 -2
- package/vendor/node_modules/@legendapp/spark-secure-storage/src/unavailable.ts +6 -3
- package/vendor/node_modules/@legendapp/spark-settings/package.json +10 -3
- package/vendor/node_modules/@legendapp/spark-settings/src/fileStorage.ts +11 -0
- package/vendor/node_modules/@legendapp/spark-settings/src/index.ts +7 -9
- package/vendor/node_modules/@legendapp/spark-settings/src/storage/index.ts +142 -0
- package/vendor/node_modules/@legendapp/spark-settings/src/store.ts +63 -21
- package/vendor/node_modules/@legendapp/spark-settings-ui/package.json +20 -0
- package/vendor/node_modules/@legendapp/spark-settings-ui/src/index.tsx +436 -0
- package/vendor/node_modules/@legendapp/spark-settings-ui/src/options.ts +10 -0
- package/vendor/node_modules/@legendapp/spark-sqlite/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-sqlite/src/database.ts +182 -0
- package/vendor/node_modules/@legendapp/spark-sqlite/src/index.ts +19 -6
- package/vendor/node_modules/@legendapp/spark-sqlite/src/types.ts +22 -0
- package/vendor/node_modules/@legendapp/spark-system/macos/RNDesktopSystem.mm +36 -11
- package/vendor/node_modules/@legendapp/spark-system/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-system/src/NativeDesktopSystem.ts +1 -1
- package/vendor/node_modules/@legendapp/spark-system/src/index.ts +89 -32
- package/vendor/node_modules/@legendapp/spark-system/windows/SparkSystem/SparkSystem.h +8 -4
- package/vendor/node_modules/@legendapp/spark-tray/macos/RNDesktopTray.mm +20 -8
- package/vendor/node_modules/@legendapp/spark-tray/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-tray/src/NativeDesktopTray.ts +1 -1
- package/vendor/node_modules/@legendapp/spark-tray/src/index.ts +91 -34
- package/vendor/node_modules/@legendapp/spark-tray/windows/SparkTray/SparkTray.h +45 -15
- package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkButton.mm +2 -1
- package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkTextInput.mm +10 -2
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSidebarSplitViewComponent.h +15 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSidebarSplitViewComponent.mm +1419 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/glass-effect-view/RNGlassEffectView.mm +72 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSegmentedControl.h +15 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSegmentedControl.mm +194 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSelect.h +15 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSelect.mm +180 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/sf-symbol/RNSFSymbol.h +15 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/sf-symbol/RNSFSymbol.mm +155 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/sidebar/RNSidebar.h +18 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/sidebar/RNSidebar.mm +645 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/swipe-actions/RNSwipeActions.h +10 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/swipe-actions/RNSwipeActions.mm +422 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/text-input-search/RNTextInputSearch.h +15 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/text-input-search/RNTextInputSearch.mm +164 -0
- package/vendor/node_modules/@legendapp/spark-ui/package.json +17 -4
- package/vendor/node_modules/@legendapp/spark-ui/src/SparkSelectNativeComponent.ts +3 -1
- package/vendor/node_modules/@legendapp/spark-ui/src/SparkTextInputNativeComponent.ts +6 -2
- package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SidebarSplitViewNativeComponent.ts +37 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/index.tsx +86 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/availability.ts +10 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/classnames/index.ts +8 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/control.ts +42 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/desktop.tsx +56 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/glass-effect-view/index.tsx +15 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/index.android.tsx +35 -21
- package/vendor/node_modules/@legendapp/spark-ui/src/index.ios.tsx +55 -26
- package/vendor/node_modules/@legendapp/spark-ui/src/index.tsx +1 -27
- package/vendor/node_modules/@legendapp/spark-ui/src/index.web.tsx +45 -14
- package/vendor/node_modules/@legendapp/spark-ui/src/index.windows.tsx +1 -42
- package/vendor/node_modules/@legendapp/spark-ui/src/mobile-input.tsx +11 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/native-select/NativeSegmentedControlNativeComponent.ts +17 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/native-select/NativeSelectNativeComponent.ts +17 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/select.ts +5 -3
- package/vendor/node_modules/@legendapp/spark-ui/src/sf-symbol/SFSymbolNativeComponent.ts +13 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/sf-symbol/index.tsx +27 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/SidebarItemNativeComponent.ts +25 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/SidebarNativeComponent.ts +24 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/index.tsx +104 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/specialized.ts +22 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/swipe-actions/SwipeActionsNativeComponent.ts +11 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/swipe-actions/index.tsx +41 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/text-input-search/TextInputSearchNativeComponent.ts +33 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/text-input-search/index.tsx +34 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/types.ts +30 -19
- package/vendor/node_modules/@legendapp/spark-ui/uniwind.ts +3 -1
- package/vendor/node_modules/@legendapp/spark-ui/uniwind.web.ts +3 -1
- package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/SparkUI.h +16 -11
- package/vendor/node_modules/@legendapp/spark-updates/macos/RNDesktopUpdates.mm +21 -8
- package/vendor/node_modules/@legendapp/spark-updates/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-updates/src/NativeDesktopUpdates.ts +3 -2
- package/vendor/node_modules/@legendapp/spark-updates/src/index.ts +71 -15
- package/vendor/node_modules/@legendapp/spark-webview/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-webview/src/WebView.tsx +11 -0
- package/vendor/node_modules/@legendapp/spark-webview/src/adapter.ts +55 -0
- package/vendor/node_modules/@legendapp/spark-webview/src/index.ts +2 -2
- package/vendor/node_modules/@legendapp/spark-webview/src/types.ts +32 -0
- package/vendor/node_modules/@legendapp/spark-webview/src/view-props.ts +28 -0
- package/vendor/node_modules/@legendapp/spark-window-options/index.cjs +51 -14
- package/vendor/node_modules/@legendapp/spark-window-options/index.d.ts +21 -8
- package/vendor/node_modules/@legendapp/spark-window-options/package.json +1 -1
- package/windows-macos.ts +1 -0
- package/expo-metro.cjs +0 -1
- package/message-dialog.ts +0 -1
- package/universal.cjs +0 -1
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/src/accelerator.ts +0 -22
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows-options.ts +0 -11
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/index.windows.ts +0 -15
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/src/accelerator.ts +0 -22
- package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkSelect.h +0 -4
- package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkSelect.mm +0 -53
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
#import "RNSwipeActions.h"
|
|
2
|
+
#import <QuartzCore/QuartzCore.h>
|
|
3
|
+
#import <react/renderer/components/RNSparkUISpec/ComponentDescriptors.h>
|
|
4
|
+
#import <react/renderer/components/RNSparkUISpec/EventEmitters.h>
|
|
5
|
+
#import <react/renderer/components/RNSparkUISpec/Props.h>
|
|
6
|
+
using namespace facebook::react;
|
|
7
|
+
|
|
8
|
+
static const CGFloat kButtonWidth = 76; // one revealed action when the row rests open
|
|
9
|
+
static const CGFloat kAxisDistance = 5; // travel before a gesture commits to an axis
|
|
10
|
+
static const CGFloat kRubberLimit = 36; // how far a side without actions gives
|
|
11
|
+
|
|
12
|
+
typedef NS_ENUM(NSInteger, RNSwipeGesture) { RNSwipeGestureIdle, RNSwipeGestureUndecided, RNSwipeGestureTracking, RNSwipeGesturePassing };
|
|
13
|
+
|
|
14
|
+
static NSColor *RNSwipeColor(NSString *hex)
|
|
15
|
+
{
|
|
16
|
+
unsigned long long raw = 0;
|
|
17
|
+
[[NSScanner scannerWithString:[hex substringFromIndex:1]] scanHexLongLong:&raw];
|
|
18
|
+
if (hex.length == 9) return [NSColor colorWithSRGBRed:((raw >> 24) & 0xff) / 255.0 green:((raw >> 16) & 0xff) / 255.0 blue:((raw >> 8) & 0xff) / 255.0 alpha:(raw & 0xff) / 255.0];
|
|
19
|
+
return [NSColor colorWithSRGBRed:((raw >> 16) & 0xff) / 255.0 green:((raw >> 8) & 0xff) / 255.0 blue:(raw & 0xff) / 255.0 alpha:1];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static void RNSwipeAnimate(NSTimeInterval duration, void (^changes)(void), void (^_Nullable completion)(void))
|
|
23
|
+
{
|
|
24
|
+
BOOL reduce = NSWorkspace.sharedWorkspace.accessibilityDisplayShouldReduceMotion;
|
|
25
|
+
[NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {
|
|
26
|
+
context.duration = reduce ? MIN(duration, 0.12) : duration;
|
|
27
|
+
context.timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.2 :0.9 :0.25 :1];
|
|
28
|
+
context.allowsImplicitAnimation = YES;
|
|
29
|
+
changes();
|
|
30
|
+
} completionHandler:completion];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// React child frames use top-left coordinates, even inside private AppKit containers.
|
|
34
|
+
@interface RNSwipeContainerView : NSView @end
|
|
35
|
+
@implementation RNSwipeContainerView
|
|
36
|
+
- (BOOL)isFlipped { return YES; }
|
|
37
|
+
@end
|
|
38
|
+
|
|
39
|
+
@class RNSwipeActions;
|
|
40
|
+
|
|
41
|
+
@interface RNSwipeActionButton : NSView
|
|
42
|
+
@property (nonatomic, readonly) NSString *actionId;
|
|
43
|
+
@property (nonatomic, readonly) BOOL dismisses;
|
|
44
|
+
/** +1 on the leading side, -1 trailing; the outermost button tracks the content edge once armed. */
|
|
45
|
+
@property (nonatomic) NSInteger edge;
|
|
46
|
+
@property (nonatomic) BOOL followsContent;
|
|
47
|
+
@property (nonatomic, weak) RNSwipeActions *owner;
|
|
48
|
+
@end
|
|
49
|
+
|
|
50
|
+
@interface RNSwipeActions ()
|
|
51
|
+
- (void)performActionForButton:(RNSwipeActionButton *)button;
|
|
52
|
+
@end
|
|
53
|
+
|
|
54
|
+
@implementation RNSwipeActionButton {
|
|
55
|
+
NSImageView *_icon;
|
|
56
|
+
NSTextField *_label;
|
|
57
|
+
}
|
|
58
|
+
- (instancetype)initWithAction:(NSDictionary *)action
|
|
59
|
+
{
|
|
60
|
+
if ((self = [super initWithFrame:NSZeroRect])) {
|
|
61
|
+
_actionId = [action[@"id"] copy];
|
|
62
|
+
_dismisses = [action[@"dismisses"] boolValue];
|
|
63
|
+
self.wantsLayer = YES;
|
|
64
|
+
self.layer.backgroundColor = RNSwipeColor(action[@"color"]).CGColor;
|
|
65
|
+
NSImageSymbolConfiguration *config = [NSImageSymbolConfiguration configurationWithPointSize:17 weight:NSFontWeightSemibold];
|
|
66
|
+
_icon = [NSImageView imageViewWithImage:[[NSImage imageWithSystemSymbolName:action[@"symbol"] accessibilityDescription:nil] imageWithSymbolConfiguration:config] ?: [NSImage new]];
|
|
67
|
+
_icon.contentTintColor = NSColor.whiteColor;
|
|
68
|
+
_label = [NSTextField labelWithString:action[@"title"]];
|
|
69
|
+
_label.font = [NSFont systemFontOfSize:11 weight:NSFontWeightSemibold];
|
|
70
|
+
_label.textColor = NSColor.whiteColor;
|
|
71
|
+
_label.alignment = NSTextAlignmentCenter;
|
|
72
|
+
_label.lineBreakMode = NSLineBreakByTruncatingTail;
|
|
73
|
+
[self addSubview:_icon];
|
|
74
|
+
[self addSubview:_label];
|
|
75
|
+
self.accessibilityElement = YES;
|
|
76
|
+
self.accessibilityRole = NSAccessibilityButtonRole;
|
|
77
|
+
self.accessibilityLabel = action[@"title"];
|
|
78
|
+
}
|
|
79
|
+
return self;
|
|
80
|
+
}
|
|
81
|
+
- (BOOL)isFlipped { return YES; }
|
|
82
|
+
- (BOOL)acceptsFirstMouse:(NSEvent *)event { return YES; }
|
|
83
|
+
// Non-opaque views drag the window by default, which would swallow the click.
|
|
84
|
+
- (BOOL)mouseDownCanMoveWindow { return NO; }
|
|
85
|
+
- (void)layout
|
|
86
|
+
{
|
|
87
|
+
[super layout];
|
|
88
|
+
NSRect bounds = self.bounds;
|
|
89
|
+
CGFloat slot = MIN(bounds.size.width, kButtonWidth);
|
|
90
|
+
CGFloat center = !_followsContent ? NSMidX(bounds) : _edge > 0 ? bounds.size.width - slot / 2 : slot / 2;
|
|
91
|
+
CGFloat iconSize = 22, labelHeight = 15, top = floor((bounds.size.height - iconSize - 3 - labelHeight) / 2);
|
|
92
|
+
_icon.frame = NSMakeRect(round(center - iconSize / 2), top, iconSize, iconSize);
|
|
93
|
+
_label.frame = NSMakeRect(round(center - kButtonWidth / 2) + 4, top + iconSize + 3, kButtonWidth - 8, labelHeight);
|
|
94
|
+
// Contents fade in as the button gains room, so a sliver never shows clipped glyphs.
|
|
95
|
+
CGFloat alpha = MAX(0, MIN(1, (bounds.size.width - 20) / 36));
|
|
96
|
+
_icon.alphaValue = alpha;
|
|
97
|
+
_label.alphaValue = alpha;
|
|
98
|
+
}
|
|
99
|
+
- (void)mouseDown:(NSEvent *)event {}
|
|
100
|
+
- (void)mouseUp:(NSEvent *)event
|
|
101
|
+
{
|
|
102
|
+
if (NSPointInRect([self convertPoint:event.locationInWindow fromView:nil], self.bounds)) [_owner performActionForButton:self];
|
|
103
|
+
}
|
|
104
|
+
- (BOOL)accessibilityPerformPress { [_owner performActionForButton:self]; return YES; }
|
|
105
|
+
@end
|
|
106
|
+
|
|
107
|
+
static __weak RNSwipeActions *RNSwipeOpenRow;
|
|
108
|
+
|
|
109
|
+
@implementation RNSwipeActions {
|
|
110
|
+
NSView *_clipView;
|
|
111
|
+
NSView *_actionsView;
|
|
112
|
+
NSView *_contentView;
|
|
113
|
+
NSArray<RNSwipeActionButton *> *_leading;
|
|
114
|
+
NSArray<RNSwipeActionButton *> *_trailing;
|
|
115
|
+
std::string _leadingJson;
|
|
116
|
+
std::string _trailingJson;
|
|
117
|
+
NSMutableArray<NSEvent *> *_pending;
|
|
118
|
+
RNSwipeGesture _gesture;
|
|
119
|
+
CGFloat _pendingX;
|
|
120
|
+
CGFloat _pendingY;
|
|
121
|
+
CGFloat _offset;
|
|
122
|
+
/** The button filling the revealed strip: the outermost once armed, or a tapped dismissing one. */
|
|
123
|
+
RNSwipeActionButton *_takeover;
|
|
124
|
+
BOOL _dismissed;
|
|
125
|
+
NSUInteger _generation;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
- (instancetype)initWithFrame:(NSRect)frame
|
|
129
|
+
{
|
|
130
|
+
if ((self = [super initWithFrame:frame])) {
|
|
131
|
+
_props = std::make_shared<const SwipeActionsProps>();
|
|
132
|
+
_clipView = [[RNSwipeContainerView alloc] initWithFrame:self.bounds];
|
|
133
|
+
_clipView.wantsLayer = YES;
|
|
134
|
+
// Fabric rewrites the host layer's masksToBounds from overflow props. Own this clip separately.
|
|
135
|
+
_clipView.layer.masksToBounds = YES;
|
|
136
|
+
[self addSubview:_clipView];
|
|
137
|
+
_actionsView = [[RNSwipeContainerView alloc] initWithFrame:self.bounds];
|
|
138
|
+
_actionsView.wantsLayer = YES;
|
|
139
|
+
_contentView = [[RNSwipeContainerView alloc] initWithFrame:self.bounds];
|
|
140
|
+
_contentView.wantsLayer = YES;
|
|
141
|
+
[_clipView addSubview:_actionsView];
|
|
142
|
+
[_clipView addSubview:_contentView];
|
|
143
|
+
_leading = @[];
|
|
144
|
+
_trailing = @[];
|
|
145
|
+
_pending = [NSMutableArray new];
|
|
146
|
+
}
|
|
147
|
+
return self;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
- (BOOL)isFlipped { return YES; }
|
|
151
|
+
|
|
152
|
+
#pragma mark - React
|
|
153
|
+
|
|
154
|
+
- (void)mountChildComponentView:(RCTUIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
155
|
+
{
|
|
156
|
+
if (index < (NSInteger)_contentView.subviews.count) [_contentView addSubview:childComponentView positioned:NSWindowBelow relativeTo:_contentView.subviews[index]];
|
|
157
|
+
else [_contentView addSubview:childComponentView];
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
- (void)unmountChildComponentView:(RCTUIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
161
|
+
{
|
|
162
|
+
[childComponentView removeFromSuperview];
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
- (NSArray<RNSwipeActionButton *> *)buttonsFromJson:(const std::string &)json edge:(NSInteger)edge
|
|
166
|
+
{
|
|
167
|
+
NSData *data = [NSData dataWithBytes:json.data() length:json.size()];
|
|
168
|
+
NSArray *actions = data.length ? [NSJSONSerialization JSONObjectWithData:data options:0 error:nil] : @[];
|
|
169
|
+
NSMutableArray *buttons = [NSMutableArray new];
|
|
170
|
+
for (NSDictionary *action in [actions isKindOfClass:NSArray.class] ? actions : @[]) {
|
|
171
|
+
RNSwipeActionButton *button = [[RNSwipeActionButton alloc] initWithAction:action];
|
|
172
|
+
button.edge = edge;
|
|
173
|
+
button.owner = self;
|
|
174
|
+
[buttons addObject:button];
|
|
175
|
+
}
|
|
176
|
+
return buttons;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
|
180
|
+
{
|
|
181
|
+
const auto &value = *std::static_pointer_cast<const SwipeActionsProps>(props);
|
|
182
|
+
if (value.leadingActionsJson != _leadingJson || value.trailingActionsJson != _trailingJson) {
|
|
183
|
+
_leadingJson = value.leadingActionsJson;
|
|
184
|
+
_trailingJson = value.trailingActionsJson;
|
|
185
|
+
for (NSView *button in [_leading arrayByAddingObjectsFromArray:_trailing]) [button removeFromSuperview];
|
|
186
|
+
_leading = [self buttonsFromJson:_leadingJson edge:1];
|
|
187
|
+
_trailing = [self buttonsFromJson:_trailingJson edge:-1];
|
|
188
|
+
for (NSView *button in [_leading arrayByAddingObjectsFromArray:_trailing]) [_actionsView addSubview:button];
|
|
189
|
+
[self resetPosition];
|
|
190
|
+
}
|
|
191
|
+
[super updateProps:props oldProps:oldProps];
|
|
192
|
+
// Revealed actions and slid-away content must never paint over neighboring rows.
|
|
193
|
+
self.clipsToBounds = YES;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
- (void)updateLayoutMetrics:(const LayoutMetrics &)layoutMetrics oldLayoutMetrics:(const LayoutMetrics &)oldLayoutMetrics
|
|
197
|
+
{
|
|
198
|
+
[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
|
|
199
|
+
[self layoutSubviews];
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
- (void)layoutSubviews
|
|
203
|
+
{
|
|
204
|
+
[super layoutSubviews];
|
|
205
|
+
_clipView.frame = self.bounds;
|
|
206
|
+
_actionsView.frame = _clipView.bounds;
|
|
207
|
+
if (_dismissed) _offset = _offset > 0 ? self.bounds.size.width : -self.bounds.size.width;
|
|
208
|
+
[self applyOffset];
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
- (void)prepareForRecycle
|
|
212
|
+
{
|
|
213
|
+
[super prepareForRecycle];
|
|
214
|
+
[self resetPosition];
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
- (void)resetPosition
|
|
218
|
+
{
|
|
219
|
+
// Invalidate delayed action completions before this view acquires a new owner or actions.
|
|
220
|
+
++_generation;
|
|
221
|
+
if (RNSwipeOpenRow == self) RNSwipeOpenRow = nil;
|
|
222
|
+
[_pending removeAllObjects];
|
|
223
|
+
_gesture = RNSwipeGestureIdle;
|
|
224
|
+
_offset = 0;
|
|
225
|
+
_takeover = nil;
|
|
226
|
+
_dismissed = NO;
|
|
227
|
+
[self applyOffset];
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
231
|
+
{
|
|
232
|
+
return concreteComponentDescriptorProvider<SwipeActionsComponentDescriptor>();
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
#pragma mark - Layout
|
|
236
|
+
|
|
237
|
+
- (void)applyOffset
|
|
238
|
+
{
|
|
239
|
+
NSRect bounds = _clipView.bounds;
|
|
240
|
+
_contentView.frame = NSOffsetRect(bounds, _offset, 0);
|
|
241
|
+
[self layoutButtons:_leading reveal:MAX(0, _offset) bounds:bounds];
|
|
242
|
+
[self layoutButtons:_trailing reveal:MAX(0, -_offset) bounds:bounds];
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** The first action sits at the outer edge; a takeover button fills the whole revealed strip. */
|
|
246
|
+
- (void)layoutButtons:(NSArray<RNSwipeActionButton *> *)buttons reveal:(CGFloat)reveal bounds:(NSRect)bounds
|
|
247
|
+
{
|
|
248
|
+
CGFloat height = bounds.size.height, width = bounds.size.width, each = buttons.count ? reveal / buttons.count : 0;
|
|
249
|
+
[buttons enumerateObjectsUsingBlock:^(RNSwipeActionButton *button, NSUInteger index, BOOL *stop) {
|
|
250
|
+
BOOL takesAll = button == self->_takeover, collapsed = !takesAll && [buttons containsObject:self->_takeover];
|
|
251
|
+
CGFloat size = takesAll ? reveal : collapsed ? 0 : each;
|
|
252
|
+
CGFloat inner = takesAll ? 0 : collapsed ? reveal : index * each;
|
|
253
|
+
CGFloat x = button.edge > 0 ? inner : width - inner - size;
|
|
254
|
+
button.followsContent = takesAll;
|
|
255
|
+
button.frame = NSMakeRect(x, 0, size, height);
|
|
256
|
+
button.needsLayout = YES;
|
|
257
|
+
[button layoutSubtreeIfNeeded];
|
|
258
|
+
}];
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
- (NSArray<RNSwipeActionButton *> *)buttonsForOffset:(CGFloat)offset { return offset > 0 ? _leading : offset < 0 ? _trailing : @[]; }
|
|
262
|
+
|
|
263
|
+
- (CGFloat)commitDistance
|
|
264
|
+
{
|
|
265
|
+
CGFloat width = self.bounds.size.width;
|
|
266
|
+
return MIN(MAX(width * 0.45, 150), width - 24);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
#pragma mark - Gesture
|
|
270
|
+
|
|
271
|
+
- (CGFloat)resisted:(CGFloat)offset
|
|
272
|
+
{
|
|
273
|
+
if ([self buttonsForOffset:offset].count) return MAX(-self.bounds.size.width, MIN(self.bounds.size.width, offset));
|
|
274
|
+
CGFloat distance = fabs(offset);
|
|
275
|
+
return copysign(kRubberLimit * distance / (distance + kRubberLimit), offset);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
- (void)scrollWheel:(NSEvent *)event
|
|
279
|
+
{
|
|
280
|
+
if (_dismissed || (!_leading.count && !_trailing.count)) { [super scrollWheel:event]; return; }
|
|
281
|
+
// Momentum and plain mouse wheels carry no gesture phase.
|
|
282
|
+
if (event.phase == NSEventPhaseNone || event.phase == NSEventPhaseMayBegin) {
|
|
283
|
+
if (_gesture == RNSwipeGestureTracking && event.momentumPhase != NSEventPhaseNone) return;
|
|
284
|
+
[super scrollWheel:event];
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
if (event.phase == NSEventPhaseBegan) {
|
|
288
|
+
[_pending removeAllObjects];
|
|
289
|
+
_gesture = RNSwipeGestureUndecided;
|
|
290
|
+
_pendingX = 0;
|
|
291
|
+
_pendingY = 0;
|
|
292
|
+
}
|
|
293
|
+
CGFloat dx = event.directionInvertedFromDevice ? event.scrollingDeltaX : -event.scrollingDeltaX;
|
|
294
|
+
BOOL ended = event.phase == NSEventPhaseEnded || event.phase == NSEventPhaseCancelled;
|
|
295
|
+
|
|
296
|
+
if (_gesture == RNSwipeGestureUndecided) {
|
|
297
|
+
// Held back until the axis is clear, then replayed to the list if the gesture is vertical.
|
|
298
|
+
[_pending addObject:event];
|
|
299
|
+
_pendingX += dx;
|
|
300
|
+
_pendingY += event.scrollingDeltaY;
|
|
301
|
+
if (!ended && hypot(_pendingX, _pendingY) < kAxisDistance) return;
|
|
302
|
+
if (!ended && fabs(_pendingX) > fabs(_pendingY) * 1.4) {
|
|
303
|
+
_gesture = RNSwipeGestureTracking;
|
|
304
|
+
[_pending removeAllObjects];
|
|
305
|
+
if (RNSwipeOpenRow && RNSwipeOpenRow != self) [RNSwipeOpenRow close];
|
|
306
|
+
[self trackBy:_pendingX];
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
_gesture = RNSwipeGesturePassing;
|
|
310
|
+
if (RNSwipeOpenRow) [RNSwipeOpenRow close];
|
|
311
|
+
NSArray *replay = [_pending copy];
|
|
312
|
+
[_pending removeAllObjects];
|
|
313
|
+
for (NSEvent *pending in replay) [super scrollWheel:pending];
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
if (_gesture == RNSwipeGestureTracking) {
|
|
317
|
+
if (event.phase == NSEventPhaseCancelled) [self close];
|
|
318
|
+
else if (ended) [self settle];
|
|
319
|
+
else [self trackBy:dx];
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
[super scrollWheel:event];
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
- (void)trackBy:(CGFloat)dx
|
|
326
|
+
{
|
|
327
|
+
// Accumulate in unresisted space so rubber-banding does not drift.
|
|
328
|
+
CGFloat raw = _offset + dx;
|
|
329
|
+
if (![self buttonsForOffset:_offset].count && _offset != 0) {
|
|
330
|
+
CGFloat distance = fabs(_offset);
|
|
331
|
+
raw = copysign(kRubberLimit * distance / MAX(kRubberLimit - distance, 1), _offset) + dx;
|
|
332
|
+
}
|
|
333
|
+
_offset = [self resisted:raw];
|
|
334
|
+
NSArray<RNSwipeActionButton *> *buttons = [self buttonsForOffset:_offset];
|
|
335
|
+
CGFloat restDistance = MIN(kButtonWidth * buttons.count, self.bounds.size.width);
|
|
336
|
+
// A closing gesture must never arm just because the resting buttons exceed the threshold.
|
|
337
|
+
RNSwipeActionButton *takeover = fabs(_offset) > restDistance && fabs(_offset) >= [self commitDistance] ? buttons.firstObject : nil;
|
|
338
|
+
if (takeover != _takeover) {
|
|
339
|
+
_takeover = takeover;
|
|
340
|
+
[NSHapticFeedbackManager.defaultPerformer performFeedbackPattern:NSHapticFeedbackPatternAlignment performanceTime:NSHapticFeedbackPerformanceTimeNow];
|
|
341
|
+
RNSwipeAnimate(0.22, ^{ [self applyOffset]; }, nil);
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
[self applyOffset];
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// The gesture stays Tracking until the next one begins, so its momentum never scrolls the list.
|
|
348
|
+
- (void)settle
|
|
349
|
+
{
|
|
350
|
+
NSArray<RNSwipeActionButton *> *buttons = [self buttonsForOffset:_offset];
|
|
351
|
+
if (_takeover) { [self commit:_takeover]; return; }
|
|
352
|
+
if (buttons.count && fabs(_offset) > kButtonWidth * 0.5) {
|
|
353
|
+
_offset = copysign(MIN(kButtonWidth * buttons.count, self.bounds.size.width), _offset);
|
|
354
|
+
RNSwipeOpenRow = self;
|
|
355
|
+
RNSwipeAnimate(0.34, ^{ [self applyOffset]; }, nil);
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
[self close];
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
- (void)close
|
|
362
|
+
{
|
|
363
|
+
if (RNSwipeOpenRow == self) RNSwipeOpenRow = nil;
|
|
364
|
+
if (_offset == 0 || _dismissed) return;
|
|
365
|
+
_offset = 0;
|
|
366
|
+
_takeover = nil;
|
|
367
|
+
RNSwipeAnimate(0.32, ^{ [self applyOffset]; }, nil);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
- (void)performActionForButton:(RNSwipeActionButton *)button
|
|
371
|
+
{
|
|
372
|
+
if (_dismissed) return;
|
|
373
|
+
[self commit:button];
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/** Dismissing actions carry the row away and report once it is gone; others report while it springs back. */
|
|
377
|
+
- (void)commit:(RNSwipeActionButton *)button
|
|
378
|
+
{
|
|
379
|
+
if (RNSwipeOpenRow == self) RNSwipeOpenRow = nil;
|
|
380
|
+
NSString *actionId = button.actionId;
|
|
381
|
+
if (!button.dismisses) {
|
|
382
|
+
[self close];
|
|
383
|
+
[self emit:actionId];
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
_dismissed = YES;
|
|
387
|
+
_takeover = button;
|
|
388
|
+
_offset = button.edge * self.bounds.size.width;
|
|
389
|
+
NSUInteger generation = _generation;
|
|
390
|
+
__weak RNSwipeActions *weakSelf = self;
|
|
391
|
+
RNSwipeAnimate(0.26, ^{ [self applyOffset]; }, ^{
|
|
392
|
+
RNSwipeActions *view = weakSelf;
|
|
393
|
+
if (view && view->_generation == generation && view->_dismissed) [view emit:actionId];
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
- (void)emit:(NSString *)actionId
|
|
398
|
+
{
|
|
399
|
+
auto emitter = std::static_pointer_cast<const SwipeActionsEventEmitter>(_eventEmitter);
|
|
400
|
+
if (emitter) emitter->onSwipeAction({.actionId = std::string(actionId.UTF8String)});
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
#pragma mark - Clicks while open
|
|
404
|
+
|
|
405
|
+
- (NSView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
|
|
406
|
+
{
|
|
407
|
+
NSView *hit = [super hitTest:point withEvent:event];
|
|
408
|
+
// Fabric parents use this local-coordinate route; AppKit's route delegates here too.
|
|
409
|
+
// Respect the superclass visibility/pointer-events result before consuming a close click.
|
|
410
|
+
if (hit && _offset != 0 && !_dismissed && NSPointInRect(point, self.bounds) && NSPointInRect(point, _contentView.frame)) return self;
|
|
411
|
+
return hit;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
- (BOOL)mouseDownCanMoveWindow { return _offset == 0 && super.mouseDownCanMoveWindow; }
|
|
415
|
+
|
|
416
|
+
- (void)mouseDown:(NSEvent *)event
|
|
417
|
+
{
|
|
418
|
+
if (_offset != 0) [self close];
|
|
419
|
+
else [super mouseDown:event];
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
@end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#import <React/RCTViewComponentView.h>
|
|
2
|
+
#import <TargetConditionals.h>
|
|
3
|
+
|
|
4
|
+
#if TARGET_OS_OSX
|
|
5
|
+
#import <AppKit/AppKit.h>
|
|
6
|
+
#else
|
|
7
|
+
#import <UIKit/UIKit.h>
|
|
8
|
+
#endif
|
|
9
|
+
|
|
10
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
11
|
+
|
|
12
|
+
@interface RNTextInputSearch : RCTViewComponentView
|
|
13
|
+
@end
|
|
14
|
+
|
|
15
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
#import "RNTextInputSearch.h"
|
|
2
|
+
|
|
3
|
+
#import <react/renderer/components/RNSparkUISpec/ComponentDescriptors.h>
|
|
4
|
+
#import <react/renderer/components/RNSparkUISpec/EventEmitters.h>
|
|
5
|
+
#import <react/renderer/components/RNSparkUISpec/Props.h>
|
|
6
|
+
#import <react/renderer/components/RNSparkUISpec/RCTComponentViewHelpers.h>
|
|
7
|
+
|
|
8
|
+
using namespace facebook::react;
|
|
9
|
+
|
|
10
|
+
#if TARGET_OS_OSX
|
|
11
|
+
static NSAppearance *RNTextInputSearchAppearanceForName(NSString *appearanceName)
|
|
12
|
+
{
|
|
13
|
+
if ([appearanceName isEqualToString:@"light"]) {
|
|
14
|
+
return [NSAppearance appearanceNamed:NSAppearanceNameAqua];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if ([appearanceName isEqualToString:@"dark"]) {
|
|
18
|
+
return [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return nil;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
@interface RNTextInputSearch () <
|
|
27
|
+
#if TARGET_OS_OSX
|
|
28
|
+
NSSearchFieldDelegate,
|
|
29
|
+
#endif
|
|
30
|
+
RCTTextInputSearchViewProtocol
|
|
31
|
+
>
|
|
32
|
+
@end
|
|
33
|
+
|
|
34
|
+
@implementation RNTextInputSearch {
|
|
35
|
+
#if TARGET_OS_OSX
|
|
36
|
+
NSSearchField *_textField;
|
|
37
|
+
BOOL _hasSetDefaultText;
|
|
38
|
+
int _eventCount;
|
|
39
|
+
#else
|
|
40
|
+
UIView *_textField;
|
|
41
|
+
#endif
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
- (instancetype)init
|
|
45
|
+
{
|
|
46
|
+
if (self = [super init]) {
|
|
47
|
+
_props = std::make_shared<const TextInputSearchProps>();
|
|
48
|
+
#if TARGET_OS_OSX
|
|
49
|
+
_textField = [NSSearchField new];
|
|
50
|
+
_textField.delegate = self;
|
|
51
|
+
_textField.focusRingType = NSFocusRingTypeNone;
|
|
52
|
+
_textField.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
|
|
53
|
+
[self addSubview:_textField];
|
|
54
|
+
#else
|
|
55
|
+
_textField = [UIView new];
|
|
56
|
+
[self addSubview:_textField];
|
|
57
|
+
#endif
|
|
58
|
+
}
|
|
59
|
+
return self;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
#if TARGET_OS_OSX
|
|
63
|
+
- (BOOL)isFlipped
|
|
64
|
+
{
|
|
65
|
+
return YES;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
- (void)controlTextDidChange:(NSNotification *)notification
|
|
69
|
+
{
|
|
70
|
+
if (notification.object != _textField || !_textField.enabled) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
++_eventCount;
|
|
74
|
+
const auto eventEmitter = std::static_pointer_cast<const TextInputSearchEventEmitter>(_eventEmitter);
|
|
75
|
+
if (eventEmitter) {
|
|
76
|
+
eventEmitter->onChangeText(TextInputSearchEventEmitter::OnChangeText{
|
|
77
|
+
.text = _textField.stringValue.UTF8String ?: "",
|
|
78
|
+
.eventCount = _eventCount,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
#endif
|
|
83
|
+
|
|
84
|
+
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
|
85
|
+
{
|
|
86
|
+
const auto &newProps = *std::static_pointer_cast<TextInputSearchProps const>(props);
|
|
87
|
+
#if TARGET_OS_OSX
|
|
88
|
+
NSString *appearanceName = [NSString stringWithUTF8String:newProps.appearance.c_str()];
|
|
89
|
+
NSAppearance *appearance = RNTextInputSearchAppearanceForName(appearanceName);
|
|
90
|
+
self.appearance = appearance;
|
|
91
|
+
_textField.appearance = appearance;
|
|
92
|
+
|
|
93
|
+
_textField.enabled = !newProps.disabled;
|
|
94
|
+
_textField.accessibilityLabel = [NSString stringWithUTF8String:newProps.accessibilityLabel.c_str()];
|
|
95
|
+
_textField.accessibilityIdentifier = [NSString stringWithUTF8String:newProps.testId.c_str()];
|
|
96
|
+
NSString *placeholder = [NSString stringWithUTF8String:newProps.placeholder.c_str()];
|
|
97
|
+
_textField.placeholderString = placeholder;
|
|
98
|
+
|
|
99
|
+
if (!_hasSetDefaultText) {
|
|
100
|
+
_textField.stringValue = [NSString stringWithUTF8String:newProps.defaultText.c_str()];
|
|
101
|
+
_hasSetDefaultText = YES;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (newProps.controlled && newProps.eventCount >= _eventCount) {
|
|
105
|
+
NSString *text = [NSString stringWithUTF8String:newProps.text.c_str()];
|
|
106
|
+
if (![_textField.stringValue isEqualToString:text]) {
|
|
107
|
+
_textField.stringValue = text;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
#endif
|
|
111
|
+
[super updateProps:props oldProps:oldProps];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args
|
|
115
|
+
{
|
|
116
|
+
RCTTextInputSearchHandleCommand(self, commandName, args);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
- (void)focus
|
|
120
|
+
{
|
|
121
|
+
#if TARGET_OS_OSX
|
|
122
|
+
if (_textField.enabled) [self.window makeFirstResponder:_textField];
|
|
123
|
+
#endif
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
- (void)blur
|
|
127
|
+
{
|
|
128
|
+
#if TARGET_OS_OSX
|
|
129
|
+
if (self.window.firstResponder == _textField || _textField.currentEditor == self.window.firstResponder) [self.window makeFirstResponder:nil];
|
|
130
|
+
#endif
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
- (void)prepareForRecycle
|
|
134
|
+
{
|
|
135
|
+
[super prepareForRecycle];
|
|
136
|
+
#if TARGET_OS_OSX
|
|
137
|
+
_textField.stringValue = @"";
|
|
138
|
+
_textField.placeholderString = @"";
|
|
139
|
+
[_textField abortEditing];
|
|
140
|
+
_hasSetDefaultText = NO; _eventCount = 0; _textField.enabled = YES;
|
|
141
|
+
_textField.accessibilityLabel = nil; _textField.accessibilityIdentifier = nil;
|
|
142
|
+
self.appearance = nil; _textField.appearance = nil;
|
|
143
|
+
#endif
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
- (void)layoutSubviews
|
|
147
|
+
{
|
|
148
|
+
[super layoutSubviews];
|
|
149
|
+
_textField.frame = self.bounds;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
- (void)updateLayoutMetrics:(const LayoutMetrics &)layoutMetrics
|
|
153
|
+
oldLayoutMetrics:(const LayoutMetrics &)oldLayoutMetrics
|
|
154
|
+
{
|
|
155
|
+
[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
|
|
156
|
+
[self layoutSubviews];
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
160
|
+
{
|
|
161
|
+
return concreteComponentDescriptorProvider<TextInputSearchComponentDescriptor>();
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
@end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legendapp/spark-ui",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "src/index",
|
|
6
6
|
"react-native": "src/index",
|
|
@@ -39,8 +39,16 @@
|
|
|
39
39
|
"componentProvider": {
|
|
40
40
|
"SparkButton": "RNSparkButton",
|
|
41
41
|
"SparkTextInput": "RNSparkTextInput",
|
|
42
|
-
"
|
|
43
|
-
|
|
42
|
+
"SidebarSplitView": "RNSidebarSplitViewComponent",
|
|
43
|
+
"Sidebar": "RNSidebar",
|
|
44
|
+
"SidebarItem": "RNSidebarItem",
|
|
45
|
+
"SFSymbol": "RNSFSymbol",
|
|
46
|
+
"SwipeActions": "RNSwipeActions",
|
|
47
|
+
"NativeSelect": "RNNativeSelect",
|
|
48
|
+
"NativeSegmentedControl": "RNNativeSegmentedControl",
|
|
49
|
+
"TextInputSearch": "RNTextInputSearch"
|
|
50
|
+
},
|
|
51
|
+
"modulesProvider": {}
|
|
44
52
|
},
|
|
45
53
|
"windows": {
|
|
46
54
|
"namespace": "FrameUICodegen",
|
|
@@ -57,5 +65,10 @@
|
|
|
57
65
|
"windows"
|
|
58
66
|
]
|
|
59
67
|
},
|
|
60
|
-
"private": true
|
|
68
|
+
"private": true,
|
|
69
|
+
"dependencies": {
|
|
70
|
+
"clsx": "^2.1.1",
|
|
71
|
+
"tailwind-merge": "^3.4.0",
|
|
72
|
+
"@legendapp/spark-desktop-app": "0.0.1-next.4"
|
|
73
|
+
}
|
|
61
74
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { HostComponent, ViewProps } from "react-native";
|
|
2
|
-
import type { DirectEventHandler } from "react-native/Libraries/Types/CodegenTypes";
|
|
2
|
+
import type { DirectEventHandler, WithDefault, Int32 } from "react-native/Libraries/Types/CodegenTypes";
|
|
3
3
|
import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
|
|
4
4
|
export interface NativeProps extends ViewProps {
|
|
5
5
|
onUnavailable?: DirectEventHandler<Readonly<{ message: string }>>;
|
|
6
6
|
itemsJson: string;
|
|
7
|
+
disabled?: WithDefault<boolean, false>;
|
|
8
|
+
selectionRevision?: Int32;
|
|
7
9
|
value: string;
|
|
8
10
|
onSelectionChange?: DirectEventHandler<Readonly<{ value: string }>>;
|
|
9
11
|
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { HostComponent, ViewProps } from "react-native";
|
|
2
|
-
import type { DirectEventHandler } from "react-native/Libraries/Types/CodegenTypes";
|
|
2
|
+
import type { DirectEventHandler, WithDefault, Int32 } from "react-native/Libraries/Types/CodegenTypes";
|
|
3
3
|
import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
|
|
4
4
|
export interface NativeProps extends ViewProps {
|
|
5
5
|
onUnavailable?: DirectEventHandler<Readonly<{ message: string }>>;
|
|
6
6
|
defaultText?: string;
|
|
7
|
-
|
|
7
|
+
text?: string;
|
|
8
|
+
controlled?: WithDefault<boolean, false>;
|
|
9
|
+
disabled?: WithDefault<boolean, false>;
|
|
10
|
+
eventCount?: Int32;
|
|
11
|
+
onTextChange?: DirectEventHandler<Readonly<{ text: string; eventCount: Int32 }>>;
|
|
8
12
|
}
|
|
9
13
|
export default codegenNativeComponent<NativeProps>("SparkTextInput") as HostComponent<NativeProps>;
|