@jobber/components-native 0.43.18-quick-use-.13 → 0.44.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/README.md +40 -0
- package/dist/src/Banner/Banner.js +19 -4
- package/dist/src/Banner/Banner.style.js +16 -0
- package/dist/src/Banner/components/BannerIcon/BannerIcon.js +9 -0
- package/dist/src/Form/components/FormActionBar/FormActionBar.js +2 -2
- package/dist/src/Form/hooks/useScrollToError/useScrollToError.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/Banner/Banner.d.ts +1 -1
- package/dist/types/src/Banner/Banner.style.d.ts +16 -0
- package/dist/types/src/Banner/components/BannerIcon/BannerIcon.d.ts +6 -0
- package/dist/types/src/Banner/types.d.ts +13 -6
- package/jestSetup.js +35 -0
- package/package.json +13 -7
- package/src/Banner/Banner.style.ts +16 -0
- package/src/Banner/Banner.tsx +33 -4
- package/src/Banner/components/BannerIcon/BannerIcon.tsx +17 -0
- package/src/Banner/types.ts +14 -6
- package/src/Form/components/FormActionBar/FormActionBar.tsx +2 -2
- package/src/Form/hooks/useScrollToError/useScrollToError.ts +1 -1
package/README.md
CHANGED
|
@@ -46,6 +46,46 @@ transformIgnorePatterns: [
|
|
|
46
46
|
],
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
+
Also update the Jest config as to include the `jestSetup.js`
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
setupFiles: [
|
|
53
|
+
...
|
|
54
|
+
"./node_modules/@jobber/components-native/jestSetup.js",
|
|
55
|
+
...
|
|
56
|
+
],
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
You will also need to create a mock for the Form component
|
|
60
|
+
|
|
61
|
+
```jsx
|
|
62
|
+
jest.mock("./dist/src/Form", () => {
|
|
63
|
+
const { Form, AtlantisFormContext, ...Actual } =
|
|
64
|
+
jest.requireActual("./dist/src/Form");
|
|
65
|
+
const useConfirmBeforeBack = jest.fn(() => jest.fn());
|
|
66
|
+
const useInternalFormLocalCache = jest.fn(() => ({
|
|
67
|
+
setLocalCache: jest.fn(),
|
|
68
|
+
removeLocalCache: jest.fn(),
|
|
69
|
+
}));
|
|
70
|
+
// Or
|
|
71
|
+
const useConfirmBeforeBack = require("<path-to-your>/useConfirmBeforeBackHook");
|
|
72
|
+
const useInternalFormLocalCache = require("<path-to-your>/useInternalFormLocalCacheHook");
|
|
73
|
+
return {
|
|
74
|
+
...Actual,
|
|
75
|
+
AtlantisFormContext: AtlantisFormContext,
|
|
76
|
+
Form: ({ children, ...props }) => {
|
|
77
|
+
return (
|
|
78
|
+
<AtlantisFormContext.Provider
|
|
79
|
+
value={{ useConfirmBeforeBack, useInternalFormLocalCache }}
|
|
80
|
+
>
|
|
81
|
+
<Form {...props}>{children}</Form>
|
|
82
|
+
</AtlantisFormContext.Provider>
|
|
83
|
+
);
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
49
89
|
## Further Reading
|
|
50
90
|
|
|
51
91
|
More information on Atlantis can be found at
|
|
@@ -1,15 +1,30 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Pressable } from "react-native";
|
|
2
|
+
import { Pressable, View } from "react-native";
|
|
3
3
|
import { BannerTypeStyles } from "./constants";
|
|
4
4
|
import { styles } from "./Banner.style";
|
|
5
|
+
import { BannerIcon } from "./components/BannerIcon/BannerIcon";
|
|
5
6
|
import { Content } from "../Content";
|
|
6
7
|
import { Text } from "../Text";
|
|
7
8
|
import { TextList } from "../TextList";
|
|
8
9
|
import { ActionLabel } from "../ActionLabel";
|
|
9
|
-
export function Banner({ action, details, text, type, }) {
|
|
10
|
+
export function Banner({ action, details, text, type, children, icon, }) {
|
|
10
11
|
return (React.createElement(Pressable, { style: [styles.container, BannerTypeStyles[type].styles], accessibilityRole: "alert", onPress: action === null || action === void 0 ? void 0 : action.onPress },
|
|
11
12
|
React.createElement(Content, { childSpacing: "small" },
|
|
12
|
-
React.createElement(
|
|
13
|
-
|
|
13
|
+
React.createElement(View, { style: styles.bannerContent },
|
|
14
|
+
icon && React.createElement(BannerIcon, { icon: icon }),
|
|
15
|
+
React.createElement(View, { style: styles.contentContainer },
|
|
16
|
+
React.createElement(View, { style: styles.childrenContainer },
|
|
17
|
+
React.createElement(BannerChildren, null, children)),
|
|
18
|
+
text && (React.createElement(View, { style: styles.textContainer },
|
|
19
|
+
React.createElement(Text, { level: "textSupporting" }, text))),
|
|
20
|
+
details && React.createElement(TextList, { items: details, level: "textSupporting" }))),
|
|
14
21
|
action && React.createElement(ActionLabel, { align: "start" }, action.label))));
|
|
15
22
|
}
|
|
23
|
+
function BannerChildren({ children, }) {
|
|
24
|
+
if (!children)
|
|
25
|
+
return React.createElement(React.Fragment, null);
|
|
26
|
+
if (children && typeof children === "string") {
|
|
27
|
+
return React.createElement(Text, { level: "textSupporting" }, children);
|
|
28
|
+
}
|
|
29
|
+
return React.createElement(React.Fragment, null, children);
|
|
30
|
+
}
|
|
@@ -13,4 +13,20 @@ export const styles = StyleSheet.create({
|
|
|
13
13
|
notice: {
|
|
14
14
|
backgroundColor: tokens["color-informative--surface"],
|
|
15
15
|
},
|
|
16
|
+
bannerContent: {
|
|
17
|
+
flexDirection: "row",
|
|
18
|
+
alignItems: "flex-start",
|
|
19
|
+
},
|
|
20
|
+
contentContainer: {
|
|
21
|
+
flex: 1,
|
|
22
|
+
},
|
|
23
|
+
childrenContainer: {
|
|
24
|
+
marginTop: tokens["space-smallest"],
|
|
25
|
+
},
|
|
26
|
+
textContainer: {
|
|
27
|
+
marginTop: tokens["space-minuscule"],
|
|
28
|
+
},
|
|
29
|
+
bannerIcon: {
|
|
30
|
+
paddingRight: tokens["space-small"],
|
|
31
|
+
},
|
|
16
32
|
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { tokens } from "@jobber/design";
|
|
3
|
+
import { View } from "react-native";
|
|
4
|
+
import { Icon } from "../../../Icon";
|
|
5
|
+
import { styles } from "../../Banner.style";
|
|
6
|
+
export function BannerIcon({ icon }) {
|
|
7
|
+
return (React.createElement(View, { style: styles.bannerIcon },
|
|
8
|
+
React.createElement(Icon, { name: icon, customColor: tokens["color-text"] })));
|
|
9
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { StyleSheet
|
|
2
|
+
import { StyleSheet } from "react-native";
|
|
3
3
|
import Reanimated from "react-native-reanimated";
|
|
4
4
|
import { styles } from "./FormActionBar.style";
|
|
5
5
|
import { FormSaveButton } from "../FormSaveButton";
|
|
6
|
-
const ReanimatedView = Reanimated.
|
|
6
|
+
const ReanimatedView = Reanimated.View;
|
|
7
7
|
export function FormActionBar({ keyboardHeight, submit, isFormSubmitting, saveButtonLabel, renderStickySection, setSaveButtonHeight, secondaryActions, setSecondaryActionLoading, }) {
|
|
8
8
|
const buttonStyle = StyleSheet.flatten([
|
|
9
9
|
styles.saveButton,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useState } from "react";
|
|
2
2
|
import { Keyboard, Platform, } from "react-native";
|
|
3
|
-
import { useIsScreenReaderEnabled } from "../../../hooks
|
|
3
|
+
import { useIsScreenReaderEnabled } from "../../../hooks";
|
|
4
4
|
import { useErrorMessageContext } from "../../../ErrorMessageWrapper";
|
|
5
5
|
export function useScrollToError({ formState: { errors, isValid, submitCount }, refNode, setFocus, scrollToPosition, }) {
|
|
6
6
|
const [submitCounter, setSubmitCounter] = useState(submitCount);
|