@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.
- package/.ai/guidelines/core.md +1 -1
- package/CHANGELOG.md +393 -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 +120 -7
- 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 +5 -3
- 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/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/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/TextField.d.ts.map +1 -1
- package/dist/TextField.js +44 -10
- package/dist/TextField.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 +3 -2
- package/src/Accordion.test.tsx +5 -0
- package/src/Accordion.tsx +3 -8
- package/src/AreaChart.test.tsx +15 -0
- package/src/Avatar.test.tsx +8 -0
- package/src/Avatar.tsx +2 -0
- package/src/BarChart.test.tsx +15 -0
- package/src/Box.test.tsx +61 -1
- package/src/Box.tsx +44 -2
- package/src/Card.tsx +2 -2
- package/src/Common.ts +134 -7
- package/src/ConsentFormScreen.test.tsx +84 -0
- package/src/ConsentFormScreen.tsx +28 -4
- package/src/DateTimeField.tsx +5 -3
- package/src/DonutChart.test.tsx +15 -0
- 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 +16 -0
- package/src/GPTChat.tsx +8 -2
- package/src/Heading.test.tsx +14 -0
- package/src/Heading.tsx +6 -1
- package/src/Icon.test.tsx +52 -1
- package/src/Icon.tsx +92 -3
- package/src/IconButton.test.tsx +85 -0
- package/src/LabeledCheckBox.test.tsx +45 -0
- package/src/LabeledCheckBox.tsx +89 -0
- package/src/ListDetailLayout.tsx +247 -0
- package/src/MarkdownEditor.tsx +2 -1
- package/src/MediaQuery.ts +1 -0
- package/src/OtpField.test.tsx +280 -0
- package/src/OtpField.tsx +307 -0
- package/src/ProvisionalConsentSigner.test.tsx +625 -0
- package/src/ProvisionalConsentSigner.tsx +423 -0
- package/src/ResponsiveBreakpoint.test.tsx +7 -0
- package/src/ResponsiveBreakpoint.tsx +14 -0
- package/src/RootImportRegression.test.tsx +3 -0
- package/src/SocialLoginButton.test.tsx +14 -0
- package/src/SocialLoginButton.tsx +51 -7
- package/src/SplitPage.native.tsx +3 -1
- package/src/SplitPage.tsx +11 -5
- package/src/SyncStatusBanner.test.tsx +61 -4
- package/src/SyncStatusBanner.tsx +29 -3
- package/src/TextField.test.tsx +150 -0
- package/src/TextField.tsx +66 -8
- 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__/CustomSelectField.test.tsx.snap +3 -0
- package/src/__snapshots__/EmailField.test.tsx.snap +6 -0
- package/src/__snapshots__/Field.test.tsx.snap +37 -0
- package/src/__snapshots__/HeightField.test.tsx.snap +2 -0
- package/src/__snapshots__/MobileAddressAutoComplete.test.tsx.snap +3 -0
- package/src/__snapshots__/NumberField.test.tsx.snap +3 -0
- 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__/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/bunSetup.ts +13 -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 +634 -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 +837 -1
- 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 +170 -1
- 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/useConsentForms.test.ts +37 -1
- package/src/useConsentForms.ts +25 -0
- package/src/useProvisionalConsent.test.ts +256 -0
- package/src/useProvisionalConsent.ts +218 -0
package/src/AreaChart.test.tsx
CHANGED
|
@@ -124,6 +124,21 @@ describe("AreaChart", () => {
|
|
|
124
124
|
expect(getByText("B: 50")).toBeTruthy();
|
|
125
125
|
});
|
|
126
126
|
|
|
127
|
+
it("records a positive plot width from layout", () => {
|
|
128
|
+
const {getByTestId} = renderWithTheme(<AreaChart data={POINTS} testID="chart" />);
|
|
129
|
+
|
|
130
|
+
act(() => {
|
|
131
|
+
fireEvent(getByTestId("chart.plot"), "layout", {
|
|
132
|
+
nativeEvent: {layout: {height: 0, width: 0}},
|
|
133
|
+
});
|
|
134
|
+
fireEvent(getByTestId("chart.plot"), "layout", {
|
|
135
|
+
nativeEvent: {layout: {height: 180, width: 640}},
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
expect(getByTestId("chart.plot")).toBeTruthy();
|
|
140
|
+
});
|
|
141
|
+
|
|
127
142
|
it("updates or clears the active tooltip when data changes", async () => {
|
|
128
143
|
const {getByTestId, getByText, queryByTestId, rerender} = renderWithTheme(
|
|
129
144
|
<AreaChart data={POINTS} testID="chart" />
|
package/src/Avatar.test.tsx
CHANGED
|
@@ -74,6 +74,14 @@ describe("Avatar", () => {
|
|
|
74
74
|
expect(toJSON()).toMatchSnapshot();
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
+
it("takes keyboard focus only when the avatar is editable", () => {
|
|
78
|
+
const {UNSAFE_getAllByProps, rerender} = renderWithTheme(<Avatar name="John Doe" />);
|
|
79
|
+
expect(UNSAFE_getAllByProps({"aria-role": "button"})[0].props.focusable).toBe(false);
|
|
80
|
+
|
|
81
|
+
rerender(<Avatar name="John Doe" status="imagePicker" />);
|
|
82
|
+
expect(UNSAFE_getAllByProps({"aria-role": "button"})[0].props.focusable).toBe(true);
|
|
83
|
+
});
|
|
84
|
+
|
|
77
85
|
it("renders initials when no image is provided", () => {
|
|
78
86
|
const {getByText} = renderWithTheme(<Avatar name="John Doe" testID="avatar" />);
|
|
79
87
|
expect(getByText("JD")).toBeTruthy();
|
package/src/Avatar.tsx
CHANGED
|
@@ -204,6 +204,8 @@ export const Avatar: FC<AvatarProps> = ({
|
|
|
204
204
|
>
|
|
205
205
|
<Pressable
|
|
206
206
|
aria-role="button"
|
|
207
|
+
// Only an editable avatar does anything when pressed, so only that one takes focus.
|
|
208
|
+
focusable={showEditIcon}
|
|
207
209
|
style={{
|
|
208
210
|
borderRadius: 1,
|
|
209
211
|
cursor: showEditIcon ? "pointer" : "auto",
|
package/src/BarChart.test.tsx
CHANGED
|
@@ -183,6 +183,21 @@ describe("BarChart", () => {
|
|
|
183
183
|
expect(queryByTestId("chart.tooltip")).toBeNull();
|
|
184
184
|
});
|
|
185
185
|
|
|
186
|
+
it("records a positive plot width from layout", () => {
|
|
187
|
+
const {getByTestId} = renderWithTheme(<BarChart data={POINTS} testID="chart" />);
|
|
188
|
+
|
|
189
|
+
act(() => {
|
|
190
|
+
fireEvent(getByTestId("chart.plot"), "layout", {
|
|
191
|
+
nativeEvent: {layout: {height: 0, width: 0}},
|
|
192
|
+
});
|
|
193
|
+
fireEvent(getByTestId("chart.plot"), "layout", {
|
|
194
|
+
nativeEvent: {layout: {height: 180, width: 640}},
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
expect(getByTestId("chart.plot")).toBeTruthy();
|
|
199
|
+
});
|
|
200
|
+
|
|
186
201
|
it("shows tooltip copy after pressing a zero-value bar", async () => {
|
|
187
202
|
const {getByTestId, getByText} = renderWithTheme(<BarChart data={POINTS} testID="chart" />);
|
|
188
203
|
|
package/src/Box.test.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import {describe, expect, it, mock, spyOn} from "bun:test";
|
|
|
2
2
|
import {act, fireEvent} from "@testing-library/react-native";
|
|
3
3
|
import {assert} from "chai";
|
|
4
4
|
import React from "react";
|
|
5
|
-
import type
|
|
5
|
+
import {Platform, type ScrollView} from "react-native";
|
|
6
6
|
|
|
7
7
|
import {Box} from "./Box";
|
|
8
8
|
import {sharedResponsiveBreakpointStore} from "./ResponsiveBreakpoint";
|
|
@@ -630,6 +630,66 @@ describe("Box", () => {
|
|
|
630
630
|
expect(onClick).not.toHaveBeenCalled();
|
|
631
631
|
});
|
|
632
632
|
|
|
633
|
+
it("marks a selected clickable row with aria-current", () => {
|
|
634
|
+
const originalOS = Platform.OS;
|
|
635
|
+
Platform.OS = "web";
|
|
636
|
+
try {
|
|
637
|
+
const {getByTestId} = renderWithTheme(
|
|
638
|
+
<Box
|
|
639
|
+
accessibilityHint="Opens the message"
|
|
640
|
+
accessibilityLabel="Quarterly report"
|
|
641
|
+
accessibilityState={{selected: true}}
|
|
642
|
+
onClick={() => {}}
|
|
643
|
+
testID="row"
|
|
644
|
+
/>
|
|
645
|
+
);
|
|
646
|
+
const pressable = getByTestId("row-clickable");
|
|
647
|
+
expect(pressable.props.accessibilityState).toBeUndefined();
|
|
648
|
+
expect(pressable.props["aria-current"]).toBe("true");
|
|
649
|
+
expect(pressable.props["aria-selected"]).toBeUndefined();
|
|
650
|
+
} finally {
|
|
651
|
+
Platform.OS = originalOS;
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
|
|
655
|
+
it("drops aria-current from an unselected row", () => {
|
|
656
|
+
const originalOS = Platform.OS;
|
|
657
|
+
Platform.OS = "web";
|
|
658
|
+
try {
|
|
659
|
+
const {getByTestId} = renderWithTheme(
|
|
660
|
+
<Box
|
|
661
|
+
accessibilityHint="Opens the message"
|
|
662
|
+
accessibilityLabel="Quarterly report"
|
|
663
|
+
accessibilityState={{selected: false}}
|
|
664
|
+
onClick={() => {}}
|
|
665
|
+
testID="row"
|
|
666
|
+
/>
|
|
667
|
+
);
|
|
668
|
+
const pressable = getByTestId("row-clickable");
|
|
669
|
+
expect(pressable.props.accessibilityState).toBeUndefined();
|
|
670
|
+
expect(pressable.props["aria-current"]).toBeUndefined();
|
|
671
|
+
expect(pressable.props["aria-selected"]).toBeUndefined();
|
|
672
|
+
} finally {
|
|
673
|
+
Platform.OS = originalOS;
|
|
674
|
+
}
|
|
675
|
+
});
|
|
676
|
+
|
|
677
|
+
it("sends aria-selected for a selectable role", () => {
|
|
678
|
+
const {getByTestId} = renderWithTheme(
|
|
679
|
+
<Box
|
|
680
|
+
accessibilityHint="Shows the inbox"
|
|
681
|
+
accessibilityLabel="Inbox"
|
|
682
|
+
accessibilityRole="tab"
|
|
683
|
+
accessibilityState={{selected: false}}
|
|
684
|
+
onClick={() => {}}
|
|
685
|
+
testID="tab"
|
|
686
|
+
/>
|
|
687
|
+
);
|
|
688
|
+
const pressable = getByTestId("tab-clickable");
|
|
689
|
+
expect(pressable.props["aria-selected"]).toBe(false);
|
|
690
|
+
expect(pressable.props["aria-current"]).toBeUndefined();
|
|
691
|
+
});
|
|
692
|
+
|
|
633
693
|
it("forwards checked to a Box without onClick", () => {
|
|
634
694
|
const {getByTestId} = renderWithTheme(
|
|
635
695
|
<Box accessibilityState={{checked: false}} testID="plain" />
|
package/src/Box.tsx
CHANGED
|
@@ -31,6 +31,28 @@ import {getLoadingAccessibilityProps, resolveLoadingContent} from "./Skeleton";
|
|
|
31
31
|
import {useTheme} from "./Theme";
|
|
32
32
|
import {Unifier} from "./Unifier";
|
|
33
33
|
|
|
34
|
+
const ARIA_SELECTABLE_ROLES = new Set([
|
|
35
|
+
"columnheader",
|
|
36
|
+
"gridcell",
|
|
37
|
+
"option",
|
|
38
|
+
"row",
|
|
39
|
+
"rowheader",
|
|
40
|
+
"tab",
|
|
41
|
+
"treeitem",
|
|
42
|
+
]);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* react-native-web turns `accessibilityState.selected` into `aria-selected`.
|
|
46
|
+
* A button cannot have that attribute, so a clickable row keeps `aria-current`
|
|
47
|
+
* only and drops `selected` from the state object on web.
|
|
48
|
+
*/
|
|
49
|
+
const omitSelectedState = (
|
|
50
|
+
state: NonNullable<AccessibilityProps["accessibilityState"]>
|
|
51
|
+
): NonNullable<AccessibilityProps["accessibilityState"]> => {
|
|
52
|
+
const {selected: _selected, ...rest} = state;
|
|
53
|
+
return rest;
|
|
54
|
+
};
|
|
55
|
+
|
|
34
56
|
const ALIGN_CONTENT = {
|
|
35
57
|
around: "space-around",
|
|
36
58
|
between: "space-between",
|
|
@@ -427,15 +449,35 @@ const BoxComponent = React.forwardRef((props: BoxProps, ref) => {
|
|
|
427
449
|
props.accessibilityState || isLoading
|
|
428
450
|
? {...props.accessibilityState, ...loadingAccessibilityProps.accessibilityState}
|
|
429
451
|
: undefined;
|
|
452
|
+
const accessibilityRoleProp = (props as AccessibilityProps).accessibilityRole;
|
|
453
|
+
// ARIA allows aria-selected only on selectable roles. Any other Box, such as a clickable
|
|
454
|
+
// list row (a button), marks the selected item with aria-current instead.
|
|
455
|
+
const sendsAriaSelected = ARIA_SELECTABLE_ROLES.has(accessibilityRoleProp ?? "");
|
|
456
|
+
const selectedAriaProps =
|
|
457
|
+
accessibilityState?.selected === undefined
|
|
458
|
+
? {}
|
|
459
|
+
: sendsAriaSelected
|
|
460
|
+
? {"aria-selected": accessibilityState.selected}
|
|
461
|
+
: {"aria-current": accessibilityState.selected ? ("true" as const) : undefined};
|
|
462
|
+
const hostAccessibilityState =
|
|
463
|
+
accessibilityState &&
|
|
464
|
+
Platform.OS === "web" &&
|
|
465
|
+
accessibilityState.selected !== undefined &&
|
|
466
|
+
!sendsAriaSelected
|
|
467
|
+
? omitSelectedState(accessibilityState)
|
|
468
|
+
: accessibilityState;
|
|
430
469
|
const accessibilityStateProps = accessibilityState
|
|
431
470
|
? {
|
|
432
|
-
|
|
471
|
+
...(hostAccessibilityState && Object.keys(hostAccessibilityState).length > 0
|
|
472
|
+
? {accessibilityState: hostAccessibilityState}
|
|
473
|
+
: {}),
|
|
433
474
|
...(accessibilityState.checked !== undefined
|
|
434
475
|
? {"aria-checked": accessibilityState.checked}
|
|
435
476
|
: {}),
|
|
436
477
|
...(accessibilityState.disabled !== undefined
|
|
437
478
|
? {"aria-disabled": accessibilityState.disabled}
|
|
438
479
|
: {}),
|
|
480
|
+
...selectedAriaProps,
|
|
439
481
|
...(accessibilityState.busy !== undefined ? {"aria-busy": accessibilityState.busy} : {}),
|
|
440
482
|
}
|
|
441
483
|
: {};
|
|
@@ -445,7 +487,7 @@ const BoxComponent = React.forwardRef((props: BoxProps, ref) => {
|
|
|
445
487
|
// itself translates to accessibilityRole under the hood) by default; an explicit
|
|
446
488
|
// `accessibilityRole` prop is only forwarded literally when the caller opts in.
|
|
447
489
|
if (props.onClick) {
|
|
448
|
-
const explicitAccessibilityRole =
|
|
490
|
+
const explicitAccessibilityRole = accessibilityRoleProp;
|
|
449
491
|
// Content is not there yet while loading, so presses are held until it is.
|
|
450
492
|
const isDisabled = accessibilityState?.disabled === true || isLoading;
|
|
451
493
|
// Per ARIA, Space toggles a checkbox or switch; react-native-web only maps Space to buttons.
|
package/src/Card.tsx
CHANGED
|
@@ -5,6 +5,7 @@ import {Box} from "./Box";
|
|
|
5
5
|
import {Button} from "./Button";
|
|
6
6
|
import type {CardProps} from "./Common";
|
|
7
7
|
import {Heading} from "./Heading";
|
|
8
|
+
import {isSupportedDesktopWidth} from "./MediaQuery";
|
|
8
9
|
import {SkeletonCard} from "./Skeleton";
|
|
9
10
|
import {Text} from "./Text";
|
|
10
11
|
|
|
@@ -14,7 +15,6 @@ const MOBILE_ROW_IMAGE_WIDTH = 100;
|
|
|
14
15
|
const DESKTOP_ROW_IMAGE_WIDTH = 160;
|
|
15
16
|
const MOBILE_LARGE_IMAGE_HEIGHT = 300;
|
|
16
17
|
const TITLE_DESCRIPTION_GAP = 2;
|
|
17
|
-
const MOBILE_BREAKPOINT = 768;
|
|
18
18
|
|
|
19
19
|
const getDisplayCardWidth = ({
|
|
20
20
|
isMobile,
|
|
@@ -186,7 +186,7 @@ const ContainerCard = ({
|
|
|
186
186
|
|
|
187
187
|
export const Card = ({variant = "container", ...props}: CardProps): React.ReactElement => {
|
|
188
188
|
const {width: windowWidth} = useWindowDimensions();
|
|
189
|
-
const isMobile = windowWidth
|
|
189
|
+
const isMobile = !isSupportedDesktopWidth({width: windowWidth});
|
|
190
190
|
|
|
191
191
|
if (variant === "display") {
|
|
192
192
|
return <DisplayCard {...props} isMobile={isMobile} variant={variant} />;
|
package/src/Common.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type {Block, BlockAction, BlocksDocument, InlineDataset} from "@terreno/blocks";
|
|
2
|
+
import type {Href, Stack} from "expo-router";
|
|
2
3
|
import type {CountryCode} from "libphonenumber-js";
|
|
3
4
|
import type React from "react";
|
|
4
|
-
import type {FC, ReactElement, ReactNode} from "react";
|
|
5
|
+
import type {ComponentProps, FC, ReactElement, ReactNode} from "react";
|
|
5
6
|
import type {
|
|
6
7
|
ImageStyle,
|
|
7
8
|
ListRenderItemInfo,
|
|
@@ -89,7 +90,7 @@ export interface AccordionProps extends InfoModalIconProps {
|
|
|
89
90
|
|
|
90
91
|
/**
|
|
91
92
|
* If true, the accordion will be collapsed.
|
|
92
|
-
* @default
|
|
93
|
+
* @default false
|
|
93
94
|
*/
|
|
94
95
|
isCollapsed?: boolean;
|
|
95
96
|
|
|
@@ -683,12 +684,13 @@ export interface AccessibilityProps {
|
|
|
683
684
|
accessibilityRole?: string;
|
|
684
685
|
}
|
|
685
686
|
|
|
686
|
-
/** Checked and
|
|
687
|
+
/** Checked, disabled, and selected state a `Box` reports to screen readers. */
|
|
687
688
|
export interface BoxAccessibilityState {
|
|
688
689
|
/** Set automatically while `loading` is true; sent as `aria-busy` on web. */
|
|
689
690
|
busy?: boolean;
|
|
690
691
|
checked?: boolean;
|
|
691
692
|
disabled?: boolean;
|
|
693
|
+
selected?: boolean;
|
|
692
694
|
}
|
|
693
695
|
|
|
694
696
|
/** How skeleton placeholders animate. `none` renders a static block. */
|
|
@@ -802,8 +804,12 @@ export interface SkeletonGroupProps {
|
|
|
802
804
|
|
|
803
805
|
export interface BoxPropsBase extends WithTestID, LoadingProps {
|
|
804
806
|
/**
|
|
805
|
-
* Checked and
|
|
806
|
-
* `aria-checked` / `aria-disabled`.
|
|
807
|
+
* Checked, disabled, and selected state for screen readers, sent as `accessibilityState` and as
|
|
808
|
+
* `aria-checked` / `aria-disabled`. `selected` is sent as `aria-selected` on a selectable
|
|
809
|
+
* `accessibilityRole` (`tab`, `option`, `row`, ...) and as `aria-current="true"` on any other Box,
|
|
810
|
+
* such as a clickable list row. On web that row does not also keep `selected` in
|
|
811
|
+
* `accessibilityState`, because react-native-web would emit `aria-selected` on the button.
|
|
812
|
+
* On a clickable Box, `disabled: true` also stops presses.
|
|
807
813
|
*/
|
|
808
814
|
accessibilityState?: BoxAccessibilityState;
|
|
809
815
|
/**
|
|
@@ -1098,6 +1104,11 @@ export interface HelperTextProps {
|
|
|
1098
1104
|
|
|
1099
1105
|
export interface ErrorTextProps {
|
|
1100
1106
|
errorText?: string;
|
|
1107
|
+
/**
|
|
1108
|
+
* Where `errorText` sits relative to the control.
|
|
1109
|
+
* @default "above"
|
|
1110
|
+
*/
|
|
1111
|
+
errorPosition?: "above" | "below";
|
|
1101
1112
|
}
|
|
1102
1113
|
|
|
1103
1114
|
export interface AiSuggestionProps {
|
|
@@ -1130,7 +1141,24 @@ export interface TextFieldProps extends BaseFieldProps, HelperTextProps, ErrorTe
|
|
|
1130
1141
|
*/
|
|
1131
1142
|
showVisibilityToggle?: boolean;
|
|
1132
1143
|
|
|
1133
|
-
|
|
1144
|
+
/**
|
|
1145
|
+
* Autofill hint. On web it is set as the input's `autocomplete` attribute; `"username webauthn"`
|
|
1146
|
+
* asks the browser to offer saved passkeys in the field's autofill. On native it is sent as
|
|
1147
|
+
* React Native's `autoComplete` (Android's autofill hint) and as the matching iOS
|
|
1148
|
+
* `textContentType`: `username` → `username`, `email` → `emailAddress`, `current-password` →
|
|
1149
|
+
* `password`, `new-password` → `newPassword` (iOS offers a strong password), `one-time-code` →
|
|
1150
|
+
* `oneTimeCode`, `off` → `none`. Without it (or with `"on"`) the field's `type` picks the iOS
|
|
1151
|
+
* hint.
|
|
1152
|
+
*/
|
|
1153
|
+
autoComplete?:
|
|
1154
|
+
| "current-password"
|
|
1155
|
+
| "email"
|
|
1156
|
+
| "new-password"
|
|
1157
|
+
| "on"
|
|
1158
|
+
| "off"
|
|
1159
|
+
| "one-time-code"
|
|
1160
|
+
| "username"
|
|
1161
|
+
| "username webauthn";
|
|
1134
1162
|
returnKeyType?: "done" | "go" | "next" | "search" | "send";
|
|
1135
1163
|
|
|
1136
1164
|
grow?: boolean;
|
|
@@ -1144,8 +1172,15 @@ export interface TextFieldProps extends BaseFieldProps, HelperTextProps, ErrorTe
|
|
|
1144
1172
|
|
|
1145
1173
|
inputRef?: (ref: TextInput | null) => void;
|
|
1146
1174
|
trimOnBlur?: boolean;
|
|
1175
|
+
/** Renders the value in a monospace face with tracking, for codes such as backup codes. */
|
|
1176
|
+
mono?: boolean;
|
|
1147
1177
|
|
|
1148
1178
|
aiSuggestion?: AiSuggestionProps;
|
|
1179
|
+
|
|
1180
|
+
/**
|
|
1181
|
+
* Accessible name for the input. Screen readers otherwise announce "Text input field".
|
|
1182
|
+
*/
|
|
1183
|
+
accessibilityLabel?: string;
|
|
1149
1184
|
}
|
|
1150
1185
|
|
|
1151
1186
|
export interface TextAreaProps extends Omit<TextFieldProps, "multiline" | "type"> {}
|
|
@@ -1254,6 +1289,12 @@ export interface HeadingProps extends WithTestID {
|
|
|
1254
1289
|
align?: "left" | "right" | "center" | "justify"; // default "left"
|
|
1255
1290
|
children?: React.ReactNode;
|
|
1256
1291
|
color?: TextColor;
|
|
1292
|
+
/**
|
|
1293
|
+
* Outline level, 1 for the page title. When set, the heading is exposed to assistive
|
|
1294
|
+
* technology as a heading: `role="heading"` with `aria-level` (an `<h1>`–`<h6>` on web, the
|
|
1295
|
+
* header accessibility role on native). When omitted, the heading is plain text.
|
|
1296
|
+
*/
|
|
1297
|
+
level?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
1257
1298
|
overflow?: "normal" | "breakWord"; // default "breakWord"
|
|
1258
1299
|
size?: "sm" | "md" | "lg" | "xl" | "2xl"; // default "sm"
|
|
1259
1300
|
truncate?: boolean; // default false
|
|
@@ -1428,6 +1469,79 @@ export interface SplitPageProps<TItem extends SplitPageListItem = SplitPageListI
|
|
|
1428
1469
|
childColumnRounding?: Rounding;
|
|
1429
1470
|
}
|
|
1430
1471
|
|
|
1472
|
+
/**
|
|
1473
|
+
* Props for ListDetailLayout, the route-driven list/detail layout used as a route group's
|
|
1474
|
+
* `_layout.tsx`. The group's `index.tsx` renders `ListDetailIndex`, and a dynamic child route
|
|
1475
|
+
* (default `[id].tsx`) renders the detail.
|
|
1476
|
+
*/
|
|
1477
|
+
export interface ListDetailLayoutProps {
|
|
1478
|
+
/**
|
|
1479
|
+
* The list. Rendered in the left pane when split, and by `ListDetailIndex` when not split.
|
|
1480
|
+
*/
|
|
1481
|
+
list: ReactElement;
|
|
1482
|
+
/**
|
|
1483
|
+
* Where selecting an item navigates, e.g. `(id) => \`/mail/${id}\``.
|
|
1484
|
+
*/
|
|
1485
|
+
detailHref: (id: string) => Href;
|
|
1486
|
+
/**
|
|
1487
|
+
* The group's own path, e.g. `/mail`. `clear()` returns here, and `selectedId` is only read
|
|
1488
|
+
* from routes directly below it.
|
|
1489
|
+
*/
|
|
1490
|
+
indexHref: string;
|
|
1491
|
+
/**
|
|
1492
|
+
* Shown in the detail pane when split and no item is open.
|
|
1493
|
+
*/
|
|
1494
|
+
emptyDetail?: ReactElement;
|
|
1495
|
+
/**
|
|
1496
|
+
* Split into list and detail panes when the layout's measured width is at least this many
|
|
1497
|
+
* pixels. Defaults to 768.
|
|
1498
|
+
*/
|
|
1499
|
+
splitAtWidth?: number;
|
|
1500
|
+
/**
|
|
1501
|
+
* Width in pixels of the list pane when split. Defaults to 360.
|
|
1502
|
+
*/
|
|
1503
|
+
listWidth?: number;
|
|
1504
|
+
/**
|
|
1505
|
+
* The child route name that holds the detail. Defaults to `"[id]"`.
|
|
1506
|
+
*/
|
|
1507
|
+
detailRoute?: string;
|
|
1508
|
+
/**
|
|
1509
|
+
* The route param that holds the item id. Defaults to `"id"`.
|
|
1510
|
+
*/
|
|
1511
|
+
paramName?: string;
|
|
1512
|
+
/**
|
|
1513
|
+
* Screen options passed through to the underlying expo-router Stack.
|
|
1514
|
+
*/
|
|
1515
|
+
screenOptions?: ComponentProps<typeof Stack>["screenOptions"];
|
|
1516
|
+
/**
|
|
1517
|
+
* Optional `Stack.Screen` definitions passed through to the underlying expo-router Stack.
|
|
1518
|
+
*/
|
|
1519
|
+
children?: React.ReactNode;
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
/**
|
|
1523
|
+
* The value returned by `useListDetail()` inside a ListDetailLayout.
|
|
1524
|
+
*/
|
|
1525
|
+
export interface ListDetailState {
|
|
1526
|
+
/**
|
|
1527
|
+
* True when the list and detail panes are shown side by side.
|
|
1528
|
+
*/
|
|
1529
|
+
isSplit: boolean;
|
|
1530
|
+
/**
|
|
1531
|
+
* The id of the open item, read from the detail route. Undefined on the index route.
|
|
1532
|
+
*/
|
|
1533
|
+
selectedId?: string;
|
|
1534
|
+
/**
|
|
1535
|
+
* Open an item. Pushes the detail route, or replaces the open detail when split, so back
|
|
1536
|
+
* always returns to the list.
|
|
1537
|
+
*/
|
|
1538
|
+
select: (id: string) => void;
|
|
1539
|
+
/**
|
|
1540
|
+
* Close the open item and return to the group's index route.
|
|
1541
|
+
*/
|
|
1542
|
+
clear: () => void;
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1431
1545
|
export type PermissionKind =
|
|
1432
1546
|
| "location"
|
|
1433
1547
|
| "locationAlways"
|
|
@@ -2297,6 +2411,11 @@ export interface ButtonProps extends WithTestID {
|
|
|
2297
2411
|
* Used for OAuth social login buttons (Google, GitHub, Apple).
|
|
2298
2412
|
*/
|
|
2299
2413
|
export interface SocialLoginButtonProps extends WithTestID {
|
|
2414
|
+
/**
|
|
2415
|
+
* Accessible name. Defaults to the button text.
|
|
2416
|
+
*/
|
|
2417
|
+
accessibilityLabel?: string;
|
|
2418
|
+
|
|
2300
2419
|
/**
|
|
2301
2420
|
* The OAuth provider for the social login.
|
|
2302
2421
|
*/
|
|
@@ -2316,11 +2435,19 @@ export interface SocialLoginButtonProps extends WithTestID {
|
|
|
2316
2435
|
/**
|
|
2317
2436
|
* The visual variant of the button.
|
|
2318
2437
|
* - "primary": Uses the provider's brand colors
|
|
2319
|
-
* - "outline":
|
|
2438
|
+
* - "outline": Neutral outline pill, matching the other sign-in methods
|
|
2320
2439
|
* @default "primary"
|
|
2321
2440
|
*/
|
|
2322
2441
|
variant?: "primary" | "outline";
|
|
2323
2442
|
|
|
2443
|
+
/**
|
|
2444
|
+
* When set on the outline variant, highlights the pill and shows this label inside it.
|
|
2445
|
+
*/
|
|
2446
|
+
lastUsedLabel?: string;
|
|
2447
|
+
|
|
2448
|
+
/** Test ID of the last-used label. Requires `lastUsedLabel`. */
|
|
2449
|
+
lastUsedTestID?: string;
|
|
2450
|
+
|
|
2324
2451
|
/**
|
|
2325
2452
|
* If true, the button will be disabled.
|
|
2326
2453
|
* @default false
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {afterEach, describe, expect, it, mock} from "bun:test";
|
|
2
2
|
import {act, fireEvent, render, waitFor} from "@testing-library/react-native";
|
|
3
3
|
import {assert} from "chai";
|
|
4
|
+
import {DateTime} from "luxon";
|
|
4
5
|
import {Platform} from "react-native";
|
|
5
6
|
|
|
6
7
|
import {ConsentFormScreen} from "./ConsentFormScreen";
|
|
@@ -35,6 +36,89 @@ const waitForConsentMarkdown = async (getByText: (text: string) => unknown): Pro
|
|
|
35
36
|
};
|
|
36
37
|
|
|
37
38
|
describe("ConsentFormScreen", () => {
|
|
39
|
+
describe("provisional signature notice", () => {
|
|
40
|
+
const signedAt = "2026-10-20T15:30:00.000Z";
|
|
41
|
+
|
|
42
|
+
it("shows who signed on the user's behalf and when", () => {
|
|
43
|
+
const {getByTestId} = renderWithTheme(
|
|
44
|
+
<ConsentFormScreen
|
|
45
|
+
form={{...baseForm, provisionalSignature: {signedAt, signedByName: "Dana Rivera"}}}
|
|
46
|
+
locale="en"
|
|
47
|
+
onAgree={() => {}}
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
const expectedDate = DateTime.fromISO(signedAt)
|
|
51
|
+
.setLocale("en")
|
|
52
|
+
.toLocaleString(DateTime.DATETIME_MED);
|
|
53
|
+
const notice = getByTestId("consent-form-provisional-notice");
|
|
54
|
+
expect(notice).toBeTruthy();
|
|
55
|
+
expect(getByTestId("consent-form-provisional-notice-text").props.children).toBe(
|
|
56
|
+
`Signed on your behalf by Dana Rivera on ${expectedDate}`
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("leaves the date off when the signing date cannot be parsed", () => {
|
|
61
|
+
const {getByTestId} = renderWithTheme(
|
|
62
|
+
<ConsentFormScreen
|
|
63
|
+
form={{...baseForm, provisionalSignature: {signedAt: "bad", signedByName: "Dana Rivera"}}}
|
|
64
|
+
locale="en"
|
|
65
|
+
onAgree={() => {}}
|
|
66
|
+
/>
|
|
67
|
+
);
|
|
68
|
+
expect(getByTestId("consent-form-provisional-notice-text").props.children).toBe(
|
|
69
|
+
"Signed on your behalf by Dana Rivera"
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("shows no notice when the form has no provisional signature", () => {
|
|
74
|
+
const {queryByTestId} = renderWithTheme(
|
|
75
|
+
<ConsentFormScreen form={baseForm} locale="en" onAgree={() => {}} />
|
|
76
|
+
);
|
|
77
|
+
expect(queryByTestId("consent-form-provisional-notice")).toBeNull();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("still requires the user's own checkboxes and signature to agree", () => {
|
|
81
|
+
const onAgree = mock(() => {});
|
|
82
|
+
const {getByTestId} = renderWithTheme(
|
|
83
|
+
<ConsentFormScreen
|
|
84
|
+
form={{
|
|
85
|
+
...baseForm,
|
|
86
|
+
captureSignature: true,
|
|
87
|
+
checkboxes: [{label: "I understand", required: true}],
|
|
88
|
+
provisionalSignature: {signedAt, signedByName: "Dana Rivera"},
|
|
89
|
+
}}
|
|
90
|
+
locale="en"
|
|
91
|
+
onAgree={onAgree}
|
|
92
|
+
/>
|
|
93
|
+
);
|
|
94
|
+
expect(getByTestId("consent-form-agree-button").props.accessibilityState?.disabled).toBe(
|
|
95
|
+
true
|
|
96
|
+
);
|
|
97
|
+
expect(getByTestId("consent-footer-checkboxes-hint")).toBeTruthy();
|
|
98
|
+
expect(getByTestId("consent-footer-signature-hint")).toBeTruthy();
|
|
99
|
+
fireEvent.press(getByTestId("consent-form-agree-button"));
|
|
100
|
+
expect(onAgree).not.toHaveBeenCalled();
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it("lets the user decline a provisionally signed form", async () => {
|
|
104
|
+
const onDecline = mock(() => {});
|
|
105
|
+
const {getByTestId} = renderWithTheme(
|
|
106
|
+
<ConsentFormScreen
|
|
107
|
+
form={{...baseForm, provisionalSignature: {signedAt, signedByName: "Dana Rivera"}}}
|
|
108
|
+
locale="en"
|
|
109
|
+
onAgree={() => {}}
|
|
110
|
+
onDecline={onDecline}
|
|
111
|
+
/>
|
|
112
|
+
);
|
|
113
|
+
act(() => {
|
|
114
|
+
fireEvent.press(getByTestId("consent-form-decline-button"));
|
|
115
|
+
});
|
|
116
|
+
await waitFor(() => {
|
|
117
|
+
expect(onDecline).toHaveBeenCalledTimes(1);
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
38
122
|
it("renders with default state and a locale fallback", () => {
|
|
39
123
|
const onAgree = mock(() => {});
|
|
40
124
|
const {getByTestId, getByText} = renderWithTheme(
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {DateTime} from "luxon";
|
|
1
2
|
import React, {useCallback, useRef, useState} from "react";
|
|
2
3
|
import {
|
|
3
4
|
type LayoutChangeEvent,
|
|
@@ -17,7 +18,7 @@ import {Modal} from "./Modal";
|
|
|
17
18
|
import {Page} from "./Page";
|
|
18
19
|
import {SignatureField} from "./SignatureField";
|
|
19
20
|
import {Text} from "./Text";
|
|
20
|
-
import type
|
|
21
|
+
import {applyConsentVariables, type ConsentFormPublic} from "./useConsentForms";
|
|
21
22
|
|
|
22
23
|
interface ConsentFormScreenProps {
|
|
23
24
|
form: ConsentFormPublic;
|
|
@@ -49,9 +50,19 @@ export const ConsentFormScreen: React.FC<ConsentFormScreenProps> = ({
|
|
|
49
50
|
const scrollViewRef = useRef<ScrollView>(null);
|
|
50
51
|
|
|
51
52
|
const rawContent = form.content[locale] ?? form.content[form.defaultLocale] ?? "";
|
|
52
|
-
const content = variables
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
const content = applyConsentVariables(rawContent, variables);
|
|
54
|
+
|
|
55
|
+
// Staff may have signed provisionally; the user still reads and answers the form.
|
|
56
|
+
const provisionalSignedAt = form.provisionalSignature
|
|
57
|
+
? DateTime.fromISO(form.provisionalSignature.signedAt).setLocale(locale)
|
|
58
|
+
: undefined;
|
|
59
|
+
const provisionalNotice = form.provisionalSignature
|
|
60
|
+
? `Signed on your behalf by ${form.provisionalSignature.signedByName}${
|
|
61
|
+
provisionalSignedAt?.isValid
|
|
62
|
+
? ` on ${provisionalSignedAt.toLocaleString(DateTime.DATETIME_MED)}`
|
|
63
|
+
: ""
|
|
64
|
+
}`
|
|
65
|
+
: undefined;
|
|
55
66
|
|
|
56
67
|
const allRequiredCheckboxesChecked = form.checkboxes.every((checkbox, index) => {
|
|
57
68
|
if (!checkbox.required) {
|
|
@@ -244,6 +255,19 @@ export const ConsentFormScreen: React.FC<ConsentFormScreenProps> = ({
|
|
|
244
255
|
testID="consent-form-scroll-view"
|
|
245
256
|
>
|
|
246
257
|
<Box direction="column" gap={3} paddingY={2}>
|
|
258
|
+
{Boolean(provisionalNotice) && (
|
|
259
|
+
<Box
|
|
260
|
+
border="default"
|
|
261
|
+
color="secondaryExtraLight"
|
|
262
|
+
padding={3}
|
|
263
|
+
rounding="md"
|
|
264
|
+
testID="consent-form-provisional-notice"
|
|
265
|
+
>
|
|
266
|
+
<Text size="md" testID="consent-form-provisional-notice-text">
|
|
267
|
+
{provisionalNotice}
|
|
268
|
+
</Text>
|
|
269
|
+
</Box>
|
|
270
|
+
)}
|
|
247
271
|
<MarkdownView onLoad={handleMarkdownLoad}>{content}</MarkdownView>
|
|
248
272
|
|
|
249
273
|
{form.checkboxes.length > 0 && (
|
package/src/DateTimeField.tsx
CHANGED
|
@@ -461,20 +461,22 @@ export const DateTimeField: FC<DateTimeFieldProps> = ({
|
|
|
461
461
|
providedTimezone ?? DateTime.local().zoneName ?? "UTC"
|
|
462
462
|
);
|
|
463
463
|
|
|
464
|
-
|
|
464
|
+
// Parent width, in pt, below which inline controls do not fit. This is the field's own
|
|
465
|
+
// minimum, not a viewport breakpoint.
|
|
466
|
+
const inlineControlsMinWidth = 395;
|
|
465
467
|
let minimumWidth = 230; // Minimum width for the field container
|
|
466
468
|
if (type === "date") {
|
|
467
469
|
minimumWidth = 200;
|
|
468
470
|
}
|
|
469
471
|
|
|
470
|
-
let maximumWidth =
|
|
472
|
+
let maximumWidth = inlineControlsMinWidth; // Maximum width for the field container
|
|
471
473
|
if (["date", "time"].includes(type)) {
|
|
472
474
|
maximumWidth = minimumWidth + 10;
|
|
473
475
|
}
|
|
474
476
|
|
|
475
477
|
const [parentWidth, setParentWidth] = useState<number | null>(null);
|
|
476
478
|
const parentIsLessThanBreakpointOrIsMobile =
|
|
477
|
-
(parentWidth !== null && parentWidth <
|
|
479
|
+
(parentWidth !== null && parentWidth < inlineControlsMinWidth) || isNarrowViewport();
|
|
478
480
|
|
|
479
481
|
// We need to store the pending value in a ref because the state changes don't trigger
|
|
480
482
|
// immediately, so onBlur may use stale values.
|
package/src/DonutChart.test.tsx
CHANGED
|
@@ -177,6 +177,21 @@ describe("DonutChart", () => {
|
|
|
177
177
|
expect(queryByTestId("chart.tooltip")).toBeNull();
|
|
178
178
|
});
|
|
179
179
|
|
|
180
|
+
it("records a positive plot width from layout", () => {
|
|
181
|
+
const {getByTestId} = renderWithTheme(<DonutChart data={POINTS} testID="chart" />);
|
|
182
|
+
|
|
183
|
+
act(() => {
|
|
184
|
+
fireEvent(getByTestId("chart.plot"), "layout", {
|
|
185
|
+
nativeEvent: {layout: {height: 0, width: 0}},
|
|
186
|
+
});
|
|
187
|
+
fireEvent(getByTestId("chart.plot"), "layout", {
|
|
188
|
+
nativeEvent: {layout: {height: 180, width: 320}},
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
expect(getByTestId("chart.plot")).toBeTruthy();
|
|
193
|
+
});
|
|
194
|
+
|
|
180
195
|
it("does not open URLs from slice legend labels", () => {
|
|
181
196
|
const {getByText} = renderWithTheme(
|
|
182
197
|
<DonutChart data={[{label: "https://evil.example", value: 10}]} />
|