@applicaster/zapp-react-native-ui-components 15.0.0-rc.14 → 15.0.0-rc.141

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 (197) 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 +25 -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 +261 -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 +42 -0
  59. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Button.ts +127 -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 +195 -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 +44 -65
  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 +18 -16
  94. package/Components/River/ComponentsMap/hooks/__tests__/useLoadingState.test.ts +1 -1
  95. package/Components/River/RefreshControl.tsx +19 -82
  96. package/Components/River/River.tsx +9 -82
  97. package/Components/River/RiverItem.tsx +26 -20
  98. package/Components/River/TV/River.tsx +31 -14
  99. package/Components/River/TV/index.tsx +8 -4
  100. package/Components/River/TV/utils/__tests__/toStringOrEmpty.test.ts +30 -0
  101. package/Components/River/TV/utils/index.ts +4 -0
  102. package/Components/River/TV/withFocusableGroupForContent.tsx +71 -0
  103. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +2 -0
  104. package/Components/River/__tests__/componentsMap.test.js +38 -0
  105. package/Components/River/hooks/__tests__/usePullToRefresh.test.ts +132 -0
  106. package/Components/River/hooks/index.ts +1 -0
  107. package/Components/River/hooks/usePullToRefresh.ts +51 -0
  108. package/Components/Screen/TV/index.web.tsx +4 -2
  109. package/Components/Screen/__tests__/Screen.test.tsx +66 -42
  110. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +68 -44
  111. package/Components/Screen/hooks.ts +75 -6
  112. package/Components/Screen/index.tsx +9 -4
  113. package/Components/Screen/navigationHandler.ts +49 -24
  114. package/Components/Screen/orientationHandler.ts +10 -13
  115. package/Components/ScreenFeedLoader/ScreenFeedLoader.tsx +46 -0
  116. package/Components/ScreenFeedLoader/__tests__/ScreenFeedLoader.test.tsx +94 -0
  117. package/Components/ScreenFeedLoader/index.ts +1 -0
  118. package/Components/ScreenResolver/__tests__/screenResolver.test.js +24 -0
  119. package/Components/ScreenResolver/hooks/index.ts +3 -0
  120. package/Components/ScreenResolver/hooks/useGetComponent.ts +15 -0
  121. package/Components/ScreenResolver/hooks/useScreenComponentResolver.tsx +90 -0
  122. package/Components/ScreenResolver/index.tsx +15 -111
  123. package/Components/ScreenResolver/utils/__tests__/getScreenTypeProps.test.ts +45 -0
  124. package/Components/ScreenResolver/utils/getScreenTypeProps.ts +43 -0
  125. package/Components/ScreenResolver/utils/index.ts +1 -0
  126. package/Components/ScreenResolver/withDefaultScreenContext.tsx +16 -0
  127. package/Components/ScreenResolverFeedProvider/ScreenResolverFeedProvider.tsx +25 -0
  128. package/Components/ScreenResolverFeedProvider/__tests__/ScreenResolverFeedProvider.test.tsx +44 -0
  129. package/Components/ScreenResolverFeedProvider/index.ts +1 -0
  130. package/Components/ScreenRevealManager/ScreenRevealManager.ts +40 -8
  131. package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +86 -69
  132. package/Components/ScreenRevealManager/withScreenRevealManager.tsx +44 -26
  133. package/Components/Tabs/TV/Tabs.tsx +20 -3
  134. package/Components/Tabs/TabContent.tsx +7 -4
  135. package/Components/TopCutoffOverlay/hooks/__tests__/useMarginTop.test.ts +130 -0
  136. package/Components/TopCutoffOverlay/hooks/index.ts +1 -0
  137. package/Components/TopCutoffOverlay/hooks/useMarginTop.ts +59 -0
  138. package/Components/TopCutoffOverlay/index.tsx +55 -0
  139. package/Components/Transitioner/Scene.tsx +10 -3
  140. package/Components/Transitioner/index.js +3 -3
  141. package/Components/VideoLive/LiveImageManager.ts +199 -54
  142. package/Components/VideoLive/PlayerLiveImageComponent.tsx +31 -33
  143. package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +2 -17
  144. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +1 -0
  145. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +118 -171
  146. package/Components/VideoModal/ModalAnimation/index.ts +2 -13
  147. package/Components/VideoModal/ModalAnimation/utils.ts +1 -327
  148. package/Components/VideoModal/PlayerWrapper.tsx +14 -88
  149. package/Components/VideoModal/VideoModal.tsx +1 -5
  150. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -0
  151. package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +15 -7
  152. package/Components/VideoModal/hooks/useModalSize.ts +10 -5
  153. package/Components/VideoModal/playerWrapperStyle.ts +70 -0
  154. package/Components/VideoModal/playerWrapperUtils.ts +91 -0
  155. package/Components/VideoModal/utils.ts +19 -9
  156. package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +0 -2
  157. package/Components/Viewport/ViewportAware/index.tsx +16 -7
  158. package/Components/Viewport/ViewportEvents/__tests__/viewportEvents.test.js +1 -1
  159. package/Components/ZappUIComponent/index.tsx +12 -6
  160. package/Components/default-cell-renderer/viewTrees/mobile/index.ts +0 -3
  161. package/Components/index.js +1 -1
  162. package/Contexts/ScreenContext/__tests__/index.test.tsx +57 -0
  163. package/Contexts/ScreenContext/index.tsx +71 -19
  164. package/Contexts/ScreenTrackedViewPositionsContext/__tests__/index.test.tsx +1 -1
  165. package/Contexts/ZappHookModalContext/index.tsx +37 -61
  166. package/Contexts/ZappPipesContext/ZappPipesContextFactory.tsx +18 -7
  167. package/Contexts/index.ts +0 -2
  168. package/Decorators/Analytics/index.tsx +6 -5
  169. package/Decorators/ConfigurationWrapper/__tests__/__snapshots__/withConfigurationProvider.test.tsx.snap +1 -0
  170. package/Decorators/ConfigurationWrapper/const.ts +1 -0
  171. package/Decorators/ZappPipesDataConnector/ResolverSelector.tsx +25 -7
  172. package/Decorators/ZappPipesDataConnector/__tests__/ResolverSelector.test.tsx +212 -5
  173. package/Decorators/ZappPipesDataConnector/__tests__/UrlFeedResolver.test.tsx +39 -21
  174. package/Decorators/ZappPipesDataConnector/__tests__/zappPipesDataConnector.test.js +1 -1
  175. package/Decorators/ZappPipesDataConnector/index.tsx +2 -2
  176. package/Decorators/ZappPipesDataConnector/resolvers/StaticFeedResolver.tsx +1 -1
  177. package/Decorators/ZappPipesDataConnector/resolvers/UrlFeedResolver.tsx +18 -7
  178. package/Helpers/DataSourceHelper/__tests__/itemLimitForData.test.ts +80 -0
  179. package/Helpers/DataSourceHelper/index.ts +19 -0
  180. package/events/index.ts +3 -0
  181. package/events/scrollEndReached.ts +15 -0
  182. package/index.d.ts +7 -0
  183. package/package.json +6 -5
  184. package/Components/MasterCell/DefaultComponents/Text/utils/__tests__/withAdjustedLineHeight.test.ts +0 -46
  185. package/Components/MasterCell/DefaultComponents/Text/utils/index.ts +0 -21
  186. package/Components/PlayerContainer/ErrorDisplay/ErrorDisplay.tsx +0 -57
  187. package/Components/PlayerContainer/ErrorDisplay/index.ts +0 -9
  188. package/Components/River/TV/withTVEventHandler.tsx +0 -27
  189. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +0 -60
  190. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +0 -417
  191. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.web.tsx +0 -294
  192. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +0 -176
  193. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.web.tsx +0 -93
  194. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +0 -500
  195. package/Components/VideoModal/ModalAnimation/__tests__/getMoveUpValue.test.ts +0 -108
  196. package/Helpers/DataSourceHelper/index.js +0 -19
  197. /package/Components/HookRenderer/{index.tsx → index.ts} +0 -0
@@ -18,7 +18,7 @@ import {
18
18
  routeIsPlayerScreen,
19
19
  } from "@applicaster/zapp-react-native-utils/navigationUtils";
20
20
  import { isApplePlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
21
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
21
+ import { usePlugins } from "@applicaster/zapp-react-native-redux/hooks";
22
22
  import { NavBarContainer } from "./NavBarContainer";
23
23
 
24
24
  type ComponentsExtraProps = {
@@ -111,11 +111,7 @@ export const ScreenContainer = React.memo(function ScreenContainer({
111
111
  const { activeRiver } = navigator;
112
112
  const { title, visible } = useNavbarState();
113
113
 
114
- const { plugins = [] } = usePickFromState([
115
- "appState",
116
- "remoteConfigurations",
117
- "plugins",
118
- ]);
114
+ const plugins = usePlugins();
119
115
 
120
116
  const navigationProps = getNavigationProps({
121
117
  navigator,
@@ -3,18 +3,13 @@
3
3
  exports[`NavBarContainer renders 1`] = `
4
4
  <View
5
5
  style={
6
- [
7
- {
8
- "flex": 1,
9
- "position": "absolute",
10
- "top": 0,
11
- "width": "100%",
12
- "zIndex": 10,
13
- },
14
- {
15
- "maxHeight": 1,
16
- },
17
- ]
6
+ {
7
+ "flex": 1,
8
+ "position": "absolute",
9
+ "top": 0,
10
+ "width": "100%",
11
+ "zIndex": 10,
12
+ }
18
13
  }
19
14
  testID="nav-bar-container"
20
15
  >
@@ -14,18 +14,13 @@ exports[`ScreenContainer renders 1`] = `
14
14
  >
15
15
  <View
16
16
  style={
17
- [
18
- {
19
- "flex": 1,
20
- "position": "absolute",
21
- "top": 0,
22
- "width": "100%",
23
- "zIndex": 10,
24
- },
25
- {
26
- "maxHeight": 1,
27
- },
28
- ]
17
+ {
18
+ "flex": 1,
19
+ "position": "absolute",
20
+ "top": 0,
21
+ "width": "100%",
22
+ "zIndex": 10,
23
+ }
29
24
  }
30
25
  testID="nav-bar-container"
31
26
  >
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
2
+ import { useAppSelector } from "@applicaster/zapp-react-native-redux/hooks";
3
3
  import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
4
4
 
5
5
  import { LayoutContainer } from "./LayoutContainer";
@@ -10,6 +10,7 @@ import { PathnameContext } from "../../../Contexts/PathnameContext";
10
10
  import { ScreenDataContext } from "../../../Contexts/ScreenDataContext";
11
11
  import { ScreenContextProvider } from "../../../Contexts/ScreenContext";
12
12
  import { LayoutBackground } from "./LayoutBackground";
13
+ import { selectAppReady } from "@applicaster/zapp-react-native-redux";
13
14
 
14
15
  type Components = {
15
16
  NavBar: React.ComponentType<any>;
@@ -29,9 +30,7 @@ type Props = {
29
30
  const Layout = ({ Components, ComponentsExtraProps, children }: Props) => {
30
31
  const navigator = useNavigation();
31
32
 
32
- const { appState: { appReady = false } = {} } = usePickFromState([
33
- "appState",
34
- ]);
33
+ const appReady = useAppSelector(selectAppReady);
35
34
 
36
35
  if (!appReady) {
37
36
  return null;
@@ -1,11 +1,11 @@
1
1
  import * as React from "react";
2
- import { pathOr } from "ramda";
3
2
 
4
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
3
+ import { useAppSelector } from "@applicaster/zapp-react-native-redux/hooks";
5
4
 
6
5
  import { ScreenLayoutContextProvider } from "./ScreenLayoutContextProvider";
7
6
  import { StackNavigator } from "../../Navigator";
8
7
  import { LayoutBackground } from "./LayoutBackground";
8
+ import { selectAppReady } from "@applicaster/zapp-react-native-redux";
9
9
 
10
10
  type Components = {
11
11
  NavBar: React.ComponentType<any>;
@@ -17,8 +17,7 @@ type Props = {
17
17
  };
18
18
 
19
19
  const Layout = ({ Components }: Props) => {
20
- const { appState } = usePickFromState(["appState"]);
21
- const appReady = pathOr(false, ["appReady"], appState);
20
+ const appReady = useAppSelector(selectAppReady);
22
21
 
23
22
  if (!appReady) {
24
23
  return null;
@@ -2,7 +2,7 @@ import * as React from "react";
2
2
  import * as R from "ramda";
3
3
 
4
4
  import { findPluginByIdentifier } from "@applicaster/zapp-react-native-utils/pluginUtils";
5
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
5
+ import { usePlugins } from "@applicaster/zapp-react-native-redux/hooks";
6
6
  import {
7
7
  inflateString,
8
8
  objectToReadableString,
@@ -40,7 +40,7 @@ export async function inflateUrl(url) {
40
40
 
41
41
  export function LinkHandler(props: Props) {
42
42
  const screenData = props?.screenData;
43
- const { plugins } = usePickFromState(["rivers", "plugins"]);
43
+ const plugins = usePlugins();
44
44
 
45
45
  const ScreenPlugin = findPluginByIdentifier(
46
46
  WEBVIEW_SCREEN_IDENTIFIER,
@@ -0,0 +1,80 @@
1
+ import { buildActionButtonsModel } from "../model";
2
+
3
+ describe("buildActionButtonsModel", () => {
4
+ it("returns null when the container is disabled", () => {
5
+ const configuration = {
6
+ mobile_buttons_container_buttons_enabled: false,
7
+ mobile_button_1_button_enabled: true,
8
+ };
9
+
10
+ const value = (key) => configuration[key];
11
+
12
+ expect(
13
+ buildActionButtonsModel({
14
+ configuration,
15
+ value,
16
+ containerPrefix: "mobile_buttons_container",
17
+ buttonPrefix: "mobile_button",
18
+ })
19
+ ).toBeNull();
20
+ });
21
+
22
+ it("returns explicit enabled slots and semantic container data", () => {
23
+ const configuration = {
24
+ mobile_buttons_container_buttons_enabled: true,
25
+ mobile_buttons_container_align: "right",
26
+ mobile_buttons_container_margin_top: 1,
27
+ mobile_buttons_container_margin_right: 2,
28
+ mobile_buttons_container_margin_bottom: 3,
29
+ mobile_buttons_container_margin_left: 4,
30
+ mobile_buttons_container_stacking: "vertical",
31
+ mobile_buttons_container_horizontal_gutter: 8,
32
+ mobile_buttons_container_vertical_gutter: 12,
33
+ mobile_buttons_container_independent_styles: false,
34
+ mobile_button_1_button_enabled: true,
35
+ mobile_button_2_button_enabled: false,
36
+ mobile_button_3_button_enabled: true,
37
+ };
38
+
39
+ const value = (key) => configuration[key];
40
+
41
+ expect(
42
+ buildActionButtonsModel({
43
+ configuration,
44
+ value,
45
+ containerPrefix: "mobile_buttons_container",
46
+ buttonPrefix: "mobile_button",
47
+ })
48
+ ).toEqual({
49
+ enabledSlots: [1, 3],
50
+ buttonsCount: 2,
51
+ container: {
52
+ horizontalAlign: "flex-end",
53
+ margins: {
54
+ top: 1,
55
+ right: 2,
56
+ bottom: 3,
57
+ left: 4,
58
+ },
59
+ stacking: "vertical",
60
+ horizontalGutter: 8,
61
+ verticalGutter: 12,
62
+ independentStyles: false,
63
+ },
64
+ buttons: [
65
+ {
66
+ slot: 1,
67
+ renderIndex: 0,
68
+ specificPrefix: "mobile_button_1",
69
+ stylePrefix: "mobile_button_1",
70
+ },
71
+ {
72
+ slot: 3,
73
+ renderIndex: 1,
74
+ specificPrefix: "mobile_button_3",
75
+ stylePrefix: "mobile_button_1",
76
+ },
77
+ ],
78
+ });
79
+ });
80
+ });
@@ -0,0 +1,187 @@
1
+ import {
2
+ insertBetweenLabelContainers,
3
+ insertBetweenLabels,
4
+ } from "../placement";
5
+
6
+ describe("ActionButtonsCore placement", () => {
7
+ const buttons = { type: "View", name: "buttons" };
8
+
9
+ const above_labels = [
10
+ { name: "above_label_1" },
11
+ { name: "above_label_2" },
12
+ { name: "above_label_3" },
13
+ ];
14
+
15
+ const below_labels = [
16
+ { name: "below_label_1" },
17
+ { name: "below_label_2" },
18
+ { name: "below_label_3" },
19
+ ];
20
+
21
+ it("inserts buttons after the matching label", () => {
22
+ expect(
23
+ insertBetweenLabels({ position: "below_label_2" }, buttons, below_labels)
24
+ ).toEqual([below_labels[0], below_labels[1], buttons, below_labels[2]]);
25
+ });
26
+
27
+ it("inserts buttons before the matching label", () => {
28
+ expect(
29
+ insertBetweenLabels({ position: "above_label_2" }, buttons, above_labels)
30
+ ).toEqual([above_labels[0], buttons, above_labels[1], above_labels[2]]);
31
+ });
32
+
33
+ it("prepends buttons only when on_top is allowed", () => {
34
+ expect(
35
+ insertBetweenLabels(
36
+ { position: "on_top", allowOnTop: true },
37
+ buttons,
38
+ below_labels
39
+ )
40
+ ).toEqual([buttons, ...below_labels]);
41
+
42
+ expect(
43
+ insertBetweenLabels(
44
+ { position: "on_top", allowOnTop: false },
45
+ buttons,
46
+ below_labels
47
+ )
48
+ ).toEqual(below_labels);
49
+ });
50
+
51
+ it("appends buttons when appendWhenMissing is enabled", () => {
52
+ expect(
53
+ insertBetweenLabels(
54
+ { position: "unknown", appendWhenMissing: true },
55
+ buttons,
56
+ below_labels
57
+ )
58
+ ).toEqual([...below_labels, buttons]);
59
+ });
60
+
61
+ it("returns labels unchanged when appendWhenMissing is disabled", () => {
62
+ expect(
63
+ insertBetweenLabels(
64
+ { position: "unknown", appendWhenMissing: false },
65
+ buttons,
66
+ below_labels
67
+ )
68
+ ).toEqual(below_labels);
69
+ });
70
+
71
+ const labelContainers = [
72
+ {
73
+ elements: [
74
+ {
75
+ elements: [{ name: "top_label_1" }, { name: "top_label_2" }],
76
+ },
77
+ ],
78
+ },
79
+ {
80
+ elements: [
81
+ {
82
+ elements: [{ name: "bottom_label_1" }],
83
+ },
84
+ ],
85
+ },
86
+ ];
87
+
88
+ it("inserts buttons after the matching label in a nested container", () => {
89
+ expect(
90
+ insertBetweenLabelContainers(
91
+ { position: "below_top_label_2" },
92
+ buttons,
93
+ labelContainers
94
+ )
95
+ ).toEqual([
96
+ {
97
+ elements: [
98
+ {
99
+ elements: [
100
+ { name: "top_label_1" },
101
+ { name: "top_label_2" },
102
+ buttons,
103
+ ],
104
+ },
105
+ ],
106
+ },
107
+ labelContainers[1],
108
+ ]);
109
+ });
110
+
111
+ it("inserts buttons before the matching label in a nested container", () => {
112
+ expect(
113
+ insertBetweenLabelContainers(
114
+ { position: "above_top_label_2" },
115
+ buttons,
116
+ labelContainers
117
+ )
118
+ ).toEqual([
119
+ {
120
+ elements: [
121
+ {
122
+ elements: [
123
+ { name: "top_label_1" },
124
+ buttons,
125
+ { name: "top_label_2" },
126
+ ],
127
+ },
128
+ ],
129
+ },
130
+ labelContainers[1],
131
+ ]);
132
+ });
133
+
134
+ it("prepends buttons into the first container only when on_top is allowed", () => {
135
+ expect(
136
+ insertBetweenLabelContainers(
137
+ { position: "on_top", allowOnTop: true },
138
+ buttons,
139
+ labelContainers
140
+ )
141
+ ).toEqual([
142
+ {
143
+ elements: [buttons, ...labelContainers[0].elements],
144
+ },
145
+ labelContainers[1],
146
+ ]);
147
+ });
148
+
149
+ it("appends buttons into the last container when configured", () => {
150
+ expect(
151
+ insertBetweenLabelContainers(
152
+ { position: "unknown", appendWhenMissing: true },
153
+ buttons,
154
+ labelContainers
155
+ )
156
+ ).toEqual([
157
+ labelContainers[0],
158
+ {
159
+ elements: [...labelContainers[1].elements, buttons],
160
+ },
161
+ ]);
162
+ });
163
+
164
+ it("inserts buttons after a matching label in a direct two-level container", () => {
165
+ const directLabelContainers = [
166
+ {
167
+ elements: [{ name: "top_label_1" }, { name: "top_label_2" }],
168
+ },
169
+ {
170
+ elements: [{ name: "bottom_label_1" }],
171
+ },
172
+ ];
173
+
174
+ expect(
175
+ insertBetweenLabelContainers(
176
+ { position: "below_top_label_2" },
177
+ buttons,
178
+ directLabelContainers
179
+ )
180
+ ).toEqual([
181
+ {
182
+ elements: [{ name: "top_label_1" }, { name: "top_label_2" }, buttons],
183
+ },
184
+ directLabelContainers[1],
185
+ ]);
186
+ });
187
+ });
@@ -0,0 +1,45 @@
1
+ import {
2
+ getButtonSlotPrefix,
3
+ getEnabledButtonSlots,
4
+ getStylePrefix,
5
+ } from "../selectors";
6
+
7
+ describe("ActionButtonsCore selectors", () => {
8
+ it("returns explicit enabled button slots without collapsing sparse slots", () => {
9
+ const configuration = {
10
+ mobile_button_1_button_enabled: true,
11
+ mobile_button_2_button_enabled: false,
12
+ mobile_button_3_button_enabled: true,
13
+ };
14
+
15
+ expect(getEnabledButtonSlots(configuration, "mobile_button")).toEqual([
16
+ 1, 3,
17
+ ]);
18
+ });
19
+
20
+ it("returns slot-based prefixes", () => {
21
+ expect(getButtonSlotPrefix("tv_buttons_button", 3)).toBe(
22
+ "tv_buttons_button_3"
23
+ );
24
+ });
25
+
26
+ it("reuses button 1 styles when independent styles are disabled", () => {
27
+ expect(
28
+ getStylePrefix({
29
+ slot: 3,
30
+ independentStyles: false,
31
+ buttonPrefix: "mobile_button",
32
+ })
33
+ ).toBe("mobile_button_1");
34
+ });
35
+
36
+ it("uses the explicit slot prefix when independent styles are enabled", () => {
37
+ expect(
38
+ getStylePrefix({
39
+ slot: 3,
40
+ independentStyles: true,
41
+ buttonPrefix: "mobile_button",
42
+ })
43
+ ).toBe("mobile_button_3");
44
+ });
45
+ });
@@ -0,0 +1,49 @@
1
+ import { buildContainerLayout, getContainerMargins } from "../style";
2
+
3
+ describe("ActionButtonsCore style helpers", () => {
4
+ it("returns numeric margins with zero defaults", () => {
5
+ const configuration = {
6
+ mobile_buttons_container_margin_top: "4",
7
+ mobile_buttons_container_margin_left: 6,
8
+ };
9
+
10
+ const value = (key) => configuration[key];
11
+
12
+ expect(getContainerMargins(value, "mobile_buttons_container")).toEqual({
13
+ top: 4,
14
+ right: 0,
15
+ bottom: 0,
16
+ left: 6,
17
+ });
18
+ });
19
+
20
+ it("returns semantic layout data using shared alignment mapping", () => {
21
+ const configuration = {
22
+ tv_buttons_container_align: "middle",
23
+ tv_buttons_container_margin_top: 1,
24
+ tv_buttons_container_margin_right: 2,
25
+ tv_buttons_container_margin_bottom: 3,
26
+ tv_buttons_container_margin_left: 4,
27
+ tv_buttons_container_stacking: "vertical",
28
+ tv_buttons_container_horizontal_gutter: 8,
29
+ tv_buttons_container_vertical_gutter: 12,
30
+ tv_buttons_container_independent_styles: true,
31
+ };
32
+
33
+ const value = (key) => configuration[key];
34
+
35
+ expect(buildContainerLayout(value, "tv_buttons_container")).toEqual({
36
+ horizontalAlign: "center",
37
+ margins: {
38
+ top: 1,
39
+ right: 2,
40
+ bottom: 3,
41
+ left: 4,
42
+ },
43
+ stacking: "vertical",
44
+ horizontalGutter: 8,
45
+ verticalGutter: 12,
46
+ independentStyles: true,
47
+ });
48
+ });
49
+ });
@@ -0,0 +1,47 @@
1
+ import {
2
+ getButtonSlotPrefix,
3
+ getEnabledButtonSlots,
4
+ getStylePrefix,
5
+ } from "./selectors";
6
+ import { buildContainerLayout } from "./style";
7
+ import { ActionButtonsModel, BuildActionButtonsModelOptions } from "./types";
8
+
9
+ export const buildActionButtonsModel = ({
10
+ configuration,
11
+ value,
12
+ containerPrefix,
13
+ buttonPrefix,
14
+ maxButtons = 3,
15
+ }: BuildActionButtonsModelOptions): ActionButtonsModel | null => {
16
+ if (!value(`${containerPrefix}_buttons_enabled`)) {
17
+ return null;
18
+ }
19
+
20
+ const enabledSlots = getEnabledButtonSlots(
21
+ configuration,
22
+ buttonPrefix,
23
+ maxButtons
24
+ );
25
+
26
+ if (enabledSlots.length === 0) {
27
+ return null;
28
+ }
29
+
30
+ const container = buildContainerLayout(value, containerPrefix);
31
+
32
+ return {
33
+ enabledSlots,
34
+ buttonsCount: enabledSlots.length,
35
+ container,
36
+ buttons: enabledSlots.map((slot, renderIndex) => ({
37
+ slot,
38
+ renderIndex,
39
+ specificPrefix: getButtonSlotPrefix(buttonPrefix, slot),
40
+ stylePrefix: getStylePrefix({
41
+ slot,
42
+ independentStyles: container.independentStyles,
43
+ buttonPrefix,
44
+ }),
45
+ })),
46
+ };
47
+ };