@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
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
import {DateTime} from "luxon";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
import {useCallback, useState} from "react";
|
|
4
|
+
|
|
5
|
+
import {Badge} from "./Badge";
|
|
6
|
+
import {Box} from "./Box";
|
|
7
|
+
import {Button} from "./Button";
|
|
8
|
+
import {Card} from "./Card";
|
|
9
|
+
import type {BadgeProps} from "./Common";
|
|
10
|
+
import {Heading} from "./Heading";
|
|
11
|
+
import {MarkdownView} from "./MarkdownView";
|
|
12
|
+
import {Modal} from "./Modal";
|
|
13
|
+
import {buildConsentPdfHtml, printConsentHtml} from "./pdfHtmlTemplate";
|
|
14
|
+
import {Spinner} from "./Spinner";
|
|
15
|
+
import {Text} from "./Text";
|
|
16
|
+
import {TextField} from "./TextField";
|
|
17
|
+
import {applyConsentVariables, detectLocale, resolveConsentLocale} from "./useConsentForms";
|
|
18
|
+
import {
|
|
19
|
+
type ProvisionalConsentResponse,
|
|
20
|
+
type ProvisionalConsentStatusRow,
|
|
21
|
+
provisionalSignerName,
|
|
22
|
+
useProvisionalConsent,
|
|
23
|
+
} from "./useProvisionalConsent";
|
|
24
|
+
|
|
25
|
+
export interface ProvisionalConsentSignerProps {
|
|
26
|
+
/** The consumer's RTK Query api, as passed to `ConsentNavigator`. */
|
|
27
|
+
api: unknown;
|
|
28
|
+
baseUrl?: string;
|
|
29
|
+
/** The user whose consent forms are listed and signed on their behalf. */
|
|
30
|
+
userId: string;
|
|
31
|
+
/** Called with the stored response after a provisional signature succeeds. */
|
|
32
|
+
onSigned?: (response: ProvisionalConsentResponse) => void;
|
|
33
|
+
/** Called with the server error when signing fails. */
|
|
34
|
+
onError?: (error: unknown) => void;
|
|
35
|
+
/** Values for `{{name}}` placeholders in form content. */
|
|
36
|
+
variables?: Record<string, string>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface SignedSummary {
|
|
40
|
+
formId: string;
|
|
41
|
+
formTitle: string;
|
|
42
|
+
signerName: string;
|
|
43
|
+
signedAt: string;
|
|
44
|
+
/** The just-signed form as a provisional row, for printing before statuses refetch. */
|
|
45
|
+
row: ProvisionalConsentStatusRow;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const STATUS_BADGE: Record<ProvisionalConsentStatusRow["status"], BadgeProps["status"]> = {
|
|
49
|
+
declined: "error",
|
|
50
|
+
pending: "warning",
|
|
51
|
+
provisional: "info",
|
|
52
|
+
signed: "success",
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/** " on <date>", or nothing when the date is missing or unparseable. */
|
|
56
|
+
const onDate = (iso?: string): string => {
|
|
57
|
+
const date = iso ? DateTime.fromISO(iso) : undefined;
|
|
58
|
+
if (!date?.isValid) {
|
|
59
|
+
return "";
|
|
60
|
+
}
|
|
61
|
+
return ` on ${date.toLocaleString(DateTime.DATETIME_MED)}`;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/** The status line for a row, e.g. "Signed provisionally by Dana Rivera on Oct 20, 2026, 3:30 PM". */
|
|
65
|
+
const provisionalConsentStatusLabel = (row: ProvisionalConsentStatusRow): string => {
|
|
66
|
+
if (row.status === "provisional") {
|
|
67
|
+
const signerName = provisionalSignerName(row.provisional?.signedBy);
|
|
68
|
+
return `Signed provisionally by ${signerName}${onDate(row.provisional?.signedAt)}`;
|
|
69
|
+
}
|
|
70
|
+
if (row.status === "signed") {
|
|
71
|
+
return `Signed by user${onDate(row.respondedAt)}`;
|
|
72
|
+
}
|
|
73
|
+
if (row.status === "declined") {
|
|
74
|
+
return `Declined by user${onDate(row.respondedAt)}`;
|
|
75
|
+
}
|
|
76
|
+
return "Pending";
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const errorMessage = (error: unknown, fallback: string): string => {
|
|
80
|
+
const title = (error as {data?: {title?: unknown}} | undefined)?.data?.title;
|
|
81
|
+
if (typeof title === "string" && title.length > 0) {
|
|
82
|
+
return title;
|
|
83
|
+
}
|
|
84
|
+
return fallback;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// Only pending forms can be signed on the user's behalf: the user's own answer always decides
|
|
88
|
+
// the status, so a provisional signature on a declined form would change nothing.
|
|
89
|
+
const CAN_SIGN_STATUSES = new Set<ProvisionalConsentStatusRow["status"]>(["pending"]);
|
|
90
|
+
|
|
91
|
+
const contentFor = (
|
|
92
|
+
row: ProvisionalConsentStatusRow,
|
|
93
|
+
variables?: Record<string, string>
|
|
94
|
+
): string => {
|
|
95
|
+
const locale = resolveConsentLocale(row.form, detectLocale());
|
|
96
|
+
return applyConsentVariables(
|
|
97
|
+
row.form.content[locale] ?? row.form.content[row.form.defaultLocale] ?? "",
|
|
98
|
+
variables
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/** Printable HTML for a row: the form content, its status, and any provisional signature. */
|
|
103
|
+
const rowPrintHtml = (
|
|
104
|
+
row: ProvisionalConsentStatusRow,
|
|
105
|
+
variables?: Record<string, string>
|
|
106
|
+
): string => {
|
|
107
|
+
return buildConsentPdfHtml({
|
|
108
|
+
contentSnapshot: contentFor(row, variables),
|
|
109
|
+
fields: [
|
|
110
|
+
{label: "Status:", value: provisionalConsentStatusLabel(row)},
|
|
111
|
+
{label: "Form Version:", value: String(row.form.version)},
|
|
112
|
+
],
|
|
113
|
+
formTitle: row.form.title,
|
|
114
|
+
provisionalSignature: row.provisional
|
|
115
|
+
? {
|
|
116
|
+
note: row.provisional.note,
|
|
117
|
+
signedAt: row.provisional.signedAt,
|
|
118
|
+
signedByName: provisionalSignerName(row.provisional.signedBy),
|
|
119
|
+
}
|
|
120
|
+
: undefined,
|
|
121
|
+
responseId: row.provisional?.responseId,
|
|
122
|
+
title: "Consent Record",
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const printRow = async (
|
|
127
|
+
row: ProvisionalConsentStatusRow,
|
|
128
|
+
variables?: Record<string, string>
|
|
129
|
+
): Promise<void> => {
|
|
130
|
+
try {
|
|
131
|
+
await printConsentHtml({html: rowPrintHtml(row, variables)});
|
|
132
|
+
} catch (printError) {
|
|
133
|
+
console.warn("[ProvisionalConsentSigner] Printing failed", {printError});
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const rowFormId = (row: ProvisionalConsentStatusRow): string => row.form.id ?? row.form._id ?? "";
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Lists a user's consent forms with their status so staff can record consent on the user's
|
|
141
|
+
* behalf. Requires `consentResponse:signOnBehalf` (or `user.admin` without RBAC) on the server.
|
|
142
|
+
*/
|
|
143
|
+
export const ProvisionalConsentSigner: React.FC<ProvisionalConsentSignerProps> = ({
|
|
144
|
+
api,
|
|
145
|
+
baseUrl,
|
|
146
|
+
userId,
|
|
147
|
+
onSigned,
|
|
148
|
+
onError,
|
|
149
|
+
variables,
|
|
150
|
+
}) => {
|
|
151
|
+
const {error, isLoading, isSigning, isVoiding, refetch, sign, statuses, voidSignature} =
|
|
152
|
+
useProvisionalConsent({
|
|
153
|
+
api,
|
|
154
|
+
baseUrl,
|
|
155
|
+
userId,
|
|
156
|
+
});
|
|
157
|
+
const [openFormId, setOpenFormId] = useState<string | null>(null);
|
|
158
|
+
const [note, setNote] = useState("");
|
|
159
|
+
const [submitError, setSubmitError] = useState<string | null>(null);
|
|
160
|
+
const [signed, setSigned] = useState<SignedSummary | null>(null);
|
|
161
|
+
const [voidRow, setVoidRow] = useState<ProvisionalConsentStatusRow | null>(null);
|
|
162
|
+
const [voidReason, setVoidReason] = useState("");
|
|
163
|
+
const [voidError, setVoidError] = useState<string | null>(null);
|
|
164
|
+
|
|
165
|
+
const openRow = statuses.find((row) => rowFormId(row) === openFormId);
|
|
166
|
+
const locale = openRow ? resolveConsentLocale(openRow.form, detectLocale()) : undefined;
|
|
167
|
+
const isNoteBlank = note.trim().length === 0;
|
|
168
|
+
|
|
169
|
+
const handleOpen = useCallback((formId: string): void => {
|
|
170
|
+
setOpenFormId(formId);
|
|
171
|
+
setNote("");
|
|
172
|
+
setSubmitError(null);
|
|
173
|
+
setSigned(null);
|
|
174
|
+
}, []);
|
|
175
|
+
|
|
176
|
+
const handleCancel = useCallback((): void => {
|
|
177
|
+
setOpenFormId(null);
|
|
178
|
+
setSubmitError(null);
|
|
179
|
+
}, []);
|
|
180
|
+
|
|
181
|
+
const handleSubmit = useCallback(async (): Promise<void> => {
|
|
182
|
+
if (!openRow || isNoteBlank) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
setSubmitError(null);
|
|
186
|
+
try {
|
|
187
|
+
const response = await sign({consentFormId: rowFormId(openRow), locale, note: note.trim()});
|
|
188
|
+
const signerName = provisionalSignerName(response.provisionalSignedBy);
|
|
189
|
+
setSigned({
|
|
190
|
+
formId: rowFormId(openRow),
|
|
191
|
+
formTitle: openRow.form.title,
|
|
192
|
+
row: {
|
|
193
|
+
form: openRow.form,
|
|
194
|
+
isConsented: true,
|
|
195
|
+
provisional: {
|
|
196
|
+
note: response.provisionalNote ?? note.trim(),
|
|
197
|
+
responseId: response._id,
|
|
198
|
+
signedAt: response.agreedAt,
|
|
199
|
+
signedBy: {id: "", name: signerName},
|
|
200
|
+
},
|
|
201
|
+
respondedAt: response.agreedAt,
|
|
202
|
+
status: "provisional",
|
|
203
|
+
},
|
|
204
|
+
signedAt: response.agreedAt,
|
|
205
|
+
signerName,
|
|
206
|
+
});
|
|
207
|
+
setOpenFormId(null);
|
|
208
|
+
setNote("");
|
|
209
|
+
onSigned?.(response);
|
|
210
|
+
} catch (signError) {
|
|
211
|
+
console.warn("[ProvisionalConsentSigner] Provisional signature failed", {signError});
|
|
212
|
+
setSubmitError(errorMessage(signError, "Could not sign the form."));
|
|
213
|
+
onError?.(signError);
|
|
214
|
+
}
|
|
215
|
+
}, [isNoteBlank, locale, note, onError, onSigned, openRow, sign]);
|
|
216
|
+
|
|
217
|
+
const handleOpenVoid = useCallback((row: ProvisionalConsentStatusRow): void => {
|
|
218
|
+
setVoidRow(row);
|
|
219
|
+
setVoidReason("");
|
|
220
|
+
setVoidError(null);
|
|
221
|
+
}, []);
|
|
222
|
+
|
|
223
|
+
const handleCloseVoid = useCallback((): void => {
|
|
224
|
+
setVoidRow(null);
|
|
225
|
+
setVoidError(null);
|
|
226
|
+
}, []);
|
|
227
|
+
|
|
228
|
+
const handleVoid = useCallback(async (): Promise<void> => {
|
|
229
|
+
const responseId = voidRow?.provisional?.responseId;
|
|
230
|
+
if (!responseId || voidReason.trim().length === 0) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
setVoidError(null);
|
|
234
|
+
try {
|
|
235
|
+
await voidSignature({reason: voidReason.trim(), responseId});
|
|
236
|
+
} catch (voidFailure) {
|
|
237
|
+
console.warn("[ProvisionalConsentSigner] Voiding failed", {voidFailure});
|
|
238
|
+
setVoidError(errorMessage(voidFailure, "Could not void the signature."));
|
|
239
|
+
onError?.(voidFailure);
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
setVoidRow(null);
|
|
243
|
+
setSigned(null);
|
|
244
|
+
await refetch();
|
|
245
|
+
}, [onError, refetch, voidReason, voidRow, voidSignature]);
|
|
246
|
+
|
|
247
|
+
if (isLoading) {
|
|
248
|
+
return (
|
|
249
|
+
<Box alignItems="center" padding={4} testID="provisional-consent-signer">
|
|
250
|
+
<Box testID="provisional-consent-loading">
|
|
251
|
+
<Spinner />
|
|
252
|
+
</Box>
|
|
253
|
+
</Box>
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (error) {
|
|
258
|
+
return (
|
|
259
|
+
<Box gap={3} padding={4} testID="provisional-consent-signer">
|
|
260
|
+
<Box testID="provisional-consent-error">
|
|
261
|
+
<Text color="error">{errorMessage(error, "Could not load consent forms.")}</Text>
|
|
262
|
+
</Box>
|
|
263
|
+
<Box width={160}>
|
|
264
|
+
<Button
|
|
265
|
+
onClick={() => refetch()}
|
|
266
|
+
testID="provisional-consent-retry-button"
|
|
267
|
+
text="Retry"
|
|
268
|
+
variant="outline"
|
|
269
|
+
/>
|
|
270
|
+
</Box>
|
|
271
|
+
</Box>
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (openRow) {
|
|
276
|
+
const content = contentFor(openRow, variables);
|
|
277
|
+
return (
|
|
278
|
+
<Box gap={3} testID="provisional-consent-signer">
|
|
279
|
+
<Heading size="md">{openRow.form.title}</Heading>
|
|
280
|
+
<Card testID="provisional-consent-form-content">
|
|
281
|
+
<MarkdownView>{content}</MarkdownView>
|
|
282
|
+
</Card>
|
|
283
|
+
<TextField
|
|
284
|
+
helperText="Required. How and from whom consent was obtained."
|
|
285
|
+
multiline
|
|
286
|
+
onChange={setNote}
|
|
287
|
+
rows={4}
|
|
288
|
+
testID="provisional-consent-note-input"
|
|
289
|
+
title="Note"
|
|
290
|
+
value={note}
|
|
291
|
+
/>
|
|
292
|
+
{Boolean(submitError) && (
|
|
293
|
+
<Text color="error" testID="provisional-consent-submit-error">
|
|
294
|
+
{submitError}
|
|
295
|
+
</Text>
|
|
296
|
+
)}
|
|
297
|
+
<Box direction="row" gap={3}>
|
|
298
|
+
<Button
|
|
299
|
+
disabled={isNoteBlank}
|
|
300
|
+
loading={isSigning}
|
|
301
|
+
onClick={handleSubmit}
|
|
302
|
+
testID="provisional-consent-submit-button"
|
|
303
|
+
text="Sign provisionally"
|
|
304
|
+
/>
|
|
305
|
+
<Button
|
|
306
|
+
onClick={handleCancel}
|
|
307
|
+
testID="provisional-consent-cancel-button"
|
|
308
|
+
text="Cancel"
|
|
309
|
+
variant="muted"
|
|
310
|
+
/>
|
|
311
|
+
</Box>
|
|
312
|
+
</Box>
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
return (
|
|
317
|
+
<Box gap={3} testID="provisional-consent-signer">
|
|
318
|
+
{signed && (
|
|
319
|
+
<Card testID="provisional-consent-success">
|
|
320
|
+
<Box gap={2}>
|
|
321
|
+
<Text>
|
|
322
|
+
{`${signed.formTitle} signed provisionally by ${signed.signerName}${onDate(
|
|
323
|
+
signed.signedAt
|
|
324
|
+
)}`}
|
|
325
|
+
</Text>
|
|
326
|
+
<Box alignSelf="start">
|
|
327
|
+
<Button
|
|
328
|
+
iconName="print"
|
|
329
|
+
onClick={() => printRow(signed.row, variables)}
|
|
330
|
+
testID="provisional-consent-success-print"
|
|
331
|
+
text="Print"
|
|
332
|
+
variant="outline"
|
|
333
|
+
/>
|
|
334
|
+
</Box>
|
|
335
|
+
</Box>
|
|
336
|
+
</Card>
|
|
337
|
+
)}
|
|
338
|
+
{statuses.length === 0 && (
|
|
339
|
+
<Text color="secondaryDark" testID="provisional-consent-empty">
|
|
340
|
+
No consent forms apply to this user.
|
|
341
|
+
</Text>
|
|
342
|
+
)}
|
|
343
|
+
{statuses.map((row) => {
|
|
344
|
+
const formId = rowFormId(row);
|
|
345
|
+
return (
|
|
346
|
+
<Card key={formId} testID={`provisional-consent-row-${formId}`}>
|
|
347
|
+
<Box gap={2}>
|
|
348
|
+
<Heading size="sm">{row.form.title}</Heading>
|
|
349
|
+
<Box alignSelf="start">
|
|
350
|
+
<Badge
|
|
351
|
+
status={STATUS_BADGE[row.status]}
|
|
352
|
+
testID={`provisional-consent-status-${formId}`}
|
|
353
|
+
value={provisionalConsentStatusLabel(row)}
|
|
354
|
+
/>
|
|
355
|
+
</Box>
|
|
356
|
+
<Box direction="row" gap={2} wrap>
|
|
357
|
+
{CAN_SIGN_STATUSES.has(row.status) && (
|
|
358
|
+
<Button
|
|
359
|
+
onClick={() => handleOpen(formId)}
|
|
360
|
+
testID={`provisional-consent-open-${formId}`}
|
|
361
|
+
text="Sign on behalf"
|
|
362
|
+
variant="outline"
|
|
363
|
+
/>
|
|
364
|
+
)}
|
|
365
|
+
{row.status !== "pending" && (
|
|
366
|
+
<Button
|
|
367
|
+
iconName="print"
|
|
368
|
+
onClick={() => printRow(row, variables)}
|
|
369
|
+
testID={`provisional-consent-print-${formId}`}
|
|
370
|
+
text="Print"
|
|
371
|
+
variant="outline"
|
|
372
|
+
/>
|
|
373
|
+
)}
|
|
374
|
+
{row.status === "provisional" && (
|
|
375
|
+
<Button
|
|
376
|
+
onClick={() => handleOpenVoid(row)}
|
|
377
|
+
testID={`provisional-consent-void-${formId}`}
|
|
378
|
+
text="Void"
|
|
379
|
+
variant="destructive"
|
|
380
|
+
/>
|
|
381
|
+
)}
|
|
382
|
+
</Box>
|
|
383
|
+
</Box>
|
|
384
|
+
</Card>
|
|
385
|
+
);
|
|
386
|
+
})}
|
|
387
|
+
<Modal
|
|
388
|
+
onDismiss={handleCloseVoid}
|
|
389
|
+
primaryButtonDisabled={voidReason.trim().length === 0 || isVoiding}
|
|
390
|
+
primaryButtonOnClick={handleVoid}
|
|
391
|
+
primaryButtonText="Void signature"
|
|
392
|
+
secondaryButtonOnClick={handleCloseVoid}
|
|
393
|
+
secondaryButtonText="Cancel"
|
|
394
|
+
size="md"
|
|
395
|
+
testID="provisional-consent-void-modal"
|
|
396
|
+
text={
|
|
397
|
+
voidRow
|
|
398
|
+
? `The provisional signature on ${voidRow.form.title} will no longer count as consent. The record is kept.`
|
|
399
|
+
: undefined
|
|
400
|
+
}
|
|
401
|
+
title="Void provisional signature"
|
|
402
|
+
visible={Boolean(voidRow)}
|
|
403
|
+
>
|
|
404
|
+
<Box gap={2}>
|
|
405
|
+
<TextField
|
|
406
|
+
helperText="Required. Why this signature was made in error."
|
|
407
|
+
multiline
|
|
408
|
+
onChange={setVoidReason}
|
|
409
|
+
rows={3}
|
|
410
|
+
testID="provisional-consent-void-reason-input"
|
|
411
|
+
title="Reason"
|
|
412
|
+
value={voidReason}
|
|
413
|
+
/>
|
|
414
|
+
{Boolean(voidError) && (
|
|
415
|
+
<Text color="error" testID="provisional-consent-void-error">
|
|
416
|
+
{voidError}
|
|
417
|
+
</Text>
|
|
418
|
+
)}
|
|
419
|
+
</Box>
|
|
420
|
+
</Modal>
|
|
421
|
+
</Box>
|
|
422
|
+
);
|
|
423
|
+
};
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
getBreakpointForWidth,
|
|
12
12
|
isBreakpointAtLeast,
|
|
13
13
|
isSupportedDesktopViewport,
|
|
14
|
+
isSupportedDesktopWidth,
|
|
14
15
|
type ResponsiveBreakpointStore,
|
|
15
16
|
useResponsiveBreakpoint,
|
|
16
17
|
} from "./ResponsiveBreakpoint";
|
|
@@ -61,6 +62,12 @@ describe("ResponsiveBreakpoint", () => {
|
|
|
61
62
|
assert.isTrue(isSupportedDesktopViewport({breakpoint: "xl", surface: "native"}));
|
|
62
63
|
assert.isFalse(isSupportedDesktopViewport({breakpoint: "md", surface: "web"}));
|
|
63
64
|
assert.isTrue(isSupportedDesktopViewport({breakpoint: "lg", surface: "web"}));
|
|
65
|
+
assert.isFalse(isSupportedDesktopWidth({surface: "web", width: 768}));
|
|
66
|
+
assert.isFalse(isSupportedDesktopWidth({surface: "native", width: 768}));
|
|
67
|
+
assert.isFalse(isSupportedDesktopWidth({surface: "web", width: 1023}));
|
|
68
|
+
assert.isTrue(isSupportedDesktopWidth({surface: "web", width: 1024}));
|
|
69
|
+
assert.isFalse(isSupportedDesktopWidth({surface: "native", width: 1023}));
|
|
70
|
+
assert.isTrue(isSupportedDesktopWidth({surface: "native", width: 1024}));
|
|
64
71
|
});
|
|
65
72
|
|
|
66
73
|
it("compares breakpoints without reading Dimensions", () => {
|
|
@@ -116,6 +116,20 @@ export const isSupportedDesktopViewport = ({
|
|
|
116
116
|
return isBreakpointAtLeast({breakpoint, minimum: "xl"});
|
|
117
117
|
};
|
|
118
118
|
|
|
119
|
+
/** True when `width` is at or above the desktop floor for `surface` (web `lg`, native `xl`). */
|
|
120
|
+
export const isSupportedDesktopWidth = ({
|
|
121
|
+
surface = getBreakpointSurface(),
|
|
122
|
+
width,
|
|
123
|
+
}: {
|
|
124
|
+
surface?: BreakpointSurface;
|
|
125
|
+
width: number;
|
|
126
|
+
}): boolean => {
|
|
127
|
+
return isSupportedDesktopViewport({
|
|
128
|
+
breakpoint: getBreakpointForWidth(width, surface),
|
|
129
|
+
surface,
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
|
|
119
133
|
const getServerBreakpointSnapshot = (): ResponsiveBreakpoint => {
|
|
120
134
|
return "xs";
|
|
121
135
|
};
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
GPTChat,
|
|
12
12
|
LineChart,
|
|
13
13
|
MarkdownEditor,
|
|
14
|
+
ProvisionalConsentSigner,
|
|
14
15
|
} from "@terreno/ui";
|
|
15
16
|
import {Box} from "@terreno/ui/Box";
|
|
16
17
|
import EmojiSelectorSubpath from "@terreno/ui/EmojiSelector";
|
|
@@ -58,11 +59,13 @@ describe("root import compatibility", () => {
|
|
|
58
59
|
expect(modulePaths.includes("/AreaChart.tsx")).toBe(false);
|
|
59
60
|
expect(modulePaths.includes("/DonutChart.tsx")).toBe(false);
|
|
60
61
|
expect(modulePaths.includes("/DashboardGrid.tsx")).toBe(true);
|
|
62
|
+
expect(modulePaths.includes("/ProvisionalConsentSigner.tsx")).toBe(false);
|
|
61
63
|
});
|
|
62
64
|
|
|
63
65
|
it("exposes lazy root exports for measured heavy optional widgets", () => {
|
|
64
66
|
expect(AIRequestExplorer).toBeTruthy();
|
|
65
67
|
expect(ConsentNavigator).toBeTruthy();
|
|
68
|
+
expect(ProvisionalConsentSigner).toBeTruthy();
|
|
66
69
|
expect(DraggableList).toBeTruthy();
|
|
67
70
|
expect(EmojiSelector).toBeTruthy();
|
|
68
71
|
expect(GPTChat).toBeTruthy();
|
package/src/Scorecard.test.tsx
CHANGED
|
@@ -62,4 +62,15 @@ describe("Scorecard", () => {
|
|
|
62
62
|
it("is available from the package root lazy boundary", () => {
|
|
63
63
|
assert.isFunction(RootScorecard);
|
|
64
64
|
});
|
|
65
|
+
|
|
66
|
+
it("keeps the title and hides the value while loading", () => {
|
|
67
|
+
const {getByText, queryByTestId} = renderWithTheme(
|
|
68
|
+
<Scorecard loading sparklineData={CURRENT} testID="score" title="Visits" value={42} />
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
assert.exists(getByText("Visits"));
|
|
72
|
+
assert.notExists(queryByTestId("score.value"));
|
|
73
|
+
assert.notExists(queryByTestId("score.sparkline"));
|
|
74
|
+
assert.exists(queryByTestId("score.loading"));
|
|
75
|
+
});
|
|
65
76
|
});
|
package/src/Scorecard.tsx
CHANGED
|
@@ -4,12 +4,20 @@ import {Box} from "./Box";
|
|
|
4
4
|
import {ChartCard} from "./ChartCard";
|
|
5
5
|
import type {ScorecardProps} from "./Common";
|
|
6
6
|
import {Heading} from "./Heading";
|
|
7
|
+
import {Skeleton} from "./Skeleton";
|
|
7
8
|
import {SparklineChart} from "./SparklineChart";
|
|
8
9
|
import {resolveTestID} from "./testing/resolveTestId";
|
|
9
10
|
|
|
11
|
+
const SCORECARD_VALUE_SKELETON_HEIGHT = 32;
|
|
12
|
+
const SCORECARD_SPARKLINE_SKELETON_HEIGHT = 48;
|
|
13
|
+
|
|
10
14
|
export const Scorecard: FC<ScorecardProps> = ({
|
|
11
15
|
comparisonData,
|
|
12
16
|
formatValue = String,
|
|
17
|
+
loading,
|
|
18
|
+
loadingAnimation,
|
|
19
|
+
loadingComponent,
|
|
20
|
+
loadingLabel,
|
|
13
21
|
onPeriodPress,
|
|
14
22
|
periodLabel,
|
|
15
23
|
sparklineData,
|
|
@@ -21,6 +29,19 @@ export const Scorecard: FC<ScorecardProps> = ({
|
|
|
21
29
|
|
|
22
30
|
return (
|
|
23
31
|
<ChartCard
|
|
32
|
+
loading={loading}
|
|
33
|
+
loadingAnimation={loadingAnimation}
|
|
34
|
+
loadingComponent={
|
|
35
|
+
loadingComponent ?? (
|
|
36
|
+
<Box gap={2} width="100%">
|
|
37
|
+
<Skeleton height={SCORECARD_VALUE_SKELETON_HEIGHT} width="50%" />
|
|
38
|
+
{sparklineData !== undefined && (
|
|
39
|
+
<Skeleton height={SCORECARD_SPARKLINE_SKELETON_HEIGHT} />
|
|
40
|
+
)}
|
|
41
|
+
</Box>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
loadingLabel={loadingLabel}
|
|
24
45
|
onPeriodPress={onPeriodPress}
|
|
25
46
|
periodLabel={periodLabel}
|
|
26
47
|
testID={testID}
|