@jobber/components-native 0.98.4 → 0.99.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 (73) hide show
  1. package/dist/package.json +2 -2
  2. package/dist/src/AtlantisOverlayProvider/AtlantisOverlayProvider.js +5 -0
  3. package/dist/src/AtlantisOverlayProvider/index.js +1 -0
  4. package/dist/src/BottomSheet/BottomSheet.js +9 -11
  5. package/dist/src/BottomSheet/hooks/useBottomSheetBackHandler.js +2 -2
  6. package/dist/src/ButtonGroup/components/SecondaryActionSheet/SecondaryActionSheet.js +9 -11
  7. package/dist/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.js +7 -9
  8. package/dist/src/index.js +1 -1
  9. package/dist/src/utils/meta/meta.json +1 -1
  10. package/dist/tsconfig.build.tsbuildinfo +1 -1
  11. package/dist/types/src/AtlantisOverlayProvider/AtlantisOverlayProvider.d.ts +6 -0
  12. package/dist/types/src/AtlantisOverlayProvider/index.d.ts +1 -0
  13. package/dist/types/src/BottomSheet/hooks/useBottomSheetBackHandler.d.ts +3 -3
  14. package/dist/types/src/index.d.ts +1 -1
  15. package/package.json +2 -2
  16. package/src/AtlantisOverlayProvider/AtlantisOverlayProvider.tsx +12 -0
  17. package/src/AtlantisOverlayProvider/index.ts +1 -0
  18. package/src/BottomSheet/BottomSheet.tsx +13 -13
  19. package/src/BottomSheet/hooks/useBottomSheetBackHandler.test.ts +10 -10
  20. package/src/BottomSheet/hooks/useBottomSheetBackHandler.ts +4 -4
  21. package/src/ButtonGroup/ButtonGroup.stories.tsx +10 -8
  22. package/src/ButtonGroup/ButtonGroup.test.tsx +7 -10
  23. package/src/ButtonGroup/components/SecondaryActionSheet/SecondaryActionSheet.tsx +26 -29
  24. package/src/Form/Form.stories.tsx +8 -4
  25. package/src/Form/Form.test.tsx +51 -54
  26. package/src/Form/components/FormSaveButton/FormSaveButton.test.tsx +7 -10
  27. package/src/FormatFile/FormatFile.stories.tsx +3 -4
  28. package/src/FormatFile/FormatFile.test.tsx +11 -14
  29. package/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.test.tsx +6 -9
  30. package/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.tsx +21 -24
  31. package/src/InputDate/InputDate.test.tsx +5 -8
  32. package/src/InputTime/InputTime.stories.tsx +8 -4
  33. package/src/InputTime/InputTime.test.tsx +5 -8
  34. package/src/ThumbnailList/ThumbnailList.stories.tsx +6 -4
  35. package/src/ThumbnailList/ThumbnailList.test.tsx +5 -8
  36. package/src/ThumbnailList/__snapshots__/ThumbnailList.test.tsx.snap +101 -150
  37. package/src/index.ts +1 -1
  38. package/src/utils/meta/meta.json +2 -2
  39. package/dist/src/Menu/Menu.js +0 -85
  40. package/dist/src/Menu/Menu.style.js +0 -7
  41. package/dist/src/Menu/components/MenuOption/MenuOption.js +0 -27
  42. package/dist/src/Menu/components/MenuOption/MenuOption.style.js +0 -11
  43. package/dist/src/Menu/components/MenuOption/index.js +0 -1
  44. package/dist/src/Menu/components/Overlay/Overlay.js +0 -10
  45. package/dist/src/Menu/components/Overlay/Overlay.style.js +0 -8
  46. package/dist/src/Menu/components/Overlay/index.js +0 -1
  47. package/dist/src/Menu/index.js +0 -1
  48. package/dist/src/Menu/types.js +0 -1
  49. package/dist/src/Menu/utils.js +0 -78
  50. package/dist/types/src/Menu/Menu.d.ts +0 -3
  51. package/dist/types/src/Menu/Menu.style.d.ts +0 -18
  52. package/dist/types/src/Menu/components/MenuOption/MenuOption.d.ts +0 -3
  53. package/dist/types/src/Menu/components/MenuOption/MenuOption.style.d.ts +0 -8
  54. package/dist/types/src/Menu/components/MenuOption/index.d.ts +0 -1
  55. package/dist/types/src/Menu/components/Overlay/Overlay.d.ts +0 -3
  56. package/dist/types/src/Menu/components/Overlay/Overlay.style.d.ts +0 -12
  57. package/dist/types/src/Menu/components/Overlay/index.d.ts +0 -1
  58. package/dist/types/src/Menu/index.d.ts +0 -2
  59. package/dist/types/src/Menu/types.d.ts +0 -26
  60. package/dist/types/src/Menu/utils.d.ts +0 -11
  61. package/src/Menu/Menu.stories.tsx +0 -52
  62. package/src/Menu/Menu.style.ts +0 -17
  63. package/src/Menu/Menu.test.tsx +0 -203
  64. package/src/Menu/Menu.tsx +0 -141
  65. package/src/Menu/components/MenuOption/MenuOption.style.tsx +0 -12
  66. package/src/Menu/components/MenuOption/MenuOption.tsx +0 -66
  67. package/src/Menu/components/MenuOption/index.ts +0 -1
  68. package/src/Menu/components/Overlay/Overlay.style.ts +0 -15
  69. package/src/Menu/components/Overlay/Overlay.tsx +0 -18
  70. package/src/Menu/components/Overlay/index.ts +0 -1
  71. package/src/Menu/index.ts +0 -6
  72. package/src/Menu/types.ts +0 -31
  73. package/src/Menu/utils.ts +0 -148
@@ -1,12 +0,0 @@
1
- import { buildThemedStyles } from "../../../AtlantisThemeContext";
2
-
3
- export const useStyles = buildThemedStyles(tokens => {
4
- return {
5
- menuOption: {
6
- display: "flex",
7
- paddingHorizontal: tokens["space-base"],
8
- paddingVertical: tokens["space-small"],
9
- borderRadius: tokens["radius-large"],
10
- },
11
- };
12
- });
@@ -1,66 +0,0 @@
1
- import React from "react";
2
- import { Pressable, View } from "react-native";
3
- import capitalize from "lodash/capitalize";
4
- import { useStyles } from "./MenuOption.style";
5
- import type { MenuOptionInternalProps } from "../../types";
6
- import { Flex } from "../../../Flex";
7
- import { Typography } from "../../../Typography";
8
- import { Icon } from "../../../Icon";
9
- import { useAtlantisTheme } from "../../../AtlantisThemeContext";
10
-
11
- export function MenuOption({
12
- label,
13
- icon,
14
- iconColor = "heading",
15
- textAlign,
16
- destructive,
17
- textTransform = "capitalize",
18
- onPress,
19
- setOpen,
20
- }: MenuOptionInternalProps) {
21
- const destructiveColor = "destructive";
22
- const textVariation = destructive ? destructiveColor : "heading";
23
- const styles = useStyles();
24
- const { tokens } = useAtlantisTheme();
25
-
26
- return (
27
- <View testID="ATL-MENU-OPTIONS">
28
- <Pressable
29
- style={({ pressed }) => [
30
- styles.menuOption,
31
- { opacity: pressed ? tokens["opacity-pressed"] : 1 },
32
- ]}
33
- onPress={() => {
34
- onPress();
35
- setOpen(false);
36
- }}
37
- accessibilityLabel={label}
38
- >
39
- <Flex
40
- template={["grow", "shrink"]}
41
- align={"flex-start"}
42
- gap={"smaller"}
43
- >
44
- <Typography
45
- selectable={false}
46
- color={textVariation}
47
- fontWeight={"semiBold"}
48
- lineHeight={"large"}
49
- align={textAlign}
50
- >
51
- {textTransform === "capitalize"
52
- ? capitalize(label.toLocaleLowerCase())
53
- : label}
54
- </Typography>
55
-
56
- {icon && (
57
- <Icon
58
- name={icon}
59
- color={destructive ? destructiveColor : iconColor}
60
- />
61
- )}
62
- </Flex>
63
- </Pressable>
64
- </View>
65
- );
66
- }
@@ -1 +0,0 @@
1
- export { MenuOption } from "./MenuOption";
@@ -1,15 +0,0 @@
1
- import { Dimensions, StyleSheet } from "react-native";
2
- import { buildThemedStyles } from "../../../AtlantisThemeContext";
3
-
4
- const { height } = Dimensions.get("window");
5
-
6
- export const useStyles = buildThemedStyles(tokens => {
7
- return {
8
- overlay: {
9
- ...StyleSheet.absoluteFillObject,
10
- backgroundColor: tokens["color-overlay"],
11
- opacity: 0,
12
- height,
13
- },
14
- };
15
- });
@@ -1,18 +0,0 @@
1
- import React from "react";
2
- import { Pressable, View } from "react-native";
3
- import { useStyles } from "./Overlay.style";
4
- import type { OverlayProp } from "../../types";
5
-
6
- export function Overlay({ setOpen }: OverlayProp) {
7
- const styles = useStyles();
8
-
9
- return (
10
- <Pressable
11
- onPressIn={() => {
12
- setOpen(false);
13
- }}
14
- >
15
- <View style={styles.overlay} />
16
- </Pressable>
17
- );
18
- }
@@ -1 +0,0 @@
1
- export { Overlay } from "./Overlay";
package/src/Menu/index.ts DELETED
@@ -1,6 +0,0 @@
1
- export { Menu } from "./Menu";
2
- export type {
3
- MenuProps,
4
- MenuOptionProps,
5
- MenuOptionInternalProps,
6
- } from "./types";
package/src/Menu/types.ts DELETED
@@ -1,31 +0,0 @@
1
- import type { ReactElement } from "react";
2
- import type { IconColorNames, IconNames } from "@jobber/design";
3
- import type { TextAlign } from "../Typography";
4
-
5
- export interface MenuOptionProps {
6
- readonly label: string;
7
- readonly icon?: IconNames;
8
- readonly iconColor?: IconColorNames;
9
- readonly textAlign?: TextAlign;
10
- readonly destructive?: boolean;
11
- readonly textTransform?: "none" | "capitalize";
12
- onPress: () => void;
13
- }
14
-
15
- export interface MenuOptionInternalProps extends MenuOptionProps {
16
- setOpen: (bool: boolean) => void;
17
- }
18
-
19
- export interface CustomActivatorProps {
20
- readonly onPress?: () => void;
21
- readonly onLongPress?: () => void;
22
- }
23
-
24
- export interface MenuProps {
25
- readonly menuOptions?: MenuOptionProps[];
26
- readonly customActivator?: ReactElement<CustomActivatorProps>;
27
- }
28
-
29
- export interface OverlayProp {
30
- setOpen: (bool: boolean) => void;
31
- }
package/src/Menu/utils.ts DELETED
@@ -1,148 +0,0 @@
1
- import type { LayoutRectangle } from "react-native";
2
- import type { useStyles } from "./Menu.style";
3
-
4
- interface ScreenInfo {
5
- windowHeight: number;
6
- headerHeight: number;
7
- windowWidth: number;
8
- }
9
-
10
- export function findViewpoint(
11
- screenInfo: ScreenInfo,
12
- activatorLayout: LayoutRectangle,
13
- styles: ReturnType<typeof useStyles>,
14
- ): { [key: string]: number | undefined } {
15
- const { windowHeight, windowWidth, headerHeight } = screenInfo;
16
- const pos: { [key: string]: number | undefined } = {};
17
- const menuWidth = styles.menu.width;
18
- const windowHalf = (windowHeight - headerHeight) / 2 + headerHeight;
19
- const menuPositionVertical =
20
- activatorLayout.y + activatorLayout.height > windowHalf
21
- ? "menuAbove"
22
- : "menuBelow";
23
-
24
- const menuPositionHorizontal =
25
- windowWidth / 2 > activatorLayout.width / 2 + activatorLayout.x
26
- ? "menuRight"
27
- : "menuLeft";
28
-
29
- const menuPadding = 36;
30
-
31
- getVerticalPosition(pos, windowHeight, activatorLayout, menuPositionVertical);
32
-
33
- getHorizontalPosition(
34
- pos,
35
- activatorLayout,
36
- windowWidth,
37
- menuPadding,
38
- menuWidth,
39
- menuPositionHorizontal,
40
- );
41
-
42
- return pos;
43
- }
44
-
45
- function getVerticalPosition(
46
- pos: { [key: string]: number | undefined },
47
- windowHeight: number,
48
- activatorLayout: LayoutRectangle,
49
- menuPositionVertical: string,
50
- ) {
51
- if (menuPositionVertical === "menuAbove") {
52
- getAbovePosition(pos, windowHeight, activatorLayout);
53
- }
54
-
55
- if (menuPositionVertical === "menuBelow") {
56
- getBelowPosition(pos, activatorLayout);
57
- }
58
- }
59
-
60
- function getBelowPosition(
61
- pos: { [key: string]: number | undefined },
62
- activatorLayout: LayoutRectangle,
63
- ) {
64
- pos.top = activatorLayout.y + activatorLayout.height;
65
- }
66
-
67
- function getAbovePosition(
68
- pos: { [key: string]: number | undefined },
69
- windowHeight: number,
70
- activatorLayout: LayoutRectangle,
71
- ) {
72
- pos.bottom = windowHeight - activatorLayout.y;
73
- }
74
-
75
- function getHorizontalPosition(
76
- pos: { [key: string]: number | undefined },
77
- activatorLayout: LayoutRectangle,
78
- windowWidth: number,
79
- menuPadding: number,
80
- menuWidth: number,
81
- menuPositionHorizontal: string,
82
- ) {
83
- if (menuPositionHorizontal === "menuRight") {
84
- getRightPosition(pos, activatorLayout, windowWidth, menuPadding, menuWidth);
85
- }
86
-
87
- if (menuPositionHorizontal === "menuLeft") {
88
- getLeftPosition(pos, activatorLayout, windowWidth, menuPadding, menuWidth);
89
- }
90
- }
91
-
92
- function getLeftPosition(
93
- pos: { [key: string]: number | undefined },
94
- activatorLayout: LayoutRectangle,
95
- windowWidth: number,
96
- menuHorizontalPadding: number,
97
- menuWidth: number,
98
- ) {
99
- const overflowLeft =
100
- windowWidth -
101
- activatorLayout.x -
102
- activatorLayout.width +
103
- activatorLayout.width / 2 -
104
- menuHorizontalPadding +
105
- menuWidth >
106
- windowWidth;
107
-
108
- const overflowRight =
109
- windowWidth -
110
- activatorLayout.x -
111
- activatorLayout.width +
112
- activatorLayout.width / 2 -
113
- menuHorizontalPadding <
114
- 0;
115
-
116
- if (overflowLeft) {
117
- pos.right = undefined;
118
- pos.left = 0;
119
- } else if (overflowRight) {
120
- pos.right = 0;
121
- } else {
122
- pos.right = windowWidth - activatorLayout.x - activatorLayout.width;
123
- }
124
- }
125
-
126
- function getRightPosition(
127
- pos: { [key: string]: number | undefined },
128
- activatorLayout: LayoutRectangle,
129
- windowWidth: number,
130
- menuPadding: number,
131
- menuWidth: number,
132
- ) {
133
- const overflowRight =
134
- activatorLayout.x + activatorLayout.width / 2 - menuPadding + menuWidth >
135
- windowWidth;
136
-
137
- const overflowLeft =
138
- activatorLayout.x + activatorLayout.width / 2 - menuPadding < 0;
139
-
140
- if (overflowRight) {
141
- pos.left = undefined;
142
- pos.right = 0;
143
- } else if (overflowLeft) {
144
- pos.left = 0;
145
- } else {
146
- pos.left = activatorLayout.x;
147
- }
148
- }