@applicaster/zapp-react-native-ui-components 14.0.0-alpha.5533663133 → 14.0.0-alpha.6242515303

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.
@@ -38,6 +38,9 @@ describe("Focusable", () => {
38
38
  });
39
39
 
40
40
  it("updates disableFocus state when disableFocus prop changes", () => {
41
+ const unregister = jest.fn();
42
+ mockFocusManager.registerFocusable.mockReturnValue(unregister);
43
+
41
44
  const { rerender } = render(
42
45
  <Focusable id="test-id" disableFocus={false}>
43
46
  <Touchable testID="touchable" />
@@ -43,11 +43,13 @@ export const FocusableContext = React.createContext<
43
43
  // eslint-disable-next-line
44
44
  setIsFocusable: (enableFocus: boolean) => void;
45
45
  ref: FocusManager.FocusableRef;
46
+ parentFocusableId: Option<string>;
46
47
  } & ParentFocus
47
48
  >({
48
49
  focused: false,
49
50
  setIsFocusable: () => {},
50
51
  ref: { current: null },
52
+ parentFocusableId: undefined,
51
53
  });
52
54
 
53
55
  export const useFocusable = () => React.useContext(FocusableContext);
@@ -74,7 +76,7 @@ function FocusableComponent(props: Props, forwardedRef) {
74
76
 
75
77
  const isRTL = useIsRTL();
76
78
  const focusManager = useFocusManager();
77
- const { ref: parentFocusable } = useFocusable();
79
+ const { ref: parentFocusableRef, parentFocusableId } = useFocusable();
78
80
  const touchableRef = React.useRef(null);
79
81
 
80
82
  const [focused, setFocused] = React.useState(() =>
@@ -98,13 +100,14 @@ function FocusableComponent(props: Props, forwardedRef) {
98
100
  }
99
101
  }, [disableFocus]);
100
102
 
101
- React.useEffect(() => {
103
+ React.useLayoutEffect(() => {
102
104
  if (id) {
103
- const unregister = focusManager.registerFocusable(
105
+ const unregister = focusManager.registerFocusable({
104
106
  touchableRef,
105
- parentFocusable,
106
- isFocusableCell
107
- );
107
+ parentFocusableRef,
108
+ isFocusableCell,
109
+ parentFocusableId,
110
+ });
108
111
 
109
112
  onRegister();
110
113
 
@@ -112,7 +115,7 @@ function FocusableComponent(props: Props, forwardedRef) {
112
115
  unregister();
113
116
  };
114
117
  }
115
- }, [id, onRegister, isFocusableCell]);
118
+ }, [id, onRegister, isFocusableCell, parentFocusableId]);
116
119
 
117
120
  if (R.isNil(id)) {
118
121
  // eslint-disable-next-line no-console
@@ -164,8 +167,9 @@ function FocusableComponent(props: Props, forwardedRef) {
164
167
  ...parentFocus,
165
168
  ref: touchableRef,
166
169
  setIsFocusable,
170
+ parentFocusableId: id,
167
171
  };
168
- }, [parentFocus, focused]);
172
+ }, [parentFocus, focused, id]);
169
173
 
170
174
  return (
171
175
  <Touchable
@@ -7,12 +7,14 @@ import {
7
7
  import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
8
8
  import {
9
9
  useDimensions,
10
+ useIsTablet as isTablet,
10
11
  useNavigation,
11
12
  } from "@applicaster/zapp-react-native-utils/reactHooks";
12
13
 
13
14
  import { BufferAnimation } from "../PlayerContainer/BufferAnimation";
14
15
  import { PlayerContainer } from "../PlayerContainer";
15
16
  import { useModalSize } from "../VideoModal/hooks";
17
+ import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
16
18
 
17
19
  type Props = {
18
20
  item: ZappEntry;
@@ -83,6 +85,13 @@ type PlayableComponent = {
83
85
  Component: React.ComponentType<any>;
84
86
  };
85
87
 
88
+ const dimensionsContext: "window" | "screen" = platformSelect({
89
+ android_tv: "window",
90
+ amazon: "window",
91
+ // eslint-disable-next-line react-hooks/rules-of-hooks
92
+ default: isTablet() ? "window" : "screen", // on tablet, window represents correct values, on phone it's not as the screen could be rotated
93
+ });
94
+
86
95
  export function HandlePlayable({
87
96
  item,
88
97
  isModal,
@@ -135,7 +144,8 @@ export function HandlePlayable({
135
144
  });
136
145
  }, [casting]);
137
146
 
138
- const { width: screenWidth, height: screenHeight } = useDimensions("window");
147
+ const { width: screenWidth, height: screenHeight } =
148
+ useDimensions(dimensionsContext);
139
149
 
140
150
  const modalSize = useModalSize();
141
151
 
@@ -2,7 +2,6 @@ import React, { useMemo } from "react";
2
2
  import { ImageStyle } from "react-native";
3
3
  import { Focusable } from "@applicaster/zapp-react-native-ui-components/Components/Focusable";
4
4
  import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
5
- import * as R from "ramda";
6
5
  import { getXray } from "@applicaster/zapp-react-native-utils/logger";
7
6
  import { toBooleanWithDefaultFalse } from "@applicaster/zapp-react-native-utils/booleanUtils";
8
7
  import { useAccessibilityManager } from "@applicaster/zapp-react-native-utils/appUtils/accessibilityManager/hooks";
@@ -67,32 +66,10 @@ export function FocusableView({ style, children, item, ...otherProps }: Props) {
67
66
  const handleFocus = (focusable) => {
68
67
  const focusedButtonId = getFocusedButtonId(focusable);
69
68
 
70
- wrapperRef?.current?.measure((x, y, width, height, pageX, pageY) => {
71
- const top = pageY;
72
- const bottom = top + height;
73
- const left = pageX;
74
- const right = left + width;
75
-
76
- const boundingRect = {
77
- x,
78
- y,
79
- pageX,
80
- pageY,
81
- width,
82
- height,
83
- top,
84
- bottom,
85
- left,
86
- right,
87
- };
88
-
89
- otherProps?.onToggleFocus?.({
90
- focusable: {
91
- getRect: R.always(boundingRect),
92
- },
93
- focusedButtonId,
94
- mouse: focusable.mouse,
95
- });
69
+ otherProps?.onToggleFocus?.({
70
+ focusable: wrapperRef.current,
71
+ focusedButtonId,
72
+ mouse: focusable.mouse,
96
73
  });
97
74
 
98
75
  if (ttsLabel) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-ui-components",
3
- "version": "14.0.0-alpha.5533663133",
3
+ "version": "14.0.0-alpha.6242515303",
4
4
  "description": "Applicaster Zapp React Native ui components for the Quick Brick App",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -27,14 +27,11 @@
27
27
  "url": "https://github.com/applicaster/quickbrick/issues"
28
28
  },
29
29
  "homepage": "https://github.com/applicaster/quickbrick#readme",
30
- "devDependencies": {
31
- "redux-mock-store": "^1.5.3"
32
- },
33
30
  "dependencies": {
34
- "@applicaster/applicaster-types": "14.0.0-alpha.5533663133",
35
- "@applicaster/zapp-react-native-bridge": "14.0.0-alpha.5533663133",
36
- "@applicaster/zapp-react-native-redux": "14.0.0-alpha.5533663133",
37
- "@applicaster/zapp-react-native-utils": "14.0.0-alpha.5533663133",
31
+ "@applicaster/applicaster-types": "14.0.0-alpha.6242515303",
32
+ "@applicaster/zapp-react-native-bridge": "14.0.0-alpha.6242515303",
33
+ "@applicaster/zapp-react-native-redux": "14.0.0-alpha.6242515303",
34
+ "@applicaster/zapp-react-native-utils": "14.0.0-alpha.6242515303",
38
35
  "promise": "^8.3.0",
39
36
  "url": "^0.11.0",
40
37
  "uuid": "^3.3.2"