@terreno/ui 0.31.0 → 56.0.0-beta.2
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/dist/ActionSheet.d.ts +1 -1
- package/dist/Avatar.js +1 -4
- package/dist/Avatar.js.map +1 -1
- package/dist/Box.js +45 -9
- package/dist/Box.js.map +1 -1
- package/dist/Common.d.ts +21 -0
- package/dist/Common.js.map +1 -1
- package/dist/ConflictSheet.d.ts +53 -0
- package/dist/ConflictSheet.js +132 -0
- package/dist/ConflictSheet.js.map +1 -0
- package/dist/DateTimeActionSheet.d.ts +2 -1
- package/dist/DateTimeField.js +5 -21
- package/dist/DateTimeField.js.map +1 -1
- package/dist/DecimalRangeActionSheet.d.ts +1 -1
- package/dist/EmojiSelector.d.ts +1 -1
- package/dist/ErrorPage.d.ts +1 -1
- package/dist/HeightActionSheet.d.ts +1 -1
- package/dist/Hyperlink.d.ts +2 -1
- package/dist/Hyperlink.js +2 -1
- package/dist/Hyperlink.js.map +1 -1
- package/dist/Image.d.ts +1 -1
- package/dist/ImageBackground.d.ts +1 -1
- package/dist/MobileAddressAutoComplete.d.ts +1 -1
- package/dist/NumberPickerActionSheet.d.ts +1 -1
- package/dist/Page.d.ts +5 -4
- package/dist/Page.js +0 -2
- package/dist/Page.js.map +1 -1
- package/dist/PickerSelect.d.ts +1 -1
- package/dist/SidebarNavigation.js +1 -1
- package/dist/SidebarNavigation.js.map +1 -1
- package/dist/SidebarNavigation.native.js +1 -1
- package/dist/SidebarNavigation.native.js.map +1 -1
- package/dist/SplitPage.d.ts +1 -1
- package/dist/SplitPage.js +1 -4
- package/dist/SplitPage.js.map +1 -1
- package/dist/SplitPage.native.d.ts +1 -1
- package/dist/SyncStatusBanner.d.ts +46 -0
- package/dist/SyncStatusBanner.js +29 -0
- package/dist/SyncStatusBanner.js.map +1 -0
- package/dist/Theme.d.ts +1 -1
- package/dist/Toast.d.ts +9 -1
- package/dist/Toast.js +20 -7
- package/dist/Toast.js.map +1 -1
- package/dist/ToastNotifications.js +23 -1
- package/dist/ToastNotifications.js.map +1 -1
- package/dist/UnifiedAddressAutoComplete.d.ts +1 -1
- package/dist/Unifier.js +1 -1
- package/dist/Unifier.js.map +1 -1
- package/dist/conflictFieldDiff.d.ts +14 -0
- package/dist/conflictFieldDiff.js +62 -0
- package/dist/conflictFieldDiff.js.map +1 -0
- package/dist/icons/OfflineIcon.d.ts +1 -1
- package/dist/icons/OnlineIcon.d.ts +1 -1
- package/dist/icons/OutOfficeIcon.d.ts +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/pdfHtmlTemplate.d.ts +30 -0
- package/dist/pdfHtmlTemplate.js +170 -0
- package/dist/pdfHtmlTemplate.js.map +1 -0
- package/dist/table/TableTitle.js +1 -3
- package/dist/table/TableTitle.js.map +1 -1
- package/dist/useAppLaunchOrForeground.d.ts +9 -0
- package/dist/useAppLaunchOrForeground.js +27 -0
- package/dist/useAppLaunchOrForeground.js.map +1 -0
- package/package.json +44 -37
- package/src/ActionSheet.test.tsx +123 -136
- package/src/Box.test.tsx +68 -30
- package/src/Box.tsx +46 -7
- package/src/Common.ts +21 -3
- package/src/ConflictSheet.test.tsx +461 -0
- package/src/ConflictSheet.tsx +399 -0
- package/src/ConsentFormScreen.test.tsx +22 -0
- package/src/DateTimeField.test.tsx +14 -0
- package/src/DateTimeField.tsx +5 -19
- package/src/Hyperlink.tsx +1 -1
- package/src/Page.tsx +2 -3
- package/src/SidebarNavigation.native.tsx +1 -1
- package/src/SidebarNavigation.tsx +1 -1
- package/src/SyncStatusBanner.test.tsx +204 -0
- package/src/SyncStatusBanner.tsx +148 -0
- package/src/TerrenoProvider.test.tsx +3 -4
- package/src/Toast.test.tsx +60 -0
- package/src/Toast.tsx +46 -1
- package/src/ToastNotifications.test.tsx +82 -0
- package/src/ToastNotifications.tsx +25 -1
- package/src/Unifier.ts +1 -1
- package/src/WebDropdownMenu.test.tsx +128 -0
- package/src/__snapshots__/AiSuggestionBox.test.tsx.snap +0 -3
- package/src/__snapshots__/Body.test.tsx.snap +0 -16
- package/src/__snapshots__/Box.test.tsx.snap +4 -13
- package/src/__snapshots__/Page.test.tsx.snap +0 -84
- package/src/__snapshots__/SplitPage.test.tsx.snap +24 -120
- package/src/__snapshots__/TapToEdit.test.tsx.snap +5 -16
- package/src/__snapshots__/Toast.test.tsx.snap +4 -2
- package/src/bunSetup.ts +19 -0
- package/src/conflictFieldDiff.test.ts +26 -0
- package/src/conflictFieldDiff.ts +78 -0
- package/src/index.tsx +5 -2
- package/src/login/__snapshots__/LoginScreen.test.tsx.snap +0 -9
- package/src/pdfHtmlTemplate.ts +219 -0
- package/src/signUp/__snapshots__/OAuthButtons.test.tsx.snap +0 -1
- package/src/signUp/__snapshots__/PasswordRequirements.test.tsx.snap +2 -16
- package/src/signUp/__snapshots__/SignUpScreen.test.tsx.snap +1 -17
- package/src/signUp/__snapshots__/Swiper.test.tsx.snap +0 -1
- package/src/table/__snapshots__/Table.test.tsx.snap +22 -87
- package/src/table/__snapshots__/TableHeader.test.tsx.snap +10 -50
- package/src/table/__snapshots__/TableHeaderCell.test.tsx.snap +10 -84
- package/src/table/__snapshots__/TableRow.test.tsx.snap +12 -77
- package/src/useAppLaunchOrForeground.test.tsx +54 -0
- package/src/useAppLaunchOrForeground.ts +30 -0
- package/dist/ConsentHistory.d.ts +0 -9
- package/dist/ConsentHistory.js +0 -70
- package/dist/ConsentHistory.js.map +0 -1
- package/dist/generateConsentHistoryPdf.d.ts +0 -2
- package/dist/generateConsentHistoryPdf.js +0 -185
- package/dist/generateConsentHistoryPdf.js.map +0 -1
- package/dist/useConsentHistory.d.ts +0 -63
- package/dist/useConsentHistory.js +0 -40
- package/dist/useConsentHistory.js.map +0 -1
- package/src/ConsentHistory.test.tsx +0 -224
- package/src/ConsentHistory.tsx +0 -249
- package/src/generateConsentHistoryPdf.test.ts +0 -253
- package/src/generateConsentHistoryPdf.ts +0 -211
- package/src/useConsentHistory.test.ts +0 -106
- package/src/useConsentHistory.ts +0 -94
package/src/Box.test.tsx
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
// noExplicitAny: test mock typing
|
|
2
|
-
// biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
|
|
3
1
|
import {describe, expect, it, mock, spyOn} from "bun:test";
|
|
4
2
|
import {act, fireEvent} from "@testing-library/react-native";
|
|
5
3
|
import React from "react";
|
|
4
|
+
import type {ScrollView} from "react-native";
|
|
6
5
|
|
|
7
6
|
import {Box} from "./Box";
|
|
8
7
|
import {Text} from "./Text";
|
|
9
8
|
import {renderWithTheme} from "./test-utils";
|
|
10
9
|
|
|
10
|
+
/** Imperative handle exposed by Box's forwarded ref. */
|
|
11
|
+
interface BoxScrollHandle {
|
|
12
|
+
scrollTo: (y: number) => void;
|
|
13
|
+
scrollToEnd: () => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
11
16
|
describe("Box", () => {
|
|
12
17
|
describe("basic rendering", () => {
|
|
13
18
|
it("should render with default props", () => {
|
|
@@ -502,6 +507,37 @@ describe("Box", () => {
|
|
|
502
507
|
expect(root).toBeTruthy();
|
|
503
508
|
// Just verify the component renders without error when onScroll is provided
|
|
504
509
|
});
|
|
510
|
+
|
|
511
|
+
// Behavior props leaking into style reach the native view as unserializable
|
|
512
|
+
// values: a ref object in style is cyclical (host instance points back at the
|
|
513
|
+
// node) and gets dev-frozen, so React throws when detaching it on unmount.
|
|
514
|
+
it("should keep behavior props out of the ScrollView style", () => {
|
|
515
|
+
const scrollRef = React.createRef<ScrollView>();
|
|
516
|
+
const {root} = renderWithTheme(
|
|
517
|
+
<Box onScroll={mock(() => {})} scroll scrollRef={scrollRef}>
|
|
518
|
+
<Text>Scrollable</Text>
|
|
519
|
+
</Box>
|
|
520
|
+
);
|
|
521
|
+
|
|
522
|
+
// RN Testing Library resolves host ScrollView by display name, not the JS class.
|
|
523
|
+
const scrollView = root.findByType("ScrollView");
|
|
524
|
+
expect(scrollView.props.style).not.toHaveProperty("scrollRef");
|
|
525
|
+
expect(scrollView.props.style).not.toHaveProperty("scroll");
|
|
526
|
+
expect(scrollView.props.style).not.toHaveProperty("onScroll");
|
|
527
|
+
expect(scrollView.props.style).not.toHaveProperty("testID");
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
it("should keep behavior props out of the View style", () => {
|
|
531
|
+
const {root} = renderWithTheme(
|
|
532
|
+
<Box avoidKeyboard keyboardOffset={12} onLayout={mock(() => {})} testID="behavior-box" />
|
|
533
|
+
);
|
|
534
|
+
|
|
535
|
+
const view = root.findByType("View");
|
|
536
|
+
expect(view.props.style).not.toHaveProperty("onLayout");
|
|
537
|
+
expect(view.props.style).not.toHaveProperty("avoidKeyboard");
|
|
538
|
+
expect(view.props.style).not.toHaveProperty("keyboardOffset");
|
|
539
|
+
expect(view.props.style).not.toHaveProperty("testID");
|
|
540
|
+
});
|
|
505
541
|
});
|
|
506
542
|
|
|
507
543
|
describe("keyboard avoidance", () => {
|
|
@@ -548,7 +584,7 @@ describe("Box", () => {
|
|
|
548
584
|
|
|
549
585
|
describe("ref forwarding", () => {
|
|
550
586
|
it("should expose scrollToEnd method", () => {
|
|
551
|
-
const ref = React.createRef<
|
|
587
|
+
const ref = React.createRef<BoxScrollHandle>();
|
|
552
588
|
renderWithTheme(<Box ref={ref} scroll />);
|
|
553
589
|
|
|
554
590
|
expect(ref.current).toBeTruthy();
|
|
@@ -556,7 +592,7 @@ describe("Box", () => {
|
|
|
556
592
|
});
|
|
557
593
|
|
|
558
594
|
it("should expose scrollTo method", () => {
|
|
559
|
-
const ref = React.createRef<
|
|
595
|
+
const ref = React.createRef<BoxScrollHandle>();
|
|
560
596
|
renderWithTheme(<Box ref={ref} scroll />);
|
|
561
597
|
|
|
562
598
|
expect(ref.current).toBeTruthy();
|
|
@@ -566,8 +602,10 @@ describe("Box", () => {
|
|
|
566
602
|
it("scrollTo forwards to the underlying scroll ref after the delay", async () => {
|
|
567
603
|
const scrollTo = mock(() => {});
|
|
568
604
|
const scrollToEnd = mock(() => {});
|
|
569
|
-
const scrollRef = {
|
|
570
|
-
|
|
605
|
+
const scrollRef = {
|
|
606
|
+
current: {scrollTo, scrollToEnd},
|
|
607
|
+
} as unknown as React.RefObject<ScrollView>;
|
|
608
|
+
const ref = React.createRef<BoxScrollHandle>();
|
|
571
609
|
// Intentionally omit `scroll` so the ScrollView does not claim `scrollRef`
|
|
572
610
|
// and overwrite `.current`; the imperative handle still reads it.
|
|
573
611
|
renderWithTheme(
|
|
@@ -601,12 +639,10 @@ describe("Box", () => {
|
|
|
601
639
|
});
|
|
602
640
|
|
|
603
641
|
describe("warnings", () => {
|
|
604
|
-
it("should warn when using wrap and alignItems together", () => {
|
|
642
|
+
it("should not warn when using wrap and alignItems together", () => {
|
|
605
643
|
const consoleSpy = spyOn(console, "warn").mockImplementation(() => {});
|
|
606
644
|
renderWithTheme(<Box alignItems="center" wrap />);
|
|
607
|
-
expect(consoleSpy).
|
|
608
|
-
"React Native doesn't support wrap and alignItems together."
|
|
609
|
-
);
|
|
645
|
+
expect(consoleSpy).not.toHaveBeenCalled();
|
|
610
646
|
consoleSpy.mockRestore();
|
|
611
647
|
});
|
|
612
648
|
});
|
|
@@ -695,54 +731,54 @@ describe("Box", () => {
|
|
|
695
731
|
|
|
696
732
|
describe("edge case warnings and fallbacks", () => {
|
|
697
733
|
it("returns empty style when border prop is falsy", () => {
|
|
698
|
-
const {root} = renderWithTheme(<Box border={undefined
|
|
734
|
+
const {root} = renderWithTheme(<Box border={undefined} />);
|
|
699
735
|
expect(root).toBeTruthy();
|
|
700
736
|
});
|
|
701
737
|
|
|
702
738
|
it("returns empty style when borderBottom prop is falsy", () => {
|
|
703
|
-
const {root} = renderWithTheme(<Box borderBottom={undefined
|
|
739
|
+
const {root} = renderWithTheme(<Box borderBottom={undefined} />);
|
|
704
740
|
expect(root).toBeTruthy();
|
|
705
741
|
});
|
|
706
742
|
|
|
707
743
|
it("returns empty style when borderLeft prop is falsy", () => {
|
|
708
|
-
const {root} = renderWithTheme(<Box borderLeft={undefined
|
|
744
|
+
const {root} = renderWithTheme(<Box borderLeft={undefined} />);
|
|
709
745
|
expect(root).toBeTruthy();
|
|
710
746
|
});
|
|
711
747
|
|
|
712
748
|
it("returns empty style when borderRight prop is falsy", () => {
|
|
713
|
-
const {root} = renderWithTheme(<Box borderRight={undefined
|
|
749
|
+
const {root} = renderWithTheme(<Box borderRight={undefined} />);
|
|
714
750
|
expect(root).toBeTruthy();
|
|
715
751
|
});
|
|
716
752
|
|
|
717
753
|
it("returns empty style when borderTop prop is falsy", () => {
|
|
718
|
-
const {root} = renderWithTheme(<Box borderTop={undefined
|
|
754
|
+
const {root} = renderWithTheme(<Box borderTop={undefined} />);
|
|
719
755
|
expect(root).toBeTruthy();
|
|
720
756
|
});
|
|
721
757
|
|
|
722
758
|
it("warns when invalid height value is provided", () => {
|
|
723
759
|
const warnSpy = spyOn(console, "warn").mockImplementation(() => {});
|
|
724
|
-
renderWithTheme(<Box height={"abc"
|
|
760
|
+
renderWithTheme(<Box height={"abc"} />);
|
|
725
761
|
expect(warnSpy).toHaveBeenCalled();
|
|
726
762
|
warnSpy.mockRestore();
|
|
727
763
|
});
|
|
728
764
|
|
|
729
765
|
it("warns when invalid maxHeight value is provided", () => {
|
|
730
766
|
const warnSpy = spyOn(console, "warn").mockImplementation(() => {});
|
|
731
|
-
renderWithTheme(<Box maxHeight={"xyz"
|
|
767
|
+
renderWithTheme(<Box maxHeight={"xyz"} />);
|
|
732
768
|
expect(warnSpy).toHaveBeenCalled();
|
|
733
769
|
warnSpy.mockRestore();
|
|
734
770
|
});
|
|
735
771
|
|
|
736
772
|
it("warns when invalid maxWidth value is provided", () => {
|
|
737
773
|
const warnSpy = spyOn(console, "warn").mockImplementation(() => {});
|
|
738
|
-
renderWithTheme(<Box maxWidth={"abc"
|
|
774
|
+
renderWithTheme(<Box maxWidth={"abc"} />);
|
|
739
775
|
expect(warnSpy).toHaveBeenCalled();
|
|
740
776
|
warnSpy.mockRestore();
|
|
741
777
|
});
|
|
742
778
|
|
|
743
779
|
it("warns when invalid minHeight value is provided", () => {
|
|
744
780
|
const warnSpy = spyOn(console, "warn").mockImplementation(() => {});
|
|
745
|
-
renderWithTheme(<Box minHeight={"abc"
|
|
781
|
+
renderWithTheme(<Box minHeight={"abc"} />);
|
|
746
782
|
expect(warnSpy).toHaveBeenCalled();
|
|
747
783
|
warnSpy.mockRestore();
|
|
748
784
|
});
|
|
@@ -754,7 +790,7 @@ describe("Box", () => {
|
|
|
754
790
|
});
|
|
755
791
|
|
|
756
792
|
it("applies a valid minHeight value", () => {
|
|
757
|
-
const {root} = renderWithTheme(<Box minHeight={"50%"
|
|
793
|
+
const {root} = renderWithTheme(<Box minHeight={"50%"} />);
|
|
758
794
|
const view = root.findByType("View");
|
|
759
795
|
expect(view.props.style).toMatchObject({minHeight: "50%"});
|
|
760
796
|
});
|
|
@@ -766,21 +802,21 @@ describe("Box", () => {
|
|
|
766
802
|
});
|
|
767
803
|
|
|
768
804
|
it("applies a valid minWidth value", () => {
|
|
769
|
-
const {root} = renderWithTheme(<Box minWidth={"25%"
|
|
805
|
+
const {root} = renderWithTheme(<Box minWidth={"25%"} />);
|
|
770
806
|
const view = root.findByType("View");
|
|
771
807
|
expect(view.props.style).toMatchObject({minWidth: "25%"});
|
|
772
808
|
});
|
|
773
809
|
|
|
774
810
|
it("warns when invalid minWidth value is provided", () => {
|
|
775
811
|
const warnSpy = spyOn(console, "warn").mockImplementation(() => {});
|
|
776
|
-
renderWithTheme(<Box minWidth={"abc"
|
|
812
|
+
renderWithTheme(<Box minWidth={"abc"} />);
|
|
777
813
|
expect(warnSpy).toHaveBeenCalled();
|
|
778
814
|
warnSpy.mockRestore();
|
|
779
815
|
});
|
|
780
816
|
|
|
781
817
|
it("warns when invalid width value is provided", () => {
|
|
782
818
|
const warnSpy = spyOn(console, "warn").mockImplementation(() => {});
|
|
783
|
-
renderWithTheme(<Box width={"abc"
|
|
819
|
+
renderWithTheme(<Box width={"abc"} />);
|
|
784
820
|
expect(warnSpy).toHaveBeenCalled();
|
|
785
821
|
warnSpy.mockRestore();
|
|
786
822
|
});
|
|
@@ -807,11 +843,13 @@ describe("Box", () => {
|
|
|
807
843
|
expect(view.props.style.height).toBe(84);
|
|
808
844
|
});
|
|
809
845
|
|
|
810
|
-
it("
|
|
811
|
-
const
|
|
812
|
-
|
|
813
|
-
expect(
|
|
814
|
-
|
|
846
|
+
it("keeps an explicit alignItems when combined with wrap", () => {
|
|
847
|
+
const {root} = renderWithTheme(<Box alignItems="center" wrap />);
|
|
848
|
+
const view = root.findByType("View");
|
|
849
|
+
expect(view.props.style).toMatchObject({
|
|
850
|
+
alignItems: "center",
|
|
851
|
+
flexWrap: "wrap",
|
|
852
|
+
});
|
|
815
853
|
});
|
|
816
854
|
|
|
817
855
|
it("applies dangerouslySetInlineStyle overrides", () => {
|
|
@@ -881,7 +919,7 @@ describe("Box", () => {
|
|
|
881
919
|
<Text>Scrollable</Text>
|
|
882
920
|
</Box>
|
|
883
921
|
);
|
|
884
|
-
const scrollView = root.findByType("ScrollView"
|
|
922
|
+
const scrollView = root.findByType("ScrollView");
|
|
885
923
|
await act(async () => {
|
|
886
924
|
scrollView.props.onScroll?.({nativeEvent: {contentOffset: {y: 100}}});
|
|
887
925
|
});
|
|
@@ -908,7 +946,7 @@ describe("Box", () => {
|
|
|
908
946
|
});
|
|
909
947
|
|
|
910
948
|
it("exposes scrollTo and scrollToEnd through ref", () => {
|
|
911
|
-
const ref = React.createRef<
|
|
949
|
+
const ref = React.createRef<BoxScrollHandle>();
|
|
912
950
|
renderWithTheme(
|
|
913
951
|
<Box ref={ref} scroll>
|
|
914
952
|
<Text>Content</Text>
|
package/src/Box.tsx
CHANGED
|
@@ -60,6 +60,32 @@ const isValidWidthHeight = (value: number | string): boolean => {
|
|
|
60
60
|
return typeof value === "number" || !Number.isNaN(Number(value)) || isValidPercentage(value);
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Box props that describe behavior rather than layout. Unknown props fall through
|
|
65
|
+
* to the style object, so these have to be named explicitly: a callback or ref
|
|
66
|
+
* object reaching a native view's style crashes on Fabric, which serializes style
|
|
67
|
+
* (a ref holding a host instance is a cyclical structure) and freezes it in dev,
|
|
68
|
+
* so React then throws detaching the frozen `ref.current` on unmount.
|
|
69
|
+
*/
|
|
70
|
+
const NON_STYLE_BOX_PROPS = new Set<string>([
|
|
71
|
+
"accessibilityHint",
|
|
72
|
+
"accessibilityLabel",
|
|
73
|
+
"accessibilityRole",
|
|
74
|
+
"avoidKeyboard",
|
|
75
|
+
"children",
|
|
76
|
+
"dangerouslySetInlineStyle",
|
|
77
|
+
"keyboardOffset",
|
|
78
|
+
"onClick",
|
|
79
|
+
"onHoverEnd",
|
|
80
|
+
"onHoverStart",
|
|
81
|
+
"onLayout",
|
|
82
|
+
"onScroll",
|
|
83
|
+
"scroll",
|
|
84
|
+
"scrollRef",
|
|
85
|
+
"testID",
|
|
86
|
+
"testIDs",
|
|
87
|
+
]);
|
|
88
|
+
|
|
63
89
|
export const Box = React.forwardRef((props: BoxProps, ref) => {
|
|
64
90
|
const {theme} = useTheme();
|
|
65
91
|
const resolvedTestID = props.testID;
|
|
@@ -261,7 +287,14 @@ export const Box = React.forwardRef((props: BoxProps, ref) => {
|
|
|
261
287
|
return {width: value};
|
|
262
288
|
}
|
|
263
289
|
},
|
|
264
|
-
|
|
290
|
+
// Defaults to alignItems: "flex-start" so wrapped lines size to their content instead of
|
|
291
|
+
// stretching, but never overrides an explicit alignItems (prop order would decide the winner).
|
|
292
|
+
wrap: (value, allProps) => ({
|
|
293
|
+
alignItems: allProps.alignItems
|
|
294
|
+
? ALIGN_ITEMS[allProps.alignItems as AlignItems]
|
|
295
|
+
: "flex-start",
|
|
296
|
+
flexWrap: value ? "wrap" : "nowrap",
|
|
297
|
+
}),
|
|
265
298
|
zIndex: (value) => ({zIndex: value ? value : undefined}),
|
|
266
299
|
};
|
|
267
300
|
|
|
@@ -277,16 +310,12 @@ export const Box = React.forwardRef((props: BoxProps, ref) => {
|
|
|
277
310
|
const value = props[prop];
|
|
278
311
|
if (BOX_STYLE_MAP[prop]) {
|
|
279
312
|
Object.assign(style, BOX_STYLE_MAP[prop](value, props));
|
|
280
|
-
} else if (prop
|
|
313
|
+
} else if (!NON_STYLE_BOX_PROPS.has(prop as string)) {
|
|
281
314
|
style[prop] = value;
|
|
282
315
|
// console.warn(`Box: unknown property ${prop}`);
|
|
283
316
|
}
|
|
284
317
|
}
|
|
285
318
|
|
|
286
|
-
if (props.wrap && props.alignItems && Platform.OS !== "web") {
|
|
287
|
-
console.warn("React Native doesn't support wrap and alignItems together.");
|
|
288
|
-
}
|
|
289
|
-
|
|
290
319
|
// Finally, dangerously set overrides.
|
|
291
320
|
if (props.dangerouslySetInlineStyle) {
|
|
292
321
|
style = {...style, ...props.dangerouslySetInlineStyle.__style};
|
|
@@ -306,11 +335,17 @@ export const Box = React.forwardRef((props: BoxProps, ref) => {
|
|
|
306
335
|
let box: React.ReactElement;
|
|
307
336
|
|
|
308
337
|
// Adding the accessibilityRole of button throws a warning in React Native since we nest buttons
|
|
309
|
-
// within Box and RN does not support nested buttons
|
|
338
|
+
// within Box and RN does not support nested buttons — so this stays on `aria-role` (which RN
|
|
339
|
+
// itself translates to accessibilityRole under the hood) by default; an explicit
|
|
340
|
+
// `accessibilityRole` prop is only forwarded literally when the caller opts in.
|
|
310
341
|
if (props.onClick) {
|
|
342
|
+
const explicitAccessibilityRole = (props as AccessibilityProps).accessibilityRole;
|
|
311
343
|
box = (
|
|
312
344
|
<Pressable
|
|
313
345
|
accessibilityHint={(props as AccessibilityProps).accessibilityHint}
|
|
346
|
+
{...(explicitAccessibilityRole
|
|
347
|
+
? {accessibilityRole: explicitAccessibilityRole as never}
|
|
348
|
+
: {})}
|
|
314
349
|
aria-label={(props as AccessibilityProps).accessibilityLabel}
|
|
315
350
|
aria-role="button"
|
|
316
351
|
onLayout={props.onLayout}
|
|
@@ -327,8 +362,12 @@ export const Box = React.forwardRef((props: BoxProps, ref) => {
|
|
|
327
362
|
</Pressable>
|
|
328
363
|
);
|
|
329
364
|
} else {
|
|
365
|
+
const accessibilityHint = (props as AccessibilityProps).accessibilityHint;
|
|
366
|
+
const accessibilityLabel = (props as AccessibilityProps).accessibilityLabel;
|
|
330
367
|
box = (
|
|
331
368
|
<View
|
|
369
|
+
{...(accessibilityHint ? {accessibilityHint} : {})}
|
|
370
|
+
{...(accessibilityLabel ? {accessibilityLabel} : {})}
|
|
332
371
|
onPointerEnter={onHoverIn}
|
|
333
372
|
onPointerLeave={onHoverOut}
|
|
334
373
|
style={propsToStyle()}
|
package/src/Common.ts
CHANGED
|
@@ -518,6 +518,13 @@ export interface LayerProps {
|
|
|
518
518
|
export interface AccessibilityProps {
|
|
519
519
|
accessibilityLabel: string;
|
|
520
520
|
accessibilityHint: string;
|
|
521
|
+
/**
|
|
522
|
+
* RN/RNW accessibility role (e.g. "button") for a clickable Box. Optional —
|
|
523
|
+
* most onClick Boxes get an implicit button role already (see Box.tsx); set
|
|
524
|
+
* this explicitly when a screen-reader-facing role needs to be guaranteed
|
|
525
|
+
* (e.g. a badge that opens a sheet).
|
|
526
|
+
*/
|
|
527
|
+
accessibilityRole?: string;
|
|
521
528
|
}
|
|
522
529
|
|
|
523
530
|
export interface BoxPropsBase extends WithTestID {
|
|
@@ -2600,6 +2607,12 @@ export interface TextFieldPickerActionSheetProps {
|
|
|
2600
2607
|
|
|
2601
2608
|
export interface ToastProps {
|
|
2602
2609
|
title: string;
|
|
2610
|
+
/**
|
|
2611
|
+
* Stable toast id, forwarded by `useToast` from the caller's options. Used to
|
|
2612
|
+
* disambiguate the action button's testID so two stacked action toasts do not
|
|
2613
|
+
* both answer to `toast-action-button`.
|
|
2614
|
+
*/
|
|
2615
|
+
id?: string;
|
|
2603
2616
|
variant?: "error" | "info" | "success" | "warning";
|
|
2604
2617
|
secondary?: boolean;
|
|
2605
2618
|
size?: "sm" | "lg";
|
|
@@ -2607,9 +2620,14 @@ export interface ToastProps {
|
|
|
2607
2620
|
persistent?: boolean;
|
|
2608
2621
|
// TODO enforce these should only show if size is "lg" with type discrinimation
|
|
2609
2622
|
subtitle?: string;
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2623
|
+
/**
|
|
2624
|
+
* Optional action button label. Renders only when `buttonOnClick` is also provided.
|
|
2625
|
+
*/
|
|
2626
|
+
buttonText?: string;
|
|
2627
|
+
/**
|
|
2628
|
+
* Optional action button handler. Renders only when `buttonText` is also provided.
|
|
2629
|
+
*/
|
|
2630
|
+
buttonOnClick?: () => void | Promise<void>;
|
|
2613
2631
|
}
|
|
2614
2632
|
|
|
2615
2633
|
export interface TooltipProps {
|