@applicaster/zapp-react-native-ui-components 13.0.0-alpha.1909212433 → 13.0.0-alpha.2178537102

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/FocusableTvOS";
5
+ import { Focusable } from "@applicaster/zapp-react-native-ui-components/Components/Focusable";
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";
@@ -3,6 +3,9 @@ import * as React from "react";
3
3
  import { BaseFocusable } from "../BaseFocusable";
4
4
  import { FocusableGroupContextProvider } from "../../Contexts/FocusableGroupContext";
5
5
  import { withFocusableContext } from "../../Contexts/FocusableGroupContext/withFocusableContext";
6
+ import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager";
7
+ import * as FOCUS_EVENTS from "@applicaster/zapp-react-native-utils/appUtils/focusManager/events";
8
+ import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
6
9
 
7
10
  type Props = {
8
11
  testID?: string;
@@ -19,6 +22,7 @@ type Props = {
19
22
  resetFocusToInitialValue?: boolean;
20
23
  onFocus?: () => void;
21
24
  onBlur?: () => void;
25
+ onGroupFocusChanged?: (event?: any) => void;
22
26
  onWillUpdateFocus?: (event?: any) => void;
23
27
  willReceiveFocus?: (event?: any) => void;
24
28
  onDidUpdateFocus?: (event?: any) => void;
@@ -73,6 +77,17 @@ class FocusableGroup extends BaseFocusable<Props> {
73
77
  return this.props.isWithMemory ?? true;
74
78
  }
75
79
 
80
+ /**
81
+ * indicates whether the Group focus changed
82
+ * @returns {Promise}
83
+ */
84
+ onGroupFocusChanged: FocusManager.FocusEventCB = (focusable) => {
85
+ const { onGroupFocusChanged = noop } = this.props;
86
+ onGroupFocusChanged(focusable);
87
+
88
+ focusManager.invokeHandler?.(FOCUS_EVENTS.GROUP_FOCUS_CHANGED, this);
89
+ };
90
+
76
91
  render() {
77
92
  const { children, id, style } = this.props;
78
93
  const focusableId = `focusable-group-${id}`;
@@ -11,13 +11,6 @@ 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
-
21
14
  export type Props = ScrollViewProps & {
22
15
  id?: number | string;
23
16
  horizontal?: boolean;
@@ -39,27 +32,17 @@ export type Props = ScrollViewProps & {
39
32
  initialFocusDirection?: FocusManager.Android.FocusNavigationDirections;
40
33
  onAllComponentsLoaded?: () => void;
41
34
  omitPropsPropagation?: Array<keyof FlatListProps<any>>;
42
- renderItem: FocusableScrollViewRenderItem;
35
+ renderItem: (info: {
36
+ item: ZappUIComponent;
37
+ index: number;
38
+ focused: boolean;
39
+ parentFocus: ParentFocus;
40
+ }) => React.ReactElement;
43
41
  } & ParentFocus;
44
42
 
45
43
  type State = boolean[];
46
44
  type Action = { index?: number; isFocusable: boolean; type?: string };
47
45
 
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
-
63
46
  const focusableStateReducer = (
64
47
  state: State,
65
48
  { index = null, isFocusable, type = null }: Action
@@ -90,7 +73,7 @@ const extendScrollViewRef = (_ref, childCompsMeasurementsMap) => {
90
73
  };
91
74
 
92
75
  _ref.scrollToIndex = (params) => {
93
- const { index, viewOffset = 0 } = params;
76
+ const { index, viewOffset } = params;
94
77
 
95
78
  const itemByIndex = R.find(R.propEq("index", index))(
96
79
  R.values(childCompsMeasurementsMap)
@@ -146,11 +129,8 @@ function FocusableScrollViewComponent(props: Props, ref) {
146
129
  );
147
130
 
148
131
  const getFocusableEntryId = React.useCallback(
149
- (_entry: ZappEntry | null, index?: number) => {
150
- const entry: { id?: string } = getEntry(
151
- R.isNil(index) ? _entry : data,
152
- index
153
- );
132
+ (_entry: ZappEntry, index?: number) => {
133
+ const entry = R.isNil(index) ? _entry : data[index];
154
134
 
155
135
  return entry ? `${props.id}--${entry?.id}` : undefined;
156
136
  },
@@ -293,18 +273,11 @@ function FocusableScrollViewComponent(props: Props, ref) {
293
273
  const renderItem = React.useCallback(
294
274
  (item, index) => {
295
275
  const renderArgs = { item, index };
296
-
297
- const id = getFocusableEntryId(
298
- Array.isArray(item) ? item[0] : item,
299
- index
300
- );
301
-
302
- const nextFocus = getNextFocus(index);
276
+ const id = `${props.id}--${renderArgs?.item?.id}`;
277
+ const nextFocus = getNextFocus(renderArgs?.index);
303
278
 
304
279
  const onItemLayout = (event) => {
305
- childCompsMeasurementsMap.current[
306
- Array.isArray(item) ? index : item.id
307
- ] = {
280
+ childCompsMeasurementsMap.current[item.id] = {
308
281
  index,
309
282
  layout: event.nativeEvent.layout,
310
283
  };
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.1909212433",
3
+ "version": "13.0.0-alpha.2178537102",
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": "13.0.0-alpha.1909212433",
38
- "@applicaster/zapp-react-native-bridge": "13.0.0-alpha.1909212433",
39
- "@applicaster/zapp-react-native-redux": "13.0.0-alpha.1909212433",
40
- "@applicaster/zapp-react-native-utils": "13.0.0-alpha.1909212433",
37
+ "@applicaster/applicaster-types": "13.0.0-alpha.2178537102",
38
+ "@applicaster/zapp-react-native-bridge": "13.0.0-alpha.2178537102",
39
+ "@applicaster/zapp-react-native-redux": "13.0.0-alpha.2178537102",
40
+ "@applicaster/zapp-react-native-utils": "13.0.0-alpha.2178537102",
41
41
  "promise": "^8.3.0",
42
42
  "react-router-native": "^5.1.2",
43
43
  "url": "^0.11.0",