@terreno/ui 57.19.2 → 57.20.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 (295) hide show
  1. package/.ai/guidelines/core.md +1 -1
  2. package/CHANGELOG.md +393 -0
  3. package/dist/Accordion.d.ts.map +1 -1
  4. package/dist/Accordion.js +3 -3
  5. package/dist/Accordion.js.map +1 -1
  6. package/dist/Avatar.d.ts.map +1 -1
  7. package/dist/Avatar.js +3 -1
  8. package/dist/Avatar.js.map +1 -1
  9. package/dist/Box.d.ts.map +1 -1
  10. package/dist/Box.js +38 -2
  11. package/dist/Box.js.map +1 -1
  12. package/dist/Card.js +2 -2
  13. package/dist/Card.js.map +1 -1
  14. package/dist/Common.d.ts +120 -7
  15. package/dist/Common.d.ts.map +1 -1
  16. package/dist/Common.js.map +1 -1
  17. package/dist/ConsentFormScreen.d.ts +1 -1
  18. package/dist/ConsentFormScreen.d.ts.map +1 -1
  19. package/dist/ConsentFormScreen.js +13 -4
  20. package/dist/ConsentFormScreen.js.map +1 -1
  21. package/dist/DateTimeField.d.ts.map +1 -1
  22. package/dist/DateTimeField.js +5 -3
  23. package/dist/DateTimeField.js.map +1 -1
  24. package/dist/Field.d.ts.map +1 -1
  25. package/dist/Field.js +2 -0
  26. package/dist/Field.js.map +1 -1
  27. package/dist/FormContainer.d.ts +68 -0
  28. package/dist/FormContainer.d.ts.map +1 -0
  29. package/dist/FormContainer.js +79 -0
  30. package/dist/FormContainer.js.map +1 -0
  31. package/dist/GPTChat.d.ts.map +1 -1
  32. package/dist/GPTChat.js +2 -1
  33. package/dist/GPTChat.js.map +1 -1
  34. package/dist/Heading.d.ts +1 -1
  35. package/dist/Heading.d.ts.map +1 -1
  36. package/dist/Heading.js +5 -2
  37. package/dist/Heading.js.map +1 -1
  38. package/dist/Icon.d.ts +4 -0
  39. package/dist/Icon.d.ts.map +1 -1
  40. package/dist/Icon.js +43 -2
  41. package/dist/Icon.js.map +1 -1
  42. package/dist/LabeledCheckBox.d.ts +22 -0
  43. package/dist/LabeledCheckBox.d.ts.map +1 -0
  44. package/dist/LabeledCheckBox.js +30 -0
  45. package/dist/LabeledCheckBox.js.map +1 -0
  46. package/dist/ListDetailLayout.d.ts +36 -0
  47. package/dist/ListDetailLayout.d.ts.map +1 -0
  48. package/dist/ListDetailLayout.js +153 -0
  49. package/dist/ListDetailLayout.js.map +1 -0
  50. package/dist/MarkdownEditor.d.ts.map +1 -1
  51. package/dist/MarkdownEditor.js +2 -1
  52. package/dist/MarkdownEditor.js.map +1 -1
  53. package/dist/MediaQuery.d.ts +1 -1
  54. package/dist/MediaQuery.d.ts.map +1 -1
  55. package/dist/MediaQuery.js +1 -1
  56. package/dist/MediaQuery.js.map +1 -1
  57. package/dist/OtpField.d.ts +60 -0
  58. package/dist/OtpField.d.ts.map +1 -0
  59. package/dist/OtpField.js +154 -0
  60. package/dist/OtpField.js.map +1 -0
  61. package/dist/ProvisionalConsentSigner.d.ts +21 -0
  62. package/dist/ProvisionalConsentSigner.d.ts.map +1 -0
  63. package/dist/ProvisionalConsentSigner.js +199 -0
  64. package/dist/ProvisionalConsentSigner.js.map +1 -0
  65. package/dist/ResponsiveBreakpoint.d.ts +5 -0
  66. package/dist/ResponsiveBreakpoint.d.ts.map +1 -1
  67. package/dist/ResponsiveBreakpoint.js +7 -0
  68. package/dist/ResponsiveBreakpoint.js.map +1 -1
  69. package/dist/SocialLoginButton.d.ts +10 -0
  70. package/dist/SocialLoginButton.d.ts.map +1 -1
  71. package/dist/SocialLoginButton.js +26 -8
  72. package/dist/SocialLoginButton.js.map +1 -1
  73. package/dist/SplitPage.d.ts +11 -0
  74. package/dist/SplitPage.d.ts.map +1 -1
  75. package/dist/SplitPage.js +11 -5
  76. package/dist/SplitPage.js.map +1 -1
  77. package/dist/SplitPage.native.d.ts.map +1 -1
  78. package/dist/SplitPage.native.js +3 -1
  79. package/dist/SplitPage.native.js.map +1 -1
  80. package/dist/SyncStatusBanner.d.ts +7 -1
  81. package/dist/SyncStatusBanner.d.ts.map +1 -1
  82. package/dist/SyncStatusBanner.js +20 -4
  83. package/dist/SyncStatusBanner.js.map +1 -1
  84. package/dist/TextField.d.ts.map +1 -1
  85. package/dist/TextField.js +44 -10
  86. package/dist/TextField.js.map +1 -1
  87. package/dist/fieldElements/FieldError.d.ts.map +1 -1
  88. package/dist/fieldElements/FieldError.js +1 -1
  89. package/dist/fieldElements/FieldError.js.map +1 -1
  90. package/dist/index.d.ts +19 -3
  91. package/dist/index.d.ts.map +1 -1
  92. package/dist/index.js +14 -1
  93. package/dist/index.js.map +1 -1
  94. package/dist/lazyBoundaries/heavyOptionalExports.d.ts +3 -0
  95. package/dist/lazyBoundaries/heavyOptionalExports.d.ts.map +1 -1
  96. package/dist/lazyBoundaries/heavyOptionalExports.js +2 -0
  97. package/dist/lazyBoundaries/heavyOptionalExports.js.map +1 -1
  98. package/dist/login/LastUsedBadge.d.ts +14 -0
  99. package/dist/login/LastUsedBadge.d.ts.map +1 -0
  100. package/dist/login/LastUsedBadge.js +23 -0
  101. package/dist/login/LastUsedBadge.js.map +1 -0
  102. package/dist/login/LoginAccountCard.d.ts +38 -0
  103. package/dist/login/LoginAccountCard.d.ts.map +1 -0
  104. package/dist/login/LoginAccountCard.js +72 -0
  105. package/dist/login/LoginAccountCard.js.map +1 -0
  106. package/dist/login/LoginAccountList.d.ts +33 -0
  107. package/dist/login/LoginAccountList.d.ts.map +1 -0
  108. package/dist/login/LoginAccountList.js +30 -0
  109. package/dist/login/LoginAccountList.js.map +1 -0
  110. package/dist/login/LoginScreen.d.ts +4 -4
  111. package/dist/login/LoginScreen.d.ts.map +1 -1
  112. package/dist/login/LoginScreen.js +294 -13
  113. package/dist/login/LoginScreen.js.map +1 -1
  114. package/dist/login/OutlinePill.d.ts +28 -0
  115. package/dist/login/OutlinePill.d.ts.map +1 -0
  116. package/dist/login/OutlinePill.js +48 -0
  117. package/dist/login/OutlinePill.js.map +1 -0
  118. package/dist/login/TwoFactorChallengeScreen.d.ts +26 -0
  119. package/dist/login/TwoFactorChallengeScreen.d.ts.map +1 -0
  120. package/dist/login/TwoFactorChallengeScreen.js +139 -0
  121. package/dist/login/TwoFactorChallengeScreen.js.map +1 -0
  122. package/dist/login/loginMethods.d.ts +27 -0
  123. package/dist/login/loginMethods.d.ts.map +1 -0
  124. package/dist/login/loginMethods.js +37 -0
  125. package/dist/login/loginMethods.js.map +1 -0
  126. package/dist/login/loginTypes.d.ts +202 -5
  127. package/dist/login/loginTypes.d.ts.map +1 -1
  128. package/dist/pdfHtmlTemplate.d.ts +17 -0
  129. package/dist/pdfHtmlTemplate.d.ts.map +1 -1
  130. package/dist/pdfHtmlTemplate.js +78 -0
  131. package/dist/pdfHtmlTemplate.js.map +1 -1
  132. package/dist/security/AccountSecurityScreen.d.ts +10 -0
  133. package/dist/security/AccountSecurityScreen.d.ts.map +1 -0
  134. package/dist/security/AccountSecurityScreen.js +50 -0
  135. package/dist/security/AccountSecurityScreen.js.map +1 -0
  136. package/dist/security/LinkedAccountsCard.d.ts +32 -0
  137. package/dist/security/LinkedAccountsCard.d.ts.map +1 -0
  138. package/dist/security/LinkedAccountsCard.js +145 -0
  139. package/dist/security/LinkedAccountsCard.js.map +1 -0
  140. package/dist/security/PasskeysCard.d.ts +39 -0
  141. package/dist/security/PasskeysCard.d.ts.map +1 -0
  142. package/dist/security/PasskeysCard.js +168 -0
  143. package/dist/security/PasskeysCard.js.map +1 -0
  144. package/dist/security/PasswordCard.d.ts +32 -0
  145. package/dist/security/PasswordCard.d.ts.map +1 -0
  146. package/dist/security/PasswordCard.js +198 -0
  147. package/dist/security/PasswordCard.js.map +1 -0
  148. package/dist/security/SessionsCard.d.ts +39 -0
  149. package/dist/security/SessionsCard.d.ts.map +1 -0
  150. package/dist/security/SessionsCard.js +168 -0
  151. package/dist/security/SessionsCard.js.map +1 -0
  152. package/dist/security/TwoFactorSettingsCard.d.ts +55 -0
  153. package/dist/security/TwoFactorSettingsCard.d.ts.map +1 -0
  154. package/dist/security/TwoFactorSettingsCard.js +458 -0
  155. package/dist/security/TwoFactorSettingsCard.js.map +1 -0
  156. package/dist/security/securityMethods.d.ts +40 -0
  157. package/dist/security/securityMethods.d.ts.map +1 -0
  158. package/dist/security/securityMethods.js +66 -0
  159. package/dist/security/securityMethods.js.map +1 -0
  160. package/dist/security/securityTypes.d.ts +467 -0
  161. package/dist/security/securityTypes.d.ts.map +1 -0
  162. package/dist/security/securityTypes.js +2 -0
  163. package/dist/security/securityTypes.js.map +1 -0
  164. package/dist/security/userAgent.d.ts +26 -0
  165. package/dist/security/userAgent.d.ts.map +1 -0
  166. package/dist/security/userAgent.js +80 -0
  167. package/dist/security/userAgent.js.map +1 -0
  168. package/dist/signUp/OAuthButtons.d.ts +28 -5
  169. package/dist/signUp/OAuthButtons.d.ts.map +1 -1
  170. package/dist/signUp/OAuthButtons.js +44 -5
  171. package/dist/signUp/OAuthButtons.js.map +1 -1
  172. package/dist/signUp/SignUpScreen.d.ts.map +1 -1
  173. package/dist/signUp/SignUpScreen.js +50 -5
  174. package/dist/signUp/SignUpScreen.js.map +1 -1
  175. package/dist/signUp/signUpTypes.d.ts +21 -1
  176. package/dist/signUp/signUpTypes.d.ts.map +1 -1
  177. package/dist/useConsentForms.d.ts +9 -0
  178. package/dist/useConsentForms.d.ts.map +1 -1
  179. package/dist/useConsentForms.js +18 -0
  180. package/dist/useConsentForms.js.map +1 -1
  181. package/dist/useProvisionalConsent.d.ts +124 -0
  182. package/dist/useProvisionalConsent.d.ts.map +1 -0
  183. package/dist/useProvisionalConsent.js +79 -0
  184. package/dist/useProvisionalConsent.js.map +1 -0
  185. package/package.json +3 -2
  186. package/src/Accordion.test.tsx +5 -0
  187. package/src/Accordion.tsx +3 -8
  188. package/src/AreaChart.test.tsx +15 -0
  189. package/src/Avatar.test.tsx +8 -0
  190. package/src/Avatar.tsx +2 -0
  191. package/src/BarChart.test.tsx +15 -0
  192. package/src/Box.test.tsx +61 -1
  193. package/src/Box.tsx +44 -2
  194. package/src/Card.tsx +2 -2
  195. package/src/Common.ts +134 -7
  196. package/src/ConsentFormScreen.test.tsx +84 -0
  197. package/src/ConsentFormScreen.tsx +28 -4
  198. package/src/DateTimeField.tsx +5 -3
  199. package/src/DonutChart.test.tsx +15 -0
  200. package/src/Field.tsx +2 -0
  201. package/src/FilePickerButton.test.tsx +35 -0
  202. package/src/FormContainer.test.tsx +242 -0
  203. package/src/FormContainer.tsx +177 -0
  204. package/src/GPTChat.test.tsx +16 -0
  205. package/src/GPTChat.tsx +8 -2
  206. package/src/Heading.test.tsx +14 -0
  207. package/src/Heading.tsx +6 -1
  208. package/src/Icon.test.tsx +52 -1
  209. package/src/Icon.tsx +92 -3
  210. package/src/IconButton.test.tsx +85 -0
  211. package/src/LabeledCheckBox.test.tsx +45 -0
  212. package/src/LabeledCheckBox.tsx +89 -0
  213. package/src/ListDetailLayout.tsx +247 -0
  214. package/src/MarkdownEditor.tsx +2 -1
  215. package/src/MediaQuery.ts +1 -0
  216. package/src/OtpField.test.tsx +280 -0
  217. package/src/OtpField.tsx +307 -0
  218. package/src/ProvisionalConsentSigner.test.tsx +625 -0
  219. package/src/ProvisionalConsentSigner.tsx +423 -0
  220. package/src/ResponsiveBreakpoint.test.tsx +7 -0
  221. package/src/ResponsiveBreakpoint.tsx +14 -0
  222. package/src/RootImportRegression.test.tsx +3 -0
  223. package/src/SocialLoginButton.test.tsx +14 -0
  224. package/src/SocialLoginButton.tsx +51 -7
  225. package/src/SplitPage.native.tsx +3 -1
  226. package/src/SplitPage.tsx +11 -5
  227. package/src/SyncStatusBanner.test.tsx +61 -4
  228. package/src/SyncStatusBanner.tsx +29 -3
  229. package/src/TextField.test.tsx +150 -0
  230. package/src/TextField.tsx +66 -8
  231. package/src/__snapshots__/AddressField.test.tsx.snap +12 -0
  232. package/src/__snapshots__/AiSuggestionBox.test.tsx.snap +15 -0
  233. package/src/__snapshots__/Avatar.test.tsx.snap +1 -0
  234. package/src/__snapshots__/CustomSelectField.test.tsx.snap +3 -0
  235. package/src/__snapshots__/EmailField.test.tsx.snap +6 -0
  236. package/src/__snapshots__/Field.test.tsx.snap +37 -0
  237. package/src/__snapshots__/HeightField.test.tsx.snap +2 -0
  238. package/src/__snapshots__/MobileAddressAutoComplete.test.tsx.snap +3 -0
  239. package/src/__snapshots__/NumberField.test.tsx.snap +3 -0
  240. package/src/__snapshots__/PhoneNumberField.test.tsx.snap +12 -0
  241. package/src/__snapshots__/Slider.test.tsx.snap +1 -0
  242. package/src/__snapshots__/SocialLoginButton.test.tsx.snap +43 -22
  243. package/src/__snapshots__/TapToEdit.test.tsx.snap +3 -0
  244. package/src/__snapshots__/TextArea.test.tsx.snap +17 -1
  245. package/src/__snapshots__/TextField.test.tsx.snap +19 -2
  246. package/src/__snapshots__/TypedSignatureField.test.tsx.snap +3 -0
  247. package/src/__snapshots__/UnifiedAddressAutoComplete.test.tsx.snap +18 -0
  248. package/src/__snapshots__/WebAddressAutocomplete.test.tsx.snap +12 -0
  249. package/src/bunSetup.ts +13 -1
  250. package/src/fieldElements/FieldError.tsx +1 -0
  251. package/src/fieldElements/__snapshots__/FieldError.test.tsx.snap +2 -0
  252. package/src/index.tsx +42 -1
  253. package/src/isolated/ListDetailLayout.isolated.tsx +634 -0
  254. package/src/lazyBoundaries/heavyOptionalExports.tsx +7 -0
  255. package/src/login/LastUsedBadge.tsx +40 -0
  256. package/src/login/LoginAccountCard.tsx +205 -0
  257. package/src/login/LoginAccountList.tsx +115 -0
  258. package/src/login/LoginScreen.test.tsx +837 -1
  259. package/src/login/LoginScreen.tsx +674 -91
  260. package/src/login/OutlinePill.tsx +110 -0
  261. package/src/login/TwoFactorChallengeScreen.test.tsx +376 -0
  262. package/src/login/TwoFactorChallengeScreen.tsx +307 -0
  263. package/src/login/__snapshots__/LoginScreen.test.tsx.snap +1454 -334
  264. package/src/login/loginMethods.test.ts +53 -0
  265. package/src/login/loginMethods.ts +60 -0
  266. package/src/login/loginTypes.ts +208 -5
  267. package/src/pdfHtmlTemplate.test.ts +243 -4
  268. package/src/pdfHtmlTemplate.ts +93 -0
  269. package/src/security/AccountSecurityScreen.test.tsx +262 -0
  270. package/src/security/AccountSecurityScreen.tsx +156 -0
  271. package/src/security/LinkedAccountsCard.test.tsx +371 -0
  272. package/src/security/LinkedAccountsCard.tsx +297 -0
  273. package/src/security/PasskeysCard.test.tsx +378 -0
  274. package/src/security/PasskeysCard.tsx +371 -0
  275. package/src/security/PasswordCard.test.tsx +445 -0
  276. package/src/security/PasswordCard.tsx +342 -0
  277. package/src/security/SessionsCard.test.tsx +349 -0
  278. package/src/security/SessionsCard.tsx +362 -0
  279. package/src/security/TwoFactorSettingsCard.test.tsx +700 -0
  280. package/src/security/TwoFactorSettingsCard.tsx +872 -0
  281. package/src/security/securityMethods.test.ts +101 -0
  282. package/src/security/securityMethods.ts +104 -0
  283. package/src/security/securityTypes.ts +480 -0
  284. package/src/security/userAgent.test.ts +119 -0
  285. package/src/security/userAgent.ts +102 -0
  286. package/src/signUp/OAuthButtons.test.tsx +27 -0
  287. package/src/signUp/OAuthButtons.tsx +153 -19
  288. package/src/signUp/SignUpScreen.test.tsx +170 -1
  289. package/src/signUp/SignUpScreen.tsx +87 -25
  290. package/src/signUp/__snapshots__/SignUpScreen.test.tsx.snap +22 -11
  291. package/src/signUp/signUpTypes.ts +23 -1
  292. package/src/useConsentForms.test.ts +37 -1
  293. package/src/useConsentForms.ts +25 -0
  294. package/src/useProvisionalConsent.test.ts +256 -0
  295. package/src/useProvisionalConsent.ts +218 -0
@@ -1,18 +1,75 @@
1
- import {describe, expect, it, mock} from "bun:test";
2
- import {fireEvent} from "@testing-library/react-native";
1
+ import {describe, expect, it, jest, mock} from "bun:test";
2
+ import {act, fireEvent} from "@testing-library/react-native";
3
3
 
4
4
  import {SyncStatusBanner} from "./SyncStatusBanner";
5
5
  import {renderWithTheme} from "./test-utils";
6
6
 
7
7
  describe("SyncStatusBanner", () => {
8
- it("renders the offline indicator when offline", () => {
8
+ it("renders the offline indicator immediately when the grace period is 0", () => {
9
9
  const {getByTestId, queryByTestId} = renderWithTheme(
10
- <SyncStatusBanner conflictCount={0} isOnline={false} isSyncing={false} queuedCount={0} />
10
+ <SyncStatusBanner
11
+ conflictCount={0}
12
+ isOnline={false}
13
+ isSyncing={false}
14
+ offlineGraceMs={0}
15
+ queuedCount={0}
16
+ />
11
17
  );
12
18
  expect(getByTestId("sync-offline-indicator")).toBeTruthy();
13
19
  expect(queryByTestId("sync-syncing-indicator")).toBeNull();
14
20
  });
15
21
 
22
+ it("waits out the grace period before showing the offline indicator", () => {
23
+ jest.useFakeTimers();
24
+ try {
25
+ const {queryByTestId} = renderWithTheme(
26
+ <SyncStatusBanner conflictCount={0} isOnline={false} queuedCount={0} />
27
+ );
28
+ expect(queryByTestId("sync-offline-indicator")).toBeNull();
29
+ act(() => {
30
+ jest.advanceTimersByTime(2999);
31
+ });
32
+ expect(queryByTestId("sync-offline-indicator")).toBeNull();
33
+ act(() => {
34
+ jest.advanceTimersByTime(1);
35
+ });
36
+ expect(queryByTestId("sync-offline-indicator")).toBeTruthy();
37
+ } finally {
38
+ jest.useRealTimers();
39
+ }
40
+ });
41
+
42
+ it("does not flash offline for a drop shorter than the grace period", () => {
43
+ jest.useFakeTimers();
44
+ try {
45
+ const view = renderWithTheme(
46
+ <SyncStatusBanner conflictCount={0} isOnline={true} queuedCount={0} />
47
+ );
48
+ view.rerender(<SyncStatusBanner conflictCount={0} isOnline={false} queuedCount={0} />);
49
+ act(() => {
50
+ jest.advanceTimersByTime(1000);
51
+ });
52
+ view.rerender(<SyncStatusBanner conflictCount={0} isOnline={true} queuedCount={0} />);
53
+ act(() => {
54
+ jest.advanceTimersByTime(5000);
55
+ });
56
+ expect(view.queryByTestId("sync-offline-indicator")).toBeNull();
57
+ } finally {
58
+ jest.useRealTimers();
59
+ }
60
+ });
61
+
62
+ it("hides the offline indicator as soon as connectivity returns", () => {
63
+ const view = renderWithTheme(
64
+ <SyncStatusBanner conflictCount={0} isOnline={false} offlineGraceMs={0} queuedCount={0} />
65
+ );
66
+ expect(view.queryByTestId("sync-offline-indicator")).toBeTruthy();
67
+ view.rerender(
68
+ <SyncStatusBanner conflictCount={0} isOnline={true} offlineGraceMs={0} queuedCount={0} />
69
+ );
70
+ expect(view.queryByTestId("sync-offline-indicator")).toBeNull();
71
+ });
72
+
16
73
  it("hides the offline indicator when online", () => {
17
74
  const {getByTestId, queryByTestId} = renderWithTheme(
18
75
  <SyncStatusBanner conflictCount={0} isOnline={true} isSyncing={false} queuedCount={0} />
@@ -1,5 +1,5 @@
1
1
  import type React from "react";
2
- import {useCallback} from "react";
2
+ import {useCallback, useEffect, useState} from "react";
3
3
 
4
4
  import {Badge} from "./Badge";
5
5
  import {Box} from "./Box";
@@ -7,9 +7,18 @@ import {Box} from "./Box";
7
7
  /** Queued count above which the banner switches to a numeric drain-progress display. */
8
8
  const PROGRESS_THRESHOLD = 20;
9
9
 
10
+ /** Default time connectivity must stay lost before the offline badge appears. */
11
+ const DEFAULT_OFFLINE_GRACE_MS = 3000;
12
+
10
13
  export interface SyncStatusBannerProps {
11
14
  /** Whether the client currently has connectivity. */
12
15
  isOnline: boolean;
16
+ /**
17
+ * How long (ms) `isOnline` must stay false before the offline badge shows. Absorbs the
18
+ * not-yet-connected window at startup and sub-second socket blips so the badge does not
19
+ * flash. Going back online hides it immediately. Defaults to 3000; pass 0 to show at once.
20
+ */
21
+ offlineGraceMs?: number;
13
22
  /** Number of mutations waiting in the durable outbox. */
14
23
  queuedCount: number;
15
24
  /**
@@ -45,7 +54,7 @@ export interface SyncStatusBannerProps {
45
54
 
46
55
  /**
47
56
  * Compact, presentational sync-state banner for local-first (e.g. @terreno/syncdb) screens:
48
- * offline indicator, queued mutation count (with drain progress once the queue grows past
57
+ * offline indicator (shown only after a short grace period), queued mutation count (with drain progress once the queue grows past
49
58
  * {@link PROGRESS_THRESHOLD}), a paused-for-auth indicator, a pressable failed count, and a
50
59
  * pressable conflict badge. Initial bootstrap "Syncing…" is intentionally not shown here —
51
60
  * apps should surface that as a one-shot toast on launch (see SyncHealthToast). It is
@@ -54,6 +63,7 @@ export interface SyncStatusBannerProps {
54
63
  */
55
64
  export const SyncStatusBanner: React.FC<SyncStatusBannerProps> = ({
56
65
  isOnline,
66
+ offlineGraceMs = DEFAULT_OFFLINE_GRACE_MS,
57
67
  queuedCount,
58
68
  isSyncing: _isSyncing,
59
69
  conflictCount,
@@ -67,6 +77,22 @@ export const SyncStatusBanner: React.FC<SyncStatusBannerProps> = ({
67
77
  onOpenFailed,
68
78
  testID = "sync-status-banner",
69
79
  }) => {
80
+ const [isOfflineSettled, setIsOfflineSettled] = useState(!isOnline && offlineGraceMs <= 0);
81
+
82
+ // Only surface "Offline" once connectivity has stayed lost for the grace period.
83
+ useEffect(() => {
84
+ if (isOnline) {
85
+ setIsOfflineSettled(false);
86
+ return;
87
+ }
88
+ if (offlineGraceMs <= 0) {
89
+ setIsOfflineSettled(true);
90
+ return;
91
+ }
92
+ const timer = setTimeout(() => setIsOfflineSettled(true), offlineGraceMs);
93
+ return (): void => clearTimeout(timer);
94
+ }, [isOnline, offlineGraceMs]);
95
+
70
96
  const handleOpenConflicts = useCallback((): void => {
71
97
  onOpenConflicts?.();
72
98
  }, [onOpenConflicts]);
@@ -83,7 +109,7 @@ export const SyncStatusBanner: React.FC<SyncStatusBannerProps> = ({
83
109
 
84
110
  return (
85
111
  <Box direction="row" gap={2} marginBottom={4} minHeight={20} testID={testID} wrap>
86
- {!isOnline && (
112
+ {!isOnline && isOfflineSettled && (
87
113
  <Box alignItems="center" direction="row" gap={1} testID="sync-offline-indicator">
88
114
  <Badge status="error" value="Offline" />
89
115
  </Box>
@@ -3,6 +3,7 @@ import {act, fireEvent, userEvent} from "@testing-library/react-native";
3
3
  import {assert} from "chai";
4
4
  import type {ReactElement} from "react";
5
5
  import type {TextInput} from "react-native";
6
+ import type {TextFieldProps} from "./Common";
6
7
  import {TextField} from "./TextField";
7
8
  import {renderWithTheme} from "./test-utils";
8
9
 
@@ -579,6 +580,14 @@ describe("TextField", () => {
579
580
  expect(input.props["aria-label"]).toBe("Text input field");
580
581
  });
581
582
 
583
+ it("uses accessibilityLabel as the input's accessible name", () => {
584
+ const {getByDisplayValue} = renderWithTheme(
585
+ <TextField accessibilityLabel="Backup code" onChange={mockOnChange} value="" />
586
+ );
587
+
588
+ expect(getByDisplayValue("").props["aria-label"]).toBe("Backup code");
589
+ });
590
+
582
591
  it("should indicate disabled state in accessibility", () => {
583
592
  const {getByDisplayValue} = renderWithTheme(
584
593
  <TextField disabled onChange={mockOnChange} value="" />
@@ -1017,4 +1026,145 @@ describe("TextField", () => {
1017
1026
  }
1018
1027
  });
1019
1028
  });
1029
+
1030
+ describe("autoComplete", () => {
1031
+ const setOS = (os: string): string => {
1032
+ const reactNative = require("react-native") as {Platform: {OS: string}};
1033
+ const originalOS = reactNative.Platform.OS;
1034
+ reactNative.Platform.OS = os;
1035
+ return originalOS;
1036
+ };
1037
+
1038
+ it("sets autoComplete on the input on web", () => {
1039
+ const originalOS = setOS("web");
1040
+ try {
1041
+ const {getByTestId} = renderWithTheme(
1042
+ <>
1043
+ <TextField
1044
+ autoComplete="current-password"
1045
+ onChange={() => {}}
1046
+ testID="password"
1047
+ type="password"
1048
+ value=""
1049
+ />
1050
+ <TextField
1051
+ autoComplete="username webauthn"
1052
+ onChange={() => {}}
1053
+ testID="email"
1054
+ type="email"
1055
+ value=""
1056
+ />
1057
+ </>
1058
+ );
1059
+ expect(getByTestId("password").props.autoComplete).toBe("current-password");
1060
+ expect(getByTestId("email").props.autoComplete).toBe("username webauthn");
1061
+ } finally {
1062
+ setOS(originalOS);
1063
+ }
1064
+ });
1065
+
1066
+ const nativeCases: {
1067
+ autoComplete: TextFieldProps["autoComplete"];
1068
+ expectedAutoComplete: string | undefined;
1069
+ expectedTextContentType: string;
1070
+ type: TextFieldProps["type"];
1071
+ }[] = [
1072
+ {
1073
+ autoComplete: "username",
1074
+ expectedAutoComplete: "username",
1075
+ expectedTextContentType: "username",
1076
+ type: "email",
1077
+ },
1078
+ {
1079
+ autoComplete: "username webauthn",
1080
+ expectedAutoComplete: "username",
1081
+ expectedTextContentType: "username",
1082
+ type: "email",
1083
+ },
1084
+ {
1085
+ autoComplete: "email",
1086
+ expectedAutoComplete: "email",
1087
+ expectedTextContentType: "emailAddress",
1088
+ type: "email",
1089
+ },
1090
+ {
1091
+ autoComplete: "current-password",
1092
+ expectedAutoComplete: "current-password",
1093
+ expectedTextContentType: "password",
1094
+ type: "password",
1095
+ },
1096
+ {
1097
+ autoComplete: "new-password",
1098
+ expectedAutoComplete: "new-password",
1099
+ expectedTextContentType: "newPassword",
1100
+ type: "password",
1101
+ },
1102
+ {
1103
+ autoComplete: "one-time-code",
1104
+ expectedAutoComplete: "one-time-code",
1105
+ expectedTextContentType: "oneTimeCode",
1106
+ type: "text",
1107
+ },
1108
+ {
1109
+ autoComplete: "off",
1110
+ expectedAutoComplete: "off",
1111
+ expectedTextContentType: "none",
1112
+ type: "search",
1113
+ },
1114
+ {
1115
+ autoComplete: "on",
1116
+ expectedAutoComplete: undefined,
1117
+ expectedTextContentType: "password",
1118
+ type: "password",
1119
+ },
1120
+ ];
1121
+
1122
+ for (const testCase of nativeCases) {
1123
+ it(`forwards autoComplete="${testCase.autoComplete}" to native autofill hints`, () => {
1124
+ const {getByTestId} = renderWithTheme(
1125
+ <TextField
1126
+ autoComplete={testCase.autoComplete}
1127
+ onChange={() => {}}
1128
+ testID="field"
1129
+ type={testCase.type}
1130
+ value=""
1131
+ />
1132
+ );
1133
+ const input = getByTestId("field");
1134
+ expect(input.props.autoComplete).toBe(testCase.expectedAutoComplete);
1135
+ expect(input.props.textContentType).toBe(testCase.expectedTextContentType);
1136
+ });
1137
+ }
1138
+
1139
+ it("falls back to the type's text content hint on native without autoComplete", () => {
1140
+ const {getByTestId} = renderWithTheme(
1141
+ <>
1142
+ <TextField onChange={() => {}} testID="email" type="email" value="" />
1143
+ <TextField onChange={() => {}} testID="password" type="password" value="" />
1144
+ </>
1145
+ );
1146
+ expect(getByTestId("email").props.autoComplete).toBeUndefined();
1147
+ expect(getByTestId("email").props.textContentType).toBe("emailAddress");
1148
+ expect(getByTestId("password").props.autoComplete).toBeUndefined();
1149
+ expect(getByTestId("password").props.textContentType).toBe("password");
1150
+ });
1151
+
1152
+ it("sets the web autofill token on web and leaves the iOS hint to the type map", () => {
1153
+ const originalOS = setOS("web");
1154
+ try {
1155
+ const {getByTestId} = renderWithTheme(
1156
+ <TextField
1157
+ autoComplete="one-time-code"
1158
+ onChange={() => {}}
1159
+ testID="code"
1160
+ type="text"
1161
+ value=""
1162
+ />
1163
+ );
1164
+ expect(getByTestId("code").props.autoComplete).toBe("one-time-code");
1165
+ } finally {
1166
+ setOS(originalOS);
1167
+ }
1168
+ });
1169
+ });
1020
1170
  });
package/src/TextField.tsx CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  type StyleProp,
9
9
  TextInput,
10
10
  type TextInputChangeEvent,
11
+ type TextInputProps,
11
12
  View,
12
13
  } from "react-native";
13
14
 
@@ -64,6 +65,51 @@ const textContentMap: {
64
65
  username: "username",
65
66
  };
66
67
 
68
+ type TextFieldAutoComplete = NonNullable<TextFieldProps["autoComplete"]>;
69
+
70
+ /**
71
+ * Native autofill hints for each `autoComplete` value. `autoComplete` goes to React Native, which
72
+ * maps the web token to Android's autofill hint; `textContentType` is iOS's hint. "on" means "no
73
+ * opinion", so the field falls back to the hint for its `type`.
74
+ */
75
+ const NATIVE_AUTOFILL: Record<
76
+ TextFieldAutoComplete,
77
+ Pick<TextInputProps, "autoComplete" | "textContentType"> | undefined
78
+ > = {
79
+ "current-password": {autoComplete: "current-password", textContentType: "password"},
80
+ email: {autoComplete: "email", textContentType: "emailAddress"},
81
+ "new-password": {autoComplete: "new-password", textContentType: "newPassword"},
82
+ off: {autoComplete: "off", textContentType: "none"},
83
+ on: undefined,
84
+ "one-time-code": {autoComplete: "one-time-code", textContentType: "oneTimeCode"},
85
+ username: {autoComplete: "username", textContentType: "username"},
86
+ // Passkey autofill is web only; native platforms get the plain username hint.
87
+ "username webauthn": {autoComplete: "username", textContentType: "username"},
88
+ };
89
+
90
+ /**
91
+ * The input's autofill props: the raw token on web (react-native-web writes it to the
92
+ * `autocomplete` attribute, which accepts token lists such as "username webauthn"), or the
93
+ * Android and iOS hints on native.
94
+ */
95
+ const getAutofillProps = ({
96
+ autoComplete,
97
+ type,
98
+ }: {
99
+ autoComplete: TextFieldProps["autoComplete"];
100
+ type: string;
101
+ }): Pick<TextInputProps, "autoComplete" | "textContentType"> => {
102
+ const textContentType = textContentMap[type];
103
+ if (Platform.OS === "web") {
104
+ return {
105
+ ...(autoComplete ? ({autoComplete} as unknown as Pick<TextInputProps, "autoComplete">) : {}),
106
+ textContentType,
107
+ };
108
+ }
109
+ const nativeHints = autoComplete ? NATIVE_AUTOFILL[autoComplete] : undefined;
110
+ return nativeHints ?? {textContentType};
111
+ };
112
+
67
113
  interface WebTextInputRef {
68
114
  focus: () => void;
69
115
  selectionEnd: number | null;
@@ -76,6 +122,7 @@ export const TextField: FC<TextFieldProps> = ({
76
122
  disabled,
77
123
  helperText,
78
124
  errorText,
125
+ errorPosition = "above",
79
126
  value,
80
127
  onChange,
81
128
  placeholder,
@@ -100,6 +147,8 @@ export const TextField: FC<TextFieldProps> = ({
100
147
  testIDs,
101
148
  id,
102
149
  aiSuggestion,
150
+ accessibilityLabel,
151
+ mono = false,
103
152
  }) => {
104
153
  const {theme} = useTheme();
105
154
  const fieldTestIDs = resolveFieldTestIDsFromProps({testID, testIDs});
@@ -167,9 +216,10 @@ export const TextField: FC<TextFieldProps> = ({
167
216
  let borderColor = focused ? theme.border.focus : theme.border.dark;
168
217
  if (disabled) {
169
218
  borderColor = theme.border.activeNeutral;
170
- } else if (errorText) {
219
+ } else if (errorText && !focused) {
171
220
  borderColor = theme.border.error;
172
221
  }
222
+ const borderWidth = focused ? 3 : errorText ? 2 : 1;
173
223
 
174
224
  const calculatedHeight: DimensionValue = useMemo(() => {
175
225
  if (grow) {
@@ -189,10 +239,11 @@ export const TextField: FC<TextFieldProps> = ({
189
239
  const style: StyleProp<TextStyleWithOutline> = {
190
240
  color: theme.text.primary,
191
241
  flex: 1,
192
- fontFamily: "text",
242
+ fontFamily: mono ? "monospace" : "text",
193
243
  fontSize: 16,
194
244
  gap: 10,
195
245
  height: calculatedHeight,
246
+ letterSpacing: mono ? 2 : undefined,
196
247
  paddingVertical: 0,
197
248
  width: "100%",
198
249
  };
@@ -201,7 +252,7 @@ export const TextField: FC<TextFieldProps> = ({
201
252
  style.outline = "none";
202
253
  }
203
254
  return style;
204
- }, [calculatedHeight, theme.text.primary]);
255
+ }, [calculatedHeight, mono, theme.text.primary]);
205
256
 
206
257
  if (["numberRange", "decimalRange", "height"].includes(type)) {
207
258
  console.warn(`${type} is not yet supported`);
@@ -260,8 +311,8 @@ export const TextField: FC<TextFieldProps> = ({
260
311
  onChangeRef.current(text);
261
312
  }, []);
262
313
 
314
+ const autofillProps = getAutofillProps({autoComplete, type: type || "text"});
263
315
  const keyboardType = keyboardMap[type];
264
- const textContentType = textContentMap[type || "text"];
265
316
 
266
317
  return (
267
318
  <View
@@ -271,13 +322,15 @@ export const TextField: FC<TextFieldProps> = ({
271
322
  }}
272
323
  >
273
324
  {Boolean(title) && <FieldTitle testID={fieldTestIDs.label} text={title!} />}
274
- {Boolean(errorText) && <FieldError testID={fieldTestIDs.error} text={errorText!} />}
325
+ {Boolean(errorText) && errorPosition === "above" && (
326
+ <FieldError testID={fieldTestIDs.error} text={errorText!} />
327
+ )}
275
328
  <View
276
329
  style={{
277
330
  backgroundColor: disabled ? theme.surface.neutralLight : theme.surface.base,
278
331
  borderColor,
279
332
  borderRadius: 4,
280
- borderWidth: focused ? 3 : 1,
333
+ borderWidth,
281
334
  flexDirection: "column",
282
335
  gap: aiSuggestion ? 10 : 0,
283
336
  overflow: "hidden",
@@ -299,9 +352,12 @@ export const TextField: FC<TextFieldProps> = ({
299
352
  >
300
353
  <TextInput
301
354
  {...(Platform.OS === "web" ? {spellCheck: false} : {})}
355
+ {...autofillProps}
302
356
  accessibilityHint="Enter text here"
303
357
  accessibilityState={{disabled}}
304
- aria-label="Text input field"
358
+ aria-describedby={errorText ? fieldTestIDs.error : undefined}
359
+ aria-invalid={Boolean(errorText)}
360
+ aria-label={accessibilityLabel ?? "Text input field"}
305
361
  autoCapitalize={type === "text" ? "sentences" : "none"}
306
362
  autoCorrect={shouldAutocorrect}
307
363
  blurOnSubmit={blurOnSubmit}
@@ -363,7 +419,6 @@ export const TextField: FC<TextFieldProps> = ({
363
419
  secureTextEntry={isPasswordField && !isValueRevealed}
364
420
  style={defaultTextInputStyles}
365
421
  testID={fieldTestIDs.input}
366
- textContentType={textContentType}
367
422
  underlineColorAndroid="transparent"
368
423
  value={value}
369
424
  />
@@ -394,6 +449,9 @@ export const TextField: FC<TextFieldProps> = ({
394
449
  )}
395
450
  </View>
396
451
  </View>
452
+ {Boolean(errorText) && errorPosition === "below" && (
453
+ <FieldError testID={fieldTestIDs.error} text={errorText!} />
454
+ )}
397
455
  {Boolean(helperText) && <FieldHelperText testID={fieldTestIDs.helper} text={helperText!} />}
398
456
  {/* {type === "numberRange" && value && (
399
457
  <NumberPickerActionSheet
@@ -38,6 +38,8 @@ exports[`AddressField renders correctly with default props 1`] = `
38
38
  "accessibilityState": {
39
39
  "disabled": undefined,
40
40
  },
41
+ "aria-describedby": undefined,
42
+ "aria-invalid": false,
41
43
  "aria-label": "Text input field",
42
44
  "autoCapitalize": "sentences",
43
45
  "autoCorrect": true,
@@ -64,6 +66,7 @@ exports[`AddressField renders correctly with default props 1`] = `
64
66
  "fontSize": 16,
65
67
  "gap": 10,
66
68
  "height": 24,
69
+ "letterSpacing": undefined,
67
70
  "paddingVertical": 0,
68
71
  "width": "100%",
69
72
  },
@@ -156,6 +159,8 @@ exports[`AddressField renders correctly with default props 1`] = `
156
159
  "accessibilityState": {
157
160
  "disabled": undefined,
158
161
  },
162
+ "aria-describedby": undefined,
163
+ "aria-invalid": false,
159
164
  "aria-label": "Text input field",
160
165
  "autoCapitalize": "sentences",
161
166
  "autoCorrect": true,
@@ -182,6 +187,7 @@ exports[`AddressField renders correctly with default props 1`] = `
182
187
  "fontSize": 16,
183
188
  "gap": 10,
184
189
  "height": 24,
190
+ "letterSpacing": undefined,
185
191
  "paddingVertical": 0,
186
192
  "width": "100%",
187
193
  },
@@ -274,6 +280,8 @@ exports[`AddressField renders correctly with default props 1`] = `
274
280
  "accessibilityState": {
275
281
  "disabled": undefined,
276
282
  },
283
+ "aria-describedby": undefined,
284
+ "aria-invalid": false,
277
285
  "aria-label": "Text input field",
278
286
  "autoCapitalize": "sentences",
279
287
  "autoCorrect": true,
@@ -300,6 +308,7 @@ exports[`AddressField renders correctly with default props 1`] = `
300
308
  "fontSize": 16,
301
309
  "gap": 10,
302
310
  "height": 24,
311
+ "letterSpacing": undefined,
303
312
  "paddingVertical": 0,
304
313
  "width": "100%",
305
314
  },
@@ -2594,6 +2603,8 @@ exports[`AddressField renders correctly with default props 1`] = `
2594
2603
  "accessibilityState": {
2595
2604
  "disabled": undefined,
2596
2605
  },
2606
+ "aria-describedby": undefined,
2607
+ "aria-invalid": false,
2597
2608
  "aria-label": "Text input field",
2598
2609
  "autoCapitalize": "sentences",
2599
2610
  "autoCorrect": true,
@@ -2620,6 +2631,7 @@ exports[`AddressField renders correctly with default props 1`] = `
2620
2631
  "fontSize": 16,
2621
2632
  "gap": 10,
2622
2633
  "height": 24,
2634
+ "letterSpacing": undefined,
2623
2635
  "paddingVertical": 0,
2624
2636
  "width": "100%",
2625
2637
  },
@@ -108,6 +108,8 @@ exports[`AiSuggestionBox in TextArea snapshots should match snapshot for not-sta
108
108
  "accessibilityState": {
109
109
  "disabled": undefined,
110
110
  },
111
+ "aria-describedby": undefined,
112
+ "aria-invalid": false,
111
113
  "aria-label": "Text input field",
112
114
  "autoCapitalize": "sentences",
113
115
  "autoCorrect": true,
@@ -134,6 +136,7 @@ exports[`AiSuggestionBox in TextArea snapshots should match snapshot for not-sta
134
136
  "fontSize": 16,
135
137
  "gap": 10,
136
138
  "height": 40,
139
+ "letterSpacing": undefined,
137
140
  "paddingVertical": 0,
138
141
  "width": "100%",
139
142
  },
@@ -291,6 +294,8 @@ exports[`AiSuggestionBox in TextArea snapshots should match snapshot for generat
291
294
  "accessibilityState": {
292
295
  "disabled": undefined,
293
296
  },
297
+ "aria-describedby": undefined,
298
+ "aria-invalid": false,
294
299
  "aria-label": "Text input field",
295
300
  "autoCapitalize": "sentences",
296
301
  "autoCorrect": true,
@@ -317,6 +322,7 @@ exports[`AiSuggestionBox in TextArea snapshots should match snapshot for generat
317
322
  "fontSize": 16,
318
323
  "gap": 10,
319
324
  "height": 40,
325
+ "letterSpacing": undefined,
320
326
  "paddingVertical": 0,
321
327
  "width": "100%",
322
328
  },
@@ -739,6 +745,8 @@ exports[`AiSuggestionBox in TextArea snapshots should match snapshot for ready s
739
745
  "accessibilityState": {
740
746
  "disabled": undefined,
741
747
  },
748
+ "aria-describedby": undefined,
749
+ "aria-invalid": false,
742
750
  "aria-label": "Text input field",
743
751
  "autoCapitalize": "sentences",
744
752
  "autoCorrect": true,
@@ -765,6 +773,7 @@ exports[`AiSuggestionBox in TextArea snapshots should match snapshot for ready s
765
773
  "fontSize": 16,
766
774
  "gap": 10,
767
775
  "height": 40,
776
+ "letterSpacing": undefined,
768
777
  "paddingVertical": 0,
769
778
  "width": "100%",
770
779
  },
@@ -1078,6 +1087,8 @@ exports[`AiSuggestionBox in TextArea snapshots should match snapshot for hidden
1078
1087
  "accessibilityState": {
1079
1088
  "disabled": undefined,
1080
1089
  },
1090
+ "aria-describedby": undefined,
1091
+ "aria-invalid": false,
1081
1092
  "aria-label": "Text input field",
1082
1093
  "autoCapitalize": "sentences",
1083
1094
  "autoCorrect": true,
@@ -1104,6 +1115,7 @@ exports[`AiSuggestionBox in TextArea snapshots should match snapshot for hidden
1104
1115
  "fontSize": 16,
1105
1116
  "gap": 10,
1106
1117
  "height": 40,
1118
+ "letterSpacing": undefined,
1107
1119
  "paddingVertical": 0,
1108
1120
  "width": "100%",
1109
1121
  },
@@ -1417,6 +1429,8 @@ exports[`AiSuggestionBox in TextArea snapshots should match snapshot for added s
1417
1429
  "accessibilityState": {
1418
1430
  "disabled": undefined,
1419
1431
  },
1432
+ "aria-describedby": undefined,
1433
+ "aria-invalid": false,
1420
1434
  "aria-label": "Text input field",
1421
1435
  "autoCapitalize": "sentences",
1422
1436
  "autoCorrect": true,
@@ -1443,6 +1457,7 @@ exports[`AiSuggestionBox in TextArea snapshots should match snapshot for added s
1443
1457
  "fontSize": 16,
1444
1458
  "gap": 10,
1445
1459
  "height": 40,
1460
+ "letterSpacing": undefined,
1446
1461
  "paddingVertical": 0,
1447
1462
  "width": "100%",
1448
1463
  },
@@ -31,6 +31,7 @@ exports[`Avatar renders correctly with default props 1`] = `
31
31
  ],
32
32
  "props": {
33
33
  "aria-role": "button",
34
+ "focusable": false,
34
35
  "style": {
35
36
  "borderRadius": 1,
36
37
  "cursor": "auto",
@@ -2121,6 +2121,8 @@ exports[`CustomSelectField renders with custom value (not in options) 1`] = `
2121
2121
  "accessibilityState": {
2122
2122
  "disabled": undefined,
2123
2123
  },
2124
+ "aria-describedby": undefined,
2125
+ "aria-invalid": false,
2124
2126
  "aria-label": "Text input field",
2125
2127
  "autoCapitalize": "sentences",
2126
2128
  "autoCorrect": true,
@@ -2147,6 +2149,7 @@ exports[`CustomSelectField renders with custom value (not in options) 1`] = `
2147
2149
  "fontSize": 16,
2148
2150
  "gap": 10,
2149
2151
  "height": 24,
2152
+ "letterSpacing": undefined,
2150
2153
  "paddingVertical": 0,
2151
2154
  "width": "100%",
2152
2155
  },