@applicaster/zapp-react-native-ui-components 15.0.0-rc.13 → 15.0.0-rc.132

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.
Files changed (189) hide show
  1. package/Components/AnimatedInOut/index.tsx +69 -26
  2. package/Components/BaseFocusable/index.ios.ts +12 -2
  3. package/Components/Cell/Cell.tsx +14 -3
  4. package/Components/Cell/CellWithFocusable.tsx +9 -0
  5. package/Components/Cell/FocusableWrapper.tsx +3 -0
  6. package/Components/Cell/TvOSCellComponent.tsx +30 -6
  7. package/Components/Focusable/Focusable.tsx +4 -2
  8. package/Components/Focusable/FocusableTvOS.tsx +18 -1
  9. package/Components/Focusable/__tests__/__snapshots__/FocusableTvOS.test.tsx.snap +1 -0
  10. package/Components/FocusableGroup/FocusableTvOS.tsx +32 -1
  11. package/Components/GeneralContentScreen/GeneralContentScreen.tsx +39 -28
  12. package/Components/GeneralContentScreen/__tests__/GeneralContentScreen.test.tsx +104 -0
  13. package/Components/GeneralContentScreen/utils/__tests__/getScreenDataSource.test.ts +19 -0
  14. package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +1 -1
  15. package/Components/GeneralContentScreen/utils/getScreenDataSource.ts +9 -0
  16. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +22 -6
  17. package/Components/HandlePlayable/HandlePlayable.tsx +33 -94
  18. package/Components/HandlePlayable/const.ts +3 -0
  19. package/Components/HandlePlayable/utils.ts +105 -0
  20. package/Components/HookRenderer/HookRenderer.tsx +40 -10
  21. package/Components/HookRenderer/__tests__/HookRenderer.test.tsx +60 -0
  22. package/Components/Layout/TV/LayoutBackground.tsx +5 -2
  23. package/Components/Layout/TV/NavBarContainer.tsx +1 -10
  24. package/Components/Layout/TV/ScreenContainer.tsx +2 -6
  25. package/Components/Layout/TV/__tests__/__snapshots__/NavBarContainer.test.tsx.snap +7 -12
  26. package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +7 -12
  27. package/Components/Layout/TV/index.tsx +3 -4
  28. package/Components/Layout/TV/index.web.tsx +3 -4
  29. package/Components/LinkHandler/LinkHandler.tsx +2 -2
  30. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/model.test.ts +80 -0
  31. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/placement.test.ts +187 -0
  32. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/selectors.test.ts +45 -0
  33. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/style.test.ts +49 -0
  34. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/model.ts +47 -0
  35. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/placement.ts +170 -0
  36. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/selectors.ts +26 -0
  37. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/style.ts +29 -0
  38. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/types.ts +37 -0
  39. package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx +16 -1
  40. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +30 -2
  41. package/Components/MasterCell/DefaultComponents/Button.tsx +0 -15
  42. package/Components/MasterCell/DefaultComponents/Image/Image.android.tsx +5 -1
  43. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +11 -3
  44. package/Components/MasterCell/DefaultComponents/Image/Image.web.tsx +9 -1
  45. package/Components/MasterCell/DefaultComponents/Image/hooks/useImage.ts +15 -14
  46. package/Components/MasterCell/DefaultComponents/LiveImage/__tests__/prepareEntry.test.ts +352 -0
  47. package/Components/MasterCell/DefaultComponents/LiveImage/executePreloadHooks.ts +136 -0
  48. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +43 -22
  49. package/Components/MasterCell/DefaultComponents/PressableView.tsx +196 -0
  50. package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +40 -39
  51. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/Image.test.tsx +95 -0
  52. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +86 -0
  53. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/index.test.ts +141 -0
  54. package/Components/MasterCell/DefaultComponents/SecondaryImage/hooks/__tests__/useGetImageDimensions.test.ts +7 -6
  55. package/Components/MasterCell/DefaultComponents/SecondaryImage/index.ts +1 -1
  56. package/Components/MasterCell/DefaultComponents/Text/index.tsx +10 -14
  57. package/Components/MasterCell/DefaultComponents/index.ts +2 -0
  58. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Asset.ts +46 -0
  59. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Button.ts +126 -0
  60. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/ButtonContainerView.ts +23 -0
  61. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Spacer.ts +16 -0
  62. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/TextLabel.ts +67 -0
  63. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/TextLabelsContainer.ts +32 -0
  64. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/PressableView.test.tsx +191 -0
  65. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/builders.test.ts +140 -0
  66. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/index.test.ts +222 -0
  67. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/helpers.ts +105 -0
  68. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/index.ts +104 -0
  69. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/__tests__/insertButtons.test.ts +118 -0
  70. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/index.ts +73 -0
  71. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/__tests__/index.test.ts +86 -0
  72. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/index.ts +35 -48
  73. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/__tests__/getPluginIdentifier.test.ts +115 -29
  74. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/index.ts +39 -144
  75. package/Components/MasterCell/elementMapper.tsx +1 -0
  76. package/Components/MasterCell/hoc/__tests__/withAsyncRender.test.tsx +219 -0
  77. package/Components/MasterCell/hoc/withAsyncRender.tsx +9 -7
  78. package/Components/MasterCell/index.tsx +2 -0
  79. package/Components/MasterCell/utils/__tests__/resolveColor.test.js +82 -3
  80. package/Components/MasterCell/utils/index.ts +61 -31
  81. package/Components/MeasurmentsPortal/MeasurementsPortal.tsx +102 -87
  82. package/Components/MeasurmentsPortal/__tests__/MeasurementsPortal.test.tsx +355 -0
  83. package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +17 -9
  84. package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +16 -8
  85. package/Components/OfflineHandler/NotificationView/NotificationView.tsx +2 -2
  86. package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +17 -18
  87. package/Components/OfflineHandler/NotificationView/utils.ts +34 -0
  88. package/Components/OfflineHandler/__tests__/index.test.tsx +27 -18
  89. package/Components/PlayerContainer/PlayerContainer.tsx +43 -64
  90. package/Components/PlayerImageBackground/index.tsx +3 -22
  91. package/Components/PreloaderWrapper/__tests__/index.test.tsx +26 -0
  92. package/Components/PreloaderWrapper/index.tsx +15 -0
  93. package/Components/River/ComponentsMap/ComponentsMap.tsx +16 -0
  94. package/Components/River/ComponentsMap/hooks/__tests__/useLoadingState.test.ts +1 -1
  95. package/Components/River/RefreshControl.tsx +36 -13
  96. package/Components/River/RiverItem.tsx +26 -20
  97. package/Components/River/TV/River.tsx +31 -14
  98. package/Components/River/TV/index.tsx +8 -4
  99. package/Components/River/TV/utils/__tests__/toStringOrEmpty.test.ts +30 -0
  100. package/Components/River/TV/utils/index.ts +4 -0
  101. package/Components/River/TV/withFocusableGroupForContent.tsx +71 -0
  102. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +2 -0
  103. package/Components/River/__tests__/componentsMap.test.js +38 -0
  104. package/Components/Screen/TV/index.web.tsx +4 -2
  105. package/Components/Screen/__tests__/Screen.test.tsx +66 -42
  106. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +68 -44
  107. package/Components/Screen/hooks.ts +75 -6
  108. package/Components/Screen/index.tsx +9 -4
  109. package/Components/Screen/navigationHandler.ts +49 -24
  110. package/Components/Screen/orientationHandler.ts +10 -13
  111. package/Components/ScreenFeedLoader/ScreenFeedLoader.tsx +46 -0
  112. package/Components/ScreenFeedLoader/__tests__/ScreenFeedLoader.test.tsx +94 -0
  113. package/Components/ScreenFeedLoader/index.ts +1 -0
  114. package/Components/ScreenResolver/__tests__/screenResolver.test.js +24 -0
  115. package/Components/ScreenResolver/hooks/index.ts +3 -0
  116. package/Components/ScreenResolver/hooks/useGetComponent.ts +15 -0
  117. package/Components/ScreenResolver/hooks/useScreenComponentResolver.tsx +90 -0
  118. package/Components/ScreenResolver/index.tsx +15 -111
  119. package/Components/ScreenResolver/utils/__tests__/getScreenTypeProps.test.ts +45 -0
  120. package/Components/ScreenResolver/utils/getScreenTypeProps.ts +43 -0
  121. package/Components/ScreenResolver/utils/index.ts +1 -0
  122. package/Components/ScreenResolver/withDefaultScreenContext.tsx +16 -0
  123. package/Components/ScreenResolverFeedProvider/ScreenResolverFeedProvider.tsx +25 -0
  124. package/Components/ScreenResolverFeedProvider/__tests__/ScreenResolverFeedProvider.test.tsx +44 -0
  125. package/Components/ScreenResolverFeedProvider/index.ts +1 -0
  126. package/Components/ScreenRevealManager/ScreenRevealManager.ts +40 -8
  127. package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +86 -69
  128. package/Components/ScreenRevealManager/withScreenRevealManager.tsx +44 -26
  129. package/Components/Tabs/TV/Tabs.tsx +20 -3
  130. package/Components/Tabs/TabContent.tsx +7 -4
  131. package/Components/Transitioner/Scene.tsx +10 -3
  132. package/Components/Transitioner/index.js +3 -3
  133. package/Components/VideoLive/LiveImageManager.ts +199 -54
  134. package/Components/VideoLive/PlayerLiveImageComponent.tsx +31 -33
  135. package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +2 -17
  136. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +1 -0
  137. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +118 -171
  138. package/Components/VideoModal/ModalAnimation/index.ts +2 -13
  139. package/Components/VideoModal/ModalAnimation/utils.ts +1 -327
  140. package/Components/VideoModal/PlayerWrapper.tsx +14 -88
  141. package/Components/VideoModal/VideoModal.tsx +1 -5
  142. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -0
  143. package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +15 -7
  144. package/Components/VideoModal/hooks/useModalSize.ts +10 -5
  145. package/Components/VideoModal/playerWrapperStyle.ts +70 -0
  146. package/Components/VideoModal/playerWrapperUtils.ts +91 -0
  147. package/Components/VideoModal/utils.ts +19 -9
  148. package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +0 -2
  149. package/Components/Viewport/ViewportAware/index.tsx +16 -7
  150. package/Components/Viewport/ViewportEvents/__tests__/viewportEvents.test.js +1 -1
  151. package/Components/ZappUIComponent/index.tsx +12 -6
  152. package/Components/default-cell-renderer/viewTrees/mobile/index.ts +0 -3
  153. package/Components/index.js +1 -1
  154. package/Contexts/ScreenContext/__tests__/index.test.tsx +57 -0
  155. package/Contexts/ScreenContext/index.tsx +71 -19
  156. package/Contexts/ScreenTrackedViewPositionsContext/__tests__/index.test.tsx +1 -1
  157. package/Contexts/ZappHookModalContext/index.tsx +37 -61
  158. package/Contexts/ZappPipesContext/ZappPipesContextFactory.tsx +18 -7
  159. package/Contexts/index.ts +0 -2
  160. package/Decorators/Analytics/index.tsx +6 -5
  161. package/Decorators/ConfigurationWrapper/__tests__/__snapshots__/withConfigurationProvider.test.tsx.snap +1 -0
  162. package/Decorators/ConfigurationWrapper/const.ts +1 -0
  163. package/Decorators/ZappPipesDataConnector/ResolverSelector.tsx +25 -7
  164. package/Decorators/ZappPipesDataConnector/__tests__/ResolverSelector.test.tsx +212 -5
  165. package/Decorators/ZappPipesDataConnector/__tests__/UrlFeedResolver.test.tsx +39 -21
  166. package/Decorators/ZappPipesDataConnector/__tests__/zappPipesDataConnector.test.js +1 -1
  167. package/Decorators/ZappPipesDataConnector/index.tsx +2 -2
  168. package/Decorators/ZappPipesDataConnector/resolvers/StaticFeedResolver.tsx +1 -1
  169. package/Decorators/ZappPipesDataConnector/resolvers/UrlFeedResolver.tsx +18 -7
  170. package/Helpers/DataSourceHelper/__tests__/itemLimitForData.test.ts +80 -0
  171. package/Helpers/DataSourceHelper/index.ts +19 -0
  172. package/events/index.ts +3 -0
  173. package/events/scrollEndReached.ts +15 -0
  174. package/index.d.ts +7 -0
  175. package/package.json +6 -5
  176. package/Components/MasterCell/DefaultComponents/Text/utils/__tests__/withAdjustedLineHeight.test.ts +0 -46
  177. package/Components/MasterCell/DefaultComponents/Text/utils/index.ts +0 -21
  178. package/Components/PlayerContainer/ErrorDisplay/ErrorDisplay.tsx +0 -57
  179. package/Components/PlayerContainer/ErrorDisplay/index.ts +0 -9
  180. package/Components/River/TV/withTVEventHandler.tsx +0 -27
  181. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +0 -60
  182. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +0 -417
  183. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.web.tsx +0 -294
  184. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +0 -176
  185. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.web.tsx +0 -93
  186. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +0 -500
  187. package/Components/VideoModal/ModalAnimation/__tests__/getMoveUpValue.test.ts +0 -108
  188. package/Helpers/DataSourceHelper/index.js +0 -19
  189. /package/Components/HookRenderer/{index.tsx → index.ts} +0 -0
@@ -103,7 +103,7 @@ export const SecondaryImage = ({ value, currentPosition, state }: Props) => {
103
103
  data: [
104
104
  {
105
105
  func: "image_src_from_media_item",
106
- args: [imageKey],
106
+ args: [imageKey, false],
107
107
  propName: "uri",
108
108
  },
109
109
  ],
@@ -7,7 +7,6 @@ import {
7
7
  } from "@applicaster/zapp-react-native-utils/cellUtils";
8
8
 
9
9
  import { useTextLabel, withFocusedStyles } from "./hooks";
10
- import { withScaledLineHeight } from "./utils";
11
10
  import { toNumber } from "@applicaster/zapp-react-native-utils/numberUtils";
12
11
  import { MeasurementPortalContext } from "../../../MeasurmentsPortal";
13
12
  import { isNilOrEmpty } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
@@ -52,14 +51,14 @@ const _Text = ({
52
51
  : textTransform(transformText, _label);
53
52
 
54
53
  React.useLayoutEffect(() => {
55
- // For FocusableCells with action buttons
56
- if (otherProps.state) {
57
- if (otherProps.state === "focused" && cellFocused === true) {
58
- accessibilityManager.addHeading(textLabel);
59
- }
60
- } else {
61
- if (cellFocused === true) {
62
- accessibilityManager.addHeading(textLabel);
54
+ if (cellFocused) {
55
+ switch (otherProps.state) {
56
+ case "focused":
57
+ accessibilityManager.addHeading(textLabel);
58
+ break;
59
+ case "focused_selected":
60
+ accessibilityManager.addHeading(`${textLabel}, Selected`);
61
+ break;
63
62
  }
64
63
  }
65
64
  }, [cellFocused, otherProps.state, textLabel]);
@@ -70,12 +69,9 @@ const _Text = ({
70
69
 
71
70
  return (
72
71
  <Text
73
- style={[
74
- withScaledLineHeight(withFocusedStyles({ style, otherProps })),
75
- { height },
76
- ]}
77
- allowFontScaling={false}
72
+ style={[withFocusedStyles({ style, otherProps }), { height }]}
78
73
  {...withoutLabel(otherProps)}
74
+ allowFontScaling={false}
79
75
  >
80
76
  {textLabel}
81
77
  </Text>
@@ -16,12 +16,14 @@ import { CellBadge } from "./CellBadge";
16
16
  import { TvActionButtons } from "./tv/TvActionButtons";
17
17
  import { ButtonContainerView } from "./tv/ButtonContainerView";
18
18
  import { ImageBorderContainer } from "./ImageBorderContainer";
19
+ import { PressableView } from "./PressableView";
19
20
 
20
21
  export const defaultComponents = {
21
22
  View,
22
23
  CollapsibleTextContainer,
23
24
  Text,
24
25
  Button,
26
+ PressableView,
25
27
  Image,
26
28
  PureImage,
27
29
  ButtonContainerView,
@@ -0,0 +1,46 @@
1
+ import { toNumberWithDefaultZero } from "@applicaster/zapp-react-native-utils/numberUtils";
2
+
3
+ type Props = {
4
+ prefix: string;
5
+ value: Function;
6
+ actionIdentifier: string;
7
+ testID?: string;
8
+ };
9
+
10
+ export const Asset = ({ prefix, value, actionIdentifier, testID }: Props) => {
11
+ if (!value(`${prefix}_asset_enabled`)) {
12
+ return null;
13
+ }
14
+
15
+ return {
16
+ type: "Image",
17
+ style: {
18
+ width: toNumberWithDefaultZero(value(`${prefix}_asset_width`)),
19
+ height: toNumberWithDefaultZero(value(`${prefix}_asset_height`)),
20
+ marginTop: toNumberWithDefaultZero(value(`${prefix}_asset_margin_top`)),
21
+ marginRight: toNumberWithDefaultZero(
22
+ value(`${prefix}_asset_margin_right`)
23
+ ),
24
+ marginBottom: toNumberWithDefaultZero(
25
+ value(`${prefix}_asset_margin_bottom`)
26
+ ),
27
+ marginLeft: toNumberWithDefaultZero(value(`${prefix}_asset_margin_left`)),
28
+ backgroundColor: "transparent",
29
+ },
30
+ data: [
31
+ {
32
+ func: (entry) => entry,
33
+ args: [],
34
+ propName: "entry",
35
+ },
36
+ ],
37
+ additionalProps: {
38
+ source: {
39
+ context: actionIdentifier,
40
+ },
41
+ state: "inactive",
42
+ mobileActionRole: "asset",
43
+ testID: testID ? `${testID}-asset` : undefined,
44
+ },
45
+ };
46
+ };
@@ -0,0 +1,126 @@
1
+ import {
2
+ toNumberWithDefault,
3
+ toNumberWithDefaultZero,
4
+ } from "@applicaster/zapp-react-native-utils/numberUtils";
5
+ import { compact } from "@applicaster/zapp-react-native-utils/cellUtils";
6
+
7
+ import { Asset } from "./Asset";
8
+ import { Spacer } from "./Spacer";
9
+ import { TextLabelsContainer } from "./TextLabelsContainer";
10
+ import { getContentDirection, getContentsAlignment } from "./helpers";
11
+
12
+ const displayModeStyle = ({ value, prefix }) => {
13
+ const mode = value(`${prefix}_display_mode`) || "dynamic";
14
+
15
+ if (mode === "fixed") {
16
+ return {
17
+ width: toNumberWithDefault(140, value(`${prefix}_width`)),
18
+ };
19
+ }
20
+
21
+ if (mode === "fill") {
22
+ return {
23
+ flex: 1,
24
+ };
25
+ }
26
+
27
+ return {};
28
+ };
29
+
30
+ type Props = {
31
+ index: number;
32
+ value: Function;
33
+ stylePrefix: string;
34
+ specificPrefix: string;
35
+ spacingStyle: Record<string, unknown>;
36
+ };
37
+
38
+ export const Button = ({
39
+ index,
40
+ value,
41
+ stylePrefix,
42
+ specificPrefix,
43
+ spacingStyle,
44
+ }: Props) => {
45
+ if (!value(`${specificPrefix}_button_enabled`)) {
46
+ return null;
47
+ }
48
+
49
+ const testID = `mobile_action_button_${index + 1}`;
50
+ const actionIdentifier = value(`${specificPrefix}_assign_action`);
51
+ const assetAlignment = value(`${stylePrefix}_asset_alignment`) || "left";
52
+
53
+ const contentsAlignment =
54
+ value(`${stylePrefix}_contents_alignment`) || "center";
55
+
56
+ return {
57
+ type: "PressableView",
58
+ style: {
59
+ flexDirection: getContentDirection(assetAlignment),
60
+ alignItems: "center",
61
+ justifyContent: getContentsAlignment(contentsAlignment),
62
+
63
+ marginTop: toNumberWithDefaultZero(value(`${stylePrefix}_margin_top`)),
64
+ marginRight: toNumberWithDefaultZero(
65
+ value(`${stylePrefix}_margin_right`)
66
+ ),
67
+ marginBottom: toNumberWithDefaultZero(
68
+ value(`${stylePrefix}_margin_bottom`)
69
+ ),
70
+ marginLeft: toNumberWithDefaultZero(value(`${stylePrefix}_margin_left`)),
71
+
72
+ paddingTop: toNumberWithDefaultZero(value(`${stylePrefix}_padding_top`)),
73
+ paddingRight: toNumberWithDefaultZero(
74
+ value(`${stylePrefix}_padding_right`)
75
+ ),
76
+ paddingBottom: toNumberWithDefaultZero(
77
+ value(`${stylePrefix}_padding_bottom`)
78
+ ),
79
+ paddingLeft: toNumberWithDefaultZero(
80
+ value(`${stylePrefix}_padding_left`)
81
+ ),
82
+
83
+ borderWidth: toNumberWithDefaultZero(value(`${stylePrefix}_border_size`)),
84
+ borderRadius: toNumberWithDefaultZero(
85
+ value(`${stylePrefix}_corner_radius`)
86
+ ),
87
+ borderColor: value(`${stylePrefix}_border_color`),
88
+ backgroundColor: value(`${stylePrefix}_background_color`),
89
+
90
+ ...displayModeStyle({ value, prefix: stylePrefix }),
91
+ ...spacingStyle,
92
+ },
93
+ additionalProps: {
94
+ action: {
95
+ identifier: actionIdentifier,
96
+ },
97
+ focusedStyles: {
98
+ backgroundColor: value(`${stylePrefix}_focused_background_color`),
99
+ borderColor: value(`${stylePrefix}_focused_border_color`),
100
+ },
101
+ testID,
102
+ },
103
+ elements: compact([
104
+ Asset({
105
+ prefix: stylePrefix,
106
+ value,
107
+ actionIdentifier,
108
+ testID,
109
+ }),
110
+ Spacer(),
111
+ TextLabelsContainer({
112
+ prefix: stylePrefix,
113
+ value,
114
+ actionIdentifier,
115
+ testID,
116
+ }),
117
+ ]),
118
+ data: [
119
+ {
120
+ func: (x) => x,
121
+ args: [],
122
+ propName: "item",
123
+ },
124
+ ],
125
+ };
126
+ };
@@ -0,0 +1,23 @@
1
+ type Props = {
2
+ style: Record<string, unknown>;
3
+ contentStyle: Record<string, unknown>;
4
+ elements: Array<Record<string, unknown>>;
5
+ };
6
+
7
+ export const ButtonContainerView = ({
8
+ style,
9
+ contentStyle,
10
+ elements,
11
+ }: Props) => {
12
+ return {
13
+ type: "View",
14
+ style,
15
+ elements: [
16
+ {
17
+ type: "View",
18
+ style: contentStyle,
19
+ elements,
20
+ },
21
+ ],
22
+ };
23
+ };
@@ -0,0 +1,16 @@
1
+ type Props = {
2
+ enabled?: boolean;
3
+ };
4
+
5
+ export const Spacer = ({ enabled = false }: Props = {}) => {
6
+ if (!enabled) {
7
+ return null;
8
+ }
9
+
10
+ return {
11
+ type: "View",
12
+ style: {
13
+ flex: 1,
14
+ },
15
+ };
16
+ };
@@ -0,0 +1,67 @@
1
+ import { Platform } from "react-native";
2
+
3
+ import { toNumberWithDefaultZero } from "@applicaster/zapp-react-native-utils/numberUtils";
4
+
5
+ type Props = {
6
+ prefix: string;
7
+ value: Function;
8
+ actionIdentifier: string;
9
+ testID?: string;
10
+ };
11
+
12
+ export const TextLabel = ({
13
+ prefix,
14
+ value,
15
+ actionIdentifier,
16
+ testID,
17
+ }: Props) => {
18
+ if (!value(`${prefix}_label_enabled`)) {
19
+ return null;
20
+ }
21
+
22
+ return {
23
+ type: "Text",
24
+ style: {
25
+ color: value(`${prefix}_font_color`),
26
+ fontSize: toNumberWithDefaultZero(value(`${prefix}_font_size`)),
27
+ lineHeight: toNumberWithDefaultZero(value(`${prefix}_line_height`)),
28
+ marginTop: toNumberWithDefaultZero(value(`${prefix}_margin_top`)),
29
+ marginRight: toNumberWithDefaultZero(value(`${prefix}_margin_right`)),
30
+ marginBottom: toNumberWithDefaultZero(value(`${prefix}_margin_bottom`)),
31
+ marginLeft: toNumberWithDefaultZero(value(`${prefix}_margin_left`)),
32
+ fontFamily:
33
+ Platform.OS === "ios"
34
+ ? value(`${prefix}_ios_font_family`)
35
+ : value(`${prefix}_android_font_family`),
36
+ letterSpacing: toNumberWithDefaultZero(
37
+ Platform.OS === "ios"
38
+ ? value(`${prefix}_ios_letter_spacing`)
39
+ : value(`${prefix}_android_letter_spacing`)
40
+ ),
41
+ },
42
+ data: [
43
+ {
44
+ func: (entry) => entry,
45
+ args: [],
46
+ propName: "entry",
47
+ },
48
+ ],
49
+ additionalProps: {
50
+ label: {
51
+ context: actionIdentifier,
52
+ name: "label_1",
53
+ },
54
+ normalStyles: {
55
+ color: value(`${prefix}_font_color`),
56
+ },
57
+ focusedStyles: {
58
+ color: value(`${prefix}_focused_font_color`),
59
+ },
60
+ state: "default",
61
+ mobileActionRole: "label",
62
+ transformText: value(`${prefix}_text_transform`) || "default",
63
+ numberOfLines: value(`${prefix}_number_of_lines`),
64
+ testID: testID ? `${testID}-label` : undefined,
65
+ },
66
+ };
67
+ };
@@ -0,0 +1,32 @@
1
+ import { compact } from "@applicaster/zapp-react-native-utils/cellUtils";
2
+
3
+ import { TextLabel } from "./TextLabel";
4
+
5
+ type Props = {
6
+ prefix: string;
7
+ value: Function;
8
+ actionIdentifier: string;
9
+ testID?: string;
10
+ };
11
+
12
+ export const TextLabelsContainer = ({
13
+ prefix,
14
+ value,
15
+ actionIdentifier,
16
+ testID,
17
+ }: Props) => {
18
+ return {
19
+ type: "View",
20
+ additionalProps: {
21
+ mobileActionRole: "label_container",
22
+ },
23
+ elements: compact([
24
+ TextLabel({
25
+ prefix,
26
+ value,
27
+ actionIdentifier,
28
+ testID,
29
+ }),
30
+ ]),
31
+ };
32
+ };
@@ -0,0 +1,191 @@
1
+ import React from "react";
2
+ import { render, fireEvent } from "@testing-library/react-native";
3
+ import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
4
+
5
+ import { elementMapper } from "../../../../elementMapper";
6
+ import { defaultComponents } from "../../../index";
7
+
8
+ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/actions", () => ({
9
+ useActions: jest.fn(),
10
+ }));
11
+
12
+ jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
13
+ useTheme: () => ({}),
14
+ }));
15
+
16
+ jest.mock("@applicaster/zapp-react-native-utils/localizationUtils", () => ({
17
+ useIsRTL: jest.fn(() => false),
18
+ }));
19
+
20
+ jest.mock(
21
+ "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation",
22
+ () => ({
23
+ useNavigation: jest.fn(() => ({
24
+ currentRoute: "home",
25
+ videoModalState: {
26
+ visible: false,
27
+ },
28
+ })),
29
+ })
30
+ );
31
+
32
+ jest.mock(
33
+ "@applicaster/zapp-react-native-utils/reactHooks/navigation/usePathname",
34
+ () => ({
35
+ usePathname: jest.fn(() => "home"),
36
+ })
37
+ );
38
+
39
+ jest.mock(
40
+ "@applicaster/zapp-react-native-utils/appUtils/accessibilityManager/hooks",
41
+ () => ({
42
+ useAccessibilityManager: jest.fn(() => ({
43
+ addHeading: jest.fn(),
44
+ })),
45
+ })
46
+ );
47
+
48
+ const mockUseActions = useActions as jest.Mock;
49
+
50
+ const item = {
51
+ id: "entry-1",
52
+ } as ZappEntry;
53
+
54
+ const buildActionContext = (entryState = {}) => ({
55
+ initialEntryState: jest.fn(() => ({
56
+ asset: {
57
+ inactive: "https://example.com/image-inactive.png",
58
+ active: "https://example.com/image-active.png",
59
+ },
60
+ label: {
61
+ label_1: "Play",
62
+ },
63
+ ...entryState,
64
+ })),
65
+ invokeAction: jest.fn(),
66
+ addListener: jest.fn(() => jest.fn()),
67
+ isActionAvailable: jest.fn(() => true),
68
+ });
69
+
70
+ const baseNode = {
71
+ type: "PressableView",
72
+ style: {
73
+ backgroundColor: "rgba(1,1,1,1)",
74
+ borderColor: "rgba(2,2,2,1)",
75
+ borderWidth: 1,
76
+ },
77
+ props: {
78
+ item,
79
+ action: {
80
+ identifier: "navigation_action",
81
+ },
82
+ focusedStyles: {
83
+ backgroundColor: "rgba(3,3,3,1)",
84
+ borderColor: "rgba(4,4,4,1)",
85
+ },
86
+ testID: "mobile-action-button",
87
+ },
88
+ elements: [
89
+ {
90
+ type: "Image",
91
+ style: {
92
+ width: 24,
93
+ height: 24,
94
+ },
95
+ props: {
96
+ testID: "mobile-action-button-asset",
97
+ source: {
98
+ context: "navigation_action",
99
+ },
100
+ mobileActionRole: "asset",
101
+ },
102
+ },
103
+ {
104
+ type: "View",
105
+ style: {
106
+ flexDirection: "column",
107
+ },
108
+ props: {
109
+ mobileActionRole: "label_container",
110
+ },
111
+ elements: [
112
+ {
113
+ type: "Text",
114
+ style: {
115
+ fontSize: 15,
116
+ },
117
+ props: {
118
+ testID: "mobile-action-button-label",
119
+ label: {
120
+ context: "navigation_action",
121
+ name: "label_1",
122
+ },
123
+ focusedStyles: {
124
+ color: "rgba(20,20,20,1)",
125
+ },
126
+ normalStyles: {
127
+ color: "rgba(10,10,10,1)",
128
+ },
129
+ mobileActionRole: "label",
130
+ transformText: "default",
131
+ },
132
+ },
133
+ ],
134
+ },
135
+ ],
136
+ };
137
+
138
+ describe("PressableView", () => {
139
+ beforeEach(() => {
140
+ jest.clearAllMocks();
141
+ });
142
+
143
+ const renderNode = (node = baseNode) =>
144
+ render(
145
+ <React.Fragment>
146
+ {elementMapper(defaultComponents)(node as never)}
147
+ </React.Fragment>
148
+ );
149
+
150
+ it("renders nested image and text children through elementMapper", () => {
151
+ mockUseActions.mockReturnValue(buildActionContext());
152
+
153
+ const { getByText, getByTestId } = renderNode();
154
+
155
+ expect(getByTestId("mobile-action-button")).toBeTruthy();
156
+ expect(getByTestId("mobile-action-button-asset")).toBeTruthy();
157
+ expect(getByText("Play")).toBeTruthy();
158
+ });
159
+
160
+ it("applies focused styles when action entry state is active", () => {
161
+ mockUseActions.mockReturnValue(buildActionContext({ active: true }));
162
+
163
+ const { getByTestId, getByText } = renderNode();
164
+
165
+ expect(
166
+ getByTestId("mobile-action-button").props.style.backgroundColor
167
+ ).toBe("rgba(3,3,3,1)");
168
+
169
+ expect(getByText("Play").props.style).toEqual(
170
+ expect.arrayContaining([
171
+ expect.objectContaining({ color: "rgba(20,20,20,1)" }),
172
+ ])
173
+ );
174
+ });
175
+
176
+ it("invokes action on press", () => {
177
+ const actionContext = buildActionContext();
178
+ mockUseActions.mockReturnValue(actionContext);
179
+
180
+ const { getByTestId } = renderNode();
181
+
182
+ fireEvent.press(getByTestId("mobile-action-button"));
183
+
184
+ expect(actionContext.invokeAction).toHaveBeenCalledWith(
185
+ item,
186
+ expect.objectContaining({
187
+ updateState: expect.any(Function),
188
+ })
189
+ );
190
+ });
191
+ });