@jobber/components-native 0.38.0 → 0.40.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/dist/src/AtlantisContext/AtlantisContext.js +2 -0
- package/dist/src/Form/Form.js +187 -0
- package/dist/src/Form/Form.style.js +33 -0
- package/dist/src/Form/components/FormActionBar/FormActionBar.js +21 -0
- package/dist/src/Form/components/FormActionBar/FormActionBar.style.js +5 -0
- package/dist/src/Form/components/FormActionBar/index.js +1 -0
- package/dist/src/Form/components/FormBody/FormBody.js +20 -0
- package/dist/src/Form/components/FormBody/FormBody.style.js +26 -0
- package/dist/src/Form/components/FormBody/index.js +1 -0
- package/dist/src/Form/components/FormCache/FormCache.js +34 -0
- package/dist/src/Form/components/FormErrorBanner/FormErrorBanner.js +21 -0
- package/dist/src/Form/components/FormErrorBanner/index.js +1 -0
- package/dist/src/Form/components/FormErrorBanner/messages.js +13 -0
- package/dist/src/Form/components/FormMask/FormMask.js +11 -0
- package/dist/src/Form/components/FormMask/FormMask.style.js +15 -0
- package/dist/src/Form/components/FormMask/index.js +1 -0
- package/dist/src/Form/components/FormMessage/FormMessage.js +48 -0
- package/dist/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.js +28 -0
- package/dist/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.style.js +17 -0
- package/dist/src/Form/components/FormMessage/components/InternalFormMessage/index.js +1 -0
- package/dist/src/Form/components/FormMessage/components/InternalFormMessage/messages.js +8 -0
- package/dist/src/Form/components/FormMessage/index.js +1 -0
- package/dist/src/Form/components/FormMessageBanner/FormMessageBanner.js +15 -0
- package/dist/src/Form/components/FormMessageBanner/index.js +1 -0
- package/dist/src/Form/components/FormSaveButton/FormSaveButton.js +69 -0
- package/dist/src/Form/components/FormSaveButton/index.js +1 -0
- package/dist/src/Form/components/FormSaveButton/messages.js +8 -0
- package/dist/src/Form/constants.js +2 -0
- package/dist/src/Form/context/AtlantisFormContext.js +16 -0
- package/dist/src/Form/context/index.js +1 -0
- package/dist/src/Form/context/types.js +1 -0
- package/dist/src/Form/hooks/useFormViewRefs.js +14 -0
- package/dist/src/Form/hooks/useInternalForm.js +37 -0
- package/dist/src/Form/hooks/useOfflineHandler.js +24 -0
- package/dist/src/Form/hooks/useSaveButtonPosition.js +25 -0
- package/dist/src/Form/hooks/useScreenInformation.js +15 -0
- package/dist/src/Form/hooks/useScrollToError/index.js +1 -0
- package/dist/src/Form/hooks/useScrollToError/useScrollToError.js +63 -0
- package/dist/src/Form/index.js +4 -0
- package/dist/src/Form/messages.js +28 -0
- package/dist/src/Form/types.js +10 -0
- package/dist/src/InputDate/InputDate.js +76 -0
- package/dist/src/InputDate/index.js +1 -0
- package/dist/src/InputDate/messages.js +8 -0
- package/dist/src/Menu/Menu.js +67 -0
- package/dist/src/Menu/Menu.style.js +6 -0
- package/dist/src/Menu/components/MenuOption/MenuOption.js +25 -0
- package/dist/src/Menu/components/MenuOption/MenuOption.style.js +10 -0
- package/dist/src/Menu/components/MenuOption/index.js +1 -0
- package/dist/src/Menu/components/Overlay/Overlay.js +9 -0
- package/dist/src/Menu/components/Overlay/Overlay.style.js +6 -0
- package/dist/src/Menu/components/Overlay/index.js +1 -0
- package/dist/src/Menu/index.js +1 -0
- package/dist/src/Menu/messages.js +8 -0
- package/dist/src/Menu/types.js +1 -0
- package/dist/src/Menu/utils.js +84 -0
- package/dist/src/index.js +3 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/AtlantisContext/AtlantisContext.d.ts +7 -1
- package/dist/types/src/Form/Form.d.ts +4 -0
- package/dist/types/src/Form/Form.style.d.ts +31 -0
- package/dist/types/src/Form/components/FormActionBar/FormActionBar.d.ts +13 -0
- package/dist/types/src/Form/components/FormActionBar/FormActionBar.style.d.ts +15 -0
- package/dist/types/src/Form/components/FormActionBar/index.d.ts +2 -0
- package/dist/types/src/Form/components/FormBody/FormBody.d.ts +10 -0
- package/dist/types/src/Form/components/FormBody/FormBody.style.d.ts +24 -0
- package/dist/types/src/Form/components/FormBody/index.d.ts +1 -0
- package/dist/types/src/Form/components/FormCache/FormCache.d.ts +10 -0
- package/dist/types/src/Form/components/FormErrorBanner/FormErrorBanner.d.ts +3 -0
- package/dist/types/src/Form/components/FormErrorBanner/index.d.ts +1 -0
- package/dist/types/src/Form/components/FormErrorBanner/messages.d.ts +12 -0
- package/dist/types/src/Form/components/FormMask/FormMask.d.ts +2 -0
- package/dist/types/src/Form/components/FormMask/FormMask.style.d.ts +13 -0
- package/dist/types/src/Form/components/FormMask/index.d.ts +1 -0
- package/dist/types/src/Form/components/FormMessage/FormMessage.d.ts +19 -0
- package/dist/types/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.d.ts +8 -0
- package/dist/types/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.style.d.ts +20 -0
- package/dist/types/src/Form/components/FormMessage/components/InternalFormMessage/index.d.ts +1 -0
- package/dist/types/src/Form/components/FormMessage/components/InternalFormMessage/messages.d.ts +7 -0
- package/dist/types/src/Form/components/FormMessage/index.d.ts +1 -0
- package/dist/types/src/Form/components/FormMessageBanner/FormMessageBanner.d.ts +7 -0
- package/dist/types/src/Form/components/FormMessageBanner/index.d.ts +1 -0
- package/dist/types/src/Form/components/FormSaveButton/FormSaveButton.d.ts +3 -0
- package/dist/types/src/Form/components/FormSaveButton/index.d.ts +1 -0
- package/dist/types/src/Form/components/FormSaveButton/messages.d.ts +7 -0
- package/dist/types/src/Form/constants.d.ts +2 -0
- package/dist/types/src/Form/context/AtlantisFormContext.d.ts +12 -0
- package/dist/types/src/Form/context/index.d.ts +2 -0
- package/dist/types/src/Form/context/types.d.ts +26 -0
- package/dist/types/src/Form/hooks/useFormViewRefs.d.ts +10 -0
- package/dist/types/src/Form/hooks/useInternalForm.d.ts +19 -0
- package/dist/types/src/Form/hooks/useOfflineHandler.d.ts +1 -0
- package/dist/types/src/Form/hooks/useSaveButtonPosition.d.ts +12 -0
- package/dist/types/src/Form/hooks/useScreenInformation.d.ts +8 -0
- package/dist/types/src/Form/hooks/useScrollToError/index.d.ts +1 -0
- package/dist/types/src/Form/hooks/useScrollToError/useScrollToError.d.ts +10 -0
- package/dist/types/src/Form/index.d.ts +5 -0
- package/dist/types/src/Form/messages.d.ts +27 -0
- package/dist/types/src/Form/types.d.ts +199 -0
- package/dist/types/src/InputDate/InputDate.d.ts +74 -0
- package/dist/types/src/InputDate/index.d.ts +1 -0
- package/dist/types/src/InputDate/messages.d.ts +7 -0
- package/dist/types/src/InputNumber/InputNumber.d.ts +1 -1
- package/dist/types/src/Menu/Menu.d.ts +3 -0
- package/dist/types/src/Menu/Menu.style.d.ts +18 -0
- package/dist/types/src/Menu/components/MenuOption/MenuOption.d.ts +3 -0
- package/dist/types/src/Menu/components/MenuOption/MenuOption.style.d.ts +8 -0
- package/dist/types/src/Menu/components/MenuOption/index.d.ts +1 -0
- package/dist/types/src/Menu/components/Overlay/Overlay.d.ts +3 -0
- package/dist/types/src/Menu/components/Overlay/Overlay.style.d.ts +12 -0
- package/dist/types/src/Menu/components/Overlay/index.d.ts +1 -0
- package/dist/types/src/Menu/index.d.ts +2 -0
- package/dist/types/src/Menu/messages.d.ts +7 -0
- package/dist/types/src/Menu/types.d.ts +22 -0
- package/dist/types/src/Menu/utils.d.ts +10 -0
- package/dist/types/src/index.d.ts +3 -0
- package/package.json +3 -2
- package/src/AtlantisContext/AtlantisContext.tsx +10 -1
- package/src/Form/Form.style.ts +34 -0
- package/src/Form/Form.test.tsx +588 -0
- package/src/Form/Form.tsx +296 -0
- package/src/Form/components/FormActionBar/FormActionBar.style.ts +11 -0
- package/src/Form/components/FormActionBar/FormActionBar.tsx +63 -0
- package/src/Form/components/FormActionBar/index.ts +2 -0
- package/src/Form/components/FormBody/FormBody.style.ts +27 -0
- package/src/Form/components/FormBody/FormBody.tsx +62 -0
- package/src/Form/components/FormBody/index.ts +1 -0
- package/src/Form/components/FormCache/FormCache.tsx +50 -0
- package/src/Form/components/FormErrorBanner/FormErrorBanner.test.tsx +124 -0
- package/src/Form/components/FormErrorBanner/FormErrorBanner.tsx +34 -0
- package/src/Form/components/FormErrorBanner/index.ts +1 -0
- package/src/Form/components/FormErrorBanner/messages.ts +14 -0
- package/src/Form/components/FormMask/FormMask.style.tsx +16 -0
- package/src/Form/components/FormMask/FormMask.tsx +19 -0
- package/src/Form/components/FormMask/index.ts +1 -0
- package/src/Form/components/FormMessage/FormMessage.test.tsx +72 -0
- package/src/Form/components/FormMessage/FormMessage.tsx +63 -0
- package/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.style.ts +18 -0
- package/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.tsx +55 -0
- package/src/Form/components/FormMessage/components/InternalFormMessage/index.ts +1 -0
- package/src/Form/components/FormMessage/components/InternalFormMessage/messages.ts +10 -0
- package/src/Form/components/FormMessage/index.ts +1 -0
- package/src/Form/components/FormMessageBanner/FormMessageBanner.test.tsx +27 -0
- package/src/Form/components/FormMessageBanner/FormMessageBanner.tsx +33 -0
- package/src/Form/components/FormMessageBanner/index.ts +1 -0
- package/src/Form/components/FormSaveButton/FormSaveButton.test.tsx +159 -0
- package/src/Form/components/FormSaveButton/FormSaveButton.tsx +103 -0
- package/src/Form/components/FormSaveButton/index.ts +1 -0
- package/src/Form/components/FormSaveButton/messages.ts +9 -0
- package/src/Form/constants.ts +2 -0
- package/src/Form/context/AtlantisFormContext.test.tsx +45 -0
- package/src/Form/context/AtlantisFormContext.tsx +21 -0
- package/src/Form/context/index.ts +5 -0
- package/src/Form/context/types.ts +34 -0
- package/src/Form/hooks/useFormViewRefs.ts +23 -0
- package/src/Form/hooks/useInternalForm.ts +99 -0
- package/src/Form/hooks/useOfflineHandler.ts +36 -0
- package/src/Form/hooks/useSaveButtonPosition.ts +52 -0
- package/src/Form/hooks/useScreenInformation.ts +25 -0
- package/src/Form/hooks/useScrollToError/index.ts +1 -0
- package/src/Form/hooks/useScrollToError/useScrollToError.test.tsx +103 -0
- package/src/Form/hooks/useScrollToError/useScrollToError.ts +102 -0
- package/src/Form/index.ts +13 -0
- package/src/Form/messages.ts +33 -0
- package/src/Form/types.ts +255 -0
- package/src/InputDate/InputDate.test.tsx +295 -0
- package/src/InputDate/InputDate.tsx +231 -0
- package/src/InputDate/index.ts +1 -0
- package/src/InputDate/messages.ts +9 -0
- package/src/InputNumber/InputNumber.tsx +1 -1
- package/src/Menu/Menu.style.ts +16 -0
- package/src/Menu/Menu.test.tsx +201 -0
- package/src/Menu/Menu.tsx +116 -0
- package/src/Menu/components/MenuOption/MenuOption.style.tsx +11 -0
- package/src/Menu/components/MenuOption/MenuOption.tsx +63 -0
- package/src/Menu/components/MenuOption/index.ts +1 -0
- package/src/Menu/components/Overlay/Overlay.style.ts +13 -0
- package/src/Menu/components/Overlay/Overlay.tsx +16 -0
- package/src/Menu/components/Overlay/index.ts +1 -0
- package/src/Menu/index.ts +6 -0
- package/src/Menu/messages.ts +9 -0
- package/src/Menu/types.ts +25 -0
- package/src/Menu/utils.ts +151 -0
- package/src/index.ts +3 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { IconColorNames, IconNames } from "@jobber/design";
|
|
2
|
+
import { TextAlign } from "../Typography";
|
|
3
|
+
|
|
4
|
+
export interface MenuOptionProps {
|
|
5
|
+
readonly label: string;
|
|
6
|
+
readonly icon?: IconNames;
|
|
7
|
+
readonly iconColor?: IconColorNames;
|
|
8
|
+
readonly textAlign?: TextAlign;
|
|
9
|
+
readonly destructive?: boolean;
|
|
10
|
+
readonly textTransform?: "none" | "capitalize";
|
|
11
|
+
onPress: () => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface MenuOptionInternalProps extends MenuOptionProps {
|
|
15
|
+
setOpen: (bool: boolean) => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface MenuProps {
|
|
19
|
+
readonly menuOptions?: MenuOptionProps[];
|
|
20
|
+
readonly customActivator?: JSX.Element;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface OverlayProp {
|
|
24
|
+
setOpen: (bool: boolean) => void;
|
|
25
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { LayoutRectangle } from "react-native";
|
|
2
|
+
import { styles } 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
|
+
): { [key: string]: number | undefined } {
|
|
14
|
+
const { windowHeight, windowWidth, headerHeight } = screenInfo;
|
|
15
|
+
const pos: { [key: string]: number | undefined } = {};
|
|
16
|
+
const menuWidth = styles.menu.width;
|
|
17
|
+
const windowHalf = (windowHeight - headerHeight) / 2 + headerHeight;
|
|
18
|
+
const menuPositionVertical =
|
|
19
|
+
activatorLayout.y + activatorLayout.height > windowHalf
|
|
20
|
+
? "menuAbove"
|
|
21
|
+
: "menuBelow";
|
|
22
|
+
|
|
23
|
+
const menuPositionHorizontal =
|
|
24
|
+
windowWidth / 2 > activatorLayout.width / 2 + activatorLayout.x
|
|
25
|
+
? "menuRight"
|
|
26
|
+
: "menuLeft";
|
|
27
|
+
|
|
28
|
+
const menuPadding = 36;
|
|
29
|
+
|
|
30
|
+
getVerticalPosition(pos, windowHeight, activatorLayout, menuPositionVertical);
|
|
31
|
+
|
|
32
|
+
getHorizontalPosition(
|
|
33
|
+
pos,
|
|
34
|
+
activatorLayout,
|
|
35
|
+
windowWidth,
|
|
36
|
+
menuPadding,
|
|
37
|
+
menuWidth,
|
|
38
|
+
menuPositionHorizontal,
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
return pos;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function getVerticalPosition(
|
|
45
|
+
pos: { [key: string]: number | undefined },
|
|
46
|
+
windowHeight: number,
|
|
47
|
+
activatorLayout: LayoutRectangle,
|
|
48
|
+
menuPositionVertical: string,
|
|
49
|
+
) {
|
|
50
|
+
if (menuPositionVertical === "menuAbove") {
|
|
51
|
+
getAbovePosition(pos, windowHeight, activatorLayout);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (menuPositionVertical === "menuBelow") {
|
|
55
|
+
getBelowPosition(pos, activatorLayout);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function getBelowPosition(
|
|
60
|
+
pos: { [key: string]: number | undefined },
|
|
61
|
+
activatorLayout: LayoutRectangle,
|
|
62
|
+
) {
|
|
63
|
+
pos.top = activatorLayout.y + activatorLayout.height;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function getAbovePosition(
|
|
67
|
+
pos: { [key: string]: number | undefined },
|
|
68
|
+
windowHeight: number,
|
|
69
|
+
activatorLayout: LayoutRectangle,
|
|
70
|
+
) {
|
|
71
|
+
pos.bottom = windowHeight - activatorLayout.y;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function getHorizontalPosition(
|
|
75
|
+
pos: { [key: string]: number | undefined },
|
|
76
|
+
activatorLayout: LayoutRectangle,
|
|
77
|
+
windowWidth: number,
|
|
78
|
+
menuPadding: number,
|
|
79
|
+
menuWidth: number,
|
|
80
|
+
menuPositionHorizontal: string,
|
|
81
|
+
) {
|
|
82
|
+
if (menuPositionHorizontal === "menuRight") {
|
|
83
|
+
getRightPosition(pos, activatorLayout, windowWidth, menuPadding, menuWidth);
|
|
84
|
+
}
|
|
85
|
+
if (menuPositionHorizontal === "menuLeft") {
|
|
86
|
+
getLeftPosition(pos, activatorLayout, windowWidth, menuPadding, menuWidth);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function getLeftPosition(
|
|
91
|
+
pos: { [key: string]: number | undefined },
|
|
92
|
+
activatorLayout: LayoutRectangle,
|
|
93
|
+
windowWidth: number,
|
|
94
|
+
menuHorizontalPadding: number,
|
|
95
|
+
menuWidth: number,
|
|
96
|
+
) {
|
|
97
|
+
const overflowLeft =
|
|
98
|
+
windowWidth -
|
|
99
|
+
activatorLayout.x -
|
|
100
|
+
activatorLayout.width +
|
|
101
|
+
activatorLayout.width / 2 -
|
|
102
|
+
menuHorizontalPadding +
|
|
103
|
+
menuWidth >
|
|
104
|
+
windowWidth;
|
|
105
|
+
|
|
106
|
+
const overflowRight =
|
|
107
|
+
windowWidth -
|
|
108
|
+
activatorLayout.x -
|
|
109
|
+
activatorLayout.width +
|
|
110
|
+
activatorLayout.width / 2 -
|
|
111
|
+
menuHorizontalPadding <
|
|
112
|
+
0;
|
|
113
|
+
|
|
114
|
+
if (overflowLeft) {
|
|
115
|
+
pos.right = undefined;
|
|
116
|
+
pos.left = 0;
|
|
117
|
+
} else if (overflowRight) {
|
|
118
|
+
pos.right = 0;
|
|
119
|
+
} else {
|
|
120
|
+
pos.right =
|
|
121
|
+
windowWidth -
|
|
122
|
+
activatorLayout.x -
|
|
123
|
+
activatorLayout.width +
|
|
124
|
+
activatorLayout.width / 2 -
|
|
125
|
+
menuHorizontalPadding;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function getRightPosition(
|
|
130
|
+
pos: { [key: string]: number | undefined },
|
|
131
|
+
activatorLayout: LayoutRectangle,
|
|
132
|
+
windowWidth: number,
|
|
133
|
+
menuPadding: number,
|
|
134
|
+
menuWidth: number,
|
|
135
|
+
) {
|
|
136
|
+
const overflowRight =
|
|
137
|
+
activatorLayout.x + activatorLayout.width / 2 - menuPadding + menuWidth >
|
|
138
|
+
windowWidth;
|
|
139
|
+
|
|
140
|
+
const overflowLeft =
|
|
141
|
+
activatorLayout.x + activatorLayout.width / 2 - menuPadding < 0;
|
|
142
|
+
|
|
143
|
+
if (overflowRight) {
|
|
144
|
+
pos.left = undefined;
|
|
145
|
+
pos.right = 0;
|
|
146
|
+
} else if (overflowLeft) {
|
|
147
|
+
pos.left = 0;
|
|
148
|
+
} else {
|
|
149
|
+
pos.left = activatorLayout.x + activatorLayout.width / 2 - menuPadding;
|
|
150
|
+
}
|
|
151
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -16,18 +16,21 @@ export * from "./Divider";
|
|
|
16
16
|
export * from "./EmptyState";
|
|
17
17
|
export * from "./ErrorMessageWrapper";
|
|
18
18
|
export * from "./Flex";
|
|
19
|
+
export * from "./Form";
|
|
19
20
|
export * from "./FormField";
|
|
20
21
|
export * from "./Heading";
|
|
21
22
|
export * from "./Icon";
|
|
22
23
|
export * from "./IconButton";
|
|
23
24
|
export * from "./InputFieldWrapper";
|
|
24
25
|
export * from "./InputCurrency";
|
|
26
|
+
export * from "./InputDate";
|
|
25
27
|
export * from "./InputNumber";
|
|
26
28
|
export * from "./InputPassword";
|
|
27
29
|
export * from "./InputPressable";
|
|
28
30
|
export * from "./InputSearch";
|
|
29
31
|
export * from "./InputTime";
|
|
30
32
|
export * from "./InputText";
|
|
33
|
+
export * from "./Menu";
|
|
31
34
|
export * from "./TextList";
|
|
32
35
|
export * from "./ProgressBar";
|
|
33
36
|
export * from "./Select";
|