@terreno/ui 57.19.2 → 57.21.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.
- package/.ai/guidelines/core.md +1 -1
- package/CHANGELOG.md +443 -0
- package/dist/Accordion.d.ts.map +1 -1
- package/dist/Accordion.js +3 -3
- package/dist/Accordion.js.map +1 -1
- package/dist/Avatar.d.ts.map +1 -1
- package/dist/Avatar.js +3 -1
- package/dist/Avatar.js.map +1 -1
- package/dist/Box.d.ts.map +1 -1
- package/dist/Box.js +38 -2
- package/dist/Box.js.map +1 -1
- package/dist/Card.js +2 -2
- package/dist/Card.js.map +1 -1
- package/dist/Common.d.ts +175 -34
- package/dist/Common.d.ts.map +1 -1
- package/dist/Common.js.map +1 -1
- package/dist/ConsentFormScreen.d.ts +1 -1
- package/dist/ConsentFormScreen.d.ts.map +1 -1
- package/dist/ConsentFormScreen.js +13 -4
- package/dist/ConsentFormScreen.js.map +1 -1
- package/dist/DateTimeField.d.ts.map +1 -1
- package/dist/DateTimeField.js +11 -9
- package/dist/DateTimeField.js.map +1 -1
- package/dist/Field.d.ts.map +1 -1
- package/dist/Field.js +2 -0
- package/dist/Field.js.map +1 -1
- package/dist/FormContainer.d.ts +68 -0
- package/dist/FormContainer.d.ts.map +1 -0
- package/dist/FormContainer.js +79 -0
- package/dist/FormContainer.js.map +1 -0
- package/dist/GPTChat.d.ts.map +1 -1
- package/dist/GPTChat.js +2 -1
- package/dist/GPTChat.js.map +1 -1
- package/dist/Heading.d.ts +1 -1
- package/dist/Heading.d.ts.map +1 -1
- package/dist/Heading.js +5 -2
- package/dist/Heading.js.map +1 -1
- package/dist/HeightField.js +8 -8
- package/dist/HeightField.js.map +1 -1
- package/dist/Icon.d.ts +4 -0
- package/dist/Icon.d.ts.map +1 -1
- package/dist/Icon.js +43 -2
- package/dist/Icon.js.map +1 -1
- package/dist/LabeledCheckBox.d.ts +22 -0
- package/dist/LabeledCheckBox.d.ts.map +1 -0
- package/dist/LabeledCheckBox.js +30 -0
- package/dist/LabeledCheckBox.js.map +1 -0
- package/dist/ListDetailLayout.d.ts +36 -0
- package/dist/ListDetailLayout.d.ts.map +1 -0
- package/dist/ListDetailLayout.js +153 -0
- package/dist/ListDetailLayout.js.map +1 -0
- package/dist/MarkdownEditor.d.ts.map +1 -1
- package/dist/MarkdownEditor.js +2 -1
- package/dist/MarkdownEditor.js.map +1 -1
- package/dist/MediaQuery.d.ts +1 -1
- package/dist/MediaQuery.d.ts.map +1 -1
- package/dist/MediaQuery.js +1 -1
- package/dist/MediaQuery.js.map +1 -1
- package/dist/OtpField.d.ts +60 -0
- package/dist/OtpField.d.ts.map +1 -0
- package/dist/OtpField.js +154 -0
- package/dist/OtpField.js.map +1 -0
- package/dist/PickerSelect.js +9 -9
- package/dist/PickerSelect.js.map +1 -1
- package/dist/ProvisionalConsentSigner.d.ts +21 -0
- package/dist/ProvisionalConsentSigner.d.ts.map +1 -0
- package/dist/ProvisionalConsentSigner.js +199 -0
- package/dist/ProvisionalConsentSigner.js.map +1 -0
- package/dist/ResponsiveBreakpoint.d.ts +5 -0
- package/dist/ResponsiveBreakpoint.d.ts.map +1 -1
- package/dist/ResponsiveBreakpoint.js +7 -0
- package/dist/ResponsiveBreakpoint.js.map +1 -1
- package/dist/SocialLoginButton.d.ts +10 -0
- package/dist/SocialLoginButton.d.ts.map +1 -1
- package/dist/SocialLoginButton.js +26 -8
- package/dist/SocialLoginButton.js.map +1 -1
- package/dist/SplitPage.d.ts +11 -0
- package/dist/SplitPage.d.ts.map +1 -1
- package/dist/SplitPage.js +11 -5
- package/dist/SplitPage.js.map +1 -1
- package/dist/SplitPage.native.d.ts.map +1 -1
- package/dist/SplitPage.native.js +3 -1
- package/dist/SplitPage.native.js.map +1 -1
- package/dist/SyncStatusBanner.d.ts +7 -1
- package/dist/SyncStatusBanner.d.ts.map +1 -1
- package/dist/SyncStatusBanner.js +20 -4
- package/dist/SyncStatusBanner.js.map +1 -1
- package/dist/TapToEdit.d.ts +1 -1
- package/dist/TapToEdit.d.ts.map +1 -1
- package/dist/TapToEdit.js.map +1 -1
- package/dist/TextField.d.ts.map +1 -1
- package/dist/TextField.js +48 -14
- package/dist/TextField.js.map +1 -1
- package/dist/Theme.d.ts.map +1 -1
- package/dist/Theme.js +16 -0
- package/dist/Theme.js.map +1 -1
- package/dist/fieldElements/FieldError.d.ts.map +1 -1
- package/dist/fieldElements/FieldError.js +1 -1
- package/dist/fieldElements/FieldError.js.map +1 -1
- package/dist/index.d.ts +19 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -1
- package/dist/index.js.map +1 -1
- package/dist/lazyBoundaries/heavyOptionalExports.d.ts +3 -0
- package/dist/lazyBoundaries/heavyOptionalExports.d.ts.map +1 -1
- package/dist/lazyBoundaries/heavyOptionalExports.js +2 -0
- package/dist/lazyBoundaries/heavyOptionalExports.js.map +1 -1
- package/dist/login/LastUsedBadge.d.ts +14 -0
- package/dist/login/LastUsedBadge.d.ts.map +1 -0
- package/dist/login/LastUsedBadge.js +23 -0
- package/dist/login/LastUsedBadge.js.map +1 -0
- package/dist/login/LoginAccountCard.d.ts +38 -0
- package/dist/login/LoginAccountCard.d.ts.map +1 -0
- package/dist/login/LoginAccountCard.js +72 -0
- package/dist/login/LoginAccountCard.js.map +1 -0
- package/dist/login/LoginAccountList.d.ts +33 -0
- package/dist/login/LoginAccountList.d.ts.map +1 -0
- package/dist/login/LoginAccountList.js +30 -0
- package/dist/login/LoginAccountList.js.map +1 -0
- package/dist/login/LoginScreen.d.ts +4 -4
- package/dist/login/LoginScreen.d.ts.map +1 -1
- package/dist/login/LoginScreen.js +294 -13
- package/dist/login/LoginScreen.js.map +1 -1
- package/dist/login/OutlinePill.d.ts +28 -0
- package/dist/login/OutlinePill.d.ts.map +1 -0
- package/dist/login/OutlinePill.js +48 -0
- package/dist/login/OutlinePill.js.map +1 -0
- package/dist/login/TwoFactorChallengeScreen.d.ts +26 -0
- package/dist/login/TwoFactorChallengeScreen.d.ts.map +1 -0
- package/dist/login/TwoFactorChallengeScreen.js +139 -0
- package/dist/login/TwoFactorChallengeScreen.js.map +1 -0
- package/dist/login/loginMethods.d.ts +27 -0
- package/dist/login/loginMethods.d.ts.map +1 -0
- package/dist/login/loginMethods.js +37 -0
- package/dist/login/loginMethods.js.map +1 -0
- package/dist/login/loginTypes.d.ts +202 -5
- package/dist/login/loginTypes.d.ts.map +1 -1
- package/dist/pdfHtmlTemplate.d.ts +17 -0
- package/dist/pdfHtmlTemplate.d.ts.map +1 -1
- package/dist/pdfHtmlTemplate.js +78 -0
- package/dist/pdfHtmlTemplate.js.map +1 -1
- package/dist/security/AccountSecurityScreen.d.ts +10 -0
- package/dist/security/AccountSecurityScreen.d.ts.map +1 -0
- package/dist/security/AccountSecurityScreen.js +50 -0
- package/dist/security/AccountSecurityScreen.js.map +1 -0
- package/dist/security/LinkedAccountsCard.d.ts +32 -0
- package/dist/security/LinkedAccountsCard.d.ts.map +1 -0
- package/dist/security/LinkedAccountsCard.js +145 -0
- package/dist/security/LinkedAccountsCard.js.map +1 -0
- package/dist/security/PasskeysCard.d.ts +39 -0
- package/dist/security/PasskeysCard.d.ts.map +1 -0
- package/dist/security/PasskeysCard.js +168 -0
- package/dist/security/PasskeysCard.js.map +1 -0
- package/dist/security/PasswordCard.d.ts +32 -0
- package/dist/security/PasswordCard.d.ts.map +1 -0
- package/dist/security/PasswordCard.js +198 -0
- package/dist/security/PasswordCard.js.map +1 -0
- package/dist/security/SessionsCard.d.ts +39 -0
- package/dist/security/SessionsCard.d.ts.map +1 -0
- package/dist/security/SessionsCard.js +168 -0
- package/dist/security/SessionsCard.js.map +1 -0
- package/dist/security/TwoFactorSettingsCard.d.ts +55 -0
- package/dist/security/TwoFactorSettingsCard.d.ts.map +1 -0
- package/dist/security/TwoFactorSettingsCard.js +458 -0
- package/dist/security/TwoFactorSettingsCard.js.map +1 -0
- package/dist/security/securityMethods.d.ts +40 -0
- package/dist/security/securityMethods.d.ts.map +1 -0
- package/dist/security/securityMethods.js +66 -0
- package/dist/security/securityMethods.js.map +1 -0
- package/dist/security/securityTypes.d.ts +467 -0
- package/dist/security/securityTypes.d.ts.map +1 -0
- package/dist/security/securityTypes.js +2 -0
- package/dist/security/securityTypes.js.map +1 -0
- package/dist/security/userAgent.d.ts +26 -0
- package/dist/security/userAgent.d.ts.map +1 -0
- package/dist/security/userAgent.js +80 -0
- package/dist/security/userAgent.js.map +1 -0
- package/dist/signUp/OAuthButtons.d.ts +28 -5
- package/dist/signUp/OAuthButtons.d.ts.map +1 -1
- package/dist/signUp/OAuthButtons.js +44 -5
- package/dist/signUp/OAuthButtons.js.map +1 -1
- package/dist/signUp/SignUpScreen.d.ts.map +1 -1
- package/dist/signUp/SignUpScreen.js +50 -5
- package/dist/signUp/SignUpScreen.js.map +1 -1
- package/dist/signUp/signUpTypes.d.ts +21 -1
- package/dist/signUp/signUpTypes.d.ts.map +1 -1
- package/dist/useConsentForms.d.ts +9 -0
- package/dist/useConsentForms.d.ts.map +1 -1
- package/dist/useConsentForms.js +18 -0
- package/dist/useConsentForms.js.map +1 -1
- package/dist/useProvisionalConsent.d.ts +124 -0
- package/dist/useProvisionalConsent.d.ts.map +1 -0
- package/dist/useProvisionalConsent.js +79 -0
- package/dist/useProvisionalConsent.js.map +1 -0
- package/package.json +5 -2
- package/src/Accordion.test.tsx +5 -0
- package/src/Accordion.tsx +3 -8
- package/src/ActionSheet.test.tsx +13 -13
- package/src/AddressField.test.tsx +9 -3
- package/src/AnnouncementNavigator.test.tsx +4 -4
- package/src/AreaChart.test.tsx +15 -0
- package/src/Avatar.test.tsx +8 -0
- package/src/Avatar.tsx +2 -0
- package/src/Badge.test.tsx +1 -1
- package/src/Banner.test.tsx +0 -1
- package/src/BarChart.test.tsx +15 -0
- package/src/Box.test.tsx +143 -75
- package/src/Box.tsx +44 -2
- package/src/Button.test.tsx +11 -6
- package/src/Card.test.tsx +2 -2
- package/src/Card.tsx +2 -2
- package/src/Common.ts +194 -36
- package/src/ConflictSheet.test.tsx +5 -5
- package/src/ConsentFormScreen.test.tsx +87 -1
- package/src/ConsentFormScreen.tsx +28 -4
- package/src/ConsentNavigator.test.tsx +1 -2
- package/src/CustomSelectField.test.tsx +16 -4
- package/src/DataTable.test.tsx +4 -4
- package/src/DataTableVirtualizationRegression.test.tsx +1 -0
- package/src/DateTimeActionSheet.test.tsx +2 -0
- package/src/DateTimeField.test.tsx +3 -12
- package/src/DateTimeField.tsx +11 -9
- package/src/DismissButton.test.tsx +22 -4
- package/src/DonutChart.test.tsx +15 -0
- package/src/EmailField.test.tsx +13 -22
- package/src/EmojiSelector.test.tsx +2 -2
- package/src/ErrorBoundary.test.tsx +5 -3
- package/src/Field.test.tsx +20 -44
- package/src/Field.tsx +2 -0
- package/src/FilePickerButton.test.tsx +35 -0
- package/src/FormContainer.test.tsx +242 -0
- package/src/FormContainer.tsx +177 -0
- package/src/GPTChat.test.tsx +40 -16
- package/src/GPTChat.tsx +8 -2
- package/src/Heading.test.tsx +15 -1
- package/src/Heading.tsx +6 -1
- package/src/HeightField.tsx +8 -8
- package/src/Icon.test.tsx +54 -3
- package/src/Icon.tsx +92 -3
- package/src/IconButton.test.tsx +85 -0
- package/src/Image.test.tsx +1 -1
- package/src/LabeledCheckBox.test.tsx +45 -0
- package/src/LabeledCheckBox.tsx +89 -0
- package/src/Link.test.tsx +11 -4
- package/src/ListDetailLayout.tsx +247 -0
- package/src/MarkdownEditor.tsx +2 -1
- package/src/MarkdownView.test.tsx +1 -1
- package/src/MediaQuery.ts +1 -0
- package/src/MobileAddressAutoComplete.test.tsx +2 -1
- package/src/Modal.test.tsx +7 -2
- package/src/ModalSheet.test.tsx +5 -4
- package/src/MultiselectField.test.tsx +17 -3
- package/src/NumberField.test.tsx +14 -14
- package/src/NumberPickerActionSheet.test.tsx +1 -1
- package/src/OpenAPIContext.test.tsx +4 -4
- package/src/OpenAPIRenderRegression.test.tsx +1 -1
- package/src/OtpField.test.tsx +280 -0
- package/src/OtpField.tsx +307 -0
- package/src/P0RenderRegression.test.tsx +7 -1
- package/src/P1RenderRegression.test.tsx +1 -0
- package/src/P2ButtonRenderRegression.test.tsx +1 -0
- package/src/Page.test.tsx +1 -1
- package/src/PhoneNumberField.test.tsx +14 -38
- package/src/PickerSelect.tsx +9 -9
- package/src/Popover.test.tsx +2 -2
- package/src/ProvisionalConsentSigner.test.tsx +625 -0
- package/src/ProvisionalConsentSigner.tsx +423 -0
- package/src/RadioField.test.tsx +7 -2
- package/src/ResponsiveBreakpoint.test.tsx +7 -0
- package/src/ResponsiveBreakpoint.tsx +14 -0
- package/src/RootImportRegression.test.tsx +3 -0
- package/src/SegmentedControl.test.tsx +21 -12
- package/src/SidebarNavigation.test.tsx +18 -6
- package/src/Signature.test.tsx +20 -23
- package/src/Slider.test.tsx +1 -1
- package/src/SocialLoginButton.test.tsx +14 -0
- package/src/SocialLoginButton.tsx +51 -7
- package/src/SplitPage.native.tsx +3 -1
- package/src/SplitPage.test.tsx +15 -5
- package/src/SplitPage.tsx +11 -5
- package/src/SyncStatusBanner.test.tsx +61 -4
- package/src/SyncStatusBanner.tsx +29 -3
- package/src/TapToEdit.test.tsx +38 -15
- package/src/TapToEdit.tsx +1 -1
- package/src/TerrenoFontProvider.test.tsx +1 -1
- package/src/Text.test.tsx +4 -4
- package/src/TextField.test.tsx +232 -9
- package/src/TextField.tsx +70 -12
- package/src/Theme.test.tsx +49 -0
- package/src/Theme.tsx +16 -0
- package/src/Toast.test.tsx +5 -5
- package/src/ToastNotifications.test.tsx +73 -70
- package/src/ToastNotifications.webModal.test.tsx +2 -2
- package/src/Tooltip.test.tsx +3 -3
- package/src/UnifiedAddressAutoComplete.test.tsx +1 -1
- package/src/UserInactivity.test.tsx +4 -2
- package/src/WebAddressAutocomplete.test.tsx +12 -12
- package/src/WebDropdownMenu.test.tsx +16 -15
- package/src/__snapshots__/AddressField.test.tsx.snap +12 -0
- package/src/__snapshots__/AiSuggestionBox.test.tsx.snap +15 -0
- package/src/__snapshots__/Avatar.test.tsx.snap +1 -0
- package/src/__snapshots__/Card.test.tsx.snap +1 -1
- package/src/__snapshots__/CustomSelectField.test.tsx.snap +3 -0
- package/src/__snapshots__/DismissButton.test.tsx.snap +3 -3
- package/src/__snapshots__/EmailField.test.tsx.snap +6 -0
- package/src/__snapshots__/Field.test.tsx.snap +41 -2
- package/src/__snapshots__/Heading.test.tsx.snap +1 -1
- package/src/__snapshots__/HeightField.test.tsx.snap +2 -0
- package/src/__snapshots__/Image.test.tsx.snap +1 -1
- package/src/__snapshots__/MobileAddressAutoComplete.test.tsx.snap +3 -0
- package/src/__snapshots__/NumberField.test.tsx.snap +3 -0
- package/src/__snapshots__/Page.test.tsx.snap +2 -2
- package/src/__snapshots__/PhoneNumberField.test.tsx.snap +12 -0
- package/src/__snapshots__/Slider.test.tsx.snap +1 -0
- package/src/__snapshots__/SocialLoginButton.test.tsx.snap +43 -22
- package/src/__snapshots__/TapToEdit.test.tsx.snap +3 -0
- package/src/__snapshots__/Text.test.tsx.snap +1 -1
- package/src/__snapshots__/TextArea.test.tsx.snap +17 -1
- package/src/__snapshots__/TextField.test.tsx.snap +19 -2
- package/src/__snapshots__/TypedSignatureField.test.tsx.snap +3 -0
- package/src/__snapshots__/UnifiedAddressAutoComplete.test.tsx.snap +18 -0
- package/src/__snapshots__/WebAddressAutocomplete.test.tsx.snap +12 -0
- package/src/asks/AskCard.test.tsx +16 -13
- package/src/asks/AskFiles.test.tsx +5 -1
- package/src/asks/askFileRefs.test.ts +1 -1
- package/src/asks/askSummary.test.ts +2 -2
- package/src/benchmarks/importTiming.ts +1 -1
- package/src/blocks/BlocksView.test.tsx +20 -11
- package/src/bunSetup.ts +14 -2
- package/src/dataTableFilters.test.tsx +1 -1
- package/src/fieldElements/FieldError.tsx +1 -0
- package/src/fieldElements/__snapshots__/FieldError.test.tsx.snap +2 -0
- package/src/index.tsx +42 -1
- package/src/isolated/ListDetailLayout.isolated.tsx +632 -0
- package/src/lazyBoundaries/heavyOptionalExports.tsx +7 -0
- package/src/login/LastUsedBadge.tsx +40 -0
- package/src/login/LoginAccountCard.tsx +205 -0
- package/src/login/LoginAccountList.tsx +115 -0
- package/src/login/LoginScreen.test.tsx +839 -3
- package/src/login/LoginScreen.tsx +674 -91
- package/src/login/OutlinePill.tsx +110 -0
- package/src/login/TwoFactorChallengeScreen.test.tsx +376 -0
- package/src/login/TwoFactorChallengeScreen.tsx +307 -0
- package/src/login/__snapshots__/LoginScreen.test.tsx.snap +1454 -334
- package/src/login/loginMethods.test.ts +53 -0
- package/src/login/loginMethods.ts +60 -0
- package/src/login/loginTypes.ts +208 -5
- package/src/pdfHtmlTemplate.test.ts +243 -4
- package/src/pdfHtmlTemplate.ts +93 -0
- package/src/security/AccountSecurityScreen.test.tsx +262 -0
- package/src/security/AccountSecurityScreen.tsx +156 -0
- package/src/security/LinkedAccountsCard.test.tsx +371 -0
- package/src/security/LinkedAccountsCard.tsx +297 -0
- package/src/security/PasskeysCard.test.tsx +378 -0
- package/src/security/PasskeysCard.tsx +371 -0
- package/src/security/PasswordCard.test.tsx +445 -0
- package/src/security/PasswordCard.tsx +342 -0
- package/src/security/SessionsCard.test.tsx +349 -0
- package/src/security/SessionsCard.tsx +362 -0
- package/src/security/TwoFactorSettingsCard.test.tsx +700 -0
- package/src/security/TwoFactorSettingsCard.tsx +872 -0
- package/src/security/securityMethods.test.ts +101 -0
- package/src/security/securityMethods.ts +104 -0
- package/src/security/securityTypes.ts +480 -0
- package/src/security/userAgent.test.ts +119 -0
- package/src/security/userAgent.ts +102 -0
- package/src/signUp/OAuthButtons.test.tsx +27 -0
- package/src/signUp/OAuthButtons.tsx +153 -19
- package/src/signUp/SignUpScreen.test.tsx +171 -2
- package/src/signUp/SignUpScreen.tsx +87 -25
- package/src/signUp/__snapshots__/SignUpScreen.test.tsx.snap +22 -11
- package/src/signUp/signUpTypes.ts +23 -1
- package/src/table/tableContext.test.tsx +5 -5
- package/src/test-utils.tsx +56 -1
- package/src/testing/reactDomServer.d.ts +7 -0
- package/src/useConsentForms.test.ts +38 -2
- package/src/useConsentForms.ts +25 -0
- package/src/useProvisionalConsent.test.ts +256 -0
- package/src/useProvisionalConsent.ts +218 -0
package/src/TapToEdit.test.tsx
CHANGED
|
@@ -8,14 +8,14 @@ import {renderWithTheme} from "./test-utils";
|
|
|
8
8
|
describe("TapToEdit", () => {
|
|
9
9
|
it("renders correctly with text value", () => {
|
|
10
10
|
const {toJSON} = renderWithTheme(
|
|
11
|
-
<TapToEdit setValue={() => {}} title="Name" value="John Doe" />
|
|
11
|
+
<TapToEdit setValue={() => {}} title="Name" type="text" value="John Doe" />
|
|
12
12
|
);
|
|
13
13
|
expect(toJSON()).toMatchSnapshot();
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
it("displays title and value", () => {
|
|
17
17
|
const {getByText} = renderWithTheme(
|
|
18
|
-
<TapToEdit setValue={() => {}} title="Email" value="test@example.com" />
|
|
18
|
+
<TapToEdit setValue={() => {}} title="Email" type="text" value="test@example.com" />
|
|
19
19
|
);
|
|
20
20
|
expect(getByText("Email")).toBeTruthy();
|
|
21
21
|
expect(getByText("test@example.com")).toBeTruthy();
|
|
@@ -23,21 +23,27 @@ describe("TapToEdit", () => {
|
|
|
23
23
|
|
|
24
24
|
it("renders non-editable when editable is false", () => {
|
|
25
25
|
const {toJSON} = renderWithTheme(
|
|
26
|
-
<TapToEdit editable={false} title="Read Only" value="Cannot edit this" />
|
|
26
|
+
<TapToEdit editable={false} title="Read Only" type="text" value="Cannot edit this" />
|
|
27
27
|
);
|
|
28
28
|
expect(toJSON()).toMatchSnapshot();
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
it("renders edit icon when editable", () => {
|
|
32
32
|
const {toJSON} = renderWithTheme(
|
|
33
|
-
<TapToEdit
|
|
33
|
+
<TapToEdit
|
|
34
|
+
editable
|
|
35
|
+
setValue={() => {}}
|
|
36
|
+
title="Editable Field"
|
|
37
|
+
type="text"
|
|
38
|
+
value="Click to edit"
|
|
39
|
+
/>
|
|
34
40
|
);
|
|
35
41
|
expect(toJSON()).toMatchSnapshot();
|
|
36
42
|
});
|
|
37
43
|
|
|
38
44
|
it("shows editing mode when isEditing is true", () => {
|
|
39
45
|
const {toJSON} = renderWithTheme(
|
|
40
|
-
<TapToEdit isEditing setValue={() => {}} title="Field" value="Editing..." />
|
|
46
|
+
<TapToEdit isEditing setValue={() => {}} title="Field" type="text" value="Editing..." />
|
|
41
47
|
);
|
|
42
48
|
expect(toJSON()).toMatchSnapshot();
|
|
43
49
|
});
|
|
@@ -49,6 +55,7 @@ describe("TapToEdit", () => {
|
|
|
49
55
|
onlyShowHelperTextWhileEditing={false}
|
|
50
56
|
setValue={() => {}}
|
|
51
57
|
title="Name"
|
|
58
|
+
type="text"
|
|
52
59
|
value=""
|
|
53
60
|
/>
|
|
54
61
|
);
|
|
@@ -75,6 +82,7 @@ describe("TapToEdit", () => {
|
|
|
75
82
|
editable={false}
|
|
76
83
|
title="Custom"
|
|
77
84
|
transform={(val) => `Transformed: ${val}`}
|
|
85
|
+
type="text"
|
|
78
86
|
value="data"
|
|
79
87
|
/>
|
|
80
88
|
);
|
|
@@ -95,7 +103,13 @@ describe("TapToEdit", () => {
|
|
|
95
103
|
|
|
96
104
|
it("renders multiselect type as comma-joined string", () => {
|
|
97
105
|
const {getByText} = renderWithTheme(
|
|
98
|
-
<TapToEdit
|
|
106
|
+
<TapToEdit
|
|
107
|
+
editable={false}
|
|
108
|
+
options={[]}
|
|
109
|
+
title="Tags"
|
|
110
|
+
type="multiselect"
|
|
111
|
+
value={["a", "b", "c"]}
|
|
112
|
+
/>
|
|
99
113
|
);
|
|
100
114
|
expect(getByText("a, b, c")).toBeTruthy();
|
|
101
115
|
});
|
|
@@ -177,14 +191,14 @@ describe("TapToEdit", () => {
|
|
|
177
191
|
|
|
178
192
|
it("throws when editable is true and setValue is not provided", () => {
|
|
179
193
|
expect(() =>
|
|
180
|
-
renderWithTheme(<TapToEdit editable title="Required Save" value="foo" />)
|
|
194
|
+
renderWithTheme(<TapToEdit editable title="Required Save" type="text" value="foo" />)
|
|
181
195
|
).toThrow();
|
|
182
196
|
});
|
|
183
197
|
|
|
184
198
|
it("enters editing mode when Edit button is pressed", async () => {
|
|
185
199
|
const setValue = mock(() => {});
|
|
186
200
|
const {getByLabelText, queryByText} = renderWithTheme(
|
|
187
|
-
<TapToEdit setValue={setValue} title="Name" value="Jane" />
|
|
201
|
+
<TapToEdit setValue={setValue} title="Name" type="text" value="Jane" />
|
|
188
202
|
);
|
|
189
203
|
await act(async () => {
|
|
190
204
|
fireEvent.press(getByLabelText("Edit"));
|
|
@@ -196,7 +210,7 @@ describe("TapToEdit", () => {
|
|
|
196
210
|
it("calls setValue with initial value and exits editing on Cancel", async () => {
|
|
197
211
|
const setValue = mock(() => {});
|
|
198
212
|
const {getByLabelText, getByText} = renderWithTheme(
|
|
199
|
-
<TapToEdit setValue={setValue} title="Name" value="Jane" />
|
|
213
|
+
<TapToEdit setValue={setValue} title="Name" type="text" value="Jane" />
|
|
200
214
|
);
|
|
201
215
|
await act(async () => {
|
|
202
216
|
fireEvent.press(getByLabelText("Edit"));
|
|
@@ -210,7 +224,7 @@ describe("TapToEdit", () => {
|
|
|
210
224
|
it("reverts to original value (not edited value) when Cancel is pressed", async () => {
|
|
211
225
|
const setValue = mock((_v: unknown) => {});
|
|
212
226
|
const {getByLabelText, getByText} = renderWithTheme(
|
|
213
|
-
<TapToEdit setValue={setValue} title="Name" value="Jane" />
|
|
227
|
+
<TapToEdit setValue={setValue} title="Name" type="text" value="Jane" />
|
|
214
228
|
);
|
|
215
229
|
await act(async () => {
|
|
216
230
|
fireEvent.press(getByLabelText("Edit"));
|
|
@@ -227,7 +241,14 @@ describe("TapToEdit", () => {
|
|
|
227
241
|
const setValue = mock(() => {});
|
|
228
242
|
const onSave = mock(() => Promise.resolve());
|
|
229
243
|
const {getByLabelText, getByText} = renderWithTheme(
|
|
230
|
-
<TapToEdit
|
|
244
|
+
<TapToEdit
|
|
245
|
+
onSave={onSave}
|
|
246
|
+
setValue={setValue}
|
|
247
|
+
showClearButton
|
|
248
|
+
title="Name"
|
|
249
|
+
type="text"
|
|
250
|
+
value="Jane"
|
|
251
|
+
/>
|
|
231
252
|
);
|
|
232
253
|
await act(async () => {
|
|
233
254
|
fireEvent.press(getByLabelText("Edit"));
|
|
@@ -243,7 +264,7 @@ describe("TapToEdit", () => {
|
|
|
243
264
|
const setValue = mock(() => {});
|
|
244
265
|
const onSave = mock(() => Promise.resolve());
|
|
245
266
|
const {getByLabelText, getByText} = renderWithTheme(
|
|
246
|
-
<TapToEdit onSave={onSave} setValue={setValue} title="Name" value="Jane" />
|
|
267
|
+
<TapToEdit onSave={onSave} setValue={setValue} title="Name" type="text" value="Jane" />
|
|
247
268
|
);
|
|
248
269
|
await act(async () => {
|
|
249
270
|
fireEvent.press(getByLabelText("Edit"));
|
|
@@ -261,7 +282,7 @@ describe("TapToEdit", () => {
|
|
|
261
282
|
console.error = errorMock;
|
|
262
283
|
|
|
263
284
|
const {getByLabelText, getByText} = renderWithTheme(
|
|
264
|
-
<TapToEdit setValue={setValue} title="Name" value="Jane" />
|
|
285
|
+
<TapToEdit setValue={setValue} title="Name" type="text" value="Jane" />
|
|
265
286
|
);
|
|
266
287
|
await act(async () => {
|
|
267
288
|
fireEvent.press(getByLabelText("Edit"));
|
|
@@ -389,6 +410,7 @@ describe("TapToEdit - additional function coverage", () => {
|
|
|
389
410
|
editable={false}
|
|
390
411
|
helperText="Should be hidden in title"
|
|
391
412
|
title="Field"
|
|
413
|
+
type="text"
|
|
392
414
|
value="val"
|
|
393
415
|
/>
|
|
394
416
|
);
|
|
@@ -406,7 +428,7 @@ describe("TapToEdit - additional function coverage", () => {
|
|
|
406
428
|
|
|
407
429
|
it("forwards testID to the edit control", () => {
|
|
408
430
|
const {getByTestId} = renderWithTheme(
|
|
409
|
-
<TapToEdit setValue={() => {}} testID="profile.name" title="Name" value="Jane" />
|
|
431
|
+
<TapToEdit setValue={() => {}} testID="profile.name" title="Name" type="text" value="Jane" />
|
|
410
432
|
);
|
|
411
433
|
expect(getByTestId("profile.name.edit-clickable")).toBeTruthy();
|
|
412
434
|
});
|
|
@@ -419,6 +441,7 @@ describe("TapToEdit - additional function coverage", () => {
|
|
|
419
441
|
showClearButton
|
|
420
442
|
testID="profile.name"
|
|
421
443
|
title="Name"
|
|
444
|
+
type="text"
|
|
422
445
|
value="Jane"
|
|
423
446
|
/>
|
|
424
447
|
);
|
|
@@ -435,7 +458,7 @@ describe("TapToEdit - additional function coverage", () => {
|
|
|
435
458
|
|
|
436
459
|
it("does not set action testIDs when testID is omitted", async () => {
|
|
437
460
|
const {getByLabelText, queryByTestId} = renderWithTheme(
|
|
438
|
-
<TapToEdit setValue={() => {}} showClearButton title="Name" value="Jane" />
|
|
461
|
+
<TapToEdit setValue={() => {}} showClearButton title="Name" type="text" value="Jane" />
|
|
439
462
|
);
|
|
440
463
|
|
|
441
464
|
expect(queryByTestId("undefined.edit-clickable")).toBeNull();
|
package/src/TapToEdit.tsx
CHANGED
|
@@ -27,7 +27,7 @@ const TapToEditTitle: FC<{
|
|
|
27
27
|
);
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
export const formatAddress = (address: AddressInterface
|
|
30
|
+
export const formatAddress = (address: Partial<AddressInterface>, asString = false): string => {
|
|
31
31
|
let city = "";
|
|
32
32
|
if (address?.city) {
|
|
33
33
|
city = address?.state || address.zipcode ? `${address.city}, ` : `${address.city}`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import {describe, it, type mock} from "bun:test";
|
|
2
2
|
import {useFonts as useTextFonts} from "@expo-google-fonts/nunito";
|
|
3
3
|
import {useFonts as useHeadingFonts} from "@expo-google-fonts/titillium-web";
|
|
4
4
|
import {render} from "@testing-library/react-native";
|
package/src/Text.test.tsx
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {describe, expect, it, spyOn} from "bun:test";
|
|
2
2
|
import {render} from "@testing-library/react-native";
|
|
3
3
|
import {createRef} from "react";
|
|
4
|
-
import type {Text as NativeText} from "react-native";
|
|
4
|
+
import type {Text as NativeText, TextProps} from "react-native";
|
|
5
5
|
|
|
6
6
|
import {Text} from "./Text";
|
|
7
7
|
import {ThemeProvider} from "./Theme";
|
|
8
|
-
import {renderWithTheme} from "./test-utils";
|
|
8
|
+
import {elementProps, renderWithTheme} from "./test-utils";
|
|
9
9
|
|
|
10
10
|
describe("Text", () => {
|
|
11
11
|
it("renders correctly with default props", () => {
|
|
@@ -116,7 +116,7 @@ describe("Text", () => {
|
|
|
116
116
|
|
|
117
117
|
// Color tests
|
|
118
118
|
it("renders with secondary color", () => {
|
|
119
|
-
const {toJSON} = renderWithTheme(<Text color="
|
|
119
|
+
const {toJSON} = renderWithTheme(<Text color="secondaryDark">Secondary color</Text>);
|
|
120
120
|
expect(toJSON()).toMatchSnapshot();
|
|
121
121
|
});
|
|
122
122
|
|
|
@@ -177,7 +177,7 @@ describe("Text", () => {
|
|
|
177
177
|
</Text>,
|
|
178
178
|
{
|
|
179
179
|
createNodeMock: (element) =>
|
|
180
|
-
element.
|
|
180
|
+
elementProps<TextProps>(element).accessibilityRole === "header" ? nativeText : null,
|
|
181
181
|
wrapper: ThemeProvider,
|
|
182
182
|
}
|
|
183
183
|
);
|
package/src/TextField.test.tsx
CHANGED
|
@@ -3,7 +3,9 @@ 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";
|
|
8
|
+
import {defaultThemePrimitives, useTheme} from "./Theme";
|
|
7
9
|
import {renderWithTheme} from "./test-utils";
|
|
8
10
|
|
|
9
11
|
describe("TextField", () => {
|
|
@@ -398,21 +400,25 @@ describe("TextField", () => {
|
|
|
398
400
|
const originalRequestAnimationFrame = globalThis.requestAnimationFrame;
|
|
399
401
|
const originalSetTimeout = globalThis.setTimeout;
|
|
400
402
|
let scheduledRefocus: (() => void) | undefined;
|
|
401
|
-
const setTimeoutSpy = spyOn(globalThis, "setTimeout").mockImplementation(
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
403
|
+
const setTimeoutSpy = spyOn(globalThis, "setTimeout").mockImplementation(((
|
|
404
|
+
handler: () => void,
|
|
405
|
+
timeout?: number,
|
|
406
|
+
...args: unknown[]
|
|
407
|
+
) => {
|
|
408
|
+
scheduledRefocus = handler;
|
|
409
|
+
return originalSetTimeout(() => {}, timeout, ...args);
|
|
410
|
+
}) as unknown as typeof setTimeout);
|
|
407
411
|
reactNative.Platform.OS = "web";
|
|
408
|
-
|
|
412
|
+
(
|
|
413
|
+
globalThis as {requestAnimationFrame?: typeof requestAnimationFrame}
|
|
414
|
+
).requestAnimationFrame = undefined;
|
|
409
415
|
|
|
410
416
|
try {
|
|
411
417
|
const {getByDisplayValue, getByTestId} = renderWithTheme(
|
|
412
418
|
<TextField onChange={mockOnChange} testID="pw" type="password" value="hunter2" />
|
|
413
419
|
);
|
|
414
420
|
const input = getByDisplayValue("hunter2");
|
|
415
|
-
const webInput = {focus: () =>
|
|
421
|
+
const webInput = {focus: (): void => {}};
|
|
416
422
|
const ref = (input.props as unknown as {ref?: (value: TextInput | null) => void}).ref;
|
|
417
423
|
assert.isFunction(ref);
|
|
418
424
|
const focusSpy = mock(() => {});
|
|
@@ -579,6 +585,14 @@ describe("TextField", () => {
|
|
|
579
585
|
expect(input.props["aria-label"]).toBe("Text input field");
|
|
580
586
|
});
|
|
581
587
|
|
|
588
|
+
it("uses accessibilityLabel as the input's accessible name", () => {
|
|
589
|
+
const {getByDisplayValue} = renderWithTheme(
|
|
590
|
+
<TextField accessibilityLabel="Backup code" onChange={mockOnChange} value="" />
|
|
591
|
+
);
|
|
592
|
+
|
|
593
|
+
expect(getByDisplayValue("").props["aria-label"]).toBe("Backup code");
|
|
594
|
+
});
|
|
595
|
+
|
|
582
596
|
it("should indicate disabled state in accessibility", () => {
|
|
583
597
|
const {getByDisplayValue} = renderWithTheme(
|
|
584
598
|
<TextField disabled onChange={mockOnChange} value="" />
|
|
@@ -761,8 +775,10 @@ describe("TextField", () => {
|
|
|
761
775
|
|
|
762
776
|
it("warns for not-yet-supported field types", () => {
|
|
763
777
|
const warnSpy = spyOn(console, "warn").mockImplementation(() => {});
|
|
778
|
+
// TextFieldProps excludes numberRange; untyped callers can still pass it.
|
|
779
|
+
const unsupportedType = "numberRange" as unknown as TextFieldProps["type"];
|
|
764
780
|
try {
|
|
765
|
-
renderWithTheme(<TextField onChange={mockOnChange} type=
|
|
781
|
+
renderWithTheme(<TextField onChange={mockOnChange} type={unsupportedType} value="" />);
|
|
766
782
|
expect(warnSpy).toHaveBeenCalledWith("numberRange is not yet supported");
|
|
767
783
|
} finally {
|
|
768
784
|
warnSpy.mockRestore();
|
|
@@ -1017,4 +1033,211 @@ describe("TextField", () => {
|
|
|
1017
1033
|
}
|
|
1018
1034
|
});
|
|
1019
1035
|
});
|
|
1036
|
+
|
|
1037
|
+
describe("autoComplete", () => {
|
|
1038
|
+
const setOS = (os: string): string => {
|
|
1039
|
+
const reactNative = require("react-native") as {Platform: {OS: string}};
|
|
1040
|
+
const originalOS = reactNative.Platform.OS;
|
|
1041
|
+
reactNative.Platform.OS = os;
|
|
1042
|
+
return originalOS;
|
|
1043
|
+
};
|
|
1044
|
+
|
|
1045
|
+
it("sets autoComplete on the input on web", () => {
|
|
1046
|
+
const originalOS = setOS("web");
|
|
1047
|
+
try {
|
|
1048
|
+
const {getByTestId} = renderWithTheme(
|
|
1049
|
+
<>
|
|
1050
|
+
<TextField
|
|
1051
|
+
autoComplete="current-password"
|
|
1052
|
+
onChange={() => {}}
|
|
1053
|
+
testID="password"
|
|
1054
|
+
type="password"
|
|
1055
|
+
value=""
|
|
1056
|
+
/>
|
|
1057
|
+
<TextField
|
|
1058
|
+
autoComplete="username webauthn"
|
|
1059
|
+
onChange={() => {}}
|
|
1060
|
+
testID="email"
|
|
1061
|
+
type="email"
|
|
1062
|
+
value=""
|
|
1063
|
+
/>
|
|
1064
|
+
</>
|
|
1065
|
+
);
|
|
1066
|
+
expect(getByTestId("password").props.autoComplete).toBe("current-password");
|
|
1067
|
+
expect(getByTestId("email").props.autoComplete).toBe("username webauthn");
|
|
1068
|
+
} finally {
|
|
1069
|
+
setOS(originalOS);
|
|
1070
|
+
}
|
|
1071
|
+
});
|
|
1072
|
+
|
|
1073
|
+
const nativeCases: {
|
|
1074
|
+
autoComplete: TextFieldProps["autoComplete"];
|
|
1075
|
+
expectedAutoComplete: string | undefined;
|
|
1076
|
+
expectedTextContentType: string;
|
|
1077
|
+
type: TextFieldProps["type"];
|
|
1078
|
+
}[] = [
|
|
1079
|
+
{
|
|
1080
|
+
autoComplete: "username",
|
|
1081
|
+
expectedAutoComplete: "username",
|
|
1082
|
+
expectedTextContentType: "username",
|
|
1083
|
+
type: "email",
|
|
1084
|
+
},
|
|
1085
|
+
{
|
|
1086
|
+
autoComplete: "username webauthn",
|
|
1087
|
+
expectedAutoComplete: "username",
|
|
1088
|
+
expectedTextContentType: "username",
|
|
1089
|
+
type: "email",
|
|
1090
|
+
},
|
|
1091
|
+
{
|
|
1092
|
+
autoComplete: "email",
|
|
1093
|
+
expectedAutoComplete: "email",
|
|
1094
|
+
expectedTextContentType: "emailAddress",
|
|
1095
|
+
type: "email",
|
|
1096
|
+
},
|
|
1097
|
+
{
|
|
1098
|
+
autoComplete: "current-password",
|
|
1099
|
+
expectedAutoComplete: "current-password",
|
|
1100
|
+
expectedTextContentType: "password",
|
|
1101
|
+
type: "password",
|
|
1102
|
+
},
|
|
1103
|
+
{
|
|
1104
|
+
autoComplete: "new-password",
|
|
1105
|
+
expectedAutoComplete: "new-password",
|
|
1106
|
+
expectedTextContentType: "newPassword",
|
|
1107
|
+
type: "password",
|
|
1108
|
+
},
|
|
1109
|
+
{
|
|
1110
|
+
autoComplete: "one-time-code",
|
|
1111
|
+
expectedAutoComplete: "one-time-code",
|
|
1112
|
+
expectedTextContentType: "oneTimeCode",
|
|
1113
|
+
type: "text",
|
|
1114
|
+
},
|
|
1115
|
+
{
|
|
1116
|
+
autoComplete: "off",
|
|
1117
|
+
expectedAutoComplete: "off",
|
|
1118
|
+
expectedTextContentType: "none",
|
|
1119
|
+
type: "search",
|
|
1120
|
+
},
|
|
1121
|
+
{
|
|
1122
|
+
autoComplete: "on",
|
|
1123
|
+
expectedAutoComplete: undefined,
|
|
1124
|
+
expectedTextContentType: "password",
|
|
1125
|
+
type: "password",
|
|
1126
|
+
},
|
|
1127
|
+
];
|
|
1128
|
+
|
|
1129
|
+
for (const testCase of nativeCases) {
|
|
1130
|
+
it(`forwards autoComplete="${testCase.autoComplete}" to native autofill hints`, () => {
|
|
1131
|
+
const {getByTestId} = renderWithTheme(
|
|
1132
|
+
<TextField
|
|
1133
|
+
autoComplete={testCase.autoComplete}
|
|
1134
|
+
onChange={() => {}}
|
|
1135
|
+
testID="field"
|
|
1136
|
+
type={testCase.type}
|
|
1137
|
+
value=""
|
|
1138
|
+
/>
|
|
1139
|
+
);
|
|
1140
|
+
const input = getByTestId("field");
|
|
1141
|
+
expect(input.props.autoComplete).toBe(testCase.expectedAutoComplete);
|
|
1142
|
+
expect(input.props.textContentType).toBe(testCase.expectedTextContentType);
|
|
1143
|
+
});
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
it("falls back to the type's text content hint on native without autoComplete", () => {
|
|
1147
|
+
const {getByTestId} = renderWithTheme(
|
|
1148
|
+
<>
|
|
1149
|
+
<TextField onChange={() => {}} testID="email" type="email" value="" />
|
|
1150
|
+
<TextField onChange={() => {}} testID="password" type="password" value="" />
|
|
1151
|
+
</>
|
|
1152
|
+
);
|
|
1153
|
+
expect(getByTestId("email").props.autoComplete).toBeUndefined();
|
|
1154
|
+
expect(getByTestId("email").props.textContentType).toBe("emailAddress");
|
|
1155
|
+
expect(getByTestId("password").props.autoComplete).toBeUndefined();
|
|
1156
|
+
expect(getByTestId("password").props.textContentType).toBe("password");
|
|
1157
|
+
});
|
|
1158
|
+
|
|
1159
|
+
it("sets the web autofill token on web and leaves the iOS hint to the type map", () => {
|
|
1160
|
+
const originalOS = setOS("web");
|
|
1161
|
+
try {
|
|
1162
|
+
const {getByTestId} = renderWithTheme(
|
|
1163
|
+
<TextField
|
|
1164
|
+
autoComplete="one-time-code"
|
|
1165
|
+
onChange={() => {}}
|
|
1166
|
+
testID="code"
|
|
1167
|
+
type="text"
|
|
1168
|
+
value=""
|
|
1169
|
+
/>
|
|
1170
|
+
);
|
|
1171
|
+
expect(getByTestId("code").props.autoComplete).toBe("one-time-code");
|
|
1172
|
+
} finally {
|
|
1173
|
+
setOS(originalOS);
|
|
1174
|
+
}
|
|
1175
|
+
});
|
|
1176
|
+
});
|
|
1177
|
+
|
|
1178
|
+
describe("field theming", () => {
|
|
1179
|
+
type ThemeContextValue = ReturnType<typeof useTheme>;
|
|
1180
|
+
|
|
1181
|
+
const renderWithFieldTheme = (
|
|
1182
|
+
props: Partial<TextFieldProps> = {}
|
|
1183
|
+
): {captured: () => ThemeContextValue | undefined; findBox: (color: string) => unknown[]} => {
|
|
1184
|
+
let captured: ThemeContextValue | undefined;
|
|
1185
|
+
const Capture = (): null => {
|
|
1186
|
+
captured = useTheme();
|
|
1187
|
+
return null;
|
|
1188
|
+
};
|
|
1189
|
+
const view = renderWithTheme(
|
|
1190
|
+
<>
|
|
1191
|
+
<Capture />
|
|
1192
|
+
<TextField onChange={() => {}} testID="themed-field" value="" {...props} />
|
|
1193
|
+
</>
|
|
1194
|
+
);
|
|
1195
|
+
const findBox = (color: string): unknown[] =>
|
|
1196
|
+
view.UNSAFE_root.findAll(
|
|
1197
|
+
(node) =>
|
|
1198
|
+
typeof node.type === "string" &&
|
|
1199
|
+
node.props.style?.backgroundColor === color &&
|
|
1200
|
+
node.props.style?.borderRadius === 4
|
|
1201
|
+
);
|
|
1202
|
+
return {captured: () => captured, findBox};
|
|
1203
|
+
};
|
|
1204
|
+
|
|
1205
|
+
it("paints the input box from field.background and field.border", () => {
|
|
1206
|
+
const {captured, findBox} = renderWithFieldTheme();
|
|
1207
|
+
act(() => {
|
|
1208
|
+
captured()?.setTheme({field: {background: "primary000", border: "primary500"}});
|
|
1209
|
+
});
|
|
1210
|
+
const boxes = findBox(defaultThemePrimitives.primary000) as {
|
|
1211
|
+
props: {style: {borderColor: string}};
|
|
1212
|
+
}[];
|
|
1213
|
+
assert.isAbove(boxes.length, 0);
|
|
1214
|
+
assert.equal(boxes[0].props.style.borderColor, defaultThemePrimitives.primary500);
|
|
1215
|
+
});
|
|
1216
|
+
|
|
1217
|
+
it("paints a disabled input from field.backgroundDisabled and field.borderDisabled", () => {
|
|
1218
|
+
const {captured, findBox} = renderWithFieldTheme({disabled: true});
|
|
1219
|
+
act(() => {
|
|
1220
|
+
captured()?.setTheme({
|
|
1221
|
+
field: {backgroundDisabled: "accent050", borderDisabled: "accent700"},
|
|
1222
|
+
});
|
|
1223
|
+
});
|
|
1224
|
+
const boxes = findBox(defaultThemePrimitives.accent050) as {
|
|
1225
|
+
props: {style: {borderColor: string}};
|
|
1226
|
+
}[];
|
|
1227
|
+
assert.isAbove(boxes.length, 0);
|
|
1228
|
+
assert.equal(boxes[0].props.style.borderColor, defaultThemePrimitives.accent700);
|
|
1229
|
+
});
|
|
1230
|
+
|
|
1231
|
+
it("paints an error border from field.borderError", () => {
|
|
1232
|
+
const {captured, findBox} = renderWithFieldTheme({errorText: "Required"});
|
|
1233
|
+
act(() => {
|
|
1234
|
+
captured()?.setTheme({field: {borderError: "warning200"}});
|
|
1235
|
+
});
|
|
1236
|
+
const boxes = findBox(defaultThemePrimitives.neutral000) as {
|
|
1237
|
+
props: {style: {borderColor: string}};
|
|
1238
|
+
}[];
|
|
1239
|
+
assert.isAbove(boxes.length, 0);
|
|
1240
|
+
assert.equal(boxes[0].props.style.borderColor, defaultThemePrimitives.warning200);
|
|
1241
|
+
});
|
|
1242
|
+
});
|
|
1020
1243
|
});
|
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});
|
|
@@ -164,12 +213,13 @@ export const TextField: FC<TextFieldProps> = ({
|
|
|
164
213
|
const visibilityToggleWebProps =
|
|
165
214
|
Platform.OS === "web" ? {onMouseDown: preventVisibilityToggleBlur} : {};
|
|
166
215
|
|
|
167
|
-
let borderColor = focused ? theme.
|
|
216
|
+
let borderColor = focused ? theme.field.borderFocus : theme.field.border;
|
|
168
217
|
if (disabled) {
|
|
169
|
-
borderColor = theme.
|
|
170
|
-
} else if (errorText) {
|
|
171
|
-
borderColor = theme.
|
|
218
|
+
borderColor = theme.field.borderDisabled;
|
|
219
|
+
} else if (errorText && !focused) {
|
|
220
|
+
borderColor = theme.field.borderError;
|
|
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) &&
|
|
325
|
+
{Boolean(errorText) && errorPosition === "above" && (
|
|
326
|
+
<FieldError testID={fieldTestIDs.error} text={errorText!} />
|
|
327
|
+
)}
|
|
275
328
|
<View
|
|
276
329
|
style={{
|
|
277
|
-
backgroundColor: disabled ? theme.
|
|
330
|
+
backgroundColor: disabled ? theme.field.backgroundDisabled : theme.field.background,
|
|
278
331
|
borderColor,
|
|
279
332
|
borderRadius: 4,
|
|
280
|
-
borderWidth
|
|
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-
|
|
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
|