@jobber/components-native 0.84.4-JOB-138679-b1552ab.68 → 0.84.4-match-mobi-accfa8a.9
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/package.json +5 -3
- package/dist/src/BottomSheet/BottomSheet.js +58 -32
- package/dist/src/BottomSheet/BottomSheet.style.js +8 -9
- package/dist/src/BottomSheet/hooks/useBottomSheetBackHandler.js +26 -0
- package/dist/src/Chip/Chip.js +12 -1
- package/dist/src/Chip/Chip.style.js +1 -1
- package/dist/src/Content/ContentHorizontal.style.js +15 -0
- package/dist/src/Content/ContentSpaceAround.style.js +15 -0
- package/dist/src/Content/ContentVertical.style.js +15 -0
- package/dist/src/InputText/InputText.js +2 -2
- package/dist/src/ProgressBar/ProgressBar.js +10 -6
- package/dist/src/ProgressBar/ProgressBarInner.js +3 -12
- package/dist/src/ProgressBar/ProgressBarStepped.js +7 -2
- package/dist/src/StatusIndicator/StatusIndicator.js +11 -0
- package/dist/src/StatusIndicator/StatusIndicator.style.js +12 -0
- package/dist/src/StatusIndicator/StatusIndicator.type.js +1 -0
- package/dist/src/StatusIndicator/index.js +1 -0
- package/dist/src/StatusLabel/StatusLabel.js +6 -12
- package/dist/src/StatusLabel/StatusLabel.style.js +10 -13
- package/dist/src/hooks/useFormController.js +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/utils/meta/meta.json +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/src/BottomSheet/BottomSheet.d.ts +7 -3
- package/dist/types/src/BottomSheet/BottomSheet.style.d.ts +7 -14
- package/dist/types/src/BottomSheet/hooks/useBottomSheetBackHandler.d.ts +8 -0
- package/dist/types/src/Content/Content.d.ts +1 -1
- package/dist/types/src/Content/ContentHorizontal.style.d.ts +15 -0
- package/dist/types/src/Content/ContentSpaceAround.style.d.ts +15 -0
- package/dist/types/src/Content/ContentVertical.style.d.ts +15 -0
- package/dist/types/src/Form/context/types.d.ts +2 -2
- package/dist/types/src/Form/hooks/useInternalForm.d.ts +2 -2
- package/dist/types/src/InputText/InputText.d.ts +1 -1
- package/dist/types/src/Menu/types.d.ts +1 -1
- package/dist/types/src/ProgressBar/ProgressBar.d.ts +1 -1
- package/dist/types/src/ProgressBar/ProgressBarInner.d.ts +4 -1
- package/dist/types/src/ProgressBar/ProgressBarStepped.d.ts +3 -1
- package/dist/types/src/ProgressBar/types.d.ts +20 -0
- package/dist/types/src/StatusIndicator/StatusIndicator.d.ts +6 -0
- package/dist/types/src/StatusIndicator/StatusIndicator.style.d.ts +8 -0
- package/dist/types/src/StatusIndicator/StatusIndicator.type.d.ts +1 -0
- package/dist/types/src/StatusIndicator/index.d.ts +2 -0
- package/dist/types/src/StatusLabel/StatusLabel.d.ts +3 -3
- package/dist/types/src/StatusLabel/StatusLabel.style.d.ts +10 -10
- package/dist/types/src/index.d.ts +1 -0
- package/package.json +5 -3
- package/src/BottomSheet/BottomSheet.stories.tsx +128 -0
- package/src/BottomSheet/BottomSheet.style.ts +7 -14
- package/src/BottomSheet/BottomSheet.test.tsx +19 -24
- package/src/BottomSheet/BottomSheet.tsx +112 -93
- package/src/BottomSheet/hooks/useBottomSheetBackHandler.test.ts +90 -0
- package/src/BottomSheet/hooks/useBottomSheetBackHandler.ts +41 -0
- package/src/Checkbox/Checkbox.test.tsx +118 -1
- package/src/Chip/Chip.style.ts +1 -1
- package/src/Chip/Chip.tsx +19 -1
- package/src/Content/Content.tsx +6 -1
- package/src/Content/ContentHorizontal.style.ts +20 -0
- package/src/Content/ContentSpaceAround.style.ts +20 -0
- package/src/Content/ContentVertical.style.ts +20 -0
- package/src/Form/context/types.ts +2 -2
- package/src/Form/hooks/useInternalForm.ts +2 -2
- package/src/InputText/InputText.test.tsx +115 -1
- package/src/InputText/InputText.tsx +3 -3
- package/src/Menu/types.ts +1 -1
- package/src/ProgressBar/ProgressBar.test.tsx +109 -0
- package/src/ProgressBar/ProgressBar.tsx +17 -1
- package/src/ProgressBar/ProgressBarInner.tsx +7 -10
- package/src/ProgressBar/ProgressBarStepped.tsx +12 -1
- package/src/ProgressBar/__snapshots__/ProgressBar.test.tsx.snap +14 -0
- package/src/ProgressBar/types.ts +22 -0
- package/src/StatusIndicator/StatusIndicator.style.ts +14 -0
- package/src/StatusIndicator/StatusIndicator.test.tsx +42 -0
- package/src/StatusIndicator/StatusIndicator.tsx +23 -0
- package/src/StatusIndicator/StatusIndicator.type.ts +6 -0
- package/src/StatusIndicator/__snapshots__/StatusIndicator.test.tsx.snap +96 -0
- package/src/StatusIndicator/index.ts +2 -0
- package/src/StatusLabel/StatusLabel.style.ts +10 -16
- package/src/StatusLabel/StatusLabel.tsx +15 -28
- package/src/StatusLabel/__snapshots__/StatusLabel.test.tsx.snap +133 -105
- package/src/ThumbnailList/__snapshots__/ThumbnailList.test.tsx.snap +199 -1
- package/src/hooks/useFormController.ts +1 -1
- package/src/index.ts +1 -0
- package/src/utils/meta/meta.json +1 -0
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components-native",
|
|
3
|
-
"version": "0.84.4-
|
|
3
|
+
"version": "0.84.4-match-mobi-accfa8a.9+accfa8aef",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React Native implementation of Atlantis",
|
|
6
6
|
"repository": {
|
|
@@ -53,8 +53,9 @@
|
|
|
53
53
|
"ts-xor": "^1.1.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
+
"@gorhom/bottom-sheet": "^5.2.8",
|
|
56
57
|
"@react-native-community/datetimepicker": "^8.4.5",
|
|
57
|
-
"@react-native/babel-preset": "^0.
|
|
58
|
+
"@react-native/babel-preset": "^0.82.1",
|
|
58
59
|
"@storybook/addon-a11y": "^9.1.2",
|
|
59
60
|
"@storybook/react": "^9.1.2",
|
|
60
61
|
"@storybook/react-native-web-vite": "^9.1.2",
|
|
@@ -78,6 +79,7 @@
|
|
|
78
79
|
},
|
|
79
80
|
"peerDependencies": {
|
|
80
81
|
"@babel/core": "^7.4.5",
|
|
82
|
+
"@gorhom/bottom-sheet": "^5.2.8",
|
|
81
83
|
"@jobber/design": "*",
|
|
82
84
|
"@react-native-community/datetimepicker": ">=6.7.0",
|
|
83
85
|
"date-fns": "^2.30.0",
|
|
@@ -94,5 +96,5 @@
|
|
|
94
96
|
"react-native-safe-area-context": "^5.4.0",
|
|
95
97
|
"react-native-svg": ">=12.0.0"
|
|
96
98
|
},
|
|
97
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "accfa8aefd00ea92526e90f81830b9a8691bdac7"
|
|
98
100
|
}
|
|
@@ -1,52 +1,78 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
1
|
+
import React, { useCallback, useImperativeHandle, useRef } from "react";
|
|
3
2
|
import { Keyboard, View } from "react-native";
|
|
4
|
-
import {
|
|
3
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
4
|
+
import RNBottomSheet, { BottomSheetBackdrop, BottomSheetView, } from "@gorhom/bottom-sheet";
|
|
5
|
+
import { tokens } from "@jobber/design";
|
|
5
6
|
import { useStyles } from "./BottomSheet.style";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
7
|
+
import { BottomSheetOption } from "./components/BottomSheetOption";
|
|
8
|
+
import { useBottomSheetBackHandler } from "./hooks/useBottomSheetBackHandler";
|
|
8
9
|
import { Divider } from "../Divider";
|
|
9
10
|
import { Heading } from "../Heading";
|
|
11
|
+
import { useIsScreenReaderEnabled } from "../hooks";
|
|
10
12
|
import { useAtlantisI18n } from "../hooks/useAtlantisI18n";
|
|
11
|
-
export
|
|
12
|
-
function BottomSheetInternal({ children, showCancel, loading = false, heading, onOpen, onClose, }, ref) {
|
|
13
|
-
const isScreenReaderEnabled = useIsScreenReaderEnabled();
|
|
14
|
-
const [open, setOpen] = useState(false);
|
|
13
|
+
export function BottomSheet({ children, showCancel, loading = false, heading, onOpen, onClose, ref, }) {
|
|
15
14
|
const styles = useStyles();
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
15
|
+
const isScreenReaderEnabled = useIsScreenReaderEnabled();
|
|
16
|
+
const cancellable = (showCancel && !loading) || isScreenReaderEnabled;
|
|
17
|
+
const { t } = useAtlantisI18n();
|
|
18
|
+
const insets = useSafeAreaInsets();
|
|
19
|
+
const previousIndexRef = useRef(-1);
|
|
20
|
+
const bottomSheetRef = useRef(null);
|
|
21
|
+
const { handleSheetPositionChange } = useBottomSheetBackHandler(bottomSheetRef);
|
|
22
|
+
useImperativeHandle(ref, () => ({
|
|
23
|
+
open: () => {
|
|
24
|
+
var _a;
|
|
25
|
+
(_a = bottomSheetRef.current) === null || _a === void 0 ? void 0 : _a.expand();
|
|
26
|
+
},
|
|
27
|
+
close: () => {
|
|
28
|
+
close();
|
|
29
|
+
},
|
|
30
|
+
}));
|
|
31
|
+
const close = useCallback(() => {
|
|
32
|
+
var _a;
|
|
33
|
+
(_a = bottomSheetRef.current) === null || _a === void 0 ? void 0 : _a.close();
|
|
34
|
+
}, []);
|
|
35
|
+
const handleChange = (index) => {
|
|
36
|
+
// Handle Android back button
|
|
37
|
+
handleSheetPositionChange(index);
|
|
38
|
+
const previousIndex = previousIndexRef.current;
|
|
39
|
+
if (previousIndex === -1 && index >= 0) {
|
|
40
|
+
// Transitioned from closed to open
|
|
41
|
+
dismissKeyboard();
|
|
42
|
+
onOpen === null || onOpen === void 0 ? void 0 : onOpen();
|
|
43
|
+
}
|
|
44
|
+
else if (previousIndex >= 0 && index === -1) {
|
|
45
|
+
// Transitioned from open to closed
|
|
46
|
+
dismissKeyboard();
|
|
47
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
48
|
+
}
|
|
49
|
+
previousIndexRef.current = index;
|
|
50
|
+
};
|
|
51
|
+
return (React.createElement(RNBottomSheet, { ref: bottomSheetRef, index: -1, backdropComponent: Backdrop, backgroundStyle: styles.background, enablePanDownToClose: true, onChange: handleChange, keyboardBlurBehavior: "restore", handleStyle: styles.handle },
|
|
52
|
+
React.createElement(BottomSheetView, { style: {
|
|
53
|
+
paddingBottom: insets.bottom + tokens["space-small"],
|
|
54
|
+
paddingTop: tokens["space-small"],
|
|
55
|
+
} },
|
|
56
|
+
heading && React.createElement(Header, { heading: heading, styles: styles }),
|
|
57
|
+
children,
|
|
58
|
+
cancellable && (React.createElement(Footer, { styles: styles, close: close, cancelLabel: t("cancel") })))));
|
|
32
59
|
}
|
|
33
60
|
function Header({ heading, styles, }) {
|
|
34
61
|
return (React.createElement(View, { style: styles.header },
|
|
35
62
|
React.createElement(Heading, { level: "subtitle" }, heading)));
|
|
36
63
|
}
|
|
37
|
-
function Footer({
|
|
38
|
-
|
|
39
|
-
const { t } = useAtlantisI18n();
|
|
40
|
-
return (React.createElement(View, { style: { marginBottom: insets.bottom } }, cancellable && (React.createElement(View, { style: styles.children },
|
|
64
|
+
function Footer({ styles, close, cancelLabel, }) {
|
|
65
|
+
return (React.createElement(View, null,
|
|
41
66
|
React.createElement(View, { style: styles.footerDivider },
|
|
42
67
|
React.createElement(Divider, null)),
|
|
43
|
-
React.createElement(BottomSheetOption, { text:
|
|
68
|
+
React.createElement(BottomSheetOption, { text: cancelLabel, icon: "remove", onPress: close })));
|
|
44
69
|
}
|
|
45
70
|
function dismissKeyboard() {
|
|
46
71
|
//Dismisses the keyboard before opening the bottom sheet.
|
|
47
72
|
//In the case where an input text field is focused we don't want to show the bottom sheet behind or above keyboard
|
|
48
73
|
Keyboard.dismiss();
|
|
49
74
|
}
|
|
50
|
-
function
|
|
51
|
-
|
|
75
|
+
function Backdrop(bottomSheetBackdropProps) {
|
|
76
|
+
const styles = useStyles();
|
|
77
|
+
return (React.createElement(BottomSheetBackdrop, Object.assign({}, bottomSheetBackdropProps, { appearsOnIndex: 0, disappearsOnIndex: -1, style: styles.backdrop, opacity: 1 })));
|
|
52
78
|
}
|
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
import { Dimensions, StyleSheet } from "react-native";
|
|
2
1
|
import { buildThemedStyles } from "../AtlantisThemeContext";
|
|
3
|
-
const { height } = Dimensions.get("window");
|
|
4
2
|
export const useStyles = buildThemedStyles(tokens => {
|
|
5
3
|
const modalBorderRadius = tokens["radius-larger"];
|
|
6
4
|
return {
|
|
7
|
-
|
|
8
|
-
backgroundColor: "
|
|
5
|
+
backdrop: {
|
|
6
|
+
backgroundColor: tokens["color-overlay"],
|
|
9
7
|
},
|
|
10
|
-
|
|
11
|
-
modal: {
|
|
8
|
+
background: {
|
|
12
9
|
borderTopLeftRadius: modalBorderRadius,
|
|
13
10
|
borderTopRightRadius: modalBorderRadius,
|
|
14
|
-
paddingTop: tokens["space-small"],
|
|
15
11
|
},
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
footerContainer: {
|
|
13
|
+
backgroundColor: tokens["color-surface"],
|
|
18
14
|
},
|
|
19
15
|
header: {
|
|
20
16
|
paddingHorizontal: tokens["space-base"],
|
|
@@ -26,5 +22,8 @@ export const useStyles = buildThemedStyles(tokens => {
|
|
|
26
22
|
marginTop: tokens["space-small"],
|
|
27
23
|
marginBottom: tokens["space-smaller"],
|
|
28
24
|
},
|
|
25
|
+
handle: {
|
|
26
|
+
display: "none",
|
|
27
|
+
},
|
|
29
28
|
};
|
|
30
29
|
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useCallback, useRef } from "react";
|
|
2
|
+
import { BackHandler } from "react-native";
|
|
3
|
+
/**
|
|
4
|
+
* Hook that closes the bottom sheet on the hardware back button press if it is visible
|
|
5
|
+
* @param bottomSheetRef ref to the bottom sheet component
|
|
6
|
+
*/
|
|
7
|
+
export function useBottomSheetBackHandler(bottomSheetRef) {
|
|
8
|
+
const backHandlerSubscriptionRef = useRef(null);
|
|
9
|
+
const handleSheetPositionChange = useCallback((index) => {
|
|
10
|
+
var _a;
|
|
11
|
+
const isBottomSheetVisible = index >= 0;
|
|
12
|
+
if (isBottomSheetVisible && !backHandlerSubscriptionRef.current) {
|
|
13
|
+
// Setup the back handler if the bottom sheet is right in front of the user
|
|
14
|
+
backHandlerSubscriptionRef.current = BackHandler.addEventListener("hardwareBackPress", () => {
|
|
15
|
+
var _a;
|
|
16
|
+
(_a = bottomSheetRef.current) === null || _a === void 0 ? void 0 : _a.close();
|
|
17
|
+
return true;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
else if (!isBottomSheetVisible) {
|
|
21
|
+
(_a = backHandlerSubscriptionRef.current) === null || _a === void 0 ? void 0 : _a.remove();
|
|
22
|
+
backHandlerSubscriptionRef.current = null;
|
|
23
|
+
}
|
|
24
|
+
}, [bottomSheetRef]);
|
|
25
|
+
return { handleSheetPositionChange };
|
|
26
|
+
}
|
package/dist/src/Chip/Chip.js
CHANGED
|
@@ -19,6 +19,7 @@ export function Chip({ icon, label, onPress, isDismissible, isActive, inactiveBa
|
|
|
19
19
|
: tokens["color-interactive--background"],
|
|
20
20
|
},
|
|
21
21
|
isActive && { backgroundColor: accentColor },
|
|
22
|
+
getBorderStyle(inactiveBackgroundColor, tokens),
|
|
22
23
|
];
|
|
23
24
|
const dismiss = (isActive || inactiveBackgroundColor === "surface") &&
|
|
24
25
|
styles.activeDismissIcon;
|
|
@@ -27,7 +28,7 @@ export function Chip({ icon, label, onPress, isDismissible, isActive, inactiveBa
|
|
|
27
28
|
iconCustomColor: iconColor,
|
|
28
29
|
dismissColor: dismiss,
|
|
29
30
|
};
|
|
30
|
-
}, [accent, isActive, inactiveBackgroundColor]);
|
|
31
|
+
}, [accent, isActive, inactiveBackgroundColor, getBorderStyle, styles]);
|
|
31
32
|
const accessibilityState = useMemo(() => {
|
|
32
33
|
const checkableRoles = ["radio", "switch", "togglebutton", "checkbox"];
|
|
33
34
|
if (checkableRoles.includes(accessibilityRole)) {
|
|
@@ -43,3 +44,13 @@ export function Chip({ icon, label, onPress, isDismissible, isActive, inactiveBa
|
|
|
43
44
|
isDismissible && (React.createElement(View, { style: [styles.dismissIcon, dismissColor] },
|
|
44
45
|
React.createElement(Icon, { name: "remove", size: "small" })))));
|
|
45
46
|
}
|
|
47
|
+
function getBorderStyle(inactiveBackgroundColor, tokens) {
|
|
48
|
+
let borderColor = "transparent";
|
|
49
|
+
if (inactiveBackgroundColor === "surface") {
|
|
50
|
+
borderColor = tokens["color-border"];
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
borderColor,
|
|
54
|
+
borderWidth: tokens["border-base"],
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -10,7 +10,7 @@ export const useStyles = buildThemedStyles(tokens => {
|
|
|
10
10
|
justifyContent: "center",
|
|
11
11
|
marginHorizontal: tokens["space-smaller"],
|
|
12
12
|
marginTop: tokens["space-small"],
|
|
13
|
-
paddingHorizontal: tokens["space-
|
|
13
|
+
paddingHorizontal: tokens["space-base"],
|
|
14
14
|
},
|
|
15
15
|
iconLeft: {
|
|
16
16
|
marginHorizontal: tokens["space-smallest"],
|
|
@@ -12,6 +12,9 @@ export const useHorizontalStyles = buildThemedStyles(tokens => {
|
|
|
12
12
|
noneChildSpace: {
|
|
13
13
|
padding: 0,
|
|
14
14
|
},
|
|
15
|
+
minusculeChildSpace: {
|
|
16
|
+
paddingLeft: tokens["space-minuscule"],
|
|
17
|
+
},
|
|
15
18
|
smallestChildSpace: {
|
|
16
19
|
paddingLeft: tokens["space-smallest"],
|
|
17
20
|
},
|
|
@@ -21,11 +24,23 @@ export const useHorizontalStyles = buildThemedStyles(tokens => {
|
|
|
21
24
|
smallChildSpace: {
|
|
22
25
|
paddingLeft: tokens["space-small"],
|
|
23
26
|
},
|
|
27
|
+
slimChildSpace: {
|
|
28
|
+
paddingLeft: tokens["space-slim"],
|
|
29
|
+
},
|
|
24
30
|
baseChildSpace: {
|
|
25
31
|
paddingLeft: tokens["space-base"],
|
|
26
32
|
},
|
|
27
33
|
largeChildSpace: {
|
|
28
34
|
paddingLeft: tokens["space-large"],
|
|
29
35
|
},
|
|
36
|
+
largerChildSpace: {
|
|
37
|
+
paddingLeft: tokens["space-larger"],
|
|
38
|
+
},
|
|
39
|
+
largestChildSpace: {
|
|
40
|
+
paddingLeft: tokens["space-largest"],
|
|
41
|
+
},
|
|
42
|
+
extravagantChildSpace: {
|
|
43
|
+
paddingLeft: tokens["space-extravagant"],
|
|
44
|
+
},
|
|
30
45
|
};
|
|
31
46
|
});
|
|
@@ -4,6 +4,9 @@ export const useSpaceAroundStyles = buildThemedStyles(tokens => {
|
|
|
4
4
|
noneSpace: {
|
|
5
5
|
padding: 0,
|
|
6
6
|
},
|
|
7
|
+
minusculeSpace: {
|
|
8
|
+
padding: tokens["space-minuscule"],
|
|
9
|
+
},
|
|
7
10
|
smallestSpace: {
|
|
8
11
|
padding: tokens["space-smallest"],
|
|
9
12
|
},
|
|
@@ -13,11 +16,23 @@ export const useSpaceAroundStyles = buildThemedStyles(tokens => {
|
|
|
13
16
|
smallSpace: {
|
|
14
17
|
padding: tokens["space-small"],
|
|
15
18
|
},
|
|
19
|
+
slimSpace: {
|
|
20
|
+
padding: tokens["space-slim"],
|
|
21
|
+
},
|
|
16
22
|
baseSpace: {
|
|
17
23
|
padding: tokens["space-base"],
|
|
18
24
|
},
|
|
19
25
|
largeSpace: {
|
|
20
26
|
padding: tokens["space-large"],
|
|
21
27
|
},
|
|
28
|
+
largerSpace: {
|
|
29
|
+
padding: tokens["space-larger"],
|
|
30
|
+
},
|
|
31
|
+
largestSpace: {
|
|
32
|
+
padding: tokens["space-largest"],
|
|
33
|
+
},
|
|
34
|
+
extravagantSpace: {
|
|
35
|
+
padding: tokens["space-extravagant"],
|
|
36
|
+
},
|
|
22
37
|
};
|
|
23
38
|
});
|
|
@@ -12,6 +12,9 @@ export const useVerticalStyles = buildThemedStyles(tokens => {
|
|
|
12
12
|
noneChildSpace: {
|
|
13
13
|
padding: 0,
|
|
14
14
|
},
|
|
15
|
+
minusculeChildSpace: {
|
|
16
|
+
paddingTop: tokens["space-minuscule"],
|
|
17
|
+
},
|
|
15
18
|
smallestChildSpace: {
|
|
16
19
|
paddingTop: tokens["space-smallest"],
|
|
17
20
|
},
|
|
@@ -21,11 +24,23 @@ export const useVerticalStyles = buildThemedStyles(tokens => {
|
|
|
21
24
|
smallChildSpace: {
|
|
22
25
|
paddingTop: tokens["space-small"],
|
|
23
26
|
},
|
|
27
|
+
slimChildSpace: {
|
|
28
|
+
paddingTop: tokens["space-slim"],
|
|
29
|
+
},
|
|
24
30
|
baseChildSpace: {
|
|
25
31
|
paddingTop: tokens["space-base"],
|
|
26
32
|
},
|
|
27
33
|
largeChildSpace: {
|
|
28
34
|
paddingTop: tokens["space-large"],
|
|
29
35
|
},
|
|
36
|
+
largerChildSpace: {
|
|
37
|
+
paddingTop: tokens["space-larger"],
|
|
38
|
+
},
|
|
39
|
+
largestChildSpace: {
|
|
40
|
+
paddingTop: tokens["space-largest"],
|
|
41
|
+
},
|
|
42
|
+
extravagantChildSpace: {
|
|
43
|
+
paddingTop: tokens["space-extravagant"],
|
|
44
|
+
},
|
|
30
45
|
};
|
|
31
46
|
});
|
|
@@ -93,10 +93,10 @@ function InputTextInternal({ invalid, disabled, readonly = false, name, placehol
|
|
|
93
93
|
_name && setFocusedInput(_name);
|
|
94
94
|
setFocused(true);
|
|
95
95
|
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
96
|
-
}, onBlur:
|
|
96
|
+
}, onBlur: event => {
|
|
97
97
|
_name && setFocusedInput("");
|
|
98
98
|
setFocused(false);
|
|
99
|
-
onBlur === null || onBlur === void 0 ? void 0 : onBlur();
|
|
99
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
100
100
|
field.onBlur();
|
|
101
101
|
trimWhitespace(inputTransform(field.value), updateFormAndState);
|
|
102
102
|
}, ref: (instance) => {
|
|
@@ -6,17 +6,21 @@ import { ProgressBarStepped } from "./ProgressBarStepped";
|
|
|
6
6
|
import { sizeStyles } from "./ProgressBar.size.style";
|
|
7
7
|
import { useAtlantisI18n } from "../hooks/useAtlantisI18n";
|
|
8
8
|
import { useAtlantisTheme } from "../AtlantisThemeContext";
|
|
9
|
-
export function ProgressBar({ loading, total, current, inProgress = 0, reverseTheme = false, header, variation = "progress", size = "base", }) {
|
|
9
|
+
export function ProgressBar({ loading, total, current, inProgress = 0, reverseTheme = false, header, variation = "progress", size = "base", UNSAFE_style, }) {
|
|
10
10
|
const { t } = useAtlantisI18n();
|
|
11
11
|
const styles = useStyles();
|
|
12
12
|
const { tokens } = useAtlantisTheme();
|
|
13
|
-
return (React.createElement(View, { accessible: true, accessibilityRole: "progressbar", accessibilityLabel: getA11yLabel() },
|
|
13
|
+
return (React.createElement(View, { accessible: true, accessibilityRole: "progressbar", accessibilityLabel: getA11yLabel(), style: UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.container },
|
|
14
14
|
header,
|
|
15
|
-
variation === "stepped" ? (React.createElement(ProgressBarStepped, { total: total, current: current, color: reverseTheme ? undefined : tokens["color-interactive--background"], loading: loading, inProgress: inProgress })) : (React.createElement(View, {
|
|
16
|
-
|
|
15
|
+
variation === "stepped" ? (React.createElement(ProgressBarStepped, { total: total, current: current, color: reverseTheme ? undefined : tokens["color-interactive--background"], loading: loading, inProgress: inProgress, UNSAFE_style: UNSAFE_style })) : (React.createElement(View, { testID: "progressbar-container", style: [
|
|
16
|
+
styles.progressBarContainer,
|
|
17
|
+
sizeStyles[size],
|
|
18
|
+
UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.progressBarContainer,
|
|
19
|
+
] },
|
|
20
|
+
React.createElement(ProgressBarInner, { testID: "progressbar-track", width: 100, animationDuration: 0, color: reverseTheme ? undefined : tokens["color-interactive--background"], style: UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.track }),
|
|
17
21
|
!loading && (React.createElement(React.Fragment, null,
|
|
18
|
-
inProgress && inProgress > 0 ? (React.createElement(ProgressBarInner, { width: calculateWidth(total, current + inProgress), color: tokens["color-informative"], animationDuration: 800 })) : (React.createElement(React.Fragment, null)),
|
|
19
|
-
React.createElement(ProgressBarInner, { width: calculateWidth(total, current), color: tokens["color-interactive"], animationDuration: 600 })))))));
|
|
22
|
+
inProgress && inProgress > 0 ? (React.createElement(ProgressBarInner, { testID: "progressbar-inprogress", width: calculateWidth(total, current + inProgress), color: tokens["color-informative"], animationDuration: 800, style: UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.inProgressFill })) : (React.createElement(React.Fragment, null)),
|
|
23
|
+
React.createElement(ProgressBarInner, { testID: "progressbar-fill", width: calculateWidth(total, current), color: tokens["color-interactive"], animationDuration: 600, style: UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.fill })))))));
|
|
20
24
|
function getA11yLabel() {
|
|
21
25
|
const a11yLabelValues = {
|
|
22
26
|
current: String(current),
|
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
|
-
// import Reanimated from "react-native-reanimated";
|
|
4
|
-
// import { useTiming } from "utils/reanimated";
|
|
5
3
|
import { useStyles } from "./ProgressBar.style";
|
|
6
|
-
export function ProgressBarInner({ width,
|
|
7
|
-
// animationDuration = 0,
|
|
8
|
-
color, }) {
|
|
9
|
-
// Animation breaking on Android
|
|
10
|
-
// const [animatedOpacity] = useTiming({
|
|
11
|
-
// duration: animationDuration,
|
|
12
|
-
// fromValue: 0,
|
|
13
|
-
// toValue: 1,
|
|
14
|
-
// });
|
|
4
|
+
export function ProgressBarInner({ width, color, style, testID, }) {
|
|
15
5
|
const styles = useStyles();
|
|
16
|
-
return (React.createElement(View, { style: [
|
|
6
|
+
return (React.createElement(View, { testID: testID, style: [
|
|
17
7
|
styles.progressBarInner,
|
|
18
8
|
Object.assign({ width: `${width}%` }, (color && { backgroundColor: color })),
|
|
9
|
+
style,
|
|
19
10
|
] }));
|
|
20
11
|
}
|
|
21
12
|
export function calculateWidth(total, current) {
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
3
|
import { useStyles } from "./ProgressBar.style";
|
|
4
|
-
export function ProgressBarStepped({ total, current, color, loading, inProgress, }) {
|
|
4
|
+
export function ProgressBarStepped({ total, current, color, loading, inProgress, UNSAFE_style, }) {
|
|
5
5
|
const styles = useStyles();
|
|
6
|
-
return (React.createElement(View, {
|
|
6
|
+
return (React.createElement(View, { testID: "progressbar-container", style: [
|
|
7
|
+
styles.progressBarContainer,
|
|
8
|
+
{ height: 10 },
|
|
9
|
+
UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.progressBarContainer,
|
|
10
|
+
] }, Array.from({ length: total }).map((_, index) => {
|
|
7
11
|
const step = index + 1;
|
|
8
12
|
const isCompleted = step <= current;
|
|
9
13
|
const lastStep = step === total;
|
|
@@ -17,6 +21,7 @@ export function ProgressBarStepped({ total, current, color, loading, inProgress,
|
|
|
17
21
|
step <= inProgressSteps &&
|
|
18
22
|
styles.inProgressStep,
|
|
19
23
|
lastStep && { marginRight: 0 },
|
|
24
|
+
UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.step,
|
|
20
25
|
], testID: isCompleted
|
|
21
26
|
? "progress-step-completed"
|
|
22
27
|
: step <= inProgressSteps
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import { useStyles } from "./StatusIndicator.style";
|
|
4
|
+
import { tokens } from "../utils/design";
|
|
5
|
+
export function StatusIndicator({ status }) {
|
|
6
|
+
const styles = useStyles();
|
|
7
|
+
return (React.createElement(View, { testID: `${status}Indicator`, style: [
|
|
8
|
+
styles.statusIndicator,
|
|
9
|
+
{ backgroundColor: tokens[`color-${status}`] },
|
|
10
|
+
] }));
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { buildThemedStyles } from "../AtlantisThemeContext";
|
|
2
|
+
export const useStyles = buildThemedStyles(tokens => {
|
|
3
|
+
const statusIndicatorDiameter = 8;
|
|
4
|
+
return {
|
|
5
|
+
statusIndicator: {
|
|
6
|
+
borderRadius: tokens["radius-circle"],
|
|
7
|
+
backgroundColor: tokens["color-success"],
|
|
8
|
+
width: statusIndicatorDiameter,
|
|
9
|
+
height: statusIndicatorDiameter,
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { StatusIndicator } from "./StatusIndicator";
|
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
3
|
import { useStyles } from "./StatusLabel.style";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { Typography } from "../Typography";
|
|
5
|
+
import { StatusIndicator } from "../StatusIndicator";
|
|
6
|
+
import { tokens } from "../utils/design";
|
|
6
7
|
export function StatusLabel({ text, alignment = "end", status = "success", }) {
|
|
7
8
|
const styles = useStyles();
|
|
8
9
|
return (React.createElement(View, { style: [
|
|
9
10
|
styles.statusLabelRow,
|
|
11
|
+
{ backgroundColor: tokens[`color-${status}--surface`] },
|
|
10
12
|
alignment === "start" && styles.labelTextStartAligned,
|
|
11
13
|
] },
|
|
12
14
|
React.createElement(View, { style: styles.statusLabelText },
|
|
13
|
-
React.createElement(
|
|
14
|
-
React.createElement(
|
|
15
|
-
React.createElement(StatusLabelIcon, { status: status, styles: styles })));
|
|
16
|
-
}
|
|
17
|
-
function StatusLabelIcon({ status, styles }) {
|
|
18
|
-
const { tokens } = useAtlantisTheme();
|
|
19
|
-
return (React.createElement(View, { testID: `${status}LabelIcon`, style: [
|
|
20
|
-
styles.statusLabelIcon,
|
|
21
|
-
{ backgroundColor: tokens[`color-${status}`] },
|
|
22
|
-
] }));
|
|
15
|
+
React.createElement(Typography, { align: alignment, size: "smaller", fontWeight: "medium", color: `${status}OnSurface` }, text)),
|
|
16
|
+
React.createElement(StatusIndicator, { status: status })));
|
|
23
17
|
}
|
|
@@ -1,29 +1,26 @@
|
|
|
1
1
|
import { buildThemedStyles } from "../AtlantisThemeContext";
|
|
2
|
-
const statusLabelRadius = 3; // Needs to be hardcoded to 3 as this shouldn't change with the tokens
|
|
3
2
|
export const useStyles = buildThemedStyles(tokens => {
|
|
4
|
-
const statusLabelIconDiameter = tokens["space-base"] - tokens["space-smaller"]; //12px
|
|
5
|
-
const indicatorOffset = tokens["space-smallest"] + tokens["space-minuscule"];
|
|
6
3
|
return {
|
|
7
4
|
statusLabelRow: {
|
|
8
5
|
flexDirection: "row",
|
|
9
6
|
justifyContent: "flex-end",
|
|
7
|
+
alignItems: "center",
|
|
8
|
+
alignSelf: "flex-start",
|
|
10
9
|
flexWrap: "nowrap",
|
|
10
|
+
flexGrow: 0,
|
|
11
|
+
flexShrink: 1,
|
|
12
|
+
gap: tokens["space-smaller"],
|
|
13
|
+
backgroundColor: tokens["color-success--surface"],
|
|
14
|
+
borderRadius: tokens["radius-large"],
|
|
15
|
+
paddingVertical: tokens["space-smaller"],
|
|
16
|
+
paddingHorizontal: tokens["space-small"],
|
|
11
17
|
},
|
|
12
18
|
statusLabelText: {
|
|
13
19
|
flexShrink: 1,
|
|
14
|
-
|
|
15
|
-
statusLabelIcon: {
|
|
16
|
-
borderRadius: statusLabelRadius,
|
|
17
|
-
backgroundColor: tokens["color-success"],
|
|
18
|
-
width: statusLabelIconDiameter,
|
|
19
|
-
height: statusLabelIconDiameter,
|
|
20
|
-
marginTop: indicatorOffset,
|
|
20
|
+
marginBottom: -1,
|
|
21
21
|
},
|
|
22
22
|
labelTextStartAligned: {
|
|
23
23
|
flexDirection: "row-reverse",
|
|
24
24
|
},
|
|
25
|
-
innerPad: {
|
|
26
|
-
width: tokens["space-small"],
|
|
27
|
-
},
|
|
28
25
|
};
|
|
29
26
|
});
|
|
@@ -13,7 +13,7 @@ export function useFormController({ name, value, validations, }) {
|
|
|
13
13
|
name: fieldName,
|
|
14
14
|
control,
|
|
15
15
|
rules: validations,
|
|
16
|
-
defaultValue: value || undefined,
|
|
16
|
+
defaultValue: typeof value === "boolean" ? value : value || undefined,
|
|
17
17
|
});
|
|
18
18
|
// The naming convention established by react-hook-form for arrays of fields is, for example, "emails.0.description".
|
|
19
19
|
// Preserve original behavior: only treat three-part names as nested paths.
|
package/dist/src/index.js
CHANGED