@jobber/components-native 0.24.1-migrate-te.4 → 0.25.1-fix-breakp.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.
Files changed (47) hide show
  1. package/dist/src/BottomSheet/BottomSheet.js +52 -0
  2. package/dist/src/BottomSheet/BottomSheet.style.js +28 -0
  3. package/dist/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.js +17 -0
  4. package/dist/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.styles.js +18 -0
  5. package/dist/src/BottomSheet/components/BottomSheetOption/index.js +1 -0
  6. package/dist/src/BottomSheet/index.js +1 -0
  7. package/dist/src/BottomSheet/messages.js +8 -0
  8. package/dist/src/hooks/index.js +1 -0
  9. package/dist/src/hooks/useIsScreenReaderEnabled.js +22 -0
  10. package/dist/src/index.js +1 -1
  11. package/dist/src/utils/test/wait.js +58 -0
  12. package/dist/tsconfig.tsbuildinfo +1 -1
  13. package/dist/types/src/BottomSheet/BottomSheet.d.ts +28 -0
  14. package/dist/types/src/BottomSheet/BottomSheet.style.d.ts +32 -0
  15. package/dist/types/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.d.ts +13 -0
  16. package/dist/types/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.styles.d.ts +16 -0
  17. package/dist/types/src/BottomSheet/components/BottomSheetOption/index.d.ts +1 -0
  18. package/dist/types/src/BottomSheet/index.d.ts +1 -0
  19. package/dist/types/src/BottomSheet/messages.d.ts +7 -0
  20. package/dist/types/src/hooks/index.d.ts +1 -0
  21. package/dist/types/src/hooks/useIsScreenReaderEnabled.d.ts +1 -0
  22. package/dist/types/src/index.d.ts +1 -1
  23. package/dist/types/src/utils/test/wait.d.ts +36 -0
  24. package/package.json +7 -5
  25. package/src/BottomSheet/BottomSheet.style.ts +35 -0
  26. package/src/BottomSheet/BottomSheet.test.tsx +152 -0
  27. package/src/BottomSheet/BottomSheet.tsx +149 -0
  28. package/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.styles.ts +19 -0
  29. package/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.test.tsx +34 -0
  30. package/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.tsx +53 -0
  31. package/src/BottomSheet/components/BottomSheetOption/index.ts +1 -0
  32. package/src/BottomSheet/index.ts +1 -0
  33. package/src/BottomSheet/messages.ts +9 -0
  34. package/src/hooks/index.ts +1 -0
  35. package/src/hooks/useIsScreenReaderEnabled.ts +32 -0
  36. package/src/index.ts +1 -1
  37. package/src/utils/test/wait.ts +52 -0
  38. package/dist/src/TextList/TextList.js +0 -13
  39. package/dist/src/TextList/TextList.style.js +0 -16
  40. package/dist/src/TextList/index.js +0 -1
  41. package/dist/types/src/TextList/TextList.d.ts +0 -30
  42. package/dist/types/src/TextList/TextList.style.d.ts +0 -14
  43. package/dist/types/src/TextList/index.d.ts +0 -1
  44. package/src/TextList/TextList.style.ts +0 -17
  45. package/src/TextList/TextList.test.tsx +0 -20
  46. package/src/TextList/TextList.tsx +0 -68
  47. package/src/TextList/index.ts +0 -1
@@ -0,0 +1,32 @@
1
+ import { useEffect, useState } from "react";
2
+ import { AccessibilityInfo } from "react-native";
3
+
4
+ export function useIsScreenReaderEnabled(): boolean {
5
+ const [screenReaderEnabled, setScreenReaderEnabled] =
6
+ useState<boolean>(false);
7
+
8
+ useEffect(() => {
9
+ function handleScreenReaderToggle(isScreenReaderEnabled: boolean) {
10
+ setScreenReaderEnabled(isScreenReaderEnabled);
11
+ }
12
+
13
+ AccessibilityInfo.isScreenReaderEnabled()
14
+ .then(enabled => {
15
+ setScreenReaderEnabled(enabled);
16
+ })
17
+ .catch(() => {
18
+ setScreenReaderEnabled(false);
19
+ });
20
+
21
+ const listener = AccessibilityInfo.addEventListener(
22
+ "screenReaderChanged",
23
+ handleScreenReaderToggle,
24
+ );
25
+
26
+ return () => {
27
+ listener.remove();
28
+ };
29
+ }, []);
30
+
31
+ return screenReaderEnabled;
32
+ }
package/src/index.ts CHANGED
@@ -2,6 +2,7 @@ export * from "./ActionItem";
2
2
  export * from "./ActionLabel";
3
3
  export * from "./ActivityIndicator";
4
4
  export * from "./AtlantisContext";
5
+ export * from "./BottomSheet";
5
6
  export * from "./Button";
6
7
  export * from "./Card";
7
8
  export * from "./Chip";
@@ -16,7 +17,6 @@ export * from "./IconButton";
16
17
  export * from "./InputFieldWrapper";
17
18
  export * from "./InputPressable";
18
19
  export * from "./InputText";
19
- export * from "./TextList";
20
20
  export * from "./ProgressBar";
21
21
  export * from "./StatusLabel";
22
22
  export * from "./Switch";
@@ -0,0 +1,52 @@
1
+ import { screen } from "@testing-library/react-native";
2
+ import { act } from "react-test-renderer";
3
+
4
+ /**
5
+ * wait is used in our tests for testing Apollo Mocks
6
+ * useQuery returns fetching equal to true in the first render
7
+ * and the second render would return the mock result
8
+ * using "await act(wait)", we can wait for the next rerender
9
+ * to get the mock result of the query
10
+ * @param milliseconds time to wait in milliseconds
11
+ */
12
+ export async function wait(milliseconds = 0): Promise<void> {
13
+ await new Promise(resolve => setTimeout(resolve, milliseconds));
14
+ }
15
+
16
+ /**
17
+ * Use this test helper thoughtfully. If you are running into the
18
+ * "not wrapped in act(...)" warning while running your test it is
19
+ * recommended that:
20
+ *
21
+ * 1. Double check that there are really no layout changes that you can test against.
22
+ * waitForUntestableRender will fail your test if it detects layout changes
23
+ * 2. Re-evalutate your implementation. Maybe the managed state can be deferred to
24
+ * to a component further down the hierarchy? This can help prevent renders since
25
+ * your managed state isn't being used yet maybe?
26
+ *
27
+ * `waitForUntestableRender` is meant to be used as an alternative to
28
+ *
29
+ * ```tsx
30
+ * await act(wait)
31
+ * ```
32
+ *
33
+ * to make tests more readable.
34
+ *
35
+ * The `explanation` argument is required to ensure that a developer _thinks_
36
+ * about why they need use this function. It is _really_ important that devs
37
+ * understand when _and why_ a component's render cycle is flagged to be untested
38
+ * So do not put a throwaway explanation here. If you don't know why your test
39
+ * needs this function, find out!
40
+
41
+ */
42
+ export const waitForUntestableRender = async (
43
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
44
+ _explanation: string,
45
+ ): Promise<void> => {
46
+ const before = JSON.stringify(screen.toJSON(), null, 2);
47
+
48
+ await act(wait);
49
+
50
+ const after = JSON.stringify(screen.toJSON(), null, 2);
51
+ expect(before).toEqual(after);
52
+ };
@@ -1,13 +0,0 @@
1
- import React from "react";
2
- import { View } from "react-native";
3
- import { styles } from "./TextList.style";
4
- import { Content } from "../Content";
5
- import { Text } from "../Text";
6
- const BULLET_SYMBOL = `\u2022`;
7
- export function TextList({ items, childSpacing = "none", emphasis, level = "text", spacing = "none", }) {
8
- return (React.createElement(React.Fragment, null, items && (React.createElement(View, { style: styles.details },
9
- React.createElement(Content, { spacing: spacing, childSpacing: childSpacing }, items.map((item, index) => (React.createElement(View, { style: styles.detail, key: index },
10
- React.createElement(Text, { level: level, emphasis: emphasis }, BULLET_SYMBOL),
11
- React.createElement(View, { style: styles.detailText },
12
- React.createElement(Text, { level: level, emphasis: emphasis }, item))))))))));
13
- }
@@ -1,16 +0,0 @@
1
- import { StyleSheet } from "react-native";
2
- import { tokens } from "../utils/design";
3
- export const styles = StyleSheet.create({
4
- details: {
5
- flexDirection: "column",
6
- marginTop: tokens["space-small"],
7
- },
8
- detail: {
9
- flexDirection: "row",
10
- paddingLeft: tokens["space-small"],
11
- },
12
- detailText: {
13
- paddingLeft: tokens["space-small"],
14
- flex: 1,
15
- },
16
- });
@@ -1 +0,0 @@
1
- export { TextList } from "./TextList";
@@ -1,30 +0,0 @@
1
- /// <reference types="react" />
2
- import { Spacing } from "../Content";
3
- import { TextLevel } from "../Text";
4
- interface TextListProps {
5
- /**
6
- * Text to display.
7
- */
8
- readonly items?: string[];
9
- /**
10
- * Change the appearance of the text
11
- */
12
- readonly emphasis?: "strong";
13
- /**
14
- * Visual hierarchy of the text.
15
- * @default "text"
16
- */
17
- readonly level?: TextLevel;
18
- /**
19
- * The amount of spacing that content will give.
20
- * @default "none"
21
- */
22
- readonly spacing?: Spacing;
23
- /**
24
- * The amount of spacing that will be applied between the list items.
25
- * @default "none"
26
- */
27
- readonly childSpacing?: Spacing;
28
- }
29
- export declare function TextList({ items, childSpacing, emphasis, level, spacing, }: TextListProps): JSX.Element;
30
- export {};
@@ -1,14 +0,0 @@
1
- export declare const styles: {
2
- details: {
3
- flexDirection: "column";
4
- marginTop: number;
5
- };
6
- detail: {
7
- flexDirection: "row";
8
- paddingLeft: number;
9
- };
10
- detailText: {
11
- paddingLeft: number;
12
- flex: number;
13
- };
14
- };
@@ -1 +0,0 @@
1
- export { TextList } from "./TextList";
@@ -1,17 +0,0 @@
1
- import { StyleSheet } from "react-native";
2
- import { tokens } from "../utils/design";
3
-
4
- export const styles = StyleSheet.create({
5
- details: {
6
- flexDirection: "column",
7
- marginTop: tokens["space-small"],
8
- },
9
- detail: {
10
- flexDirection: "row",
11
- paddingLeft: tokens["space-small"],
12
- },
13
- detailText: {
14
- paddingLeft: tokens["space-small"],
15
- flex: 1,
16
- },
17
- });
@@ -1,20 +0,0 @@
1
- import React from "react";
2
- import { render } from "@testing-library/react-native";
3
- import { TextList } from "./TextList";
4
-
5
- describe("TextList", () => {
6
- describe("when the bulletItems is provided", () => {
7
- it("displays the text list", () => {
8
- const items = ["this is list item uno", "this is list item dos"];
9
- const tree = render(<TextList items={items} />);
10
-
11
- expect(tree.toJSON()).toMatchSnapshot();
12
- });
13
-
14
- it("displays will not display a bulleted list", () => {
15
- const tree = render(<TextList />);
16
-
17
- expect(tree.toJSON()).toMatchSnapshot();
18
- });
19
- });
20
- });
@@ -1,68 +0,0 @@
1
- import React from "react";
2
- import { View } from "react-native";
3
- import { styles } from "./TextList.style";
4
- import { Content, Spacing } from "../Content";
5
- import { Text, TextLevel } from "../Text";
6
-
7
- const BULLET_SYMBOL = `\u2022`;
8
-
9
- interface TextListProps {
10
- /**
11
- * Text to display.
12
- */
13
- readonly items?: string[];
14
-
15
- /**
16
- * Change the appearance of the text
17
- */
18
- readonly emphasis?: "strong";
19
-
20
- /**
21
- * Visual hierarchy of the text.
22
- * @default "text"
23
- */
24
- readonly level?: TextLevel;
25
-
26
- /**
27
- * The amount of spacing that content will give.
28
- * @default "none"
29
- */
30
- readonly spacing?: Spacing;
31
-
32
- /**
33
- * The amount of spacing that will be applied between the list items.
34
- * @default "none"
35
- */
36
- readonly childSpacing?: Spacing;
37
- }
38
-
39
- export function TextList({
40
- items,
41
- childSpacing = "none",
42
- emphasis,
43
- level = "text",
44
- spacing = "none",
45
- }: TextListProps): JSX.Element {
46
- return (
47
- <>
48
- {items && (
49
- <View style={styles.details}>
50
- <Content spacing={spacing} childSpacing={childSpacing}>
51
- {items.map((item, index) => (
52
- <View style={styles.detail} key={index}>
53
- <Text level={level} emphasis={emphasis}>
54
- {BULLET_SYMBOL}
55
- </Text>
56
- <View style={styles.detailText}>
57
- <Text level={level} emphasis={emphasis}>
58
- {item}
59
- </Text>
60
- </View>
61
- </View>
62
- ))}
63
- </Content>
64
- </View>
65
- )}
66
- </>
67
- );
68
- }
@@ -1 +0,0 @@
1
- export { TextList } from "./TextList";