@applicaster/zapp-react-native-ui-components 13.0.0-alpha.1102149799 → 13.0.0-alpha.1338463240
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.
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import * as R from "ramda";
|
|
3
3
|
import { View, StyleSheet } from "react-native";
|
|
4
4
|
|
|
5
|
-
import { Focusable } from "@applicaster/zapp-react-native-ui-components/Components/Focusable";
|
|
5
|
+
import { Focusable } from "@applicaster/zapp-react-native-ui-components/Components/Focusable/FocusableTvOS";
|
|
6
6
|
import { FocusableCell } from "@applicaster/zapp-react-native-ui-components/Components/FocusableCell";
|
|
7
7
|
import { getItemType } from "@applicaster/zapp-react-native-utils/navigationUtils";
|
|
8
8
|
import { SCREEN_TYPES } from "@applicaster/zapp-react-native-utils/navigationUtils/itemTypes";
|
|
@@ -251,7 +251,7 @@ export class TvOSCellComponent extends React.Component<Props, State> {
|
|
|
251
251
|
|
|
252
252
|
const focusableId = R.join("-", [component?.id, id, index]);
|
|
253
253
|
|
|
254
|
-
const handleFocus = (arg1: any, index
|
|
254
|
+
const handleFocus = (arg1: any, index?: number) => {
|
|
255
255
|
const focusFn = onFocus || noop;
|
|
256
256
|
focusFn(arg1, index);
|
|
257
257
|
|
|
@@ -284,7 +284,7 @@ export class TvOSCellComponent extends React.Component<Props, State> {
|
|
|
284
284
|
<View onLayout={this.onLayout} style={styles.container}>
|
|
285
285
|
<Focusable
|
|
286
286
|
id={focusableId}
|
|
287
|
-
groupId={groupId || component?.id}
|
|
287
|
+
groupId={(groupId || component?.id).toString()}
|
|
288
288
|
onFocus={handleFocus}
|
|
289
289
|
onBlur={onBlur || this.onBlur}
|
|
290
290
|
isParallaxDisabled={this.layout?.width > 1740}
|
|
@@ -303,7 +303,7 @@ export class TvOSCellComponent extends React.Component<Props, State> {
|
|
|
303
303
|
index,
|
|
304
304
|
CellRenderer,
|
|
305
305
|
item,
|
|
306
|
-
focused: this.props.focused || selectedCell || focused,
|
|
306
|
+
focused: !!(this.props.focused || selectedCell || focused),
|
|
307
307
|
scrollTo: this.scrollTo,
|
|
308
308
|
behavior,
|
|
309
309
|
}}
|
|
@@ -16,6 +16,8 @@ function noop() {}
|
|
|
16
16
|
type Props = {
|
|
17
17
|
id: string;
|
|
18
18
|
groupId: string;
|
|
19
|
+
willReceiveFocus?: (nativeEvent: React.SyntheticEvent) => void;
|
|
20
|
+
hasReceivedFocus?: (nativeEvent: React.SyntheticEvent) => void;
|
|
19
21
|
onPress?: (nativeEvent: React.SyntheticEvent) => void;
|
|
20
22
|
onFocus?: (nativeEvent: React.SyntheticEvent) => void;
|
|
21
23
|
onBlur?: (nativeEvent: React.SyntheticEvent) => void;
|
|
@@ -35,6 +37,8 @@ type Props = {
|
|
|
35
37
|
forceFocus?: boolean;
|
|
36
38
|
initialFocus?: boolean;
|
|
37
39
|
onLayout?: (e: any) => void;
|
|
40
|
+
offsetUpdater: (arg1: string, arg2: number) => number;
|
|
41
|
+
style: any;
|
|
38
42
|
};
|
|
39
43
|
|
|
40
44
|
export class Focusable extends BaseFocusable<Props> {
|
|
@@ -15,6 +15,7 @@ import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
|
15
15
|
|
|
16
16
|
import { useParentFocus, useCheckItemIdsForUnique } from "./hooks";
|
|
17
17
|
import { FocusableListItemWrapper } from "./FocusableListItemWrapper";
|
|
18
|
+
import { FocusableScrollView } from "../FocusableScrollView";
|
|
18
19
|
|
|
19
20
|
const mapIndexed = R.addIndex(R.map);
|
|
20
21
|
|
|
@@ -54,6 +55,7 @@ export type Props<ItemT> = FlatListProps<ItemT> & {
|
|
|
54
55
|
disableNextFocusUp?: boolean;
|
|
55
56
|
disableNextFocusLeft?: boolean;
|
|
56
57
|
disableNextFocusRight?: boolean;
|
|
58
|
+
useScrollView?: boolean;
|
|
57
59
|
} & ParentFocus;
|
|
58
60
|
|
|
59
61
|
function FocusableListComponent<ItemT>(props: Props<ItemT>, ref) {
|
|
@@ -89,6 +91,7 @@ function FocusableListComponent<ItemT>(props: Props<ItemT>, ref) {
|
|
|
89
91
|
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
90
92
|
onAllComponentsLoaded, // TODO: re-implement it
|
|
91
93
|
omitPropsPropagation = [],
|
|
94
|
+
useScrollView = false,
|
|
92
95
|
} = props;
|
|
93
96
|
|
|
94
97
|
useCheckItemIdsForUnique({ componentId: props.id, items: data });
|
|
@@ -274,6 +277,7 @@ function FocusableListComponent<ItemT>(props: Props<ItemT>, ref) {
|
|
|
274
277
|
"initialFocusDirection",
|
|
275
278
|
"withStateMemory",
|
|
276
279
|
"useSequentialLoading",
|
|
280
|
+
"useScrollView",
|
|
277
281
|
...omitPropsPropagation,
|
|
278
282
|
],
|
|
279
283
|
R.__
|
|
@@ -296,15 +300,27 @@ function FocusableListComponent<ItemT>(props: Props<ItemT>, ref) {
|
|
|
296
300
|
return (
|
|
297
301
|
// @ts-ignore
|
|
298
302
|
<ChildrenFocusDeactivatorView flex={1}>
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
303
|
+
{useScrollView ? (
|
|
304
|
+
<FocusableScrollView
|
|
305
|
+
ref={ref}
|
|
306
|
+
{...getFlatListProps(props)}
|
|
307
|
+
onEndReached={onEndReached}
|
|
308
|
+
initialNumToRender={initialNumToRender}
|
|
309
|
+
renderItem={renderItem}
|
|
310
|
+
focused={focused}
|
|
311
|
+
data={data}
|
|
312
|
+
/>
|
|
313
|
+
) : (
|
|
314
|
+
<FlatList
|
|
315
|
+
focusable={false}
|
|
316
|
+
scrollEnabled={false}
|
|
317
|
+
ref={ref}
|
|
318
|
+
{...getFlatListProps(props)}
|
|
319
|
+
renderItem={renderItem}
|
|
320
|
+
onEndReached={onEndReached}
|
|
321
|
+
initialNumToRender={initialNumToRender}
|
|
322
|
+
/>
|
|
323
|
+
)}
|
|
308
324
|
</ChildrenFocusDeactivatorView>
|
|
309
325
|
);
|
|
310
326
|
}
|
|
@@ -11,6 +11,13 @@ import {
|
|
|
11
11
|
useInitialFocus,
|
|
12
12
|
} from "@applicaster/zapp-react-native-utils/focusManager";
|
|
13
13
|
|
|
14
|
+
export type FocusableScrollViewRenderItem = (info: {
|
|
15
|
+
item: ZappUIComponent;
|
|
16
|
+
index: number;
|
|
17
|
+
focused: boolean;
|
|
18
|
+
parentFocus: ParentFocus;
|
|
19
|
+
}) => React.ReactElement;
|
|
20
|
+
|
|
14
21
|
export type Props = ScrollViewProps & {
|
|
15
22
|
id?: number | string;
|
|
16
23
|
horizontal?: boolean;
|
|
@@ -32,17 +39,27 @@ export type Props = ScrollViewProps & {
|
|
|
32
39
|
initialFocusDirection?: FocusManager.Android.FocusNavigationDirections;
|
|
33
40
|
onAllComponentsLoaded?: () => void;
|
|
34
41
|
omitPropsPropagation?: Array<keyof FlatListProps<any>>;
|
|
35
|
-
renderItem:
|
|
36
|
-
item: ZappUIComponent;
|
|
37
|
-
index: number;
|
|
38
|
-
focused: boolean;
|
|
39
|
-
parentFocus: ParentFocus;
|
|
40
|
-
}) => React.ReactElement;
|
|
42
|
+
renderItem: FocusableScrollViewRenderItem;
|
|
41
43
|
} & ParentFocus;
|
|
42
44
|
|
|
43
45
|
type State = boolean[];
|
|
44
46
|
type Action = { index?: number; isFocusable: boolean; type?: string };
|
|
45
47
|
|
|
48
|
+
const unwrapArray = (maybeArray) =>
|
|
49
|
+
Array.isArray(maybeArray) ? maybeArray[0] : maybeArray;
|
|
50
|
+
|
|
51
|
+
function getEntry<T>(data: T | T[], index: unknown): T {
|
|
52
|
+
let entry;
|
|
53
|
+
|
|
54
|
+
if (R.isNil(index)) {
|
|
55
|
+
entry = unwrapArray(data);
|
|
56
|
+
} else if (typeof index === "number") {
|
|
57
|
+
entry = unwrapArray(data[index]);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return entry;
|
|
61
|
+
}
|
|
62
|
+
|
|
46
63
|
const focusableStateReducer = (
|
|
47
64
|
state: State,
|
|
48
65
|
{ index = null, isFocusable, type = null }: Action
|
|
@@ -73,7 +90,7 @@ const extendScrollViewRef = (_ref, childCompsMeasurementsMap) => {
|
|
|
73
90
|
};
|
|
74
91
|
|
|
75
92
|
_ref.scrollToIndex = (params) => {
|
|
76
|
-
const { index, viewOffset } = params;
|
|
93
|
+
const { index, viewOffset = 0 } = params;
|
|
77
94
|
|
|
78
95
|
const itemByIndex = R.find(R.propEq("index", index))(
|
|
79
96
|
R.values(childCompsMeasurementsMap)
|
|
@@ -129,8 +146,11 @@ function FocusableScrollViewComponent(props: Props, ref) {
|
|
|
129
146
|
);
|
|
130
147
|
|
|
131
148
|
const getFocusableEntryId = React.useCallback(
|
|
132
|
-
(_entry: ZappEntry, index?: number) => {
|
|
133
|
-
const entry
|
|
149
|
+
(_entry: ZappEntry | null, index?: number) => {
|
|
150
|
+
const entry: { id?: string } = getEntry(
|
|
151
|
+
R.isNil(index) ? _entry : data,
|
|
152
|
+
index
|
|
153
|
+
);
|
|
134
154
|
|
|
135
155
|
return entry ? `${props.id}--${entry?.id}` : undefined;
|
|
136
156
|
},
|
|
@@ -273,11 +293,18 @@ function FocusableScrollViewComponent(props: Props, ref) {
|
|
|
273
293
|
const renderItem = React.useCallback(
|
|
274
294
|
(item, index) => {
|
|
275
295
|
const renderArgs = { item, index };
|
|
276
|
-
|
|
277
|
-
const
|
|
296
|
+
|
|
297
|
+
const id = getFocusableEntryId(
|
|
298
|
+
Array.isArray(item) ? item[0] : item,
|
|
299
|
+
index
|
|
300
|
+
);
|
|
301
|
+
|
|
302
|
+
const nextFocus = getNextFocus(index);
|
|
278
303
|
|
|
279
304
|
const onItemLayout = (event) => {
|
|
280
|
-
childCompsMeasurementsMap.current[
|
|
305
|
+
childCompsMeasurementsMap.current[
|
|
306
|
+
Array.isArray(item) ? index : item.id
|
|
307
|
+
] = {
|
|
281
308
|
index,
|
|
282
309
|
layout: event.nativeEvent.layout,
|
|
283
310
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-ui-components",
|
|
3
|
-
"version": "13.0.0-alpha.
|
|
3
|
+
"version": "13.0.0-alpha.1338463240",
|
|
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",
|
|
@@ -34,26 +34,20 @@
|
|
|
34
34
|
"redux-mock-store": "^1.5.3"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@applicaster/applicaster-types": "13.0.0-alpha.
|
|
38
|
-
"@applicaster/zapp-react-native-bridge": "13.0.0-alpha.
|
|
39
|
-
"@applicaster/zapp-react-native-redux": "13.0.0-alpha.
|
|
40
|
-
"@applicaster/zapp-react-native-utils": "13.0.0-alpha.
|
|
37
|
+
"@applicaster/applicaster-types": "13.0.0-alpha.1338463240",
|
|
38
|
+
"@applicaster/zapp-react-native-bridge": "13.0.0-alpha.1338463240",
|
|
39
|
+
"@applicaster/zapp-react-native-redux": "13.0.0-alpha.1338463240",
|
|
40
|
+
"@applicaster/zapp-react-native-utils": "13.0.0-alpha.1338463240",
|
|
41
41
|
"promise": "^8.3.0",
|
|
42
42
|
"react-router-native": "^5.1.2",
|
|
43
43
|
"url": "^0.11.0",
|
|
44
44
|
"uuid": "^3.3.2"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@applicaster/zapp-pipes-v2-client": "*",
|
|
48
47
|
"@react-native-community/netinfo": "*",
|
|
49
|
-
"@types/node": "*",
|
|
50
|
-
"immer": "*",
|
|
51
48
|
"react": "17.0.2",
|
|
52
49
|
"react-native": "0.68.6",
|
|
53
50
|
"react-native-safe-area-context": "*",
|
|
54
|
-
"react-native-svg": "*"
|
|
55
|
-
"uglify-js": "*",
|
|
56
|
-
"validate-color": "*",
|
|
57
|
-
"zustand": "*"
|
|
51
|
+
"react-native-svg": "*"
|
|
58
52
|
}
|
|
59
53
|
}
|