@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.
@@ -3,6 +3,10 @@ export declare const useStyles: () => {
3
3
  flex: number;
4
4
  justifyContent: "center";
5
5
  };
6
+ contentWithoutLabel: {
7
+ flexDirection: "row";
8
+ alignItems: "center";
9
+ };
6
10
  contentInside: {
7
11
  paddingTop: number;
8
12
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components-native",
3
- "version": "0.115.5",
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": "^3.7.1",
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": "^3.0.0",
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": "9b27100be34c36aa1d4717f298cea4388ab9277d"
128
+ "gitHead": "d324e138d0e3c27cf0e54dac5d40b2c2d7e9ab82"
128
129
  }
@@ -5,9 +5,13 @@ import { useReducedMotion } from "react-native-reanimated";
5
5
  import type { ReactTestInstance } from "react-test-renderer";
6
6
  import { ActivityIndicator } from "./index";
7
7
 
8
- // `useReducedMotion` is mocked globally in src/__mocks__/__mocks.ts and
9
- // defaults to returning `false`. Tests that exercise the reduced-motion
10
- // branch override the return value below.
8
+ // Reanimated's `useReducedMotion` reads the OS setting once at module load,
9
+ // so it is mocked to let tests toggle the reduced-motion branch.
10
+ jest.mock("react-native-reanimated", () => ({
11
+ __esModule: true,
12
+ ...jest.requireActual("react-native-reanimated"),
13
+ useReducedMotion: jest.fn(() => false),
14
+ }));
11
15
 
12
16
  const testId = "ActivityIndicator";
13
17
 
@@ -102,7 +102,7 @@ does not require keyboard or screen-reader interaction.
102
102
 
103
103
  The default (`base`) presentation renders Material Design 3's three-layer
104
104
  indeterminate ring. The implementation uses `react-native-svg` for the ring
105
- geometry and `react-native-reanimated` 3 for the motion — all worklet-driven so
105
+ geometry and `react-native-reanimated` 4 for the motion — all worklet-driven so
106
106
  the animation runs on the UI thread regardless of JS thread load.
107
107
 
108
108
  The three concurrent animations (base only):
@@ -17,10 +17,9 @@ import Reanimated from "react-native-reanimated";
17
17
  *
18
18
  * @see https://kirillzyusko.github.io/react-native-keyboard-controller/docs/api/components/keyboard-aware-scroll-view#gorhombottom-sheet
19
19
  */
20
- const AnimatedScrollView =
21
- Reanimated.createAnimatedComponent<KeyboardAwareScrollViewProps>(
22
- KeyboardAwareScrollView,
23
- );
20
+ const AnimatedScrollView = Reanimated.createAnimatedComponent(
21
+ KeyboardAwareScrollView,
22
+ );
24
23
 
25
24
  const BottomSheetScrollViewComponent = createBottomSheetScrollableComponent<
26
25
  BottomSheetScrollViewMethods,
@@ -17,7 +17,6 @@ import { Content } from "../Content";
17
17
  import { Text } from "../Text";
18
18
 
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.
@@ -104,6 +104,12 @@ A few decisions shape how the composable parts fit together:
104
104
  `Select.Trigger` renders it in the inside slot. So the part's JSX position is
105
105
  irrelevant; only `labelPlacement` matters.
106
106
 
107
+ - **Only an actual inside label uses the stacked layout.** With no composed
108
+ label, or with `labelPlacement="above"`, the trigger centers its value or
109
+ placeholder vertically alongside the chevron. Its content uses a row so the
110
+ primitive Value's `flex: 1` fills width rather than stretching the text box
111
+ vertically. The inside-label inset only applies when label content exists.
112
+
107
113
  - **Accessibility names the trigger directly.** The accessible name is applied
108
114
  as the trigger's `accessibilityLabel` — not via the rn-primitives `Label` / a
109
115
  `nativeID`+`accessibilityLabelledBy` association (unsupported on iOS). It is
@@ -1,11 +1,12 @@
1
1
  import React from "react";
2
+ import { Pressable, StyleSheet } from "react-native";
3
+ import type { ReactTestInstance } from "react-test-renderer";
2
4
  import {
3
5
  fireEvent,
4
6
  render,
5
7
  screen,
6
8
  within,
7
9
  } from "@testing-library/react-native";
8
- import { Pressable } from "react-native";
9
10
  import type { TriggerRef } from "@rn-primitives/select";
10
11
  import { SelectRoot } from "./SelectRoot";
11
12
  import { SelectTrigger } from "./components/SelectTrigger";
@@ -190,11 +191,53 @@ describe("SelectRoot label placement", () => {
190
191
  );
191
192
  }
192
193
 
194
+ function getTriggerContent() {
195
+ const trigger = screen.getByTestId("ATL-Select-Trigger");
196
+ const content = trigger.children[0] as ReactTestInstance;
197
+
198
+ // Unwrap the mocked View to return its native host element.
199
+ return content.children[0] as ReactTestInstance;
200
+ }
201
+
202
+ it.each([
203
+ { labelPlacement: "inside" as const },
204
+ { labelPlacement: "above" as const },
205
+ { readOnly: true },
206
+ { disabled: true },
207
+ ])("centers a value without an inside label (%j)", props => {
208
+ renderRoot({
209
+ ...props,
210
+ defaultValue: { value: "tor", label: "Toronto" },
211
+ });
212
+
213
+ const content = getTriggerContent();
214
+ expect(content).toHaveStyle({
215
+ flexDirection: "row",
216
+ alignItems: "center",
217
+ });
218
+ expect(StyleSheet.flatten(content.props.style).paddingTop ?? 0).toBe(0);
219
+ });
220
+
221
+ it("centers the placeholder when the composed label is above the trigger", () => {
222
+ renderComposed({ labelPlacement: "above" });
223
+
224
+ expect(getTriggerContent()).toHaveStyle({
225
+ flexDirection: "row",
226
+ alignItems: "center",
227
+ });
228
+ });
229
+
193
230
  it("places the label inside the trigger by default (labelPlacement inside)", () => {
194
231
  renderComposed();
195
232
 
196
233
  const trigger = screen.getByTestId("ATL-Select-Trigger");
197
234
  expect(within(trigger).getByText("City", hidden)).toBeDefined();
235
+ expect(getTriggerContent()).toHaveStyle({
236
+ paddingTop: tokens["space-small"] - tokens["space-smallest"],
237
+ });
238
+ expect(getTriggerContent()).not.toHaveStyle({
239
+ flexDirection: "row",
240
+ });
198
241
  });
199
242
 
200
243
  it("places the label above the trigger with labelPlacement='above'", () => {
@@ -6,6 +6,12 @@ export const useStyles = buildThemedStyles(tokens => ({
6
6
  justifyContent: "center",
7
7
  },
8
8
 
9
+ // Keep the Value's flex horizontal when there is no label to stack above it.
10
+ contentWithoutLabel: {
11
+ flexDirection: "row",
12
+ alignItems: "center",
13
+ },
14
+
9
15
  // Inside-label placement: the Value's flex fills the column vertically and
10
16
  // would otherwise pin the label flush to the top. This top inset gives the
11
17
  // label the same breathing room as the shared input chrome's mini-label.
@@ -35,18 +35,28 @@ export function SelectTrigger({
35
35
  ref,
36
36
  }: SelectTriggerProps): ReactElement {
37
37
  const styles = useStyles();
38
- const { invalid, readOnly, accessibilityLabel, labelPlacement } =
39
- useSelectFieldState();
38
+ const {
39
+ invalid,
40
+ readOnly,
41
+ accessibilityLabel,
42
+ labelPlacement,
43
+ labelContent,
44
+ } = useSelectFieldState();
40
45
  const { open, value, disabled } = useRootContext();
41
46
 
42
47
  const isDisabled = disabled ?? false;
43
48
  // `disabled` wins over `readOnly`.
44
49
  const isReadOnly = !isDisabled && (readOnly ?? false);
45
50
 
46
- const isInsideLabel = labelPlacement === "inside";
51
+ const isInsideLabel = labelPlacement === "inside" && labelContent != null;
47
52
 
48
53
  const content = (
49
- <View style={[styles.content, isInsideLabel && styles.contentInside]}>
54
+ <View
55
+ style={[
56
+ styles.content,
57
+ isInsideLabel ? styles.contentInside : styles.contentWithoutLabel,
58
+ ]}
59
+ >
50
60
  {isInsideLabel && <FieldLabel />}
51
61
  {children}
52
62
  </View>