@terreno/ui 57.2.0 → 57.4.0

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 (383) hide show
  1. package/.ai/guidelines/core.md +1 -1
  2. package/README.md +17 -8
  3. package/dist/ActionSheet.d.ts +3 -3
  4. package/dist/ActionSheet.js +2 -2
  5. package/dist/ActionSheet.js.map +1 -1
  6. package/dist/AnnouncementBanner.d.ts +12 -0
  7. package/dist/AnnouncementBanner.js +61 -0
  8. package/dist/AnnouncementBanner.js.map +1 -0
  9. package/dist/AnnouncementNavigator.d.ts +11 -0
  10. package/dist/AnnouncementNavigator.js +189 -0
  11. package/dist/AnnouncementNavigator.js.map +1 -0
  12. package/dist/AnnouncementScreen.d.ts +12 -0
  13. package/dist/AnnouncementScreen.js +28 -0
  14. package/dist/AnnouncementScreen.js.map +1 -0
  15. package/dist/AreaChart.d.ts +5 -0
  16. package/dist/AreaChart.js +69 -0
  17. package/dist/AreaChart.js.map +1 -0
  18. package/dist/BarChart.d.ts +5 -0
  19. package/dist/BarChart.js +89 -0
  20. package/dist/BarChart.js.map +1 -0
  21. package/dist/Box.d.ts +1 -1
  22. package/dist/Box.js +219 -177
  23. package/dist/Box.js.map +1 -1
  24. package/dist/Button.js +116 -35
  25. package/dist/Button.js.map +1 -1
  26. package/dist/Common.d.ts +215 -9
  27. package/dist/Common.js.map +1 -1
  28. package/dist/ConsentFormScreen.js +46 -12
  29. package/dist/ConsentFormScreen.js.map +1 -1
  30. package/dist/ConsentNavigator.d.ts +5 -1
  31. package/dist/ConsentNavigator.js.map +1 -1
  32. package/dist/DashboardGrid.d.ts +4 -0
  33. package/dist/DashboardGrid.js +38 -0
  34. package/dist/DashboardGrid.js.map +1 -0
  35. package/dist/DataTable.d.ts +2 -2
  36. package/dist/DataTable.js +278 -47
  37. package/dist/DataTable.js.map +1 -1
  38. package/dist/DataTableHeaderInfoMarkdown.d.ts +6 -0
  39. package/dist/DataTableHeaderInfoMarkdown.js +7 -0
  40. package/dist/DataTableHeaderInfoMarkdown.js.map +1 -0
  41. package/dist/DonutChart.d.ts +5 -0
  42. package/dist/DonutChart.js +84 -0
  43. package/dist/DonutChart.js.map +1 -0
  44. package/dist/EmojiSelector.d.ts +2 -46
  45. package/dist/EmojiSelector.js +46 -56
  46. package/dist/EmojiSelector.js.map +1 -1
  47. package/dist/Filter.js +12 -2
  48. package/dist/Filter.js.map +1 -1
  49. package/dist/GPTChat.d.ts +7 -1
  50. package/dist/GPTChat.js +28 -15
  51. package/dist/GPTChat.js.map +1 -1
  52. package/dist/Heading.d.ts +5 -2
  53. package/dist/Heading.js +6 -8
  54. package/dist/Heading.js.map +1 -1
  55. package/dist/Hyperlink.js.map +1 -1
  56. package/dist/Icon.d.ts +1 -2
  57. package/dist/Icon.js +4 -1
  58. package/dist/Icon.js.map +1 -1
  59. package/dist/LineChart.d.ts +5 -0
  60. package/dist/LineChart.js +68 -0
  61. package/dist/LineChart.js.map +1 -0
  62. package/dist/MarkdownEmbed.d.ts +6 -0
  63. package/dist/MarkdownEmbed.js +17 -0
  64. package/dist/MarkdownEmbed.js.map +1 -0
  65. package/dist/MarkdownView.d.ts +6 -3
  66. package/dist/MarkdownView.js +81 -44
  67. package/dist/MarkdownView.js.map +1 -1
  68. package/dist/MediaQuery.d.ts +5 -3
  69. package/dist/MediaQuery.js +9 -40
  70. package/dist/MediaQuery.js.map +1 -1
  71. package/dist/Modal.js +12 -10
  72. package/dist/Modal.js.map +1 -1
  73. package/dist/ModalSheet.d.ts +5 -1
  74. package/dist/ModalSheet.js +31 -13
  75. package/dist/ModalSheet.js.map +1 -1
  76. package/dist/MultiselectField.js +4 -9
  77. package/dist/MultiselectField.js.map +1 -1
  78. package/dist/NotificationBell.d.ts +16 -0
  79. package/dist/NotificationBell.js +15 -0
  80. package/dist/NotificationBell.js.map +1 -0
  81. package/dist/NotificationInbox.d.ts +21 -0
  82. package/dist/NotificationInbox.js +41 -0
  83. package/dist/NotificationInbox.js.map +1 -0
  84. package/dist/NotificationPreferences.d.ts +14 -0
  85. package/dist/NotificationPreferences.js +32 -0
  86. package/dist/NotificationPreferences.js.map +1 -0
  87. package/dist/OpenAPIContext.js +7 -6
  88. package/dist/OpenAPIContext.js.map +1 -1
  89. package/dist/Page.js +7 -1
  90. package/dist/Page.js.map +1 -1
  91. package/dist/PickerSelect.js +8 -1
  92. package/dist/PickerSelect.js.map +1 -1
  93. package/dist/Popover.d.ts +12 -0
  94. package/dist/Popover.js +37 -0
  95. package/dist/Popover.js.map +1 -0
  96. package/dist/PortalHost.js +10 -1
  97. package/dist/PortalHost.js.map +1 -1
  98. package/dist/ResponsiveBreakpoint.d.ts +65 -0
  99. package/dist/ResponsiveBreakpoint.js +111 -0
  100. package/dist/ResponsiveBreakpoint.js.map +1 -0
  101. package/dist/SplitPage.d.ts +2 -2
  102. package/dist/SplitPage.js +7 -12
  103. package/dist/SplitPage.js.map +1 -1
  104. package/dist/SplitPage.native.d.ts +2 -2
  105. package/dist/SplitPage.native.js +1 -6
  106. package/dist/SplitPage.native.js.map +1 -1
  107. package/dist/TapToEdit.js +12 -10
  108. package/dist/TapToEdit.js.map +1 -1
  109. package/dist/TerrenoFontProvider.d.ts +7 -0
  110. package/dist/TerrenoFontProvider.js +27 -0
  111. package/dist/TerrenoFontProvider.js.map +1 -0
  112. package/dist/TerrenoProvider.js +4 -2
  113. package/dist/TerrenoProvider.js.map +1 -1
  114. package/dist/Text.d.ts +5 -2
  115. package/dist/Text.js +6 -11
  116. package/dist/Text.js.map +1 -1
  117. package/dist/TextField.js +83 -6
  118. package/dist/TextField.js.map +1 -1
  119. package/dist/TextFieldNumberActionSheet.js +9 -2
  120. package/dist/TextFieldNumberActionSheet.js.map +1 -1
  121. package/dist/Theme.js +10 -8
  122. package/dist/Theme.js.map +1 -1
  123. package/dist/ToastNotifications.d.ts +4 -2
  124. package/dist/ToastNotifications.js.map +1 -1
  125. package/dist/Tooltip.d.ts +4 -3
  126. package/dist/Tooltip.js +14 -3
  127. package/dist/Tooltip.js.map +1 -1
  128. package/dist/Unifier.d.ts +26 -1
  129. package/dist/Unifier.js.map +1 -1
  130. package/dist/WebAddressAutocomplete.js +6 -1
  131. package/dist/WebAddressAutocomplete.js.map +1 -1
  132. package/dist/announcementBuildVersion.d.ts +6 -0
  133. package/dist/announcementBuildVersion.js +21 -0
  134. package/dist/announcementBuildVersion.js.map +1 -0
  135. package/dist/announcementFrequency.d.ts +42 -0
  136. package/dist/announcementFrequency.js +163 -0
  137. package/dist/announcementFrequency.js.map +1 -0
  138. package/dist/announcementPlatform.d.ts +2 -0
  139. package/dist/announcementPlatform.js +11 -0
  140. package/dist/announcementPlatform.js.map +1 -0
  141. package/dist/charts/ChartFrame.d.ts +12 -0
  142. package/dist/charts/ChartFrame.js +13 -0
  143. package/dist/charts/ChartFrame.js.map +1 -0
  144. package/dist/charts/bars.d.ts +18 -0
  145. package/dist/charts/bars.js +29 -0
  146. package/dist/charts/bars.js.map +1 -0
  147. package/dist/charts/layout.d.ts +47 -0
  148. package/dist/charts/layout.js +56 -0
  149. package/dist/charts/layout.js.map +1 -0
  150. package/dist/charts/paths.d.ts +31 -0
  151. package/dist/charts/paths.js +52 -0
  152. package/dist/charts/paths.js.map +1 -0
  153. package/dist/charts/scales.d.ts +6 -0
  154. package/dist/charts/scales.js +43 -0
  155. package/dist/charts/scales.js.map +1 -0
  156. package/dist/charts/theme.d.ts +9 -0
  157. package/dist/charts/theme.js +15 -0
  158. package/dist/charts/theme.js.map +1 -0
  159. package/dist/charts/types/chartTypes.d.ts +17 -0
  160. package/dist/charts/types/chartTypes.js +2 -0
  161. package/dist/charts/types/chartTypes.js.map +1 -0
  162. package/dist/dashboardGridLayout.d.ts +22 -0
  163. package/dist/dashboardGridLayout.js +33 -0
  164. package/dist/dashboardGridLayout.js.map +1 -0
  165. package/dist/dataTableFilters.d.ts +33 -0
  166. package/dist/dataTableFilters.js +221 -0
  167. package/dist/dataTableFilters.js.map +1 -0
  168. package/dist/dataTableListQuery.d.ts +42 -0
  169. package/dist/dataTableListQuery.js +161 -0
  170. package/dist/dataTableListQuery.js.map +1 -0
  171. package/dist/emojiCategories.d.ts +46 -0
  172. package/dist/emojiCategories.js +47 -0
  173. package/dist/emojiCategories.js.map +1 -0
  174. package/dist/index.d.ts +30 -13
  175. package/dist/index.js +12 -13
  176. package/dist/index.js.map +1 -1
  177. package/dist/lazyBoundaries/createLazyComponentExport.d.ts +6 -0
  178. package/dist/lazyBoundaries/createLazyComponentExport.js +35 -0
  179. package/dist/lazyBoundaries/createLazyComponentExport.js.map +1 -0
  180. package/dist/lazyBoundaries/heavyOptionalExports.d.ts +53 -0
  181. package/dist/lazyBoundaries/heavyOptionalExports.js +51 -0
  182. package/dist/lazyBoundaries/heavyOptionalExports.js.map +1 -0
  183. package/dist/login/LoginScreen.d.ts +1 -0
  184. package/dist/login/LoginScreen.js +4 -2
  185. package/dist/login/LoginScreen.js.map +1 -1
  186. package/dist/login/loginTypes.d.ts +2 -0
  187. package/dist/markdownEmbeds.d.ts +6 -0
  188. package/dist/markdownEmbeds.js +59 -0
  189. package/dist/markdownEmbeds.js.map +1 -0
  190. package/dist/testing/resolveTestId.js +2 -1
  191. package/dist/testing/resolveTestId.js.map +1 -1
  192. package/dist/testing/types.d.ts +3 -0
  193. package/dist/textFieldOscillationGuard.d.ts +25 -0
  194. package/dist/textFieldOscillationGuard.js +41 -0
  195. package/dist/textFieldOscillationGuard.js.map +1 -0
  196. package/dist/useAcknowledgeAnnouncement.d.ts +71 -0
  197. package/dist/useAcknowledgeAnnouncement.js +94 -0
  198. package/dist/useAcknowledgeAnnouncement.js.map +1 -0
  199. package/dist/useAnnouncements.d.ts +73 -0
  200. package/dist/useAnnouncements.js +66 -0
  201. package/dist/useAnnouncements.js.map +1 -0
  202. package/package.json +46 -18
  203. package/src/AIRequestExplorer.test.tsx +141 -0
  204. package/src/ActionSheet.tsx +9 -7
  205. package/src/AnnouncementBanner.test.tsx +267 -0
  206. package/src/AnnouncementBanner.tsx +128 -0
  207. package/src/AnnouncementNavigator.test.tsx +759 -0
  208. package/src/AnnouncementNavigator.tsx +287 -0
  209. package/src/AnnouncementScreen.test.tsx +97 -0
  210. package/src/AnnouncementScreen.tsx +70 -0
  211. package/src/AreaChart.test.tsx +68 -0
  212. package/src/AreaChart.tsx +194 -0
  213. package/src/AttachmentPreview.test.tsx +80 -0
  214. package/src/BarChart.test.tsx +96 -0
  215. package/src/BarChart.tsx +208 -0
  216. package/src/Box.test.tsx +97 -10
  217. package/src/Box.tsx +263 -200
  218. package/src/Button.test.tsx +273 -0
  219. package/src/Button.tsx +163 -50
  220. package/src/Common.ts +219 -25
  221. package/src/ConsentFormScreen.markdownGate.test.tsx +129 -0
  222. package/src/ConsentFormScreen.test.tsx +145 -8
  223. package/src/ConsentFormScreen.tsx +74 -25
  224. package/src/ConsentNavigator.test.tsx +55 -0
  225. package/src/ConsentNavigator.tsx +13 -5
  226. package/src/DashboardGrid.test.tsx +75 -0
  227. package/src/DashboardGrid.tsx +69 -0
  228. package/src/DataTable.test.tsx +296 -1
  229. package/src/DataTable.tsx +623 -160
  230. package/src/DataTableHeaderInfoMarkdown.test.tsx +21 -0
  231. package/src/DataTableHeaderInfoMarkdown.tsx +17 -0
  232. package/src/DataTableVirtualizationRegression.test.tsx +266 -0
  233. package/src/DateTimeField.test.tsx +54 -0
  234. package/src/DonutChart.test.tsx +121 -0
  235. package/src/DonutChart.tsx +160 -0
  236. package/src/EmojiSelector.test.tsx +84 -42
  237. package/src/EmojiSelector.tsx +60 -57
  238. package/src/Field.test.tsx +18 -0
  239. package/src/FilePickerButton.test.tsx +167 -0
  240. package/src/Filter.test.tsx +25 -0
  241. package/src/Filter.tsx +38 -7
  242. package/src/FilterAccordion.test.tsx +37 -0
  243. package/src/FilterBoolean.test.tsx +96 -0
  244. package/src/FilterSelectMenu.test.tsx +23 -0
  245. package/src/GPTChat.test.tsx +803 -0
  246. package/src/GPTChat.tsx +177 -87
  247. package/src/GPTMemoryModal.test.tsx +67 -0
  248. package/src/Heading.tsx +8 -14
  249. package/src/HeightActionSheet.test.tsx +6 -9
  250. package/src/Hyperlink.tsx +5 -18
  251. package/src/Icon.tsx +6 -2
  252. package/src/LineChart.test.tsx +166 -0
  253. package/src/LineChart.tsx +190 -0
  254. package/src/MarkdownEditor.test.tsx +134 -0
  255. package/src/MarkdownEditorField.test.tsx +124 -0
  256. package/src/MarkdownEmbed.test.tsx +34 -0
  257. package/src/MarkdownEmbed.tsx +43 -0
  258. package/src/MarkdownView.test.tsx +112 -11
  259. package/src/MarkdownView.tsx +197 -150
  260. package/src/MediaQuery.ts +30 -34
  261. package/src/Modal.test.tsx +107 -14
  262. package/src/Modal.tsx +20 -8
  263. package/src/ModalSheet.test.tsx +121 -9
  264. package/src/ModalSheet.tsx +46 -11
  265. package/src/MultiselectField.test.tsx +21 -0
  266. package/src/MultiselectField.tsx +11 -13
  267. package/src/NotificationBell.test.tsx +91 -0
  268. package/src/NotificationBell.tsx +77 -0
  269. package/src/NotificationInbox.test.tsx +130 -0
  270. package/src/NotificationInbox.tsx +144 -0
  271. package/src/NotificationPreferences.test.tsx +25 -0
  272. package/src/NotificationPreferences.tsx +75 -0
  273. package/src/OpenAPIContext.tsx +36 -29
  274. package/src/OpenAPIRenderRegression.test.tsx +200 -0
  275. package/src/P0RenderRegression.test.tsx +214 -0
  276. package/src/P1RenderRegression.test.tsx +141 -0
  277. package/src/P2ButtonRenderRegression.test.tsx +158 -0
  278. package/src/Page.test.tsx +13 -0
  279. package/src/Page.tsx +25 -5
  280. package/src/PickerSelect.test.tsx +38 -0
  281. package/src/PickerSelect.tsx +7 -0
  282. package/src/Popover.test.tsx +151 -0
  283. package/src/Popover.tsx +211 -0
  284. package/src/PortalHost.tsx +12 -6
  285. package/src/ResponsiveBreakpoint.test.tsx +184 -0
  286. package/src/ResponsiveBreakpoint.tsx +195 -0
  287. package/src/RootImportRegression.test.tsx +82 -0
  288. package/src/SplitPage.native.tsx +5 -9
  289. package/src/SplitPage.tsx +16 -19
  290. package/src/TapToEdit.test.tsx +45 -0
  291. package/src/TapToEdit.tsx +23 -18
  292. package/src/TerrenoFontProvider.test.tsx +38 -0
  293. package/src/TerrenoFontProvider.tsx +50 -0
  294. package/src/TerrenoProvider.tsx +6 -1
  295. package/src/Text.tsx +8 -21
  296. package/src/TextField.test.tsx +421 -0
  297. package/src/TextField.tsx +121 -4
  298. package/src/TextFieldNumberActionSheet.test.tsx +100 -0
  299. package/src/TextFieldNumberActionSheet.tsx +11 -2
  300. package/src/Theme.test.tsx +27 -0
  301. package/src/Theme.tsx +15 -10
  302. package/src/Toast.tsx +1 -1
  303. package/src/ToastNotifications.tsx +4 -4
  304. package/src/Tooltip.test.tsx +64 -0
  305. package/src/Tooltip.tsx +18 -4
  306. package/src/Unifier.ts +26 -3
  307. package/src/WebAddressAutocomplete.tsx +6 -2
  308. package/src/__snapshots__/ActionSheet.test.tsx.snap +0 -36
  309. package/src/__snapshots__/AddressField.test.tsx.snap +1 -0
  310. package/src/__snapshots__/AttachmentPreview.test.tsx.snap +225 -0
  311. package/src/__snapshots__/CustomSelectField.test.tsx.snap +7 -0
  312. package/src/__snapshots__/DataTable.test.tsx.snap +793 -250
  313. package/src/__snapshots__/DecimalRangeActionSheet.test.tsx.snap +0 -8
  314. package/src/__snapshots__/EmojiSelector.test.tsx.snap +35555 -30
  315. package/src/__snapshots__/Field.test.tsx.snap +29 -0
  316. package/src/__snapshots__/FilterSelectMenu.test.tsx.snap +1 -0
  317. package/src/__snapshots__/HeightActionSheet.test.tsx.snap +0 -8
  318. package/src/__snapshots__/HeightField.test.tsx.snap +0 -20
  319. package/src/__snapshots__/ModalSheet.test.tsx.snap +4 -1
  320. package/src/__snapshots__/NumberPickerActionSheet.test.tsx.snap +0 -8
  321. package/src/__snapshots__/Page.test.tsx.snap +13 -1
  322. package/src/__snapshots__/PickerSelect.test.tsx.snap +7 -0
  323. package/src/__snapshots__/SelectField.test.tsx.snap +6 -0
  324. package/src/__snapshots__/TextArea.test.tsx.snap +5 -5
  325. package/src/__snapshots__/TextField.test.tsx.snap +5 -5
  326. package/src/__snapshots__/TimezonePicker.test.tsx.snap +6 -0
  327. package/src/announcementBuildVersion.test.ts +43 -0
  328. package/src/announcementBuildVersion.ts +21 -0
  329. package/src/announcementFrequency.test.ts +245 -0
  330. package/src/announcementFrequency.ts +246 -0
  331. package/src/announcementPlatform.test.ts +27 -0
  332. package/src/announcementPlatform.ts +13 -0
  333. package/src/benchmarks/importGraph.test.ts +71 -0
  334. package/src/benchmarks/importGraph.ts +136 -0
  335. package/src/benchmarks/importTiming.test.ts +42 -0
  336. package/src/benchmarks/importTiming.ts +86 -0
  337. package/src/bunSetup.ts +174 -32
  338. package/src/charts/ChartFrame.tsx +67 -0
  339. package/src/charts/bars.test.ts +56 -0
  340. package/src/charts/bars.ts +53 -0
  341. package/src/charts/layout.test.ts +80 -0
  342. package/src/charts/layout.ts +99 -0
  343. package/src/charts/paths.test.ts +79 -0
  344. package/src/charts/paths.ts +100 -0
  345. package/src/charts/scales.test.ts +59 -0
  346. package/src/charts/scales.ts +60 -0
  347. package/src/charts/theme.test.ts +22 -0
  348. package/src/charts/theme.ts +24 -0
  349. package/src/charts/types/chartTypes.ts +19 -0
  350. package/src/dashboardGridLayout.test.ts +90 -0
  351. package/src/dashboardGridLayout.ts +60 -0
  352. package/src/dataTableFilters.test.tsx +552 -0
  353. package/src/dataTableFilters.tsx +441 -0
  354. package/src/dataTableListQuery.test.ts +220 -0
  355. package/src/dataTableListQuery.ts +201 -0
  356. package/src/emojiCategories.test.ts +23 -0
  357. package/src/emojiCategories.ts +46 -0
  358. package/src/index.tsx +48 -14
  359. package/src/lazyBoundaries/createLazyComponentExport.test.tsx +104 -0
  360. package/src/lazyBoundaries/createLazyComponentExport.tsx +63 -0
  361. package/src/lazyBoundaries/heavyOptionalExports.test.tsx +33 -0
  362. package/src/lazyBoundaries/heavyOptionalExports.tsx +134 -0
  363. package/src/login/LoginScreen.test.tsx +9 -2
  364. package/src/login/LoginScreen.tsx +6 -2
  365. package/src/login/__snapshots__/LoginScreen.test.tsx.snap +22 -0
  366. package/src/login/loginTypes.ts +2 -0
  367. package/src/markdownEmbeds.test.ts +53 -0
  368. package/src/markdownEmbeds.ts +62 -0
  369. package/src/pdfHtmlTemplate.test.ts +119 -0
  370. package/src/signUp/__snapshots__/SignUpScreen.test.tsx.snap +22 -0
  371. package/src/table/TableDate.test.tsx +35 -1
  372. package/src/table/__snapshots__/TableBadge.test.tsx.snap +1 -0
  373. package/src/testing/resolveTestId.test.ts +3 -0
  374. package/src/testing/resolveTestId.ts +1 -0
  375. package/src/testing/types.ts +3 -0
  376. package/src/textFieldOscillationGuard.test.ts +63 -0
  377. package/src/textFieldOscillationGuard.ts +89 -0
  378. package/src/types/react-native-markdown-display.d.ts +6 -0
  379. package/src/types/react-native-swiper-flatlist.d.ts +5 -5
  380. package/src/useAcknowledgeAnnouncement.test.ts +223 -0
  381. package/src/useAcknowledgeAnnouncement.ts +166 -0
  382. package/src/useAnnouncements.test.ts +226 -0
  383. package/src/useAnnouncements.ts +150 -0
package/src/TapToEdit.tsx CHANGED
@@ -8,6 +8,7 @@ import {Field} from "./Field";
8
8
  import {Icon} from "./Icon";
9
9
  // import {useOpenAPISpec} from "./OpenAPIContext";
10
10
  import {Text} from "./Text";
11
+ import {resolveTestID} from "./testing/resolveTestId";
11
12
 
12
13
  const TapToEditTitle: FC<{
13
14
  onlyShowHelperTextWhileEditing?: boolean;
@@ -77,6 +78,7 @@ export const TapToEdit: FC<TapToEditProps> = ({
77
78
  helperText: propsHelperText,
78
79
  onlyShowHelperTextWhileEditing = true,
79
80
  showClearButton = false,
81
+ testID,
80
82
  ...fieldProps
81
83
  }) => {
82
84
  const [editing, setEditing] = useState(false);
@@ -102,30 +104,29 @@ export const TapToEdit: FC<TapToEditProps> = ({
102
104
  }
103
105
 
104
106
  if (editable && (editing || isEditing)) {
107
+ const editableFieldProps = {
108
+ grow: fieldProps?.type === "textarea" ? (fieldProps.grow ?? true) : undefined,
109
+ helperText,
110
+ inputRef: ["text", "textarea", "url", "email", "number"].includes(fieldProps?.type)
111
+ ? (ref: unknown): void => {
112
+ inputRef.current = ref as FocusableInput | null;
113
+ }
114
+ : undefined,
115
+ onChange: setValue as NonNullable<typeof setValue>,
116
+ row: fieldProps?.type === "textarea" ? 5 : undefined,
117
+ value,
118
+ ...fieldProps,
119
+ testID,
120
+ type: (fieldProps?.type ?? "text") as NonNullable<FieldProps["type"]>,
121
+ } as unknown as FieldProps;
122
+
105
123
  return (
106
124
  <View style={{flexDirection: "column", width: "100%"}}>
107
125
  <View style={{flex: 1, justifyContent: "center"}}>
108
126
  <Text bold>{title}</Text>
109
127
  </View>
110
128
  <View style={{gap: 16}}>
111
- <Field
112
- grow={fieldProps?.type === "textarea" ? (fieldProps.grow ?? true) : undefined}
113
- helperText={helperText}
114
- inputRef={
115
- ["text", "textarea", "url", "email", "number"].includes(fieldProps?.type)
116
- ? (ref: unknown) => {
117
- inputRef.current = ref as FocusableInput | null;
118
- }
119
- : undefined
120
- }
121
- onChange={setValue as NonNullable<typeof setValue>}
122
- row={fieldProps?.type === "textarea" ? 5 : undefined}
123
- type={(fieldProps?.type ?? "text") as NonNullable<FieldProps["type"]>}
124
- value={value}
125
- // noExplicitAny: fieldProps is a discriminated union (FieldProps) but the spread loses narrowing; type-checking each variant individually is impractical here
126
- // biome-ignore lint/suspicious/noExplicitAny: fieldProps is a discriminated union (FieldProps) but the spread loses narrowing; type-checking each variant individually is impractical here
127
- {...(fieldProps as any)}
128
- />
129
+ <Field {...editableFieldProps} />
129
130
  {editing && !isEditing && (
130
131
  <View style={{flexDirection: "row", gap: 16, justifyContent: "flex-end"}}>
131
132
  <Button
@@ -135,6 +136,7 @@ export const TapToEdit: FC<TapToEditProps> = ({
135
136
  }
136
137
  setEditing(false);
137
138
  }}
139
+ testID={resolveTestID(testID, "cancel")}
138
140
  text="Cancel"
139
141
  variant="muted"
140
142
  />
@@ -149,6 +151,7 @@ export const TapToEdit: FC<TapToEditProps> = ({
149
151
  }
150
152
  setEditing(false);
151
153
  }}
154
+ testID={resolveTestID(testID, "clear")}
152
155
  text="Clear"
153
156
  variant="muted"
154
157
  />
@@ -165,6 +168,7 @@ export const TapToEdit: FC<TapToEditProps> = ({
165
168
  }
166
169
  setEditing(false);
167
170
  }}
171
+ testID={resolveTestID(testID, "save")}
168
172
  text="Save"
169
173
  withConfirmation={withConfirmation}
170
174
  />
@@ -274,6 +278,7 @@ export const TapToEdit: FC<TapToEditProps> = ({
274
278
  initialValueRef.current = value;
275
279
  setEditing(true);
276
280
  }}
281
+ testID={resolveTestID(testID, "edit")}
277
282
  width={16}
278
283
  >
279
284
  <Icon iconName="pencil" size="md" />
@@ -0,0 +1,38 @@
1
+ import type {mock} from "bun:test";
2
+ import {useFonts as useTextFonts} from "@expo-google-fonts/nunito";
3
+ import {useFonts as useHeadingFonts} from "@expo-google-fonts/titillium-web";
4
+ import {render} from "@testing-library/react-native";
5
+ import {assert} from "chai";
6
+ import type React from "react";
7
+ import {Text as NativeText} from "react-native";
8
+
9
+ import {TerrenoFontProvider, useTerrenoFontsLoaded} from "./TerrenoFontProvider";
10
+
11
+ const FontStatus: React.FC = () => {
12
+ const areFontsLoaded = useTerrenoFontsLoaded();
13
+ return <NativeText testID="font-status">{String(areFontsLoaded)}</NativeText>;
14
+ };
15
+
16
+ describe("TerrenoFontProvider", () => {
17
+ it("publishes font-load completion so memoized typography redraws", () => {
18
+ (useTextFonts as ReturnType<typeof mock>).mockReturnValue([false, null]);
19
+ (useHeadingFonts as ReturnType<typeof mock>).mockReturnValue([false, null]);
20
+ const result = render(
21
+ <TerrenoFontProvider>
22
+ <FontStatus />
23
+ </TerrenoFontProvider>
24
+ );
25
+
26
+ assert.equal(result.getByTestId("font-status").children[0], "false");
27
+
28
+ (useTextFonts as ReturnType<typeof mock>).mockReturnValue([true, null]);
29
+ (useHeadingFonts as ReturnType<typeof mock>).mockReturnValue([true, null]);
30
+ result.rerender(
31
+ <TerrenoFontProvider>
32
+ <FontStatus />
33
+ </TerrenoFontProvider>
34
+ );
35
+
36
+ assert.equal(result.getByTestId("font-status").children[0], "true");
37
+ });
38
+ });
@@ -0,0 +1,50 @@
1
+ import {
2
+ Nunito_400Regular,
3
+ Nunito_400Regular_Italic,
4
+ Nunito_500Medium,
5
+ Nunito_500Medium_Italic,
6
+ Nunito_700Bold,
7
+ Nunito_700Bold_Italic,
8
+ useFonts as useTextFonts,
9
+ } from "@expo-google-fonts/nunito";
10
+ import {
11
+ TitilliumWeb_600SemiBold,
12
+ TitilliumWeb_700Bold,
13
+ useFonts as useHeadingFonts,
14
+ } from "@expo-google-fonts/titillium-web";
15
+ import {createContext, type FC, type ReactNode, useContext} from "react";
16
+
17
+ interface TerrenoFontProviderProps {
18
+ children: ReactNode;
19
+ }
20
+
21
+ const TerrenoFontLoadContext = createContext(true);
22
+
23
+ export const TerrenoFontProvider: FC<TerrenoFontProviderProps> = ({children}) => {
24
+ const [areTextFontsLoaded] = useTextFonts({
25
+ text: Nunito_400Regular,
26
+ "text-bold": Nunito_700Bold,
27
+ "text-bold-italic": Nunito_700Bold_Italic,
28
+ "text-medium": Nunito_500Medium,
29
+ "text-medium-italic": Nunito_500Medium_Italic,
30
+ "text-regular": Nunito_400Regular,
31
+ "text-regular-italic": Nunito_400Regular_Italic,
32
+ });
33
+ const [areHeadingFontsLoaded] = useHeadingFonts({
34
+ heading: TitilliumWeb_600SemiBold,
35
+ "heading-bold": TitilliumWeb_700Bold,
36
+ "heading-semibold": TitilliumWeb_600SemiBold,
37
+ });
38
+
39
+ const areFontsLoaded = areTextFontsLoaded && areHeadingFontsLoaded;
40
+
41
+ return (
42
+ <TerrenoFontLoadContext.Provider value={areFontsLoaded}>
43
+ {children}
44
+ </TerrenoFontLoadContext.Provider>
45
+ );
46
+ };
47
+
48
+ export const useTerrenoFontsLoaded = (): boolean => {
49
+ return useContext(TerrenoFontLoadContext);
50
+ };
@@ -36,7 +36,12 @@ export const TerrenoProvider: FC<{
36
36
  providerOnHide?.();
37
37
  };
38
38
 
39
- return <Toast {...toastOptions?.data} onDismiss={handleDismiss} />;
39
+ const toastData = toastOptions?.data;
40
+ const title =
41
+ toastData?.title ??
42
+ (typeof toastOptions?.message === "string" ? toastOptions.message : "");
43
+
44
+ return <Toast {...toastData} onDismiss={handleDismiss} title={title} />;
40
45
  }}
41
46
  swipeEnabled
42
47
  >
package/src/Text.tsx CHANGED
@@ -1,17 +1,9 @@
1
- import {
2
- Nunito_400Regular,
3
- Nunito_400Regular_Italic,
4
- Nunito_500Medium,
5
- Nunito_500Medium_Italic,
6
- Nunito_700Bold,
7
- Nunito_700Bold_Italic,
8
- useFonts,
9
- } from "@expo-google-fonts/nunito";
10
- import type React from "react";
1
+ import React from "react";
11
2
  import {Text as NativeText, Platform, type TextStyle} from "react-native";
12
3
 
13
4
  import type {TextProps} from "./Common";
14
5
  import {Hyperlink} from "./Hyperlink";
6
+ import {useTerrenoFontsLoaded} from "./TerrenoFontProvider";
15
7
  import {useTheme} from "./Theme";
16
8
 
17
9
  const fontSizeAndWeightWeb = {
@@ -32,7 +24,7 @@ const fontSizeAndWeighMobile = {
32
24
 
33
25
  const fontSizes = Platform.OS === "web" ? fontSizeAndWeightWeb : fontSizeAndWeighMobile;
34
26
 
35
- export const Text = ({
27
+ const TextComponent = ({
36
28
  align = "left",
37
29
  bold,
38
30
  children,
@@ -46,16 +38,7 @@ export const Text = ({
46
38
  testID,
47
39
  }: TextProps): React.ReactElement => {
48
40
  const {theme} = useTheme();
49
-
50
- useFonts({
51
- text: Nunito_400Regular,
52
- "text-bold": Nunito_700Bold,
53
- "text-bold-italic": Nunito_700Bold_Italic,
54
- "text-medium": Nunito_500Medium,
55
- "text-medium-italic": Nunito_500Medium_Italic,
56
- "text-regular": Nunito_400Regular,
57
- "text-regular-italic": Nunito_400Regular_Italic,
58
- });
41
+ useTerrenoFontsLoaded();
59
42
 
60
43
  const style: TextStyle = {};
61
44
 
@@ -124,3 +107,7 @@ export const Text = ({
124
107
  );
125
108
  }
126
109
  };
110
+
111
+ TextComponent.displayName = "Text";
112
+
113
+ export const Text = React.memo(TextComponent);
@@ -1,5 +1,8 @@
1
1
  import {afterEach, beforeEach, describe, expect, it, mock, spyOn} from "bun:test";
2
2
  import {act, fireEvent, userEvent} from "@testing-library/react-native";
3
+ import {assert} from "chai";
4
+ import type {ReactElement} from "react";
5
+ import type {TextInput} from "react-native";
3
6
  import {TextField} from "./TextField";
4
7
  import {renderWithTheme} from "./test-utils";
5
8
 
@@ -21,6 +24,53 @@ describe("TextField", () => {
21
24
  });
22
25
 
23
26
  describe("basic rendering", () => {
27
+ it("warns when the device timezone cannot be determined", () => {
28
+ mock.module("expo-localization", () => ({
29
+ getCalendars: mock(() => []),
30
+ getLocales: mock(() => [
31
+ {
32
+ countryCode: "US",
33
+ decimalSeparator: ".",
34
+ digitGroupingSeparator: ",",
35
+ languageCode: "en",
36
+ measurementSystem: "US",
37
+ temperatureUnit: "F",
38
+ textDirection: "ltr",
39
+ },
40
+ ]),
41
+ }));
42
+ const warnSpy = spyOn(console, "warn").mockImplementation(() => {});
43
+
44
+ try {
45
+ renderWithTheme(<TextField onChange={mockOnChange} value="" />);
46
+ assert.equal(warnSpy.mock.calls.length, 1);
47
+ assert.equal(warnSpy.mock.calls[0]?.[0], "Could not automatically determine timezone.");
48
+ } finally {
49
+ mock.module("expo-localization", () => ({
50
+ getCalendars: mock(() => [
51
+ {
52
+ calendar: "gregorian",
53
+ id: "gregorian",
54
+ locale: "en-US",
55
+ timeZone: "America/New_York",
56
+ },
57
+ ]),
58
+ getLocales: mock(() => [
59
+ {
60
+ countryCode: "US",
61
+ decimalSeparator: ".",
62
+ digitGroupingSeparator: ",",
63
+ languageCode: "en",
64
+ measurementSystem: "US",
65
+ temperatureUnit: "F",
66
+ textDirection: "ltr",
67
+ },
68
+ ]),
69
+ }));
70
+ warnSpy.mockRestore();
71
+ }
72
+ });
73
+
24
74
  it("should render with default props", () => {
25
75
  const {getByDisplayValue} = renderWithTheme(
26
76
  <TextField onChange={mockOnChange} value="test value" />
@@ -193,6 +243,214 @@ describe("TextField", () => {
193
243
  expect(input.props.secureTextEntry).toBe(true);
194
244
  });
195
245
 
246
+ describe("password visibility toggle", () => {
247
+ it("should reveal and re-hide the value when the toggle is pressed", () => {
248
+ const {getByDisplayValue, getByTestId} = renderWithTheme(
249
+ <TextField onChange={mockOnChange} testID="pw" type="password" value="hunter2" />
250
+ );
251
+
252
+ expect(getByDisplayValue("hunter2").props.secureTextEntry).toBe(true);
253
+
254
+ fireEvent.press(getByTestId("pw.visibility-toggle"));
255
+ expect(getByDisplayValue("hunter2").props.secureTextEntry).toBe(false);
256
+
257
+ fireEvent.press(getByTestId("pw.visibility-toggle"));
258
+ expect(getByDisplayValue("hunter2").props.secureTextEntry).toBe(true);
259
+ });
260
+
261
+ it("should describe the next action on the toggle", () => {
262
+ const {getByTestId} = renderWithTheme(
263
+ <TextField onChange={mockOnChange} testID="pw" type="password" value="hunter2" />
264
+ );
265
+
266
+ const toggle = getByTestId("pw.visibility-toggle");
267
+ expect(toggle.props.accessibilityLabel).toBe("Show password");
268
+
269
+ fireEvent.press(toggle);
270
+ expect(getByTestId("pw.visibility-toggle").props.accessibilityLabel).toBe("Hide password");
271
+ });
272
+
273
+ it("should not render the toggle for non-password types", () => {
274
+ const {queryByTestId} = renderWithTheme(
275
+ <TextField onChange={mockOnChange} testID="email" type="email" value="" />
276
+ );
277
+
278
+ expect(queryByTestId("email.visibility-toggle")).toBeNull();
279
+ });
280
+
281
+ it("should not render the toggle when showVisibilityToggle is false", () => {
282
+ const {queryByTestId} = renderWithTheme(
283
+ <TextField
284
+ onChange={mockOnChange}
285
+ showVisibilityToggle={false}
286
+ testID="pw"
287
+ type="password"
288
+ value="hunter2"
289
+ />
290
+ );
291
+
292
+ expect(queryByTestId("pw.visibility-toggle")).toBeNull();
293
+ });
294
+
295
+ it("should keep the value hidden when the field is disabled", () => {
296
+ const {getByDisplayValue, getByTestId} = renderWithTheme(
297
+ <TextField disabled onChange={mockOnChange} testID="pw" type="password" value="hunter2" />
298
+ );
299
+
300
+ fireEvent.press(getByTestId("pw.visibility-toggle"));
301
+ expect(getByDisplayValue("hunter2").props.secureTextEntry).toBe(true);
302
+ });
303
+
304
+ it("should accept a custom toggle test id", () => {
305
+ const {getByTestId} = renderWithTheme(
306
+ <TextField
307
+ onChange={mockOnChange}
308
+ testID="pw"
309
+ testIDs={{visibilityToggle: "custom-toggle"}}
310
+ type="password"
311
+ value="hunter2"
312
+ />
313
+ );
314
+
315
+ expect(getByTestId("custom-toggle")).toBeTruthy();
316
+ });
317
+
318
+ it("should not blur the input when the visibility toggle is pressed", async () => {
319
+ const {getByDisplayValue, getByTestId} = renderWithTheme(
320
+ <TextField
321
+ onBlur={mockOnBlur}
322
+ onChange={mockOnChange}
323
+ testID="pw"
324
+ trimOnBlur
325
+ type="password"
326
+ value="secret "
327
+ />
328
+ );
329
+
330
+ const input = getByDisplayValue("secret ");
331
+ fireEvent(input, "focus");
332
+ await act(async () => {
333
+ fireEvent.press(getByTestId("pw.visibility-toggle"));
334
+ await new Promise((resolve) => {
335
+ setTimeout(resolve, 0);
336
+ });
337
+ });
338
+
339
+ expect(mockOnBlur).not.toHaveBeenCalled();
340
+ expect(mockOnChange).not.toHaveBeenCalled();
341
+ });
342
+
343
+ it("refocuses and restores selection on web when toggled while focused", () => {
344
+ const reactNative = require("react-native") as {Platform: {OS: string}};
345
+ const originalOS = reactNative.Platform.OS;
346
+ const originalRequestAnimationFrame = globalThis.requestAnimationFrame;
347
+ const requestAnimationFrameSpy = mock((callback: FrameRequestCallback): number => {
348
+ callback(0);
349
+ return 1;
350
+ });
351
+ reactNative.Platform.OS = "web";
352
+ globalThis.requestAnimationFrame = requestAnimationFrameSpy;
353
+
354
+ try {
355
+ const {getByDisplayValue, getByTestId} = renderWithTheme(
356
+ <TextField onChange={mockOnChange} testID="pw" type="password" value="hunter2" />
357
+ );
358
+ const input = getByDisplayValue("hunter2");
359
+ const webInput: {
360
+ focus: () => void;
361
+ selectionEnd: number;
362
+ selectionStart: number;
363
+ setSelectionRange: (start: number, end: number) => void;
364
+ } = {
365
+ focus: () => {},
366
+ selectionEnd: 0,
367
+ selectionStart: 0,
368
+ setSelectionRange: () => {},
369
+ };
370
+ const focusSpy = mock(() => {});
371
+ const setSelectionRangeSpy = mock((_start: number, _end: number) => {});
372
+ const ref = (input.props as unknown as {ref?: (value: TextInput | null) => void}).ref;
373
+ assert.isFunction(ref);
374
+ webInput.focus = focusSpy;
375
+ webInput.selectionStart = 2;
376
+ webInput.selectionEnd = 5;
377
+ webInput.setSelectionRange = setSelectionRangeSpy;
378
+
379
+ fireEvent(input, "focus");
380
+ ref?.(webInput as unknown as TextInput);
381
+ const preventDefault = mock(() => {});
382
+ fireEvent(getByTestId("pw.visibility-toggle"), "mouseDown", {preventDefault});
383
+ fireEvent.press(getByTestId("pw.visibility-toggle"));
384
+
385
+ assert.equal(requestAnimationFrameSpy.mock.calls.length, 1);
386
+ assert.equal(focusSpy.mock.calls.length, 1);
387
+ assert.deepEqual(setSelectionRangeSpy.mock.calls[0], [2, 5]);
388
+ assert.equal(preventDefault.mock.calls.length, 1);
389
+ } finally {
390
+ reactNative.Platform.OS = originalOS;
391
+ globalThis.requestAnimationFrame = originalRequestAnimationFrame;
392
+ }
393
+ });
394
+
395
+ it("refocuses with a timeout when requestAnimationFrame is unavailable on web", async () => {
396
+ const reactNative = require("react-native") as {Platform: {OS: string}};
397
+ const originalOS = reactNative.Platform.OS;
398
+ const originalRequestAnimationFrame = globalThis.requestAnimationFrame;
399
+ const originalSetTimeout = globalThis.setTimeout;
400
+ let scheduledRefocus: (() => void) | undefined;
401
+ const setTimeoutSpy = spyOn(globalThis, "setTimeout").mockImplementation(
402
+ (handler, timeout, ...args) => {
403
+ scheduledRefocus = handler as unknown as () => void;
404
+ return originalSetTimeout(() => {}, timeout, ...args);
405
+ }
406
+ );
407
+ reactNative.Platform.OS = "web";
408
+ globalThis.requestAnimationFrame = undefined;
409
+
410
+ try {
411
+ const {getByDisplayValue, getByTestId} = renderWithTheme(
412
+ <TextField onChange={mockOnChange} testID="pw" type="password" value="hunter2" />
413
+ );
414
+ const input = getByDisplayValue("hunter2");
415
+ const webInput = {focus: () => void 0};
416
+ const ref = (input.props as unknown as {ref?: (value: TextInput | null) => void}).ref;
417
+ assert.isFunction(ref);
418
+ const focusSpy = mock(() => {});
419
+ webInput.focus = focusSpy;
420
+
421
+ fireEvent(input, "focus");
422
+ ref?.(webInput as unknown as TextInput);
423
+ fireEvent.press(getByTestId("pw.visibility-toggle"));
424
+
425
+ assert.isAtLeast(setTimeoutSpy.mock.calls.length, 1);
426
+ ref?.(webInput as unknown as TextInput);
427
+ scheduledRefocus?.();
428
+ assert.equal(focusSpy.mock.calls.length, 1);
429
+ } finally {
430
+ setTimeoutSpy.mockRestore();
431
+ reactNative.Platform.OS = originalOS;
432
+ globalThis.requestAnimationFrame = originalRequestAnimationFrame;
433
+ }
434
+ });
435
+ });
436
+
437
+ it("calls both onEnter and onSubmitEditing when submitting", () => {
438
+ const onSubmitEditing = mock(() => {});
439
+ const {getByDisplayValue} = renderWithTheme(
440
+ <TextField
441
+ onChange={mockOnChange}
442
+ onEnter={mockOnEnter}
443
+ onSubmitEditing={onSubmitEditing}
444
+ value=""
445
+ />
446
+ );
447
+
448
+ getByDisplayValue("").props.onSubmitEditing();
449
+
450
+ assert.equal(mockOnEnter.mock.calls.length, 1);
451
+ assert.equal(onSubmitEditing.mock.calls.length, 1);
452
+ });
453
+
196
454
  it("should render url type with correct keyboard", () => {
197
455
  const {getByDisplayValue} = renderWithTheme(
198
456
  <TextField onChange={mockOnChange} type="url" value="" />
@@ -539,5 +797,168 @@ describe("TextField", () => {
539
797
  fireEvent(getByDisplayValue(""), "focus");
540
798
  expect(mockOnFocus).toHaveBeenCalledTimes(1);
541
799
  });
800
+
801
+ it("ignores onChangeText when the text matches the controlled value", async () => {
802
+ const onChange = mock(() => {});
803
+ const {getByDisplayValue} = renderWithTheme(
804
+ <TextField onChange={onChange} value="stable title" />
805
+ );
806
+
807
+ await act(async () => {
808
+ fireEvent.changeText(getByDisplayValue("stable title"), "stable title");
809
+ });
810
+
811
+ expect(onChange).not.toHaveBeenCalled();
812
+ });
813
+
814
+ it("keeps a stable onChangeText callback across value and onChange updates while invoking the latest onChange", async () => {
815
+ const onChange1 = mock(() => {});
816
+ const onChange2 = mock(() => {});
817
+ const {getByDisplayValue, rerender} = renderWithTheme(
818
+ <TextField onChange={onChange1} value="hello" />
819
+ );
820
+
821
+ const initialOnChangeText = getByDisplayValue("hello").props.onChangeText;
822
+
823
+ rerender(<TextField onChange={onChange2} value="world" />);
824
+
825
+ const input = getByDisplayValue("world");
826
+ expect(input.props.onChangeText).toBe(initialOnChangeText);
827
+
828
+ await act(async () => {
829
+ fireEvent.changeText(input, "updated");
830
+ });
831
+
832
+ expect(onChange2).toHaveBeenCalledWith("updated");
833
+ expect(onChange1).not.toHaveBeenCalled();
834
+ });
835
+
836
+ it("preserves per-character typing when onChangeText identity churn would trigger stale RN Web rebinds", async () => {
837
+ const savedOS = PlatformModule.OS;
838
+ const perCharTitle = "Review";
839
+
840
+ try {
841
+ PlatformModule.OS = "web";
842
+ let value = "";
843
+ const onChange = mock((next: string) => {
844
+ value = next;
845
+ });
846
+
847
+ const renderField = (): ReactElement => (
848
+ <TextField onChange={onChange} type="text" value={value} />
849
+ );
850
+
851
+ const view = renderWithTheme(renderField());
852
+
853
+ for (let i = 0; i < perCharTitle.length; i++) {
854
+ const partial = perCharTitle.slice(0, i + 1);
855
+ const field = view.getByDisplayValue(value);
856
+ const previousOnChangeText = field.props.onChangeText;
857
+
858
+ await act(async () => {
859
+ fireEvent.changeText(field, partial);
860
+ });
861
+
862
+ view.rerender(renderField());
863
+
864
+ const fieldAfterChange = view.getByDisplayValue(value);
865
+ expect(fieldAfterChange.props.onChangeText).toBe(previousOnChangeText);
866
+ expect(fieldAfterChange.props.value).toBe(partial);
867
+ }
868
+
869
+ expect(view.getByDisplayValue(value).props.value).toBe(perCharTitle);
870
+ } finally {
871
+ PlatformModule.OS = savedOS;
872
+ }
873
+ });
874
+
875
+ it("disables browser autocorrect and spellcheck on web", () => {
876
+ const savedOS = PlatformModule.OS;
877
+ try {
878
+ PlatformModule.OS = "web";
879
+ const {getByDisplayValue} = renderWithTheme(
880
+ <TextField onChange={mockOnChange} type="text" value="controlled title" />
881
+ );
882
+ const input = getByDisplayValue("controlled title");
883
+ expect(input.props.autoCorrect).toBe(false);
884
+ expect(input.props.spellCheck).toBe(false);
885
+ } finally {
886
+ PlatformModule.OS = savedOS;
887
+ }
888
+ });
889
+
890
+ it("does not recurse when synthetic onChange alternates by a single-space autocorrect delta", async () => {
891
+ const savedOS = PlatformModule.OS;
892
+ const withoutSpace =
893
+ "Tetginsbhep al attempt to trigger loop crash now via extended typed input to reachthreshold fo maximum update depth exc";
894
+ const withSpace =
895
+ "Tetginsbhep al attempt to trigger loop crash now via extended typed input to reach threshold fo maximum update depth exc";
896
+
897
+ try {
898
+ PlatformModule.OS = "web";
899
+ let value = withoutSpace;
900
+ const onChange = mock((next: string) => {
901
+ value = next;
902
+ });
903
+
904
+ const renderField = (): ReactElement => (
905
+ <TextField onChange={onChange} testID="admin-field-title" type="text" value={value} />
906
+ );
907
+
908
+ const view = renderWithTheme(renderField());
909
+ const alternates = [withSpace, withoutSpace];
910
+
911
+ for (let i = 0; i < 6; i++) {
912
+ const nextText = alternates[i % 2];
913
+ await act(async () => {
914
+ fireEvent.changeText(view.getByDisplayValue(value), nextText);
915
+ });
916
+ view.rerender(renderField());
917
+ }
918
+
919
+ expect(onChange.mock.calls.length).toBe(1);
920
+ expect(onChange.mock.calls[0]?.[0]).toBe(withSpace);
921
+ expect(value).toBe(withSpace);
922
+ } finally {
923
+ PlatformModule.OS = savedOS;
924
+ }
925
+ });
926
+
927
+ it("allows backspace and retype after the oscillation window", async () => {
928
+ const savedOS = PlatformModule.OS;
929
+ const originalNow = performance.now.bind(performance);
930
+ let fakeNow = 10_000;
931
+
932
+ try {
933
+ PlatformModule.OS = "web";
934
+ performance.now = () => fakeNow;
935
+
936
+ let value = "hello";
937
+ const onChange = mock((next: string) => {
938
+ value = next;
939
+ });
940
+
941
+ const view = renderWithTheme(
942
+ <TextField onChange={onChange} testID="admin-field-title" type="text" value={value} />
943
+ );
944
+
945
+ await act(async () => {
946
+ fireEvent.changeText(view.getByDisplayValue(value), "hell");
947
+ });
948
+ view.rerender(
949
+ <TextField onChange={onChange} testID="admin-field-title" type="text" value={value} />
950
+ );
951
+
952
+ fakeNow += 600;
953
+ await act(async () => {
954
+ fireEvent.changeText(view.getByDisplayValue(value), "hello");
955
+ });
956
+
957
+ expect(onChange.mock.calls.map((call) => call[0])).toEqual(["hell", "hello"]);
958
+ } finally {
959
+ performance.now = originalNow;
960
+ PlatformModule.OS = savedOS;
961
+ }
962
+ });
542
963
  });
543
964
  });