@applicaster/zapp-react-native-ui-components 13.0.12 → 13.0.13-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.
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Focusable } from "@applicaster/zapp-react-native-ui-components/Components/Focusable/FocusableTvOS";
|
|
3
|
+
import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
4
|
+
|
|
5
|
+
type Props = {
|
|
6
|
+
id: string;
|
|
7
|
+
groupId: string;
|
|
8
|
+
isParallaxDisabled: boolean;
|
|
9
|
+
applyWrapper: boolean;
|
|
10
|
+
children: (focused: boolean) => React.ReactNode;
|
|
11
|
+
onFocus: (arg1: any, index?: number) => void;
|
|
12
|
+
onBlur: Callback;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const FocusableWrapper = ({
|
|
16
|
+
id,
|
|
17
|
+
groupId,
|
|
18
|
+
isParallaxDisabled,
|
|
19
|
+
children,
|
|
20
|
+
applyWrapper,
|
|
21
|
+
onFocus,
|
|
22
|
+
onBlur,
|
|
23
|
+
}: Props) => {
|
|
24
|
+
if (applyWrapper) {
|
|
25
|
+
return (
|
|
26
|
+
<Focusable
|
|
27
|
+
id={id}
|
|
28
|
+
groupId={groupId}
|
|
29
|
+
isParallaxDisabled={isParallaxDisabled}
|
|
30
|
+
onFocus={onFocus}
|
|
31
|
+
onBlur={onBlur}
|
|
32
|
+
willReceiveFocus={noop}
|
|
33
|
+
hasReceivedFocus={noop}
|
|
34
|
+
// @ts-ignore
|
|
35
|
+
offsetUpdater={noop}
|
|
36
|
+
isFocusable
|
|
37
|
+
>
|
|
38
|
+
{(focused) => children(focused)}
|
|
39
|
+
</Focusable>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return <>{children(false)}</>;
|
|
44
|
+
};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import * as R from "ramda";
|
|
3
3
|
import { View, StyleSheet } from "react-native";
|
|
4
|
+
import { first, filter } from "rxjs/operators";
|
|
5
|
+
|
|
6
|
+
import { compose } from "@applicaster/zapp-react-native-utils/utils";
|
|
4
7
|
|
|
5
8
|
import { Focusable } from "@applicaster/zapp-react-native-ui-components/Components/Focusable/FocusableTvOS";
|
|
6
9
|
import { FocusableCell } from "@applicaster/zapp-react-native-ui-components/Components/FocusableCell";
|
|
@@ -9,7 +12,11 @@ import { SCREEN_TYPES } from "@applicaster/zapp-react-native-utils/navigationUti
|
|
|
9
12
|
import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager";
|
|
10
13
|
import { sendSelectCellEvent } from "@applicaster/zapp-react-native-utils/analyticsUtils";
|
|
11
14
|
import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
15
|
+
import { toBooleanWithDefaultTrue } from "@applicaster/zapp-react-native-utils/booleanUtils";
|
|
12
16
|
import { CellWithFocusable } from "./CellWithFocusable";
|
|
17
|
+
import { FocusableWrapper } from "./FocusableWrapper";
|
|
18
|
+
|
|
19
|
+
import { focusableButtonsRegistration$ } from "@applicaster/zapp-react-native-utils/appUtils/focusManagerAux/utils/utils.ios";
|
|
13
20
|
|
|
14
21
|
type Props = {
|
|
15
22
|
item: ZappEntry;
|
|
@@ -66,6 +73,8 @@ type Props = {
|
|
|
66
73
|
shouldUpdate: boolean;
|
|
67
74
|
behavior: Behavior;
|
|
68
75
|
componentsMapOffset: number;
|
|
76
|
+
applyFocusableWrapper: boolean;
|
|
77
|
+
hasFocusableInside: boolean;
|
|
69
78
|
};
|
|
70
79
|
|
|
71
80
|
type State = {
|
|
@@ -82,7 +91,7 @@ const baseCellStyles = {
|
|
|
82
91
|
flex: 1,
|
|
83
92
|
} as const;
|
|
84
93
|
|
|
85
|
-
|
|
94
|
+
class TvOSCell extends React.Component<Props, State> {
|
|
86
95
|
cell: any;
|
|
87
96
|
target: any;
|
|
88
97
|
layout: any;
|
|
@@ -239,6 +248,8 @@ export class TvOSCellComponent extends React.Component<Props, State> {
|
|
|
239
248
|
groupId,
|
|
240
249
|
isFocusable,
|
|
241
250
|
behavior,
|
|
251
|
+
applyFocusableWrapper,
|
|
252
|
+
hasFocusableInside,
|
|
242
253
|
} = this.props;
|
|
243
254
|
|
|
244
255
|
const { id } = item;
|
|
@@ -254,24 +265,33 @@ export class TvOSCellComponent extends React.Component<Props, State> {
|
|
|
254
265
|
this.onFocus(arg1, index);
|
|
255
266
|
};
|
|
256
267
|
|
|
257
|
-
const hasFocusableInside = CellRenderer.hasFocusableInside?.(item);
|
|
258
|
-
|
|
259
268
|
if (hasFocusableInside) {
|
|
260
269
|
return (
|
|
261
270
|
<View onLayout={this.onLayout}>
|
|
262
|
-
<
|
|
263
|
-
CellRenderer={CellRenderer}
|
|
264
|
-
item={item}
|
|
271
|
+
<FocusableWrapper
|
|
265
272
|
id={focusableId}
|
|
266
|
-
groupId={(groupId || component?.id)
|
|
273
|
+
groupId={String(groupId || component?.id)}
|
|
274
|
+
isParallaxDisabled={this.layout?.width > 1740}
|
|
267
275
|
onFocus={handleFocus}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
276
|
+
onBlur={onBlur || this.onBlur}
|
|
277
|
+
applyWrapper={applyFocusableWrapper}
|
|
278
|
+
>
|
|
279
|
+
{(focused) => (
|
|
280
|
+
<CellWithFocusable
|
|
281
|
+
CellRenderer={CellRenderer}
|
|
282
|
+
item={item}
|
|
283
|
+
id={focusableId}
|
|
284
|
+
groupId={(groupId || component?.id).toString()}
|
|
285
|
+
onFocus={handleFocus}
|
|
286
|
+
index={index}
|
|
287
|
+
scrollTo={this.scrollTo}
|
|
288
|
+
preferredFocus={preferredFocus}
|
|
289
|
+
focused={focused || this.props.focused}
|
|
290
|
+
behavior={behavior}
|
|
291
|
+
isFocusable={isFocusable}
|
|
292
|
+
/>
|
|
293
|
+
)}
|
|
294
|
+
</FocusableWrapper>
|
|
275
295
|
</View>
|
|
276
296
|
);
|
|
277
297
|
}
|
|
@@ -309,3 +329,49 @@ export class TvOSCellComponent extends React.Component<Props, State> {
|
|
|
309
329
|
);
|
|
310
330
|
}
|
|
311
331
|
}
|
|
332
|
+
|
|
333
|
+
export function withFocusableWrapperHOC(Component) {
|
|
334
|
+
return function WrappedComponent(props: Props) {
|
|
335
|
+
const [focusableViewIsRendered, setFocusableViewIsRendered] =
|
|
336
|
+
React.useState(false);
|
|
337
|
+
|
|
338
|
+
const { CellRenderer, item, groupId, component } = props;
|
|
339
|
+
|
|
340
|
+
const focusableGroupId = String(groupId || component?.id);
|
|
341
|
+
|
|
342
|
+
const hasFocusableInside = CellRenderer.hasFocusableInside?.(item);
|
|
343
|
+
|
|
344
|
+
const isFocusable = toBooleanWithDefaultTrue(props?.isFocusable);
|
|
345
|
+
|
|
346
|
+
React.useEffect(() => {
|
|
347
|
+
// start waiting any first registration of FocusableButton inside this focusableGroup
|
|
348
|
+
// after it we could get rid of applying focusable-wrapper
|
|
349
|
+
const subscription = focusableButtonsRegistration$(focusableGroupId)
|
|
350
|
+
.pipe(
|
|
351
|
+
filter(() => isFocusable),
|
|
352
|
+
first()
|
|
353
|
+
)
|
|
354
|
+
.subscribe(() => {
|
|
355
|
+
setFocusableViewIsRendered(true);
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
return () => {
|
|
359
|
+
subscription.unsubscribe();
|
|
360
|
+
};
|
|
361
|
+
}, [isFocusable, focusableGroupId]);
|
|
362
|
+
|
|
363
|
+
const applyFocusableWrapper = React.useMemo(() => {
|
|
364
|
+
return isFocusable && hasFocusableInside && !focusableViewIsRendered;
|
|
365
|
+
}, [isFocusable, hasFocusableInside, focusableViewIsRendered]);
|
|
366
|
+
|
|
367
|
+
return (
|
|
368
|
+
<Component
|
|
369
|
+
{...props}
|
|
370
|
+
applyFocusableWrapper={applyFocusableWrapper}
|
|
371
|
+
hasFocusableInside={hasFocusableInside}
|
|
372
|
+
/>
|
|
373
|
+
);
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
export const TvOSCellComponent = compose(withFocusableWrapperHOC)(TvOSCell);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`<Screen Component /> when the navbar should be hidden renders correctly 1`] = `
|
|
4
4
|
<View
|
|
5
|
+
importantForAccessibility="yes"
|
|
5
6
|
style={
|
|
6
7
|
{
|
|
7
8
|
"backgroundColor": "blue",
|
|
@@ -34,6 +35,7 @@ exports[`<Screen Component /> when the navbar should be hidden renders correctly
|
|
|
34
35
|
|
|
35
36
|
exports[`<Screen Component /> when the navbar should show renders correctly 1`] = `
|
|
36
37
|
<View
|
|
38
|
+
importantForAccessibility="yes"
|
|
37
39
|
style={
|
|
38
40
|
{
|
|
39
41
|
"backgroundColor": "blue",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="@applicaster/applicaster-types" />
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { View } from "react-native";
|
|
3
|
+
import { AccessibilityInfo, findNodeHandle, View } from "react-native";
|
|
4
4
|
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
5
5
|
|
|
6
6
|
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
useRoute,
|
|
18
18
|
useScreenData,
|
|
19
19
|
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
20
|
+
import { useIsScreenActive } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
|
|
20
21
|
import { getNavigationPluginModule } from "@applicaster/zapp-react-native-app/App/Layout/layoutHelpers";
|
|
21
22
|
|
|
22
23
|
import { RouteManager } from "../RouteManager";
|
|
@@ -57,8 +58,8 @@ export function Screen(_props: Props) {
|
|
|
57
58
|
const hasMenu = shouldNavBarDisplayMenu(currentRiver, plugins);
|
|
58
59
|
|
|
59
60
|
const navBarProps = React.useMemo<MobileNavBarPluginProps | null>(
|
|
60
|
-
getNavBarProps(currentRiver, pathname, title),
|
|
61
|
-
[currentRiver, pathname]
|
|
61
|
+
() => getNavBarProps(currentRiver, pathname, title),
|
|
62
|
+
[currentRiver, pathname, title]
|
|
62
63
|
);
|
|
63
64
|
|
|
64
65
|
const NavBar = React.useMemo(
|
|
@@ -89,13 +90,29 @@ export function Screen(_props: Props) {
|
|
|
89
90
|
[theme.app_background_color, backgroundColor]
|
|
90
91
|
);
|
|
91
92
|
|
|
92
|
-
|
|
93
|
+
const isActive = useIsScreenActive();
|
|
94
|
+
|
|
95
|
+
const ref = React.useRef(null);
|
|
93
96
|
const isReady = useWaitForValidOrientation();
|
|
94
97
|
|
|
98
|
+
React.useEffect(() => {
|
|
99
|
+
if (ref.current && isActive && isReady) {
|
|
100
|
+
const nodeHandle = findNodeHandle(ref.current);
|
|
101
|
+
|
|
102
|
+
if (nodeHandle != null) {
|
|
103
|
+
AccessibilityInfo.setAccessibilityFocus(nodeHandle);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}, [isActive, isReady]);
|
|
107
|
+
|
|
95
108
|
// We prevent rendering of the screen until UI is actually rotated to screen desired orientation.
|
|
96
109
|
// This saves unnecessary re-renders and user will not see distorted aspect screen.
|
|
97
110
|
return (
|
|
98
|
-
<View
|
|
111
|
+
<View
|
|
112
|
+
ref={ref}
|
|
113
|
+
style={style}
|
|
114
|
+
importantForAccessibility={!isActive ? "no-hide-descendants" : "yes"}
|
|
115
|
+
>
|
|
99
116
|
{isReady ? (
|
|
100
117
|
<>
|
|
101
118
|
{navBarProps ? <NavBar {...navBarProps} hasMenu={hasMenu} /> : null}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-ui-components",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.0.13-rc.0",
|
|
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",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"redux-mock-store": "^1.5.3"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@applicaster/applicaster-types": "13.0.
|
|
35
|
-
"@applicaster/zapp-react-native-bridge": "13.0.
|
|
36
|
-
"@applicaster/zapp-react-native-redux": "13.0.
|
|
37
|
-
"@applicaster/zapp-react-native-utils": "13.0.
|
|
34
|
+
"@applicaster/applicaster-types": "13.0.13-rc.0",
|
|
35
|
+
"@applicaster/zapp-react-native-bridge": "13.0.13-rc.0",
|
|
36
|
+
"@applicaster/zapp-react-native-redux": "13.0.13-rc.0",
|
|
37
|
+
"@applicaster/zapp-react-native-utils": "13.0.13-rc.0",
|
|
38
38
|
"promise": "^8.3.0",
|
|
39
39
|
"react-router-native": "^5.1.2",
|
|
40
40
|
"url": "^0.11.0",
|