@terreno/ui 57.20.0 → 58.0.0-beta.1
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 +93 -0
- package/dist/ActionSheet.d.ts +9 -9
- package/dist/ActionSheet.d.ts.map +1 -1
- package/dist/ActionSheet.js +11 -4
- package/dist/ActionSheet.js.map +1 -1
- package/dist/AnnouncementNavigator.d.ts +7 -1
- package/dist/AnnouncementNavigator.d.ts.map +1 -1
- package/dist/AnnouncementNavigator.js +15 -16
- package/dist/AnnouncementNavigator.js.map +1 -1
- package/dist/Avatar.d.ts.map +1 -1
- package/dist/Avatar.js +1 -1
- package/dist/Avatar.js.map +1 -1
- package/dist/Box.d.ts.map +1 -1
- package/dist/Box.js +3 -1
- package/dist/Box.js.map +1 -1
- package/dist/Common.d.ts +71 -39
- package/dist/Common.d.ts.map +1 -1
- package/dist/Common.js.map +1 -1
- package/dist/ConsentFormScreen.d.ts.map +1 -1
- package/dist/ConsentFormScreen.js.map +1 -1
- package/dist/ConsentNavigator.d.ts +5 -3
- package/dist/ConsentNavigator.d.ts.map +1 -1
- package/dist/ConsentNavigator.js +4 -4
- package/dist/ConsentNavigator.js.map +1 -1
- package/dist/CustomSelectField.js.map +1 -1
- package/dist/DataTable.d.ts.map +1 -1
- package/dist/DataTable.js +37 -12
- package/dist/DataTable.js.map +1 -1
- package/dist/DateTimeField.js +6 -6
- package/dist/DateTimeField.js.map +1 -1
- package/dist/DropdownPanel.d.ts +0 -5
- package/dist/DropdownPanel.d.ts.map +1 -1
- package/dist/DropdownPanel.js +0 -5
- package/dist/DropdownPanel.js.map +1 -1
- package/dist/FilterAccordion.d.ts.map +1 -1
- package/dist/FilterAccordion.js.map +1 -1
- package/dist/FilterBoolean.d.ts.map +1 -1
- package/dist/FilterBoolean.js.map +1 -1
- package/dist/FilterSelectMenu.js +1 -1
- package/dist/FilterSelectMenu.js.map +1 -1
- package/dist/GPTChat.d.ts.map +1 -1
- package/dist/GPTChat.js.map +1 -1
- package/dist/Heading.d.ts.map +1 -1
- package/dist/Heading.js +6 -12
- package/dist/Heading.js.map +1 -1
- package/dist/HeightField.d.ts.map +1 -1
- package/dist/HeightField.js +9 -9
- package/dist/HeightField.js.map +1 -1
- package/dist/Hyperlink.d.ts.map +1 -1
- package/dist/Hyperlink.js +6 -1
- package/dist/Hyperlink.js.map +1 -1
- package/dist/Image.d.ts +1 -1
- package/dist/MarkdownEditorField.d.ts.map +1 -1
- package/dist/MarkdownEditorField.js +1 -1
- package/dist/MarkdownEditorField.js.map +1 -1
- package/dist/OfflineBanner.d.ts +3 -2
- package/dist/OfflineBanner.d.ts.map +1 -1
- package/dist/OfflineBanner.js +3 -2
- package/dist/OfflineBanner.js.map +1 -1
- package/dist/OtpField.d.ts.map +1 -1
- package/dist/OtpField.js +4 -4
- package/dist/OtpField.js.map +1 -1
- package/dist/PickerSelect.d.ts +4 -4
- package/dist/PickerSelect.d.ts.map +1 -1
- package/dist/PickerSelect.js +9 -9
- package/dist/PickerSelect.js.map +1 -1
- package/dist/ProvisionalConsentSigner.d.ts +3 -2
- package/dist/ProvisionalConsentSigner.d.ts.map +1 -1
- package/dist/ProvisionalConsentSigner.js +2 -2
- package/dist/ProvisionalConsentSigner.js.map +1 -1
- package/dist/SidebarNavigation.js +2 -2
- package/dist/SidebarNavigation.js.map +1 -1
- package/dist/SidebarNavigation.native.js +2 -2
- package/dist/SidebarNavigation.native.js.map +1 -1
- package/dist/Skeleton.js.map +1 -1
- package/dist/TapToEdit.d.ts +1 -1
- package/dist/TapToEdit.d.ts.map +1 -1
- package/dist/TapToEdit.js.map +1 -1
- package/dist/Text.d.ts.map +1 -1
- package/dist/Text.js +27 -50
- package/dist/Text.js.map +1 -1
- package/dist/TextField.d.ts.map +1 -1
- package/dist/TextField.js +4 -4
- package/dist/TextField.js.map +1 -1
- package/dist/Theme.d.ts.map +1 -1
- package/dist/Theme.js +16 -0
- package/dist/Theme.js.map +1 -1
- package/dist/ThumbsUpDownFeedback.d.ts.map +1 -1
- package/dist/ThumbsUpDownFeedback.js.map +1 -1
- package/dist/ToastNotifications.d.ts.map +1 -1
- package/dist/ToastNotifications.js.map +1 -1
- package/dist/Tooltip.d.ts.map +1 -1
- package/dist/Tooltip.js.map +1 -1
- package/dist/Unifier.d.ts +1 -1
- package/dist/WebAddressAutocomplete.js.map +1 -1
- package/dist/WebDropdownMenu.d.ts +3 -3
- package/dist/WebDropdownMenu.d.ts.map +1 -1
- package/dist/WebDropdownMenu.js +1 -1
- package/dist/WebDropdownMenu.js.map +1 -1
- package/dist/announcementPlatform.d.ts +5 -0
- package/dist/announcementPlatform.d.ts.map +1 -1
- package/dist/announcementPlatform.js +9 -0
- package/dist/announcementPlatform.js.map +1 -1
- package/dist/asks/AskCard.d.ts +2 -2
- package/dist/asks/AskCard.d.ts.map +1 -1
- package/dist/dataTableColumnWidths.d.ts +76 -0
- package/dist/dataTableColumnWidths.d.ts.map +1 -0
- package/dist/dataTableColumnWidths.js +181 -0
- package/dist/dataTableColumnWidths.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/login/LoginScreen.js.map +1 -1
- package/dist/requestClient.d.ts +71 -0
- package/dist/requestClient.d.ts.map +1 -0
- package/dist/requestClient.js +139 -0
- package/dist/requestClient.js.map +1 -0
- package/dist/security/PasswordCard.d.ts.map +1 -1
- package/dist/security/PasswordCard.js.map +1 -1
- package/dist/security/TwoFactorSettingsCard.d.ts.map +1 -1
- package/dist/security/TwoFactorSettingsCard.js +1 -1
- package/dist/security/TwoFactorSettingsCard.js.map +1 -1
- package/dist/signUp/SignUpScreen.js.map +1 -1
- package/dist/table/Table.d.ts.map +1 -1
- package/dist/table/Table.js.map +1 -1
- package/dist/table/TableTitle.d.ts.map +1 -1
- package/dist/table/TableTitle.js +2 -1
- package/dist/table/TableTitle.js.map +1 -1
- package/dist/textFontSizes.d.ts +12 -0
- package/dist/textFontSizes.d.ts.map +1 -0
- package/dist/textFontSizes.js +21 -0
- package/dist/textFontSizes.js.map +1 -0
- package/dist/useAcknowledgeAnnouncement.d.ts +8 -63
- package/dist/useAcknowledgeAnnouncement.d.ts.map +1 -1
- package/dist/useAcknowledgeAnnouncement.js +31 -80
- package/dist/useAcknowledgeAnnouncement.js.map +1 -1
- package/dist/useAnnouncements.d.ts +14 -47
- package/dist/useAnnouncements.d.ts.map +1 -1
- package/dist/useAnnouncements.js +30 -57
- package/dist/useAnnouncements.js.map +1 -1
- package/dist/useConsentForms.d.ts +6 -38
- package/dist/useConsentForms.d.ts.map +1 -1
- package/dist/useConsentForms.js +25 -48
- package/dist/useConsentForms.js.map +1 -1
- package/dist/useProvisionalConsent.d.ts +7 -58
- package/dist/useProvisionalConsent.d.ts.map +1 -1
- package/dist/useProvisionalConsent.js +57 -67
- package/dist/useProvisionalConsent.js.map +1 -1
- package/dist/useSubmitConsent.d.ts +9 -39
- package/dist/useSubmitConsent.d.ts.map +1 -1
- package/dist/useSubmitConsent.js +10 -39
- package/dist/useSubmitConsent.js.map +1 -1
- package/package.json +40 -38
- package/src/ActionSheet.test.tsx +13 -13
- package/src/ActionSheet.tsx +18 -5
- package/src/AddressField.test.tsx +9 -3
- package/src/AnnouncementNavigator.test.tsx +219 -319
- package/src/AnnouncementNavigator.tsx +25 -20
- package/src/Avatar.tsx +2 -9
- package/src/Badge.test.tsx +1 -1
- package/src/Banner.test.tsx +0 -1
- package/src/Box.test.tsx +85 -77
- package/src/Box.tsx +4 -2
- package/src/Button.test.tsx +11 -6
- package/src/Card.test.tsx +2 -2
- package/src/Common.ts +79 -44
- package/src/ConflictSheet.test.tsx +5 -5
- package/src/ConsentFormScreen.test.tsx +3 -1
- package/src/ConsentFormScreen.tsx +2 -1
- package/src/ConsentNavigator.test.tsx +166 -243
- package/src/ConsentNavigator.tsx +9 -13
- package/src/CustomSelectField.test.tsx +16 -4
- package/src/CustomSelectField.tsx +3 -3
- package/src/DataTable.test.tsx +73 -5
- package/src/DataTable.tsx +72 -19
- package/src/DataTableVirtualizationRegression.test.tsx +1 -0
- package/src/DateTimeActionSheet.test.tsx +2 -0
- package/src/DateTimeField.test.tsx +3 -12
- package/src/DateTimeField.tsx +10 -10
- package/src/DismissButton.test.tsx +22 -4
- package/src/DropdownPanel.tsx +0 -6
- package/src/EmailField.test.tsx +13 -22
- package/src/EmojiSelector.test.tsx +2 -2
- package/src/ErrorBoundary.test.tsx +5 -3
- package/src/Field.test.tsx +20 -44
- package/src/FilterAccordion.tsx +3 -3
- package/src/FilterBoolean.tsx +3 -3
- package/src/FilterSelectMenu.tsx +1 -1
- package/src/GPTChat.test.tsx +24 -16
- package/src/GPTChat.tsx +10 -9
- package/src/Heading.test.tsx +1 -1
- package/src/Heading.tsx +7 -14
- package/src/HeightField.tsx +17 -10
- package/src/Hyperlink.tsx +6 -3
- package/src/Icon.test.tsx +2 -2
- package/src/Image.test.tsx +1 -1
- package/src/Link.test.tsx +13 -6
- package/src/MarkdownEditorField.tsx +10 -2
- package/src/MarkdownView.test.tsx +10 -6
- package/src/MobileAddressAutoComplete.test.tsx +2 -1
- package/src/Modal.test.tsx +10 -3
- package/src/ModalSheet.test.tsx +11 -10
- package/src/MultiselectField.test.tsx +17 -3
- package/src/NumberField.test.tsx +14 -14
- package/src/NumberPickerActionSheet.test.tsx +1 -1
- package/src/OfflineBanner.tsx +3 -2
- package/src/OpenAPIContext.test.tsx +4 -4
- package/src/OpenAPIRenderRegression.test.tsx +1 -1
- package/src/OtpField.tsx +6 -5
- package/src/P0RenderRegression.test.tsx +7 -1
- package/src/P1RenderRegression.test.tsx +1 -0
- package/src/P2ButtonRenderRegression.test.tsx +1 -0
- package/src/Page.test.tsx +1 -1
- package/src/PhoneNumberField.test.tsx +14 -38
- package/src/PickerSelect.tsx +12 -11
- package/src/Popover.test.tsx +2 -2
- package/src/ProvisionalConsentSigner.test.tsx +140 -113
- package/src/ProvisionalConsentSigner.tsx +5 -4
- package/src/RadioField.test.tsx +7 -2
- package/src/SegmentedControl.test.tsx +21 -12
- package/src/SidebarNavigation.native.tsx +2 -2
- package/src/SidebarNavigation.test.tsx +18 -6
- package/src/SidebarNavigation.tsx +2 -2
- package/src/Signature.test.tsx +20 -23
- package/src/Skeleton.tsx +1 -1
- package/src/Slider.test.tsx +1 -1
- package/src/SplitPage.test.tsx +15 -5
- package/src/TapToEdit.test.tsx +40 -17
- package/src/TapToEdit.tsx +1 -1
- package/src/TerrenoFontProvider.test.tsx +1 -1
- package/src/Text.test.tsx +4 -4
- package/src/Text.tsx +25 -51
- package/src/TextField.test.tsx +82 -9
- package/src/TextField.tsx +6 -5
- package/src/Theme.test.tsx +49 -0
- package/src/Theme.tsx +16 -0
- package/src/ThumbsUpDownFeedback.tsx +3 -3
- package/src/Toast.test.tsx +5 -5
- package/src/ToastNotifications.test.tsx +73 -70
- package/src/ToastNotifications.tsx +3 -2
- package/src/ToastNotifications.webModal.test.tsx +6 -3
- package/src/Tooltip.test.tsx +3 -3
- package/src/Tooltip.tsx +2 -1
- package/src/UnifiedAddressAutoComplete.test.tsx +1 -1
- package/src/UserInactivity.test.tsx +1 -0
- package/src/WebAddressAutocomplete.test.tsx +12 -12
- package/src/WebAddressAutocomplete.tsx +3 -3
- package/src/WebDropdownMenu.test.tsx +16 -15
- package/src/WebDropdownMenu.tsx +16 -5
- package/src/__snapshots__/Card.test.tsx.snap +1 -1
- package/src/__snapshots__/DataTable.test.tsx.snap +13 -0
- package/src/__snapshots__/DismissButton.test.tsx.snap +3 -3
- package/src/__snapshots__/Field.test.tsx.snap +4 -2
- package/src/__snapshots__/Heading.test.tsx.snap +1 -1
- package/src/__snapshots__/Image.test.tsx.snap +1 -1
- package/src/__snapshots__/Page.test.tsx.snap +2 -2
- package/src/__snapshots__/Text.test.tsx.snap +1 -1
- package/src/announcementPlatform.ts +10 -0
- package/src/asks/AskCard.test.tsx +20 -15
- package/src/asks/AskCard.tsx +2 -2
- package/src/asks/AskFiles.test.tsx +5 -1
- package/src/asks/askFileRefs.test.ts +1 -1
- package/src/asks/askSummary.test.ts +2 -2
- package/src/benchmarks/importTiming.ts +1 -1
- package/src/blocks/BlocksView.test.tsx +20 -11
- package/src/bunSetup.ts +43 -1
- package/src/dataTableColumnWidths.test.ts +266 -0
- package/src/dataTableColumnWidths.ts +272 -0
- package/src/dataTableFilters.test.tsx +1 -1
- package/src/index.tsx +9 -2
- package/src/isolated/ListDetailLayout.isolated.tsx +2 -4
- package/src/login/LoginScreen.test.tsx +6 -6
- package/src/login/LoginScreen.tsx +2 -2
- package/src/requestClient.test.ts +288 -0
- package/src/requestClient.ts +228 -0
- package/src/security/PasswordCard.test.tsx +3 -3
- package/src/security/PasswordCard.tsx +7 -5
- package/src/security/TwoFactorSettingsCard.tsx +10 -3
- package/src/signUp/SignUpScreen.test.tsx +4 -4
- package/src/signUp/SignUpScreen.tsx +2 -2
- package/src/table/Table.tsx +1 -2
- package/src/table/TableTitle.tsx +2 -1
- package/src/table/tableContext.test.tsx +5 -5
- package/src/test-utils.tsx +132 -1
- package/src/testing/reactDomServer.d.ts +7 -0
- package/src/textFontSizes.ts +31 -0
- package/src/useAcknowledgeAnnouncement.test.ts +101 -193
- package/src/useAcknowledgeAnnouncement.ts +69 -147
- package/src/useAnnouncements.test.ts +122 -186
- package/src/useAnnouncements.ts +49 -105
- package/src/useConsentForms.test.ts +59 -112
- package/src/useConsentForms.ts +37 -87
- package/src/useProvisionalConsent.test.ts +74 -150
- package/src/useProvisionalConsent.ts +79 -125
- package/src/useSubmitConsent.test.ts +59 -85
- package/src/useSubmitConsent.ts +22 -77
|
@@ -94,7 +94,7 @@ describe("UnifiedAddressAutoCompleteField", () => {
|
|
|
94
94
|
});
|
|
95
95
|
|
|
96
96
|
describe("web branch", () => {
|
|
97
|
-
const testGlobal = globalThis as MutableGlobal;
|
|
97
|
+
const testGlobal = globalThis as unknown as MutableGlobal;
|
|
98
98
|
const originalDocument = testGlobal.document;
|
|
99
99
|
const originalWindow = testGlobal.window;
|
|
100
100
|
|
|
@@ -148,6 +148,7 @@ describe("UserInactivity", () => {
|
|
|
148
148
|
const addListenerSpy = spyOn(Keyboard, "addListener").mockImplementation(
|
|
149
149
|
(event: string, callback: () => void) => {
|
|
150
150
|
if (event === "keyboardDidHide") {
|
|
151
|
+
// UserInactivity's keyboard handler ignores the event payload.
|
|
151
152
|
capturedHideCallback = callback;
|
|
152
153
|
}
|
|
153
154
|
return {remove: mock(() => {})} as unknown as EmitterSubscription;
|
|
@@ -5,6 +5,14 @@ import type {AddressInterface} from "./Common";
|
|
|
5
5
|
import {renderWithTheme} from "./test-utils";
|
|
6
6
|
import {WebAddressAutocomplete} from "./WebAddressAutocomplete";
|
|
7
7
|
|
|
8
|
+
interface PlaceResult {
|
|
9
|
+
address_components: {
|
|
10
|
+
long_name: string;
|
|
11
|
+
short_name: string;
|
|
12
|
+
types: string[];
|
|
13
|
+
}[];
|
|
14
|
+
}
|
|
15
|
+
|
|
8
16
|
describe("WebAddressAutocomplete", () => {
|
|
9
17
|
const defaultProps = {
|
|
10
18
|
handleAddressChange: () => {},
|
|
@@ -51,14 +59,6 @@ describe("WebAddressAutocomplete", () => {
|
|
|
51
59
|
});
|
|
52
60
|
|
|
53
61
|
describe("with Google Maps available", () => {
|
|
54
|
-
interface PlaceResult {
|
|
55
|
-
address_components: {
|
|
56
|
-
long_name: string;
|
|
57
|
-
short_name: string;
|
|
58
|
-
types: string[];
|
|
59
|
-
}[];
|
|
60
|
-
}
|
|
61
|
-
|
|
62
62
|
interface GoogleMapsWindow {
|
|
63
63
|
google?: {
|
|
64
64
|
maps?: {
|
|
@@ -80,7 +80,7 @@ describe("WebAddressAutocomplete", () => {
|
|
|
80
80
|
document?: MinimalDocument;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
const testGlobal = globalThis as TestGlobals;
|
|
83
|
+
const testGlobal = globalThis as unknown as TestGlobals;
|
|
84
84
|
const originalWindow = testGlobal.window;
|
|
85
85
|
const originalDocument = testGlobal.document;
|
|
86
86
|
|
|
@@ -207,7 +207,7 @@ describe("WebAddressAutocomplete", () => {
|
|
|
207
207
|
document?: MinimalDocument;
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
const testGlobal = globalThis as TestGlobals;
|
|
210
|
+
const testGlobal = globalThis as unknown as TestGlobals;
|
|
211
211
|
const originalWindow = testGlobal.window;
|
|
212
212
|
const originalDocument = testGlobal.document;
|
|
213
213
|
|
|
@@ -468,7 +468,7 @@ describe("WebAddressAutocomplete", () => {
|
|
|
468
468
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
469
469
|
});
|
|
470
470
|
|
|
471
|
-
const win = (globalThis as Record<string, Record<string, unknown>>).window;
|
|
471
|
+
const win = (globalThis as unknown as Record<string, Record<string, unknown>>).window;
|
|
472
472
|
expect(win.initAutocomplete).toBeDefined();
|
|
473
473
|
|
|
474
474
|
unmount();
|
|
@@ -502,7 +502,7 @@ describe("WebAddressAutocomplete", () => {
|
|
|
502
502
|
}),
|
|
503
503
|
}));
|
|
504
504
|
|
|
505
|
-
const win = (globalThis as Record<string, Record<string, unknown>>).window;
|
|
505
|
+
const win = (globalThis as unknown as Record<string, Record<string, unknown>>).window;
|
|
506
506
|
win.google = {
|
|
507
507
|
maps: {places: {Autocomplete: autocompleteConstructor}},
|
|
508
508
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {type ReactElement, useEffect, useRef, useState} from "react";
|
|
2
|
-
import type {
|
|
2
|
+
import type {TextInputInstance} from "react-native";
|
|
3
3
|
|
|
4
4
|
import type {AddressAutocompleteProps} from "./Common";
|
|
5
5
|
import {GOOGLE_PLACES_API_RESTRICTIONS} from "./Constants";
|
|
@@ -37,7 +37,7 @@ export const WebAddressAutocomplete = ({
|
|
|
37
37
|
handleAutoCompleteChange,
|
|
38
38
|
}: AddressAutocompleteProps): ReactElement => {
|
|
39
39
|
const [scriptLoaded, setScriptLoaded] = useState(true);
|
|
40
|
-
const autocompleteInputRef = useRef<
|
|
40
|
+
const autocompleteInputRef = useRef<TextInputInstance | null>(null);
|
|
41
41
|
|
|
42
42
|
// Load the Google Maps script and initialize the autocomplete.
|
|
43
43
|
useEffect(() => {
|
|
@@ -83,7 +83,7 @@ export const WebAddressAutocomplete = ({
|
|
|
83
83
|
disabled={disabled}
|
|
84
84
|
inputRef={
|
|
85
85
|
scriptLoaded
|
|
86
|
-
? (ref:
|
|
86
|
+
? (ref: TextInputInstance | null): void => {
|
|
87
87
|
autocompleteInputRef.current = ref;
|
|
88
88
|
}
|
|
89
89
|
: undefined
|
|
@@ -4,11 +4,12 @@ import {assert} from "chai";
|
|
|
4
4
|
import type {ComponentProps} from "react";
|
|
5
5
|
import {Dimensions} from "react-native";
|
|
6
6
|
|
|
7
|
-
import {renderWithTheme} from "./test-utils";
|
|
7
|
+
import {findAllByHostType, renderWithTheme} from "./test-utils";
|
|
8
8
|
import {
|
|
9
9
|
resolveDocumentBodyPortalTarget,
|
|
10
10
|
scheduleAfterPaint,
|
|
11
11
|
useWebDropdownAnchor,
|
|
12
|
+
type WebDropdownAnchor,
|
|
12
13
|
WebDropdownMenu,
|
|
13
14
|
} from "./WebDropdownMenu";
|
|
14
15
|
|
|
@@ -63,7 +64,7 @@ describe("WebDropdownMenu", () => {
|
|
|
63
64
|
});
|
|
64
65
|
|
|
65
66
|
it("invokes onSelect with value and index when an option is pressed", () => {
|
|
66
|
-
const onSelect = mock(() => {});
|
|
67
|
+
const onSelect = mock((_value: string, _index: number) => {});
|
|
67
68
|
const {getByTestId} = renderWithTheme(
|
|
68
69
|
<WebDropdownMenu
|
|
69
70
|
anchor={anchor}
|
|
@@ -365,7 +366,7 @@ describe("WebDropdownMenu disableSearch", () => {
|
|
|
365
366
|
});
|
|
366
367
|
|
|
367
368
|
it("reports the original index when selecting a filtered option", () => {
|
|
368
|
-
const onSelect = mock(() => {});
|
|
369
|
+
const onSelect = mock((_value: string, _index: number) => {});
|
|
369
370
|
const {getByTestId} = renderWithTheme(
|
|
370
371
|
<WebDropdownMenu
|
|
371
372
|
anchor={anchor}
|
|
@@ -469,7 +470,7 @@ describe("WebDropdownMenu keepTriggerFocus portal overlay", () => {
|
|
|
469
470
|
keyupListeners.push(listener);
|
|
470
471
|
}
|
|
471
472
|
},
|
|
472
|
-
body: body as HTMLElement,
|
|
473
|
+
body: body as unknown as HTMLElement,
|
|
473
474
|
removeEventListener: (type: string, listener: (event: KeyboardEvent) => void) => {
|
|
474
475
|
if (type === "keyup") {
|
|
475
476
|
keyupListeners = keyupListeners.filter((registered) => registered !== listener);
|
|
@@ -488,7 +489,7 @@ describe("WebDropdownMenu keepTriggerFocus portal overlay", () => {
|
|
|
488
489
|
};
|
|
489
490
|
|
|
490
491
|
const dispatchEscapeKey = (): void => {
|
|
491
|
-
const event = {key: "Escape", stopPropagation: mock(() => {})} as KeyboardEvent;
|
|
492
|
+
const event = {key: "Escape", stopPropagation: mock(() => {})} as unknown as KeyboardEvent;
|
|
492
493
|
for (const listener of keyupListeners) {
|
|
493
494
|
listener(event);
|
|
494
495
|
}
|
|
@@ -542,7 +543,7 @@ describe("WebDropdownMenu keepTriggerFocus portal overlay", () => {
|
|
|
542
543
|
expect(style.position).toBe("fixed");
|
|
543
544
|
expect(style.left).toBe(anchor.x);
|
|
544
545
|
|
|
545
|
-
const modals = root
|
|
546
|
+
const modals = findAllByHostType(root, "Modal");
|
|
546
547
|
expect(modals.length).toBe(0);
|
|
547
548
|
} finally {
|
|
548
549
|
PlatformModule.OS = savedOS;
|
|
@@ -562,7 +563,7 @@ describe("WebDropdownMenu keepTriggerFocus portal overlay", () => {
|
|
|
562
563
|
|
|
563
564
|
assert.isOk(getByTestId("web_dropdown_menu"));
|
|
564
565
|
assert.isNull(queryByTestId("web_dropdown_modal"));
|
|
565
|
-
assert.equal(root
|
|
566
|
+
assert.equal(findAllByHostType(root, "Modal").length, 0);
|
|
566
567
|
} finally {
|
|
567
568
|
PlatformModule.OS = savedOS;
|
|
568
569
|
restoreWebDocument();
|
|
@@ -578,7 +579,7 @@ describe("WebDropdownMenu keepTriggerFocus portal overlay", () => {
|
|
|
578
579
|
const placeholder = getByTestId("web_dropdown_modal");
|
|
579
580
|
expect(placeholder.props.visible).toBeUndefined();
|
|
580
581
|
|
|
581
|
-
const modals = root
|
|
582
|
+
const modals = findAllByHostType(root, "Modal");
|
|
582
583
|
expect(modals.length).toBe(0);
|
|
583
584
|
} finally {
|
|
584
585
|
PlatformModule.OS = savedOS;
|
|
@@ -712,7 +713,7 @@ describe("useWebDropdownAnchor", () => {
|
|
|
712
713
|
|
|
713
714
|
it("invokes the callback synchronously with the existing anchor when the ref is empty", () => {
|
|
714
715
|
const {result} = renderHook(() => useWebDropdownAnchor());
|
|
715
|
-
const onMeasured = mock(() => {});
|
|
716
|
+
const onMeasured = mock((_anchor: WebDropdownAnchor) => {});
|
|
716
717
|
act(() => {
|
|
717
718
|
result.current.measure(onMeasured);
|
|
718
719
|
});
|
|
@@ -726,7 +727,7 @@ describe("useWebDropdownAnchor", () => {
|
|
|
726
727
|
cb(10, 20, 100, 40);
|
|
727
728
|
});
|
|
728
729
|
(result.current.triggerRef as {current: unknown}).current = {measureInWindow};
|
|
729
|
-
const onMeasured = mock(() => {});
|
|
730
|
+
const onMeasured = mock((_anchor: WebDropdownAnchor) => {});
|
|
730
731
|
act(() => {
|
|
731
732
|
result.current.measure(onMeasured);
|
|
732
733
|
});
|
|
@@ -886,14 +887,14 @@ describe("WebDropdownMenu layout callbacks", () => {
|
|
|
886
887
|
visible
|
|
887
888
|
/>
|
|
888
889
|
);
|
|
889
|
-
const scrollView = root
|
|
890
|
+
const scrollView = findAllByHostType(root, "ScrollView")[0];
|
|
890
891
|
expect(scrollView).toBeTruthy();
|
|
891
892
|
act(() => {
|
|
892
893
|
fireEvent(scrollView, "layout", {nativeEvent: {layout: {height: 200, width: 200}}});
|
|
893
894
|
});
|
|
894
895
|
// The list viewport height is recorded and a scroll is scheduled; the
|
|
895
896
|
// component should remain mounted and functional.
|
|
896
|
-
expect(root
|
|
897
|
+
expect(findAllByHostType(root, "ScrollView").length).toBeGreaterThan(0);
|
|
897
898
|
});
|
|
898
899
|
|
|
899
900
|
it("records option layout and schedules a scroll for the selected option", () => {
|
|
@@ -936,7 +937,7 @@ describe("WebDropdownMenu layout callbacks", () => {
|
|
|
936
937
|
/>
|
|
937
938
|
);
|
|
938
939
|
|
|
939
|
-
const scrollView = root
|
|
940
|
+
const scrollView = findAllByHostType(root, "ScrollView")[0];
|
|
940
941
|
const scrollCalls: Array<{animated?: boolean; y?: number}> = [];
|
|
941
942
|
const scrollRef = scrollView.props.ref as {current: unknown};
|
|
942
943
|
scrollRef.current = {
|
|
@@ -975,7 +976,7 @@ describe("WebDropdownMenu layout callbacks", () => {
|
|
|
975
976
|
/>
|
|
976
977
|
);
|
|
977
978
|
|
|
978
|
-
const scrollView = root
|
|
979
|
+
const scrollView = findAllByHostType(root, "ScrollView")[0];
|
|
979
980
|
const scrollCalls: Array<{animated?: boolean; y?: number}> = [];
|
|
980
981
|
const scrollRef = scrollView.props.ref as {current: unknown};
|
|
981
982
|
scrollRef.current = {
|
|
@@ -1013,7 +1014,7 @@ describe("WebDropdownMenu layout callbacks", () => {
|
|
|
1013
1014
|
/>
|
|
1014
1015
|
);
|
|
1015
1016
|
|
|
1016
|
-
const scrollView = root
|
|
1017
|
+
const scrollView = findAllByHostType(root, "ScrollView")[0];
|
|
1017
1018
|
const scrollCalls: Array<{animated?: boolean; y?: number}> = [];
|
|
1018
1019
|
const scrollRef = scrollView.props.ref as {current: unknown};
|
|
1019
1020
|
scrollRef.current = {
|
package/src/WebDropdownMenu.tsx
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type ReactElement,
|
|
3
|
+
type RefObject,
|
|
4
|
+
useCallback,
|
|
5
|
+
useEffect,
|
|
6
|
+
useMemo,
|
|
7
|
+
useRef,
|
|
8
|
+
useState,
|
|
9
|
+
} from "react";
|
|
2
10
|
import {
|
|
3
11
|
Dimensions,
|
|
4
12
|
type DimensionValue,
|
|
@@ -6,10 +14,13 @@ import {
|
|
|
6
14
|
Platform,
|
|
7
15
|
Pressable,
|
|
8
16
|
ScrollView,
|
|
17
|
+
type ScrollViewInstance,
|
|
9
18
|
Text,
|
|
10
19
|
TextInput,
|
|
20
|
+
type TextInputInstance,
|
|
11
21
|
type TextStyle,
|
|
12
22
|
View,
|
|
23
|
+
type ViewInstance,
|
|
13
24
|
type ViewStyle,
|
|
14
25
|
} from "react-native";
|
|
15
26
|
|
|
@@ -136,8 +147,8 @@ export const WebDropdownMenu = ({
|
|
|
136
147
|
const searchable = !disableSearch;
|
|
137
148
|
const {theme} = useTheme();
|
|
138
149
|
const [searchQuery, setSearchQuery] = useState("");
|
|
139
|
-
const searchInputRef = useRef<
|
|
140
|
-
const listScrollRef = useRef<
|
|
150
|
+
const searchInputRef = useRef<TextInputInstance>(null);
|
|
151
|
+
const listScrollRef = useRef<ScrollViewInstance>(null);
|
|
141
152
|
const listViewportHeightRef = useRef(0);
|
|
142
153
|
const optionLayoutsRef = useRef<Array<{height: number; offset: number}>>([]);
|
|
143
154
|
|
|
@@ -509,12 +520,12 @@ export const WebDropdownMenu = ({
|
|
|
509
520
|
* the menu lines up beneath it across browsers.
|
|
510
521
|
*/
|
|
511
522
|
export const useWebDropdownAnchor = (): {
|
|
512
|
-
triggerRef:
|
|
523
|
+
triggerRef: RefObject<ViewInstance | null>;
|
|
513
524
|
anchor: WebDropdownAnchor;
|
|
514
525
|
cancelPendingMeasurement: () => void;
|
|
515
526
|
measure: (onMeasured: (anchor: WebDropdownAnchor) => void) => void;
|
|
516
527
|
} => {
|
|
517
|
-
const triggerRef = useRef<
|
|
528
|
+
const triggerRef = useRef<ViewInstance>(null);
|
|
518
529
|
const [anchor, setAnchor] = useState<WebDropdownAnchor>({height: 0, width: 0, x: 0, y: 0});
|
|
519
530
|
const measurementRequestRef = useRef(0);
|
|
520
531
|
|
|
@@ -142,7 +142,7 @@ exports[`Card container variant (default) applies custom color 1`] = `
|
|
|
142
142
|
"onPointerEnter": [Function: AsyncFunction],
|
|
143
143
|
"onPointerLeave": [Function: AsyncFunction],
|
|
144
144
|
"style": {
|
|
145
|
-
"backgroundColor":
|
|
145
|
+
"backgroundColor": "#2B6072",
|
|
146
146
|
"borderBottomColor": "#CDCDCD",
|
|
147
147
|
"borderBottomWidth": 1,
|
|
148
148
|
"borderRadius": undefined,
|
|
@@ -848,6 +848,7 @@ exports[`DataTable renders correctly with basic data 1`] = `
|
|
|
848
848
|
},
|
|
849
849
|
],
|
|
850
850
|
"props": {
|
|
851
|
+
"onLayout": [Function],
|
|
851
852
|
"style": {
|
|
852
853
|
"borderColor": "#CDCDCD",
|
|
853
854
|
"borderWidth": 1,
|
|
@@ -1720,6 +1721,7 @@ exports[`DataTable renders with alternate row background (default) 1`] = `
|
|
|
1720
1721
|
},
|
|
1721
1722
|
],
|
|
1722
1723
|
"props": {
|
|
1724
|
+
"onLayout": [Function],
|
|
1723
1725
|
"style": {
|
|
1724
1726
|
"borderColor": "#CDCDCD",
|
|
1725
1727
|
"borderWidth": 1,
|
|
@@ -2592,6 +2594,7 @@ exports[`DataTable renders without alternate row background 1`] = `
|
|
|
2592
2594
|
},
|
|
2593
2595
|
],
|
|
2594
2596
|
"props": {
|
|
2597
|
+
"onLayout": [Function],
|
|
2595
2598
|
"style": {
|
|
2596
2599
|
"borderColor": "#CDCDCD",
|
|
2597
2600
|
"borderWidth": 1,
|
|
@@ -3596,6 +3599,7 @@ exports[`DataTable renders with pinned columns 1`] = `
|
|
|
3596
3599
|
},
|
|
3597
3600
|
],
|
|
3598
3601
|
"props": {
|
|
3602
|
+
"onLayout": [Function],
|
|
3599
3603
|
"style": {
|
|
3600
3604
|
"borderColor": "#CDCDCD",
|
|
3601
3605
|
"borderWidth": 1,
|
|
@@ -4468,6 +4472,7 @@ exports[`DataTable renders with custom row height 1`] = `
|
|
|
4468
4472
|
},
|
|
4469
4473
|
],
|
|
4470
4474
|
"props": {
|
|
4475
|
+
"onLayout": [Function],
|
|
4471
4476
|
"style": {
|
|
4472
4477
|
"borderColor": "#CDCDCD",
|
|
4473
4478
|
"borderWidth": 1,
|
|
@@ -5340,6 +5345,7 @@ exports[`DataTable renders with custom header height 1`] = `
|
|
|
5340
5345
|
},
|
|
5341
5346
|
],
|
|
5342
5347
|
"props": {
|
|
5348
|
+
"onLayout": [Function],
|
|
5343
5349
|
"style": {
|
|
5344
5350
|
"borderColor": "#CDCDCD",
|
|
5345
5351
|
"borderWidth": 1,
|
|
@@ -6212,6 +6218,7 @@ exports[`DataTable renders with pagination 1`] = `
|
|
|
6212
6218
|
},
|
|
6213
6219
|
],
|
|
6214
6220
|
"props": {
|
|
6221
|
+
"onLayout": [Function],
|
|
6215
6222
|
"style": {
|
|
6216
6223
|
"borderColor": "#CDCDCD",
|
|
6217
6224
|
"borderWidth": 1,
|
|
@@ -6969,6 +6976,7 @@ exports[`DataTable renders sortable columns 1`] = `
|
|
|
6969
6976
|
},
|
|
6970
6977
|
],
|
|
6971
6978
|
"props": {
|
|
6979
|
+
"onLayout": [Function],
|
|
6972
6980
|
"style": {
|
|
6973
6981
|
"borderColor": "#CDCDCD",
|
|
6974
6982
|
"borderWidth": 1,
|
|
@@ -7287,6 +7295,7 @@ exports[`DataTable renders with sort indicator 1`] = `
|
|
|
7287
7295
|
},
|
|
7288
7296
|
],
|
|
7289
7297
|
"props": {
|
|
7298
|
+
"onLayout": [Function],
|
|
7290
7299
|
"style": {
|
|
7291
7300
|
"borderColor": "#CDCDCD",
|
|
7292
7301
|
"borderWidth": 1,
|
|
@@ -8159,6 +8168,7 @@ exports[`DataTable renders with different text sizes 1`] = `
|
|
|
8159
8168
|
},
|
|
8160
8169
|
],
|
|
8161
8170
|
"props": {
|
|
8171
|
+
"onLayout": [Function],
|
|
8162
8172
|
"style": {
|
|
8163
8173
|
"borderColor": "#CDCDCD",
|
|
8164
8174
|
"borderWidth": 1,
|
|
@@ -9219,6 +9229,7 @@ exports[`DataTable renders with more content component 1`] = `
|
|
|
9219
9229
|
},
|
|
9220
9230
|
],
|
|
9221
9231
|
"props": {
|
|
9232
|
+
"onLayout": [Function],
|
|
9222
9233
|
"style": {
|
|
9223
9234
|
"borderColor": "#CDCDCD",
|
|
9224
9235
|
"borderWidth": 1,
|
|
@@ -9536,6 +9547,7 @@ exports[`DataTable renders boolean cells correctly 1`] = `
|
|
|
9536
9547
|
},
|
|
9537
9548
|
],
|
|
9538
9549
|
"props": {
|
|
9550
|
+
"onLayout": [Function],
|
|
9539
9551
|
"style": {
|
|
9540
9552
|
"borderColor": "#CDCDCD",
|
|
9541
9553
|
"borderWidth": 1,
|
|
@@ -9870,6 +9882,7 @@ exports[`DataTable renders empty data 1`] = `
|
|
|
9870
9882
|
},
|
|
9871
9883
|
],
|
|
9872
9884
|
"props": {
|
|
9885
|
+
"onLayout": [Function],
|
|
9873
9886
|
"style": {
|
|
9874
9887
|
"borderColor": "#CDCDCD",
|
|
9875
9888
|
"borderWidth": 1,
|
|
@@ -17,7 +17,7 @@ exports[`DismissButton renders correctly with default props 1`] = `
|
|
|
17
17
|
},
|
|
18
18
|
],
|
|
19
19
|
"props": {
|
|
20
|
-
"accessibilityHint":
|
|
20
|
+
"accessibilityHint": "Dismisses the message",
|
|
21
21
|
"aria-label": "Dismiss",
|
|
22
22
|
"aria-role": "button",
|
|
23
23
|
"onPress": [Function],
|
|
@@ -49,7 +49,7 @@ exports[`DismissButton renders with primary color (default) 1`] = `
|
|
|
49
49
|
},
|
|
50
50
|
],
|
|
51
51
|
"props": {
|
|
52
|
-
"accessibilityHint":
|
|
52
|
+
"accessibilityHint": "Dismisses the message",
|
|
53
53
|
"aria-label": "Dismiss",
|
|
54
54
|
"aria-role": "button",
|
|
55
55
|
"onPress": [Function],
|
|
@@ -81,7 +81,7 @@ exports[`DismissButton renders with inverted color 1`] = `
|
|
|
81
81
|
},
|
|
82
82
|
],
|
|
83
83
|
"props": {
|
|
84
|
-
"accessibilityHint":
|
|
84
|
+
"accessibilityHint": "Dismisses the message",
|
|
85
85
|
"aria-label": "Dismiss",
|
|
86
86
|
"aria-role": "button",
|
|
87
87
|
"onPress": [Function],
|
|
@@ -3607,7 +3607,9 @@ exports[`Field renders multiselect field 1`] = `
|
|
|
3607
3607
|
"children": [
|
|
3608
3608
|
{
|
|
3609
3609
|
"$$typeof": Symbol(react.test.json),
|
|
3610
|
-
"children":
|
|
3610
|
+
"children": [
|
|
3611
|
+
"Skills",
|
|
3612
|
+
],
|
|
3611
3613
|
"props": {
|
|
3612
3614
|
"numberOfLines": 0,
|
|
3613
3615
|
"style": {
|
|
@@ -3830,7 +3832,7 @@ exports[`Field renders multiselect field 1`] = `
|
|
|
3830
3832
|
],
|
|
3831
3833
|
"props": {
|
|
3832
3834
|
"accessibilityHint": "Contains a prompt and list of options to select",
|
|
3833
|
-
"aria-label":
|
|
3835
|
+
"aria-label": "Skills",
|
|
3834
3836
|
"aria-role": "combobox",
|
|
3835
3837
|
"style": {
|
|
3836
3838
|
"display": "flex",
|
|
@@ -237,7 +237,7 @@ exports[`Image renders with background color 1`] = `
|
|
|
237
237
|
"onPointerEnter": [Function: AsyncFunction],
|
|
238
238
|
"onPointerLeave": [Function: AsyncFunction],
|
|
239
239
|
"style": {
|
|
240
|
-
"backgroundColor":
|
|
240
|
+
"backgroundColor": "#2B6072",
|
|
241
241
|
},
|
|
242
242
|
"testID": undefined,
|
|
243
243
|
},
|
|
@@ -1405,7 +1405,7 @@ exports[`Page renders with custom color 1`] = `
|
|
|
1405
1405
|
"onPointerLeave": [Function: AsyncFunction],
|
|
1406
1406
|
"style": {
|
|
1407
1407
|
"alignSelf": "center",
|
|
1408
|
-
"backgroundColor":
|
|
1408
|
+
"backgroundColor": "#2B6072",
|
|
1409
1409
|
"display": "flex",
|
|
1410
1410
|
"flex": undefined,
|
|
1411
1411
|
"flexDirection": "column",
|
|
@@ -1437,7 +1437,7 @@ exports[`Page renders with custom color 1`] = `
|
|
|
1437
1437
|
"scrollEventThrottle": 50,
|
|
1438
1438
|
"style": {
|
|
1439
1439
|
"alignSelf": "center",
|
|
1440
|
-
"backgroundColor":
|
|
1440
|
+
"backgroundColor": "#2B6072",
|
|
1441
1441
|
"display": "flex",
|
|
1442
1442
|
"flex": undefined,
|
|
1443
1443
|
"flexDirection": "column",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {Platform} from "react-native";
|
|
2
|
+
import {getAnnouncementBuildVersion} from "./announcementBuildVersion";
|
|
2
3
|
|
|
3
4
|
export type AnnouncementPlatform = "android" | "ios" | "web";
|
|
4
5
|
|
|
@@ -11,3 +12,12 @@ export const getAnnouncementPlatform = (): AnnouncementPlatform => {
|
|
|
11
12
|
}
|
|
12
13
|
return "web";
|
|
13
14
|
};
|
|
15
|
+
|
|
16
|
+
/** `platform` and `version` query params the announcement routes filter by. */
|
|
17
|
+
export const buildAnnouncementParams = (): {platform: AnnouncementPlatform; version?: number} => {
|
|
18
|
+
const version = getAnnouncementBuildVersion();
|
|
19
|
+
return {
|
|
20
|
+
platform: getAnnouncementPlatform(),
|
|
21
|
+
...(version === undefined ? {} : {version}),
|
|
22
|
+
};
|
|
23
|
+
};
|
|
@@ -9,12 +9,12 @@ import {
|
|
|
9
9
|
import {act, fireEvent, render, waitFor, within} from "@testing-library/react-native";
|
|
10
10
|
import {assert} from "chai";
|
|
11
11
|
import {createRef} from "react";
|
|
12
|
-
import type {
|
|
12
|
+
import type {TextInstance, TextProps} from "react-native";
|
|
13
13
|
import {ThemeProvider} from "../Theme";
|
|
14
14
|
import {TimezonePicker} from "../TimezonePicker";
|
|
15
|
-
import {renderWithTheme} from "../test-utils";
|
|
15
|
+
import {elementProps, findAllByHostType, renderWithTheme} from "../test-utils";
|
|
16
16
|
import {AskCard, type AskCardProps} from "./AskCard";
|
|
17
|
-
import type {AskSubmission, ChatAsk} from "./askTypes";
|
|
17
|
+
import type {AskSubmission, ChatAsk, ChatAskState} from "./askTypes";
|
|
18
18
|
|
|
19
19
|
const PLAN_INPUT: ChoiceAskInput = {
|
|
20
20
|
default: ["team"],
|
|
@@ -49,7 +49,7 @@ const COUNTRY_INPUT: ChoiceAskInput = {
|
|
|
49
49
|
select: "one",
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
const pendingAsk = (input: ChoiceAskInput, state: Partial<
|
|
52
|
+
const pendingAsk = (input: ChoiceAskInput, state: Partial<ChatAskState> = {}): ChatAsk => ({
|
|
53
53
|
input,
|
|
54
54
|
kind: "choice",
|
|
55
55
|
status: "pending",
|
|
@@ -67,7 +67,7 @@ const ARCHIVE_INPUT: ConfirmAskInput = {
|
|
|
67
67
|
|
|
68
68
|
const REPORT_INPUT: ConfirmAskInput = {prompt: "Send the weekly report to the team now?"};
|
|
69
69
|
|
|
70
|
-
const pendingConfirm = (input: ConfirmAskInput, state: Partial<
|
|
70
|
+
const pendingConfirm = (input: ConfirmAskInput, state: Partial<ChatAskState> = {}): ChatAsk =>
|
|
71
71
|
({input, kind: "confirm", status: "pending", toolCallId: "call_1", ...state}) as ChatAsk;
|
|
72
72
|
|
|
73
73
|
const DRAFT = "# We're live\n\nToday we launched.";
|
|
@@ -82,7 +82,7 @@ const DRAFT_INPUT: MarkdownAskInput = {
|
|
|
82
82
|
title: "Launch announcement",
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
-
const pendingMarkdown = (input: MarkdownAskInput, state: Partial<
|
|
85
|
+
const pendingMarkdown = (input: MarkdownAskInput, state: Partial<ChatAskState> = {}): ChatAsk =>
|
|
86
86
|
({input, kind: "markdown", status: "pending", toolCallId: "call_1", ...state}) as ChatAsk;
|
|
87
87
|
|
|
88
88
|
const INVOICE_INPUT: FormAskInput = {
|
|
@@ -145,7 +145,7 @@ const DEFAULTS_INPUT: FormAskInput = {
|
|
|
145
145
|
prompt: "Check the details.",
|
|
146
146
|
};
|
|
147
147
|
|
|
148
|
-
const pendingForm = (input: FormAskInput, state: Partial<
|
|
148
|
+
const pendingForm = (input: FormAskInput, state: Partial<ChatAskState> = {}): ChatAsk =>
|
|
149
149
|
({input, kind: "form", status: "pending", toolCallId: "call_1", ...state}) as ChatAsk;
|
|
150
150
|
|
|
151
151
|
const renderCard = (props: Partial<AskCardProps> & Pick<AskCardProps, "ask">) =>
|
|
@@ -556,7 +556,7 @@ describe("AskCard", () => {
|
|
|
556
556
|
|
|
557
557
|
await press(getByTestId("ask-card-button-approve"));
|
|
558
558
|
assert.lengthOf(
|
|
559
|
-
getByTestId("ask-card-button-approve")
|
|
559
|
+
findAllByHostType(getByTestId("ask-card-button-approve"), "ActivityIndicator"),
|
|
560
560
|
1
|
|
561
561
|
);
|
|
562
562
|
assert.isTrue(isDisabled(getByTestId("ask-card-button-deny")));
|
|
@@ -1011,8 +1011,11 @@ describe("AskCard", () => {
|
|
|
1011
1011
|
assert.isNull(card.queryByText("Enter a complete date and time, or clear it."));
|
|
1012
1012
|
await press(card.getByTestId("ask-card-submit"));
|
|
1013
1013
|
assert.deepInclude(
|
|
1014
|
-
(
|
|
1015
|
-
?.
|
|
1014
|
+
(
|
|
1015
|
+
onSubmit.mock.calls[0]?.[0]?.response as unknown as {
|
|
1016
|
+
content: {values: Record<string, unknown>};
|
|
1017
|
+
}
|
|
1018
|
+
)?.content?.values ?? {},
|
|
1016
1019
|
{meeting: "2026-10-01T09:30:00Z", reminder: "10:30"}
|
|
1017
1020
|
);
|
|
1018
1021
|
});
|
|
@@ -1244,8 +1247,9 @@ describe("AskCard", () => {
|
|
|
1244
1247
|
const {getByTestId} = renderCard({ask: pendingAsk(PLAN_INPUT), onSubmit});
|
|
1245
1248
|
|
|
1246
1249
|
await press(getByTestId("ask-card-button-option:team"));
|
|
1247
|
-
const spinners =
|
|
1248
|
-
(
|
|
1250
|
+
const spinners = findAllByHostType(
|
|
1251
|
+
getByTestId("ask-card-button-option:team"),
|
|
1252
|
+
"ActivityIndicator"
|
|
1249
1253
|
);
|
|
1250
1254
|
assert.lengthOf(spinners, 1);
|
|
1251
1255
|
assert.isTrue(isDisabled(getByTestId("ask-card-button-option:team")));
|
|
@@ -1301,18 +1305,19 @@ describe("AskCard", () => {
|
|
|
1301
1305
|
});
|
|
1302
1306
|
|
|
1303
1307
|
it("shows the question as an accessible header the host can focus through promptRef", () => {
|
|
1304
|
-
const promptRef = createRef<
|
|
1308
|
+
const promptRef = createRef<TextInstance>();
|
|
1305
1309
|
const prompt = {focus: (): void => {}};
|
|
1306
1310
|
const {getByRole} = render(
|
|
1307
1311
|
<AskCard ask={pendingAsk(PLAN_INPUT)} onSubmit={async () => {}} promptRef={promptRef} />,
|
|
1308
1312
|
{
|
|
1309
|
-
createNodeMock: (element) =>
|
|
1313
|
+
createNodeMock: (element) =>
|
|
1314
|
+
elementProps<TextProps>(element).accessibilityRole === "header" ? prompt : null,
|
|
1310
1315
|
wrapper: ThemeProvider,
|
|
1311
1316
|
}
|
|
1312
1317
|
);
|
|
1313
1318
|
|
|
1314
1319
|
assert.isOk(getByRole("header", {name: "Which plan should I set up for your workspace?"}));
|
|
1315
|
-
assert.strictEqual(promptRef.current, prompt as unknown as
|
|
1320
|
+
assert.strictEqual(promptRef.current, prompt as unknown as TextInstance);
|
|
1316
1321
|
});
|
|
1317
1322
|
|
|
1318
1323
|
it("disables its controls when the host takes no answers", () => {
|
package/src/asks/AskCard.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {type AskValidationError, validateAskInput} from "@terreno/blocks";
|
|
2
2
|
import type React from "react";
|
|
3
3
|
import {useCallback, useRef, useState} from "react";
|
|
4
|
-
import type {
|
|
4
|
+
import type {TextInstance} from "react-native";
|
|
5
5
|
|
|
6
6
|
import {Box} from "../Box";
|
|
7
7
|
import type {IconName} from "../Common";
|
|
@@ -33,7 +33,7 @@ export interface AskCardProps {
|
|
|
33
33
|
* The pending ask's question, an accessible header. Pass it to
|
|
34
34
|
* `AccessibilityInfo.setAccessibilityFocus` to move screen reader focus to the ask.
|
|
35
35
|
*/
|
|
36
|
-
promptRef?: React.Ref<
|
|
36
|
+
promptRef?: React.Ref<TextInstance>;
|
|
37
37
|
/**
|
|
38
38
|
* Turns the files picked for a `files` ask into the answer's refs on Submit: uploads
|
|
39
39
|
* (`{fileId}`) or data URLs (`{url}`). Defaults to data URLs (`resolveAskFilesAsDataUrls`).
|
|
@@ -306,7 +306,11 @@ describe("AskCard files", () => {
|
|
|
306
306
|
assert.isNull(rendered.queryByTestId("ask-card-errors"));
|
|
307
307
|
assert.isFalse(isDisabled(rendered.getByTestId("ask-card-submit")));
|
|
308
308
|
|
|
309
|
-
const tooLarge = {
|
|
309
|
+
const tooLarge = {
|
|
310
|
+
...mismatch,
|
|
311
|
+
code: "FILE_TOO_LARGE" as const,
|
|
312
|
+
message: "items.txt is too large.",
|
|
313
|
+
};
|
|
310
314
|
rendered.rerender(<AskCard ask={ask} errors={[tooLarge]} onSubmit={onSubmit} />);
|
|
311
315
|
assert.isOk(within(rendered.getByTestId("ask-card-errors")).getByText(tooLarge.message));
|
|
312
316
|
|