@jobber/components-native 0.115.5 → 0.116.1
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 -4
- package/dist/src/ActivityIndicator/ActivityIndicator.test.js +3 -3
- package/dist/src/ContentOverlay/ContentOverlay.test.js +0 -1
- package/dist/src/Select/SelectRoot.test.js +35 -1
- package/dist/src/Select/components/SelectTrigger.js +6 -3
- package/dist/src/Select/components/SelectTrigger.style.js +5 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/src/Select/components/SelectTrigger.style.d.ts +4 -0
- package/package.json +5 -4
- package/src/ActivityIndicator/ActivityIndicator.test.tsx +7 -3
- package/src/ActivityIndicator/guide.md +1 -1
- package/src/ContentOverlay/BottomSheetKeyboardAwareScrollView.tsx +3 -4
- package/src/ContentOverlay/ContentOverlay.test.tsx +0 -1
- package/src/Select/Select.guide.md +6 -0
- package/src/Select/SelectRoot.test.tsx +44 -1
- package/src/Select/components/SelectTrigger.style.ts +6 -0
- package/src/Select/components/SelectTrigger.tsx +14 -4
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.116.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React Native implementation of Atlantis",
|
|
6
6
|
"repository": {
|
|
@@ -96,11 +96,12 @@
|
|
|
96
96
|
"react-native-gesture-handler": "^2.29.1",
|
|
97
97
|
"react-native-keyboard-controller": "^1.12.0",
|
|
98
98
|
"react-native-modal-datetime-picker": "^18.0.0",
|
|
99
|
-
"react-native-reanimated": "
|
|
99
|
+
"react-native-reanimated": "4.2.3",
|
|
100
100
|
"react-native-safe-area-context": "^5.4.0",
|
|
101
101
|
"react-native-screens": "^4.18.0",
|
|
102
102
|
"react-native-svg": "^15.1.0",
|
|
103
103
|
"react-native-web": "^0.20.0",
|
|
104
|
+
"react-native-worklets": "0.7.4",
|
|
104
105
|
"react-test-renderer": "19.1.1",
|
|
105
106
|
"storybook": "10.3.5",
|
|
106
107
|
"vite": "^8.0.9"
|
|
@@ -119,10 +120,10 @@
|
|
|
119
120
|
"react-native-gesture-handler": ">=2.22.0",
|
|
120
121
|
"react-native-keyboard-controller": "^1.20.7",
|
|
121
122
|
"react-native-modal-datetime-picker": " >=13.0.0",
|
|
122
|
-
"react-native-reanimated": "^
|
|
123
|
+
"react-native-reanimated": "^4.0.0",
|
|
123
124
|
"react-native-safe-area-context": "^5.4.0",
|
|
124
125
|
"react-native-screens": ">=4.18.0",
|
|
125
126
|
"react-native-svg": ">=12.0.0"
|
|
126
127
|
},
|
|
127
|
-
"gitHead": "
|
|
128
|
+
"gitHead": "d324e138d0e3c27cf0e54dac5d40b2c2d7e9ab82"
|
|
128
129
|
}
|
|
@@ -3,9 +3,9 @@ import { AccessibilityInfo } from "react-native";
|
|
|
3
3
|
import { render } from "@testing-library/react-native";
|
|
4
4
|
import { useReducedMotion } from "react-native-reanimated";
|
|
5
5
|
import { ActivityIndicator } from "./index";
|
|
6
|
-
// `useReducedMotion`
|
|
7
|
-
//
|
|
8
|
-
|
|
6
|
+
// Reanimated's `useReducedMotion` reads the OS setting once at module load,
|
|
7
|
+
// so it is mocked to let tests toggle the reduced-motion branch.
|
|
8
|
+
jest.mock("react-native-reanimated", () => (Object.assign(Object.assign({ __esModule: true }, jest.requireActual("react-native-reanimated")), { useReducedMotion: jest.fn(() => false) })));
|
|
9
9
|
const testId = "ActivityIndicator";
|
|
10
10
|
describe("ActivityIndicator", () => {
|
|
11
11
|
beforeEach(() => {
|
|
@@ -17,7 +17,6 @@ import { Button } from "../Button";
|
|
|
17
17
|
import { Content } from "../Content";
|
|
18
18
|
import { Text } from "../Text";
|
|
19
19
|
jest.unmock("../hooks/useIsScreenReaderEnabled");
|
|
20
|
-
jest.unmock("react-native-reanimated");
|
|
21
20
|
jest.unmock("@gorhom/bottom-sheet");
|
|
22
21
|
jest.mock("@gorhom/bottom-sheet/lib/commonjs/hooks/useAnimatedLayout", () => ({
|
|
23
22
|
// Fix for reanimated not actually running in the test environment.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { Pressable, StyleSheet } from "react-native";
|
|
2
3
|
import { fireEvent, render, screen, within, } from "@testing-library/react-native";
|
|
3
|
-
import { Pressable } from "react-native";
|
|
4
4
|
import { SelectRoot } from "./SelectRoot";
|
|
5
5
|
import { SelectTrigger } from "./components/SelectTrigger";
|
|
6
6
|
import { SelectLabel } from "./components/SelectLabel";
|
|
@@ -117,10 +117,44 @@ describe("SelectRoot label placement", () => {
|
|
|
117
117
|
React.createElement(SelectTrigger, null,
|
|
118
118
|
React.createElement(SelectPrimitive.Value, { placeholder: "Select an option" }))));
|
|
119
119
|
}
|
|
120
|
+
function getTriggerContent() {
|
|
121
|
+
const trigger = screen.getByTestId("ATL-Select-Trigger");
|
|
122
|
+
const content = trigger.children[0];
|
|
123
|
+
// Unwrap the mocked View to return its native host element.
|
|
124
|
+
return content.children[0];
|
|
125
|
+
}
|
|
126
|
+
it.each([
|
|
127
|
+
{ labelPlacement: "inside" },
|
|
128
|
+
{ labelPlacement: "above" },
|
|
129
|
+
{ readOnly: true },
|
|
130
|
+
{ disabled: true },
|
|
131
|
+
])("centers a value without an inside label (%j)", props => {
|
|
132
|
+
var _a;
|
|
133
|
+
renderRoot(Object.assign(Object.assign({}, props), { defaultValue: { value: "tor", label: "Toronto" } }));
|
|
134
|
+
const content = getTriggerContent();
|
|
135
|
+
expect(content).toHaveStyle({
|
|
136
|
+
flexDirection: "row",
|
|
137
|
+
alignItems: "center",
|
|
138
|
+
});
|
|
139
|
+
expect((_a = StyleSheet.flatten(content.props.style).paddingTop) !== null && _a !== void 0 ? _a : 0).toBe(0);
|
|
140
|
+
});
|
|
141
|
+
it("centers the placeholder when the composed label is above the trigger", () => {
|
|
142
|
+
renderComposed({ labelPlacement: "above" });
|
|
143
|
+
expect(getTriggerContent()).toHaveStyle({
|
|
144
|
+
flexDirection: "row",
|
|
145
|
+
alignItems: "center",
|
|
146
|
+
});
|
|
147
|
+
});
|
|
120
148
|
it("places the label inside the trigger by default (labelPlacement inside)", () => {
|
|
121
149
|
renderComposed();
|
|
122
150
|
const trigger = screen.getByTestId("ATL-Select-Trigger");
|
|
123
151
|
expect(within(trigger).getByText("City", hidden)).toBeDefined();
|
|
152
|
+
expect(getTriggerContent()).toHaveStyle({
|
|
153
|
+
paddingTop: tokens["space-small"] - tokens["space-smallest"],
|
|
154
|
+
});
|
|
155
|
+
expect(getTriggerContent()).not.toHaveStyle({
|
|
156
|
+
flexDirection: "row",
|
|
157
|
+
});
|
|
124
158
|
});
|
|
125
159
|
it("places the label above the trigger with labelPlacement='above'", () => {
|
|
126
160
|
renderComposed({ labelPlacement: "above" });
|
|
@@ -14,13 +14,16 @@ import { Icon } from "../../Icon";
|
|
|
14
14
|
*/
|
|
15
15
|
export function SelectTrigger({ children, testID, ref, }) {
|
|
16
16
|
const styles = useStyles();
|
|
17
|
-
const { invalid, readOnly, accessibilityLabel, labelPlacement } = useSelectFieldState();
|
|
17
|
+
const { invalid, readOnly, accessibilityLabel, labelPlacement, labelContent, } = useSelectFieldState();
|
|
18
18
|
const { open, value, disabled } = useRootContext();
|
|
19
19
|
const isDisabled = disabled !== null && disabled !== void 0 ? disabled : false;
|
|
20
20
|
// `disabled` wins over `readOnly`.
|
|
21
21
|
const isReadOnly = !isDisabled && (readOnly !== null && readOnly !== void 0 ? readOnly : false);
|
|
22
|
-
const isInsideLabel = labelPlacement === "inside";
|
|
23
|
-
const content = (React.createElement(View, { style: [
|
|
22
|
+
const isInsideLabel = labelPlacement === "inside" && labelContent != null;
|
|
23
|
+
const content = (React.createElement(View, { style: [
|
|
24
|
+
styles.content,
|
|
25
|
+
isInsideLabel ? styles.contentInside : styles.contentWithoutLabel,
|
|
26
|
+
] },
|
|
24
27
|
isInsideLabel && React.createElement(FieldLabel, null),
|
|
25
28
|
children));
|
|
26
29
|
if (isReadOnly) {
|
|
@@ -4,6 +4,11 @@ export const useStyles = buildThemedStyles(tokens => ({
|
|
|
4
4
|
flex: 1,
|
|
5
5
|
justifyContent: "center",
|
|
6
6
|
},
|
|
7
|
+
// Keep the Value's flex horizontal when there is no label to stack above it.
|
|
8
|
+
contentWithoutLabel: {
|
|
9
|
+
flexDirection: "row",
|
|
10
|
+
alignItems: "center",
|
|
11
|
+
},
|
|
7
12
|
// Inside-label placement: the Value's flex fills the column vertically and
|
|
8
13
|
// would otherwise pin the label flush to the top. This top inset gives the
|
|
9
14
|
// label the same breathing room as the shared input chrome's mini-label.
|