@applicaster/zapp-react-native-ui-components 13.0.0-alpha.6944415045 → 13.0.0-alpha.7048001189
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__/AppContainer.test.js +4 -6
- package/Components/AudioPlayer/AudioPlayer.tsx +7 -0
- package/Components/AudioPlayer/__tests__/Runtime.test.js +5 -8
- package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +54 -111
- package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayerLayout.test.js.snap +36 -20
- package/Components/AudioPlayer/__tests__/artWork.test.js +3 -5
- package/Components/AudioPlayer/__tests__/audioPlayer.test.js +3 -5
- package/Components/AudioPlayer/__tests__/audioPlayerLayout.test.js +7 -8
- package/Components/AudioPlayer/__tests__/channel.test.js +3 -5
- package/Components/AudioPlayer/__tests__/summary.test.js +3 -5
- package/Components/AudioPlayer/__tests__/title.test.js +3 -5
- package/Components/AudioPlayer/helpers.tsx +1 -0
- package/Components/BaseFocusable/index.ios.ts +1 -1
- package/Components/BaseFocusable/index.tsx +2 -3
- package/Components/Cell/Cell.tsx +10 -16
- package/Components/Cell/CellWithFocusable.tsx +50 -59
- package/Components/Cell/CellWrapper.tsx +18 -0
- package/Components/Cell/__tests__/CellWIthFocusable.test.js +13 -6
- package/Components/Cell/styles.ts +17 -0
- package/Components/CellRendererResolver/__tests__/cellRendererResolver.test.js +46 -48
- package/Components/ComponentResolver/__tests__/__snapshots__/componentResolver.test.js.snap +1 -42
- package/Components/ComponentResolver/__tests__/componentResolver.test.js +16 -22
- package/Components/ContentScreen/__tests__/contentScreen.test.js +3 -3
- package/Components/ErrorScreen/index.tsx +14 -6
- package/Components/Focusable/Focusable.tsx +1 -0
- package/Components/Focusable/Touchable.tsx +19 -20
- package/Components/Focusable/index.android.tsx +10 -3
- package/Components/FocusableCell/index.tsx +1 -1
- package/Components/FocusableGroup/FocusableTvOS.tsx +34 -86
- package/Components/FocusableGroup/index.tsx +0 -3
- package/Components/FocusableList/index.tsx +1 -0
- package/Components/FocusableScrollView/index.tsx +6 -3
- package/Components/HandlePlayable/HandlePlayable.tsx +21 -27
- package/Components/Layout/TV/NavBarContainer.tsx +14 -19
- package/Components/Layout/TV/ScreenContainer.tsx +8 -1
- package/Components/Layout/TV/ScreenLayoutContextProvider.tsx +5 -0
- package/Components/Layout/TV/__tests__/ScreenContainer.test.tsx +2 -1
- package/Components/Layout/TV/__tests__/__snapshots__/NavBarContainer.test.tsx.snap +3 -2
- package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +3 -2
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -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 +9 -14
- package/Components/MasterCell/DefaultComponents/Image/hooks/useImage.ts +11 -7
- package/Components/MasterCell/DefaultComponents/ImageBorderContainer/__tests__/index.test.ts +93 -0
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +2 -2
- package/Components/MasterCell/DefaultComponents/SecondaryImage/utils.ts +1 -1
- package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/const.ts +3 -0
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/index.ts +6 -6
- package/Components/MasterCell/SharedUI/ProgressBar/hooks/useFillInPercent.ts +2 -8
- package/Components/MasterCell/__tests__/__snapshots__/elementMapper.test.js.snap +4 -12
- package/Components/MasterCell/__tests__/__snapshots__/masterCell.test.js.snap +0 -229
- package/Components/MasterCell/__tests__/elementMapper.test.js +18 -5
- package/Components/MasterCell/__tests__/masterCell.test.js +26 -26
- package/Components/MasterCell/hooks/useAsyncRendering/MasterCellAsyncRenderManager.ts +2 -2
- package/Components/MasterCell/utils/behaviorProvider.ts +136 -0
- package/Components/MasterCell/utils/index.ts +9 -135
- package/Components/ModalComponent/BottomSheetModalContent.tsx +38 -15
- package/Components/ModalComponent/Button/Item.tsx +1 -0
- package/Components/ModalComponent/Button/assets.ts +1 -1
- package/Components/ModalComponent/Button/index.tsx +30 -43
- package/Components/ModalComponent/Header/index.tsx +3 -3
- package/Components/ModalComponent/utils.ts +52 -4
- package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +2 -2
- package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +2 -2
- package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +0 -5
- package/Components/OfflineHandler/utils/index.ts +1 -1
- package/Components/PlayerContainer/PlayerContainer.tsx +28 -14
- package/Components/PlayerContainer/ProgramInfo/index.tsx +2 -2
- package/Components/PlayerImageBackground/index.tsx +1 -1
- package/Components/River/ComponentsMap/ComponentsMap.tsx +42 -65
- package/Components/River/ComponentsMap/hooks/useLoadingState.ts +78 -51
- package/Components/River/RiverFooter.tsx +39 -9
- package/Components/River/RiverItem.tsx +37 -2
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +100 -31
- package/Components/River/__tests__/__snapshots__/river.test.js.snap +20 -82
- package/Components/River/__tests__/componentsMap.test.js +17 -5
- package/Components/River/__tests__/river.test.js +75 -40
- package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +11 -4
- package/Components/RouteManager/__tests__/routeManager.test.js +29 -14
- package/Components/RouteManager/__tests__/testId.test.js +8 -6
- package/Components/Screen/TV/index.web.tsx +5 -6
- package/Components/Screen/hooks.ts +53 -0
- package/Components/Screen/index.tsx +16 -42
- package/Components/ScreenResolver/__tests__/screenResolver.test.js +91 -70
- package/Components/Tabs/Tab.tsx +11 -9
- package/Components/TextInputTv/index.tsx +4 -3
- package/Components/TrackedView/index.tsx +1 -0
- package/Components/Transitioner/AnimationManager.js +15 -15
- package/Components/Transitioner/Scene.tsx +53 -24
- package/Components/Transitioner/Transitioner.tsx +3 -3
- package/Components/Transitioner/__tests__/Scene.test.js +25 -14
- package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +9 -49
- package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +2 -2
- package/Components/Transitioner/__tests__/transitioner.test.js +13 -4
- package/Components/Transitioner/index.js +8 -4
- package/Components/VideoLive/LiveImageManager.ts +27 -1
- package/Components/VideoLive/PlayerLiveImageComponent.tsx +36 -24
- package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +51 -1
- package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +1 -5
- package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +1 -1
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +44 -30
- package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +3 -3
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +35 -17
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +4 -5
- package/Components/VideoModal/ModalAnimation/utils.ts +2 -2
- package/Components/VideoModal/OpaqueLayer.tsx +33 -0
- package/Components/VideoModal/PlayerDetails.tsx +13 -10
- package/Components/VideoModal/PlayerWrapper.tsx +43 -39
- package/Components/VideoModal/VideoModal.tsx +17 -11
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -1
- package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +0 -90
- 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 +1 -1
- package/Components/Viewport/ViewportAware/__tests__/__snapshots__/viewportAware.test.js.snap +24 -36
- package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +12 -18
- package/Components/Viewport/__tests__/utils.test.js +5 -4
- package/Components/ZappUIComponent/Placeholder.tsx +3 -1
- package/Components/ZappUIComponent/__tests__/{ZappUIComponent.test.js → ZappUIComponent.test.tsx} +26 -10
- package/Components/ZappUIComponent/index.tsx +4 -17
- package/Components/default-cell-renderer/__tests__/defaultCellRenderer.test.tsx +20 -17
- package/Components/default-cell-renderer/viewTrees/tv/DefaultCell/__tests__/DefaultCell.test.tsx +15 -11
- package/Contexts/ComponentsMapOffsetContext/index.tsx +8 -5
- package/Contexts/FocusableGroupContext/withFocusableContext.tsx +4 -10
- package/Contexts/HeaderOffsetContext/index.tsx +4 -6
- package/Contexts/ScreenContext/index.tsx +6 -12
- package/Contexts/ScreenLayoutContext/index.tsx +5 -3
- package/Decorators/Navigator/__tests__/navigator.test.js +16 -16
- package/Decorators/Navigator/index.tsx +1 -1
- package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +18 -24
- package/Decorators/RiverResolver/index.tsx +6 -8
- package/Decorators/ZappPipesDataConnector/__tests__/Hero.js +1 -1
- package/Decorators/ZappPipesDataConnector/__tests__/zappPipesDataConnector.test.js +29 -22
- package/Decorators/ZappPipesDataConnector/index.tsx +6 -2
- package/package.json +7 -11
- package/tsconfig.json +2 -3
- package/.babelrc +0 -8
- package/Components/Cell/CellStyles/FallbackCellStyle/index.js +0 -157
- package/Components/Cell/CellStyles/Hero/index.js +0 -111
- package/Components/Cell/CellStyles/ScreenSelector/index.js +0 -68
- package/Components/Cell/CellStyles/cellStylesResolver.ts +0 -19
- package/Components/Cell/CellStyles/colors.js +0 -40
- package/Components/Cell/CellStyles/index.js +0 -15
- package/Components/CellRendererResolver/__tests__/__snapshots__/cellRendererResolver.test.js.snap +0 -53
- package/Components/RouteManager/__tests__/__snapshots__/testId.test.js.snap +0 -17
- package/Components/ScreenResolver/__tests__/__snapshots__/screenResolver.test.js.snap +0 -17
- package/Components/ZappUIComponent/__tests__/__snapshots__/ZappUIComponent.test.js.snap +0 -91
- package/Components/default-cell-renderer/__tests__/__snapshots__/defaultCellRenderer.test.tsx.snap +0 -338
- package/Decorators/Navigator/__tests__/__snapshots__/navigator.test.js.snap +0 -18
- package/Decorators/RiverResolver/__tests__/__snapshots__/riverResolver.test.tsx.snap +0 -28
|
@@ -1,48 +1,12 @@
|
|
|
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
|
-
|
|
12
|
-
|
|
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";
|
|
8
|
+
import { CellWrapper } from "./CellWrapper";
|
|
9
|
+
import { styles } from "./styles";
|
|
46
10
|
|
|
47
11
|
type Props = {
|
|
48
12
|
item: ZappEntry;
|
|
@@ -59,6 +23,8 @@ type Props = {
|
|
|
59
23
|
focused?: boolean;
|
|
60
24
|
};
|
|
61
25
|
|
|
26
|
+
const addPrefix = (id: string) => `focusable-cell-wrapper-${id}`;
|
|
27
|
+
|
|
62
28
|
export function CellWithFocusable(props: Props) {
|
|
63
29
|
const {
|
|
64
30
|
index,
|
|
@@ -75,14 +41,10 @@ export function CellWithFocusable(props: Props) {
|
|
|
75
41
|
focused,
|
|
76
42
|
} = props;
|
|
77
43
|
|
|
78
|
-
const isFocused =
|
|
79
|
-
skipFocusManagerRegistration,
|
|
80
|
-
groupId,
|
|
81
|
-
id
|
|
82
|
-
);
|
|
44
|
+
const [isFocused, setIsFocused] = React.useState(false);
|
|
83
45
|
|
|
84
46
|
const state = useCellState({
|
|
85
|
-
|
|
47
|
+
item,
|
|
86
48
|
behavior,
|
|
87
49
|
focused: isFocused || toBooleanWithDefaultFalse(focused),
|
|
88
50
|
});
|
|
@@ -96,26 +58,55 @@ export function CellWithFocusable(props: Props) {
|
|
|
96
58
|
}
|
|
97
59
|
}, [focusedButtonId]);
|
|
98
60
|
|
|
99
|
-
const handleToggleFocus = (
|
|
100
|
-
|
|
61
|
+
const handleToggleFocus = React.useCallback(
|
|
62
|
+
(value) => {
|
|
63
|
+
setFocusedButtonId(value.focusedButtonId);
|
|
64
|
+
|
|
65
|
+
if (value.focusable) {
|
|
66
|
+
onFocus(value.focusable, value.mouse);
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
[onFocus]
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
const onGroupFocus = React.useCallback(() => {
|
|
73
|
+
if (!skipFocusManagerRegistration) {
|
|
74
|
+
setIsFocused(true);
|
|
75
|
+
}
|
|
76
|
+
}, [skipFocusManagerRegistration]);
|
|
101
77
|
|
|
102
|
-
|
|
103
|
-
|
|
78
|
+
const onGroupBlur = React.useCallback(() => {
|
|
79
|
+
if (!skipFocusManagerRegistration) {
|
|
80
|
+
setIsFocused(false);
|
|
104
81
|
}
|
|
105
|
-
};
|
|
82
|
+
}, [skipFocusManagerRegistration]);
|
|
106
83
|
|
|
107
84
|
return (
|
|
108
|
-
<
|
|
109
|
-
|
|
85
|
+
<FocusableGroup
|
|
86
|
+
id={addPrefix(id)}
|
|
87
|
+
testID={"cell-with-focusable-cell-renderer-focusable-group"}
|
|
110
88
|
groupId={groupId}
|
|
111
|
-
onToggleFocus={handleToggleFocus}
|
|
112
|
-
state={state}
|
|
113
|
-
prefixId={id}
|
|
114
|
-
focusedButtonId={focusedButtonId}
|
|
115
89
|
preferredFocus={preferredFocus}
|
|
90
|
+
shouldUsePreferredFocus
|
|
91
|
+
onFocus={onGroupFocus}
|
|
92
|
+
onBlur={onGroupBlur}
|
|
116
93
|
skipFocusManagerRegistration={skipFocusManagerRegistration}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
94
|
+
>
|
|
95
|
+
<CellWrapper style={styles.cellWrapper}>
|
|
96
|
+
<CellRenderer
|
|
97
|
+
testID={"cell-with-focusable-cell-renderer"}
|
|
98
|
+
item={item}
|
|
99
|
+
groupId={addPrefix(id)}
|
|
100
|
+
onToggleFocus={handleToggleFocus}
|
|
101
|
+
state={state}
|
|
102
|
+
prefixId={id}
|
|
103
|
+
focusedButtonId={focusedButtonId}
|
|
104
|
+
preferredFocus={true}
|
|
105
|
+
skipFocusManagerRegistration={skipFocusManagerRegistration}
|
|
106
|
+
isFocusable={isFocusable}
|
|
107
|
+
focused={focused}
|
|
108
|
+
/>
|
|
109
|
+
</CellWrapper>
|
|
110
|
+
</FocusableGroup>
|
|
120
111
|
);
|
|
121
112
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { View, ViewStyle } from "react-native";
|
|
3
|
+
import { isTvOSPlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
4
|
+
|
|
5
|
+
const isTvOS = isTvOSPlatform();
|
|
6
|
+
|
|
7
|
+
type Props = {
|
|
8
|
+
style: ViewStyle;
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const CellWrapper = ({ style, children }: Props) => {
|
|
13
|
+
if (isTvOS) {
|
|
14
|
+
return <View style={style}>{children}</View>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return <>{children}</>;
|
|
18
|
+
};
|
|
@@ -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
|
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
|
|
3
|
+
export const styles = StyleSheet.create({
|
|
4
|
+
cellWrapper: {
|
|
5
|
+
flex: 0,
|
|
6
|
+
height: "100%",
|
|
7
|
+
},
|
|
8
|
+
baseCell: {
|
|
9
|
+
height: "100%",
|
|
10
|
+
display: "flex",
|
|
11
|
+
flex: 1,
|
|
12
|
+
},
|
|
13
|
+
touchableCell: {
|
|
14
|
+
flex: 1,
|
|
15
|
+
height: "100%",
|
|
16
|
+
},
|
|
17
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
|
-
import {
|
|
3
|
+
import { render } from "@testing-library/react-native";
|
|
4
|
+
import { CellRendererResolver } from "../";
|
|
4
5
|
|
|
5
6
|
jest.mock("../../default-cell-renderer", () => {
|
|
6
7
|
const View = jest.requireActual("react-native").View;
|
|
@@ -8,8 +9,6 @@ jest.mock("../../default-cell-renderer", () => {
|
|
|
8
9
|
return jest.fn((prop) => <View whoAmI="default renderer" someProp={prop} />);
|
|
9
10
|
});
|
|
10
11
|
|
|
11
|
-
const { CellRendererResolver } = require("../index");
|
|
12
|
-
|
|
13
12
|
const component = {
|
|
14
13
|
styles: {
|
|
15
14
|
cell_plugin_configuration_id: "ABCDE-123456",
|
|
@@ -45,17 +44,9 @@ describe("CellRendererResolver", () => {
|
|
|
45
44
|
cellStyles,
|
|
46
45
|
});
|
|
47
46
|
|
|
48
|
-
it("renders correctly", () => {
|
|
49
|
-
const result = shallow(
|
|
50
|
-
getResult({ component, plugins, styles, cellStyles })
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
expect(result).toMatchSnapshot();
|
|
54
|
-
});
|
|
55
|
-
|
|
56
47
|
describe("with a default renderer plugin", () => {
|
|
57
48
|
it("renders correctly", () => {
|
|
58
|
-
const
|
|
49
|
+
const { UNSAFE_root } = render(
|
|
59
50
|
getResult({
|
|
60
51
|
component,
|
|
61
52
|
plugins,
|
|
@@ -64,56 +55,63 @@ describe("CellRendererResolver", () => {
|
|
|
64
55
|
})
|
|
65
56
|
);
|
|
66
57
|
|
|
67
|
-
expect(
|
|
58
|
+
expect(UNSAFE_root).toBeDefined();
|
|
68
59
|
});
|
|
69
60
|
|
|
70
61
|
it("returns default plugin if component has no cell_plugin_configuration_id", () => {
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
62
|
+
const { UNSAFE_getByProps } = render(
|
|
63
|
+
getResult({
|
|
64
|
+
component: {},
|
|
65
|
+
plugins,
|
|
66
|
+
styles,
|
|
67
|
+
cellStyles,
|
|
68
|
+
})
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
expect(UNSAFE_getByProps({ whoAmI: "default renderer" })).toBeTruthy();
|
|
80
72
|
});
|
|
81
73
|
|
|
82
74
|
it("returns default plugin if requested cell plugin configuration does not exist", () => {
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
75
|
+
const { UNSAFE_getByProps } = render(
|
|
76
|
+
getResult({
|
|
77
|
+
component: { styles: { cell_plugin_configuration_id: "wrong-id" } },
|
|
78
|
+
plugins,
|
|
79
|
+
styles,
|
|
80
|
+
cellStyles,
|
|
81
|
+
})
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
expect(UNSAFE_getByProps({ whoAmI: "default renderer" })).toBeTruthy();
|
|
91
85
|
});
|
|
92
86
|
|
|
93
87
|
it("returns default plugin if cellStyles store is empty", () => {
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
88
|
+
const { UNSAFE_getByProps } = render(
|
|
89
|
+
getResult({
|
|
90
|
+
component,
|
|
91
|
+
plugins,
|
|
92
|
+
styles,
|
|
93
|
+
cellStyles: {},
|
|
94
|
+
})
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
expect(UNSAFE_getByProps({ whoAmI: "default renderer" })).toBeTruthy();
|
|
102
98
|
});
|
|
103
99
|
|
|
104
100
|
it("returns null if requested renderer plugin does not exist", () => {
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
101
|
+
const { UNSAFE_getByProps } = render(
|
|
102
|
+
getResult({
|
|
103
|
+
component: {
|
|
104
|
+
styles: {
|
|
105
|
+
cell_plugin_configuration_id: "FGHIJ-123456",
|
|
106
|
+
},
|
|
109
107
|
},
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
108
|
+
plugins,
|
|
109
|
+
styles,
|
|
110
|
+
cellStyles,
|
|
111
|
+
})
|
|
112
|
+
);
|
|
115
113
|
|
|
116
|
-
expect(
|
|
114
|
+
expect(UNSAFE_getByProps({ whoAmI: "default renderer" })).toBeTruthy();
|
|
117
115
|
});
|
|
118
116
|
});
|
|
119
117
|
});
|
|
@@ -1,48 +1,7 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`ComponentResolver renders correctly 1`] = `
|
|
4
|
-
<ContextProvider
|
|
5
|
-
value={null}
|
|
6
|
-
>
|
|
7
|
-
<Memo(ComponentResolver)
|
|
8
|
-
cellStyles={{}}
|
|
9
|
-
component={
|
|
10
|
-
{
|
|
11
|
-
"component_type": "some_component",
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
components={
|
|
15
|
-
{
|
|
16
|
-
"SomeComponent": [MockFunction],
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
decorators={[MockFunction]}
|
|
20
|
-
dispatch={[Function]}
|
|
21
|
-
plugins={[]}
|
|
22
|
-
store={
|
|
23
|
-
{
|
|
24
|
-
"clearActions": [Function],
|
|
25
|
-
"dispatch": [Function],
|
|
26
|
-
"getActions": [Function],
|
|
27
|
-
"getState": [Function],
|
|
28
|
-
"replaceReducer": [Function],
|
|
29
|
-
"subscribe": [Function],
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
/>
|
|
33
|
-
</ContextProvider>
|
|
34
|
-
`;
|
|
35
|
-
|
|
36
3
|
exports[`ComponentResolverComponent initializes the cell renderer plugin module if matching plugin exists 1`] = `
|
|
37
|
-
<
|
|
4
|
+
<View
|
|
38
5
|
rendered={true}
|
|
39
6
|
/>
|
|
40
7
|
`;
|
|
41
|
-
|
|
42
|
-
exports[`ComponentResolverComponent renders the Component if it exists 1`] = `
|
|
43
|
-
<mockConstructor
|
|
44
|
-
rendered={true}
|
|
45
|
-
/>
|
|
46
|
-
`;
|
|
47
|
-
|
|
48
|
-
exports[`ComponentResolverComponent returns null if the component doesn't exist 1`] = `""`;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
|
-
import {
|
|
4
|
-
import { shallowToJson } from "enzyme-to-json";
|
|
3
|
+
import { render } from "@testing-library/react-native";
|
|
5
4
|
import configureStore from "redux-mock-store";
|
|
6
5
|
|
|
7
6
|
const mockLogger = {
|
|
@@ -43,37 +42,36 @@ const store = configureStore()({
|
|
|
43
42
|
});
|
|
44
43
|
|
|
45
44
|
const component = { component_type: "some_component" };
|
|
46
|
-
const decorators =
|
|
45
|
+
const decorators = (x) => x;
|
|
47
46
|
const renderFunction = jest.fn((Comp) => <Comp rendered />);
|
|
48
47
|
|
|
49
48
|
function clearAllMocks() {
|
|
50
|
-
|
|
51
|
-
decorators.mockClear();
|
|
52
|
-
renderFunction.mockClear();
|
|
53
|
-
mockLogger.warning.mockClear();
|
|
49
|
+
jest.clearAllMocks();
|
|
54
50
|
}
|
|
55
51
|
|
|
56
52
|
describe("ComponentResolver", () => {
|
|
57
53
|
beforeEach(clearAllMocks);
|
|
58
54
|
|
|
59
55
|
it("renders correctly", () => {
|
|
60
|
-
const
|
|
56
|
+
const { toJSON } = render(
|
|
61
57
|
<ComponentResolver
|
|
62
58
|
component={component}
|
|
63
59
|
decorators={decorators}
|
|
64
60
|
store={store}
|
|
65
|
-
|
|
61
|
+
>
|
|
62
|
+
{() => null}
|
|
63
|
+
</ComponentResolver>
|
|
66
64
|
);
|
|
67
65
|
|
|
68
|
-
expect(
|
|
66
|
+
expect(toJSON()).toBeNull();
|
|
69
67
|
});
|
|
70
68
|
});
|
|
71
69
|
|
|
72
70
|
describe("ComponentResolverComponent", () => {
|
|
73
71
|
beforeEach(clearAllMocks);
|
|
74
72
|
|
|
75
|
-
const
|
|
76
|
-
|
|
73
|
+
const renderComponent = (component, plugins) =>
|
|
74
|
+
render(
|
|
77
75
|
<ComponentResolverComponent
|
|
78
76
|
components={components}
|
|
79
77
|
component={component}
|
|
@@ -87,9 +85,9 @@ describe("ComponentResolverComponent", () => {
|
|
|
87
85
|
);
|
|
88
86
|
|
|
89
87
|
it("renders the Component if it exists", () => {
|
|
90
|
-
const
|
|
88
|
+
const { toJSON } = renderComponent(component, plugins);
|
|
91
89
|
|
|
92
|
-
expect(
|
|
90
|
+
expect(toJSON()).not.toBeNull();
|
|
93
91
|
|
|
94
92
|
expect(renderFunction).toHaveBeenCalledWith(
|
|
95
93
|
SomeComponent,
|
|
@@ -98,14 +96,12 @@ describe("ComponentResolverComponent", () => {
|
|
|
98
96
|
});
|
|
99
97
|
|
|
100
98
|
it("returns null if the component doesn't exist", () => {
|
|
101
|
-
const
|
|
99
|
+
const { UNSAFE_root } = renderComponent({ component_type: "foo" }, plugins);
|
|
102
100
|
|
|
103
101
|
const warningMessage =
|
|
104
102
|
"Component foo cannot be found - it is skipped from rendering";
|
|
105
103
|
|
|
106
|
-
expect(
|
|
107
|
-
expect(wrapper.isEmptyRender()).toBe(true);
|
|
108
|
-
|
|
104
|
+
expect(UNSAFE_root.children.length).toBe(0);
|
|
109
105
|
expect(mockLogger.warning).toHaveBeenCalledTimes(2);
|
|
110
106
|
|
|
111
107
|
expect(mockLogger.warning).toHaveBeenNthCalledWith(
|
|
@@ -124,11 +120,9 @@ describe("ComponentResolverComponent", () => {
|
|
|
124
120
|
});
|
|
125
121
|
|
|
126
122
|
it("initializes the cell renderer plugin module if matching plugin exists", () => {
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
const wrapper = getWrapper(component, plugins);
|
|
123
|
+
const { toJSON } = renderComponent(component, plugins);
|
|
130
124
|
|
|
131
|
-
expect(
|
|
125
|
+
expect(toJSON()).toMatchSnapshot();
|
|
132
126
|
|
|
133
127
|
expect(renderFunction).toHaveBeenCalledWith(
|
|
134
128
|
SomeComponent,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { render } from "@testing-library/react-native";
|
|
3
3
|
|
|
4
|
-
import { ContentScreen } from "../
|
|
4
|
+
import { ContentScreen } from "../";
|
|
5
5
|
|
|
6
6
|
describe("<ContentScreen />", () => {
|
|
7
7
|
it("renders correctly", () => {
|
|
8
|
-
expect(() =>
|
|
8
|
+
expect(() => render(<ContentScreen />)).toThrowErrorMatchingSnapshot();
|
|
9
9
|
});
|
|
10
10
|
});
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React, { useMemo } from "react";
|
|
2
2
|
import * as R from "ramda";
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
ImageStyle,
|
|
5
5
|
StyleSheet,
|
|
6
6
|
Text,
|
|
7
|
-
ViewStyle,
|
|
8
|
-
TextStyle,
|
|
9
|
-
ImageStyle,
|
|
10
7
|
TextProps,
|
|
8
|
+
TextStyle,
|
|
9
|
+
View,
|
|
10
|
+
ViewStyle,
|
|
11
11
|
} from "react-native";
|
|
12
12
|
import { defaultAsset } from "./defaultAsset";
|
|
13
13
|
import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
@@ -105,6 +105,11 @@ const defaultProps = {
|
|
|
105
105
|
alignItems: "center",
|
|
106
106
|
justifyContent: "center",
|
|
107
107
|
},
|
|
108
|
+
focusedButton: {
|
|
109
|
+
backgroundColor: "#3a3a3a",
|
|
110
|
+
borderColor: "#ffffff",
|
|
111
|
+
borderWidth: 2,
|
|
112
|
+
},
|
|
108
113
|
buttonText: {
|
|
109
114
|
fontFamily: platformSelect({
|
|
110
115
|
ios: "SFProText-Medium",
|
|
@@ -116,6 +121,9 @@ const defaultProps = {
|
|
|
116
121
|
color: "rgba(255, 255, 255, 1)",
|
|
117
122
|
textTransform: "uppercase",
|
|
118
123
|
},
|
|
124
|
+
focusedText: {
|
|
125
|
+
color: "#ffffff",
|
|
126
|
+
},
|
|
119
127
|
},
|
|
120
128
|
};
|
|
121
129
|
|
|
@@ -150,13 +158,13 @@ export function ErrorScreen(props: Props) {
|
|
|
150
158
|
return (
|
|
151
159
|
<View style={[baseStyles.container, styles.screen]}>
|
|
152
160
|
<View style={[baseStyles.container, styles.component]}>
|
|
153
|
-
{assetEnabled
|
|
161
|
+
{assetEnabled ? (
|
|
154
162
|
<Image
|
|
155
163
|
fadeDuration={0}
|
|
156
164
|
source={{ uri: asset }}
|
|
157
165
|
style={styles.asset}
|
|
158
166
|
/>
|
|
159
|
-
)}
|
|
167
|
+
) : null}
|
|
160
168
|
<Text style={styles.title} {...titleProps}>
|
|
161
169
|
{title}
|
|
162
170
|
</Text>
|
|
@@ -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 {
|
|
@@ -33,6 +33,8 @@ type Props = {
|
|
|
33
33
|
onLongPress?: (ref: FocusManager.FocusableRef) => void;
|
|
34
34
|
onRegister?: () => void;
|
|
35
35
|
isFocusableCell?: boolean;
|
|
36
|
+
/** only for FocusableScrollView */
|
|
37
|
+
onSetIsFocusable?: (isFocusable: boolean) => void;
|
|
36
38
|
} & ParentFocus;
|
|
37
39
|
|
|
38
40
|
export const FocusableContext = React.createContext<
|
|
@@ -67,6 +69,7 @@ function FocusableComponent(props: Props, forwardedRef) {
|
|
|
67
69
|
onLongPress,
|
|
68
70
|
onRegister = noop,
|
|
69
71
|
isFocusableCell = true,
|
|
72
|
+
onSetIsFocusable,
|
|
70
73
|
} = props;
|
|
71
74
|
|
|
72
75
|
const isRTL = useIsRTL();
|
|
@@ -137,9 +140,13 @@ function FocusableComponent(props: Props, forwardedRef) {
|
|
|
137
140
|
[onBlur]
|
|
138
141
|
);
|
|
139
142
|
|
|
140
|
-
const setIsFocusable = React.useCallback(
|
|
141
|
-
|
|
142
|
-
|
|
143
|
+
const setIsFocusable = React.useCallback(
|
|
144
|
+
(blockFocus) => {
|
|
145
|
+
onSetIsFocusable?.(blockFocus);
|
|
146
|
+
setDisableFocus(!blockFocus);
|
|
147
|
+
},
|
|
148
|
+
[onSetIsFocusable]
|
|
149
|
+
);
|
|
143
150
|
|
|
144
151
|
const parentFocus = React.useMemo(
|
|
145
152
|
() => ({
|