@terreno/ui 57.18.0 → 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 +2074 -0
- package/dist/Accordion.d.ts.map +1 -1
- package/dist/Accordion.js +3 -3
- package/dist/Accordion.js.map +1 -1
- package/dist/AreaChart.d.ts.map +1 -1
- package/dist/AreaChart.js +2 -2
- package/dist/AreaChart.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/BarChart.d.ts.map +1 -1
- package/dist/BarChart.js +2 -2
- package/dist/BarChart.js.map +1 -1
- package/dist/Box.d.ts.map +1 -1
- package/dist/Box.js +66 -8
- package/dist/Box.js.map +1 -1
- package/dist/Card.d.ts.map +1 -1
- package/dist/Card.js +5 -4
- package/dist/Card.js.map +1 -1
- package/dist/ChartCard.d.ts.map +1 -1
- package/dist/ChartCard.js +4 -2
- package/dist/ChartCard.js.map +1 -1
- package/dist/Common.d.ts +240 -14
- 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/DonutChart.d.ts.map +1 -1
- package/dist/DonutChart.js +2 -2
- package/dist/DonutChart.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/LineChart.d.ts.map +1 -1
- package/dist/LineChart.js +2 -2
- package/dist/LineChart.js.map +1 -1
- 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/Page.d.ts +1 -0
- package/dist/Page.d.ts.map +1 -1
- package/dist/Page.js +10 -1
- package/dist/Page.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/Scorecard.d.ts.map +1 -1
- package/dist/Scorecard.js +5 -2
- package/dist/Scorecard.js.map +1 -1
- package/dist/Skeleton.d.ts +39 -0
- package/dist/Skeleton.d.ts.map +1 -0
- package/dist/Skeleton.js +195 -0
- package/dist/Skeleton.js.map +1 -0
- 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 +12 -1
- package/dist/SplitPage.d.ts.map +1 -1
- package/dist/SplitPage.js +14 -7
- package/dist/SplitPage.js.map +1 -1
- package/dist/SplitPage.native.d.ts +1 -1
- package/dist/SplitPage.native.d.ts.map +1 -1
- package/dist/SplitPage.native.js +6 -3
- package/dist/SplitPage.native.js.map +1 -1
- package/dist/SplitPageLoading.d.ts +14 -0
- package/dist/SplitPageLoading.d.ts.map +1 -0
- package/dist/SplitPageLoading.js +19 -0
- package/dist/SplitPageLoading.js.map +1 -0
- 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/Text.d.ts +3 -1
- package/dist/Text.d.ts.map +1 -1
- package/dist/Text.js +2 -0
- package/dist/Text.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/charts/ChartFrame.d.ts +2 -2
- package/dist/charts/ChartFrame.d.ts.map +1 -1
- package/dist/charts/ChartFrame.js +9 -2
- package/dist/charts/ChartFrame.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 +21 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -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/dist/withLoading.d.ts +20 -0
- package/dist/withLoading.d.ts.map +1 -0
- package/dist/withLoading.js +24 -0
- package/dist/withLoading.js.map +1 -0
- package/package.json +4 -2
- package/src/Accordion.test.tsx +5 -0
- package/src/Accordion.tsx +3 -8
- package/src/AreaChart.test.tsx +15 -0
- package/src/AreaChart.tsx +6 -0
- package/src/Avatar.test.tsx +8 -0
- package/src/Avatar.tsx +2 -0
- package/src/BarChart.test.tsx +15 -0
- package/src/BarChart.tsx +6 -0
- package/src/Box.test.tsx +131 -1
- package/src/Box.tsx +77 -8
- package/src/Card.test.tsx +48 -0
- package/src/Card.tsx +13 -2
- package/src/ChartCard.test.tsx +30 -0
- package/src/ChartCard.tsx +18 -1
- package/src/Common.ts +263 -14
- 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/DonutChart.tsx +6 -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/LineChart.test.tsx +18 -0
- package/src/LineChart.tsx +6 -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/Page.test.tsx +38 -0
- package/src/Page.tsx +38 -19
- 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/Scorecard.test.tsx +11 -0
- package/src/Scorecard.tsx +21 -0
- package/src/Skeleton.test.tsx +262 -0
- package/src/Skeleton.tsx +430 -0
- package/src/SocialLoginButton.test.tsx +14 -0
- package/src/SocialLoginButton.tsx +51 -7
- package/src/SplitPage.native.tsx +16 -3
- package/src/SplitPage.tsx +29 -12
- package/src/SplitPageLoading.test.tsx +51 -0
- package/src/SplitPageLoading.tsx +53 -0
- package/src/SyncStatusBanner.test.tsx +61 -4
- package/src/SyncStatusBanner.tsx +29 -3
- package/src/Text.tsx +4 -1
- 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__/Page.test.tsx.snap +28 -5
- 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__/SplitPage.test.tsx.snap +16 -0
- 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/charts/ChartFrame.tsx +19 -8
- package/src/fieldElements/FieldError.tsx +1 -0
- package/src/fieldElements/__snapshots__/FieldError.test.tsx.snap +2 -0
- package/src/index.tsx +44 -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/withLoading.test.tsx +61 -0
- package/src/withLoading.tsx +50 -0
package/package.json
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@react-native-picker/picker": "2.11.4",
|
|
27
27
|
"@react-navigation/native": "^7.1.8",
|
|
28
28
|
"@shopify/react-native-skia": "2.6.5",
|
|
29
|
-
"@terreno/blocks": "57.
|
|
29
|
+
"@terreno/blocks": "57.20.0",
|
|
30
30
|
"d3-scale": "^4.0.2",
|
|
31
31
|
"d3-shape": "^3.2.0",
|
|
32
32
|
"emoji-datasource": "^16.0.0",
|
|
@@ -67,6 +67,7 @@
|
|
|
67
67
|
"react-native-modalize": "^2.1.1",
|
|
68
68
|
"react-native-permissions": "^5.4.4",
|
|
69
69
|
"react-native-picker-select": "^9.1.3",
|
|
70
|
+
"react-native-qrcode-svg": "6.3.26",
|
|
70
71
|
"react-native-reanimated": "4.5.1",
|
|
71
72
|
"react-native-safe-area-context": "~5.7.0",
|
|
72
73
|
"react-native-screens": "4.26.2",
|
|
@@ -113,6 +114,7 @@
|
|
|
113
114
|
},
|
|
114
115
|
"files": [
|
|
115
116
|
"LICENSE",
|
|
117
|
+
"CHANGELOG.md",
|
|
116
118
|
"dist/**/*",
|
|
117
119
|
"src/**/*",
|
|
118
120
|
".ai/**/*"
|
|
@@ -163,7 +165,7 @@
|
|
|
163
165
|
"test:coverage": "TZ=America/New_York bun run ../scripts/check-coverage.ts",
|
|
164
166
|
"types": "bun typedoc"
|
|
165
167
|
},
|
|
166
|
-
"version": "57.
|
|
168
|
+
"version": "57.20.0",
|
|
167
169
|
"bugs": {
|
|
168
170
|
"url": "https://github.com/TerrenoLabs/terreno/issues"
|
|
169
171
|
},
|
package/src/Accordion.test.tsx
CHANGED
|
@@ -29,6 +29,11 @@ describe("Accordion", () => {
|
|
|
29
29
|
expect(getByText("Test Subtitle")).toBeTruthy();
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
+
it("starts expanded by default", () => {
|
|
33
|
+
const {getByTestId} = renderWithTheme(<Accordion {...defaultProps} />);
|
|
34
|
+
expect(getByTestId("test-content")).toBeTruthy();
|
|
35
|
+
});
|
|
36
|
+
|
|
32
37
|
it("collapses when isCollapsed is true", () => {
|
|
33
38
|
const {queryByTestId} = renderWithTheme(<Accordion {...defaultProps} isCollapsed />);
|
|
34
39
|
expect(queryByTestId("test-content")).toBeNull();
|
package/src/Accordion.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import FontAwesome6 from "@expo/vector-icons/FontAwesome6";
|
|
2
1
|
import {type FC, useEffect, useState} from "react";
|
|
3
2
|
import {Pressable, View} from "react-native";
|
|
4
3
|
|
|
5
4
|
import type {AccordionProps} from "./Common";
|
|
6
5
|
import {Heading} from "./Heading";
|
|
6
|
+
import {Icon} from "./Icon";
|
|
7
7
|
import {InfoModalIcon} from "./InfoModalIcon";
|
|
8
8
|
import {Text} from "./Text";
|
|
9
9
|
import {useTheme} from "./Theme";
|
|
@@ -22,7 +22,7 @@ export const Accordion: FC<AccordionProps> = ({
|
|
|
22
22
|
testID,
|
|
23
23
|
}) => {
|
|
24
24
|
const {theme} = useTheme();
|
|
25
|
-
const [collapsed, setCollapsed] = useState(
|
|
25
|
+
const [collapsed, setCollapsed] = useState(isCollapsed);
|
|
26
26
|
|
|
27
27
|
// The external collapse state should override the internal collapse state.
|
|
28
28
|
useEffect(() => {
|
|
@@ -68,12 +68,7 @@ export const Accordion: FC<AccordionProps> = ({
|
|
|
68
68
|
}}
|
|
69
69
|
testID={testID ? `${testID}.toggle` : "accordion-toggle"}
|
|
70
70
|
>
|
|
71
|
-
<
|
|
72
|
-
color={theme.text.link}
|
|
73
|
-
name={collapsed ? "chevron-down" : "chevron-up"}
|
|
74
|
-
selectable={undefined}
|
|
75
|
-
size={16}
|
|
76
|
-
/>
|
|
71
|
+
<Icon color="link" iconName={collapsed ? "chevron-down" : "chevron-up"} size="md" />
|
|
77
72
|
</Pressable>
|
|
78
73
|
</View>
|
|
79
74
|
</View>
|
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/AreaChart.tsx
CHANGED
|
@@ -56,6 +56,9 @@ export const AreaChart: FC<AreaChartProps> = ({
|
|
|
56
56
|
height = DEFAULT_HEIGHT,
|
|
57
57
|
legendLabel,
|
|
58
58
|
loading = false,
|
|
59
|
+
loadingAnimation,
|
|
60
|
+
loadingComponent,
|
|
61
|
+
loadingLabel,
|
|
59
62
|
onPeriodPress,
|
|
60
63
|
periodLabel,
|
|
61
64
|
series,
|
|
@@ -130,6 +133,9 @@ export const AreaChart: FC<AreaChartProps> = ({
|
|
|
130
133
|
legendItems={legendItems}
|
|
131
134
|
legendLabel={legendLabel}
|
|
132
135
|
loading={loading}
|
|
136
|
+
loadingAnimation={loadingAnimation}
|
|
137
|
+
loadingComponent={loadingComponent}
|
|
138
|
+
loadingLabel={loadingLabel}
|
|
133
139
|
testID={testID}
|
|
134
140
|
tooltipText={tooltipText}
|
|
135
141
|
>
|
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/BarChart.tsx
CHANGED
|
@@ -48,6 +48,9 @@ export const BarChart: FC<BarChartProps> = ({
|
|
|
48
48
|
height = DEFAULT_HEIGHT,
|
|
49
49
|
legendLabel,
|
|
50
50
|
loading = false,
|
|
51
|
+
loadingAnimation,
|
|
52
|
+
loadingComponent,
|
|
53
|
+
loadingLabel,
|
|
51
54
|
onPeriodPress,
|
|
52
55
|
periodLabel,
|
|
53
56
|
series,
|
|
@@ -119,6 +122,9 @@ export const BarChart: FC<BarChartProps> = ({
|
|
|
119
122
|
isEmpty={allPoints.length === 0}
|
|
120
123
|
legendLabel={effectiveLegendLabel}
|
|
121
124
|
loading={loading}
|
|
125
|
+
loadingAnimation={loadingAnimation}
|
|
126
|
+
loadingComponent={loadingComponent}
|
|
127
|
+
loadingLabel={loadingLabel}
|
|
122
128
|
testID={testID}
|
|
123
129
|
tooltipText={tooltipText}
|
|
124
130
|
>
|
package/src/Box.test.tsx
CHANGED
|
@@ -2,13 +2,17 @@ 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";
|
|
9
|
+
import {Skeleton, SkeletonCircle} from "./Skeleton";
|
|
9
10
|
import {Text} from "./Text";
|
|
10
11
|
import {renderWithTheme} from "./test-utils";
|
|
11
12
|
|
|
13
|
+
// Skeletons are hidden from assistive tech, so queries opt in to hidden elements.
|
|
14
|
+
const HIDDEN = {includeHiddenElements: true};
|
|
15
|
+
|
|
12
16
|
/** Imperative handle exposed by Box's forwarded ref. */
|
|
13
17
|
interface BoxScrollHandle {
|
|
14
18
|
scrollTo: (y: number) => void;
|
|
@@ -626,6 +630,66 @@ describe("Box", () => {
|
|
|
626
630
|
expect(onClick).not.toHaveBeenCalled();
|
|
627
631
|
});
|
|
628
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
|
+
|
|
629
693
|
it("forwards checked to a Box without onClick", () => {
|
|
630
694
|
const {getByTestId} = renderWithTheme(
|
|
631
695
|
<Box accessibilityState={{checked: false}} testID="plain" />
|
|
@@ -1139,4 +1203,70 @@ describe("Box", () => {
|
|
|
1139
1203
|
expect(onClick).toHaveBeenCalled();
|
|
1140
1204
|
});
|
|
1141
1205
|
});
|
|
1206
|
+
|
|
1207
|
+
describe("loading", () => {
|
|
1208
|
+
it("renders children when not loading", () => {
|
|
1209
|
+
const {getByText} = renderWithTheme(
|
|
1210
|
+
<Box loading={false}>
|
|
1211
|
+
<Text>Loaded</Text>
|
|
1212
|
+
</Box>
|
|
1213
|
+
);
|
|
1214
|
+
expect(getByText("Loaded")).toBeTruthy();
|
|
1215
|
+
});
|
|
1216
|
+
|
|
1217
|
+
it("renders the default text skeleton instead of children while loading", () => {
|
|
1218
|
+
const {getByTestId, queryByText} = renderWithTheme(
|
|
1219
|
+
<Box loading testID="box">
|
|
1220
|
+
<Text>Loaded</Text>
|
|
1221
|
+
</Box>
|
|
1222
|
+
);
|
|
1223
|
+
expect(queryByText("Loaded")).toBeNull();
|
|
1224
|
+
const box = getByTestId("box");
|
|
1225
|
+
expect(box.props["aria-busy"]).toBe(true);
|
|
1226
|
+
expect(box.props.accessibilityState).toMatchObject({busy: true});
|
|
1227
|
+
expect(box.props.accessibilityLabel).toBe("Loading");
|
|
1228
|
+
});
|
|
1229
|
+
|
|
1230
|
+
it("renders a custom loading component with a custom label", () => {
|
|
1231
|
+
const {getByTestId} = renderWithTheme(
|
|
1232
|
+
<Box
|
|
1233
|
+
loading
|
|
1234
|
+
loadingComponent={<SkeletonCircle testID="avatar-skeleton" />}
|
|
1235
|
+
loadingLabel="Loading profile"
|
|
1236
|
+
testID="box"
|
|
1237
|
+
/>
|
|
1238
|
+
);
|
|
1239
|
+
expect(getByTestId("avatar-skeleton", HIDDEN)).toBeTruthy();
|
|
1240
|
+
expect(getByTestId("box").props.accessibilityLabel).toBe("Loading profile");
|
|
1241
|
+
});
|
|
1242
|
+
|
|
1243
|
+
it("hands loadingAnimation to skeletons inside the loading component", async () => {
|
|
1244
|
+
const {getByTestId} = renderWithTheme(
|
|
1245
|
+
<Box loading loadingAnimation="shimmer" loadingComponent={<Skeleton testID="block" />} />
|
|
1246
|
+
);
|
|
1247
|
+
// Skeletons hold still until the reduce-motion setting resolves.
|
|
1248
|
+
await act(async () => {
|
|
1249
|
+
await Promise.resolve();
|
|
1250
|
+
});
|
|
1251
|
+
expect(getByTestId("block.shimmer", HIDDEN)).toBeTruthy();
|
|
1252
|
+
});
|
|
1253
|
+
|
|
1254
|
+
it("keeps loading props out of the style object", () => {
|
|
1255
|
+
const {getByTestId} = renderWithTheme(
|
|
1256
|
+
<Box loading loadingAnimation="none" loadingLabel="Loading" padding={2} testID="box" />
|
|
1257
|
+
);
|
|
1258
|
+
const style = getByTestId("box").props.style;
|
|
1259
|
+
expect(style).toMatchObject({padding: 8});
|
|
1260
|
+
expect(style.loading).toBeUndefined();
|
|
1261
|
+
expect(style.loadingAnimation).toBeUndefined();
|
|
1262
|
+
expect(style.loadingLabel).toBeUndefined();
|
|
1263
|
+
});
|
|
1264
|
+
|
|
1265
|
+
it("ignores presses on a clickable Box while loading", () => {
|
|
1266
|
+
const onClick = mock(() => {});
|
|
1267
|
+
const {getByTestId} = renderWithTheme(<Box loading onClick={onClick} testID="box" />);
|
|
1268
|
+
fireEvent.press(getByTestId("box-clickable"));
|
|
1269
|
+
expect(onClick).not.toHaveBeenCalled();
|
|
1270
|
+
});
|
|
1271
|
+
});
|
|
1142
1272
|
});
|
package/src/Box.tsx
CHANGED
|
@@ -27,9 +27,32 @@ import {
|
|
|
27
27
|
type ResponsiveBreakpoint,
|
|
28
28
|
useResponsiveBreakpoint,
|
|
29
29
|
} from "./ResponsiveBreakpoint";
|
|
30
|
+
import {getLoadingAccessibilityProps, resolveLoadingContent} from "./Skeleton";
|
|
30
31
|
import {useTheme} from "./Theme";
|
|
31
32
|
import {Unifier} from "./Unifier";
|
|
32
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
|
+
|
|
33
56
|
const ALIGN_CONTENT = {
|
|
34
57
|
around: "space-around",
|
|
35
58
|
between: "space-between",
|
|
@@ -97,6 +120,10 @@ const NON_STYLE_BOX_PROPS = new Set<string>([
|
|
|
97
120
|
"children",
|
|
98
121
|
"dangerouslySetInlineStyle",
|
|
99
122
|
"keyboardOffset",
|
|
123
|
+
"loading",
|
|
124
|
+
"loadingAnimation",
|
|
125
|
+
"loadingComponent",
|
|
126
|
+
"loadingLabel",
|
|
100
127
|
"onClick",
|
|
101
128
|
"onHoverEnd",
|
|
102
129
|
"onHoverStart",
|
|
@@ -406,16 +433,52 @@ const BoxComponent = React.forwardRef((props: BoxProps, ref) => {
|
|
|
406
433
|
|
|
407
434
|
let box: React.ReactElement;
|
|
408
435
|
|
|
409
|
-
const
|
|
436
|
+
const isLoading = props.loading === true;
|
|
437
|
+
const children = resolveLoadingContent({
|
|
438
|
+
children: props.children,
|
|
439
|
+
loading: isLoading,
|
|
440
|
+
loadingAnimation: props.loadingAnimation,
|
|
441
|
+
loadingComponent: props.loadingComponent,
|
|
442
|
+
});
|
|
443
|
+
const loadingAccessibilityProps = getLoadingAccessibilityProps({
|
|
444
|
+
loading: isLoading,
|
|
445
|
+
loadingLabel: props.loadingLabel,
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
const accessibilityState =
|
|
449
|
+
props.accessibilityState || isLoading
|
|
450
|
+
? {...props.accessibilityState, ...loadingAccessibilityProps.accessibilityState}
|
|
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;
|
|
410
469
|
const accessibilityStateProps = accessibilityState
|
|
411
470
|
? {
|
|
412
|
-
|
|
471
|
+
...(hostAccessibilityState && Object.keys(hostAccessibilityState).length > 0
|
|
472
|
+
? {accessibilityState: hostAccessibilityState}
|
|
473
|
+
: {}),
|
|
413
474
|
...(accessibilityState.checked !== undefined
|
|
414
475
|
? {"aria-checked": accessibilityState.checked}
|
|
415
476
|
: {}),
|
|
416
477
|
...(accessibilityState.disabled !== undefined
|
|
417
478
|
? {"aria-disabled": accessibilityState.disabled}
|
|
418
479
|
: {}),
|
|
480
|
+
...selectedAriaProps,
|
|
481
|
+
...(accessibilityState.busy !== undefined ? {"aria-busy": accessibilityState.busy} : {}),
|
|
419
482
|
}
|
|
420
483
|
: {};
|
|
421
484
|
|
|
@@ -424,8 +487,9 @@ const BoxComponent = React.forwardRef((props: BoxProps, ref) => {
|
|
|
424
487
|
// itself translates to accessibilityRole under the hood) by default; an explicit
|
|
425
488
|
// `accessibilityRole` prop is only forwarded literally when the caller opts in.
|
|
426
489
|
if (props.onClick) {
|
|
427
|
-
const explicitAccessibilityRole =
|
|
428
|
-
|
|
490
|
+
const explicitAccessibilityRole = accessibilityRoleProp;
|
|
491
|
+
// Content is not there yet while loading, so presses are held until it is.
|
|
492
|
+
const isDisabled = accessibilityState?.disabled === true || isLoading;
|
|
429
493
|
// Per ARIA, Space toggles a checkbox or switch; react-native-web only maps Space to buttons.
|
|
430
494
|
const toggleKeyDownProps: WebKeyDownProps =
|
|
431
495
|
explicitAccessibilityRole === "checkbox" || explicitAccessibilityRole === "switch"
|
|
@@ -450,7 +514,10 @@ const BoxComponent = React.forwardRef((props: BoxProps, ref) => {
|
|
|
450
514
|
? {accessibilityRole: explicitAccessibilityRole as never}
|
|
451
515
|
: {})}
|
|
452
516
|
{...accessibilityStateProps}
|
|
453
|
-
aria-label={
|
|
517
|
+
aria-label={
|
|
518
|
+
loadingAccessibilityProps.accessibilityLabel ??
|
|
519
|
+
(props as AccessibilityProps).accessibilityLabel
|
|
520
|
+
}
|
|
454
521
|
aria-role="button"
|
|
455
522
|
{...(isDisabled ? {disabled: true} : {})}
|
|
456
523
|
onLayout={props.onLayout}
|
|
@@ -466,12 +533,14 @@ const BoxComponent = React.forwardRef((props: BoxProps, ref) => {
|
|
|
466
533
|
style={boxStyle}
|
|
467
534
|
testID={resolvedTestID ? `${resolvedTestID}-clickable` : undefined}
|
|
468
535
|
>
|
|
469
|
-
{
|
|
536
|
+
{children}
|
|
470
537
|
</Pressable>
|
|
471
538
|
);
|
|
472
539
|
} else {
|
|
473
540
|
const accessibilityHint = (props as AccessibilityProps).accessibilityHint;
|
|
474
|
-
const accessibilityLabel =
|
|
541
|
+
const accessibilityLabel =
|
|
542
|
+
loadingAccessibilityProps.accessibilityLabel ??
|
|
543
|
+
(props as AccessibilityProps).accessibilityLabel;
|
|
475
544
|
box = (
|
|
476
545
|
<View
|
|
477
546
|
{...(accessibilityHint ? {accessibilityHint} : {})}
|
|
@@ -484,7 +553,7 @@ const BoxComponent = React.forwardRef((props: BoxProps, ref) => {
|
|
|
484
553
|
style={boxStyle}
|
|
485
554
|
testID={resolvedTestID}
|
|
486
555
|
>
|
|
487
|
-
{
|
|
556
|
+
{children}
|
|
488
557
|
</View>
|
|
489
558
|
);
|
|
490
559
|
}
|
package/src/Card.test.tsx
CHANGED
|
@@ -4,9 +4,13 @@ import {useWindowDimensions} from "react-native";
|
|
|
4
4
|
import type {ReactTestRendererJSON} from "react-test-renderer";
|
|
5
5
|
|
|
6
6
|
import {Card} from "./Card";
|
|
7
|
+
import {SkeletonCircle} from "./Skeleton";
|
|
7
8
|
import {Text} from "./Text";
|
|
8
9
|
import {renderWithTheme} from "./test-utils";
|
|
9
10
|
|
|
11
|
+
// Skeletons are hidden from assistive tech, so queries opt in to hidden elements.
|
|
12
|
+
const HIDDEN = {includeHiddenElements: true};
|
|
13
|
+
|
|
10
14
|
type WindowDimensionsImpl = () => ScaledSize;
|
|
11
15
|
type MockableUseWindowDimensions = WindowDimensionsImpl & {
|
|
12
16
|
mockImplementation?: (impl: WindowDimensionsImpl) => void;
|
|
@@ -180,4 +184,48 @@ describe("Card", () => {
|
|
|
180
184
|
expect(getByTestId("display-card")).toBeTruthy();
|
|
181
185
|
});
|
|
182
186
|
});
|
|
187
|
+
|
|
188
|
+
describe("loading", () => {
|
|
189
|
+
it("renders a card skeleton with media for a display card with an image", () => {
|
|
190
|
+
const {getByTestId, queryByText} = renderWithTheme(
|
|
191
|
+
<Card
|
|
192
|
+
description="Description"
|
|
193
|
+
imageUri="https://example.com/image.png"
|
|
194
|
+
loading
|
|
195
|
+
testID="card"
|
|
196
|
+
title="Title"
|
|
197
|
+
variant="display"
|
|
198
|
+
/>
|
|
199
|
+
);
|
|
200
|
+
expect(queryByText("Title")).toBeNull();
|
|
201
|
+
expect(getByTestId("card").props["aria-busy"]).toBe(true);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it("sizes the media skeleton to the large mobile image height", () => {
|
|
205
|
+
const {UNSAFE_root} = renderWithTheme(
|
|
206
|
+
<Card
|
|
207
|
+
imageUri="https://example.com/image.png"
|
|
208
|
+
loading
|
|
209
|
+
size="large"
|
|
210
|
+
testID="card"
|
|
211
|
+
title="Title"
|
|
212
|
+
variant="display"
|
|
213
|
+
/>
|
|
214
|
+
);
|
|
215
|
+
const mediaBlocks = UNSAFE_root.findAll(
|
|
216
|
+
(node) => node.props["aria-hidden"] === true && node.props.style?.height === 300
|
|
217
|
+
);
|
|
218
|
+
expect(mediaBlocks.length).toBeGreaterThan(0);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it("renders a custom loading component in a container card", () => {
|
|
222
|
+
const {getByTestId, queryByText} = renderWithTheme(
|
|
223
|
+
<Card loading loadingComponent={<SkeletonCircle testID="circle" />}>
|
|
224
|
+
<Text>Body</Text>
|
|
225
|
+
</Card>
|
|
226
|
+
);
|
|
227
|
+
expect(getByTestId("circle", HIDDEN)).toBeTruthy();
|
|
228
|
+
expect(queryByText("Body")).toBeNull();
|
|
229
|
+
});
|
|
230
|
+
});
|
|
183
231
|
});
|
package/src/Card.tsx
CHANGED
|
@@ -5,6 +5,8 @@ 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";
|
|
9
|
+
import {SkeletonCard} from "./Skeleton";
|
|
8
10
|
import {Text} from "./Text";
|
|
9
11
|
|
|
10
12
|
const DEFAULT_DISPLAY_CARD_WIDTH = 600;
|
|
@@ -13,7 +15,6 @@ const MOBILE_ROW_IMAGE_WIDTH = 100;
|
|
|
13
15
|
const DESKTOP_ROW_IMAGE_WIDTH = 160;
|
|
14
16
|
const MOBILE_LARGE_IMAGE_HEIGHT = 300;
|
|
15
17
|
const TITLE_DESCRIPTION_GAP = 2;
|
|
16
|
-
const MOBILE_BREAKPOINT = 768;
|
|
17
18
|
|
|
18
19
|
const getDisplayCardWidth = ({
|
|
19
20
|
isMobile,
|
|
@@ -50,6 +51,7 @@ const DisplayCard = ({
|
|
|
50
51
|
imageAlt,
|
|
51
52
|
imageHeight = 160,
|
|
52
53
|
isMobile,
|
|
54
|
+
loadingComponent,
|
|
53
55
|
maxWidth = "100%",
|
|
54
56
|
minWidth = 0,
|
|
55
57
|
overflow = "hidden",
|
|
@@ -91,6 +93,15 @@ const DisplayCard = ({
|
|
|
91
93
|
rounding="md"
|
|
92
94
|
width={cardWidth ?? (isMobile ? "100%" : undefined)}
|
|
93
95
|
{...rest}
|
|
96
|
+
loadingComponent={
|
|
97
|
+
loadingComponent ?? (
|
|
98
|
+
<SkeletonCard
|
|
99
|
+
mediaHeight={columnImageHeight}
|
|
100
|
+
showAvatar={false}
|
|
101
|
+
showMedia={Boolean(imageUri)}
|
|
102
|
+
/>
|
|
103
|
+
)
|
|
104
|
+
}
|
|
94
105
|
>
|
|
95
106
|
{imageUri && (
|
|
96
107
|
<Image
|
|
@@ -175,7 +186,7 @@ const ContainerCard = ({
|
|
|
175
186
|
|
|
176
187
|
export const Card = ({variant = "container", ...props}: CardProps): React.ReactElement => {
|
|
177
188
|
const {width: windowWidth} = useWindowDimensions();
|
|
178
|
-
const isMobile = windowWidth
|
|
189
|
+
const isMobile = !isSupportedDesktopWidth({width: windowWidth});
|
|
179
190
|
|
|
180
191
|
if (variant === "display") {
|
|
181
192
|
return <DisplayCard {...props} isMobile={isMobile} variant={variant} />;
|
package/src/ChartCard.test.tsx
CHANGED
|
@@ -4,9 +4,13 @@ import {assert} from "chai";
|
|
|
4
4
|
|
|
5
5
|
import {ChartCard} from "./ChartCard";
|
|
6
6
|
import {ChartCard as RootChartCard} from "./index";
|
|
7
|
+
import {Skeleton} from "./Skeleton";
|
|
7
8
|
import {Text} from "./Text";
|
|
8
9
|
import {renderWithTheme} from "./test-utils";
|
|
9
10
|
|
|
11
|
+
// Skeletons are hidden from assistive tech, so queries opt in to hidden elements.
|
|
12
|
+
const HIDDEN = {includeHiddenElements: true};
|
|
13
|
+
|
|
10
14
|
describe("ChartCard", () => {
|
|
11
15
|
it("renders title, filter summary, period badge, and children", () => {
|
|
12
16
|
const {getByText} = renderWithTheme(
|
|
@@ -76,4 +80,30 @@ describe("ChartCard", () => {
|
|
|
76
80
|
it("is available from the package root lazy boundary", () => {
|
|
77
81
|
assert.isFunction(RootChartCard);
|
|
78
82
|
});
|
|
83
|
+
|
|
84
|
+
it("keeps the title and shows a skeleton in place of the body while loading", () => {
|
|
85
|
+
const {getByTestId, getByText, queryByText} = renderWithTheme(
|
|
86
|
+
<ChartCard loading testID="chart-card" title="Conversions">
|
|
87
|
+
<Text>Body</Text>
|
|
88
|
+
</ChartCard>
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
assert.exists(getByText("Conversions"));
|
|
92
|
+
assert.notExists(queryByText("Body"));
|
|
93
|
+
assert.isTrue(getByTestId("chart-card.loading").props["aria-busy"]);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("renders a custom loading component", () => {
|
|
97
|
+
const {getByTestId} = renderWithTheme(
|
|
98
|
+
<ChartCard
|
|
99
|
+
loading
|
|
100
|
+
loadingComponent={<Skeleton height={80} testID="custom-skeleton" />}
|
|
101
|
+
title="Conversions"
|
|
102
|
+
>
|
|
103
|
+
<Text>Body</Text>
|
|
104
|
+
</ChartCard>
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
assert.equal(getByTestId("custom-skeleton", HIDDEN).props.style.height, 80);
|
|
108
|
+
});
|
|
79
109
|
});
|