@applicaster/zapp-react-native-utils 12.0.0-alpha.9004455836 → 12.0.0-alpha.9233494544

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 (66) hide show
  1. package/actionsExecutor/ActionExecutorContext.tsx +16 -8
  2. package/analyticsUtils/__tests__/analyticsManager.test.js +75 -73
  3. package/analyticsUtils/helpers/hooks.ts +1 -1
  4. package/appUtils/HooksManager/index.js +3 -1
  5. package/appUtils/focusManager/index.ts +147 -25
  6. package/appUtils/focusManager/treeDataStructure/Utils/index.js +83 -33
  7. package/appUtils/focusManager/utils/index.ts +77 -0
  8. package/appUtils/keyCodes/__tests__/__snapshots__/keyCodes.test.js.snap +1 -1
  9. package/appUtils/keyCodes/__tests__/keyCodes.test.js +80 -85
  10. package/appUtils/keyCodes/keys.web.js +1 -0
  11. package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +53 -0
  12. package/appUtils/playerManager/conts.ts +5 -0
  13. package/appUtils/playerManager/player.ts +47 -4
  14. package/appUtils/playerManager/playerFactory.ts +12 -10
  15. package/appUtils/playerManager/playerNative.ts +35 -0
  16. package/appUtils/playerManager/usePlayerState.tsx +13 -1
  17. package/appUtils/playerManager/usePlayerTitleSummaryOverlay.tsx +50 -0
  18. package/cellUtils/__tests__/cellUtils.test.ts +59 -0
  19. package/cellUtils/__tests__/fixtures.ts +13 -0
  20. package/cellUtils/index.ts +33 -2
  21. package/focusManager/index.ts +1 -1
  22. package/functionUtils/__tests__/__snapshots__/functionUtils.test.js.snap +2 -2
  23. package/functionUtils/__tests__/functionUtils.test.js +244 -248
  24. package/headersUtils/index.ts +1 -0
  25. package/localizationUtils/__tests__/localizationUtils.test.ts +17 -13
  26. package/localizationUtils/index.ts +6 -3
  27. package/logger/index.ts +1 -1
  28. package/manifestUtils/defaultManifestConfigurations/generalContent.js +6 -0
  29. package/manifestUtils/defaultManifestConfigurations/player.js +10 -1
  30. package/manifestUtils/index.js +5 -1
  31. package/manifestUtils/secondaryImage/index.js +18 -15
  32. package/modalState/index.ts +57 -0
  33. package/navigationUtils/index.ts +56 -7
  34. package/package.json +3 -2
  35. package/playerUtils/configurationGenerator.ts +11 -1
  36. package/pluginUtils/index.ts +2 -2
  37. package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +2 -0
  38. package/reactHooks/autoscrolling/__tests__/{useTrackedView.test.ts → useTrackedView.test.tsx} +18 -1
  39. package/reactHooks/cell-click/__tests__/index.test.js +6 -2
  40. package/reactHooks/cell-click/index.ts +2 -2
  41. package/reactHooks/flatList/useLoadNextPageIfNeeded.ts +16 -9
  42. package/reactHooks/index.ts +2 -0
  43. package/reactHooks/layout/__tests__/{index.test.js → index.test.tsx} +66 -59
  44. package/reactHooks/layout/getDeviceInfo/index.ts +4 -2
  45. package/reactHooks/layout/types/index.ts +2 -0
  46. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.native.test.js +11 -16
  47. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.test.js +12 -14
  48. package/reactHooks/layout/useDimensions/useDimensions.ts +13 -7
  49. package/reactHooks/navigation/__mocks__/index.ts +15 -0
  50. package/reactHooks/navigation/__mocks__/useNavigation.ts +7 -0
  51. package/reactHooks/navigation/__tests__/index.test.tsx +234 -78
  52. package/reactHooks/navigation/index.ts +262 -81
  53. package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +3 -1
  54. package/reactHooks/screen/__mocks__/useScreenContext.ts +3 -1
  55. package/reactHooks/screen/index.ts +2 -0
  56. package/reactHooks/screen/useScreenContext.ts +5 -4
  57. package/reactHooks/screen/useScreenData.ts +1 -1
  58. package/reactHooks/screen/useTargetScreenData.ts +7 -0
  59. package/reactHooks/state/useRivers.ts +3 -1
  60. package/reactHooks/useListenEventBusEvent.ts +1 -4
  61. package/reactHooks/videoModal/hooks/useVideoModalScreenData.tsx +10 -9
  62. package/reactUtils/helpers.tsx +1 -1
  63. package/riverComponetsMeasurementProvider/index.tsx +2 -2
  64. package/stringUtils/index.ts +5 -0
  65. package/testUtils/getByTestId.ts +14 -0
  66. package/testUtils/index.tsx +38 -23
@@ -14,6 +14,7 @@ import {
14
14
  castAndFallbackColor,
15
15
  compact,
16
16
  getValue,
17
+ getColorFromData,
17
18
  } from "../";
18
19
 
19
20
  import {
@@ -23,6 +24,7 @@ import {
23
24
  EMPTY,
24
25
  FALLBACK,
25
26
  TRANSFORM,
27
+ defaultColor,
26
28
  } from "./fixtures";
27
29
 
28
30
  describe("getKeyForLabel", () => {
@@ -388,3 +390,60 @@ describe("getValue", () => {
388
390
  expect(getValue({ value })(value)).toBeNull();
389
391
  });
390
392
  });
393
+
394
+ describe("getColorFromData", () => {
395
+ it("should return value directly if valid color", () => {
396
+ const result = getColorFromData({
397
+ data: entry,
398
+ key: "background_color",
399
+ getValue: getValue(componentStyle),
400
+ defaultColor,
401
+ });
402
+
403
+ expect(result).toBe("#123456");
404
+ });
405
+
406
+ it("should return valid rgba color name", () => {
407
+ const result = getColorFromData({
408
+ data: entry,
409
+ key: "component_background_color",
410
+ getValue: getValue(componentStyle),
411
+ defaultColor,
412
+ });
413
+
414
+ expect(result).toBe("rgba(255, 255, 255, 0)");
415
+ });
416
+
417
+ it("should return path value if path value is set and is valid color", () => {
418
+ const result = getColorFromData({
419
+ data: entry,
420
+ key: VAL.colorKeyPath,
421
+ getValue: getValue(componentStyle),
422
+ defaultColor,
423
+ });
424
+
425
+ expect(result).toBe("#123456");
426
+ });
427
+
428
+ it("should return defaultColor if key value and path value are invalid", () => {
429
+ const result = getColorFromData({
430
+ data: entry,
431
+ key: VAL.invalidColorKey,
432
+ getValue: getValue(componentStyle),
433
+ defaultColor,
434
+ });
435
+
436
+ expect(result).toBe(defaultColor);
437
+ });
438
+
439
+ it("should return defaultColor if path does not exist", () => {
440
+ const result = getColorFromData({
441
+ data: entry,
442
+ key: VAL.invalidColorKeyPath,
443
+ getValue: getValue(componentStyle),
444
+ defaultColor,
445
+ });
446
+
447
+ expect(result).toBe(defaultColor);
448
+ });
449
+ });
@@ -1,5 +1,7 @@
1
1
  /* eslint-disable max-len */
2
2
 
3
+ export const defaultColor = "#ffffff";
4
+
3
5
  export const entry = {
4
6
  type: {
5
7
  value: "video",
@@ -26,7 +28,9 @@ export const entry = {
26
28
  type: "video/mp4",
27
29
  src: "https://wino-feed.s3.amazonaws.com/movieFeed/Ford+v+Ferrari.mp4",
28
30
  },
31
+ background_color: "#123456",
29
32
  extensions: {
33
+ background_color: "#123456",
30
34
  free: false,
31
35
  duration: 9000,
32
36
  section: "New Releases",
@@ -46,7 +50,11 @@ export const componentStyle = {
46
50
  horizontal_list_cell_width: "400",
47
51
  cell_plugin_configuration_id: "267bd05a-08bd-4675-bdd3-9b73899773f0",
48
52
  horizontal_list_scaled_switch: false,
53
+ background_color: "#123456",
49
54
  component_background_color: "rgba(255, 255, 255, 0)",
55
+ background_color_1: "extensions.background_color",
56
+ background_color_2: "invalidColorKey",
57
+ background_color_3: "extensions.invalidColorKeyPath",
50
58
  component_padding_left: "",
51
59
  horizontal_list_next_offset: 20,
52
60
  component_margin_bottom: "",
@@ -93,6 +101,11 @@ export const VAL = {
93
101
  upper: "STRING",
94
102
  width: 400,
95
103
  height: 225,
104
+ colorKey: "background_color",
105
+ colorKeyRgba: "component_background_color",
106
+ colorKeyPath: "background_color_1",
107
+ invalidColorKey: "background_color_2",
108
+ invalidColorKeyPath: "background_color_3",
96
109
  };
97
110
 
98
111
  export const TRANSFORM = {
@@ -1,5 +1,6 @@
1
1
  import * as R from "ramda";
2
2
  import dayjs from "dayjs";
3
+ import validateColor from "validate-color";
3
4
 
4
5
  import { toNumberWithDefault, toNumberWithDefaultZero } from "../numberUtils";
5
6
  import { transformColorCode as fixColorHexCode } from "../transform";
@@ -181,8 +182,8 @@ export const getHeight = (width, aspectRatio) => {
181
182
  * @returns {string} duration
182
183
  */
183
184
 
184
- export const getDurationInMinutes = (seconds: number): string => {
185
- if (seconds === (null || undefined)) return "00:00";
185
+ export const getDurationInMinutes = (seconds?: number): string => {
186
+ if (!seconds) return "00:00";
186
187
  const minutes = Math.floor(Number(seconds) / 60);
187
188
  const secondsReminder = Math.floor(Number(seconds)) % 60;
188
189
  const pad = (num: number): string => `${num < 10 ? "0" : ""}${num}`;
@@ -443,3 +444,33 @@ export const toResizeMode = (
443
444
  resizeMode: "contain",
444
445
  };
445
446
  };
447
+
448
+ type GetColorFromData = {
449
+ data: Record<string, any>;
450
+ key: string;
451
+ getValue: Function;
452
+ defaultColor: string;
453
+ };
454
+
455
+ export const getColorFromData = ({
456
+ data,
457
+ key,
458
+ getValue,
459
+ defaultColor,
460
+ }: GetColorFromData): string => {
461
+ const value = getValue(key);
462
+
463
+ // Temporary hack to fix color validation when alpha is floating point number
464
+ // https://github.com/dreamyguy/validate-color/issues/44
465
+ if (validateColor(value.replace(".00", ""))) {
466
+ return value;
467
+ }
468
+
469
+ const pathValue = R.path(value.split("."), data);
470
+
471
+ if (pathValue && validateColor(pathValue)) {
472
+ return pathValue;
473
+ }
474
+
475
+ return defaultColor;
476
+ };
@@ -86,7 +86,7 @@ export const isFocusable = (component: ZappEntry | ZappUIComponent | any) =>
86
86
 
87
87
  type Props = {
88
88
  component: ZappUIComponent;
89
- zappPipesData: ZappPipesData;
89
+ zappPipesData?: ZappPipesData;
90
90
  } & Record<string, any>;
91
91
 
92
92
  export const useIsFocusable = (props: Props): void => {
@@ -1,6 +1,6 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`subscriber can be invoked without args 1`] = `
3
+ exports[`functionUtils subscriber can be invoked without args 1`] = `
4
4
  Object {
5
5
  "handlers": Object {},
6
6
  "invokeHandler": [Function],
@@ -9,7 +9,7 @@ Object {
9
9
  }
10
10
  `;
11
11
 
12
- exports[`subscriber returns the original object with additional methods 1`] = `
12
+ exports[`functionUtils subscriber returns the original object with additional methods 1`] = `
13
13
  Object {
14
14
  "foo": "bar",
15
15
  "handlers": Object {},