@jobber/components-native 0.93.0 → 0.95.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/package.json +4 -2
- 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/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/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/InputText/InputText.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/package.json +4 -2
- 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/InputText/InputText.tsx +3 -3
- 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/ThumbnailList/__snapshots__/ThumbnailList.test.tsx.snap +199 -1
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { createRef } from "react";
|
|
2
|
+
import type { RefObject } from "react";
|
|
3
|
+
import { act, renderHook } from "@testing-library/react-native";
|
|
4
|
+
import { BackHandler } from "react-native";
|
|
5
|
+
import type BottomSheet from "@gorhom/bottom-sheet";
|
|
6
|
+
import { useBottomSheetBackHandler } from "./useBottomSheetBackHandler";
|
|
7
|
+
|
|
8
|
+
describe("useBottomSheetBackHandler", () => {
|
|
9
|
+
let mockRemove: jest.Mock;
|
|
10
|
+
let mockAddEventListener: jest.SpyInstance;
|
|
11
|
+
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
mockRemove = jest.fn();
|
|
14
|
+
mockAddEventListener = jest.spyOn(BackHandler, "addEventListener");
|
|
15
|
+
mockAddEventListener.mockReturnValue({ remove: mockRemove });
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
afterEach(() => {
|
|
19
|
+
mockAddEventListener.mockRestore();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("should register BackHandler listener when sheet becomes visible", async () => {
|
|
23
|
+
const bottomSheetRef = createRef<BottomSheet | null>();
|
|
24
|
+
const { result } = renderHook(() =>
|
|
25
|
+
useBottomSheetBackHandler(bottomSheetRef),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
await act(async () => {
|
|
29
|
+
result.current.handleSheetPositionChange(0);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
expect(mockAddEventListener).toHaveBeenCalledWith(
|
|
33
|
+
"hardwareBackPress",
|
|
34
|
+
expect.any(Function),
|
|
35
|
+
);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("should call close() when back button is pressed", async () => {
|
|
39
|
+
const mockClose = jest.fn();
|
|
40
|
+
const bottomSheetRef = {
|
|
41
|
+
current: {
|
|
42
|
+
close: mockClose,
|
|
43
|
+
} as unknown as BottomSheet,
|
|
44
|
+
} as RefObject<BottomSheet | null>;
|
|
45
|
+
|
|
46
|
+
const { result } = renderHook(() =>
|
|
47
|
+
useBottomSheetBackHandler(bottomSheetRef),
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
await act(async () => {
|
|
51
|
+
result.current.handleSheetPositionChange(0);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const registeredCallback = mockAddEventListener.mock.calls[0][1];
|
|
55
|
+
const returnValue = registeredCallback();
|
|
56
|
+
|
|
57
|
+
expect(mockClose).toHaveBeenCalled();
|
|
58
|
+
expect(returnValue).toBe(true);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("should remove listener when sheet is dismissed", async () => {
|
|
62
|
+
const bottomSheetRef = createRef<BottomSheet | null>();
|
|
63
|
+
const { result } = renderHook(() =>
|
|
64
|
+
useBottomSheetBackHandler(bottomSheetRef),
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
await act(async () => {
|
|
68
|
+
result.current.handleSheetPositionChange(0);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
await act(async () => {
|
|
72
|
+
result.current.handleSheetPositionChange(-1);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
expect(mockRemove).toHaveBeenCalled();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("should not register listener when index is negative", async () => {
|
|
79
|
+
const bottomSheetRef = createRef<BottomSheet | null>();
|
|
80
|
+
const { result } = renderHook(() =>
|
|
81
|
+
useBottomSheetBackHandler(bottomSheetRef),
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
await act(async () => {
|
|
85
|
+
result.current.handleSheetPositionChange(-1);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
expect(mockAddEventListener).not.toHaveBeenCalled();
|
|
89
|
+
});
|
|
90
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useCallback, useRef } from "react";
|
|
2
|
+
import { BackHandler, type NativeEventSubscription } from "react-native";
|
|
3
|
+
import type BottomSheet from "@gorhom/bottom-sheet";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Hook that closes the bottom sheet on the hardware back button press if it is visible
|
|
7
|
+
* @param bottomSheetRef ref to the bottom sheet component
|
|
8
|
+
*/
|
|
9
|
+
export function useBottomSheetBackHandler(
|
|
10
|
+
bottomSheetRef: React.RefObject<BottomSheet | null>,
|
|
11
|
+
): {
|
|
12
|
+
handleSheetPositionChange: (index: number) => void;
|
|
13
|
+
} {
|
|
14
|
+
const backHandlerSubscriptionRef = useRef<NativeEventSubscription | null>(
|
|
15
|
+
null,
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
const handleSheetPositionChange = useCallback(
|
|
19
|
+
(index: number) => {
|
|
20
|
+
const isBottomSheetVisible = index >= 0;
|
|
21
|
+
|
|
22
|
+
if (isBottomSheetVisible && !backHandlerSubscriptionRef.current) {
|
|
23
|
+
// Setup the back handler if the bottom sheet is right in front of the user
|
|
24
|
+
backHandlerSubscriptionRef.current = BackHandler.addEventListener(
|
|
25
|
+
"hardwareBackPress",
|
|
26
|
+
() => {
|
|
27
|
+
bottomSheetRef.current?.close();
|
|
28
|
+
|
|
29
|
+
return true;
|
|
30
|
+
},
|
|
31
|
+
);
|
|
32
|
+
} else if (!isBottomSheetVisible) {
|
|
33
|
+
backHandlerSubscriptionRef.current?.remove();
|
|
34
|
+
backHandlerSubscriptionRef.current = null;
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
[bottomSheetRef],
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
return { handleSheetPositionChange };
|
|
41
|
+
}
|
|
@@ -126,7 +126,7 @@ export interface InputTextProps
|
|
|
126
126
|
/**
|
|
127
127
|
* Callback that is called when the text input is blurred
|
|
128
128
|
*/
|
|
129
|
-
readonly onBlur?: () => void;
|
|
129
|
+
readonly onBlur?: (event?: FocusEvent) => void;
|
|
130
130
|
|
|
131
131
|
/**
|
|
132
132
|
* VoiceOver will read this string when a user selects the associated element
|
|
@@ -436,10 +436,10 @@ function InputTextInternal(
|
|
|
436
436
|
setFocused(true);
|
|
437
437
|
onFocus?.(event);
|
|
438
438
|
}}
|
|
439
|
-
onBlur={
|
|
439
|
+
onBlur={event => {
|
|
440
440
|
_name && setFocusedInput("");
|
|
441
441
|
setFocused(false);
|
|
442
|
-
onBlur?.();
|
|
442
|
+
onBlur?.(event);
|
|
443
443
|
field.onBlur();
|
|
444
444
|
trimWhitespace(inputTransform(field.value), updateFormAndState);
|
|
445
445
|
}}
|
|
@@ -65,3 +65,112 @@ describe("with stepped variation", () => {
|
|
|
65
65
|
expect(stepElements).toHaveLength(1);
|
|
66
66
|
});
|
|
67
67
|
});
|
|
68
|
+
|
|
69
|
+
describe("ProgressBar (native) - UNSAFE_style", () => {
|
|
70
|
+
it("applies UNSAFE_style.container to the outer wrapper", () => {
|
|
71
|
+
const containerStyle = { padding: 12, backgroundColor: "papayawhip" };
|
|
72
|
+
render(
|
|
73
|
+
<ProgressBar
|
|
74
|
+
total={100}
|
|
75
|
+
current={40}
|
|
76
|
+
UNSAFE_style={{ container: containerStyle }}
|
|
77
|
+
/>,
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const progressBar = screen.getByRole("progressbar");
|
|
81
|
+
|
|
82
|
+
expect(progressBar.props.style).toEqual(
|
|
83
|
+
expect.objectContaining(containerStyle),
|
|
84
|
+
);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("applies UNSAFE_style.progressBarContainer and track in progress variation", () => {
|
|
88
|
+
const progressBarContainer = { height: 22, borderRadius: 10 };
|
|
89
|
+
const track = { backgroundColor: "#eee" };
|
|
90
|
+
|
|
91
|
+
render(
|
|
92
|
+
<ProgressBar
|
|
93
|
+
total={100}
|
|
94
|
+
current={30}
|
|
95
|
+
UNSAFE_style={{
|
|
96
|
+
progressBarContainer,
|
|
97
|
+
track,
|
|
98
|
+
}}
|
|
99
|
+
/>,
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const progressContainer = screen.getByTestId("progressbar-container");
|
|
103
|
+
|
|
104
|
+
expect(progressContainer.props.style).toEqual(
|
|
105
|
+
expect.arrayContaining([expect.objectContaining(progressBarContainer)]),
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
const trackView = screen.getByTestId("progressbar-track");
|
|
109
|
+
expect(trackView.props.style).toEqual(
|
|
110
|
+
expect.arrayContaining([expect.objectContaining(track)]),
|
|
111
|
+
);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("applies UNSAFE_style.inProgressFill and fill in progress variation", () => {
|
|
115
|
+
const inProgressFill = { backgroundColor: "#f59e0b" };
|
|
116
|
+
const fill = { backgroundColor: "#10b981" };
|
|
117
|
+
|
|
118
|
+
render(
|
|
119
|
+
<ProgressBar
|
|
120
|
+
total={100}
|
|
121
|
+
current={30}
|
|
122
|
+
inProgress={10}
|
|
123
|
+
UNSAFE_style={{
|
|
124
|
+
inProgressFill,
|
|
125
|
+
fill,
|
|
126
|
+
}}
|
|
127
|
+
/>,
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
const inProgressView = screen.getByTestId("progressbar-inprogress");
|
|
131
|
+
const fillView = screen.getByTestId("progressbar-fill");
|
|
132
|
+
|
|
133
|
+
expect(inProgressView.props.style).toEqual(
|
|
134
|
+
expect.arrayContaining([expect.objectContaining(inProgressFill)]),
|
|
135
|
+
);
|
|
136
|
+
expect(fillView.props.style).toEqual(
|
|
137
|
+
expect.arrayContaining([expect.objectContaining(fill)]),
|
|
138
|
+
);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it("applies UNSAFE_style.progressBarContainer and step in stepped variation", () => {
|
|
142
|
+
const progressBarContainer = { height: 12 };
|
|
143
|
+
const step = { backgroundColor: "#d1d5db" };
|
|
144
|
+
|
|
145
|
+
render(
|
|
146
|
+
<ProgressBar
|
|
147
|
+
variation="stepped"
|
|
148
|
+
total={4}
|
|
149
|
+
current={2}
|
|
150
|
+
inProgress={1}
|
|
151
|
+
UNSAFE_style={{ progressBarContainer, step }}
|
|
152
|
+
/>,
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
const steppedContainer = screen.getByTestId("progressbar-container");
|
|
156
|
+
|
|
157
|
+
expect(steppedContainer.props.style).toEqual(
|
|
158
|
+
expect.arrayContaining([expect.objectContaining(progressBarContainer)]),
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
// Steps are rendered with testIDs depending on state; collect all steps by known IDs
|
|
162
|
+
const stepNodes = [
|
|
163
|
+
...screen.getAllByTestId("progress-step-completed"),
|
|
164
|
+
...screen.getAllByTestId("progress-step-in-progress"),
|
|
165
|
+
...screen.getAllByTestId("progress-step-incomplete"),
|
|
166
|
+
];
|
|
167
|
+
|
|
168
|
+
// At least one step should exist and contain the custom style
|
|
169
|
+
expect(stepNodes.length).toBeGreaterThan(0);
|
|
170
|
+
stepNodes.forEach(node => {
|
|
171
|
+
expect(node.props.style).toEqual(
|
|
172
|
+
expect.arrayContaining([expect.objectContaining(step)]),
|
|
173
|
+
);
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
});
|
|
@@ -17,6 +17,7 @@ export function ProgressBar({
|
|
|
17
17
|
header,
|
|
18
18
|
variation = "progress",
|
|
19
19
|
size = "base",
|
|
20
|
+
UNSAFE_style,
|
|
20
21
|
}: ProgressBarProps) {
|
|
21
22
|
const { t } = useAtlantisI18n();
|
|
22
23
|
const styles = useStyles();
|
|
@@ -27,6 +28,7 @@ export function ProgressBar({
|
|
|
27
28
|
accessible
|
|
28
29
|
accessibilityRole="progressbar"
|
|
29
30
|
accessibilityLabel={getA11yLabel()}
|
|
31
|
+
style={UNSAFE_style?.container}
|
|
30
32
|
>
|
|
31
33
|
{header}
|
|
32
34
|
{variation === "stepped" ? (
|
|
@@ -38,31 +40,45 @@ export function ProgressBar({
|
|
|
38
40
|
}
|
|
39
41
|
loading={loading}
|
|
40
42
|
inProgress={inProgress}
|
|
43
|
+
UNSAFE_style={UNSAFE_style}
|
|
41
44
|
/>
|
|
42
45
|
) : (
|
|
43
|
-
<View
|
|
46
|
+
<View
|
|
47
|
+
testID="progressbar-container"
|
|
48
|
+
style={[
|
|
49
|
+
styles.progressBarContainer,
|
|
50
|
+
sizeStyles[size],
|
|
51
|
+
UNSAFE_style?.progressBarContainer,
|
|
52
|
+
]}
|
|
53
|
+
>
|
|
44
54
|
<ProgressBarInner
|
|
55
|
+
testID="progressbar-track"
|
|
45
56
|
width={100}
|
|
46
57
|
animationDuration={0}
|
|
47
58
|
color={
|
|
48
59
|
reverseTheme ? undefined : tokens["color-interactive--background"]
|
|
49
60
|
}
|
|
61
|
+
style={UNSAFE_style?.track}
|
|
50
62
|
/>
|
|
51
63
|
{!loading && (
|
|
52
64
|
<>
|
|
53
65
|
{inProgress && inProgress > 0 ? (
|
|
54
66
|
<ProgressBarInner
|
|
67
|
+
testID="progressbar-inprogress"
|
|
55
68
|
width={calculateWidth(total, current + inProgress)}
|
|
56
69
|
color={tokens["color-informative"]}
|
|
57
70
|
animationDuration={800}
|
|
71
|
+
style={UNSAFE_style?.inProgressFill}
|
|
58
72
|
/>
|
|
59
73
|
) : (
|
|
60
74
|
<></>
|
|
61
75
|
)}
|
|
62
76
|
<ProgressBarInner
|
|
77
|
+
testID="progressbar-fill"
|
|
63
78
|
width={calculateWidth(total, current)}
|
|
64
79
|
color={tokens["color-interactive"]}
|
|
65
80
|
animationDuration={600}
|
|
81
|
+
style={UNSAFE_style?.fill}
|
|
66
82
|
/>
|
|
67
83
|
</>
|
|
68
84
|
)}
|
|
@@ -1,37 +1,34 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
|
-
|
|
4
|
-
// import { useTiming } from "utils/reanimated";
|
|
3
|
+
import type { StyleProp, ViewStyle } from "react-native";
|
|
5
4
|
import { useStyles } from "./ProgressBar.style";
|
|
6
5
|
|
|
7
6
|
interface ProgressBarInnerProps {
|
|
8
7
|
readonly width: number;
|
|
9
8
|
readonly animationDuration?: number;
|
|
10
9
|
readonly color?: string;
|
|
10
|
+
readonly style?: StyleProp<ViewStyle>;
|
|
11
|
+
readonly testID?: string;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export function ProgressBarInner({
|
|
14
15
|
width,
|
|
15
|
-
// animationDuration = 0,
|
|
16
16
|
color,
|
|
17
|
+
style,
|
|
18
|
+
testID,
|
|
17
19
|
}: ProgressBarInnerProps) {
|
|
18
|
-
// Animation breaking on Android
|
|
19
|
-
// const [animatedOpacity] = useTiming({
|
|
20
|
-
// duration: animationDuration,
|
|
21
|
-
// fromValue: 0,
|
|
22
|
-
// toValue: 1,
|
|
23
|
-
// });
|
|
24
20
|
const styles = useStyles();
|
|
25
21
|
|
|
26
22
|
return (
|
|
27
23
|
<View
|
|
24
|
+
testID={testID}
|
|
28
25
|
style={[
|
|
29
26
|
styles.progressBarInner,
|
|
30
27
|
{
|
|
31
28
|
width: `${width}%`,
|
|
32
|
-
// opacity: animatedOpacity,
|
|
33
29
|
...(color && { backgroundColor: color }),
|
|
34
30
|
},
|
|
31
|
+
style,
|
|
35
32
|
]}
|
|
36
33
|
/>
|
|
37
34
|
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
3
|
import { useStyles } from "./ProgressBar.style";
|
|
4
|
+
import type { ProgressBarUnsafeStyle } from "./types";
|
|
4
5
|
|
|
5
6
|
interface ProgressBarSteppedProps {
|
|
6
7
|
readonly total: number;
|
|
@@ -8,6 +9,7 @@ interface ProgressBarSteppedProps {
|
|
|
8
9
|
readonly color?: string;
|
|
9
10
|
readonly loading?: boolean;
|
|
10
11
|
readonly inProgress?: number;
|
|
12
|
+
readonly UNSAFE_style?: ProgressBarUnsafeStyle;
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
export function ProgressBarStepped({
|
|
@@ -16,11 +18,19 @@ export function ProgressBarStepped({
|
|
|
16
18
|
color,
|
|
17
19
|
loading,
|
|
18
20
|
inProgress,
|
|
21
|
+
UNSAFE_style,
|
|
19
22
|
}: ProgressBarSteppedProps) {
|
|
20
23
|
const styles = useStyles();
|
|
21
24
|
|
|
22
25
|
return (
|
|
23
|
-
<View
|
|
26
|
+
<View
|
|
27
|
+
testID="progressbar-container"
|
|
28
|
+
style={[
|
|
29
|
+
styles.progressBarContainer,
|
|
30
|
+
{ height: 10 },
|
|
31
|
+
UNSAFE_style?.progressBarContainer,
|
|
32
|
+
]}
|
|
33
|
+
>
|
|
24
34
|
{Array.from({ length: total }).map((_, index) => {
|
|
25
35
|
const step = index + 1;
|
|
26
36
|
const isCompleted = step <= current;
|
|
@@ -39,6 +49,7 @@ export function ProgressBarStepped({
|
|
|
39
49
|
step <= inProgressSteps &&
|
|
40
50
|
styles.inProgressStep,
|
|
41
51
|
lastStep && { marginRight: 0 },
|
|
52
|
+
UNSAFE_style?.step,
|
|
42
53
|
]}
|
|
43
54
|
testID={
|
|
44
55
|
isCompleted
|
|
@@ -18,8 +18,10 @@ exports[`renders blue inProgress bar when 1 or more jobs is in progress 1`] = `
|
|
|
18
18
|
{
|
|
19
19
|
"height": 16,
|
|
20
20
|
},
|
|
21
|
+
undefined,
|
|
21
22
|
]
|
|
22
23
|
}
|
|
24
|
+
testID="progressbar-container"
|
|
23
25
|
>
|
|
24
26
|
<View
|
|
25
27
|
style={
|
|
@@ -37,8 +39,10 @@ exports[`renders blue inProgress bar when 1 or more jobs is in progress 1`] = `
|
|
|
37
39
|
"backgroundColor": "hsl(51, 17%, 85%)",
|
|
38
40
|
"width": "100%",
|
|
39
41
|
},
|
|
42
|
+
undefined,
|
|
40
43
|
]
|
|
41
44
|
}
|
|
45
|
+
testID="progressbar-track"
|
|
42
46
|
/>
|
|
43
47
|
<View
|
|
44
48
|
style={
|
|
@@ -56,8 +60,10 @@ exports[`renders blue inProgress bar when 1 or more jobs is in progress 1`] = `
|
|
|
56
60
|
"backgroundColor": "hsl(207, 79%, 57%)",
|
|
57
61
|
"width": "0%",
|
|
58
62
|
},
|
|
63
|
+
undefined,
|
|
59
64
|
]
|
|
60
65
|
}
|
|
66
|
+
testID="progressbar-inprogress"
|
|
61
67
|
/>
|
|
62
68
|
<View
|
|
63
69
|
style={
|
|
@@ -75,8 +81,10 @@ exports[`renders blue inProgress bar when 1 or more jobs is in progress 1`] = `
|
|
|
75
81
|
"backgroundColor": "hsl(107, 58%, 33%)",
|
|
76
82
|
"width": "0%",
|
|
77
83
|
},
|
|
84
|
+
undefined,
|
|
78
85
|
]
|
|
79
86
|
}
|
|
87
|
+
testID="progressbar-fill"
|
|
80
88
|
/>
|
|
81
89
|
</View>
|
|
82
90
|
</View>
|
|
@@ -100,8 +108,10 @@ exports[`renders green CompletedProgress bar when 1 or more jobs is completed 1`
|
|
|
100
108
|
{
|
|
101
109
|
"height": 16,
|
|
102
110
|
},
|
|
111
|
+
undefined,
|
|
103
112
|
]
|
|
104
113
|
}
|
|
114
|
+
testID="progressbar-container"
|
|
105
115
|
>
|
|
106
116
|
<View
|
|
107
117
|
style={
|
|
@@ -119,8 +129,10 @@ exports[`renders green CompletedProgress bar when 1 or more jobs is completed 1`
|
|
|
119
129
|
"backgroundColor": "hsl(51, 17%, 85%)",
|
|
120
130
|
"width": "100%",
|
|
121
131
|
},
|
|
132
|
+
undefined,
|
|
122
133
|
]
|
|
123
134
|
}
|
|
135
|
+
testID="progressbar-track"
|
|
124
136
|
/>
|
|
125
137
|
<View
|
|
126
138
|
style={
|
|
@@ -138,8 +150,10 @@ exports[`renders green CompletedProgress bar when 1 or more jobs is completed 1`
|
|
|
138
150
|
"backgroundColor": "hsl(107, 58%, 33%)",
|
|
139
151
|
"width": "50%",
|
|
140
152
|
},
|
|
153
|
+
undefined,
|
|
141
154
|
]
|
|
142
155
|
}
|
|
156
|
+
testID="progressbar-fill"
|
|
143
157
|
/>
|
|
144
158
|
</View>
|
|
145
159
|
</View>
|
package/src/ProgressBar/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
+
import type { StyleProp, ViewStyle } from "react-native";
|
|
2
3
|
|
|
3
4
|
export interface ProgressBarProps {
|
|
4
5
|
/**
|
|
@@ -44,4 +45,25 @@ export interface ProgressBarProps {
|
|
|
44
45
|
* @default base
|
|
45
46
|
*/
|
|
46
47
|
readonly size?: "smaller" | "small" | "base";
|
|
48
|
+
|
|
49
|
+
/** **Use at your own risk:** Custom style for specific elements. This should only be used as a
|
|
50
|
+
* **last resort**. Using this may result in unexpected side effects.
|
|
51
|
+
* More information in the [Customizing components Guide](https://atlantis.getjobber.com/guides/customizing-components).
|
|
52
|
+
*/
|
|
53
|
+
readonly UNSAFE_style?: ProgressBarUnsafeStyle;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface ProgressBarUnsafeStyle {
|
|
57
|
+
/** Styles applied to the outer accessible wrapper (role="progressbar"). */
|
|
58
|
+
container?: StyleProp<ViewStyle>;
|
|
59
|
+
/** Styles applied to the inner bar container (track container) – controls bar height/rounding. */
|
|
60
|
+
progressBarContainer?: StyleProp<ViewStyle>;
|
|
61
|
+
/** Styles applied to each step block in the stepped variation. */
|
|
62
|
+
step?: StyleProp<ViewStyle>;
|
|
63
|
+
/** Track/background bar in 'progress' variation (full-width inner) */
|
|
64
|
+
track?: StyleProp<ViewStyle>;
|
|
65
|
+
/** Filled/completed portion in 'progress' variation */
|
|
66
|
+
fill?: StyleProp<ViewStyle>;
|
|
67
|
+
/** In-progress overlay portion in 'progress' variation */
|
|
68
|
+
inProgressFill?: StyleProp<ViewStyle>;
|
|
47
69
|
}
|