@applicaster/zapp-react-native-ui-components 15.0.0-alpha.5830601313 → 15.0.0-alpha.5918085834

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 (58) hide show
  1. package/Components/Cell/Cell.tsx +8 -3
  2. package/Components/Cell/TvOSCellComponent.tsx +21 -5
  3. package/Components/HandlePlayable/HandlePlayable.tsx +10 -7
  4. package/Components/Layout/TV/LayoutBackground.tsx +5 -2
  5. package/Components/Layout/TV/ScreenContainer.tsx +2 -6
  6. package/Components/Layout/TV/index.tsx +3 -4
  7. package/Components/Layout/TV/index.web.tsx +3 -4
  8. package/Components/LinkHandler/LinkHandler.tsx +2 -2
  9. package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx +16 -1
  10. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +30 -2
  11. package/Components/MasterCell/DefaultComponents/Image/Image.android.tsx +5 -1
  12. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +11 -3
  13. package/Components/MasterCell/DefaultComponents/Image/Image.web.tsx +9 -1
  14. package/Components/MasterCell/DefaultComponents/Image/hooks/useImage.ts +15 -14
  15. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +10 -6
  16. package/Components/MasterCell/DefaultComponents/Text/index.tsx +8 -8
  17. package/Components/MasterCell/index.tsx +2 -0
  18. package/Components/MasterCell/utils/__tests__/resolveColor.test.js +82 -3
  19. package/Components/MasterCell/utils/index.ts +61 -31
  20. package/Components/MeasurmentsPortal/MeasurementsPortal.tsx +102 -87
  21. package/Components/MeasurmentsPortal/__tests__/MeasurementsPortal.test.tsx +355 -0
  22. package/Components/OfflineHandler/NotificationView/NotificationView.tsx +2 -2
  23. package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +17 -18
  24. package/Components/OfflineHandler/__tests__/index.test.tsx +27 -18
  25. package/Components/PlayerContainer/PlayerContainer.tsx +4 -3
  26. package/Components/PlayerImageBackground/index.tsx +2 -11
  27. package/Components/Screen/TV/index.web.tsx +4 -2
  28. package/Components/Screen/__tests__/Screen.test.tsx +65 -42
  29. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +68 -44
  30. package/Components/Screen/hooks.ts +2 -3
  31. package/Components/Screen/index.tsx +2 -3
  32. package/Components/Screen/navigationHandler.ts +49 -24
  33. package/Components/Screen/orientationHandler.ts +3 -3
  34. package/Components/ScreenResolver/index.tsx +13 -7
  35. package/Components/ScreenRevealManager/ScreenRevealManager.ts +40 -8
  36. package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +86 -69
  37. package/Components/Tabs/TV/Tabs.tsx +20 -3
  38. package/Components/Transitioner/Scene.tsx +15 -2
  39. package/Components/Transitioner/index.js +3 -3
  40. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +124 -27
  41. package/Components/VideoModal/ModalAnimation/index.ts +1 -3
  42. package/Components/VideoModal/ModalAnimation/utils.ts +1 -12
  43. package/Components/VideoModal/PlayerWrapper.tsx +15 -61
  44. package/Components/VideoModal/VideoModal.tsx +1 -5
  45. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -0
  46. package/Components/VideoModal/hooks/useModalSize.ts +5 -1
  47. package/Components/VideoModal/playerWrapperStyle.ts +70 -0
  48. package/Components/VideoModal/playerWrapperUtils.ts +20 -21
  49. package/Components/VideoModal/utils.ts +19 -9
  50. package/Decorators/Analytics/index.tsx +6 -5
  51. package/Decorators/ZappPipesDataConnector/index.tsx +2 -2
  52. package/Decorators/ZappPipesDataConnector/resolvers/StaticFeedResolver.tsx +1 -1
  53. package/Helpers/DataSourceHelper/__tests__/itemLimitForData.test.ts +80 -0
  54. package/Helpers/DataSourceHelper/index.ts +19 -0
  55. package/index.d.ts +7 -0
  56. package/package.json +6 -5
  57. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +0 -17
  58. package/Helpers/DataSourceHelper/index.js +0 -19
@@ -0,0 +1,70 @@
1
+ import * as React from "react";
2
+ import { StyleSheet, ViewStyle } from "react-native";
3
+ import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
4
+ import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
5
+ import { playerDimensionsHack } from "./utils";
6
+ import { getTabletWidth } from "@applicaster/zapp-react-native-utils/playerUtils";
7
+ import {
8
+ getBaseDimensions,
9
+ calculateAspectRatio,
10
+ getPlayerDimensions,
11
+ getContainerDimensions,
12
+ } from "./playerWrapperUtils";
13
+
14
+ export const defaultStyles = StyleSheet.create({
15
+ playerContainer: { position: "relative", alignSelf: "center", zIndex: 200 },
16
+ });
17
+
18
+ export const useStyle = ({
19
+ style,
20
+ inline,
21
+ isModal,
22
+ isTabletPortrait,
23
+ configuration,
24
+ pip,
25
+ }) => {
26
+ const isTablet = useIsTablet();
27
+
28
+ const isInlineModal = inline && isModal;
29
+
30
+ const isTabletLandscape = !isTV() && isTablet && !isTabletPortrait;
31
+
32
+ const tabletWidth = getTabletWidth(
33
+ configuration.tablet_landscape_sidebar_width,
34
+ style
35
+ );
36
+
37
+ const baseDimensions: ViewStyle = React.useMemo(
38
+ () => getBaseDimensions(isInlineModal, isTabletLandscape, tabletWidth),
39
+ [isInlineModal, isTabletLandscape, tabletWidth]
40
+ );
41
+
42
+ const aspectRatio = React.useMemo(
43
+ () => calculateAspectRatio(isInlineModal, pip),
44
+ // ignoring insets - only initial needed
45
+ // eslint-disable-next-line react-hooks/exhaustive-deps
46
+ [isInlineModal, pip]
47
+ );
48
+
49
+ return React.useMemo(() => {
50
+ const playerDimensions: ViewStyle = getPlayerDimensions(
51
+ baseDimensions,
52
+ aspectRatio
53
+ );
54
+
55
+ const containerDimensions: ViewStyle = getContainerDimensions(
56
+ baseDimensions,
57
+ aspectRatio
58
+ );
59
+
60
+ const childrenStyles = {
61
+ ...playerDimensions,
62
+ ...playerDimensionsHack,
63
+ };
64
+
65
+ return StyleSheet.create({
66
+ containerDimensions,
67
+ childrenStyles,
68
+ });
69
+ }, [baseDimensions, aspectRatio]);
70
+ };
@@ -1,4 +1,4 @@
1
- import { Dimensions, Platform } from "react-native";
1
+ import { Dimensions, DimensionValue, Platform, ViewStyle } from "react-native";
2
2
  import { Edge } from "react-native-safe-area-context";
3
3
 
4
4
  export type DimensionsT = {
@@ -13,6 +13,10 @@ export type Configuration = {
13
13
  tablet_landscape_player_container_background_color?: string;
14
14
  };
15
15
 
16
+ // This is safe, remembering screen dimensions once as they do not change during runtime
17
+ // TODO: consider sharing screen orientation as a shared function for the app
18
+ const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get("screen");
19
+
16
20
  export const getWindowDimensions = () => {
17
21
  const { width, height } = Dimensions.get("window");
18
22
 
@@ -31,15 +35,11 @@ export const getMinWindowDimension = () => {
31
35
  return Math.min(width, height);
32
36
  };
33
37
 
34
- export const getScreenAspectRatio = (insets?: {
35
- top: number;
36
- bottom: number;
37
- }) => {
38
- const longEdge = getMaxWindowDimension();
39
- const shortEdge = getMinWindowDimension();
38
+ export const getScreenAspectRatio = () => {
39
+ const longEdge = Math.max(SCREEN_WIDTH, SCREEN_HEIGHT);
40
+ const shortEdge = Math.min(SCREEN_WIDTH, SCREEN_HEIGHT);
40
41
 
41
- // subtract insets to get correct aspect ratio on devices with notches
42
- return longEdge / (shortEdge - ((insets?.top ?? 0) + (insets?.bottom ?? 0)));
42
+ return longEdge / shortEdge;
43
43
  };
44
44
 
45
45
  export const getEdges = (
@@ -60,33 +60,32 @@ export const getEdges = (
60
60
  export const getBaseDimensions = (
61
61
  isInlineModal: boolean,
62
62
  isTabletLandscape: boolean,
63
- tabletWidth: number | string
64
- ): DimensionsT => ({
63
+ tabletWidth: DimensionValue
64
+ ): ViewStyle => ({
65
65
  width: isInlineModal && isTabletLandscape ? tabletWidth : "100%",
66
66
  height: undefined,
67
67
  });
68
68
 
69
69
  export const calculateAspectRatio = (
70
70
  isInlineModal: boolean,
71
- pip?: boolean,
72
- insets?: { top: number; bottom: number }
71
+ pip?: boolean
73
72
  ): number => {
74
- return !isInlineModal && !pip ? getScreenAspectRatio(insets) : 16 / 9;
73
+ return !isInlineModal && !pip ? getScreenAspectRatio() : 16 / 9;
75
74
  };
76
75
 
77
76
  export const getPlayerDimensions = (
78
- baseDimensions: DimensionsT,
77
+ baseDimensions: ViewStyle,
79
78
  aspectRatio: number
80
- ): DimensionsT => ({
81
- ...baseDimensions,
79
+ ): ViewStyle => ({
80
+ ...(baseDimensions as any),
82
81
  width: baseDimensions.width,
83
82
  aspectRatio,
84
83
  });
85
84
 
86
85
  export const getContainerDimensions = (
87
- baseDimensions: DimensionsT,
88
- playerAspectRatio?: number
89
- ): DimensionsT => ({
86
+ baseDimensions: ViewStyle,
87
+ aspectRatio?: string | number
88
+ ): ViewStyle => ({
90
89
  ...baseDimensions,
91
- aspectRatio: playerAspectRatio,
90
+ aspectRatio,
92
91
  });
@@ -1,31 +1,35 @@
1
1
  import { mergeRight } from "ramda";
2
2
  import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
3
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
3
+ import {
4
+ useAppSelector,
5
+ useContentTypes,
6
+ } from "@applicaster/zapp-react-native-redux/hooks";
4
7
  import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
5
8
  import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks/device/useIsTablet";
6
9
  import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils";
10
+ import { create } from "zustand";
11
+ import { useRivers } from "@applicaster/zapp-react-native-utils/reactHooks";
12
+ import { selectPluginConfigurationsByPluginId } from "@applicaster/zapp-react-native-redux";
7
13
 
8
14
  export const useConfiguration = () => {
9
15
  const {
10
16
  videoModalState: { item },
11
17
  } = useNavigation();
12
18
 
13
- const { rivers, contentTypes, pluginConfigurations } = usePickFromState([
14
- "rivers",
15
- "contentTypes",
16
- "pluginConfigurations",
17
- ]);
19
+ const rivers = useRivers();
20
+ const contentTypes = useContentTypes();
18
21
 
19
22
  const targetScreenId = contentTypes?.[item?.type?.value]?.screen_id;
20
23
  const targetScreenConfiguration = rivers?.[targetScreenId];
21
24
 
22
- const pluginConfiguration =
23
- pluginConfigurations[targetScreenConfiguration?.type]?.configuration_json;
25
+ const { configuration_json } = useAppSelector((state) =>
26
+ selectPluginConfigurationsByPluginId(state, targetScreenConfiguration?.type)
27
+ );
24
28
 
25
29
  const playerPluginConfig = playerManager.getPluginConfiguration();
26
30
 
27
31
  const config = mergeRight(playerPluginConfig, {
28
- ...pluginConfiguration,
32
+ ...configuration_json,
29
33
  ...targetScreenConfiguration?.general,
30
34
  ...targetScreenConfiguration?.styles,
31
35
  });
@@ -52,6 +56,12 @@ export const useConfiguration = () => {
52
56
  };
53
57
  };
54
58
 
59
+ export const useAnimationStateStore = create<{
60
+ isAnimationInProgress: boolean;
61
+ }>(() => ({
62
+ isAnimationInProgress: false,
63
+ }));
64
+
55
65
  const fullSize = {
56
66
  width: "100%",
57
67
  height: "100%",
@@ -1,7 +1,6 @@
1
1
  import React from "react";
2
2
 
3
3
  import { getAnalyticsFunctions } from "@applicaster/zapp-react-native-utils/analyticsUtils";
4
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
5
4
 
6
5
  type ComponentProps = {
7
6
  component: {
@@ -21,11 +20,13 @@ type ComponentProps = {
21
20
 
22
21
  function withAnalytics(Component) {
23
22
  return function WithAnalytics(props: ComponentProps) {
24
- const { appData } = usePickFromState(["appData"]);
25
-
26
23
  const analyticsFunctions = React.useMemo(
27
- () => getAnalyticsFunctions({ props, appData }),
28
- [props, appData]
24
+ () =>
25
+ getAnalyticsFunctions({
26
+ component: props.component,
27
+ zappPipesData: props.zappPipesData,
28
+ } as any),
29
+ [props.component, props.zappPipesData]
29
30
  );
30
31
 
31
32
  return (
@@ -2,7 +2,7 @@
2
2
  /// <reference types="@applicaster/zapp-react-native-ui-components" />
3
3
  import React from "react";
4
4
  import { useRoute } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
5
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
5
+ import { usePlugins } from "@applicaster/zapp-react-native-redux/hooks";
6
6
  import { ZappPipesSearchContext } from "@applicaster/zapp-react-native-ui-components/Contexts";
7
7
  import { useScreenContext } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
8
8
  import { ResolverSelector } from "./ResolverSelector";
@@ -23,7 +23,7 @@ export function zappPipesDataConnector(
23
23
  ) {
24
24
  return function WrappedWithZappPipesData(props: Props) {
25
25
  const { screenData } = useRoute();
26
- const { plugins } = usePickFromState(["plugins"]);
26
+ const plugins = usePlugins();
27
27
  const screenContextData = useScreenContext();
28
28
 
29
29
  const {
@@ -76,7 +76,7 @@ export function StaticFeedResolver({
76
76
 
77
77
  const zappPipesDataProps = useMemo(
78
78
  () => ({
79
- zappPipesData: { url, loading, data, error },
79
+ zappPipesData: { url, loading, data, error }, // todo: add applyItemLimit
80
80
  reloadData,
81
81
  loadNextData: undefined, // Static resolver doesn't support pagination
82
82
  }),
@@ -0,0 +1,80 @@
1
+ import { itemLimitForData } from "..";
2
+
3
+ describe("itemLimitForData (no mocks)", () => {
4
+ test("returns full array when item_limit is undefined (default Infinity)", () => {
5
+ // @ts-ignore
6
+ const result = itemLimitForData([1, 2, 3], {
7
+ rules: { item_limit: undefined },
8
+ });
9
+
10
+ expect(result).toEqual([1, 2, 3]);
11
+ });
12
+
13
+ test("enforces positive numeric item_limit", () => {
14
+ // @ts-ignore
15
+ const result = itemLimitForData([1, 2, 3, 4], {
16
+ rules: { item_limit: 2 },
17
+ });
18
+
19
+ expect(result).toEqual([1, 2]);
20
+ });
21
+
22
+ test("returns empty array when entry is empty", () => {
23
+ const result = itemLimitForData([], {
24
+ rules: { item_limit: 3 },
25
+ });
26
+
27
+ expect(result).toEqual([]);
28
+ });
29
+
30
+ test("defaults entry to empty array when it is undefined", () => {
31
+ const result = itemLimitForData(undefined, {
32
+ rules: { item_limit: 5 },
33
+ });
34
+
35
+ expect(result).toEqual([]);
36
+ });
37
+
38
+ test("handles missing component", () => {
39
+ // @ts-ignore
40
+ const result = itemLimitForData([10, 20, 30], undefined);
41
+ // missing component → item_limit = undefined → fallback to Infinity
42
+ expect(result).toEqual([10, 20, 30]);
43
+ });
44
+
45
+ test("handles missing rules object", () => {
46
+ // @ts-ignore
47
+ const result = itemLimitForData([10, 20, 30], {});
48
+
49
+ expect(result).toEqual([10, 20, 30]);
50
+ });
51
+
52
+ test("non-positive item_limit should fall back to Infinity", () => {
53
+ // @ts-ignore
54
+ const result = itemLimitForData([1, 2, 3], {
55
+ rules: { item_limit: -10 },
56
+ });
57
+
58
+ // -10 → invalid → fallback to Infinity → no limit
59
+ expect(result).toEqual([1, 2, 3]);
60
+ });
61
+
62
+ test("zero item_limit should fall back to Infinity", () => {
63
+ // @ts-ignore
64
+ const result = itemLimitForData([1, 2, 3], {
65
+ rules: { item_limit: 0 },
66
+ });
67
+
68
+ // 0 → invalid → fallback to Infinity
69
+ expect(result).toEqual([1, 2, 3]);
70
+ });
71
+
72
+ test("NaN item_limit should fall back to Infinity", () => {
73
+ // @ts-ignore
74
+ const result = itemLimitForData([1, 2, 3], {
75
+ rules: { item_limit: NaN },
76
+ });
77
+
78
+ expect(result).toEqual([1, 2, 3]);
79
+ });
80
+ });
@@ -0,0 +1,19 @@
1
+ import { toPositiveNumberWithDefault } from "@applicaster/zapp-react-native-utils/numberUtils";
2
+
3
+ export function itemLimitForData(
4
+ entry: ZappEntry[],
5
+ component: {
6
+ rules?: { item_limit?: number | string };
7
+ }
8
+ ) {
9
+ if (!component?.rules?.item_limit) {
10
+ return entry;
11
+ }
12
+
13
+ const itemLimit = toPositiveNumberWithDefault(
14
+ Infinity,
15
+ component?.rules?.item_limit
16
+ );
17
+
18
+ return (entry || []).slice(0, itemLimit);
19
+ }
package/index.d.ts CHANGED
@@ -228,6 +228,12 @@ declare type TabsSelectionContextType = {
228
228
  selectedEntryIndex: number;
229
229
  };
230
230
 
231
+ declare type TabsAccessibility = {
232
+ announcement?: string;
233
+ selectedHint?: string;
234
+ hint?: string;
235
+ };
236
+
231
237
  declare type TabsProps = {
232
238
  entry: ZappEntry[];
233
239
  groupId: string;
@@ -235,6 +241,7 @@ declare type TabsProps = {
235
241
  focused?: boolean;
236
242
  parentFocus?: ParentFocus;
237
243
  style?: ReactViewStyle;
244
+ accessibility?: TabsAccessibility;
238
245
  };
239
246
 
240
247
  declare type TabContentProps = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-ui-components",
3
- "version": "15.0.0-alpha.5830601313",
3
+ "version": "15.0.0-alpha.5918085834",
4
4
  "description": "Applicaster Zapp React Native ui components for the Quick Brick App",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -28,10 +28,11 @@
28
28
  },
29
29
  "homepage": "https://github.com/applicaster/quickbrick#readme",
30
30
  "dependencies": {
31
- "@applicaster/applicaster-types": "15.0.0-alpha.5830601313",
32
- "@applicaster/zapp-react-native-bridge": "15.0.0-alpha.5830601313",
33
- "@applicaster/zapp-react-native-redux": "15.0.0-alpha.5830601313",
34
- "@applicaster/zapp-react-native-utils": "15.0.0-alpha.5830601313",
31
+ "@applicaster/applicaster-types": "15.0.0-alpha.5918085834",
32
+ "@applicaster/zapp-react-native-bridge": "15.0.0-alpha.5918085834",
33
+ "@applicaster/zapp-react-native-redux": "15.0.0-alpha.5918085834",
34
+ "@applicaster/zapp-react-native-utils": "15.0.0-alpha.5918085834",
35
+ "fast-json-stable-stringify": "^2.1.0",
35
36
  "promise": "^8.3.0",
36
37
  "url": "^0.11.0",
37
38
  "uuid": "^3.3.2"
@@ -1,17 +0,0 @@
1
- import React from "react";
2
- import { View } from "react-native";
3
-
4
- type Props = {
5
- animationType: string;
6
- children: React.ReactNode;
7
- style?: Record<string, any>;
8
- additionalData?: { [key: string]: any };
9
- };
10
-
11
- export const AnimationComponent = (props: Props) => {
12
- const { style } = props;
13
-
14
- const Component = style ? View : React.Fragment;
15
-
16
- return <Component {...props}>{props.children}</Component>;
17
- };
@@ -1,19 +0,0 @@
1
- import * as R from "ramda";
2
-
3
- export function itemLimitForData(entry = [], component) {
4
- const itemLimitValue = Number(R.path(["rules", "item_limit"], component));
5
-
6
- const itemLimit =
7
- itemLimitValue && itemLimitValue > 0
8
- ? itemLimitValue
9
- : Number.MAX_SAFE_INTEGER;
10
-
11
- const isInRange = (min, max) => R.both(R.gte(R.__, min), R.lt(R.__, max));
12
-
13
- const entryShouldBeSliced = (entry) =>
14
- isInRange(0, R.length(entry))(itemLimit);
15
-
16
- const sliceEntriesUpToItemLimit = R.slice(0, itemLimit);
17
-
18
- return R.when(entryShouldBeSliced, sliceEntriesUpToItemLimit)(entry);
19
- }