@applicaster/zapp-react-native-ui-components 15.1.4 → 16.0.0-alpha.1042942411
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/BackgroundImage/index.ts +1 -8
- package/Components/BaseFocusable/index.ios.ts +12 -2
- package/Components/Cell/FocusableWrapper.tsx +3 -0
- package/Components/Cell/TvOSCellComponent.tsx +6 -3
- package/Components/CellRendererResolver/index.ts +1 -1
- package/Components/Focusable/Focusable.tsx +4 -2
- package/Components/Focusable/FocusableTvOS.tsx +18 -1
- package/Components/Focusable/__tests__/__snapshots__/FocusableTvOS.test.tsx.snap +1 -0
- package/Components/FocusableGroup/FocusableTvOS.tsx +30 -1
- package/Components/GeneralContentScreen/GeneralContentScreenHookAdapter.tsx +39 -0
- package/Components/GeneralContentScreen/__tests__/GeneralContentScreenHookAdapter.test.tsx +64 -0
- package/Components/GeneralContentScreen/__tests__/HookContentFocusGroup.web.test.tsx +91 -0
- package/Components/GeneralContentScreen/hookAdapter/__tests__/networkService.test.ts +74 -0
- package/Components/GeneralContentScreen/hookAdapter/__tests__/runInBackground.test.ts +139 -0
- package/Components/GeneralContentScreen/hookAdapter/__tests__/validationHelper.test.ts +124 -0
- package/Components/GeneralContentScreen/hookAdapter/logger.ts +6 -0
- package/Components/GeneralContentScreen/hookAdapter/networkService.ts +53 -0
- package/Components/GeneralContentScreen/hookAdapter/runInBackground.ts +48 -0
- package/Components/GeneralContentScreen/hookAdapter/validationHelper.ts +72 -0
- package/Components/GeneralContentScreen/hookFocus/index.tsx +13 -0
- package/Components/GeneralContentScreen/hookFocus/index.web.tsx +69 -0
- package/Components/GeneralContentScreen/index.ts +2 -0
- package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +1 -1
- package/Components/HandlePlayable/HandlePlayable.tsx +13 -8
- package/Components/Layout/TV/NavBarContainer.tsx +1 -10
- package/Components/Layout/TV/ScreenContainer.tsx +2 -6
- package/Components/Layout/TV/__tests__/__snapshots__/NavBarContainer.test.tsx.snap +7 -12
- package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +7 -12
- package/Components/Layout/TV/index.tsx +3 -4
- package/Components/Layout/TV/index.web.tsx +3 -4
- package/Components/LinkHandler/LinkHandler.tsx +2 -2
- package/Components/MasterCell/CONFIG_BUILDER_TO_REACT_COMPONENT.md +144 -0
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +27 -48
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/model.test.ts +80 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/placement.test.ts +213 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/selectors.test.ts +45 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/style.test.ts +49 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/components/ActionButtonController.tsx +165 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/components/__tests__/ActionButtonController.test.tsx +405 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/components/index.ts +1 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/model.ts +47 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/placement.ts +198 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/selectors.ts +26 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/style.ts +29 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/types.ts +37 -0
- package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx +217 -46
- package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +50 -119
- package/Components/MasterCell/DefaultComponents/Button.tsx +50 -58
- package/Components/MasterCell/DefaultComponents/ButtonContainerView/components/HorizontalSeparator.tsx +8 -0
- package/Components/MasterCell/DefaultComponents/ButtonContainerView/index.android.tv.tsx +58 -0
- package/Components/MasterCell/DefaultComponents/ButtonContainerView/index.tsx +15 -0
- package/Components/MasterCell/DefaultComponents/{tv/ButtonContainerView/index.tsx → ButtonContainerView/index.tv.tsx} +3 -11
- package/Components/MasterCell/DefaultComponents/ButtonContainerView/index.web.ts +1 -0
- package/Components/MasterCell/DefaultComponents/ButtonContainerView/types.ts +40 -0
- package/Components/MasterCell/DefaultComponents/CellBadge/__tests__/__snapshots__/index.test.tsx.snap +18 -0
- package/Components/MasterCell/DefaultComponents/CellBadge/__tests__/index.test.tsx +90 -0
- package/Components/MasterCell/DefaultComponents/CellBadge/index.tsx +13 -14
- package/Components/MasterCell/DefaultComponents/DataProvider/index.tsx +163 -0
- package/Components/MasterCell/DefaultComponents/FocusableView/index.android.tsx +2 -23
- package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +4 -22
- package/Components/MasterCell/DefaultComponents/Image/Image.android.tsx +8 -2
- package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +11 -3
- package/Components/MasterCell/DefaultComponents/Image/Image.web.tsx +9 -1
- package/Components/MasterCell/DefaultComponents/Image/hooks/useImage.ts +15 -14
- package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -3
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +1 -2
- package/Components/MasterCell/DefaultComponents/PressableView.tsx +54 -0
- package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +46 -50
- package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +47 -39
- package/Components/MasterCell/DefaultComponents/SecondaryImage/hooks/__tests__/useGetImageDimensions.test.ts +7 -6
- package/Components/MasterCell/DefaultComponents/SecondaryImage/utils.ts +19 -6
- package/Components/MasterCell/DefaultComponents/Text/hooks/useText.ts +15 -0
- package/Components/MasterCell/DefaultComponents/Text/index.tsx +45 -15
- package/Components/MasterCell/DefaultComponents/UIKitAdapters/Badge.tsx +49 -0
- package/Components/MasterCell/DefaultComponents/__tests__/ActionButton.test.tsx +122 -0
- package/Components/MasterCell/DefaultComponents/__tests__/Button.test.tsx +186 -0
- package/Components/MasterCell/DefaultComponents/__tests__/DataProvider.test.tsx +141 -0
- package/Components/MasterCell/DefaultComponents/__tests__/DynamicBadge.test.tsx +156 -0
- package/Components/MasterCell/DefaultComponents/__tests__/__snapshots__/ActionButton.test.tsx.snap +60 -0
- package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +196 -67
- package/Components/MasterCell/DefaultComponents/index.ts +13 -3
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/ActionButton.tsx +189 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Asset.ts +33 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/AssetComponent.tsx +33 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Button.ts +159 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Spacer.ts +18 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/TextLabel.ts +67 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/TextLabelsContainer.ts +39 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/PressableView.test.tsx +402 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/builders.test.ts +141 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/index.test.ts +354 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/helpers.ts +105 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/index.ts +129 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/__tests__/insertButtons.test.ts +123 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/index.ts +238 -0
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/Asset.ts +4 -18
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/Button.ts +24 -73
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/TextLabelsContainer.ts +37 -18
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/TvActionButton.tsx +27 -0
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/__tests__/index.test.ts +89 -0
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/__tests__/renderedTree.test.tsx +231 -0
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/index.ts +47 -48
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/__tests__/getPluginIdentifier.test.ts +115 -29
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/__tests__/insertButtonsBetweenLabels.test.ts +45 -13
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/index.ts +101 -144
- package/Components/MasterCell/MappingFunctions/index.js +3 -2
- package/Components/MasterCell/README.md +4 -0
- package/Components/MasterCell/__tests__/__snapshots__/dataAdapter.test.js.snap +24 -0
- package/Components/MasterCell/__tests__/configInflater.test.js +1 -0
- package/Components/MasterCell/__tests__/elementMapper.test.js +46 -0
- package/Components/MasterCell/contexts/PressedStateContext.ts +3 -0
- package/Components/MasterCell/dataAdapter.ts +4 -1
- package/Components/MasterCell/elementMapper.tsx +54 -7
- package/Components/MasterCell/hooks/index.ts +2 -0
- package/Components/MasterCell/hooks/usePressedState.ts +4 -0
- package/Components/MasterCell/index.tsx +20 -4
- package/Components/MasterCell/utils/__tests__/cloneChildrenWithIds.test.tsx +43 -0
- package/Components/MasterCell/utils/__tests__/useFilterChildren.test.tsx +80 -0
- package/Components/MasterCell/utils/index.ts +82 -16
- package/Components/ModalComponent/AudioPlayer/Components/Action.tsx +33 -69
- package/Components/ModalComponent/AudioPlayer/Components/Button.tsx +25 -47
- package/Components/ModalComponent/AudioPlayer/Components/Header.tsx +122 -39
- package/Components/ModalComponent/AudioPlayer/Components/Input.tsx +671 -0
- package/Components/ModalComponent/AudioPlayer/Components/Item.tsx +257 -88
- package/Components/ModalComponent/AudioPlayer/Components/index.ts +6 -4
- package/Components/ModalComponent/BottomSheetDragArea.tsx +33 -0
- package/Components/ModalComponent/BottomSheetModalContent.tsx +17 -10
- package/Components/ModalComponent/__tests__/BottomSheetDragArea.test.tsx +74 -0
- package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +4 -85
- package/Components/OfflineHandler/__tests__/index.test.tsx +101 -32
- package/Components/OfflineHandler/hooks.ts +123 -0
- package/Components/OfflineHandler/index.tsx +51 -73
- package/Components/OfflineHandler/utils/index.ts +1 -13
- package/Components/PlayerContainer/PlayerContainer.tsx +6 -5
- package/Components/PlayerContainer/__tests__/PlayerContainer.test.tsx +2 -4
- package/Components/PreloaderWrapper/index.tsx +1 -1
- package/Components/River/ComponentsMap/ComponentsMap.tsx +8 -21
- package/Components/River/ComponentsMap/hooks/__tests__/useLoadingState.test.ts +1 -1
- package/Components/River/RefreshControl.tsx +19 -105
- package/Components/River/River.tsx +9 -82
- package/Components/River/TV/River.tsx +31 -14
- package/Components/River/TV/index.tsx +8 -4
- package/Components/River/TV/utils/__tests__/toStringOrEmpty.test.ts +30 -0
- package/Components/River/TV/utils/index.ts +4 -0
- package/Components/River/TV/withFocusableGroupForContent.tsx +71 -0
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +4 -0
- package/Components/River/__tests__/componentsMap.test.js +38 -0
- package/Components/River/hooks/__tests__/usePullToRefresh.test.ts +132 -0
- package/Components/River/hooks/index.ts +1 -0
- package/Components/River/hooks/usePullToRefresh.ts +51 -0
- package/Components/Screen/TV/index.web.tsx +4 -2
- package/Components/Screen/__tests__/Screen.test.tsx +65 -42
- package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +68 -44
- package/Components/Screen/hooks.ts +2 -3
- package/Components/Screen/index.tsx +2 -3
- package/Components/Screen/orientationHandler.ts +3 -3
- package/Components/ScreenFeedLoader/ScreenFeedLoader.tsx +5 -3
- package/Components/ScreenResolver/index.tsx +9 -5
- package/Components/ScreenResolverFeedProvider/ScreenResolverFeedProvider.tsx +1 -1
- package/Components/ScreenRevealManager/ScreenRevealManager.ts +40 -8
- package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +86 -69
- package/Components/ScreenRevealManager/withScreenRevealManager.tsx +1 -1
- package/Components/Tabs/TabContent.tsx +7 -4
- package/Components/TopCutoffOverlay/__tests__/TopCutoffOverlay.test.tsx +201 -0
- package/Components/TopCutoffOverlay/hooks/__tests__/useMarginTop.test.ts +130 -0
- package/Components/TopCutoffOverlay/hooks/index.ts +1 -0
- package/Components/TopCutoffOverlay/hooks/useMarginTop.ts +59 -0
- package/Components/TopCutoffOverlay/index.tsx +55 -0
- package/Components/Transitioner/index.js +3 -3
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +5 -5
- package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +15 -7
- package/Components/VideoModal/utils.ts +12 -10
- package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +0 -2
- package/Components/Viewport/ViewportAware/index.tsx +16 -7
- package/Components/Viewport/ViewportEvents/__tests__/viewportEvents.test.js +1 -1
- package/Components/default-cell-renderer/viewTrees/mobile/index.ts +0 -3
- package/Contexts/CachedDimensionsContext/__tests__/index.test.ts +154 -0
- package/Contexts/ScreenContext/index.tsx +25 -18
- package/Contexts/ScreenTrackedViewPositionsContext/__tests__/index.test.tsx +1 -1
- package/Decorators/Analytics/index.tsx +6 -5
- package/Decorators/ConfigurationWrapper/__tests__/__snapshots__/withConfigurationProvider.test.tsx.snap +1 -0
- package/Decorators/ConfigurationWrapper/const.ts +1 -0
- package/Decorators/ZappPipesDataConnector/__tests__/UrlFeedResolver.test.tsx +39 -21
- package/Decorators/ZappPipesDataConnector/__tests__/zappPipesDataConnector.test.js +1 -1
- package/Decorators/ZappPipesDataConnector/index.tsx +2 -2
- package/Decorators/ZappPipesDataConnector/resolvers/StaticFeedResolver.tsx +1 -1
- package/Decorators/ZappPipesDataConnector/resolvers/UrlFeedResolver.tsx +18 -7
- package/Helpers/DataSourceHelper/__tests__/itemLimitForData.test.ts +80 -0
- package/Helpers/DataSourceHelper/index.ts +19 -0
- package/package.json +5 -5
- package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.android.tsx +0 -135
- package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/types.ts +0 -25
- package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +0 -112
- package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +0 -107
- package/Components/OfflineHandler/NotificationView/NotificationView.tsx +0 -153
- package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +0 -67
- package/Components/OfflineHandler/NotificationView/utils.ts +0 -34
- package/Components/River/TV/withTVEventHandler.tsx +0 -36
- package/Helpers/DataSourceHelper/index.js +0 -19
- /package/Components/BackgroundImage/{BackgroundImage.tv.android.tsx → BackgroundImage.android.tv.tsx} +0 -0
- /package/Components/BackgroundImage/{BackgroundImage.tv.ios.tsx → BackgroundImage.ios.tv.tsx} +0 -0
- /package/Components/BackgroundImage/{BackgroundImage.tv.web.tsx → BackgroundImage.tsx} +0 -0
|
@@ -3,19 +3,21 @@
|
|
|
3
3
|
exports[`SecondaryImage - Image SecondaryImage fixed mode should not use async render props 1`] = `
|
|
4
4
|
<View
|
|
5
5
|
style={
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
[
|
|
7
|
+
{
|
|
8
|
+
"borderRadius": 10,
|
|
9
|
+
"height": 100,
|
|
10
|
+
"width": 100,
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"height": 100,
|
|
14
|
+
"width": 100,
|
|
15
|
+
},
|
|
16
|
+
]
|
|
11
17
|
}
|
|
18
|
+
testID="secondary-image-fixed"
|
|
12
19
|
>
|
|
13
20
|
<Image
|
|
14
|
-
displayMode="fixed"
|
|
15
|
-
fitPosition="center"
|
|
16
|
-
fixedHeight={100}
|
|
17
|
-
fixedWidth={100}
|
|
18
|
-
imageSizing="fill"
|
|
19
21
|
source={
|
|
20
22
|
{
|
|
21
23
|
"uri": "someUrl",
|
|
@@ -29,7 +31,6 @@ exports[`SecondaryImage - Image SecondaryImage fixed mode should not use async r
|
|
|
29
31
|
"width": 100,
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
|
-
uri="someUrl"
|
|
33
34
|
/>
|
|
34
35
|
</View>
|
|
35
36
|
`;
|
|
@@ -44,20 +45,20 @@ exports[`SecondaryImage - Image SecondaryImage should render if known dimensions
|
|
|
44
45
|
<View
|
|
45
46
|
onLayout={[Function]}
|
|
46
47
|
style={
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
[
|
|
49
|
+
{
|
|
50
|
+
"borderRadius": 10,
|
|
51
|
+
"height": 100,
|
|
52
|
+
"width": 100,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"height": 100,
|
|
56
|
+
"width": 100,
|
|
57
|
+
},
|
|
58
|
+
]
|
|
52
59
|
}
|
|
53
60
|
>
|
|
54
61
|
<Image
|
|
55
|
-
displayMode="dynamic"
|
|
56
|
-
fitPosition="center"
|
|
57
|
-
fixedHeight={0}
|
|
58
|
-
fixedWidth={0}
|
|
59
|
-
imageSizing="fill"
|
|
60
|
-
onAsyncRender={[Function]}
|
|
61
62
|
source={
|
|
62
63
|
{
|
|
63
64
|
"uri": "someUrl",
|
|
@@ -71,7 +72,6 @@ exports[`SecondaryImage - Image SecondaryImage should render if known dimensions
|
|
|
71
72
|
"width": 100,
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
|
-
uri="someUrl"
|
|
75
75
|
/>
|
|
76
76
|
</View>
|
|
77
77
|
`;
|
|
@@ -79,19 +79,21 @@ exports[`SecondaryImage - Image SecondaryImage should render if known dimensions
|
|
|
79
79
|
exports[`SecondaryImage - Image SecondaryImage should render in fixed mode with known dimensions 1`] = `
|
|
80
80
|
<View
|
|
81
81
|
style={
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
[
|
|
83
|
+
{
|
|
84
|
+
"borderRadius": 10,
|
|
85
|
+
"height": 100,
|
|
86
|
+
"width": 100,
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"height": 100,
|
|
90
|
+
"width": 100,
|
|
91
|
+
},
|
|
92
|
+
]
|
|
87
93
|
}
|
|
94
|
+
testID="secondary-image-fixed"
|
|
88
95
|
>
|
|
89
96
|
<Image
|
|
90
|
-
displayMode="fixed"
|
|
91
|
-
fitPosition="center"
|
|
92
|
-
fixedHeight={100}
|
|
93
|
-
fixedWidth={100}
|
|
94
|
-
imageSizing="fill"
|
|
95
97
|
source={
|
|
96
98
|
{
|
|
97
99
|
"uri": "someUrl",
|
|
@@ -105,7 +107,6 @@ exports[`SecondaryImage - Image SecondaryImage should render in fixed mode with
|
|
|
105
107
|
"width": 100,
|
|
106
108
|
}
|
|
107
109
|
}
|
|
108
|
-
uri="someUrl"
|
|
109
110
|
/>
|
|
110
111
|
</View>
|
|
111
112
|
`;
|
|
@@ -113,11 +114,18 @@ exports[`SecondaryImage - Image SecondaryImage should render in fixed mode with
|
|
|
113
114
|
exports[`SecondaryImage - Image SecondaryImage should render in fixed mode without image until loaded 1`] = `
|
|
114
115
|
<View
|
|
115
116
|
style={
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
[
|
|
118
|
+
{
|
|
119
|
+
"borderRadius": 5,
|
|
120
|
+
"height": 100,
|
|
121
|
+
"width": 100,
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"height": 100,
|
|
125
|
+
"width": 100,
|
|
126
|
+
},
|
|
127
|
+
]
|
|
121
128
|
}
|
|
129
|
+
testID="secondary-image-fixed"
|
|
122
130
|
/>
|
|
123
131
|
`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { renderHook } from "@testing-library/react-
|
|
1
|
+
import { renderHook, waitFor } from "@testing-library/react-native";
|
|
2
2
|
import { Image } from "react-native";
|
|
3
3
|
|
|
4
4
|
import { useGetImageDimensions } from "../useGetImageDimensions";
|
|
@@ -13,15 +13,16 @@ jest.spyOn(Image, "getSize").mockImplementation((_uri, success) => {
|
|
|
13
13
|
|
|
14
14
|
describe("useGetImageDimensions", () => {
|
|
15
15
|
it("should return aspect ration initially when known dimensions", async () => {
|
|
16
|
-
const { result
|
|
16
|
+
const { result } = renderHook(() =>
|
|
17
17
|
useGetImageDimensions("https://some_url.com", WIDTH, undefined)
|
|
18
18
|
);
|
|
19
19
|
|
|
20
20
|
expect(result.current).toBeUndefined();
|
|
21
|
-
await waitForNextUpdate();
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
await waitFor(() => {
|
|
23
|
+
expect(result.current).toEqual(
|
|
24
|
+
getDimension({ width: WIDTH, height: HEIGTH })
|
|
25
|
+
);
|
|
26
|
+
});
|
|
26
27
|
});
|
|
27
28
|
});
|
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
import { identity, isNil } from "ramda";
|
|
2
2
|
import {
|
|
3
3
|
POSITION_OVER_IMAGE,
|
|
4
|
-
DISPLAY_MODE_DYNAMIC,
|
|
5
4
|
DISPLAY_MODE_FIXED,
|
|
6
5
|
VISIBILITY_ALWAYS,
|
|
7
6
|
VISIBILITY_DEFAULT,
|
|
8
7
|
VISIBILITY_FOCUSED,
|
|
9
8
|
IMAGE_POSITION,
|
|
10
9
|
IMAGE_SIZING_FIT,
|
|
11
|
-
IMAGE_SIZING_FILL,
|
|
12
10
|
FIT_POSITION,
|
|
13
11
|
} from "@applicaster/zapp-react-native-utils/manifestUtils/secondaryImage";
|
|
14
12
|
import { ImageStyle } from "react-native";
|
|
13
|
+
import type {
|
|
14
|
+
SecondaryImageDisplayMode,
|
|
15
|
+
SecondaryImageFitPosition,
|
|
16
|
+
SecondaryImageImageSizing,
|
|
17
|
+
} from "@applicaster/uikit/lib/components/uikit/secondary-image/types";
|
|
15
18
|
|
|
16
19
|
const SECONDARY_IMAGE_PREFIX = "secondary_image";
|
|
17
20
|
|
|
18
|
-
type ImageSizing =
|
|
21
|
+
export type ImageSizing = SecondaryImageImageSizing;
|
|
22
|
+
|
|
23
|
+
export type FitPosition = SecondaryImageFitPosition;
|
|
19
24
|
|
|
20
25
|
type ImagePosition = (typeof IMAGE_POSITION)[keyof typeof IMAGE_POSITION];
|
|
21
26
|
|
|
22
|
-
export type DisplayMode =
|
|
23
|
-
| typeof DISPLAY_MODE_FIXED
|
|
24
|
-
| typeof DISPLAY_MODE_DYNAMIC;
|
|
27
|
+
export type DisplayMode = SecondaryImageDisplayMode;
|
|
25
28
|
|
|
26
29
|
export enum SecondaryImageStyleKeys {
|
|
27
30
|
ENABLE = "switch",
|
|
@@ -174,6 +177,16 @@ export const getStyle = ({
|
|
|
174
177
|
imageDimension,
|
|
175
178
|
containerWidth,
|
|
176
179
|
containerHeight,
|
|
180
|
+
}: {
|
|
181
|
+
imageSizing: ImageSizing;
|
|
182
|
+
fitPosition: FitPosition;
|
|
183
|
+
displayMode: DisplayMode;
|
|
184
|
+
imageDimension: {
|
|
185
|
+
width: number;
|
|
186
|
+
height: number;
|
|
187
|
+
};
|
|
188
|
+
containerWidth: number;
|
|
189
|
+
containerHeight: number;
|
|
177
190
|
}): ImageStyle => {
|
|
178
191
|
if (!isImageSizingFit(imageSizing)) {
|
|
179
192
|
return {
|
|
@@ -45,6 +45,7 @@ export const useTextLabel = ({ label, entry }): string => {
|
|
|
45
45
|
const [entryStateLocal, setEntryStateLocal] =
|
|
46
46
|
React.useState(initialEntryState);
|
|
47
47
|
|
|
48
|
+
// For favourites
|
|
48
49
|
React.useEffect(() => {
|
|
49
50
|
return action?.addListeners?.(({ entryState, entry: actionEntry }) => {
|
|
50
51
|
if (entry.id === actionEntry.id) {
|
|
@@ -53,6 +54,16 @@ export const useTextLabel = ({ label, entry }): string => {
|
|
|
53
54
|
});
|
|
54
55
|
}, []);
|
|
55
56
|
|
|
57
|
+
// For rest actions
|
|
58
|
+
React.useEffect(() => {
|
|
59
|
+
// Update entryStateLocal when action state changes. Example: state change when pressing the download button.
|
|
60
|
+
if (typeof action?.addListener === "function") {
|
|
61
|
+
return action.addListener(String(entry?.id), (nextState) => {
|
|
62
|
+
setEntryStateLocal(nextState);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}, []);
|
|
66
|
+
|
|
56
67
|
if (context && name && action) {
|
|
57
68
|
return prepareHebrewText(extractLabel(entryStateLocal.label, name), isRTL);
|
|
58
69
|
}
|
|
@@ -72,6 +83,10 @@ export const useTextLabel = ({ label, entry }): string => {
|
|
|
72
83
|
return prepareHebrewText(label, isRTL);
|
|
73
84
|
};
|
|
74
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Uses `otherProps.state` ("focused" | "default") to select between `focusedStyles` and `normalStyles`.
|
|
88
|
+
* For mobile action buttons, map `usePressedState()` (boolean) to this state value (e.g. pressed ? "focused" : "default").
|
|
89
|
+
*/
|
|
75
90
|
export const withFocusedStyles = ({ style, otherProps }) => {
|
|
76
91
|
const state = R.path(["state"], otherProps);
|
|
77
92
|
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { Text } from "react-native";
|
|
3
|
-
import { omit } from "ramda";
|
|
4
2
|
import {
|
|
5
3
|
textTransform,
|
|
6
4
|
dateFormat,
|
|
7
5
|
} from "@applicaster/zapp-react-native-utils/cellUtils";
|
|
6
|
+
import { Text as UIKitText } from "@applicaster/uikit/lib/components/uikit/text";
|
|
8
7
|
|
|
9
8
|
import { useTextLabel, withFocusedStyles } from "./hooks";
|
|
10
9
|
import { toNumber } from "@applicaster/zapp-react-native-utils/numberUtils";
|
|
@@ -20,11 +19,18 @@ type Props = {
|
|
|
20
19
|
entry?: any;
|
|
21
20
|
dateTransformEnabled: boolean;
|
|
22
21
|
dateTransform: string;
|
|
23
|
-
|
|
22
|
+
state?: string;
|
|
23
|
+
focusedStyles?: any;
|
|
24
|
+
normalStyles?: any;
|
|
25
|
+
numberOfLines?: number;
|
|
26
|
+
ellipsizeMode?: "head" | "middle" | "tail" | "clip";
|
|
27
|
+
testID?: string;
|
|
28
|
+
accessibilityLabel?: string;
|
|
29
|
+
accessibilityHint?: string;
|
|
30
|
+
nativeID?: string;
|
|
31
|
+
selectable?: boolean;
|
|
24
32
|
};
|
|
25
33
|
|
|
26
|
-
const withoutLabel = omit(["label"]);
|
|
27
|
-
|
|
28
34
|
const _Text = ({
|
|
29
35
|
style,
|
|
30
36
|
label,
|
|
@@ -32,7 +38,16 @@ const _Text = ({
|
|
|
32
38
|
transformText = "default",
|
|
33
39
|
dateTransformEnabled = false,
|
|
34
40
|
dateTransform,
|
|
35
|
-
|
|
41
|
+
state,
|
|
42
|
+
focusedStyles,
|
|
43
|
+
normalStyles,
|
|
44
|
+
numberOfLines,
|
|
45
|
+
ellipsizeMode,
|
|
46
|
+
testID,
|
|
47
|
+
accessibilityLabel,
|
|
48
|
+
accessibilityHint,
|
|
49
|
+
nativeID,
|
|
50
|
+
selectable,
|
|
36
51
|
}: Props) => {
|
|
37
52
|
const _label = useTextLabel({ label, entry });
|
|
38
53
|
const isMeasurement = React.useContext(MeasurementPortalContext);
|
|
@@ -42,8 +57,8 @@ const _Text = ({
|
|
|
42
57
|
|
|
43
58
|
// set maximum possible height for the text in case of measurement
|
|
44
59
|
const height =
|
|
45
|
-
isMeasurement &&
|
|
46
|
-
? toNumber(
|
|
60
|
+
isMeasurement && numberOfLines && style.lineHeight
|
|
61
|
+
? toNumber(numberOfLines) * toNumber(style.lineHeight)
|
|
47
62
|
: undefined;
|
|
48
63
|
|
|
49
64
|
const textLabel = dateTransformEnabled
|
|
@@ -52,7 +67,7 @@ const _Text = ({
|
|
|
52
67
|
|
|
53
68
|
React.useLayoutEffect(() => {
|
|
54
69
|
if (cellFocused) {
|
|
55
|
-
switch (
|
|
70
|
+
switch (state) {
|
|
56
71
|
case "focused":
|
|
57
72
|
accessibilityManager.addHeading(textLabel);
|
|
58
73
|
break;
|
|
@@ -61,20 +76,35 @@ const _Text = ({
|
|
|
61
76
|
break;
|
|
62
77
|
}
|
|
63
78
|
}
|
|
64
|
-
}, [cellFocused,
|
|
79
|
+
}, [accessibilityManager, cellFocused, state, textLabel]);
|
|
65
80
|
|
|
66
81
|
if (isNilOrEmpty(_label)) {
|
|
67
82
|
return null;
|
|
68
83
|
}
|
|
69
84
|
|
|
70
85
|
return (
|
|
71
|
-
<
|
|
72
|
-
style={[
|
|
73
|
-
|
|
74
|
-
|
|
86
|
+
<UIKitText
|
|
87
|
+
style={[
|
|
88
|
+
withFocusedStyles({
|
|
89
|
+
style,
|
|
90
|
+
otherProps: {
|
|
91
|
+
state,
|
|
92
|
+
focusedStyles,
|
|
93
|
+
normalStyles,
|
|
94
|
+
},
|
|
95
|
+
}),
|
|
96
|
+
{ height },
|
|
97
|
+
]}
|
|
98
|
+
numberOfLines={numberOfLines}
|
|
99
|
+
ellipsizeMode={ellipsizeMode}
|
|
100
|
+
testID={testID}
|
|
101
|
+
accessibilityLabel={accessibilityLabel}
|
|
102
|
+
accessibilityHint={accessibilityHint}
|
|
103
|
+
nativeID={nativeID}
|
|
104
|
+
selectable={selectable}
|
|
75
105
|
>
|
|
76
106
|
{textLabel}
|
|
77
|
-
</
|
|
107
|
+
</UIKitText>
|
|
78
108
|
);
|
|
79
109
|
};
|
|
80
110
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
Badge,
|
|
4
|
+
BadgeProps,
|
|
5
|
+
} from "@applicaster/uikit/lib/components/uikit/badge";
|
|
6
|
+
import { ViewStyle } from "react-native";
|
|
7
|
+
|
|
8
|
+
export const UIKitBadge = ({
|
|
9
|
+
children,
|
|
10
|
+
style,
|
|
11
|
+
position,
|
|
12
|
+
width,
|
|
13
|
+
height,
|
|
14
|
+
margins,
|
|
15
|
+
onPress,
|
|
16
|
+
testID,
|
|
17
|
+
accessibilityLabel,
|
|
18
|
+
accessibilityHint,
|
|
19
|
+
}: {
|
|
20
|
+
children?: React.ReactNode;
|
|
21
|
+
style?: BadgeProps["style"];
|
|
22
|
+
position?: BadgeProps["position"];
|
|
23
|
+
width?: BadgeProps["width"];
|
|
24
|
+
height?: BadgeProps["height"];
|
|
25
|
+
margins?: Pick<
|
|
26
|
+
ViewStyle,
|
|
27
|
+
"marginTop" | "marginRight" | "marginBottom" | "marginLeft"
|
|
28
|
+
>;
|
|
29
|
+
onPress?: BadgeProps["onPress"];
|
|
30
|
+
testID?: BadgeProps["testID"];
|
|
31
|
+
accessibilityLabel?: BadgeProps["accessibilityLabel"];
|
|
32
|
+
accessibilityHint?: BadgeProps["accessibilityHint"];
|
|
33
|
+
}) => (
|
|
34
|
+
<Badge
|
|
35
|
+
onPress={onPress}
|
|
36
|
+
testID={testID}
|
|
37
|
+
accessibilityLabel={accessibilityLabel}
|
|
38
|
+
accessibilityHint={accessibilityHint}
|
|
39
|
+
position={position}
|
|
40
|
+
width={width}
|
|
41
|
+
height={height}
|
|
42
|
+
style={{
|
|
43
|
+
...style,
|
|
44
|
+
...margins,
|
|
45
|
+
}}
|
|
46
|
+
>
|
|
47
|
+
{children}
|
|
48
|
+
</Badge>
|
|
49
|
+
);
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { TouchableOpacity } from "react-native";
|
|
3
|
+
import { render } from "@testing-library/react-native";
|
|
4
|
+
|
|
5
|
+
import { ActionButton } from "../ActionButton";
|
|
6
|
+
|
|
7
|
+
const mockUseActions = jest.fn();
|
|
8
|
+
|
|
9
|
+
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/actions", () => ({
|
|
10
|
+
useActions: (...args) => mockUseActions(...args),
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
|
|
14
|
+
useTheme: jest.fn(() => ({
|
|
15
|
+
use_downscaling_images: false,
|
|
16
|
+
})),
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
describe("MasterCell ActionButton", () => {
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
jest.clearAllMocks();
|
|
22
|
+
|
|
23
|
+
mockUseActions.mockReturnValue({
|
|
24
|
+
initialEntryState: () => ({
|
|
25
|
+
asset: "active.png",
|
|
26
|
+
}),
|
|
27
|
+
invokeAction: jest.fn(),
|
|
28
|
+
addListener: jest.fn(),
|
|
29
|
+
isActionAvailable: jest.fn(() => true),
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("renders using UIKit ActionButton and passes Image AssetComponent for image assets", () => {
|
|
34
|
+
const item = {
|
|
35
|
+
id: "entry-id",
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const wrapper = render(
|
|
39
|
+
<ActionButton
|
|
40
|
+
item={item as any}
|
|
41
|
+
action={{ identifier: "bookmark" }}
|
|
42
|
+
asset={{
|
|
43
|
+
type: "Image",
|
|
44
|
+
src: {
|
|
45
|
+
active: "active.png",
|
|
46
|
+
inactive: "inactive.png",
|
|
47
|
+
},
|
|
48
|
+
style: {
|
|
49
|
+
width: 32,
|
|
50
|
+
height: 32,
|
|
51
|
+
},
|
|
52
|
+
props: {
|
|
53
|
+
testID: "action-button-image",
|
|
54
|
+
},
|
|
55
|
+
}}
|
|
56
|
+
style={{
|
|
57
|
+
width: 32,
|
|
58
|
+
height: 32,
|
|
59
|
+
}}
|
|
60
|
+
testID="action-button"
|
|
61
|
+
accessibilityLabel="action-button-label"
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const button = wrapper.getByTestId("action-button");
|
|
66
|
+
const image = wrapper.getByTestId("action-button-image");
|
|
67
|
+
|
|
68
|
+
expect(button.props.accessibilityLabel).toBe("action-button-label");
|
|
69
|
+
|
|
70
|
+
expect(image.props.source).toEqual({ uri: "inactive.png" });
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('matches the rendered "action-button" snapshot', () => {
|
|
74
|
+
const wrapper = render(
|
|
75
|
+
<ActionButton
|
|
76
|
+
item={{ id: "entry-id" } as any}
|
|
77
|
+
action={{ identifier: "bookmark" }}
|
|
78
|
+
asset={{
|
|
79
|
+
type: "Image",
|
|
80
|
+
src: {
|
|
81
|
+
active: "active.png",
|
|
82
|
+
inactive: "inactive.png",
|
|
83
|
+
},
|
|
84
|
+
style: {
|
|
85
|
+
width: 32,
|
|
86
|
+
height: 32,
|
|
87
|
+
},
|
|
88
|
+
props: {
|
|
89
|
+
testID: "action-button-image",
|
|
90
|
+
},
|
|
91
|
+
}}
|
|
92
|
+
style={{
|
|
93
|
+
width: 32,
|
|
94
|
+
height: 32,
|
|
95
|
+
}}
|
|
96
|
+
testID="action-button"
|
|
97
|
+
accessibilityLabel="action-button-label"
|
|
98
|
+
/>
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
expect(wrapper.UNSAFE_getByType(TouchableOpacity).props).toMatchObject({
|
|
102
|
+
activeOpacity: 1,
|
|
103
|
+
id: "action-button-entry-id",
|
|
104
|
+
testID: "action-button",
|
|
105
|
+
accessibilityLabel: "action-button-label",
|
|
106
|
+
accessible: true,
|
|
107
|
+
accessibilityHint: undefined,
|
|
108
|
+
style: { width: 32, height: 32 },
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
expect(
|
|
112
|
+
wrapper.UNSAFE_getByType(TouchableOpacity).props.children.props
|
|
113
|
+
).toMatchObject({
|
|
114
|
+
fadeDuration: 0,
|
|
115
|
+
style: { width: 32, height: 32 },
|
|
116
|
+
uri: "inactive.png",
|
|
117
|
+
testID: "action-button-image",
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
121
|
+
});
|
|
122
|
+
});
|