@terreno/ui 57.20.0 → 57.21.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/CHANGELOG.md +50 -0
- package/dist/Common.d.ts +55 -27
- package/dist/Common.d.ts.map +1 -1
- package/dist/Common.js.map +1 -1
- package/dist/DateTimeField.js +6 -6
- package/dist/DateTimeField.js.map +1 -1
- package/dist/HeightField.js +8 -8
- package/dist/HeightField.js.map +1 -1
- package/dist/OtpField.js +4 -4
- package/dist/OtpField.js.map +1 -1
- package/dist/PickerSelect.js +9 -9
- package/dist/PickerSelect.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/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/package.json +4 -2
- package/src/ActionSheet.test.tsx +13 -13
- package/src/AddressField.test.tsx +9 -3
- package/src/AnnouncementNavigator.test.tsx +4 -4
- package/src/Badge.test.tsx +1 -1
- package/src/Banner.test.tsx +0 -1
- package/src/Box.test.tsx +82 -74
- package/src/Button.test.tsx +11 -6
- package/src/Card.test.tsx +2 -2
- package/src/Common.ts +60 -29
- package/src/ConflictSheet.test.tsx +5 -5
- package/src/ConsentFormScreen.test.tsx +3 -1
- package/src/ConsentNavigator.test.tsx +1 -2
- package/src/CustomSelectField.test.tsx +16 -4
- package/src/DataTable.test.tsx +4 -4
- 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 +6 -6
- package/src/DismissButton.test.tsx +22 -4
- 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/GPTChat.test.tsx +24 -16
- package/src/Heading.test.tsx +1 -1
- package/src/HeightField.tsx +8 -8
- package/src/Icon.test.tsx +2 -2
- package/src/Image.test.tsx +1 -1
- package/src/Link.test.tsx +11 -4
- package/src/MarkdownView.test.tsx +1 -1
- package/src/MobileAddressAutoComplete.test.tsx +2 -1
- package/src/Modal.test.tsx +7 -2
- package/src/ModalSheet.test.tsx +5 -4
- package/src/MultiselectField.test.tsx +17 -3
- package/src/NumberField.test.tsx +14 -14
- package/src/NumberPickerActionSheet.test.tsx +1 -1
- package/src/OpenAPIContext.test.tsx +4 -4
- package/src/OpenAPIRenderRegression.test.tsx +1 -1
- package/src/OtpField.tsx +4 -4
- 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 +9 -9
- package/src/Popover.test.tsx +2 -2
- package/src/RadioField.test.tsx +7 -2
- package/src/SegmentedControl.test.tsx +21 -12
- package/src/SidebarNavigation.test.tsx +18 -6
- package/src/Signature.test.tsx +20 -23
- package/src/Slider.test.tsx +1 -1
- package/src/SplitPage.test.tsx +15 -5
- package/src/TapToEdit.test.tsx +38 -15
- package/src/TapToEdit.tsx +1 -1
- package/src/TerrenoFontProvider.test.tsx +1 -1
- package/src/Text.test.tsx +4 -4
- package/src/TextField.test.tsx +82 -9
- package/src/TextField.tsx +4 -4
- package/src/Theme.test.tsx +49 -0
- package/src/Theme.tsx +16 -0
- package/src/Toast.test.tsx +5 -5
- package/src/ToastNotifications.test.tsx +73 -70
- package/src/ToastNotifications.webModal.test.tsx +2 -2
- package/src/Tooltip.test.tsx +3 -3
- package/src/UnifiedAddressAutoComplete.test.tsx +1 -1
- package/src/UserInactivity.test.tsx +4 -2
- package/src/WebAddressAutocomplete.test.tsx +12 -12
- package/src/WebDropdownMenu.test.tsx +16 -15
- package/src/__snapshots__/Card.test.tsx.snap +1 -1
- 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/asks/AskCard.test.tsx +16 -13
- 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 +1 -1
- package/src/dataTableFilters.test.tsx +1 -1
- package/src/isolated/ListDetailLayout.isolated.tsx +2 -4
- package/src/login/LoginScreen.test.tsx +6 -6
- package/src/security/PasswordCard.test.tsx +3 -3
- package/src/signUp/SignUpScreen.test.tsx +4 -4
- package/src/table/tableContext.test.tsx +5 -5
- package/src/test-utils.tsx +56 -1
- package/src/testing/reactDomServer.d.ts +7 -0
- package/src/useConsentForms.test.ts +1 -1
package/src/Card.test.tsx
CHANGED
|
@@ -33,7 +33,7 @@ const setWindowWidth = (width: number): (() => void) => {
|
|
|
33
33
|
useWindowDimensionsMock.mockImplementation(dimensionsImpl);
|
|
34
34
|
|
|
35
35
|
return (): void => {
|
|
36
|
-
useWindowDimensionsMock.mockImplementation(getScaledSize(375));
|
|
36
|
+
useWindowDimensionsMock.mockImplementation?.(getScaledSize(375));
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -71,7 +71,7 @@ describe("Card", () => {
|
|
|
71
71
|
|
|
72
72
|
it("applies custom color", () => {
|
|
73
73
|
const {toJSON} = renderWithTheme(
|
|
74
|
-
<Card color="
|
|
74
|
+
<Card color="secondaryDark">
|
|
75
75
|
<Text>Content</Text>
|
|
76
76
|
</Card>
|
|
77
77
|
);
|
package/src/Common.ts
CHANGED
|
@@ -260,6 +260,16 @@ export interface BorderThemeConfig {
|
|
|
260
260
|
warning: keyof ThemePrimitiveColors;
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
+
/** Maps form field (TextField, TextArea, SelectField, etc.) colors to primitives. */
|
|
264
|
+
export interface FieldThemeConfig {
|
|
265
|
+
background: keyof ThemePrimitiveColors;
|
|
266
|
+
backgroundDisabled: keyof ThemePrimitiveColors;
|
|
267
|
+
border: keyof ThemePrimitiveColors;
|
|
268
|
+
borderFocus: keyof ThemePrimitiveColors;
|
|
269
|
+
borderError: keyof ThemePrimitiveColors;
|
|
270
|
+
borderDisabled: keyof ThemePrimitiveColors;
|
|
271
|
+
}
|
|
272
|
+
|
|
263
273
|
export interface StatusThemeConfig {
|
|
264
274
|
active: keyof ThemePrimitiveColors;
|
|
265
275
|
doNotDisturb: keyof ThemePrimitiveColors;
|
|
@@ -334,6 +344,22 @@ export interface BorderTheme {
|
|
|
334
344
|
warning: string;
|
|
335
345
|
}
|
|
336
346
|
|
|
347
|
+
/** Computed form field colors: the input box background and border in each state. */
|
|
348
|
+
export interface FieldTheme {
|
|
349
|
+
/** Input background when enabled. */
|
|
350
|
+
background: string;
|
|
351
|
+
/** Input background when disabled. */
|
|
352
|
+
backgroundDisabled: string;
|
|
353
|
+
/** Input border at rest. */
|
|
354
|
+
border: string;
|
|
355
|
+
/** Input border while focused. */
|
|
356
|
+
borderFocus: string;
|
|
357
|
+
/** Input border when the field has an error. */
|
|
358
|
+
borderError: string;
|
|
359
|
+
/** Input border when disabled. */
|
|
360
|
+
borderDisabled: string;
|
|
361
|
+
}
|
|
362
|
+
|
|
337
363
|
export interface StatusTheme {
|
|
338
364
|
active: string;
|
|
339
365
|
doNotDisturb: string;
|
|
@@ -377,6 +403,7 @@ export interface TerrenoTheme {
|
|
|
377
403
|
text: TextTheme;
|
|
378
404
|
surface: SurfaceTheme;
|
|
379
405
|
border: BorderTheme;
|
|
406
|
+
field: FieldTheme;
|
|
380
407
|
status: StatusTheme;
|
|
381
408
|
radius: RadiusTheme;
|
|
382
409
|
spacing: SpacingTheme;
|
|
@@ -389,6 +416,7 @@ export interface TerrenoThemeConfig {
|
|
|
389
416
|
text: TextThemeConfig;
|
|
390
417
|
surface: SurfaceThemeConfig;
|
|
391
418
|
border: BorderThemeConfig;
|
|
419
|
+
field: FieldThemeConfig;
|
|
392
420
|
status: StatusThemeConfig;
|
|
393
421
|
radius: RadiusThemeConfig;
|
|
394
422
|
spacing: SpacingThemeConfig;
|
|
@@ -1320,7 +1348,7 @@ export interface MetaProps {
|
|
|
1320
1348
|
|
|
1321
1349
|
export interface ImageProps {
|
|
1322
1350
|
alt?: string;
|
|
1323
|
-
color
|
|
1351
|
+
color?: BoxColor;
|
|
1324
1352
|
naturalHeight?: number;
|
|
1325
1353
|
naturalWidth?: number;
|
|
1326
1354
|
maxWidth?: number;
|
|
@@ -1598,36 +1626,39 @@ export interface AddressAutocompleteProps extends WithTestID {
|
|
|
1598
1626
|
googlePlacesMobileStyles?: Styles;
|
|
1599
1627
|
}
|
|
1600
1628
|
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
setModalVisible(visible?: boolean): void;
|
|
1629
|
+
/** Imperative methods exposed by an ActionSheet ref. */
|
|
1630
|
+
export interface ActionSheetHandle {
|
|
1631
|
+
/**
|
|
1632
|
+
* Open or close the ActionSheet.
|
|
1633
|
+
*/
|
|
1634
|
+
setModalVisible(visible?: boolean): void;
|
|
1608
1635
|
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1636
|
+
/**
|
|
1637
|
+
* Open the Action Sheet.
|
|
1638
|
+
*/
|
|
1639
|
+
show(): void;
|
|
1613
1640
|
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1641
|
+
/**
|
|
1642
|
+
* Close the ActionSheet.
|
|
1643
|
+
*/
|
|
1644
|
+
hide(): void;
|
|
1618
1645
|
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1646
|
+
/**
|
|
1647
|
+
* Attach this to any child ScrollView Component's onScrollEndDrag,
|
|
1648
|
+
* onMomentumScrollEnd,onScrollAnimationEnd callbacks to handle the ActionSheet
|
|
1649
|
+
* closing and bouncing back properly.
|
|
1650
|
+
*/
|
|
1651
|
+
handleChildScrollEnd(): void;
|
|
1625
1652
|
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1653
|
+
/**
|
|
1654
|
+
* Snap ActionSheet to given offset
|
|
1655
|
+
*/
|
|
1656
|
+
snapToOffset(offset: number): void;
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1659
|
+
export interface ActionSheetProps extends WithTestID {
|
|
1660
|
+
children?: React.ReactNode;
|
|
1661
|
+
ref?: React.Ref<ActionSheetHandle>;
|
|
1631
1662
|
/**
|
|
1632
1663
|
* Animate the opening and closing of ActionSheet.
|
|
1633
1664
|
|
|
@@ -3982,7 +4013,7 @@ export interface TableNumberProps {
|
|
|
3982
4013
|
/**
|
|
3983
4014
|
* The number to display in the text field.
|
|
3984
4015
|
*/
|
|
3985
|
-
value: string;
|
|
4016
|
+
value: string | number;
|
|
3986
4017
|
/**
|
|
3987
4018
|
* Callback to save the text field value.
|
|
3988
4019
|
*/
|
|
@@ -3991,7 +4022,7 @@ export interface TableNumberProps {
|
|
|
3991
4022
|
* Numbers generally should be right aligned for ease of scanability.
|
|
3992
4023
|
* @default "right"
|
|
3993
4024
|
*/
|
|
3994
|
-
align?: "left" | "right";
|
|
4025
|
+
align?: "left" | "right" | "center";
|
|
3995
4026
|
}
|
|
3996
4027
|
|
|
3997
4028
|
export interface SliderProps extends HelperTextProps, ErrorTextProps {
|
|
@@ -2,7 +2,7 @@ import {describe, expect, it, mock} from "bun:test";
|
|
|
2
2
|
import {fireEvent, within} from "@testing-library/react-native";
|
|
3
3
|
import {DateTime} from "luxon";
|
|
4
4
|
|
|
5
|
-
import {ConflictSheet, type SyncConflictItem} from "./ConflictSheet";
|
|
5
|
+
import {ConflictSheet, type ConflictSheetProps, type SyncConflictItem} from "./ConflictSheet";
|
|
6
6
|
import {renderWithTheme} from "./test-utils";
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -286,7 +286,7 @@ describe("ConflictSheet", () => {
|
|
|
286
286
|
});
|
|
287
287
|
|
|
288
288
|
it("calls onResolve with keepMine but keeps the sheet open until the conflict clears", async () => {
|
|
289
|
-
const onResolve = mock(() => {});
|
|
289
|
+
const onResolve = mock((_args: Parameters<ConflictSheetProps["onResolve"]>[0]) => {});
|
|
290
290
|
const onDismiss = mock(() => {});
|
|
291
291
|
const {getByTestId, rerender} = renderWithTheme(
|
|
292
292
|
<ConflictSheet
|
|
@@ -337,7 +337,7 @@ describe("ConflictSheet", () => {
|
|
|
337
337
|
});
|
|
338
338
|
|
|
339
339
|
it("calls onResolve with useServer without dismissing when other conflicts remain", async () => {
|
|
340
|
-
const onResolve = mock(() => {});
|
|
340
|
+
const onResolve = mock((_args: Parameters<ConflictSheetProps["onResolve"]>[0]) => {});
|
|
341
341
|
const onDismiss = mock(() => {});
|
|
342
342
|
const {getByTestId} = renderWithTheme(
|
|
343
343
|
<ConflictSheet
|
|
@@ -355,7 +355,7 @@ describe("ConflictSheet", () => {
|
|
|
355
355
|
});
|
|
356
356
|
|
|
357
357
|
it("uses the server version for every conflict after confirmation, dismissing once they clear", async () => {
|
|
358
|
-
const onResolve = mock(() => {});
|
|
358
|
+
const onResolve = mock((_args: Parameters<ConflictSheetProps["onResolve"]>[0]) => {});
|
|
359
359
|
const onDismiss = mock(() => {});
|
|
360
360
|
const {findByText, getByTestId, rerender} = renderWithTheme(
|
|
361
361
|
<ConflictSheet
|
|
@@ -385,7 +385,7 @@ describe("ConflictSheet", () => {
|
|
|
385
385
|
});
|
|
386
386
|
|
|
387
387
|
it("keeps the local version for every conflict after confirmation, dismissing once they clear", async () => {
|
|
388
|
-
const onResolve = mock(() => {});
|
|
388
|
+
const onResolve = mock((_args: Parameters<ConflictSheetProps["onResolve"]>[0]) => {});
|
|
389
389
|
const onDismiss = mock(() => {});
|
|
390
390
|
const {findByText, getByTestId, rerender} = renderWithTheme(
|
|
391
391
|
<ConflictSheet
|
|
@@ -145,7 +145,9 @@ describe("ConsentFormScreen", () => {
|
|
|
145
145
|
});
|
|
146
146
|
|
|
147
147
|
it("invokes onAgree with signature and checkbox values", () => {
|
|
148
|
-
const onAgree = mock(
|
|
148
|
+
const onAgree = mock(
|
|
149
|
+
(_data: {checkboxValues: Record<string, boolean>; signature?: string}) => {}
|
|
150
|
+
);
|
|
149
151
|
const form: ConsentFormPublic = {
|
|
150
152
|
...baseForm,
|
|
151
153
|
captureSignature: false,
|
|
@@ -28,9 +28,8 @@ const makeForm = (overrides: Partial<ConsentFormPublic> = {}): ConsentFormPublic
|
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
const createMockApi = (forms: ConsentFormPublic[]) => {
|
|
31
|
-
const mockSubmitMutation = mock(() => Promise.resolve({data: {agreed: true, id: "response-1"}}));
|
|
32
31
|
const mockUnwrap = mock(() => Promise.resolve({agreed: true, id: "response-1"}));
|
|
33
|
-
mockSubmitMutation
|
|
32
|
+
const mockSubmitMutation = mock(() => ({unwrap: mockUnwrap}));
|
|
34
33
|
|
|
35
34
|
const innerApi = {
|
|
36
35
|
injectEndpoints: mock((_config: unknown) => ({
|
|
@@ -13,14 +13,19 @@ describe("CustomSelectField", () => {
|
|
|
13
13
|
|
|
14
14
|
it("renders correctly with default props", () => {
|
|
15
15
|
const {toJSON} = renderWithTheme(
|
|
16
|
-
<CustomSelectField onChange={() => {}} options={defaultOptions} />
|
|
16
|
+
<CustomSelectField onChange={() => {}} options={defaultOptions} value="" />
|
|
17
17
|
);
|
|
18
18
|
expect(toJSON()).toMatchSnapshot();
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
it("renders with title", () => {
|
|
22
22
|
const {getByText, toJSON} = renderWithTheme(
|
|
23
|
-
<CustomSelectField
|
|
23
|
+
<CustomSelectField
|
|
24
|
+
onChange={() => {}}
|
|
25
|
+
options={defaultOptions}
|
|
26
|
+
title="Select Option"
|
|
27
|
+
value=""
|
|
28
|
+
/>
|
|
24
29
|
);
|
|
25
30
|
expect(getByText("Select Option")).toBeTruthy();
|
|
26
31
|
expect(toJSON()).toMatchSnapshot();
|
|
@@ -28,7 +33,12 @@ describe("CustomSelectField", () => {
|
|
|
28
33
|
|
|
29
34
|
it("renders with placeholder", () => {
|
|
30
35
|
const {toJSON} = renderWithTheme(
|
|
31
|
-
<CustomSelectField
|
|
36
|
+
<CustomSelectField
|
|
37
|
+
onChange={() => {}}
|
|
38
|
+
options={defaultOptions}
|
|
39
|
+
placeholder="Choose one..."
|
|
40
|
+
value=""
|
|
41
|
+
/>
|
|
32
42
|
);
|
|
33
43
|
expect(toJSON()).toMatchSnapshot();
|
|
34
44
|
});
|
|
@@ -53,6 +63,7 @@ describe("CustomSelectField", () => {
|
|
|
53
63
|
errorText="Please select an option"
|
|
54
64
|
onChange={() => {}}
|
|
55
65
|
options={defaultOptions}
|
|
66
|
+
value=""
|
|
56
67
|
/>
|
|
57
68
|
);
|
|
58
69
|
expect(getByText("Please select an option")).toBeTruthy();
|
|
@@ -64,6 +75,7 @@ describe("CustomSelectField", () => {
|
|
|
64
75
|
helperText="Select or enter a custom value"
|
|
65
76
|
onChange={() => {}}
|
|
66
77
|
options={defaultOptions}
|
|
78
|
+
value=""
|
|
67
79
|
/>
|
|
68
80
|
);
|
|
69
81
|
expect(getByText("Select or enter a custom value")).toBeTruthy();
|
|
@@ -79,7 +91,7 @@ describe("CustomSelectField", () => {
|
|
|
79
91
|
it("includes custom option in dropdown", () => {
|
|
80
92
|
// The component automatically adds a "Custom" option to the options list
|
|
81
93
|
const {toJSON} = renderWithTheme(
|
|
82
|
-
<CustomSelectField onChange={() => {}} options={defaultOptions} />
|
|
94
|
+
<CustomSelectField onChange={() => {}} options={defaultOptions} value="" />
|
|
83
95
|
);
|
|
84
96
|
expect(toJSON()).toMatchSnapshot();
|
|
85
97
|
});
|
package/src/DataTable.test.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import {act, fireEvent, waitFor} from "@testing-library/react-native";
|
|
|
3
3
|
import {type FC, useState} from "react";
|
|
4
4
|
import {Platform, StyleSheet} from "react-native";
|
|
5
5
|
|
|
6
|
-
import type {DataTableCustomComponentMap, DataTableProps} from "./Common";
|
|
6
|
+
import type {DataTableCellData, DataTableCustomComponentMap, DataTableProps} from "./Common";
|
|
7
7
|
import {DataTable} from "./DataTable";
|
|
8
8
|
import {Text} from "./Text";
|
|
9
9
|
import {renderWithTheme} from "./test-utils";
|
|
@@ -290,7 +290,7 @@ describe("DataTable", () => {
|
|
|
290
290
|
});
|
|
291
291
|
|
|
292
292
|
it("renders with cell highlight", () => {
|
|
293
|
-
const highlightData = [[{highlight: "primary", value: "Highlighted"}]];
|
|
293
|
+
const highlightData: DataTableCellData[][] = [[{highlight: "primary", value: "Highlighted"}]];
|
|
294
294
|
const {toJSON} = renderWithTheme(
|
|
295
295
|
<DataTable columns={[{columnType: "text", title: "Name", width: 150}]} data={highlightData} />
|
|
296
296
|
);
|
|
@@ -303,7 +303,7 @@ describe("DataTable", () => {
|
|
|
303
303
|
{columnType: "number", title: "Count", width: 100},
|
|
304
304
|
{columnType: "date", title: "Due", width: 150},
|
|
305
305
|
];
|
|
306
|
-
const highlightData = [
|
|
306
|
+
const highlightData: DataTableCellData[][] = [
|
|
307
307
|
[
|
|
308
308
|
{highlight: "error", value: "Overdue"},
|
|
309
309
|
{highlight: "error", value: 42},
|
|
@@ -495,7 +495,7 @@ describe("DataTable", () => {
|
|
|
495
495
|
});
|
|
496
496
|
|
|
497
497
|
it("renders with cell highlight color", () => {
|
|
498
|
-
const highlightData = [[{highlight: "primary", value: "Highlighted"}]];
|
|
498
|
+
const highlightData: DataTableCellData[][] = [[{highlight: "primary", value: "Highlighted"}]];
|
|
499
499
|
const highlightColumns = [{columnType: "text", title: "Col", width: 150}];
|
|
500
500
|
const {toJSON} = renderWithTheme(<DataTable columns={highlightColumns} data={highlightData} />);
|
|
501
501
|
expect(toJSON()).toBeTruthy();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {describe, expect, it} from "bun:test";
|
|
2
|
+
import {createRef} from "react";
|
|
2
3
|
|
|
3
4
|
import {DateTimeActionSheet} from "./DateTimeActionSheet";
|
|
4
5
|
import {renderWithTheme} from "./test-utils";
|
|
@@ -8,6 +9,7 @@ import {renderWithTheme} from "./test-utils";
|
|
|
8
9
|
|
|
9
10
|
describe("DateTimeActionSheet", () => {
|
|
10
11
|
const defaultProps = {
|
|
12
|
+
actionSheetRef: createRef<unknown>(),
|
|
11
13
|
onChange: () => {},
|
|
12
14
|
onDismiss: () => {},
|
|
13
15
|
visible: true,
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
afterAll,
|
|
3
|
-
afterEach,
|
|
4
|
-
beforeEach,
|
|
5
|
-
describe,
|
|
6
|
-
expect,
|
|
7
|
-
it,
|
|
8
|
-
type mock as MockType,
|
|
9
|
-
mock,
|
|
10
|
-
} from "bun:test";
|
|
1
|
+
import {afterAll, afterEach, beforeEach, describe, expect, it, mock} from "bun:test";
|
|
11
2
|
import {act, fireEvent, userEvent} from "@testing-library/react-native";
|
|
12
3
|
import {assert} from "chai";
|
|
13
4
|
import {DateTime} from "luxon";
|
|
@@ -59,7 +50,7 @@ afterAll(() => {
|
|
|
59
50
|
});
|
|
60
51
|
|
|
61
52
|
describe("DateTimeField", () => {
|
|
62
|
-
let mockOnChange: ReturnType<
|
|
53
|
+
let mockOnChange: ReturnType<typeof setupComponentTest>["onChange"];
|
|
63
54
|
|
|
64
55
|
beforeEach(() => {
|
|
65
56
|
setDesktop();
|
|
@@ -1497,7 +1488,7 @@ describe("DateTimeField", () => {
|
|
|
1497
1488
|
describe("TimezonePicker onChange", () => {
|
|
1498
1489
|
it("forwards the picked timezone to onTimezoneChange and emits a new value", async () => {
|
|
1499
1490
|
setDesktop();
|
|
1500
|
-
const mockTzChange = mock(() => {});
|
|
1491
|
+
const mockTzChange = mock((_timezone: string) => {});
|
|
1501
1492
|
const {UNSAFE_root} = renderWithTheme(
|
|
1502
1493
|
<DateTimeField
|
|
1503
1494
|
onChange={mockOnChange}
|
package/src/DateTimeField.tsx
CHANGED
|
@@ -74,7 +74,7 @@ const DateTimeSegment: FC<DateTimeSegmentProps> = ({
|
|
|
74
74
|
style={{
|
|
75
75
|
alignItems: "center",
|
|
76
76
|
backgroundColor: "transparent",
|
|
77
|
-
borderColor: error ? theme.
|
|
77
|
+
borderColor: error ? theme.field.borderError : "transparent",
|
|
78
78
|
flexDirection: "row",
|
|
79
79
|
flexShrink: 1,
|
|
80
80
|
height: 40,
|
|
@@ -237,7 +237,7 @@ const MobileTimeDisplay: FC<MobileTimeDisplayProps> = ({
|
|
|
237
237
|
paddingVertical: showBorder ? 8 : 4,
|
|
238
238
|
...(showBorder
|
|
239
239
|
? {
|
|
240
|
-
backgroundColor: disabled ? theme.surface.disabled : theme.
|
|
240
|
+
backgroundColor: disabled ? theme.surface.disabled : theme.field.background,
|
|
241
241
|
borderColor,
|
|
242
242
|
borderRadius: 4,
|
|
243
243
|
borderWidth: 1,
|
|
@@ -497,11 +497,11 @@ export const DateTimeField: FC<DateTimeFieldProps> = ({
|
|
|
497
497
|
const timezone = providedTimezone ?? localTimezone;
|
|
498
498
|
const inputRefs = useRef<(TextInput | null)[]>([]);
|
|
499
499
|
|
|
500
|
-
let borderColor = theme.border
|
|
500
|
+
let borderColor = theme.field.border;
|
|
501
501
|
if (disabled) {
|
|
502
|
-
borderColor = theme.
|
|
502
|
+
borderColor = theme.field.borderDisabled;
|
|
503
503
|
} else if (errorText || Object.values(fieldErrors).some((error) => error !== undefined)) {
|
|
504
|
-
borderColor = theme.
|
|
504
|
+
borderColor = theme.field.borderError;
|
|
505
505
|
}
|
|
506
506
|
|
|
507
507
|
/** Builds the ordered array of {@link FieldConfig} for each input segment based on the field type. */
|
|
@@ -1082,7 +1082,7 @@ export const DateTimeField: FC<DateTimeFieldProps> = ({
|
|
|
1082
1082
|
onPress={openActionSheet}
|
|
1083
1083
|
style={{
|
|
1084
1084
|
alignItems: parentIsLessThanBreakpointOrIsMobile ? "stretch" : "center",
|
|
1085
|
-
backgroundColor: theme.
|
|
1085
|
+
backgroundColor: theme.field.background,
|
|
1086
1086
|
borderColor,
|
|
1087
1087
|
borderRadius: 4,
|
|
1088
1088
|
borderWidth: 1,
|
|
@@ -7,7 +7,11 @@ import {renderWithTheme} from "./test-utils";
|
|
|
7
7
|
describe("DismissButton", () => {
|
|
8
8
|
it("renders correctly with default props", () => {
|
|
9
9
|
const {toJSON} = renderWithTheme(
|
|
10
|
-
<DismissButton
|
|
10
|
+
<DismissButton
|
|
11
|
+
accessibilityHint="Dismisses the message"
|
|
12
|
+
accessibilityLabel="Dismiss"
|
|
13
|
+
onClick={() => {}}
|
|
14
|
+
/>
|
|
11
15
|
);
|
|
12
16
|
expect(toJSON()).toMatchSnapshot();
|
|
13
17
|
});
|
|
@@ -15,7 +19,11 @@ describe("DismissButton", () => {
|
|
|
15
19
|
it("calls onClick when pressed", () => {
|
|
16
20
|
const handleClick = mock(() => {});
|
|
17
21
|
const {getByLabelText} = renderWithTheme(
|
|
18
|
-
<DismissButton
|
|
22
|
+
<DismissButton
|
|
23
|
+
accessibilityHint="Dismisses the message"
|
|
24
|
+
accessibilityLabel="Dismiss"
|
|
25
|
+
onClick={handleClick}
|
|
26
|
+
/>
|
|
19
27
|
);
|
|
20
28
|
|
|
21
29
|
fireEvent.press(getByLabelText("Dismiss"));
|
|
@@ -24,14 +32,24 @@ describe("DismissButton", () => {
|
|
|
24
32
|
|
|
25
33
|
it("renders with primary color (default)", () => {
|
|
26
34
|
const {toJSON} = renderWithTheme(
|
|
27
|
-
<DismissButton
|
|
35
|
+
<DismissButton
|
|
36
|
+
accessibilityHint="Dismisses the message"
|
|
37
|
+
accessibilityLabel="Dismiss"
|
|
38
|
+
color="primary"
|
|
39
|
+
onClick={() => {}}
|
|
40
|
+
/>
|
|
28
41
|
);
|
|
29
42
|
expect(toJSON()).toMatchSnapshot();
|
|
30
43
|
});
|
|
31
44
|
|
|
32
45
|
it("renders with inverted color", () => {
|
|
33
46
|
const {toJSON} = renderWithTheme(
|
|
34
|
-
<DismissButton
|
|
47
|
+
<DismissButton
|
|
48
|
+
accessibilityHint="Dismisses the message"
|
|
49
|
+
accessibilityLabel="Dismiss"
|
|
50
|
+
color="inverted"
|
|
51
|
+
onClick={() => {}}
|
|
52
|
+
/>
|
|
35
53
|
);
|
|
36
54
|
expect(toJSON()).toMatchSnapshot();
|
|
37
55
|
});
|
package/src/EmailField.test.tsx
CHANGED
|
@@ -6,29 +6,27 @@ import {renderWithTheme} from "./test-utils";
|
|
|
6
6
|
|
|
7
7
|
describe("EmailField", () => {
|
|
8
8
|
it("renders correctly with default props", () => {
|
|
9
|
-
const {toJSON} = renderWithTheme(<EmailField
|
|
9
|
+
const {toJSON} = renderWithTheme(<EmailField onChange={() => {}} value="" />);
|
|
10
10
|
expect(toJSON()).toMatchSnapshot();
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
it("renders with placeholder", () => {
|
|
14
14
|
const {getByPlaceholderText} = renderWithTheme(
|
|
15
|
-
<EmailField
|
|
15
|
+
<EmailField onChange={() => {}} placeholder="Enter your email" value="" />
|
|
16
16
|
);
|
|
17
17
|
expect(getByPlaceholderText("Enter your email")).toBeTruthy();
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
it("renders with initial value", () => {
|
|
21
21
|
const {getByDisplayValue} = renderWithTheme(
|
|
22
|
-
<EmailField
|
|
22
|
+
<EmailField onChange={() => {}} value="test@example.com" />
|
|
23
23
|
);
|
|
24
24
|
expect(getByDisplayValue("test@example.com")).toBeTruthy();
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
it("calls onChange with valid email", async () => {
|
|
28
28
|
const handleChange = mock((_value: string) => {});
|
|
29
|
-
const {getByDisplayValue} = renderWithTheme(
|
|
30
|
-
<EmailField label="Email" onChange={handleChange} value="" />
|
|
31
|
-
);
|
|
29
|
+
const {getByDisplayValue} = renderWithTheme(<EmailField onChange={handleChange} value="" />);
|
|
32
30
|
|
|
33
31
|
const input = getByDisplayValue("");
|
|
34
32
|
await act(async () => {
|
|
@@ -42,9 +40,7 @@ describe("EmailField", () => {
|
|
|
42
40
|
|
|
43
41
|
it("does not call onChange with invalid email", async () => {
|
|
44
42
|
const handleChange = mock((_value: string) => {});
|
|
45
|
-
const {getByDisplayValue} = renderWithTheme(
|
|
46
|
-
<EmailField label="Email" onChange={handleChange} value="" />
|
|
47
|
-
);
|
|
43
|
+
const {getByDisplayValue} = renderWithTheme(<EmailField onChange={handleChange} value="" />);
|
|
48
44
|
|
|
49
45
|
const input = getByDisplayValue("");
|
|
50
46
|
await act(async () => {
|
|
@@ -57,16 +53,13 @@ describe("EmailField", () => {
|
|
|
57
53
|
|
|
58
54
|
it("validates email format and shows error for invalid input", () => {
|
|
59
55
|
// EmailField should show error for invalid email after typing
|
|
60
|
-
const {unmount} = renderWithTheme(
|
|
61
|
-
<EmailField label="Email" onChange={() => {}} value="invalid-email" />
|
|
62
|
-
);
|
|
56
|
+
const {unmount} = renderWithTheme(<EmailField onChange={() => {}} value="invalid-email" />);
|
|
63
57
|
|
|
64
58
|
// Render with errorText to test that custom error displays
|
|
65
59
|
unmount();
|
|
66
60
|
const {queryByText: queryByText2} = renderWithTheme(
|
|
67
61
|
<EmailField
|
|
68
62
|
errorText="Please enter a valid email"
|
|
69
|
-
label="Email"
|
|
70
63
|
onChange={() => {}}
|
|
71
64
|
value="invalid-email"
|
|
72
65
|
/>
|
|
@@ -76,9 +69,7 @@ describe("EmailField", () => {
|
|
|
76
69
|
|
|
77
70
|
it("accepts valid email addresses", async () => {
|
|
78
71
|
const handleChange = mock((_value: string) => {});
|
|
79
|
-
const {getByDisplayValue} = renderWithTheme(
|
|
80
|
-
<EmailField label="Email" onChange={handleChange} value="" />
|
|
81
|
-
);
|
|
72
|
+
const {getByDisplayValue} = renderWithTheme(<EmailField onChange={handleChange} value="" />);
|
|
82
73
|
|
|
83
74
|
const input = getByDisplayValue("");
|
|
84
75
|
await act(async () => {
|
|
@@ -92,14 +83,14 @@ describe("EmailField", () => {
|
|
|
92
83
|
|
|
93
84
|
it("renders with custom errorText", () => {
|
|
94
85
|
const {getByText} = renderWithTheme(
|
|
95
|
-
<EmailField errorText="Custom error message"
|
|
86
|
+
<EmailField errorText="Custom error message" onChange={() => {}} value="" />
|
|
96
87
|
);
|
|
97
88
|
expect(getByText("Custom error message")).toBeTruthy();
|
|
98
89
|
});
|
|
99
90
|
|
|
100
91
|
it("renders with icon", () => {
|
|
101
92
|
const {toJSON} = renderWithTheme(
|
|
102
|
-
<EmailField iconName="envelope"
|
|
93
|
+
<EmailField iconName="envelope" onChange={() => {}} value="" />
|
|
103
94
|
);
|
|
104
95
|
expect(toJSON()).toMatchSnapshot();
|
|
105
96
|
});
|
|
@@ -107,7 +98,7 @@ describe("EmailField", () => {
|
|
|
107
98
|
it("calls onBlur with valid email", async () => {
|
|
108
99
|
const handleBlur = mock((_value: string) => {});
|
|
109
100
|
const {getByDisplayValue} = renderWithTheme(
|
|
110
|
-
<EmailField
|
|
101
|
+
<EmailField onBlur={handleBlur} onChange={() => {}} value="valid@email.com" />
|
|
111
102
|
);
|
|
112
103
|
|
|
113
104
|
const input = getByDisplayValue("valid@email.com");
|
|
@@ -123,7 +114,7 @@ describe("EmailField", () => {
|
|
|
123
114
|
it("does not call onBlur with invalid email", async () => {
|
|
124
115
|
const handleBlur = mock((_value: string) => {});
|
|
125
116
|
const {getByDisplayValue} = renderWithTheme(
|
|
126
|
-
<EmailField
|
|
117
|
+
<EmailField onBlur={handleBlur} onChange={() => {}} value="" />
|
|
127
118
|
);
|
|
128
119
|
|
|
129
120
|
const input = getByDisplayValue("");
|
|
@@ -140,7 +131,7 @@ describe("EmailField", () => {
|
|
|
140
131
|
it("clears local error when typing a valid email after invalid", async () => {
|
|
141
132
|
const handleChange = mock((_value: string) => {});
|
|
142
133
|
const {getByDisplayValue, queryByText} = renderWithTheme(
|
|
143
|
-
<EmailField
|
|
134
|
+
<EmailField onChange={handleChange} value="" />
|
|
144
135
|
);
|
|
145
136
|
|
|
146
137
|
const input = getByDisplayValue("");
|
|
@@ -172,7 +163,7 @@ describe("EmailField", () => {
|
|
|
172
163
|
it("validates empty string as valid on blur", async () => {
|
|
173
164
|
const handleBlur = mock((_value: string) => {});
|
|
174
165
|
const {getByDisplayValue} = renderWithTheme(
|
|
175
|
-
<EmailField
|
|
166
|
+
<EmailField onBlur={handleBlur} onChange={() => {}} value="" />
|
|
176
167
|
);
|
|
177
168
|
|
|
178
169
|
const input = getByDisplayValue("");
|
|
@@ -351,7 +351,7 @@ describe("EmojiSelector", () => {
|
|
|
351
351
|
},
|
|
352
352
|
];
|
|
353
353
|
const getItemMock = mock(async () => JSON.stringify(existing));
|
|
354
|
-
const setItemMock = mock(async () => undefined);
|
|
354
|
+
const setItemMock = mock(async (_key: string, _value: string) => undefined);
|
|
355
355
|
const originalGetItem = AsyncStorage.getItem;
|
|
356
356
|
const originalSetItem = AsyncStorage.setItem;
|
|
357
357
|
AsyncStorage.getItem = getItemMock as unknown as typeof AsyncStorage.getItem;
|
|
@@ -396,7 +396,7 @@ describe("EmojiSelector", () => {
|
|
|
396
396
|
const onEmojiSelected = mock(() => {});
|
|
397
397
|
const originalGetItem = AsyncStorage.getItem;
|
|
398
398
|
const originalSetItem = AsyncStorage.setItem;
|
|
399
|
-
const setItemMock = mock(async () => undefined);
|
|
399
|
+
const setItemMock = mock(async (_key: string, _value: string) => undefined);
|
|
400
400
|
AsyncStorage.setItem = setItemMock as unknown as typeof AsyncStorage.setItem;
|
|
401
401
|
try {
|
|
402
402
|
const {root, UNSAFE_getAllByType} = renderWithTheme(
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {afterAll, beforeAll, describe, expect, it, mock, spyOn} from "bun:test";
|
|
2
2
|
import React from "react";
|
|
3
3
|
|
|
4
|
+
import type {ErrorPageProps} from "./Common";
|
|
4
5
|
import {ErrorBoundary} from "./ErrorBoundary";
|
|
5
6
|
import {ErrorPage} from "./ErrorPage";
|
|
6
7
|
import {Text} from "./Text";
|
|
7
|
-
import {renderWithTheme} from "./test-utils";
|
|
8
|
+
import {elementProps, renderWithTheme} from "./test-utils";
|
|
8
9
|
|
|
9
10
|
describe("ErrorBoundary", () => {
|
|
10
11
|
// Suppress console.warn during tests
|
|
@@ -89,7 +90,8 @@ describe("ErrorBoundary", () => {
|
|
|
89
90
|
const renderedElement = boundary.render() as React.ReactElement;
|
|
90
91
|
|
|
91
92
|
expect(renderedElement.type).toBe(ErrorPage);
|
|
92
|
-
|
|
93
|
-
expect(
|
|
93
|
+
const pageProps = elementProps<ErrorPageProps>(renderedElement);
|
|
94
|
+
expect(pageProps.error).toBe(error);
|
|
95
|
+
expect(typeof pageProps.resetError).toBe("function");
|
|
94
96
|
});
|
|
95
97
|
});
|