@applicaster/zapp-react-native-utils 14.0.18-alpha.5740764222 → 14.0.18-rc.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/appUtils/focusManagerAux/utils/index.ts +2 -4
- package/package.json +2 -2
- package/reactHooks/layout/__tests__/index.test.tsx +0 -17
- package/reactHooks/layout/types/index.ts +0 -6
- package/reactHooks/layout/useDimensions/__tests__/useDimensions.test.ts +0 -38
- package/reactHooks/layout/useDimensions/useDimensions.ts +5 -62
- package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +13 -11
- package/reactHooks/resolvers/useCellResolver.ts +0 -1
- package/screenPickerUtils/index.ts +5 -0
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
|
|
14
14
|
import {
|
|
15
15
|
getFocusableId,
|
|
16
|
-
|
|
16
|
+
isTabsScreenContentContainerId,
|
|
17
17
|
} from "@applicaster/zapp-react-native-utils/screenPickerUtils";
|
|
18
18
|
|
|
19
19
|
// run check each 300 ms
|
|
@@ -24,8 +24,6 @@ const isTopMenu = (node) => startsWith(QUICK_BRICK_NAVBAR, node?.id);
|
|
|
24
24
|
const isContent = (node) => startsWith(QUICK_BRICK_CONTENT, node?.id);
|
|
25
25
|
const isRoot = (node) => node?.id === "root";
|
|
26
26
|
|
|
27
|
-
const isScrenPicker = (node) => startsWith(SCREEN_PICKER_CONTAINER, node?.id);
|
|
28
|
-
|
|
29
27
|
type Props = {
|
|
30
28
|
maxTimeout: number;
|
|
31
29
|
conditionFn: () => boolean;
|
|
@@ -136,7 +134,7 @@ export const isTabsScreenOnContentFocused = (node) => {
|
|
|
136
134
|
return false;
|
|
137
135
|
}
|
|
138
136
|
|
|
139
|
-
if (
|
|
137
|
+
if (isTabsScreenContentContainerId(node?.id)) {
|
|
140
138
|
return true;
|
|
141
139
|
}
|
|
142
140
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "14.0.18-
|
|
3
|
+
"version": "14.0.18-rc.0",
|
|
4
4
|
"description": "Applicaster Zapp React Native utilities package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@applicaster/applicaster-types": "14.0.18-
|
|
30
|
+
"@applicaster/applicaster-types": "14.0.18-rc.0",
|
|
31
31
|
"buffer": "^5.2.1",
|
|
32
32
|
"camelize": "^1.0.0",
|
|
33
33
|
"dayjs": "^1.11.10",
|
|
@@ -39,7 +39,6 @@ ReactNative.NativeModules.QuickBrickCommunicationModule =
|
|
|
39
39
|
|
|
40
40
|
jest.mock("react-native-safe-area-context", () => ({
|
|
41
41
|
useSafeAreaInsets: () => ({ top: 50 }),
|
|
42
|
-
useSafeAreaFrame: () => ({ x: 0, y: 0, width: 100, height: 100 }),
|
|
43
42
|
}));
|
|
44
43
|
|
|
45
44
|
jest.mock("../../../reactUtils", () => ({
|
|
@@ -50,22 +49,6 @@ jest.mock("../../../reactUtils", () => ({
|
|
|
50
49
|
|
|
51
50
|
jest.mock("../../navigation", () => ({
|
|
52
51
|
useIsScreenActive: () => true,
|
|
53
|
-
useRoute: () => ({
|
|
54
|
-
screenData: { general: { screen_orientation: "portrait" } },
|
|
55
|
-
}),
|
|
56
|
-
}));
|
|
57
|
-
|
|
58
|
-
jest.mock("../../screen", () => ({
|
|
59
|
-
useCurrentScreenData: () => null,
|
|
60
|
-
}));
|
|
61
|
-
|
|
62
|
-
jest.mock("../../device", () => ({
|
|
63
|
-
useIsTablet: () => false,
|
|
64
|
-
}));
|
|
65
|
-
|
|
66
|
-
jest.mock("../../../appUtils/orientationHelper", () => ({
|
|
67
|
-
getScreenOrientation: jest.fn(() => 1), // portrait
|
|
68
|
-
isOrientationCompatible: jest.fn(() => true),
|
|
69
52
|
}));
|
|
70
53
|
|
|
71
54
|
jest.mock("../../navigation/useNavigation");
|
|
@@ -22,12 +22,6 @@ export type Options = {
|
|
|
22
22
|
rounded?: boolean;
|
|
23
23
|
deviceInfo?: boolean;
|
|
24
24
|
updateForInactiveScreens?: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* When true, dimensions will only update when they match the screen's target orientation.
|
|
27
|
-
* Returns the last valid dimensions during orientation transitions.
|
|
28
|
-
* Requires updateForInactiveScreens: false to work properly.
|
|
29
|
-
*/
|
|
30
|
-
waitForValidOrientation?: boolean;
|
|
31
25
|
};
|
|
32
26
|
|
|
33
27
|
export type Context = "window" | "screen";
|
|
@@ -19,28 +19,6 @@ jest.mock(
|
|
|
19
19
|
})
|
|
20
20
|
);
|
|
21
21
|
|
|
22
|
-
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/screen", () => ({
|
|
23
|
-
useCurrentScreenData: jest.fn().mockReturnValue(null),
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
|
-
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
|
|
27
|
-
useRoute: jest.fn().mockReturnValue({
|
|
28
|
-
screenData: { general: { screen_orientation: "portrait" } },
|
|
29
|
-
}),
|
|
30
|
-
}));
|
|
31
|
-
|
|
32
|
-
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/device", () => ({
|
|
33
|
-
useIsTablet: jest.fn().mockReturnValue(false),
|
|
34
|
-
}));
|
|
35
|
-
|
|
36
|
-
jest.mock(
|
|
37
|
-
"@applicaster/zapp-react-native-utils/appUtils/orientationHelper",
|
|
38
|
-
() => ({
|
|
39
|
-
getScreenOrientation: jest.fn().mockReturnValue(1), // portrait
|
|
40
|
-
isOrientationCompatible: jest.fn().mockReturnValue(true),
|
|
41
|
-
})
|
|
42
|
-
);
|
|
43
|
-
|
|
44
22
|
jest.doMock("../helpers", () => ({
|
|
45
23
|
getInitialDimensions: jest
|
|
46
24
|
.fn()
|
|
@@ -151,20 +129,4 @@ describe("useDimensions", () => {
|
|
|
151
129
|
|
|
152
130
|
consoleWarnSpy.mockRestore();
|
|
153
131
|
});
|
|
154
|
-
|
|
155
|
-
it("accepts waitForValidOrientation option", () => {
|
|
156
|
-
// Smoke test to verify the option is accepted without errors
|
|
157
|
-
const { result } = renderHook(() =>
|
|
158
|
-
useDimensions("screen", {
|
|
159
|
-
updateForInactiveScreens: false,
|
|
160
|
-
waitForValidOrientation: true,
|
|
161
|
-
})
|
|
162
|
-
);
|
|
163
|
-
|
|
164
|
-
expect(result.current).toMatchObject({
|
|
165
|
-
width: expect.any(Number),
|
|
166
|
-
height: expect.any(Number),
|
|
167
|
-
statusBarHeight: expect.any(Number),
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
132
|
});
|
|
@@ -11,13 +11,6 @@ import { Options, UseDimensions } from "../types";
|
|
|
11
11
|
import { getDeviceInfo } from "../getDeviceInfo";
|
|
12
12
|
import { getInitialDimensions } from "./helpers";
|
|
13
13
|
import { useIsScreenActive } from "../../navigation/useIsScreenActive";
|
|
14
|
-
import {
|
|
15
|
-
getScreenOrientation,
|
|
16
|
-
isOrientationCompatible,
|
|
17
|
-
} from "../../../appUtils/orientationHelper";
|
|
18
|
-
import { useCurrentScreenData } from "../../screen";
|
|
19
|
-
import { useRoute } from "../../navigation";
|
|
20
|
-
import { useIsTablet } from "../../device";
|
|
21
14
|
|
|
22
15
|
function compensateForScaleIfNeeded(context) {
|
|
23
16
|
return function () {
|
|
@@ -66,43 +59,9 @@ export const useDimensions: UseDimensions = (
|
|
|
66
59
|
options.fullDimensions = false;
|
|
67
60
|
}
|
|
68
61
|
|
|
69
|
-
if (options.waitForValidOrientation === undefined) {
|
|
70
|
-
options.waitForValidOrientation = false;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
62
|
const [dimensions, setDimensions] = useState(getInitialDimensions(context));
|
|
74
63
|
const deviceInfo = useRef(getDeviceInfo(dimensions, appData));
|
|
75
64
|
|
|
76
|
-
// Orientation validation setup (only when waitForValidOrientation is enabled)
|
|
77
|
-
const currentScreenData = useCurrentScreenData();
|
|
78
|
-
const { screenData } = useRoute();
|
|
79
|
-
const isTablet = useIsTablet();
|
|
80
|
-
const isTabletPortrait = appData?.isTabletPortrait;
|
|
81
|
-
|
|
82
|
-
const targetScreenData =
|
|
83
|
-
currentScreenData || (screenData as any)?.targetScreen || screenData;
|
|
84
|
-
|
|
85
|
-
const orientation = options.waitForValidOrientation
|
|
86
|
-
? getScreenOrientation({
|
|
87
|
-
screenData: targetScreenData,
|
|
88
|
-
layoutData: { isTablet, isTabletPortrait },
|
|
89
|
-
})
|
|
90
|
-
: null;
|
|
91
|
-
|
|
92
|
-
const isOrientationValid = options.waitForValidOrientation
|
|
93
|
-
? isOrientationCompatible({
|
|
94
|
-
orientation,
|
|
95
|
-
layoutData: {
|
|
96
|
-
isTablet,
|
|
97
|
-
isTabletPortrait,
|
|
98
|
-
width: dimensions.width,
|
|
99
|
-
height: dimensions.height,
|
|
100
|
-
},
|
|
101
|
-
})
|
|
102
|
-
: true;
|
|
103
|
-
|
|
104
|
-
const lastValidDimensions = useRef(dimensions);
|
|
105
|
-
|
|
106
65
|
const applyOptions = R.compose(
|
|
107
66
|
R.when(() => options.deviceInfo, R.assoc("deviceInfo", deviceInfo.current)),
|
|
108
67
|
R.when(
|
|
@@ -150,29 +109,13 @@ export const useDimensions: UseDimensions = (
|
|
|
150
109
|
};
|
|
151
110
|
}, [isActive]);
|
|
152
111
|
|
|
153
|
-
let dimensionsToUse;
|
|
154
|
-
|
|
155
|
-
// When waitForValidOrientation is enabled, freeze dimensions during invalid orientation
|
|
156
|
-
if (options.waitForValidOrientation) {
|
|
157
|
-
if (isOrientationValid) {
|
|
158
|
-
// Store last valid dimensions to return during orientation transitions
|
|
159
|
-
lastValidDimensions.current = dimensions;
|
|
160
|
-
dimensionsToUse = dimensions;
|
|
161
|
-
} else {
|
|
162
|
-
// Return last valid dimensions during orientation transitions
|
|
163
|
-
dimensionsToUse = lastValidDimensions.current;
|
|
164
|
-
}
|
|
165
|
-
} else {
|
|
166
|
-
dimensionsToUse = dimensions;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
112
|
const memoizedDimensions = useMemo(() => {
|
|
170
|
-
return { ...applyOptions(
|
|
113
|
+
return { ...applyOptions(dimensions), statusBarHeight };
|
|
171
114
|
}, [
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
115
|
+
dimensions.width,
|
|
116
|
+
dimensions.height,
|
|
117
|
+
dimensions.fontScale,
|
|
118
|
+
dimensions.scale,
|
|
176
119
|
]);
|
|
177
120
|
|
|
178
121
|
return memoizedDimensions;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
|
-
import { cleanup } from "@testing-library/react-
|
|
4
|
-
import
|
|
3
|
+
import { cleanup, renderHook } from "@testing-library/react-hooks";
|
|
4
|
+
import configureStore from "redux-mock-store";
|
|
5
|
+
import { Provider } from "react-redux";
|
|
6
|
+
|
|
7
|
+
const mockStore = configureStore([]);
|
|
5
8
|
|
|
6
9
|
const mock_rtl_flag = false;
|
|
7
10
|
|
|
@@ -43,7 +46,12 @@ describe("cellResolver", () => {
|
|
|
43
46
|
},
|
|
44
47
|
};
|
|
45
48
|
|
|
46
|
-
const
|
|
49
|
+
const store = mockStore({ cellStyles, styles, plugins });
|
|
50
|
+
|
|
51
|
+
// eslint-disable-next-line react/prop-types
|
|
52
|
+
const wrapper = ({ children }) => (
|
|
53
|
+
<Provider store={store}>{children}</Provider>
|
|
54
|
+
);
|
|
47
55
|
|
|
48
56
|
afterEach(() => {
|
|
49
57
|
cleanup();
|
|
@@ -53,14 +61,8 @@ describe("cellResolver", () => {
|
|
|
53
61
|
expect(useCellResolver).toBeDefined();
|
|
54
62
|
});
|
|
55
63
|
|
|
56
|
-
it("
|
|
57
|
-
|
|
58
|
-
const resolvedCell = useCellResolver({ component });
|
|
59
|
-
|
|
60
|
-
return <>{resolvedCell}</>;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
renderWithProviders(<TestComponent />, storeState);
|
|
64
|
+
it("Resolves cell plugin", () => {
|
|
65
|
+
renderHook(() => useCellResolver({ component }), { wrapper });
|
|
64
66
|
|
|
65
67
|
expect(testCellModule).toBeCalled();
|
|
66
68
|
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { endsWith } from "@applicaster/zapp-react-native-utils/utils";
|
|
2
|
+
|
|
1
3
|
export const getFocusableId = (id) => `PickerItem.${id}`;
|
|
2
4
|
|
|
3
5
|
export const getPickerSelectorId = (id) => `PickerSelector.${id}`;
|
|
@@ -11,3 +13,6 @@ export const getScreenPickerSelectorContainerId = (id) =>
|
|
|
11
13
|
|
|
12
14
|
export const getScreenPickerContentContainerId = (id) =>
|
|
13
15
|
`${getScreenPickerId(id)}-screen-container`;
|
|
16
|
+
|
|
17
|
+
export const isTabsScreenContentContainerId = (id) =>
|
|
18
|
+
endsWith("-screen-container", id);
|