@legendapp/spark 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/init-template.cjs +7 -1
  2. package/package.json +11 -6
  3. package/patches/dependencies.json +4 -4
  4. package/patches/react-native-mmkv@4.3.2.patch +2 -2
  5. package/patches/react-native-nitro-zxing@0.3.1.patch +22 -0
  6. package/patches/registry.json +615 -0
  7. package/patches/workspace/expo-audio@55.0.18.patch +159 -0
  8. package/patches/workspace/op-engineering-op-sqlite@18.2.1.patch +796 -0
  9. package/patches/workspace/react-native-nitro-modules@0.37.0.patch +1348 -0
  10. package/patches/workspace/react-native-runtimes-core@0.1.0-alpha.2.patch +276 -0
  11. package/patches/workspace/react-native-webview@16.0.0.patch +208 -0
  12. package/postinstall.cjs +10 -1
  13. package/skills/spark/SKILL.md +37 -4
  14. package/skills/spark/UPGRADING.md +174 -1
  15. package/skills/spark/ai-customize.md +39 -0
  16. package/skills/spark/app-and-documents.md +56 -0
  17. package/skills/spark/external-libraries.md +87 -0
  18. package/skills/spark/files.md +64 -0
  19. package/skills/spark/integrations.md +69 -0
  20. package/skills/spark/keyboard.md +54 -0
  21. package/skills/spark/library-compat.md +76 -0
  22. package/skills/spark/menus-tray-dock.md +83 -0
  23. package/skills/spark/storage-settings.md +59 -0
  24. package/skills/spark/ui.md +83 -0
  25. package/skills/spark/windows.md +91 -0
  26. package/ui-popover.ts +1 -0
  27. package/ui-progress.ts +1 -0
  28. package/ui-sheet.ts +1 -0
  29. package/ui-split-view.ts +1 -0
  30. package/ui-table.ts +1 -0
  31. package/vendor/node_modules/@legendapp/spark-ai/package.json +3 -3
  32. package/vendor/node_modules/@legendapp/spark-audio/package.json +3 -13
  33. package/vendor/node_modules/@legendapp/spark-auth-session/package.json +3 -10
  34. package/vendor/node_modules/@legendapp/spark-cli/dist/add-desktop.js +5 -0
  35. package/vendor/node_modules/@legendapp/spark-cli/dist/build.js +157 -106
  36. package/vendor/node_modules/@legendapp/spark-cli/dist/cli-arguments.js +4 -1
  37. package/vendor/node_modules/@legendapp/spark-cli/dist/commands.js +16 -7
  38. package/vendor/node_modules/@legendapp/spark-cli/dist/dependency-pins.js +19 -3
  39. package/vendor/node_modules/@legendapp/spark-cli/dist/dev-command.js +2 -0
  40. package/vendor/node_modules/@legendapp/spark-cli/dist/dev.js +3 -0
  41. package/vendor/node_modules/@legendapp/spark-cli/dist/enriched-html-pins.js +2 -0
  42. package/vendor/node_modules/@legendapp/spark-cli/dist/errors.js +1 -1
  43. package/vendor/node_modules/@legendapp/spark-cli/dist/index.js +57 -9
  44. package/vendor/node_modules/@legendapp/spark-cli/dist/init-template.cjs +12 -2
  45. package/vendor/node_modules/@legendapp/spark-cli/dist/init-template.d.cts +1 -1
  46. package/vendor/node_modules/@legendapp/spark-cli/dist/metro.cjs +1 -0
  47. package/vendor/node_modules/@legendapp/spark-cli/dist/migrate.js +65 -0
  48. package/vendor/node_modules/@legendapp/spark-cli/dist/migration-helpers.cjs +4 -4
  49. package/vendor/node_modules/@legendapp/spark-cli/dist/migration-helpers.d.cts +2 -2
  50. package/vendor/node_modules/@legendapp/spark-cli/dist/migrations.cjs +15 -8
  51. package/vendor/node_modules/@legendapp/spark-cli/dist/native-patch-preflight.js +35 -7
  52. package/vendor/node_modules/@legendapp/spark-cli/dist/package.js +4 -8
  53. package/vendor/node_modules/@legendapp/spark-cli/dist/patch.js +92 -0
  54. package/vendor/node_modules/@legendapp/spark-cli/dist/project-version.js +12 -4
  55. package/vendor/node_modules/@legendapp/spark-cli/dist/project.js +8 -1
  56. package/vendor/node_modules/@legendapp/spark-cli/dist/publish-directory.js +32 -0
  57. package/vendor/node_modules/@legendapp/spark-cli/dist/release-app.js +139 -0
  58. package/vendor/node_modules/@legendapp/spark-cli/dist/release.json +17 -17
  59. package/vendor/node_modules/@legendapp/spark-cli/dist/signing.js +61 -41
  60. package/vendor/node_modules/@legendapp/spark-cli/dist/upgrade.js +1 -1
  61. package/vendor/node_modules/@legendapp/spark-cli/dist/windows.js +3 -0
  62. package/vendor/node_modules/@legendapp/spark-cli/package.json +5 -4
  63. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/package.json +2 -2
  64. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/package.json +2 -2
  65. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/package.json +2 -2
  66. package/vendor/node_modules/@legendapp/spark-clipboard/macos/RNDesktopClipboard.mm +1 -1
  67. package/vendor/node_modules/@legendapp/spark-clipboard/package.json +3 -10
  68. package/vendor/node_modules/@legendapp/spark-clipboard/src/desktop.ts +1 -0
  69. package/vendor/node_modules/@legendapp/spark-codex/package.json +3 -7
  70. package/vendor/node_modules/@legendapp/spark-commands/package.json +5 -5
  71. package/vendor/node_modules/@legendapp/spark-context-menu/package.json +3 -10
  72. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.h +3 -1
  73. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.mm +51 -10
  74. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkStorage.h +4 -0
  75. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkStorage.mm +82 -0
  76. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkTestDriver.h +2 -0
  77. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkTestDriver.mm +1 -0
  78. package/vendor/node_modules/@legendapp/spark-desktop-app/package.json +2 -8
  79. package/vendor/node_modules/@legendapp/spark-desktop-config/app.plugin.cjs +1 -0
  80. package/vendor/node_modules/@legendapp/spark-desktop-config/config.cjs +6 -8
  81. package/vendor/node_modules/@legendapp/spark-desktop-config/identity.cjs +2 -0
  82. package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.cjs +300 -71
  83. package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.d.cts +7 -0
  84. package/vendor/node_modules/@legendapp/spark-desktop-config/package.json +3 -3
  85. package/vendor/node_modules/@legendapp/spark-desktop-config/patch-registry.cjs +318 -0
  86. package/vendor/node_modules/@legendapp/spark-desktop-config/patch-registry.d.cts +20 -0
  87. package/vendor/node_modules/@legendapp/spark-desktop-config/rpaths.cjs +20 -0
  88. package/vendor/node_modules/@legendapp/spark-desktop-config/rpaths.d.cts +1 -0
  89. package/vendor/node_modules/@legendapp/spark-desktop-config/validation.cjs +66 -9
  90. package/vendor/node_modules/@legendapp/spark-desktop-config/windows.plugin.cjs +1 -0
  91. package/vendor/node_modules/@legendapp/spark-desktop-host/AppDelegate.mm +17 -5
  92. package/vendor/node_modules/@legendapp/spark-desktop-host/package.json +2 -2
  93. package/vendor/node_modules/@legendapp/spark-desktop-links/package.json +3 -10
  94. package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/package.json +3 -10
  95. package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/RNDesktopWindows.mm +7 -2
  96. package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/RNWindowManager.mm +235 -240
  97. package/vendor/node_modules/@legendapp/spark-desktop-windows/package.json +4 -11
  98. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/api.ts +9 -3
  99. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/macos-adapter.ts +7 -0
  100. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/types.ts +32 -3
  101. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/validation.ts +28 -11
  102. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/createWindowsNavigator.tsx +15 -3
  103. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/primaryWindowLifecycle.ts +12 -3
  104. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/usePrimaryWindowLifecycle.ts +2 -1
  105. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/useWindowFocusEffect.ts +4 -1
  106. package/vendor/node_modules/@legendapp/spark-documents/package.json +7 -7
  107. package/vendor/node_modules/@legendapp/spark-drag-drop/macos/RNDesktopDragView.mm +77 -17
  108. package/vendor/node_modules/@legendapp/spark-drag-drop/package.json +3 -8
  109. package/vendor/node_modules/@legendapp/spark-drag-drop/src/DesktopDragViewNativeComponent.ts +1 -0
  110. package/vendor/node_modules/@legendapp/spark-drag-drop/src/contracts.ts +13 -4
  111. package/vendor/node_modules/@legendapp/spark-drag-drop/src/index.tsx +5 -3
  112. package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/SparkDragDrop.h +6 -1
  113. package/vendor/node_modules/@legendapp/spark-expo-compat/metro.cjs +44 -0
  114. package/vendor/node_modules/@legendapp/spark-expo-compat/package.json +20 -0
  115. package/vendor/node_modules/@legendapp/spark-expo-compat/src/clipboard.ts +40 -0
  116. package/vendor/node_modules/@legendapp/spark-expo-compat/src/document-picker.ts +52 -0
  117. package/vendor/node_modules/@legendapp/spark-file-dialog/package.json +3 -10
  118. package/vendor/node_modules/@legendapp/spark-file-dialog/src/options.ts +5 -2
  119. package/vendor/node_modules/@legendapp/spark-file-dialog/src/types.ts +3 -3
  120. package/vendor/node_modules/@legendapp/spark-file-system/macos/RNDesktopFileSystem.mm +1 -1
  121. package/vendor/node_modules/@legendapp/spark-file-system/package.json +3 -11
  122. package/vendor/node_modules/@legendapp/spark-global-shortcuts/package.json +3 -10
  123. package/vendor/node_modules/@legendapp/spark-html/package.json +2 -2
  124. package/vendor/node_modules/@legendapp/spark-markdown/package.json +2 -2
  125. package/vendor/node_modules/@legendapp/spark-message-dialog/package.json +3 -10
  126. package/vendor/node_modules/@legendapp/spark-message-dialog/src/index.ts +1 -0
  127. package/vendor/node_modules/@legendapp/spark-native-menu/package.json +3 -9
  128. package/vendor/node_modules/@legendapp/spark-native-menu/src/hooks.ts +4 -0
  129. package/vendor/node_modules/@legendapp/spark-notifications/package.json +3 -10
  130. package/vendor/node_modules/@legendapp/spark-processes/package.json +3 -10
  131. package/vendor/node_modules/@legendapp/spark-rich-text/package.json +2 -2
  132. package/vendor/node_modules/@legendapp/spark-secure-storage/package.json +3 -10
  133. package/vendor/node_modules/@legendapp/spark-settings/package.json +3 -3
  134. package/vendor/node_modules/@legendapp/spark-settings-ui/package.json +4 -4
  135. package/vendor/node_modules/@legendapp/spark-settings-ui/src/index.tsx +122 -334
  136. package/vendor/node_modules/@legendapp/spark-settings-ui/src/rows.tsx +183 -0
  137. package/vendor/node_modules/@legendapp/spark-sqlite/package.json +3 -3
  138. package/vendor/node_modules/@legendapp/spark-system/package.json +3 -10
  139. package/vendor/node_modules/@legendapp/spark-tray/package.json +3 -10
  140. package/vendor/node_modules/@legendapp/spark-tray/src/index.ts +2 -1
  141. package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkButton.mm +82 -14
  142. package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkTextInput.h +1 -1
  143. package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkTextInput.mm +94 -11
  144. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSidebarSplitViewComponent.mm +235 -18
  145. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkPaneSplitView.h +17 -0
  146. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkPaneSplitView.mm +216 -0
  147. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkSplitViewComponent.h +4 -0
  148. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkSplitViewComponent.mm +212 -0
  149. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkSplitViewUpdates.h +6 -0
  150. package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSegmentedControl.mm +28 -13
  151. package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSelect.mm +17 -1
  152. package/vendor/node_modules/@legendapp/spark-ui/macos/popover/RNSparkPopover.h +9 -0
  153. package/vendor/node_modules/@legendapp/spark-ui/macos/popover/RNSparkPopover.mm +126 -0
  154. package/vendor/node_modules/@legendapp/spark-ui/macos/progress/RNSparkProgressIndicator.h +9 -0
  155. package/vendor/node_modules/@legendapp/spark-ui/macos/progress/RNSparkProgressIndicator.mm +66 -0
  156. package/vendor/node_modules/@legendapp/spark-ui/macos/radio-group/RNSparkRadioGroup.h +9 -0
  157. package/vendor/node_modules/@legendapp/spark-ui/macos/radio-group/RNSparkRadioGroup.mm +118 -0
  158. package/vendor/node_modules/@legendapp/spark-ui/macos/sf-symbol/RNSFSymbol.mm +4 -12
  159. package/vendor/node_modules/@legendapp/spark-ui/macos/sheet/RNSparkSheet.h +9 -0
  160. package/vendor/node_modules/@legendapp/spark-ui/macos/sheet/RNSparkSheet.mm +109 -0
  161. package/vendor/node_modules/@legendapp/spark-ui/macos/sidebar/RNSidebar.mm +438 -102
  162. package/vendor/node_modules/@legendapp/spark-ui/macos/table/RNSparkTable.h +9 -0
  163. package/vendor/node_modules/@legendapp/spark-ui/macos/table/RNSparkTable.mm +179 -0
  164. package/vendor/node_modules/@legendapp/spark-ui/package.json +9 -8
  165. package/vendor/node_modules/@legendapp/spark-ui/src/SparkButtonNativeComponent.ts +10 -2
  166. package/vendor/node_modules/@legendapp/spark-ui/src/SparkTextInputNativeComponent.ts +2 -0
  167. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SidebarSplitViewNativeComponent.ts +9 -0
  168. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SplitView.tsx +99 -0
  169. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SplitViewNativeComponent.ts +29 -0
  170. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/index.tsx +34 -17
  171. package/vendor/node_modules/@legendapp/spark-ui/src/availability.ts +6 -4
  172. package/vendor/node_modules/@legendapp/spark-ui/src/checkbox-unavailable.tsx +20 -0
  173. package/vendor/node_modules/@legendapp/spark-ui/src/control.ts +24 -3
  174. package/vendor/node_modules/@legendapp/spark-ui/src/desktop.tsx +72 -20
  175. package/vendor/node_modules/@legendapp/spark-ui/src/index.android.tsx +18 -12
  176. package/vendor/node_modules/@legendapp/spark-ui/src/index.ios.tsx +21 -15
  177. package/vendor/node_modules/@legendapp/spark-ui/src/index.web.tsx +40 -16
  178. package/vendor/node_modules/@legendapp/spark-ui/src/mobile-input.tsx +2 -2
  179. package/vendor/node_modules/@legendapp/spark-ui/src/native-select/NativeSegmentedControlNativeComponent.ts +3 -1
  180. package/vendor/node_modules/@legendapp/spark-ui/src/native-select/NativeSelectNativeComponent.ts +1 -0
  181. package/vendor/node_modules/@legendapp/spark-ui/src/popover/PopoverNativeComponent.ts +20 -0
  182. package/vendor/node_modules/@legendapp/spark-ui/src/popover/index.tsx +45 -0
  183. package/vendor/node_modules/@legendapp/spark-ui/src/progress/ProgressIndicatorNativeComponent.ts +13 -0
  184. package/vendor/node_modules/@legendapp/spark-ui/src/progress/index.tsx +32 -0
  185. package/vendor/node_modules/@legendapp/spark-ui/src/radio-group/RadioGroupNativeComponent.ts +17 -0
  186. package/vendor/node_modules/@legendapp/spark-ui/src/select.ts +4 -0
  187. package/vendor/node_modules/@legendapp/spark-ui/src/sheet/SheetNativeComponent.ts +15 -0
  188. package/vendor/node_modules/@legendapp/spark-ui/src/sheet/index.tsx +38 -0
  189. package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/SidebarItemNativeComponent.ts +9 -1
  190. package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/SidebarNativeComponent.ts +17 -2
  191. package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/index.tsx +106 -22
  192. package/vendor/node_modules/@legendapp/spark-ui/src/switch.tsx +13 -0
  193. package/vendor/node_modules/@legendapp/spark-ui/src/table/TableNativeComponent.ts +22 -0
  194. package/vendor/node_modules/@legendapp/spark-ui/src/table/index.tsx +118 -0
  195. package/vendor/node_modules/@legendapp/spark-ui/src/types.ts +52 -7
  196. package/vendor/node_modules/@legendapp/spark-ui/uniwind.ts +3 -1
  197. package/vendor/node_modules/@legendapp/spark-ui/uniwind.web.ts +2 -1
  198. package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/SparkUI.h +46 -15
  199. package/vendor/node_modules/@legendapp/spark-updates/package.json +3 -9
  200. package/vendor/node_modules/@legendapp/spark-webview/package.json +2 -2
  201. package/vendor/node_modules/@legendapp/spark-window-options/package.json +1 -1
  202. /package/{settings-window.ts → ui-settings.ts} +0 -0
@@ -0,0 +1,183 @@
1
+ import { SegmentedControl, Select, Switch, type SelectOption } from "@legendapp/spark-ui";
2
+ import { selectionIndex } from "@legendapp/spark-ui/src/select";
3
+ import { SFSymbol } from "@legendapp/spark-ui/src/sf-symbol";
4
+ import { SparkError } from "@legendapp/spark-desktop-app/src/contracts";
5
+ import { Children, Fragment, useState, type ReactNode } from "react";
6
+ import * as RN from "react-native";
7
+ import type { ColorValue, ImageSourcePropType, NativeSyntheticEvent } from "react-native";
8
+
9
+ const { Image, Platform, PlatformColor, Pressable, StyleSheet, Text, View } = RN;
10
+
11
+ // The macOS type entry also declares globals. Keep the additions used here local.
12
+ const macOS = RN as typeof RN & {
13
+ DynamicColorMacOS(colors: { light: string; dark: string }): ColorValue;
14
+ };
15
+ type KeyEvent = NativeSyntheticEvent<{
16
+ key: string;
17
+ altKey: boolean;
18
+ ctrlKey: boolean;
19
+ metaKey: boolean;
20
+ shiftKey: boolean;
21
+ }>;
22
+ const cardColor = Platform.OS === "macos" ? macOS.DynamicColorMacOS({
23
+ light: "rgba(0,0,0,0.03)",
24
+ dark: "rgba(255,255,255,0.025)",
25
+ }) : undefined;
26
+
27
+ interface RowText {
28
+ label: string;
29
+ description?: string;
30
+ info?: string;
31
+ }
32
+ export interface SettingsSectionProps {
33
+ title?: string;
34
+ children: ReactNode;
35
+ }
36
+ export interface SettingsRowProps extends RowText {
37
+ children?: ReactNode;
38
+ }
39
+ export interface SettingsSwitchRowProps extends RowText {
40
+ value: boolean;
41
+ onValueChange: (value: boolean) => void;
42
+ disabled?: boolean;
43
+ }
44
+ export interface SettingsSelectRowProps extends RowText {
45
+ disabled?: boolean;
46
+ options: readonly SelectOption[];
47
+ value: string;
48
+ onValueChange: (value: string) => void;
49
+ }
50
+ export type SettingsSegmentedRowProps = SettingsSelectRowProps;
51
+ export interface SettingsImageChoiceOption extends SelectOption {
52
+ image: ImageSourcePropType;
53
+ }
54
+ export interface SettingsImageChoiceRowProps extends SettingsSelectRowProps {
55
+ options: readonly SettingsImageChoiceOption[];
56
+ }
57
+
58
+ export function SettingsSection({ title, children }: SettingsSectionProps) {
59
+ if (Platform.OS !== "macos") throw new SparkError("E_UNSUPPORTED_PLATFORM", "Settings sections require macOS");
60
+ return (
61
+ <View style={styles.section}>
62
+ {title ? <Text accessibilityRole="header" style={[styles.heading, { color: PlatformColor("labelColor") }]}>{title}</Text> : null}
63
+ <View style={styles.card}>
64
+ {Children.toArray(children).map((child, index) => (
65
+ <Fragment key={typeof child === "object" && "key" in child ? child.key : index}>
66
+ {index > 0 ? <View style={[styles.divider, { backgroundColor: PlatformColor("separatorColor") }]} /> : null}
67
+ {child}
68
+ </Fragment>
69
+ ))}
70
+ </View>
71
+ </View>
72
+ );
73
+ }
74
+
75
+ function Row({ label, description, info, children, disabled, imageChoice }: SettingsRowProps & { disabled?: boolean; imageChoice?: boolean }) {
76
+ if (Platform.OS !== "macos") throw new SparkError("E_UNSUPPORTED_PLATFORM", "Settings rows require macOS");
77
+ return (
78
+ <View style={[styles.row, imageChoice && styles.imageRow]}>
79
+ <View style={[styles.rowText, imageChoice && styles.imageRowText]}>
80
+ <View style={styles.labelLine}>
81
+ <Text style={[styles.label, { color: PlatformColor(disabled ? "tertiaryLabelColor" : "labelColor") }]}>{label}</Text>
82
+ {info ? <View accessible={false} {...{ tooltip: info }} style={styles.info}>
83
+ <SFSymbol accessible={false} name="info.circle" size={13} color={PlatformColor("secondaryLabelColor")} />
84
+ </View> : null}
85
+ </View>
86
+ {description ? <Text style={[styles.description, { color: PlatformColor(disabled ? "tertiaryLabelColor" : "secondaryLabelColor") }]}>{description}</Text> : null}
87
+ </View>
88
+ {children != null ? <View style={[styles.control, imageChoice && styles.imageControl]}>{children}</View> : null}
89
+ </View>
90
+ );
91
+ }
92
+
93
+ export function SettingsRow(props: SettingsRowProps) {
94
+ return <Row {...props} />;
95
+ }
96
+
97
+ function accessibility({ label, description, info }: RowText) {
98
+ return { accessibilityLabel: label, accessibilityHint: [description, info].filter(Boolean).join(" ") || undefined };
99
+ }
100
+
101
+ export function SettingsSwitchRow({ value, onValueChange, disabled, ...text }: SettingsSwitchRowProps) {
102
+ return <Row {...text} disabled={disabled}>
103
+ <Switch value={value} onValueChange={onValueChange} disabled={disabled} {...accessibility(text)} />
104
+ </Row>;
105
+ }
106
+
107
+ export function SettingsSelectRow({ value, options, onValueChange, disabled, ...text }: SettingsSelectRowProps) {
108
+ return <Row {...text} disabled={disabled}>
109
+ <Select options={options} value={value} onValueChange={onValueChange} disabled={disabled} variant="borderless" style={styles.selection} {...accessibility(text)} />
110
+ </Row>;
111
+ }
112
+
113
+ export function SettingsSegmentedRow({ value, options, onValueChange, disabled, ...text }: SettingsSegmentedRowProps) {
114
+ return <Row {...text} disabled={disabled}>
115
+ <SegmentedControl options={options} value={value} onValueChange={onValueChange} disabled={disabled} style={styles.selection} {...accessibility(text)} />
116
+ </Row>;
117
+ }
118
+
119
+ const choiceKeys = [{ key: "ArrowLeft" }, { key: "ArrowRight" }];
120
+
121
+ export function SettingsImageChoiceRow({ options, value, onValueChange, disabled = false, ...text }: SettingsImageChoiceRowProps) {
122
+ if (!Array.isArray(options) || options.some(option => option?.image == null) || typeof onValueChange !== "function" || typeof disabled !== "boolean") {
123
+ throw new SparkError("E_INVALID_ARGUMENT", "Image choices require options with images and onValueChange");
124
+ }
125
+ const selectedIndex = selectionIndex(options.map(({ image, ...option }) => option), value);
126
+ const [focused, setFocused] = useState(false);
127
+ const accentColor = PlatformColor("controlAccentColor");
128
+ function choose(next: string) {
129
+ if (!disabled && next !== value) onValueChange(next);
130
+ }
131
+ function onKeyDown({ nativeEvent }: KeyEvent) {
132
+ const { key, altKey, ctrlKey, metaKey, shiftKey } = nativeEvent;
133
+ if (altKey || ctrlKey || metaKey || shiftKey) return;
134
+ const step = key === "ArrowLeft" ? -1 : key === "ArrowRight" ? 1 : 0;
135
+ if (step) choose(options[(selectedIndex + step + options.length) % options.length].value);
136
+ }
137
+ return (
138
+ <Row {...text} disabled={disabled} imageChoice>
139
+ <View style={styles.choices} accessibilityRole="radiogroup" accessibilityState={{ disabled }} {...accessibility(text)}
140
+ focusable={!disabled} onFocus={() => setFocused(true)} onBlur={() => setFocused(false)}
141
+ {...{ enableFocusRing: false, ...(!disabled && { onKeyDown, keyDownEvents: choiceKeys }) }}>
142
+ {options.map(option => {
143
+ const selected = option.value === value;
144
+ const captionColor = PlatformColor(disabled ? "tertiaryLabelColor" : selected ? "labelColor" : "secondaryLabelColor");
145
+ return (
146
+ <Pressable key={option.value} accessibilityRole="radio" accessibilityLabel={option.label}
147
+ accessibilityState={{ checked: selected, disabled }} focusable={false} disabled={disabled} onPress={() => choose(option.value)}
148
+ style={styles.choice}>
149
+ <View style={[styles.ring, selected && { borderColor: accentColor }, selected && focused && !disabled && { outlineColor: accentColor, outlineWidth: 1, outlineOffset: 2 }]}>
150
+ <Image accessible={false} source={option.image} resizeMode="cover"
151
+ style={[styles.image, !selected && { borderColor: PlatformColor("separatorColor"), borderWidth: StyleSheet.hairlineWidth }]} />
152
+ </View>
153
+ <Text style={[styles.caption, { color: captionColor, fontWeight: selected ? "600" : "400" }]}>{option.label}</Text>
154
+ </Pressable>
155
+ );
156
+ })}
157
+ </View>
158
+ </Row>
159
+ );
160
+ }
161
+
162
+ const styles = StyleSheet.create({
163
+ section: { gap: 6 },
164
+ heading: { fontSize: 13, lineHeight: 16, fontWeight: "600", marginHorizontal: 10 },
165
+ card: { backgroundColor: cardColor, borderRadius: 10, overflow: "hidden" },
166
+ divider: { height: StyleSheet.hairlineWidth, marginHorizontal: 10 },
167
+ row: { flexDirection: "row", alignItems: "center", minHeight: 42, padding: 10, gap: 12 },
168
+ rowText: { flex: 1, minWidth: 0, gap: 2 },
169
+ labelLine: { flexDirection: "row", alignItems: "flex-start", gap: 6 },
170
+ label: { fontSize: 13, lineHeight: 16, flexShrink: 1 },
171
+ description: { fontSize: 11, lineHeight: 14 },
172
+ info: { marginTop: 1.5 },
173
+ control: { flexShrink: 1, alignItems: "flex-end" },
174
+ selection: { height: 22, width: 190 },
175
+ imageControl: { maxWidth: "70%" },
176
+ imageRow: { alignItems: "flex-start", paddingVertical: 8 },
177
+ imageRowText: { paddingTop: 5 },
178
+ choices: { flexDirection: "row", flexWrap: "wrap", justifyContent: "flex-end", gap: 20 },
179
+ choice: { width: 76, alignItems: "center", gap: 6 },
180
+ ring: { borderWidth: 3, borderColor: "transparent", borderRadius: 10, padding: 1 },
181
+ image: { width: 68, height: 42, borderRadius: 6 },
182
+ caption: { fontSize: 11, lineHeight: 14, textAlign: "center" },
183
+ });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/spark-sqlite",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
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.3",
12
- "@legendapp/spark-file-system": "0.0.3"
11
+ "@legendapp/spark-desktop-app": "0.0.5",
12
+ "@legendapp/spark-file-system": "0.0.5"
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",
3
+ "version": "0.0.5",
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.3"
36
+ "@legendapp/spark-desktop-app": "0.0.5"
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",
3
+ "version": "0.0.5",
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.3"
36
+ "@legendapp/spark-desktop-app": "0.0.5"
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 && Platform.OS === "macos") {
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
- _button = [NSButton buttonWithTitle:@"" target:self action:@selector(pressed:)];
15
- _button.buttonType = NSButtonTypeMomentaryPushIn;
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
- _button.title = [NSString stringWithUTF8String:value.title.c_str()];
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 = value.variant != SparkButtonVariant::Borderless;
34
- _button.accessibilityLabel = [NSString stringWithUTF8String:value.accessibilityLabel.c_str()];
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
@@ -1,4 +1,4 @@
1
1
  #import <React/RCTViewComponentView.h>
2
2
  #import <AppKit/AppKit.h>
3
- @interface RNSparkTextInput : RCTViewComponentView <NSTextFieldDelegate>
3
+ @interface RNSparkTextInput : RCTViewComponentView <NSTextFieldDelegate, NSTextViewDelegate>
4
4
  @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
- - (void)controlTextDidChange:(NSNotification *)notification {
27
- if (!_field.enabled) return;
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 = _field.stringValue.UTF8String ?: "", .eventCount = _eventCount });
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
- if (!_initialized) { _field.stringValue = [NSString stringWithUTF8String:value.defaultText.c_str()]; _initialized = YES; }
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 (![_field.stringValue isEqualToString:text]) _field.stringValue = text;
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
- _field.accessibilityIdentifier = [NSString stringWithUTF8String:value.testId.c_str()];
41
- _field.accessibilityLabel = [NSString stringWithUTF8String:value.accessibilityLabel.c_str()];
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 { [super layoutSubviews]; _field.frame = self.bounds; }
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