@applicaster/zapp-react-native-ui-components 13.0.0-alpha.1909212433 → 13.0.0-alpha.1952415373
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.
- package/Components/AppContainer/__tests__/__snapshots__/AppContainer.test.js.snap +1 -1
- package/Components/AudioPlayer/__tests__/__snapshots__/Runtime.test.js.snap +4 -4
- package/Components/AudioPlayer/__tests__/__snapshots__/artWork.test.js.snap +3 -3
- package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +6 -6
- package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayerLayout.test.js.snap +7 -7
- package/Components/AudioPlayer/__tests__/__snapshots__/channel.test.js.snap +3 -3
- package/Components/AudioPlayer/__tests__/__snapshots__/summary.test.js.snap +2 -2
- package/Components/AudioPlayer/__tests__/__snapshots__/title.test.js.snap +2 -2
- package/Components/BaseFocusable/index.ios.ts +1 -1
- package/Components/BaseFocusable/index.tsx +66 -29
- package/Components/Cell/Cell.tsx +14 -9
- package/Components/Cell/CellWithFocusable.ios.tsx +126 -0
- package/Components/Cell/CellWithFocusable.tsx +44 -60
- package/Components/Cell/TvOSCellComponent.tsx +4 -9
- package/Components/Cell/__tests__/CellWIthFocusable.test.js +13 -6
- package/Components/CellRendererResolver/__tests__/__snapshots__/cellRendererResolver.test.js.snap +20 -20
- package/Components/CellRendererResolver/__tests__/cellRendererResolver.test.js +5 -3
- package/Components/ComponentResolver/__tests__/__snapshots__/componentResolver.test.js.snap +5 -5
- package/Components/ComponentResolver/__tests__/componentResolver.test.js +11 -9
- package/Components/DisplayState/__tests__/__snapshots__/displayState.test.js.snap +2 -2
- package/Components/Focusable/Focusable.tsx +0 -54
- package/Components/Focusable/FocusableTvOS.tsx +1 -1
- package/Components/Focusable/Touchable.tsx +19 -20
- package/Components/FocusableList/index.tsx +0 -1
- package/Components/FocusableScrollView/index.tsx +12 -39
- package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +76 -7
- package/Components/GeneralContentScreen/utils/useCurationAPI.ts +53 -9
- package/Components/Layout/TV/__tests__/ScreenContainer.test.tsx +1 -0
- package/Components/Layout/TV/__tests__/__snapshots__/LayoutContainer.test.tsx.snap +1 -1
- package/Components/Layout/TV/__tests__/__snapshots__/NavBarContainer.test.tsx.snap +3 -3
- package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +9 -9
- package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +1 -1
- package/Components/Layout/TV/__tests__/index.test.tsx +7 -3
- package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx +66 -0
- package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +4 -1
- package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +6 -12
- package/Components/MasterCell/DefaultComponents/ImageBorderContainer/__tests__/index.test.ts +93 -0
- package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +3 -3
- package/Components/MasterCell/DefaultComponents/SecondaryImage/utils.ts +1 -1
- package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
- package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/__snapshots__/index.test.tsx.snap +1 -1
- package/Components/MasterCell/__tests__/__snapshots__/dataAdapter.test.js.snap +180 -180
- package/Components/MasterCell/__tests__/__snapshots__/elementMapper.test.js.snap +7 -7
- package/Components/MasterCell/__tests__/__snapshots__/masterCell.test.js.snap +34 -34
- package/Components/MasterCell/hooks/useAsyncRendering/MasterCellAsyncRenderManager.ts +2 -2
- package/Components/MasterCell/hooks/useAsyncRendering/index.ts +2 -2
- package/Components/MasterCell/utils/index.ts +1 -1
- package/Components/ModalComponent/Header/index.tsx +3 -3
- package/Components/NativeFocusables/{index.js → index.ts} +4 -2
- package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +7 -7
- package/Components/OfflineHandler/__tests__/index.test.tsx +28 -25
- package/Components/PlayerContainer/PlayerContainer.tsx +5 -11
- package/Components/PlayerContainer/PlayerContainerContext.tsx +9 -0
- package/Components/River/ComponentsMap/ComponentsMap.tsx +39 -65
- package/Components/River/ComponentsMap/hooks/useLoadingState.ts +78 -51
- package/Components/River/RefreshControl.tsx +1 -1
- package/Components/River/RiverFooter.tsx +39 -9
- package/Components/River/RiverItem.tsx +37 -2
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +114 -45
- package/Components/River/__tests__/__snapshots__/river.test.js.snap +12 -12
- package/Components/River/__tests__/componentsMap.test.js +64 -17
- package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +1 -1
- package/Components/RouteManager/__tests__/__snapshots__/testId.test.js.snap +1 -1
- package/Components/Screen/__tests__/Screen.test.tsx +41 -27
- package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +4 -4
- package/Components/Screen/hooks.ts +56 -0
- package/Components/Screen/index.tsx +13 -39
- package/Components/ScreenResolver/__tests__/__snapshots__/screenResolver.test.js.snap +2 -2
- package/Components/ScreenResolver/__tests__/screenResolver.test.js +31 -27
- package/Components/Tabs/Tab.tsx +7 -6
- package/Components/TextInputTv/__tests__/TextInputTv.test.js +42 -42
- package/Components/TextInputTv/__tests__/__snapshots__/TextInputTv.test.js.snap +7 -0
- package/Components/TextInputTv/index.tsx +4 -4
- package/Components/Touchable/__tests__/__snapshots__/touchable.test.tsx.snap +2 -2
- package/Components/Transitioner/AnimationManager.js +8 -8
- package/Components/Transitioner/Scene.tsx +52 -23
- package/Components/Transitioner/__tests__/__snapshots__/AnimationManager.test.js.snap +26 -26
- package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +62 -46
- package/Components/Transitioner/__tests__/__snapshots__/config.test.js.snap +20 -20
- package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +4 -4
- package/Components/Transitioner/index.js +8 -4
- package/Components/VideoLive/LiveImageManager.ts +27 -1
- package/Components/VideoLive/PlayerLiveImageComponent.tsx +29 -21
- package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +63 -8
- package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +5 -10
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +5 -1
- package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +5 -1
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +8 -7
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +6 -13
- package/Components/VideoModal/ModalAnimation/index.ts +2 -1
- package/Components/VideoModal/ModalAnimation/useModalAnimationContext.ts +6 -0
- package/Components/VideoModal/ModalAnimation/utils.ts +2 -2
- package/Components/VideoModal/OpaqueLayer.tsx +33 -0
- package/Components/VideoModal/PlayerWrapper.tsx +16 -35
- package/Components/VideoModal/VideoModal.tsx +14 -23
- package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +5 -2
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +13 -10
- package/Components/VideoModal/__tests__/__snapshots__/PlayerDetails.test.tsx.snap +4 -4
- package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +66 -156
- package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +89 -0
- package/Components/VideoModal/hooks/index.ts +7 -0
- package/Components/VideoModal/hooks/useDelayedPlayerDetails.ts +49 -0
- package/Components/VideoModal/hooks/utils/__tests__/showDetails.test.ts +91 -0
- package/Components/VideoModal/hooks/utils/index.ts +33 -0
- package/Components/VideoModal/utils.ts +3 -5
- package/Components/Viewport/ViewportAware/__tests__/__snapshots__/viewportAware.test.js.snap +2 -2
- package/Components/Viewport/ViewportTracker/__tests__/__snapshots__/viewportTracker.test.js.snap +1 -1
- package/Components/ZappUIComponent/__tests__/__snapshots__/ZappUIComponent.test.js.snap +11 -11
- package/Components/default-cell-renderer/__tests__/__snapshots__/defaultCellRenderer.test.tsx.snap +30 -30
- package/Contexts/ConfigutaionContext/__tests__/__snapshots__/ConfigurationProvider.test.tsx.snap +1 -1
- package/Contexts/ScreenContext/index.tsx +3 -2
- package/Decorators/Analytics/{index.js → index.tsx} +11 -11
- package/Decorators/Navigator/__tests__/__snapshots__/navigator.test.js.snap +2 -2
- package/Decorators/RiverFeedLoader/__tests__/__snapshots__/riverFeedLoader.test.tsx.snap +77 -77
- package/Decorators/RiverFeedLoader/__tests__/riverFeedLoader.test.tsx +34 -39
- package/Decorators/RiverFeedLoader/__tests__/utils.test.ts +0 -9
- package/Decorators/RiverFeedLoader/index.tsx +1 -1
- package/Decorators/RiverFeedLoader/utils/getDatasourceUrl.ts +39 -0
- package/Decorators/RiverFeedLoader/utils/index.ts +29 -0
- package/Decorators/RiverFeedLoader/utils/usePipesContexts.ts +40 -0
- package/Decorators/RiverResolver/__tests__/__snapshots__/riverResolver.test.tsx.snap +5 -5
- package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +16 -10
- package/Decorators/ZappPipesDataConnector/__tests__/Hero.js +1 -1
- package/Decorators/ZappPipesDataConnector/index.tsx +32 -2
- package/package.json +12 -6
- package/Decorators/RiverFeedLoader/utils.ts +0 -100
|
@@ -1,52 +1,14 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
|
|
3
|
-
import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager";
|
|
4
|
-
import * as FOCUS_EVENTS from "@applicaster/zapp-react-native-utils/appUtils/focusManager/events";
|
|
5
3
|
import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
6
4
|
import { toBooleanWithDefaultFalse } from "@applicaster/zapp-react-native-utils/booleanUtils";
|
|
7
5
|
|
|
8
|
-
import { isAppleTV } from "../../Helpers/Platform";
|
|
9
6
|
import { useCellState } from "../MasterCell/utils";
|
|
10
|
-
|
|
11
|
-
const useCellFocusedState = (
|
|
12
|
-
skipFocusManagerRegistration: boolean,
|
|
13
|
-
groupId: string,
|
|
14
|
-
id: string
|
|
15
|
-
) => {
|
|
16
|
-
const [currentCellFocused, setCurrentCellFocused] = React.useState(false);
|
|
17
|
-
|
|
18
|
-
React.useEffect(() => {
|
|
19
|
-
const isGroupItemFocused = () => {
|
|
20
|
-
if (!skipFocusManagerRegistration) {
|
|
21
|
-
const isFocused = focusManager.isGroupItemFocused(groupId, id);
|
|
22
|
-
setCurrentCellFocused(isFocused);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const handler = () => {
|
|
27
|
-
// tvOS hack for properly checking focus
|
|
28
|
-
if (isAppleTV()) {
|
|
29
|
-
setTimeout(() => {
|
|
30
|
-
isGroupItemFocused();
|
|
31
|
-
}, 0);
|
|
32
|
-
} else {
|
|
33
|
-
isGroupItemFocused();
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
focusManager.on(FOCUS_EVENTS.FOCUS, handler);
|
|
38
|
-
|
|
39
|
-
return () => {
|
|
40
|
-
focusManager.removeHandler(FOCUS_EVENTS.FOCUS, handler);
|
|
41
|
-
};
|
|
42
|
-
}, [groupId, skipFocusManagerRegistration]);
|
|
43
|
-
|
|
44
|
-
return currentCellFocused;
|
|
45
|
-
};
|
|
7
|
+
import { FocusableGroup } from "../FocusableGroup";
|
|
46
8
|
|
|
47
9
|
type Props = {
|
|
48
10
|
item: ZappEntry;
|
|
49
|
-
CellRenderer: React.
|
|
11
|
+
CellRenderer: React.FunctionComponent<any>;
|
|
50
12
|
id: string;
|
|
51
13
|
groupId: string;
|
|
52
14
|
onFocus: Function;
|
|
@@ -75,11 +37,7 @@ export function CellWithFocusable(props: Props) {
|
|
|
75
37
|
focused,
|
|
76
38
|
} = props;
|
|
77
39
|
|
|
78
|
-
const isFocused =
|
|
79
|
-
skipFocusManagerRegistration,
|
|
80
|
-
groupId,
|
|
81
|
-
id
|
|
82
|
-
);
|
|
40
|
+
const [isFocused, setIsFocused] = React.useState(false);
|
|
83
41
|
|
|
84
42
|
const state = useCellState({
|
|
85
43
|
id: item.id,
|
|
@@ -96,26 +54,52 @@ export function CellWithFocusable(props: Props) {
|
|
|
96
54
|
}
|
|
97
55
|
}, [focusedButtonId]);
|
|
98
56
|
|
|
99
|
-
const handleToggleFocus = (
|
|
100
|
-
|
|
57
|
+
const handleToggleFocus = React.useCallback(
|
|
58
|
+
(value) => {
|
|
59
|
+
setFocusedButtonId(value.focusedButtonId);
|
|
60
|
+
|
|
61
|
+
if (value.focusable) {
|
|
62
|
+
onFocus(value.focusable, value.mouse);
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
[onFocus]
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
const onGroupFocus = React.useCallback(() => {
|
|
69
|
+
if (!skipFocusManagerRegistration) {
|
|
70
|
+
setIsFocused(true);
|
|
71
|
+
}
|
|
72
|
+
}, [skipFocusManagerRegistration]);
|
|
101
73
|
|
|
102
|
-
|
|
103
|
-
|
|
74
|
+
const onGroupBlur = React.useCallback(() => {
|
|
75
|
+
if (!skipFocusManagerRegistration) {
|
|
76
|
+
setIsFocused(false);
|
|
104
77
|
}
|
|
105
|
-
};
|
|
78
|
+
}, [skipFocusManagerRegistration]);
|
|
106
79
|
|
|
107
80
|
return (
|
|
108
|
-
<
|
|
109
|
-
|
|
81
|
+
<FocusableGroup
|
|
82
|
+
id={`focusable-cell-wrapper-${id}`}
|
|
83
|
+
testID={"cell-with-focusable-cell-renderer-focusable-group"}
|
|
110
84
|
groupId={groupId}
|
|
111
|
-
onToggleFocus={handleToggleFocus}
|
|
112
|
-
state={state}
|
|
113
|
-
prefixId={id}
|
|
114
|
-
focusedButtonId={focusedButtonId}
|
|
115
85
|
preferredFocus={preferredFocus}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
86
|
+
shouldUsePreferredFocus
|
|
87
|
+
onFocus={onGroupFocus}
|
|
88
|
+
onBlur={onGroupBlur}
|
|
89
|
+
>
|
|
90
|
+
<CellRenderer
|
|
91
|
+
testID={"cell-with-focusable-cell-renderer"}
|
|
92
|
+
item={item}
|
|
93
|
+
groupId={`focusable-cell-wrapper-${id}`}
|
|
94
|
+
onToggleFocus={handleToggleFocus}
|
|
95
|
+
state={state}
|
|
96
|
+
prefixId={id}
|
|
97
|
+
focusedButtonId={focusedButtonId}
|
|
98
|
+
preferredFocus={true}
|
|
99
|
+
skipFocusManagerRegistration={skipFocusManagerRegistration}
|
|
100
|
+
isFocusable={isFocusable}
|
|
101
|
+
focused={focused}
|
|
102
|
+
/>
|
|
103
|
+
</FocusableGroup>
|
|
120
104
|
);
|
|
121
105
|
}
|
|
@@ -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";
|
|
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";
|
|
@@ -10,10 +10,6 @@ import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focu
|
|
|
10
10
|
import { sendSelectCellEvent } from "@applicaster/zapp-react-native-utils/analyticsUtils";
|
|
11
11
|
import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
12
12
|
import { CellWithFocusable } from "./CellWithFocusable";
|
|
13
|
-
import { getCellState } from "./utils";
|
|
14
|
-
|
|
15
|
-
const _getCellState = (focused, selected) =>
|
|
16
|
-
getCellState({ focused, selected });
|
|
17
13
|
|
|
18
14
|
type Props = {
|
|
19
15
|
item: ZappEntry;
|
|
@@ -36,10 +32,9 @@ type Props = {
|
|
|
36
32
|
component_type: string;
|
|
37
33
|
};
|
|
38
34
|
selected: boolean;
|
|
39
|
-
CellRenderer: React.
|
|
40
|
-
item: any;
|
|
41
|
-
|
|
42
|
-
}> & { hasFocusableInside: (item: any) => boolean };
|
|
35
|
+
CellRenderer: React.FunctionComponent<any> & {
|
|
36
|
+
hasFocusableInside: (item: any) => boolean;
|
|
37
|
+
};
|
|
43
38
|
preferredFocus: boolean;
|
|
44
39
|
navigator: {
|
|
45
40
|
push: (arg1: Record<any, any>) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { View } from "react-native";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { act, render } from "@testing-library/react-native";
|
|
4
|
-
import { CellWithFocusable } from "../CellWithFocusable";
|
|
4
|
+
import { CellWithFocusable } from "../CellWithFocusable.tsx";
|
|
5
5
|
|
|
6
6
|
import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager";
|
|
7
7
|
|
|
@@ -23,7 +23,9 @@ describe("CellWithFocusable", () => {
|
|
|
23
23
|
|
|
24
24
|
const wrapper = renderWith(props);
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
const element = wrapper.getByTestId("cell-with-focusable-cell-renderer");
|
|
27
|
+
|
|
28
|
+
expect(element.props.state).toBe("default");
|
|
27
29
|
});
|
|
28
30
|
|
|
29
31
|
it("should render in default state", () => {
|
|
@@ -40,8 +42,9 @@ describe("CellWithFocusable", () => {
|
|
|
40
42
|
focusManager.isGroupItemFocused = jest.fn(() => true);
|
|
41
43
|
|
|
42
44
|
const wrapper = renderWith(props);
|
|
45
|
+
const element = wrapper.getByTestId("cell-with-focusable-cell-renderer");
|
|
43
46
|
|
|
44
|
-
expect(
|
|
47
|
+
expect(element.props.state).toBe("default");
|
|
45
48
|
});
|
|
46
49
|
|
|
47
50
|
it("should render in focused state", () => {
|
|
@@ -55,13 +58,17 @@ describe("CellWithFocusable", () => {
|
|
|
55
58
|
scrollTo: jest.fn(),
|
|
56
59
|
};
|
|
57
60
|
|
|
58
|
-
focusManager.isGroupItemFocused = jest.fn(() => true);
|
|
59
61
|
const wrapper = renderWith(props);
|
|
60
62
|
|
|
63
|
+
const focusableGroupComponent = wrapper.getByTestId(
|
|
64
|
+
"cell-with-focusable-cell-renderer-focusable-group"
|
|
65
|
+
);
|
|
66
|
+
|
|
61
67
|
act(() => {
|
|
62
|
-
|
|
68
|
+
focusableGroupComponent.props.onFocus();
|
|
63
69
|
});
|
|
64
70
|
|
|
65
|
-
|
|
71
|
+
const element = wrapper.getByTestId("cell-with-focusable-cell-renderer");
|
|
72
|
+
expect(element.props.state).toBe("focused");
|
|
66
73
|
});
|
|
67
74
|
});
|
package/Components/CellRendererResolver/__tests__/__snapshots__/cellRendererResolver.test.js.snap
CHANGED
|
@@ -3,24 +3,24 @@
|
|
|
3
3
|
exports[`CellRendererResolver renders correctly 1`] = `
|
|
4
4
|
<View
|
|
5
5
|
someProp={
|
|
6
|
-
|
|
7
|
-
"cellOptions":
|
|
8
|
-
"cellStyles":
|
|
9
|
-
"ABCDE-123456":
|
|
10
|
-
"configuration":
|
|
6
|
+
{
|
|
7
|
+
"cellOptions": {},
|
|
8
|
+
"cellStyles": {
|
|
9
|
+
"ABCDE-123456": {
|
|
10
|
+
"configuration": {},
|
|
11
11
|
"plugin_identifier": "custom_renderer_plugin",
|
|
12
12
|
},
|
|
13
|
-
"FGHIJ-123456":
|
|
14
|
-
"configuration":
|
|
13
|
+
"FGHIJ-123456": {
|
|
14
|
+
"configuration": {},
|
|
15
15
|
"plugin_identifier": "unknown_plugin",
|
|
16
16
|
},
|
|
17
17
|
},
|
|
18
|
-
"component":
|
|
19
|
-
"styles":
|
|
18
|
+
"component": {
|
|
19
|
+
"styles": {
|
|
20
20
|
"cell_plugin_configuration_id": "ABCDE-123456",
|
|
21
21
|
},
|
|
22
22
|
},
|
|
23
|
-
"styles":
|
|
23
|
+
"styles": {},
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
/>
|
|
@@ -29,24 +29,24 @@ exports[`CellRendererResolver renders correctly 1`] = `
|
|
|
29
29
|
exports[`CellRendererResolver with a default renderer plugin renders correctly 1`] = `
|
|
30
30
|
<View
|
|
31
31
|
someProp={
|
|
32
|
-
|
|
33
|
-
"cellOptions":
|
|
34
|
-
"cellStyles":
|
|
35
|
-
"ABCDE-123456":
|
|
36
|
-
"configuration":
|
|
32
|
+
{
|
|
33
|
+
"cellOptions": {},
|
|
34
|
+
"cellStyles": {
|
|
35
|
+
"ABCDE-123456": {
|
|
36
|
+
"configuration": {},
|
|
37
37
|
"plugin_identifier": "custom_renderer_plugin",
|
|
38
38
|
},
|
|
39
|
-
"FGHIJ-123456":
|
|
40
|
-
"configuration":
|
|
39
|
+
"FGHIJ-123456": {
|
|
40
|
+
"configuration": {},
|
|
41
41
|
"plugin_identifier": "unknown_plugin",
|
|
42
42
|
},
|
|
43
43
|
},
|
|
44
|
-
"component":
|
|
45
|
-
"styles":
|
|
44
|
+
"component": {
|
|
45
|
+
"styles": {
|
|
46
46
|
"cell_plugin_configuration_id": "ABCDE-123456",
|
|
47
47
|
},
|
|
48
48
|
},
|
|
49
|
-
"styles":
|
|
49
|
+
"styles": {},
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
/>
|
|
@@ -2,9 +2,11 @@ import * as React from "react";
|
|
|
2
2
|
import { View } from "react-native";
|
|
3
3
|
import { shallow } from "enzyme";
|
|
4
4
|
|
|
5
|
-
jest.mock("../../default-cell-renderer", () =>
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
jest.mock("../../default-cell-renderer", () => {
|
|
6
|
+
const View = jest.requireActual("react-native").View;
|
|
7
|
+
|
|
8
|
+
return jest.fn((prop) => <View whoAmI="default renderer" someProp={prop} />);
|
|
9
|
+
});
|
|
8
10
|
|
|
9
11
|
const { CellRendererResolver } = require("../index");
|
|
10
12
|
|
|
@@ -5,22 +5,22 @@ exports[`ComponentResolver renders correctly 1`] = `
|
|
|
5
5
|
value={null}
|
|
6
6
|
>
|
|
7
7
|
<Memo(ComponentResolver)
|
|
8
|
-
cellStyles={
|
|
8
|
+
cellStyles={{}}
|
|
9
9
|
component={
|
|
10
|
-
|
|
10
|
+
{
|
|
11
11
|
"component_type": "some_component",
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
components={
|
|
15
|
-
|
|
15
|
+
{
|
|
16
16
|
"SomeComponent": [MockFunction],
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
decorators={[MockFunction]}
|
|
20
20
|
dispatch={[Function]}
|
|
21
|
-
plugins={
|
|
21
|
+
plugins={[]}
|
|
22
22
|
store={
|
|
23
|
-
|
|
23
|
+
{
|
|
24
24
|
"clearActions": [Function],
|
|
25
25
|
"dispatch": [Function],
|
|
26
26
|
"getActions": [Function],
|
|
@@ -4,19 +4,21 @@ import { shallow } from "enzyme";
|
|
|
4
4
|
import { shallowToJson } from "enzyme-to-json";
|
|
5
5
|
import configureStore from "redux-mock-store";
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const mockLogger = {
|
|
8
8
|
warning: jest.fn(),
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
jest.mock("../../../Helpers/logger", () => ({
|
|
12
12
|
componentsLogger: {
|
|
13
|
-
addSubsystem: jest.fn(() =>
|
|
13
|
+
addSubsystem: jest.fn(() => mockLogger),
|
|
14
14
|
},
|
|
15
15
|
}));
|
|
16
16
|
|
|
17
|
-
jest.mock("../../default-cell-renderer", () =>
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
jest.mock("../../default-cell-renderer", () => {
|
|
18
|
+
const View = jest.requireActual("react-native").View;
|
|
19
|
+
|
|
20
|
+
return jest.fn((prop) => <View whoAmI="default renderer" someProp={prop} />);
|
|
21
|
+
});
|
|
20
22
|
|
|
21
23
|
const mock_rtl_flag = false;
|
|
22
24
|
|
|
@@ -48,7 +50,7 @@ function clearAllMocks() {
|
|
|
48
50
|
SomeComponent.mockClear();
|
|
49
51
|
decorators.mockClear();
|
|
50
52
|
renderFunction.mockClear();
|
|
51
|
-
|
|
53
|
+
mockLogger.warning.mockClear();
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
describe("ComponentResolver", () => {
|
|
@@ -104,16 +106,16 @@ describe("ComponentResolverComponent", () => {
|
|
|
104
106
|
expect(shallowToJson(wrapper)).toMatchSnapshot();
|
|
105
107
|
expect(wrapper.isEmptyRender()).toBe(true);
|
|
106
108
|
|
|
107
|
-
expect(
|
|
109
|
+
expect(mockLogger.warning).toHaveBeenCalledTimes(2);
|
|
108
110
|
|
|
109
|
-
expect(
|
|
111
|
+
expect(mockLogger.warning).toHaveBeenNthCalledWith(
|
|
110
112
|
1,
|
|
111
113
|
expect.objectContaining({
|
|
112
114
|
message: "Could not resolve cell builder plugin",
|
|
113
115
|
})
|
|
114
116
|
);
|
|
115
117
|
|
|
116
|
-
expect(
|
|
118
|
+
expect(mockLogger.warning).toHaveBeenNthCalledWith(
|
|
117
119
|
2,
|
|
118
120
|
expect.objectContaining({
|
|
119
121
|
message: warningMessage,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`DISPLAY_STATES matches the snapshot 1`] = `
|
|
4
|
-
|
|
4
|
+
{
|
|
5
5
|
"CONTENT": "CONTENT",
|
|
6
6
|
"CONTROLS": "CONTROLS",
|
|
7
7
|
"DISCOVERY": "DISCOVERY",
|
|
@@ -9,7 +9,7 @@ Object {
|
|
|
9
9
|
`;
|
|
10
10
|
|
|
11
11
|
exports[`DisplayStateContext has the correct properties 1`] = `
|
|
12
|
-
|
|
12
|
+
{
|
|
13
13
|
"Consumer": [MockFunction],
|
|
14
14
|
"Provider": [MockFunction],
|
|
15
15
|
"withConsumer": [MockFunction],
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import * as R from "ramda";
|
|
3
2
|
|
|
4
3
|
import { BaseFocusable } from "../BaseFocusable";
|
|
5
4
|
import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager";
|
|
@@ -42,8 +41,6 @@ class Focusable extends BaseFocusable<Props> {
|
|
|
42
41
|
this.resetLongPressTimeout = this.resetLongPressTimeout.bind(this);
|
|
43
42
|
this.longPress = this.longPress.bind(this);
|
|
44
43
|
this.press = this.press.bind(this);
|
|
45
|
-
this.focus = this.focus.bind(this);
|
|
46
|
-
this.blur = this.blur.bind(this);
|
|
47
44
|
}
|
|
48
45
|
|
|
49
46
|
/**
|
|
@@ -55,37 +52,6 @@ class Focusable extends BaseFocusable<Props> {
|
|
|
55
52
|
return this.preferredFocus();
|
|
56
53
|
}
|
|
57
54
|
|
|
58
|
-
/**
|
|
59
|
-
* Sets the focus on this item. Will trigger sequentially a sequence of
|
|
60
|
-
* functions (willReceiveFocus, focus, hasReceivedFocus). If these functions (defined in the Focusable
|
|
61
|
-
* Item underlying component) return promises, execution will wait before it proceeds to the next. This
|
|
62
|
-
* is useful for triggering sequential operations that specifically require to fully run before or after
|
|
63
|
-
* focus is actually set on that item.
|
|
64
|
-
* @param {string} scrollDirection string representation of the direction of the navigation which landed
|
|
65
|
-
* to this item being focused
|
|
66
|
-
*/
|
|
67
|
-
setFocus(scrollDirection) {
|
|
68
|
-
const focusMethods = [
|
|
69
|
-
this.willReceiveFocus,
|
|
70
|
-
this.focus,
|
|
71
|
-
this.hasReceivedFocus,
|
|
72
|
-
];
|
|
73
|
-
|
|
74
|
-
const self = this;
|
|
75
|
-
|
|
76
|
-
return R.reduce(
|
|
77
|
-
(sequence, method) => {
|
|
78
|
-
return sequence
|
|
79
|
-
.then(() => method.apply(self, [scrollDirection]))
|
|
80
|
-
.catch((e) => {
|
|
81
|
-
throw e;
|
|
82
|
-
});
|
|
83
|
-
},
|
|
84
|
-
Promise.resolve(),
|
|
85
|
-
focusMethods
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
55
|
startLongPressTimeout() {
|
|
90
56
|
this.longPressTimeout = setTimeout(() => {
|
|
91
57
|
this.longPress(null);
|
|
@@ -102,26 +68,6 @@ class Focusable extends BaseFocusable<Props> {
|
|
|
102
68
|
}
|
|
103
69
|
}
|
|
104
70
|
|
|
105
|
-
/**
|
|
106
|
-
* will invoke the underlying component's focus method
|
|
107
|
-
* @param {Object} scrollDirection
|
|
108
|
-
* @returns {Promise}
|
|
109
|
-
*/
|
|
110
|
-
focus(scrollDirection) {
|
|
111
|
-
return this.onFocus(this, scrollDirection); // invokeComponentMethod(this, "onFocus", scrollDirection);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* will invoke the underlying component's blur method
|
|
116
|
-
* @param {Object} scrollDirection
|
|
117
|
-
* @returns {Promise}
|
|
118
|
-
*/
|
|
119
|
-
blur(
|
|
120
|
-
scrollDirection?: FocusManager.Web.Direction | FocusManager.IOS.Direction
|
|
121
|
-
) {
|
|
122
|
-
return this.onBlur(this, scrollDirection);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
71
|
/**
|
|
126
72
|
* will invoke the underlying component's press method
|
|
127
73
|
* @param {Object} keyEvent
|
|
@@ -90,7 +90,7 @@ export class Focusable extends BaseFocusable<Props> {
|
|
|
90
90
|
onBlur(nativeEvent);
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
setFocus(
|
|
93
|
+
setFocus(_direction, callback) {
|
|
94
94
|
const focusMethods = [
|
|
95
95
|
{ method: this.willReceiveFocus },
|
|
96
96
|
{ method: this.focus, args: [callback] },
|
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
|
|
3
|
-
type Props =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
} & Partial<ParentFocus>;
|
|
3
|
+
type Props = {
|
|
4
|
+
id: string;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
onPress?: (ref: FocusManager.TouchableRef) => void;
|
|
7
|
+
onPressIn?: (ref: FocusManager.TouchableRef) => void;
|
|
8
|
+
onPressOut?: (ref: FocusManager.TouchableRef) => void;
|
|
9
|
+
onLongPress?: (ref: FocusManager.TouchableRef) => void;
|
|
10
|
+
onFocus?: (
|
|
11
|
+
ref: FocusManager.TouchableRef,
|
|
12
|
+
options: FocusManager.Android.CallbackOptions
|
|
13
|
+
) => void;
|
|
14
|
+
onBlur?: (
|
|
15
|
+
ref: FocusManager.TouchableRef,
|
|
16
|
+
options: FocusManager.Android.CallbackOptions
|
|
17
|
+
) => void;
|
|
18
|
+
|
|
19
|
+
disableFocus?: boolean;
|
|
20
|
+
blockFocus?: boolean;
|
|
21
|
+
} & Partial<ParentFocus>;
|
|
23
22
|
|
|
24
23
|
export class Touchable extends React.Component<Props> {
|
|
25
24
|
onPress(focusableRef: FocusManager.TouchableRef): void {
|
|
@@ -87,7 +87,6 @@ function FocusableListComponent<ItemT>(props: Props<ItemT>, ref) {
|
|
|
87
87
|
initialFocusDirection = "down",
|
|
88
88
|
data = [],
|
|
89
89
|
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
90
|
-
onAllComponentsLoaded, // TODO: re-implement it
|
|
91
90
|
omitPropsPropagation = [],
|
|
92
91
|
} = props;
|
|
93
92
|
|
|
@@ -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:
|
|
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
|
|
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
|
|
150
|
-
const entry
|
|
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
|
|
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
|
};
|