@jobber/components-native 0.114.14-JOB-183884-72cd42b.0 → 0.114.14
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 +2 -2
- package/dist/src/primitives/Select/SelectPrimitive.js +5 -3
- package/dist/src/primitives/Select/SelectPrimitive.test.js +32 -13
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/src/primitives/Select/SelectPrimitive.d.ts +1 -1
- package/package.json +2 -2
- package/src/Select/Select.guide.md +6 -0
- package/src/primitives/Select/SelectPrimitive.test.tsx +53 -14
- package/src/primitives/Select/SelectPrimitive.tsx +17 -3
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components-native",
|
|
3
|
-
"version": "0.114.14
|
|
3
|
+
"version": "0.114.14",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React Native implementation of Atlantis",
|
|
6
6
|
"repository": {
|
|
@@ -123,5 +123,5 @@
|
|
|
123
123
|
"react-native-screens": ">=4.18.0",
|
|
124
124
|
"react-native-svg": ">=12.0.0"
|
|
125
125
|
},
|
|
126
|
-
"gitHead": "
|
|
126
|
+
"gitHead": "3fba9dd8675ceed40979c17792faf2d091ac2ce7"
|
|
127
127
|
}
|
|
@@ -15,7 +15,7 @@ import * as Primitive from "@rn-primitives/select";
|
|
|
15
15
|
import { SafeAreaInsetsContext } from "react-native-safe-area-context";
|
|
16
16
|
import { useStyles } from "./SelectPrimitive.style";
|
|
17
17
|
import { tokens as staticTokens } from "../../utils/design";
|
|
18
|
-
import { useAtlantisTheme } from "../../AtlantisThemeContext";
|
|
18
|
+
import { AtlantisThemeContextProvider, useAtlantisTheme, } from "../../AtlantisThemeContext";
|
|
19
19
|
/** Default trigger testID. Consumer-supplied `testID`s are used verbatim. */
|
|
20
20
|
export const SELECT_TRIGGER_DEFAULT_TEST_ID = "ATL-Select-Trigger";
|
|
21
21
|
function useIsDarkTheme() {
|
|
@@ -63,8 +63,10 @@ function SelectPrimitiveValue(_a) {
|
|
|
63
63
|
}
|
|
64
64
|
/** Portals the dropdown into the mounted `AtlantisPortalHost`. */
|
|
65
65
|
function SelectPrimitivePortal(_a) {
|
|
66
|
-
var props = __rest(_a, []);
|
|
67
|
-
|
|
66
|
+
var { children } = _a, props = __rest(_a, ["children"]);
|
|
67
|
+
const { effectiveTheme } = useAtlantisTheme();
|
|
68
|
+
return (React.createElement(Primitive.Portal, Object.assign({}, props),
|
|
69
|
+
React.createElement(AtlantisThemeContextProvider, { dangerouslyOverrideTheme: effectiveTheme }, children)));
|
|
68
70
|
}
|
|
69
71
|
/** Tap-outside dismiss surface behind the dropdown (no scrim). */
|
|
70
72
|
function SelectPrimitiveOverlay(_a) {
|
|
@@ -8,10 +8,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import React from "react";
|
|
11
|
-
import { render,
|
|
11
|
+
import { render, screen, userEvent, within, } from "@testing-library/react-native";
|
|
12
12
|
import { darkTokens } from "@jobber/design";
|
|
13
|
+
import { PortalHost } from "@rn-primitives/portal";
|
|
13
14
|
import { SelectPrimitive } from "./SelectPrimitive";
|
|
14
|
-
import { useStyles } from "./SelectPrimitive.style";
|
|
15
15
|
import { tokens } from "../../utils/design";
|
|
16
16
|
import { PortalHostWrapper } from "../../utils/test";
|
|
17
17
|
import { Icon } from "../../Icon";
|
|
@@ -101,7 +101,7 @@ const CITIES = [
|
|
|
101
101
|
{ value: "van", label: "Vancouver" },
|
|
102
102
|
{ value: "edm", label: "Edmonton" },
|
|
103
103
|
];
|
|
104
|
-
function renderSelectWithContent({ defaultValue, onValueChange, closeOnPress, disabledItem, theme, } = {}) {
|
|
104
|
+
function renderSelectWithContent({ defaultValue, onValueChange, closeOnPress, disabledItem, pressedItem, theme, } = {}) {
|
|
105
105
|
const wrapper = theme === "dark"
|
|
106
106
|
? ({ children }) => (React.createElement(AtlantisThemeContextProvider, { dangerouslyOverrideTheme: "dark" },
|
|
107
107
|
React.createElement(PortalHostWrapper, null, children)))
|
|
@@ -115,7 +115,7 @@ function renderSelectWithContent({ defaultValue, onValueChange, closeOnPress, di
|
|
|
115
115
|
React.createElement(SelectPrimitive.Viewport, null,
|
|
116
116
|
React.createElement(SelectPrimitive.Group, null,
|
|
117
117
|
React.createElement(SelectPrimitive.Label, null, "Cities"),
|
|
118
|
-
CITIES.map(city => (React.createElement(SelectPrimitive.Item, { key: city.value, value: city.value, label: city.label, closeOnPress: closeOnPress, disabled: disabledItem === city.value, testID: `ATL-Select-Item-${city.value}` },
|
|
118
|
+
CITIES.map(city => (React.createElement(SelectPrimitive.Item, { key: city.value, value: city.value, label: city.label, closeOnPress: closeOnPress, disabled: disabledItem === city.value, testOnly_pressed: pressedItem === city.value, testID: `ATL-Select-Item-${city.value}` },
|
|
119
119
|
React.createElement(SelectPrimitive.ItemText, { disabled: disabledItem === city.value }),
|
|
120
120
|
React.createElement(SelectPrimitive.ItemIndicator, null,
|
|
121
121
|
React.createElement(Icon, { name: "checkmark" })))))),
|
|
@@ -151,17 +151,14 @@ describe("SelectPrimitive.Content", () => {
|
|
|
151
151
|
});
|
|
152
152
|
}));
|
|
153
153
|
});
|
|
154
|
-
describe("SelectPrimitive
|
|
155
|
-
it("uses the elevated dark surface active token
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
expect(result.current.itemPressedDarkElevated).toMatchObject({
|
|
154
|
+
describe("SelectPrimitive.Item", () => {
|
|
155
|
+
it("uses the elevated dark surface active token when pressed", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
156
|
+
renderSelectWithContent({ theme: "dark", pressedItem: "tor" });
|
|
157
|
+
yield openSelect();
|
|
158
|
+
expect(screen.getByTestId("ATL-Select-Item-tor")).toHaveStyle({
|
|
160
159
|
backgroundColor: darkTokens["color-surface--active"],
|
|
161
160
|
});
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
describe("SelectPrimitive.Item", () => {
|
|
161
|
+
}));
|
|
165
162
|
it("selects the option, emits { value, label }, and closes", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
166
163
|
const onValueChange = jest.fn();
|
|
167
164
|
renderSelectWithContent({ onValueChange });
|
|
@@ -241,6 +238,28 @@ describe("SelectPrimitive.Item", () => {
|
|
|
241
238
|
});
|
|
242
239
|
}));
|
|
243
240
|
});
|
|
241
|
+
describe("SelectPrimitive.Portal", () => {
|
|
242
|
+
it("preserves the selected theme when the portal host is outside the provider", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
243
|
+
render(React.createElement(SelectPrimitive.Root, null,
|
|
244
|
+
React.createElement(SelectPrimitive.Trigger, null,
|
|
245
|
+
React.createElement(SelectPrimitive.Value, { placeholder: "Select an option" })),
|
|
246
|
+
React.createElement(SelectPrimitive.Portal, null,
|
|
247
|
+
React.createElement(SelectPrimitive.Content, { testID: "ATL-Select-Content" },
|
|
248
|
+
React.createElement(SelectPrimitive.Viewport, null,
|
|
249
|
+
React.createElement(SelectPrimitive.Item, { value: "tor", label: "Toronto", testID: "ATL-Select-Item-tor" },
|
|
250
|
+
React.createElement(SelectPrimitive.ItemText, null),
|
|
251
|
+
React.createElement(SelectPrimitive.ItemIndicator, null,
|
|
252
|
+
React.createElement(Icon, { name: "checkmark" }))))))), {
|
|
253
|
+
wrapper: ({ children }) => (React.createElement(React.Fragment, null,
|
|
254
|
+
React.createElement(AtlantisThemeContextProvider, { dangerouslyOverrideTheme: "dark" }, children),
|
|
255
|
+
React.createElement(PortalHost, null))),
|
|
256
|
+
});
|
|
257
|
+
yield openSelect();
|
|
258
|
+
expect(screen.getByTestId("ATL-Select-Content")).toHaveStyle({
|
|
259
|
+
backgroundColor: darkTokens["color-surface--background--subtle"],
|
|
260
|
+
});
|
|
261
|
+
}));
|
|
262
|
+
});
|
|
244
263
|
describe("SelectPrimitive.Value", () => {
|
|
245
264
|
it("shows the placeholder with subdued styling when nothing is selected", () => {
|
|
246
265
|
renderSelect();
|