@terreno/ui 0.25.0 → 0.27.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 -0
- package/dist/ActionSheet.js.map +1 -1
- package/dist/AiSuggestionBox.js +1 -1
- package/dist/AiSuggestionBox.js.map +1 -1
- package/dist/Avatar.js +4 -1
- package/dist/Avatar.js.map +1 -1
- package/dist/BooleanField.js +2 -1
- package/dist/BooleanField.js.map +1 -1
- package/dist/Box.js +2 -0
- package/dist/Box.js.map +1 -1
- package/dist/Common.d.ts +7 -1
- package/dist/Common.js +1 -1
- package/dist/Common.js.map +1 -1
- package/dist/ConsentNavigator.js.map +1 -1
- package/dist/CustomSelectField.js +1 -1
- package/dist/CustomSelectField.js.map +1 -1
- package/dist/DateTimeField.js +4 -1
- package/dist/DateTimeField.js.map +1 -1
- package/dist/EmailField.js +1 -1
- package/dist/EmailField.js.map +1 -1
- package/dist/HeightField.js +3 -1
- package/dist/HeightField.js.map +1 -1
- package/dist/IconButton.js +10 -1
- package/dist/IconButton.js.map +1 -1
- package/dist/MarkdownEditorField.js +3 -1
- package/dist/MarkdownEditorField.js.map +1 -1
- package/dist/Modal.js +7 -2
- package/dist/Modal.js.map +1 -1
- package/dist/MultiselectField.js +2 -1
- package/dist/MultiselectField.js.map +1 -1
- package/dist/Page.js +1 -0
- package/dist/Page.js.map +1 -1
- package/dist/Permissions.d.ts +1 -1
- package/dist/Permissions.js +2 -2
- package/dist/Permissions.js.map +1 -1
- package/dist/SelectField.js +3 -1
- package/dist/SelectField.js.map +1 -1
- package/dist/SplitPage.js +3 -0
- package/dist/SplitPage.js.map +1 -1
- package/dist/SplitPage.native.js +2 -0
- package/dist/SplitPage.native.js.map +1 -1
- package/dist/TapToEdit.js +1 -0
- package/dist/TapToEdit.js.map +1 -1
- package/dist/TextField.js +3 -1
- package/dist/TextField.js.map +1 -1
- package/dist/ToastNotifications.js.map +1 -1
- package/dist/Unifier.js.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/useSubmitConsent.d.ts +1 -1
- package/dist/useSubmitConsent.js +1 -1
- package/dist/useSubmitConsent.js.map +1 -1
- package/package.json +2 -2
- package/src/ActionSheet.test.tsx +1 -0
- package/src/ActionSheet.tsx +2 -0
- package/src/AiSuggestionBox.tsx +1 -1
- package/src/Avatar.tsx +4 -1
- package/src/Badge.test.tsx +1 -2
- package/src/BooleanField.tsx +2 -1
- package/src/Box.test.tsx +56 -0
- package/src/Box.tsx +4 -0
- package/src/Button.test.tsx +34 -0
- package/src/Common.ts +31 -1
- package/src/ConsentNavigator.test.tsx +1 -0
- package/src/ConsentNavigator.tsx +1 -0
- package/src/CustomSelectField.tsx +1 -1
- package/src/DataTable.test.tsx +1 -0
- package/src/DateTimeField.test.tsx +1 -0
- package/src/DateTimeField.tsx +4 -1
- package/src/EmailField.tsx +1 -1
- package/src/HeightField.tsx +3 -1
- package/src/IconButton.test.tsx +26 -0
- package/src/IconButton.tsx +10 -0
- package/src/MarkdownEditorField.tsx +3 -1
- package/src/Modal.test.tsx +261 -66
- package/src/Modal.tsx +7 -2
- package/src/ModalSheet.test.tsx +7 -6
- package/src/MultiselectField.tsx +2 -1
- package/src/Page.tsx +1 -0
- package/src/Permissions.ts +2 -2
- package/src/PickerSelect.test.tsx +1 -0
- package/src/SelectBadge.test.tsx +1 -2
- package/src/SelectField.tsx +3 -1
- package/src/Signature.test.tsx +52 -0
- package/src/SplitPage.native.tsx +2 -0
- package/src/SplitPage.test.tsx +6 -4
- package/src/SplitPage.tsx +3 -0
- package/src/TapToEdit.test.tsx +1 -0
- package/src/TapToEdit.tsx +2 -0
- package/src/Text.test.tsx +29 -0
- package/src/TextField.test.tsx +57 -1
- package/src/TextField.tsx +3 -1
- package/src/ToastNotifications.test.tsx +1 -0
- package/src/ToastNotifications.tsx +1 -0
- package/src/Tooltip.test.tsx +1 -1
- package/src/Unifier.ts +1 -0
- package/src/UpgradeRequiredScreen.test.tsx +40 -0
- package/src/UserInactivity.test.tsx +44 -1
- package/src/WebDropdownMenu.test.tsx +116 -1
- package/src/__snapshots__/DataTable.test.tsx.snap +0 -148
- package/src/__snapshots__/IconButton.test.tsx.snap +4 -0
- package/src/__snapshots__/InfoModalIcon.test.tsx.snap +255 -1088
- package/src/__snapshots__/Modal.test.tsx.snap +950 -1108
- package/src/bunSetup.ts +24 -0
- package/src/createWebPortal.test.tsx +17 -0
- package/src/index.tsx +18 -2
- package/src/types/react-native-swiper-flatlist.d.ts +1 -0
- package/src/useSubmitConsent.test.ts +2 -1
- package/src/useSubmitConsent.ts +2 -2
- package/dist/fieldElements/index.d.ts +0 -3
- package/dist/fieldElements/index.js +0 -4
- package/dist/fieldElements/index.js.map +0 -1
- package/dist/icons/index.d.ts +0 -5
- package/dist/icons/index.js +0 -6
- package/dist/icons/index.js.map +0 -1
- package/dist/login/index.d.ts +0 -2
- package/dist/login/index.js +0 -2
- package/dist/login/index.js.map +0 -1
- package/dist/signUp/index.d.ts +0 -6
- package/dist/signUp/index.js +0 -6
- package/dist/signUp/index.js.map +0 -1
- package/dist/testing/index.d.ts +0 -2
- package/dist/testing/index.js +0 -3
- package/dist/testing/index.js.map +0 -1
- package/src/fieldElements/index.tsx +0 -3
- package/src/icons/index.ts +0 -5
- package/src/login/index.ts +0 -2
- package/src/signUp/index.ts +0 -13
- package/src/testing/index.ts +0 -2
package/src/SplitPage.test.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
|
|
2
1
|
import {afterAll, afterEach, beforeEach, describe, expect, it, mock} from "bun:test";
|
|
3
2
|
import {act} from "@testing-library/react-native";
|
|
4
3
|
import {View} from "react-native";
|
|
4
|
+
import type {ReactTestInstance} from "react-test-renderer";
|
|
5
5
|
|
|
6
6
|
import {SplitPage} from "./SplitPage";
|
|
7
7
|
import {renderWithTheme} from "./test-utils";
|
|
@@ -353,7 +353,7 @@ describe("SplitPage", () => {
|
|
|
353
353
|
fireEvent.press(boxes[0]);
|
|
354
354
|
});
|
|
355
355
|
const iconButtons = UNSAFE_root.findAll(
|
|
356
|
-
(n:
|
|
356
|
+
(n: ReactTestInstance) => n.props?.onClick && n.props?.iconName === "xmark"
|
|
357
357
|
);
|
|
358
358
|
if (iconButtons.length > 0) {
|
|
359
359
|
await act(async () => {
|
|
@@ -362,7 +362,7 @@ describe("SplitPage", () => {
|
|
|
362
362
|
expect(onSelectionChange).toHaveBeenCalledWith(undefined);
|
|
363
363
|
} else {
|
|
364
364
|
const closeButtons = UNSAFE_root.findAll(
|
|
365
|
-
(n:
|
|
365
|
+
(n: ReactTestInstance) => n.props?.accessibilityLabel === "close"
|
|
366
366
|
);
|
|
367
367
|
if (closeButtons.length > 0) {
|
|
368
368
|
await act(async () => {
|
|
@@ -449,7 +449,9 @@ describe("SplitPage", () => {
|
|
|
449
449
|
<View testID="child-c" />
|
|
450
450
|
</SplitPage>
|
|
451
451
|
);
|
|
452
|
-
const segmented = UNSAFE_root.findAll(
|
|
452
|
+
const segmented = UNSAFE_root.findAll(
|
|
453
|
+
(n: ReactTestInstance) => n.props?.onChange && n.props?.items
|
|
454
|
+
);
|
|
453
455
|
if (segmented.length > 0) {
|
|
454
456
|
await act(async () => {
|
|
455
457
|
segmented[0].props.onChange(2);
|
package/src/SplitPage.tsx
CHANGED
|
@@ -40,6 +40,7 @@ export const SplitPage = ({
|
|
|
40
40
|
const elementArray = Children.toArray(children).filter((c) => c !== null);
|
|
41
41
|
|
|
42
42
|
const onItemSelect = useCallback(
|
|
43
|
+
// noExplicitAny: SplitPage accepts heterogeneous list item shapes from consumers; the generic propagates from listViewData
|
|
43
44
|
// biome-ignore lint/suspicious/noExplicitAny: SplitPage accepts heterogeneous list item shapes from consumers; the generic propagates from listViewData
|
|
44
45
|
async (item: ListRenderItemInfo<any>): Promise<void> => {
|
|
45
46
|
setSelectedId(item.index);
|
|
@@ -70,6 +71,7 @@ export const SplitPage = ({
|
|
|
70
71
|
return null;
|
|
71
72
|
}
|
|
72
73
|
|
|
74
|
+
// noExplicitAny: SplitPage accepts heterogeneous list item shapes from consumers; the generic propagates from listViewData
|
|
73
75
|
// biome-ignore lint/suspicious/noExplicitAny: SplitPage accepts heterogeneous list item shapes from consumers; the generic propagates from listViewData
|
|
74
76
|
const renderItem = (itemInfo: ListRenderItemInfo<any>) => {
|
|
75
77
|
return (
|
|
@@ -300,6 +302,7 @@ export const SplitPage = ({
|
|
|
300
302
|
width="100%"
|
|
301
303
|
>
|
|
302
304
|
{loading === true && (
|
|
305
|
+
// noExplicitAny: Spinner color is a token enum but the legacy code passes theme.text.primary (a resolved hex string); preserving original behavior
|
|
303
306
|
// biome-ignore lint/suspicious/noExplicitAny: Spinner color is a token enum but the legacy code passes theme.text.primary (a resolved hex string); preserving original behavior
|
|
304
307
|
<Spinner color={theme.text.primary as any} size="md" />
|
|
305
308
|
)}
|
package/src/TapToEdit.test.tsx
CHANGED
package/src/TapToEdit.tsx
CHANGED
|
@@ -84,6 +84,7 @@ export const TapToEdit: FC<TapToEditProps> = ({
|
|
|
84
84
|
const helperText: string | undefined = propsHelperText;
|
|
85
85
|
|
|
86
86
|
// TODO: Auto focus on input when editing for field types other than text for accessibility
|
|
87
|
+
// noExplicitAny: inputRef references various RN input components (TextInput, etc.) depending on the field type
|
|
87
88
|
// biome-ignore lint/suspicious/noExplicitAny: inputRef references various RN input components (TextInput, etc.) depending on the field type
|
|
88
89
|
const inputRef = useRef<any>(null);
|
|
89
90
|
|
|
@@ -120,6 +121,7 @@ export const TapToEdit: FC<TapToEditProps> = ({
|
|
|
120
121
|
row={fieldProps?.type === "textarea" ? 5 : undefined}
|
|
121
122
|
type={(fieldProps?.type ?? "text") as NonNullable<FieldProps["type"]>}
|
|
122
123
|
value={value}
|
|
124
|
+
// noExplicitAny: fieldProps is a discriminated union (FieldProps) but the spread loses narrowing; type-checking each variant individually is impractical here
|
|
123
125
|
// biome-ignore lint/suspicious/noExplicitAny: fieldProps is a discriminated union (FieldProps) but the spread loses narrowing; type-checking each variant individually is impractical here
|
|
124
126
|
{...(fieldProps as any)}
|
|
125
127
|
/>
|
package/src/Text.test.tsx
CHANGED
|
@@ -60,6 +60,35 @@ describe("Text", () => {
|
|
|
60
60
|
expect(toJSON()).toMatchSnapshot();
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
+
it("uses the medium-italic font family for larger italic text", () => {
|
|
64
|
+
const {getByText} = renderWithTheme(
|
|
65
|
+
<Text italic size="lg">
|
|
66
|
+
Large italic
|
|
67
|
+
</Text>
|
|
68
|
+
);
|
|
69
|
+
expect((getByText("Large italic").props.style as {fontFamily?: string}).fontFamily).toBe(
|
|
70
|
+
"text-medium-italic"
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("uses the bold-italic font family for larger bold italic text", () => {
|
|
75
|
+
const {getByText} = renderWithTheme(
|
|
76
|
+
<Text bold italic size="xl">
|
|
77
|
+
Large bold italic
|
|
78
|
+
</Text>
|
|
79
|
+
);
|
|
80
|
+
expect((getByText("Large bold italic").props.style as {fontFamily?: string}).fontFamily).toBe(
|
|
81
|
+
"text-bold-italic"
|
|
82
|
+
);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("uses the medium font family for larger plain text", () => {
|
|
86
|
+
const {getByText} = renderWithTheme(<Text size="2xl">Extra large plain</Text>);
|
|
87
|
+
expect((getByText("Extra large plain").props.style as {fontFamily?: string}).fontFamily).toBe(
|
|
88
|
+
"text-medium"
|
|
89
|
+
);
|
|
90
|
+
});
|
|
91
|
+
|
|
63
92
|
it("renders underlined text", () => {
|
|
64
93
|
const {toJSON} = renderWithTheme(<Text underline>Underlined text</Text>);
|
|
65
94
|
expect(toJSON()).toMatchSnapshot();
|
package/src/TextField.test.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {afterEach, beforeEach, describe, expect, it, mock} from "bun:test";
|
|
1
|
+
import {afterEach, beforeEach, describe, expect, it, mock, spyOn} from "bun:test";
|
|
2
2
|
import {act, fireEvent, userEvent} from "@testing-library/react-native";
|
|
3
3
|
import {TextField} from "./TextField";
|
|
4
4
|
import {renderWithTheme} from "./test-utils";
|
|
@@ -484,4 +484,60 @@ describe("TextField", () => {
|
|
|
484
484
|
expect(component.toJSON()).toMatchSnapshot();
|
|
485
485
|
});
|
|
486
486
|
});
|
|
487
|
+
|
|
488
|
+
describe("platform, unsupported types, and content sizing", () => {
|
|
489
|
+
const PlatformModule = require("react-native").Platform;
|
|
490
|
+
|
|
491
|
+
it("renders with the web outline style when running on web", () => {
|
|
492
|
+
const savedOS = PlatformModule.OS;
|
|
493
|
+
try {
|
|
494
|
+
PlatformModule.OS = "web";
|
|
495
|
+
const {getByDisplayValue} = renderWithTheme(
|
|
496
|
+
<TextField onChange={mockOnChange} value="web value" />
|
|
497
|
+
);
|
|
498
|
+
expect(getByDisplayValue("web value")).toBeTruthy();
|
|
499
|
+
} finally {
|
|
500
|
+
PlatformModule.OS = savedOS;
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
it("warns for not-yet-supported field types", () => {
|
|
505
|
+
const warnSpy = spyOn(console, "warn").mockImplementation(() => {});
|
|
506
|
+
try {
|
|
507
|
+
renderWithTheme(<TextField onChange={mockOnChange} type="numberRange" value="" />);
|
|
508
|
+
expect(warnSpy).toHaveBeenCalledWith("numberRange is not yet supported");
|
|
509
|
+
} finally {
|
|
510
|
+
warnSpy.mockRestore();
|
|
511
|
+
}
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
it("ignores content size changes when grow is disabled", () => {
|
|
515
|
+
const {getByDisplayValue} = renderWithTheme(
|
|
516
|
+
<TextField multiline onChange={mockOnChange} value="" />
|
|
517
|
+
);
|
|
518
|
+
const input = getByDisplayValue("");
|
|
519
|
+
// Without `grow`, onContentSizeChange returns early and must not throw.
|
|
520
|
+
expect(() =>
|
|
521
|
+
fireEvent(input, "contentSizeChange", {nativeEvent: {contentSize: {height: 999}}})
|
|
522
|
+
).not.toThrow();
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
it("grows to the reported content height when grow is enabled", () => {
|
|
526
|
+
const {getByDisplayValue} = renderWithTheme(
|
|
527
|
+
<TextField grow multiline onChange={mockOnChange} value="" />
|
|
528
|
+
);
|
|
529
|
+
const input = getByDisplayValue("");
|
|
530
|
+
expect(() =>
|
|
531
|
+
fireEvent(input, "contentSizeChange", {nativeEvent: {contentSize: {height: 120}}})
|
|
532
|
+
).not.toThrow();
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
it("invokes the onFocus callback when the input is focused", () => {
|
|
536
|
+
const {getByDisplayValue} = renderWithTheme(
|
|
537
|
+
<TextField onChange={mockOnChange} onFocus={mockOnFocus} value="" />
|
|
538
|
+
);
|
|
539
|
+
fireEvent(getByDisplayValue(""), "focus");
|
|
540
|
+
expect(mockOnFocus).toHaveBeenCalledTimes(1);
|
|
541
|
+
});
|
|
542
|
+
});
|
|
487
543
|
});
|
package/src/TextField.tsx
CHANGED
|
@@ -12,7 +12,9 @@ import {
|
|
|
12
12
|
|
|
13
13
|
import {AiSuggestionBox} from "./AiSuggestionBox";
|
|
14
14
|
import type {TextFieldProps, TextStyleWithOutline} from "./Common";
|
|
15
|
-
import {FieldError
|
|
15
|
+
import {FieldError} from "./fieldElements/FieldError";
|
|
16
|
+
import {FieldHelperText} from "./fieldElements/FieldHelperText";
|
|
17
|
+
import {FieldTitle} from "./fieldElements/FieldTitle";
|
|
16
18
|
import {Icon} from "./Icon";
|
|
17
19
|
import {useTheme} from "./Theme";
|
|
18
20
|
import {resolveFieldTestIDsFromProps} from "./testing/resolveTestId";
|
|
@@ -1200,6 +1200,7 @@ describe("ToastNotifications", () => {
|
|
|
1200
1200
|
});
|
|
1201
1201
|
|
|
1202
1202
|
describe("Toast with swipe and pan responder interaction", () => {
|
|
1203
|
+
// noExplicitAny: capturing PanResponder internals for test
|
|
1203
1204
|
// biome-ignore lint/suspicious/noExplicitAny: capturing PanResponder internals for test
|
|
1204
1205
|
type PanConfig = any;
|
|
1205
1206
|
let capturedPanConfigs: PanConfig[] = [];
|
|
@@ -177,6 +177,7 @@ export interface ToastOptions {
|
|
|
177
177
|
/**
|
|
178
178
|
* Payload data for custom toasts. You can pass whatever you want
|
|
179
179
|
*/
|
|
180
|
+
// noExplicitAny: This is the public API of a vendored 3rd-party library (react-native-toast-notifications); the data field is an opaque user-provided payload. Tightening to unknown breaks downstream consumers that spread data into Toast (e.g. TerrenoProvider) without refactor.
|
|
180
181
|
// biome-ignore lint/suspicious/noExplicitAny: This is the public API of a vendored 3rd-party library (react-native-toast-notifications); the data field is an opaque user-provided payload. Tightening to unknown breaks downstream consumers that spread data into Toast (e.g. TerrenoProvider) without refactor.
|
|
181
182
|
data?: any;
|
|
182
183
|
|
package/src/Tooltip.test.tsx
CHANGED
|
@@ -776,7 +776,7 @@ describe("Tooltip", () => {
|
|
|
776
776
|
(c: TestNode) => c.props && (c.props as {hitSlop?: object}).hitSlop !== undefined
|
|
777
777
|
) as TestNode | undefined;
|
|
778
778
|
await act(async () => {
|
|
779
|
-
(wrapper?.props as {onPress?: () => void})
|
|
779
|
+
(wrapper?.props as {onPress?: () => void} | undefined)?.onPress?.();
|
|
780
780
|
});
|
|
781
781
|
expect(queryByTestId("tooltip-container")).toBeNull();
|
|
782
782
|
});
|
package/src/Unifier.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {requestPermissions} from "./Permissions";
|
|
|
8
8
|
|
|
9
9
|
declare global {
|
|
10
10
|
interface Window {
|
|
11
|
+
// noExplicitAny: Google Maps JS SDK global type is loaded dynamically and not bundled as a typed dependency
|
|
11
12
|
// biome-ignore lint/suspicious/noExplicitAny: Google Maps JS SDK global type is loaded dynamically and not bundled as a typed dependency
|
|
12
13
|
google: any;
|
|
13
14
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {describe, expect, it, mock} from "bun:test";
|
|
2
|
+
import {fireEvent, waitFor} from "@testing-library/react-native";
|
|
3
|
+
|
|
4
|
+
import {renderWithTheme} from "./test-utils";
|
|
5
|
+
import {UpgradeRequiredScreen} from "./UpgradeRequiredScreen";
|
|
6
|
+
|
|
7
|
+
describe("UpgradeRequiredScreen", () => {
|
|
8
|
+
it("renders the heading, message, and update button by default", () => {
|
|
9
|
+
const {getByText} = renderWithTheme(
|
|
10
|
+
<UpgradeRequiredScreen message="A new version is available" onUpdate={() => {}} />
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
expect(getByText("Update Required")).toBeTruthy();
|
|
14
|
+
expect(getByText("A new version is available")).toBeTruthy();
|
|
15
|
+
expect(getByText("Update")).toBeTruthy();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("invokes onUpdate when the update button is pressed", async () => {
|
|
19
|
+
const onUpdate = mock(() => {});
|
|
20
|
+
const {getByText} = renderWithTheme(
|
|
21
|
+
<UpgradeRequiredScreen canUpdate message="Please update now" onUpdate={onUpdate} />
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
fireEvent.press(getByText("Update"));
|
|
25
|
+
|
|
26
|
+
await waitFor(() => {
|
|
27
|
+
expect(onUpdate).toHaveBeenCalledTimes(1);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("shows contact-support text instead of the button when canUpdate is false", () => {
|
|
32
|
+
const {getByText, queryByText} = renderWithTheme(
|
|
33
|
+
<UpgradeRequiredScreen canUpdate={false} message="No update path" onUpdate={() => {}} />
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
expect(getByText("No update path")).toBeTruthy();
|
|
37
|
+
expect(getByText("Please contact support or check your app store for an update.")).toBeTruthy();
|
|
38
|
+
expect(queryByText("Update")).toBeNull();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import {describe, expect, it, mock, spyOn} from "bun:test";
|
|
2
2
|
import {act} from "@testing-library/react-native";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
type EmitterSubscription,
|
|
5
|
+
type GestureResponderEvent,
|
|
6
|
+
Keyboard,
|
|
7
|
+
PanResponder,
|
|
8
|
+
type PanResponderCallbacks,
|
|
9
|
+
type PanResponderGestureState,
|
|
10
|
+
type PanResponderInstance,
|
|
11
|
+
} from "react-native";
|
|
4
12
|
|
|
5
13
|
import {Text} from "./Text";
|
|
6
14
|
import {renderWithTheme} from "./test-utils";
|
|
@@ -165,4 +173,39 @@ describe("UserInactivity", () => {
|
|
|
165
173
|
expect(onAction).toHaveBeenCalledWith(true);
|
|
166
174
|
addListenerSpy.mockRestore();
|
|
167
175
|
});
|
|
176
|
+
|
|
177
|
+
it("resets the inactivity timer when a pan responder capture handler fires", () => {
|
|
178
|
+
const onAction = mock((_active: boolean) => {});
|
|
179
|
+
let capturedConfig: PanResponderCallbacks | undefined;
|
|
180
|
+
const originalCreate = PanResponder.create;
|
|
181
|
+
PanResponder.create = (config: PanResponderCallbacks): PanResponderInstance => {
|
|
182
|
+
capturedConfig = config;
|
|
183
|
+
return originalCreate(config);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
try {
|
|
187
|
+
const {unmount} = renderWithTheme(
|
|
188
|
+
<UserInactivity onAction={onAction} skipKeyboard={true}>
|
|
189
|
+
<Text>Test Content</Text>
|
|
190
|
+
</UserInactivity>
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
expect(capturedConfig).toBeDefined();
|
|
194
|
+
|
|
195
|
+
let shouldSet: boolean | undefined;
|
|
196
|
+
act(() => {
|
|
197
|
+
shouldSet = capturedConfig?.onStartShouldSetPanResponderCapture?.(
|
|
198
|
+
{} as unknown as GestureResponderEvent,
|
|
199
|
+
{} as unknown as PanResponderGestureState
|
|
200
|
+
);
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
expect(shouldSet).toBe(false);
|
|
204
|
+
act(() => {
|
|
205
|
+
unmount();
|
|
206
|
+
});
|
|
207
|
+
} finally {
|
|
208
|
+
PanResponder.create = originalCreate;
|
|
209
|
+
}
|
|
210
|
+
});
|
|
168
211
|
});
|
|
@@ -4,7 +4,7 @@ import type {ComponentProps} from "react";
|
|
|
4
4
|
import {Dimensions} from "react-native";
|
|
5
5
|
|
|
6
6
|
import {renderWithTheme} from "./test-utils";
|
|
7
|
-
import {useWebDropdownAnchor, WebDropdownMenu} from "./WebDropdownMenu";
|
|
7
|
+
import {scheduleAfterPaint, useWebDropdownAnchor, WebDropdownMenu} from "./WebDropdownMenu";
|
|
8
8
|
|
|
9
9
|
describe("WebDropdownMenu", () => {
|
|
10
10
|
const anchor = {height: 40, width: 200, x: 16, y: 32};
|
|
@@ -676,3 +676,118 @@ describe("useWebDropdownAnchor", () => {
|
|
|
676
676
|
expect(pressedStyle).toHaveProperty("paddingHorizontal");
|
|
677
677
|
});
|
|
678
678
|
});
|
|
679
|
+
|
|
680
|
+
describe("scheduleAfterPaint", () => {
|
|
681
|
+
it("uses requestAnimationFrame when it is available", () => {
|
|
682
|
+
const original = globalThis.requestAnimationFrame;
|
|
683
|
+
const raf = mock((cb: FrameRequestCallback) => {
|
|
684
|
+
cb(0);
|
|
685
|
+
return 1;
|
|
686
|
+
});
|
|
687
|
+
(globalThis as {requestAnimationFrame?: typeof requestAnimationFrame}).requestAnimationFrame =
|
|
688
|
+
raf as unknown as typeof requestAnimationFrame;
|
|
689
|
+
try {
|
|
690
|
+
const callback = mock(() => {});
|
|
691
|
+
scheduleAfterPaint(callback);
|
|
692
|
+
expect(raf).toHaveBeenCalledTimes(1);
|
|
693
|
+
expect(callback).toHaveBeenCalledTimes(1);
|
|
694
|
+
} finally {
|
|
695
|
+
if (original) {
|
|
696
|
+
globalThis.requestAnimationFrame = original;
|
|
697
|
+
} else {
|
|
698
|
+
(
|
|
699
|
+
globalThis as {requestAnimationFrame?: typeof requestAnimationFrame}
|
|
700
|
+
).requestAnimationFrame = undefined;
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
});
|
|
704
|
+
|
|
705
|
+
it("falls back to setTimeout when requestAnimationFrame is unavailable", () => {
|
|
706
|
+
const original = globalThis.requestAnimationFrame;
|
|
707
|
+
(globalThis as {requestAnimationFrame?: typeof requestAnimationFrame}).requestAnimationFrame =
|
|
708
|
+
undefined;
|
|
709
|
+
try {
|
|
710
|
+
const callback = mock(() => {});
|
|
711
|
+
scheduleAfterPaint(callback);
|
|
712
|
+
expect(callback).not.toHaveBeenCalled();
|
|
713
|
+
} finally {
|
|
714
|
+
if (original) {
|
|
715
|
+
globalThis.requestAnimationFrame = original;
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
});
|
|
719
|
+
});
|
|
720
|
+
|
|
721
|
+
describe("WebDropdownMenu layout callbacks", () => {
|
|
722
|
+
const anchor = {height: 40, width: 200, x: 16, y: 32};
|
|
723
|
+
const options = [
|
|
724
|
+
{label: "Option A", value: "a"},
|
|
725
|
+
{label: "Option B", value: "b"},
|
|
726
|
+
{label: "Option C", value: "c"},
|
|
727
|
+
];
|
|
728
|
+
|
|
729
|
+
it("handles ScrollView onLayout without throwing", () => {
|
|
730
|
+
const {root} = renderWithTheme(
|
|
731
|
+
<WebDropdownMenu
|
|
732
|
+
anchor={anchor}
|
|
733
|
+
onClose={() => {}}
|
|
734
|
+
onSelect={() => {}}
|
|
735
|
+
options={options}
|
|
736
|
+
searchable={false}
|
|
737
|
+
selectedIndex={1}
|
|
738
|
+
visible
|
|
739
|
+
/>
|
|
740
|
+
);
|
|
741
|
+
const scrollView = root.findAll((node) => node.type === "ScrollView")[0];
|
|
742
|
+
expect(scrollView).toBeTruthy();
|
|
743
|
+
act(() => {
|
|
744
|
+
fireEvent(scrollView, "layout", {nativeEvent: {layout: {height: 200, width: 200}}});
|
|
745
|
+
});
|
|
746
|
+
// The list viewport height is recorded and a scroll is scheduled; the
|
|
747
|
+
// component should remain mounted and functional.
|
|
748
|
+
expect(root.findAll((node) => node.type === "ScrollView").length).toBeGreaterThan(0);
|
|
749
|
+
});
|
|
750
|
+
|
|
751
|
+
it("records option layout and schedules a scroll for the selected option", () => {
|
|
752
|
+
const {getByTestId} = renderWithTheme(
|
|
753
|
+
<WebDropdownMenu
|
|
754
|
+
anchor={anchor}
|
|
755
|
+
onClose={() => {}}
|
|
756
|
+
onSelect={() => {}}
|
|
757
|
+
options={options}
|
|
758
|
+
searchable={false}
|
|
759
|
+
selectedIndex={1}
|
|
760
|
+
visible
|
|
761
|
+
/>
|
|
762
|
+
);
|
|
763
|
+
act(() => {
|
|
764
|
+
fireEvent(getByTestId("web_dropdown_option_a"), "layout", {
|
|
765
|
+
nativeEvent: {layout: {height: 40, width: 200, x: 0, y: 0}},
|
|
766
|
+
});
|
|
767
|
+
// The selected option (index 1) triggers the scroll-into-view branch.
|
|
768
|
+
fireEvent(getByTestId("web_dropdown_option_b"), "layout", {
|
|
769
|
+
nativeEvent: {layout: {height: 40, width: 200, x: 0, y: 40}},
|
|
770
|
+
});
|
|
771
|
+
});
|
|
772
|
+
expect(getByTestId("web_dropdown_option_b")).toBeTruthy();
|
|
773
|
+
});
|
|
774
|
+
|
|
775
|
+
it("does not schedule a scroll for option layout when nothing is selected", () => {
|
|
776
|
+
const {getByTestId} = renderWithTheme(
|
|
777
|
+
<WebDropdownMenu
|
|
778
|
+
anchor={anchor}
|
|
779
|
+
onClose={() => {}}
|
|
780
|
+
onSelect={() => {}}
|
|
781
|
+
options={options}
|
|
782
|
+
searchable={false}
|
|
783
|
+
visible
|
|
784
|
+
/>
|
|
785
|
+
);
|
|
786
|
+
act(() => {
|
|
787
|
+
fireEvent(getByTestId("web_dropdown_option_a"), "layout", {
|
|
788
|
+
nativeEvent: {layout: {height: 40, width: 200, x: 0, y: 0}},
|
|
789
|
+
});
|
|
790
|
+
});
|
|
791
|
+
expect(getByTestId("web_dropdown_option_a")).toBeTruthy();
|
|
792
|
+
});
|
|
793
|
+
});
|
|
@@ -8726,154 +8726,6 @@ exports[`DataTable renders with more content component 1`] = `
|
|
|
8726
8726
|
},
|
|
8727
8727
|
"type": "ScrollView",
|
|
8728
8728
|
},
|
|
8729
|
-
{
|
|
8730
|
-
"$$typeof": Symbol(react.test.json),
|
|
8731
|
-
"children": [
|
|
8732
|
-
{
|
|
8733
|
-
"$$typeof": Symbol(react.test.json),
|
|
8734
|
-
"children": [
|
|
8735
|
-
{
|
|
8736
|
-
"$$typeof": Symbol(react.test.json),
|
|
8737
|
-
"children": [
|
|
8738
|
-
{
|
|
8739
|
-
"$$typeof": Symbol(react.test.json),
|
|
8740
|
-
"children": [
|
|
8741
|
-
{
|
|
8742
|
-
"$$typeof": Symbol(react.test.json),
|
|
8743
|
-
"children": [
|
|
8744
|
-
{
|
|
8745
|
-
"$$typeof": Symbol(react.test.json),
|
|
8746
|
-
"children": null,
|
|
8747
|
-
"props": {
|
|
8748
|
-
"accessibilityHint": "Closes the modal",
|
|
8749
|
-
"aria-label": "Close modal",
|
|
8750
|
-
"aria-role": "button",
|
|
8751
|
-
"onPress": [Function],
|
|
8752
|
-
"style": {
|
|
8753
|
-
"alignItems": "center",
|
|
8754
|
-
"bottom": -8,
|
|
8755
|
-
"flex": 1,
|
|
8756
|
-
"justifyContent": "center",
|
|
8757
|
-
"left": -8,
|
|
8758
|
-
"position": "absolute",
|
|
8759
|
-
"right": -8,
|
|
8760
|
-
"top": -8,
|
|
8761
|
-
},
|
|
8762
|
-
},
|
|
8763
|
-
"type": "Pressable",
|
|
8764
|
-
},
|
|
8765
|
-
],
|
|
8766
|
-
"props": {
|
|
8767
|
-
"style": {
|
|
8768
|
-
"alignSelf": "flex-end",
|
|
8769
|
-
"position": "relative",
|
|
8770
|
-
},
|
|
8771
|
-
"testID": undefined,
|
|
8772
|
-
},
|
|
8773
|
-
"type": "View",
|
|
8774
|
-
},
|
|
8775
|
-
{
|
|
8776
|
-
"$$typeof": Symbol(react.test.json),
|
|
8777
|
-
"children": [
|
|
8778
|
-
{
|
|
8779
|
-
"$$typeof": Symbol(react.test.json),
|
|
8780
|
-
"children": [
|
|
8781
|
-
{
|
|
8782
|
-
"$$typeof": Symbol(react.test.json),
|
|
8783
|
-
"children": [
|
|
8784
|
-
"Row ",
|
|
8785
|
-
" details",
|
|
8786
|
-
],
|
|
8787
|
-
"props": {
|
|
8788
|
-
"numberOfLines": 0,
|
|
8789
|
-
"selectable": undefined,
|
|
8790
|
-
"style": {
|
|
8791
|
-
"color": "#1C1C1C",
|
|
8792
|
-
"fontFamily": "text-regular",
|
|
8793
|
-
"fontSize": 14,
|
|
8794
|
-
"textAlign": "left",
|
|
8795
|
-
},
|
|
8796
|
-
"testID": undefined,
|
|
8797
|
-
},
|
|
8798
|
-
"type": "Text",
|
|
8799
|
-
},
|
|
8800
|
-
],
|
|
8801
|
-
"props": {},
|
|
8802
|
-
"type": "View",
|
|
8803
|
-
},
|
|
8804
|
-
],
|
|
8805
|
-
"props": {
|
|
8806
|
-
"style": {
|
|
8807
|
-
"flex": 1,
|
|
8808
|
-
"marginTop": 12,
|
|
8809
|
-
"width": "100%",
|
|
8810
|
-
},
|
|
8811
|
-
"testID": undefined,
|
|
8812
|
-
},
|
|
8813
|
-
"type": "View",
|
|
8814
|
-
},
|
|
8815
|
-
{
|
|
8816
|
-
"$$typeof": Symbol(react.test.json),
|
|
8817
|
-
"children": null,
|
|
8818
|
-
"props": {
|
|
8819
|
-
"style": {
|
|
8820
|
-
"alignSelf": "flex-end",
|
|
8821
|
-
"flexDirection": "row",
|
|
8822
|
-
"marginTop": 32,
|
|
8823
|
-
},
|
|
8824
|
-
"testID": undefined,
|
|
8825
|
-
},
|
|
8826
|
-
"type": "View",
|
|
8827
|
-
},
|
|
8828
|
-
],
|
|
8829
|
-
"props": {
|
|
8830
|
-
"style": {
|
|
8831
|
-
"alignItems": "center",
|
|
8832
|
-
"alignSelf": "center",
|
|
8833
|
-
"backgroundColor": "#FFFFFF",
|
|
8834
|
-
"borderRadius": 4,
|
|
8835
|
-
"boxShadow": "0px 4px 24px rgba(0, 0, 0, 0.5)",
|
|
8836
|
-
"elevation": 24,
|
|
8837
|
-
"margin": "auto",
|
|
8838
|
-
"maxHeight": "100%",
|
|
8839
|
-
"padding": 32,
|
|
8840
|
-
"width": "90%",
|
|
8841
|
-
"zIndex": 1,
|
|
8842
|
-
},
|
|
8843
|
-
"testID": undefined,
|
|
8844
|
-
},
|
|
8845
|
-
"type": "View",
|
|
8846
|
-
},
|
|
8847
|
-
],
|
|
8848
|
-
"props": {
|
|
8849
|
-
"onPress": [Function],
|
|
8850
|
-
"style": {
|
|
8851
|
-
"cursor": "auto",
|
|
8852
|
-
},
|
|
8853
|
-
},
|
|
8854
|
-
"type": "Pressable",
|
|
8855
|
-
},
|
|
8856
|
-
],
|
|
8857
|
-
"props": {
|
|
8858
|
-
"onPress": [Function],
|
|
8859
|
-
"style": {
|
|
8860
|
-
"alignItems": "center",
|
|
8861
|
-
"backgroundColor": "rgba(0, 0, 0, 0.5)",
|
|
8862
|
-
"flex": 1,
|
|
8863
|
-
"justifyContent": "center",
|
|
8864
|
-
},
|
|
8865
|
-
},
|
|
8866
|
-
"type": "Pressable",
|
|
8867
|
-
},
|
|
8868
|
-
],
|
|
8869
|
-
"props": {
|
|
8870
|
-
"animationType": "none",
|
|
8871
|
-
"onRequestClose": [Function],
|
|
8872
|
-
"transparent": true,
|
|
8873
|
-
"visible": false,
|
|
8874
|
-
},
|
|
8875
|
-
"type": "Modal",
|
|
8876
|
-
},
|
|
8877
8729
|
],
|
|
8878
8730
|
"props": {
|
|
8879
8731
|
"style": {
|
|
@@ -31,3 +31,7 @@ exports[`IconButton renders with confirmation props 1`] = `null`;
|
|
|
31
31
|
exports[`IconButton renders ghost variant 1`] = `null`;
|
|
32
32
|
|
|
33
33
|
exports[`IconButton renders sm size 1`] = `null`;
|
|
34
|
+
|
|
35
|
+
exports[`IconButton renders primary variant in active state 1`] = `null`;
|
|
36
|
+
|
|
37
|
+
exports[`IconButton renders ghost variant in active state 1`] = `null`;
|