@applicaster/zapp-react-native-ui-components 12.0.2-rc.0 → 13.0.0-alpha.1839726411
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";
|
|
@@ -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,12 +39,7 @@ 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[];
|
|
@@ -73,7 +75,7 @@ const extendScrollViewRef = (_ref, childCompsMeasurementsMap) => {
|
|
|
73
75
|
};
|
|
74
76
|
|
|
75
77
|
_ref.scrollToIndex = (params) => {
|
|
76
|
-
const { index, viewOffset } = params;
|
|
78
|
+
const { index, viewOffset = 0 } = params;
|
|
77
79
|
|
|
78
80
|
const itemByIndex = R.find(R.propEq("index", index))(
|
|
79
81
|
R.values(childCompsMeasurementsMap)
|
|
@@ -129,8 +131,14 @@ function FocusableScrollViewComponent(props: Props, ref) {
|
|
|
129
131
|
);
|
|
130
132
|
|
|
131
133
|
const getFocusableEntryId = React.useCallback(
|
|
132
|
-
(_entry: ZappEntry, index?: number) => {
|
|
133
|
-
const entry = R.isNil(index)
|
|
134
|
+
(_entry: ZappEntry | null, index?: number) => {
|
|
135
|
+
const entry = R.isNil(index)
|
|
136
|
+
? Array.isArray(_entry)
|
|
137
|
+
? _entry[0]
|
|
138
|
+
: _entry
|
|
139
|
+
: Array.isArray(data[index])
|
|
140
|
+
? data[index][0]
|
|
141
|
+
: data[index];
|
|
134
142
|
|
|
135
143
|
return entry ? `${props.id}--${entry?.id}` : undefined;
|
|
136
144
|
},
|
|
@@ -273,11 +281,18 @@ function FocusableScrollViewComponent(props: Props, ref) {
|
|
|
273
281
|
const renderItem = React.useCallback(
|
|
274
282
|
(item, index) => {
|
|
275
283
|
const renderArgs = { item, index };
|
|
276
|
-
|
|
277
|
-
const
|
|
284
|
+
|
|
285
|
+
const id = getFocusableEntryId(
|
|
286
|
+
Array.isArray(item) ? item[0] : item,
|
|
287
|
+
index
|
|
288
|
+
);
|
|
289
|
+
|
|
290
|
+
const nextFocus = getNextFocus(index);
|
|
278
291
|
|
|
279
292
|
const onItemLayout = (event) => {
|
|
280
|
-
childCompsMeasurementsMap.current[
|
|
293
|
+
childCompsMeasurementsMap.current[
|
|
294
|
+
Array.isArray(item) ? index : item.id
|
|
295
|
+
] = {
|
|
281
296
|
index,
|
|
282
297
|
layout: event.nativeEvent.layout,
|
|
283
298
|
};
|
package/README.md
CHANGED
|
@@ -78,17 +78,6 @@ export default MyAwesomeComponent;
|
|
|
78
78
|
export { MyAwesomeComponent } from "./MyAwesomeComponent";
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
-
We provide flow types for component props - please use it to make sure your component will be compliant
|
|
82
|
-
|
|
83
|
-
```javascript
|
|
84
|
-
import * as React from "react";
|
|
85
|
-
import type { ZappComponentProps } from "../../flow-types"; // in the root of the project
|
|
86
|
-
|
|
87
|
-
export class MyComponent extends React.Component<ZappComponentProps> {
|
|
88
|
-
/* ... */
|
|
89
|
-
}
|
|
90
|
-
```
|
|
91
|
-
|
|
92
81
|
## Connecting my component to Zapp Pipes
|
|
93
82
|
|
|
94
83
|
Zapp App components rely on [Zapp-Pipes](https://github.com/applicaster/zapp-pipes) to load data.
|
|
@@ -100,10 +89,9 @@ In order to connect your component to ZappPipes, you simply need to use the `Zap
|
|
|
100
89
|
import * as React from "react";
|
|
101
90
|
import { View, Text } from "react-native";
|
|
102
91
|
import { zappPipesDataConnector } from "../ZappPipesDataConnector";
|
|
103
|
-
import type { ZappComponentProps } from "../../flow-types";
|
|
104
92
|
|
|
105
93
|
@zappPipesDataConnector
|
|
106
|
-
export class MyComponent extends React.Component
|
|
94
|
+
export class MyComponent extends React.Component {
|
|
107
95
|
renderComponent = (data) => {
|
|
108
96
|
return (
|
|
109
97
|
<View>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-ui-components",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.0-alpha.1839726411",
|
|
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,10 +34,10 @@
|
|
|
34
34
|
"redux-mock-store": "^1.5.3"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@applicaster/applicaster-types": "
|
|
38
|
-
"@applicaster/zapp-react-native-bridge": "
|
|
39
|
-
"@applicaster/zapp-react-native-redux": "
|
|
40
|
-
"@applicaster/zapp-react-native-utils": "
|
|
37
|
+
"@applicaster/applicaster-types": "13.0.0-alpha.1839726411",
|
|
38
|
+
"@applicaster/zapp-react-native-bridge": "13.0.0-alpha.1839726411",
|
|
39
|
+
"@applicaster/zapp-react-native-redux": "13.0.0-alpha.1839726411",
|
|
40
|
+
"@applicaster/zapp-react-native-utils": "13.0.0-alpha.1839726411",
|
|
41
41
|
"promise": "^8.3.0",
|
|
42
42
|
"react-router-native": "^5.1.2",
|
|
43
43
|
"url": "^0.11.0",
|