@terreno/ui 0.11.4-beta.4 → 0.11.5
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/Common.d.ts +0 -13
- package/dist/CustomSelectField.js +1 -1
- package/dist/CustomSelectField.js.map +1 -1
- package/dist/DataTable.js +6 -3
- package/dist/DataTable.js.map +1 -1
- package/dist/ErrorBoundary.d.ts +3 -7
- package/dist/ErrorBoundary.js.map +1 -1
- package/dist/Link.d.ts +1 -1
- package/dist/Link.js +10 -1
- package/dist/Link.js.map +1 -1
- package/dist/MarkdownEditorField.js +2 -2
- package/dist/MarkdownEditorField.js.map +1 -1
- package/dist/Modal.js +1 -1
- package/dist/Modal.js.map +1 -1
- package/dist/SelectField.js +2 -2
- package/dist/SelectField.js.map +1 -1
- package/dist/SidebarNavigation.native.d.ts +17 -9
- package/dist/SidebarNavigation.native.js +103 -167
- package/dist/SidebarNavigation.native.js.map +1 -1
- package/dist/icons/MobileIcon.d.ts +2 -1
- package/dist/icons/MobileIcon.js.map +1 -1
- package/package.json +1 -1
- package/src/Common.ts +0 -13
- package/src/CustomSelectField.test.tsx +53 -1
- package/src/CustomSelectField.tsx +1 -1
- package/src/DataTable.tsx +35 -31
- package/src/ErrorBoundary.tsx +5 -5
- package/src/Link.tsx +11 -2
- package/src/MarkdownEditorField.tsx +3 -3
- package/src/Modal.tsx +3 -3
- package/src/SelectField.tsx +2 -2
- package/src/SidebarNavigation.native.tsx +158 -275
- package/src/ToastNotifications.test.tsx +206 -0
- package/src/icons/MobileIcon.tsx +2 -1
|
@@ -603,6 +603,212 @@ describe("ToastNotifications", () => {
|
|
|
603
603
|
});
|
|
604
604
|
});
|
|
605
605
|
|
|
606
|
+
describe("Toast update and hideAll", () => {
|
|
607
|
+
it("should update an existing toast message", async () => {
|
|
608
|
+
let toastRef: ToastType | null = null;
|
|
609
|
+
|
|
610
|
+
const TestComponent = () => {
|
|
611
|
+
const toast = useToastNotifications();
|
|
612
|
+
toastRef = toast;
|
|
613
|
+
return <Text>Test</Text>;
|
|
614
|
+
};
|
|
615
|
+
|
|
616
|
+
render(
|
|
617
|
+
<ToastProvider swipeEnabled={false}>
|
|
618
|
+
<TestComponent />
|
|
619
|
+
</ToastProvider>
|
|
620
|
+
);
|
|
621
|
+
|
|
622
|
+
await waitFor(() => {
|
|
623
|
+
expect(toastRef?.show).toBeDefined();
|
|
624
|
+
});
|
|
625
|
+
|
|
626
|
+
let toastId: string | undefined;
|
|
627
|
+
await act(async () => {
|
|
628
|
+
toastId = toastRef?.show("Original message", {id: "update-test"});
|
|
629
|
+
});
|
|
630
|
+
|
|
631
|
+
expect(toastId).toBe("update-test");
|
|
632
|
+
|
|
633
|
+
await act(async () => {
|
|
634
|
+
toastRef?.update("update-test", "Updated message");
|
|
635
|
+
});
|
|
636
|
+
|
|
637
|
+
expect(typeof toastRef?.update).toBe("function");
|
|
638
|
+
});
|
|
639
|
+
|
|
640
|
+
it("should hide all toasts at once", async () => {
|
|
641
|
+
let toastRef: ToastType | null = null;
|
|
642
|
+
|
|
643
|
+
const TestComponent = () => {
|
|
644
|
+
const toast = useToastNotifications();
|
|
645
|
+
toastRef = toast;
|
|
646
|
+
return <Text>Test</Text>;
|
|
647
|
+
};
|
|
648
|
+
|
|
649
|
+
render(
|
|
650
|
+
<ToastProvider swipeEnabled={false}>
|
|
651
|
+
<TestComponent />
|
|
652
|
+
</ToastProvider>
|
|
653
|
+
);
|
|
654
|
+
|
|
655
|
+
await waitFor(() => {
|
|
656
|
+
expect(toastRef?.show).toBeDefined();
|
|
657
|
+
});
|
|
658
|
+
|
|
659
|
+
await act(async () => {
|
|
660
|
+
toastRef?.show("Toast 1", {id: "hide-all-1"});
|
|
661
|
+
toastRef?.show("Toast 2", {id: "hide-all-2"});
|
|
662
|
+
});
|
|
663
|
+
|
|
664
|
+
await act(async () => {
|
|
665
|
+
toastRef?.hideAll();
|
|
666
|
+
});
|
|
667
|
+
|
|
668
|
+
expect(toastRef?.isOpen("hide-all-1")).toBe(false);
|
|
669
|
+
expect(toastRef?.isOpen("hide-all-2")).toBe(false);
|
|
670
|
+
});
|
|
671
|
+
});
|
|
672
|
+
|
|
673
|
+
describe("Toast placement rendering", () => {
|
|
674
|
+
it("should render toast with top placement", async () => {
|
|
675
|
+
let toastRef: ToastType | null = null;
|
|
676
|
+
|
|
677
|
+
const TestComponent = () => {
|
|
678
|
+
const toast = useToastNotifications();
|
|
679
|
+
toastRef = toast;
|
|
680
|
+
return <Text>Test</Text>;
|
|
681
|
+
};
|
|
682
|
+
|
|
683
|
+
render(
|
|
684
|
+
<ToastProvider placement="top" swipeEnabled={false}>
|
|
685
|
+
<TestComponent />
|
|
686
|
+
</ToastProvider>
|
|
687
|
+
);
|
|
688
|
+
|
|
689
|
+
await waitFor(() => {
|
|
690
|
+
expect(toastRef?.show).toBeDefined();
|
|
691
|
+
});
|
|
692
|
+
|
|
693
|
+
let toastId: string | undefined;
|
|
694
|
+
await act(async () => {
|
|
695
|
+
toastId = toastRef?.show("Top toast", {placement: "top"});
|
|
696
|
+
});
|
|
697
|
+
|
|
698
|
+
expect(toastId).toBeDefined();
|
|
699
|
+
});
|
|
700
|
+
|
|
701
|
+
it("should render toast with center placement", async () => {
|
|
702
|
+
let toastRef: ToastType | null = null;
|
|
703
|
+
|
|
704
|
+
const TestComponent = () => {
|
|
705
|
+
const toast = useToastNotifications();
|
|
706
|
+
toastRef = toast;
|
|
707
|
+
return <Text>Test</Text>;
|
|
708
|
+
};
|
|
709
|
+
|
|
710
|
+
render(
|
|
711
|
+
<ToastProvider placement="center" swipeEnabled={false}>
|
|
712
|
+
<TestComponent />
|
|
713
|
+
</ToastProvider>
|
|
714
|
+
);
|
|
715
|
+
|
|
716
|
+
await waitFor(() => {
|
|
717
|
+
expect(toastRef?.show).toBeDefined();
|
|
718
|
+
});
|
|
719
|
+
|
|
720
|
+
let toastId: string | undefined;
|
|
721
|
+
await act(async () => {
|
|
722
|
+
toastId = toastRef?.show("Center toast", {placement: "center"});
|
|
723
|
+
});
|
|
724
|
+
|
|
725
|
+
expect(toastId).toBeDefined();
|
|
726
|
+
});
|
|
727
|
+
});
|
|
728
|
+
|
|
729
|
+
describe("Toast icon and color variants", () => {
|
|
730
|
+
it("should render success toast with custom icon", async () => {
|
|
731
|
+
let toastRef: ToastType | null = null;
|
|
732
|
+
|
|
733
|
+
const TestComponent = () => {
|
|
734
|
+
const toast = useToastNotifications();
|
|
735
|
+
toastRef = toast;
|
|
736
|
+
return <Text>Test</Text>;
|
|
737
|
+
};
|
|
738
|
+
|
|
739
|
+
render(
|
|
740
|
+
<ToastProvider successIcon={<Text>✓</Text>} swipeEnabled={false}>
|
|
741
|
+
<TestComponent />
|
|
742
|
+
</ToastProvider>
|
|
743
|
+
);
|
|
744
|
+
|
|
745
|
+
await waitFor(() => {
|
|
746
|
+
expect(toastRef?.show).toBeDefined();
|
|
747
|
+
});
|
|
748
|
+
|
|
749
|
+
let toastId: string | undefined;
|
|
750
|
+
await act(async () => {
|
|
751
|
+
toastId = toastRef?.show("Success!", {type: "success"});
|
|
752
|
+
});
|
|
753
|
+
|
|
754
|
+
expect(toastId).toBeDefined();
|
|
755
|
+
});
|
|
756
|
+
|
|
757
|
+
it("should render danger toast with custom icon", async () => {
|
|
758
|
+
let toastRef: ToastType | null = null;
|
|
759
|
+
|
|
760
|
+
const TestComponent = () => {
|
|
761
|
+
const toast = useToastNotifications();
|
|
762
|
+
toastRef = toast;
|
|
763
|
+
return <Text>Test</Text>;
|
|
764
|
+
};
|
|
765
|
+
|
|
766
|
+
render(
|
|
767
|
+
<ToastProvider dangerIcon={<Text>✗</Text>} swipeEnabled={false}>
|
|
768
|
+
<TestComponent />
|
|
769
|
+
</ToastProvider>
|
|
770
|
+
);
|
|
771
|
+
|
|
772
|
+
await waitFor(() => {
|
|
773
|
+
expect(toastRef?.show).toBeDefined();
|
|
774
|
+
});
|
|
775
|
+
|
|
776
|
+
let toastId: string | undefined;
|
|
777
|
+
await act(async () => {
|
|
778
|
+
toastId = toastRef?.show("Error!", {type: "danger"});
|
|
779
|
+
});
|
|
780
|
+
|
|
781
|
+
expect(toastId).toBeDefined();
|
|
782
|
+
});
|
|
783
|
+
|
|
784
|
+
it("should render warning toast with custom icon", async () => {
|
|
785
|
+
let toastRef: ToastType | null = null;
|
|
786
|
+
|
|
787
|
+
const TestComponent = () => {
|
|
788
|
+
const toast = useToastNotifications();
|
|
789
|
+
toastRef = toast;
|
|
790
|
+
return <Text>Test</Text>;
|
|
791
|
+
};
|
|
792
|
+
|
|
793
|
+
render(
|
|
794
|
+
<ToastProvider swipeEnabled={false} warningIcon={<Text>⚠</Text>}>
|
|
795
|
+
<TestComponent />
|
|
796
|
+
</ToastProvider>
|
|
797
|
+
);
|
|
798
|
+
|
|
799
|
+
await waitFor(() => {
|
|
800
|
+
expect(toastRef?.show).toBeDefined();
|
|
801
|
+
});
|
|
802
|
+
|
|
803
|
+
let toastId: string | undefined;
|
|
804
|
+
await act(async () => {
|
|
805
|
+
toastId = toastRef?.show("Warning!", {type: "warning"});
|
|
806
|
+
});
|
|
807
|
+
|
|
808
|
+
expect(toastId).toBeDefined();
|
|
809
|
+
});
|
|
810
|
+
});
|
|
811
|
+
|
|
606
812
|
describe("Type exports", () => {
|
|
607
813
|
it("should export ToastOptions type", () => {
|
|
608
814
|
const options: ToastOptions = {
|
package/src/icons/MobileIcon.tsx
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type React from "react";
|
|
1
2
|
import Svg, {Path} from "react-native-svg";
|
|
2
3
|
|
|
3
4
|
import type {CustomSvgProps} from "../Common";
|
|
4
5
|
|
|
5
|
-
export const MobileIcon = ({doNotDisturb, ...props}: CustomSvgProps) => {
|
|
6
|
+
export const MobileIcon = ({doNotDisturb, ...props}: CustomSvgProps): React.ReactElement => {
|
|
6
7
|
return (
|
|
7
8
|
<Svg fill="none" height={33} viewBox="0 0 33 45" width={30} {...props}>
|
|
8
9
|
<Path d="M3 7h24v35H3z" fill="#fff" />
|