@applicaster/zapp-react-native-utils 13.0.0-alpha.5375459737 → 13.0.0-alpha.5406200595
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/actionsExecutor/ActionExecutorContext.tsx +4 -15
- package/appUtils/__tests__/__snapshots__/localizationsHelper.test.ts.snap +151 -0
- package/appUtils/__tests__/allZappLocales.ts +79 -0
- package/appUtils/__tests__/{localizationsHelper.test.js → localizationsHelper.test.ts} +11 -0
- package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +1 -0
- package/appUtils/focusManager/index.ios.ts +14 -4
- package/appUtils/focusManager/utils/__tests__/findChild.test.ts +35 -0
- package/appUtils/focusManager/utils/index.ts +5 -0
- package/appUtils/localizationsHelper.ts +10 -2
- package/appUtils/playerManager/playerHooks/usePlayerCurrentTime.tsx +11 -7
- package/cellUtils/index.ts +9 -5
- package/componentsUtils/index.ts +8 -1
- package/localizationUtils/index.ts +3 -3
- package/manifestUtils/defaultManifestConfigurations/generalContent.js +13 -0
- package/manifestUtils/defaultManifestConfigurations/player.js +0 -8
- package/manifestUtils/keys.js +27 -2
- package/package.json +2 -2
- package/playerUtils/configurationGenerator.ts +0 -16
- package/reactHooks/feed/useBatchLoading.ts +10 -12
- package/reactHooks/screen/__tests__/useScreenBackgroundColor.test.tsx +69 -0
- package/reactHooks/screen/useScreenBackgroundColor.ts +3 -15
- package/reactHooks/useListenEventBusEvent.ts +1 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="@applicaster/applicaster-types" />
|
|
2
2
|
import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
|
|
3
3
|
import React, { createContext, useEffect, useMemo } from "react";
|
|
4
|
-
import { NativeModules } from "react-native";
|
|
5
4
|
import {
|
|
6
5
|
actionExecutor as _actionExecutor,
|
|
7
6
|
ActionResult,
|
|
@@ -27,11 +26,8 @@ import {
|
|
|
27
26
|
useContentTypes,
|
|
28
27
|
usePickFromState,
|
|
29
28
|
} from "@applicaster/zapp-react-native-redux/hooks";
|
|
30
|
-
import {
|
|
31
|
-
|
|
32
|
-
TOGGLE_FLAG_MAX_ITEMS_REACHED_EVENT,
|
|
33
|
-
} from "./consts";
|
|
34
|
-
const { ReactNativeEventBusBridge } = NativeModules;
|
|
29
|
+
import { TOGGLE_FLAG_MAX_ITEMS_REACHED_EVENT } from "./consts";
|
|
30
|
+
import { postEvent } from "../reactHooks/useSubscriberFor";
|
|
35
31
|
|
|
36
32
|
export const { log_error, log_info, log_debug } = createLogger({
|
|
37
33
|
subsystem: "ActionExecutorContext",
|
|
@@ -83,21 +79,14 @@ function findParentComponent(
|
|
|
83
79
|
// send all data just in case (like for message string formatting)
|
|
84
80
|
// Type is not exported for now
|
|
85
81
|
type MaxTagsReachedEvent = {
|
|
86
|
-
|
|
87
|
-
selectedItems?: string[];
|
|
82
|
+
selectedItems: string[];
|
|
88
83
|
maxItems: number;
|
|
89
84
|
tag: string;
|
|
90
85
|
keyNamespace: string;
|
|
91
86
|
};
|
|
92
87
|
|
|
93
88
|
async function onMaxTagsReached(data: MaxTagsReachedEvent) {
|
|
94
|
-
|
|
95
|
-
type: TOGGLE_FLAG_MAX_ITEMS_REACHED_EVENT,
|
|
96
|
-
source: ACTION_EXECUTOR_EVENT_SOURCE,
|
|
97
|
-
data,
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
await ReactNativeEventBusBridge?.postEvent(event);
|
|
89
|
+
postEvent(TOGGLE_FLAG_MAX_ITEMS_REACHED_EVENT, [data]);
|
|
101
90
|
}
|
|
102
91
|
|
|
103
92
|
const prepareDefaultActions = (actionExecutor) => {
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`toDayJSLocaleMap [af] returns a valid dayjs locale 1`] = `"af"`;
|
|
4
|
+
|
|
5
|
+
exports[`toDayJSLocaleMap [ar] returns a valid dayjs locale 1`] = `"ar"`;
|
|
6
|
+
|
|
7
|
+
exports[`toDayJSLocaleMap [bg] returns a valid dayjs locale 1`] = `"bg"`;
|
|
8
|
+
|
|
9
|
+
exports[`toDayJSLocaleMap [bn] returns a valid dayjs locale 1`] = `"bn"`;
|
|
10
|
+
|
|
11
|
+
exports[`toDayJSLocaleMap [bo] returns a valid dayjs locale 1`] = `"bo"`;
|
|
12
|
+
|
|
13
|
+
exports[`toDayJSLocaleMap [ca] returns a valid dayjs locale 1`] = `"ca"`;
|
|
14
|
+
|
|
15
|
+
exports[`toDayJSLocaleMap [cs] returns a valid dayjs locale 1`] = `"cs"`;
|
|
16
|
+
|
|
17
|
+
exports[`toDayJSLocaleMap [da] returns a valid dayjs locale 1`] = `"da"`;
|
|
18
|
+
|
|
19
|
+
exports[`toDayJSLocaleMap [de] returns a valid dayjs locale 1`] = `"de"`;
|
|
20
|
+
|
|
21
|
+
exports[`toDayJSLocaleMap [el] returns a valid dayjs locale 1`] = `"el"`;
|
|
22
|
+
|
|
23
|
+
exports[`toDayJSLocaleMap [en] returns a valid dayjs locale 1`] = `"en"`;
|
|
24
|
+
|
|
25
|
+
exports[`toDayJSLocaleMap [en-GB] returns a valid dayjs locale 1`] = `"en-gb"`;
|
|
26
|
+
|
|
27
|
+
exports[`toDayJSLocaleMap [en-UK] returns a valid dayjs locale 1`] = `"en-gb"`;
|
|
28
|
+
|
|
29
|
+
exports[`toDayJSLocaleMap [es] returns a valid dayjs locale 1`] = `"es"`;
|
|
30
|
+
|
|
31
|
+
exports[`toDayJSLocaleMap [es-LA] returns a valid dayjs locale 1`] = `"es"`;
|
|
32
|
+
|
|
33
|
+
exports[`toDayJSLocaleMap [es-MX] returns a valid dayjs locale 1`] = `"es-mx"`;
|
|
34
|
+
|
|
35
|
+
exports[`toDayJSLocaleMap [es-US] returns a valid dayjs locale 1`] = `"es-us"`;
|
|
36
|
+
|
|
37
|
+
exports[`toDayJSLocaleMap [et] returns a valid dayjs locale 1`] = `"et"`;
|
|
38
|
+
|
|
39
|
+
exports[`toDayJSLocaleMap [eu] returns a valid dayjs locale 1`] = `"eu"`;
|
|
40
|
+
|
|
41
|
+
exports[`toDayJSLocaleMap [fa] returns a valid dayjs locale 1`] = `"fa"`;
|
|
42
|
+
|
|
43
|
+
exports[`toDayJSLocaleMap [fi] returns a valid dayjs locale 1`] = `"fi"`;
|
|
44
|
+
|
|
45
|
+
exports[`toDayJSLocaleMap [fj] returns a valid dayjs locale 1`] = `"en"`;
|
|
46
|
+
|
|
47
|
+
exports[`toDayJSLocaleMap [fr] returns a valid dayjs locale 1`] = `"fr"`;
|
|
48
|
+
|
|
49
|
+
exports[`toDayJSLocaleMap [ga] returns a valid dayjs locale 1`] = `"ga"`;
|
|
50
|
+
|
|
51
|
+
exports[`toDayJSLocaleMap [gu] returns a valid dayjs locale 1`] = `"gu"`;
|
|
52
|
+
|
|
53
|
+
exports[`toDayJSLocaleMap [he] returns a valid dayjs locale 1`] = `"he"`;
|
|
54
|
+
|
|
55
|
+
exports[`toDayJSLocaleMap [hi] returns a valid dayjs locale 1`] = `"hi"`;
|
|
56
|
+
|
|
57
|
+
exports[`toDayJSLocaleMap [hr] returns a valid dayjs locale 1`] = `"hr"`;
|
|
58
|
+
|
|
59
|
+
exports[`toDayJSLocaleMap [hu] returns a valid dayjs locale 1`] = `"hu"`;
|
|
60
|
+
|
|
61
|
+
exports[`toDayJSLocaleMap [hy] returns a valid dayjs locale 1`] = `"hy-am"`;
|
|
62
|
+
|
|
63
|
+
exports[`toDayJSLocaleMap [id] returns a valid dayjs locale 1`] = `"id"`;
|
|
64
|
+
|
|
65
|
+
exports[`toDayJSLocaleMap [is] returns a valid dayjs locale 1`] = `"is"`;
|
|
66
|
+
|
|
67
|
+
exports[`toDayJSLocaleMap [it] returns a valid dayjs locale 1`] = `"it"`;
|
|
68
|
+
|
|
69
|
+
exports[`toDayJSLocaleMap [ja] returns a valid dayjs locale 1`] = `"ja"`;
|
|
70
|
+
|
|
71
|
+
exports[`toDayJSLocaleMap [ka] returns a valid dayjs locale 1`] = `"ka"`;
|
|
72
|
+
|
|
73
|
+
exports[`toDayJSLocaleMap [km] returns a valid dayjs locale 1`] = `"km"`;
|
|
74
|
+
|
|
75
|
+
exports[`toDayJSLocaleMap [ko] returns a valid dayjs locale 1`] = `"ko"`;
|
|
76
|
+
|
|
77
|
+
exports[`toDayJSLocaleMap [la] returns a valid dayjs locale 1`] = `"en"`;
|
|
78
|
+
|
|
79
|
+
exports[`toDayJSLocaleMap [lt] returns a valid dayjs locale 1`] = `"lt"`;
|
|
80
|
+
|
|
81
|
+
exports[`toDayJSLocaleMap [lv] returns a valid dayjs locale 1`] = `"lv"`;
|
|
82
|
+
|
|
83
|
+
exports[`toDayJSLocaleMap [mi] returns a valid dayjs locale 1`] = `"mi"`;
|
|
84
|
+
|
|
85
|
+
exports[`toDayJSLocaleMap [mk] returns a valid dayjs locale 1`] = `"mk"`;
|
|
86
|
+
|
|
87
|
+
exports[`toDayJSLocaleMap [ml] returns a valid dayjs locale 1`] = `"ml"`;
|
|
88
|
+
|
|
89
|
+
exports[`toDayJSLocaleMap [mn] returns a valid dayjs locale 1`] = `"mn"`;
|
|
90
|
+
|
|
91
|
+
exports[`toDayJSLocaleMap [mr] returns a valid dayjs locale 1`] = `"mr"`;
|
|
92
|
+
|
|
93
|
+
exports[`toDayJSLocaleMap [ms] returns a valid dayjs locale 1`] = `"ms"`;
|
|
94
|
+
|
|
95
|
+
exports[`toDayJSLocaleMap [mt] returns a valid dayjs locale 1`] = `"mt"`;
|
|
96
|
+
|
|
97
|
+
exports[`toDayJSLocaleMap [ne] returns a valid dayjs locale 1`] = `"ne"`;
|
|
98
|
+
|
|
99
|
+
exports[`toDayJSLocaleMap [nl] returns a valid dayjs locale 1`] = `"nl"`;
|
|
100
|
+
|
|
101
|
+
exports[`toDayJSLocaleMap [no] returns a valid dayjs locale 1`] = `"en"`;
|
|
102
|
+
|
|
103
|
+
exports[`toDayJSLocaleMap [pa] returns a valid dayjs locale 1`] = `"pa-in"`;
|
|
104
|
+
|
|
105
|
+
exports[`toDayJSLocaleMap [pl] returns a valid dayjs locale 1`] = `"pl"`;
|
|
106
|
+
|
|
107
|
+
exports[`toDayJSLocaleMap [pt] returns a valid dayjs locale 1`] = `"pt"`;
|
|
108
|
+
|
|
109
|
+
exports[`toDayJSLocaleMap [pt-BR] returns a valid dayjs locale 1`] = `"pt-br"`;
|
|
110
|
+
|
|
111
|
+
exports[`toDayJSLocaleMap [qu] returns a valid dayjs locale 1`] = `"en"`;
|
|
112
|
+
|
|
113
|
+
exports[`toDayJSLocaleMap [ro] returns a valid dayjs locale 1`] = `"ro"`;
|
|
114
|
+
|
|
115
|
+
exports[`toDayJSLocaleMap [ru] returns a valid dayjs locale 1`] = `"ru"`;
|
|
116
|
+
|
|
117
|
+
exports[`toDayJSLocaleMap [sk] returns a valid dayjs locale 1`] = `"sk"`;
|
|
118
|
+
|
|
119
|
+
exports[`toDayJSLocaleMap [sl] returns a valid dayjs locale 1`] = `"sl"`;
|
|
120
|
+
|
|
121
|
+
exports[`toDayJSLocaleMap [sm] returns a valid dayjs locale 1`] = `"en"`;
|
|
122
|
+
|
|
123
|
+
exports[`toDayJSLocaleMap [sq] returns a valid dayjs locale 1`] = `"sq"`;
|
|
124
|
+
|
|
125
|
+
exports[`toDayJSLocaleMap [sr] returns a valid dayjs locale 1`] = `"sr"`;
|
|
126
|
+
|
|
127
|
+
exports[`toDayJSLocaleMap [sv] returns a valid dayjs locale 1`] = `"sv"`;
|
|
128
|
+
|
|
129
|
+
exports[`toDayJSLocaleMap [sw] returns a valid dayjs locale 1`] = `"sw"`;
|
|
130
|
+
|
|
131
|
+
exports[`toDayJSLocaleMap [ta] returns a valid dayjs locale 1`] = `"ta"`;
|
|
132
|
+
|
|
133
|
+
exports[`toDayJSLocaleMap [te] returns a valid dayjs locale 1`] = `"te"`;
|
|
134
|
+
|
|
135
|
+
exports[`toDayJSLocaleMap [th] returns a valid dayjs locale 1`] = `"th"`;
|
|
136
|
+
|
|
137
|
+
exports[`toDayJSLocaleMap [to] returns a valid dayjs locale 1`] = `"en"`;
|
|
138
|
+
|
|
139
|
+
exports[`toDayJSLocaleMap [tr] returns a valid dayjs locale 1`] = `"tr"`;
|
|
140
|
+
|
|
141
|
+
exports[`toDayJSLocaleMap [tt] returns a valid dayjs locale 1`] = `"en"`;
|
|
142
|
+
|
|
143
|
+
exports[`toDayJSLocaleMap [uk] returns a valid dayjs locale 1`] = `"uk"`;
|
|
144
|
+
|
|
145
|
+
exports[`toDayJSLocaleMap [ur] returns a valid dayjs locale 1`] = `"ur"`;
|
|
146
|
+
|
|
147
|
+
exports[`toDayJSLocaleMap [uz] returns a valid dayjs locale 1`] = `"uz"`;
|
|
148
|
+
|
|
149
|
+
exports[`toDayJSLocaleMap [vi] returns a valid dayjs locale 1`] = `"vi"`;
|
|
150
|
+
|
|
151
|
+
exports[`toDayJSLocaleMap [zh] returns a valid dayjs locale 1`] = `"zh"`;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export default [
|
|
2
|
+
// common locales from https://rubygems.org/gems/language_list
|
|
3
|
+
"en",
|
|
4
|
+
"fr",
|
|
5
|
+
"de",
|
|
6
|
+
"nl",
|
|
7
|
+
"ru",
|
|
8
|
+
"es",
|
|
9
|
+
"he",
|
|
10
|
+
"hy",
|
|
11
|
+
"sq",
|
|
12
|
+
"af",
|
|
13
|
+
"ar",
|
|
14
|
+
"eu",
|
|
15
|
+
"bn",
|
|
16
|
+
"bg",
|
|
17
|
+
"zh",
|
|
18
|
+
"cs",
|
|
19
|
+
"km",
|
|
20
|
+
"ca",
|
|
21
|
+
"hr",
|
|
22
|
+
"da",
|
|
23
|
+
"et",
|
|
24
|
+
"fj",
|
|
25
|
+
"fi",
|
|
26
|
+
"gu",
|
|
27
|
+
"ka",
|
|
28
|
+
"hu",
|
|
29
|
+
"hi",
|
|
30
|
+
"it",
|
|
31
|
+
"is",
|
|
32
|
+
"id",
|
|
33
|
+
"ga",
|
|
34
|
+
"ja",
|
|
35
|
+
"ko",
|
|
36
|
+
"la",
|
|
37
|
+
"lv",
|
|
38
|
+
"lt",
|
|
39
|
+
"ms",
|
|
40
|
+
"mi",
|
|
41
|
+
"mn",
|
|
42
|
+
"mt",
|
|
43
|
+
"mk",
|
|
44
|
+
"el",
|
|
45
|
+
"mr",
|
|
46
|
+
"ml",
|
|
47
|
+
"ne",
|
|
48
|
+
"no",
|
|
49
|
+
"pa",
|
|
50
|
+
"pl",
|
|
51
|
+
"pt",
|
|
52
|
+
"fa",
|
|
53
|
+
"qu",
|
|
54
|
+
"ro",
|
|
55
|
+
"sk",
|
|
56
|
+
"sm",
|
|
57
|
+
"sr",
|
|
58
|
+
"sw",
|
|
59
|
+
"sv",
|
|
60
|
+
"sl",
|
|
61
|
+
"to",
|
|
62
|
+
"tr",
|
|
63
|
+
"th",
|
|
64
|
+
"te",
|
|
65
|
+
"bo",
|
|
66
|
+
"tt",
|
|
67
|
+
"ta",
|
|
68
|
+
"uk",
|
|
69
|
+
"ur",
|
|
70
|
+
"uz",
|
|
71
|
+
"vi",
|
|
72
|
+
// Extra locales https://github.com/applicaster/zapp/blob/5604794f15cfd270ae494b0db85e542de4cebfaa/config/additional_languages.yml
|
|
73
|
+
"en-UK",
|
|
74
|
+
"en-GB",
|
|
75
|
+
"es-LA",
|
|
76
|
+
"pt-BR",
|
|
77
|
+
"es-MX",
|
|
78
|
+
"es-US",
|
|
79
|
+
];
|
|
@@ -8,6 +8,7 @@ const {
|
|
|
8
8
|
getLocale,
|
|
9
9
|
getLanguageCode,
|
|
10
10
|
getCountryCode,
|
|
11
|
+
toDayJSLocaleMap,
|
|
11
12
|
} = require("../localizationsHelper");
|
|
12
13
|
|
|
13
14
|
describe("getLocale", () => {
|
|
@@ -69,3 +70,13 @@ describe("getCountryCode", () => {
|
|
|
69
70
|
expect(currentValue).toEqual(expectedValue);
|
|
70
71
|
});
|
|
71
72
|
});
|
|
73
|
+
|
|
74
|
+
describe("toDayJSLocaleMap", () => {
|
|
75
|
+
const allZappLocales: string[] = require("./allZappLocales").default;
|
|
76
|
+
|
|
77
|
+
it.each(allZappLocales)("[%s] returns a valid dayjs locale", (locale) => {
|
|
78
|
+
const dayJSLocale = toDayJSLocaleMap(locale);
|
|
79
|
+
expect(dayJSLocale).toBeDefined();
|
|
80
|
+
expect(dayJSLocale).toMatchSnapshot();
|
|
81
|
+
});
|
|
82
|
+
});
|
|
@@ -61,6 +61,7 @@ exports[`focusManagerIOS should be defined 1`] = `
|
|
|
61
61
|
"getCurrentGroup": [Function],
|
|
62
62
|
"getGroupById": [Function],
|
|
63
63
|
"getGroupRootById": [Function],
|
|
64
|
+
"getPreferredFocusChild": [Function],
|
|
64
65
|
"invokeHandler": [Function],
|
|
65
66
|
"isGroupItemFocused": [Function],
|
|
66
67
|
"moveFocus": [Function],
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { NativeModules } from "react-native";
|
|
2
2
|
import * as R from "ramda";
|
|
3
|
+
|
|
3
4
|
import { Tree } from "./treeDataStructure/Tree";
|
|
4
5
|
import { findFocusableNode } from "./treeDataStructure/Utils";
|
|
5
6
|
import { subscriber } from "../../functionUtils";
|
|
7
|
+
import { findChild } from "./utils";
|
|
6
8
|
|
|
7
9
|
const { FocusableManagerModule } = NativeModules;
|
|
8
10
|
|
|
@@ -52,10 +54,7 @@ export const focusManager = (function () {
|
|
|
52
54
|
const node = focusableTree.findInTree(groupId);
|
|
53
55
|
|
|
54
56
|
if (node?.children?.length > 0) {
|
|
55
|
-
const preferredFocus =
|
|
56
|
-
R.find(R.pathEq(["component", "props", "preferredFocus"], true)),
|
|
57
|
-
R.prop("children")
|
|
58
|
-
)(node);
|
|
57
|
+
const preferredFocus = findChild(true, node);
|
|
59
58
|
|
|
60
59
|
if (preferredFocus?.component?.isGroup) {
|
|
61
60
|
return getPreferredFocusInGroup({ groupId: preferredFocus?.id });
|
|
@@ -382,6 +381,16 @@ export const focusManager = (function () {
|
|
|
382
381
|
forceFocusOnItem({ focusableItem, callback });
|
|
383
382
|
}
|
|
384
383
|
|
|
384
|
+
function getPreferredFocusChild(id) {
|
|
385
|
+
const node = focusableTree.findInTree(id);
|
|
386
|
+
|
|
387
|
+
if (node?.children?.length > 0) {
|
|
388
|
+
return findChild(true, node) || findChild(false, node);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
return node;
|
|
392
|
+
}
|
|
393
|
+
|
|
385
394
|
return {
|
|
386
395
|
on,
|
|
387
396
|
invokeHandler,
|
|
@@ -402,5 +411,6 @@ export const focusManager = (function () {
|
|
|
402
411
|
getCurrentGroup,
|
|
403
412
|
getGroupRootById,
|
|
404
413
|
isGroupItemFocused,
|
|
414
|
+
getPreferredFocusChild,
|
|
405
415
|
};
|
|
406
416
|
})();
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { findChild } from "../index";
|
|
2
|
+
|
|
3
|
+
describe("findChild", () => {
|
|
4
|
+
const makeNode = (children = []) => ({ children });
|
|
5
|
+
|
|
6
|
+
const child = (preferredFocus: boolean) => ({
|
|
7
|
+
component: { props: { preferredFocus } },
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it("returns the child with preferredFocus=true", () => {
|
|
11
|
+
const node = makeNode([child(false), child(true), child(false)]);
|
|
12
|
+
expect(findChild(true, node)).toBe(node.children[1]);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("returns the child with preferredFocus=false", () => {
|
|
16
|
+
const node = makeNode([child(false), child(true), child(false)]);
|
|
17
|
+
expect(findChild(false, node)).toBe(node.children[0]);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("returns undefined if no child matches preferredFocus", () => {
|
|
21
|
+
const node = makeNode([child(false), child(false)]);
|
|
22
|
+
expect(findChild(true, node)).toBeUndefined();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("returns undefined if node has no children", () => {
|
|
26
|
+
const node = makeNode();
|
|
27
|
+
expect(findChild(true, node)).toBeUndefined();
|
|
28
|
+
expect(findChild(false, node)).toBeUndefined();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("returns undefined if children is not an array", () => {
|
|
32
|
+
const node = { children: null };
|
|
33
|
+
expect(findChild(true, node)).toBeUndefined();
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -98,3 +98,8 @@ export const waitForContent = (focusableTree) => {
|
|
|
98
98
|
conditionFn: contentHasAnyChildren,
|
|
99
99
|
});
|
|
100
100
|
};
|
|
101
|
+
|
|
102
|
+
export const findChild = (preferredFocus: boolean, node) =>
|
|
103
|
+
(node?.children || []).find(
|
|
104
|
+
(child) => child?.component?.props?.preferredFocus === preferredFocus
|
|
105
|
+
);
|
|
@@ -65,6 +65,12 @@ export function getUILanguage() {
|
|
|
65
65
|
return getLanguageCode();
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
/**
|
|
69
|
+
* fallback to en for missing dayjslocalization
|
|
70
|
+
* converts the locale code to a dayjs compatible locale code
|
|
71
|
+
* lowercase input code is expected, e.g. "en-GB" => "en-gb"
|
|
72
|
+
* @param {string} code - locale code, e.g. "en", "fr", "es-LA"
|
|
73
|
+
* */
|
|
68
74
|
export const toDayJSLocaleMap = (code) => {
|
|
69
75
|
const map = {
|
|
70
76
|
hy: "hy-am",
|
|
@@ -73,10 +79,12 @@ export const toDayJSLocaleMap = (code) => {
|
|
|
73
79
|
no: null,
|
|
74
80
|
pa: "pa-in",
|
|
75
81
|
qu: null,
|
|
76
|
-
"es-LA": "es",
|
|
77
82
|
sm: null,
|
|
78
83
|
to: null,
|
|
79
84
|
xh: null,
|
|
85
|
+
tt: null,
|
|
86
|
+
"es-LA": "es",
|
|
87
|
+
"en-UK": "en-gb",
|
|
80
88
|
};
|
|
81
89
|
|
|
82
90
|
if (map[code] === null) {
|
|
@@ -84,7 +92,7 @@ export const toDayJSLocaleMap = (code) => {
|
|
|
84
92
|
} else if (map[code]) {
|
|
85
93
|
return map[code];
|
|
86
94
|
} else {
|
|
87
|
-
return code;
|
|
95
|
+
return code.toLowerCase();
|
|
88
96
|
}
|
|
89
97
|
};
|
|
90
98
|
|
|
@@ -12,7 +12,7 @@ import { useThrottle } from "../../../functionUtils";
|
|
|
12
12
|
export const usePlayerCurrentTime = (
|
|
13
13
|
listenerId: string,
|
|
14
14
|
playerId?: string
|
|
15
|
-
): number | null => {
|
|
15
|
+
): { currentTime: number | null; cancel: () => void } => {
|
|
16
16
|
const [currentTime, setCurrentTime] = useState<number | null>(null);
|
|
17
17
|
const player: Player = usePlayer(playerId);
|
|
18
18
|
|
|
@@ -20,15 +20,17 @@ export const usePlayerCurrentTime = (
|
|
|
20
20
|
if (player) {
|
|
21
21
|
const newCurrentTime = player.getContentPosition();
|
|
22
22
|
|
|
23
|
-
setCurrentTime(
|
|
24
|
-
prevTime !== newCurrentTime ? newCurrentTime : prevTime
|
|
25
|
-
);
|
|
23
|
+
setCurrentTime(newCurrentTime);
|
|
26
24
|
}
|
|
27
25
|
}, [player]);
|
|
28
26
|
|
|
27
|
+
// We update the current time every ~250ms since player can have rate set to 2x.
|
|
28
|
+
// We update more often than 2x a second to avoid noticiable 'pulsation' in update,
|
|
29
|
+
// since native level also updates the current time every ~250ms,
|
|
30
|
+
// and combined with assorted delays it creates interference pattern.
|
|
29
31
|
const { throttledFunction: throttledUpdate, cancel } = useThrottle(
|
|
30
32
|
updateCurrentTime,
|
|
31
|
-
1000
|
|
33
|
+
1000 / 4
|
|
32
34
|
);
|
|
33
35
|
|
|
34
36
|
useEffect(() => {
|
|
@@ -36,7 +38,9 @@ export const usePlayerCurrentTime = (
|
|
|
36
38
|
throttledUpdate();
|
|
37
39
|
|
|
38
40
|
const listeners = {
|
|
39
|
-
onVideoProgress:
|
|
41
|
+
onVideoProgress: () => {
|
|
42
|
+
setCurrentTime(player.getContentPosition());
|
|
43
|
+
},
|
|
40
44
|
};
|
|
41
45
|
|
|
42
46
|
const id = `${listenerId}_player_current_time`;
|
|
@@ -53,5 +57,5 @@ export const usePlayerCurrentTime = (
|
|
|
53
57
|
}
|
|
54
58
|
}, [player, listenerId, throttledUpdate, cancel]);
|
|
55
59
|
|
|
56
|
-
return currentTime;
|
|
60
|
+
return { currentTime, cancel };
|
|
57
61
|
};
|
package/cellUtils/index.ts
CHANGED
|
@@ -2,12 +2,16 @@ import * as R from "ramda";
|
|
|
2
2
|
import dayjs from "dayjs";
|
|
3
3
|
import validateColor from "validate-color";
|
|
4
4
|
|
|
5
|
+
import { transformColorCode as fixColorHexCode } from "@applicaster/zapp-react-native-utils/transform";
|
|
6
|
+
import {
|
|
7
|
+
capitalize,
|
|
8
|
+
isString,
|
|
9
|
+
} from "@applicaster/zapp-react-native-utils/stringUtils";
|
|
10
|
+
import { cellUtilsLogger } from "@applicaster/zapp-react-native-utils/cellUtils/logger";
|
|
11
|
+
import { isWeb } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
12
|
+
import { isNotNil } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
|
|
13
|
+
|
|
5
14
|
import { toNumberWithDefault, toNumberWithDefaultZero } from "../numberUtils";
|
|
6
|
-
import { transformColorCode as fixColorHexCode } from "../transform";
|
|
7
|
-
import { capitalize, isString } from "../stringUtils";
|
|
8
|
-
import { cellUtilsLogger } from "./logger";
|
|
9
|
-
import { isWeb } from "../reactUtils";
|
|
10
|
-
import { isNotNil } from "../reactUtils/helpers";
|
|
11
15
|
|
|
12
16
|
const CUSTOM_KEY = "other";
|
|
13
17
|
|
package/componentsUtils/index.ts
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
const GROUP = "group-qb";
|
|
2
2
|
const GROUP_INFO = "group-info-qb";
|
|
3
|
+
const GROUP_INFO_OLD = "group-info";
|
|
3
4
|
const EMPTY_GROUP_COMPONENT = "empty_group_component";
|
|
4
5
|
|
|
5
6
|
const GALLERY = "gallery-qb";
|
|
6
7
|
|
|
7
8
|
const SCREEN_PICKER = "screen-picker-qb-tv";
|
|
8
9
|
|
|
10
|
+
const HORIZONTAL_LIST = "horizontal_list_qb";
|
|
11
|
+
|
|
9
12
|
export const isGallery = (item): boolean => item?.component_type === GALLERY;
|
|
10
13
|
|
|
14
|
+
export const isHorizontalList = (item): boolean =>
|
|
15
|
+
item?.component_type === HORIZONTAL_LIST;
|
|
16
|
+
|
|
11
17
|
export const isScreenPicker = (item): boolean =>
|
|
12
18
|
item?.component_type === SCREEN_PICKER;
|
|
13
19
|
|
|
@@ -29,4 +35,5 @@ export const isEmptyGroup = (item): boolean =>
|
|
|
29
35
|
item?.component_type === EMPTY_GROUP_COMPONENT;
|
|
30
36
|
|
|
31
37
|
export const isGroupInfo = (item): boolean =>
|
|
32
|
-
item?.component_type === GROUP_INFO
|
|
38
|
+
item?.component_type === GROUP_INFO ||
|
|
39
|
+
item?.component_type === GROUP_INFO_OLD;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ViewStyle } from "react-native";
|
|
2
2
|
|
|
3
3
|
import { useMemo } from "react";
|
|
4
|
-
import { getUILanguage } from "
|
|
5
|
-
import { utilsLogger } from "
|
|
4
|
+
import { getUILanguage } from "@applicaster/zapp-react-native-utils/appUtils/localizationsHelper";
|
|
5
|
+
import { utilsLogger } from "@applicaster/zapp-react-native-utils/logger";
|
|
6
6
|
|
|
7
7
|
export {
|
|
8
8
|
getLocale,
|
|
@@ -10,7 +10,7 @@ export {
|
|
|
10
10
|
getCountryCode,
|
|
11
11
|
getLocalizations,
|
|
12
12
|
getUILanguage,
|
|
13
|
-
} from "
|
|
13
|
+
} from "@applicaster/zapp-react-native-utils/appUtils/localizationsHelper";
|
|
14
14
|
|
|
15
15
|
const RTL_LOCALES = [
|
|
16
16
|
"ar", // Arabic
|
|
@@ -251,6 +251,19 @@ const generalContent = () => ({
|
|
|
251
251
|
key: "screen_title",
|
|
252
252
|
initial_value: null,
|
|
253
253
|
},
|
|
254
|
+
{
|
|
255
|
+
type: "text_input",
|
|
256
|
+
label: "Maximum Selection Reached - Alert Description",
|
|
257
|
+
key: "msg_maximum_selection_reached_message",
|
|
258
|
+
initial_value:
|
|
259
|
+
"You’ve reached the maximum number of items you can select.",
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
type: "text_input",
|
|
263
|
+
label: "Maximum Selection Reached - Alert Button",
|
|
264
|
+
key: "msg_maximum_selection_reached_message_ok_button",
|
|
265
|
+
initial_value: "Got it",
|
|
266
|
+
},
|
|
254
267
|
],
|
|
255
268
|
},
|
|
256
269
|
advertising: {
|
|
@@ -42,14 +42,6 @@ function getPlayerConfiguration({ platform }) {
|
|
|
42
42
|
label_tooltip:
|
|
43
43
|
"Enable if you want to have adaptive background gradient based on audio background image.",
|
|
44
44
|
},
|
|
45
|
-
{
|
|
46
|
-
key: "audio_player_background_image_query",
|
|
47
|
-
label: "Audio Player Image Query",
|
|
48
|
-
initial_value: "",
|
|
49
|
-
type: "text_input",
|
|
50
|
-
label_tooltip:
|
|
51
|
-
"Set the query params which control the size of the image e.g width, height. This will help to optimize the loading time, when magic background is enabled.",
|
|
52
|
-
},
|
|
53
45
|
{
|
|
54
46
|
key: "audio_player_background_image_default_color",
|
|
55
47
|
label: "Audio Player Background Image Default Color",
|
package/manifestUtils/keys.js
CHANGED
|
@@ -21,7 +21,30 @@ const ZAPPIFEST_FIELDS = {
|
|
|
21
21
|
},
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
const
|
|
24
|
+
const TV_PLATFORMS_FOR_FONTS = [
|
|
25
|
+
"tvOS",
|
|
26
|
+
"android",
|
|
27
|
+
"LG",
|
|
28
|
+
"samsung",
|
|
29
|
+
"roku",
|
|
30
|
+
"vizio",
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
const MOBILE_PLATFORMS = [
|
|
34
|
+
"ios",
|
|
35
|
+
"ios_for_quickbrick",
|
|
36
|
+
"android",
|
|
37
|
+
"android_for_quickbrick",
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
const TV_PLATFORMS = [
|
|
41
|
+
"android_tv_for_quickbrick",
|
|
42
|
+
"amazon_fire_tv_for_quickbrick",
|
|
43
|
+
"tvos_for_quickbrick",
|
|
44
|
+
"samsung_tv",
|
|
45
|
+
"lg_tv",
|
|
46
|
+
"vizio",
|
|
47
|
+
];
|
|
25
48
|
|
|
26
49
|
const FontPropsForTVPlatform = (platform) => ({
|
|
27
50
|
[`${R.toLower(platform)}FontFamily`]: {
|
|
@@ -92,7 +115,7 @@ const TV_FONT_KEY_DATA = {
|
|
|
92
115
|
name: "focused font color",
|
|
93
116
|
type: ZAPPIFEST_FIELDS.color_picker,
|
|
94
117
|
},
|
|
95
|
-
...R.reduce(addTVFontsForPlatform, {},
|
|
118
|
+
...R.reduce(addTVFontsForPlatform, {}, TV_PLATFORMS_FOR_FONTS),
|
|
96
119
|
textAlignment: {
|
|
97
120
|
name: "text alignment",
|
|
98
121
|
type: ZAPPIFEST_FIELDS.select,
|
|
@@ -2083,4 +2106,6 @@ module.exports = {
|
|
|
2083
2106
|
TV_CELL_BADGE_FIELDS,
|
|
2084
2107
|
progressBarFields,
|
|
2085
2108
|
secondaryImageFields,
|
|
2109
|
+
TV_PLATFORMS,
|
|
2110
|
+
MOBILE_PLATFORMS,
|
|
2086
2111
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "13.0.0-alpha.
|
|
3
|
+
"version": "13.0.0-alpha.5406200595",
|
|
4
4
|
"description": "Applicaster Zapp React Native utilities package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@applicaster/applicaster-types": "13.0.0-alpha.
|
|
30
|
+
"@applicaster/applicaster-types": "13.0.0-alpha.5406200595",
|
|
31
31
|
"buffer": "^5.2.1",
|
|
32
32
|
"camelize": "^1.0.0",
|
|
33
33
|
"dayjs": "^1.11.10",
|
|
@@ -39,22 +39,6 @@ function getPlayerConfiguration({ platform }) {
|
|
|
39
39
|
label_tooltip:
|
|
40
40
|
"Disable if you don't want the content to have a right orientation",
|
|
41
41
|
},
|
|
42
|
-
{
|
|
43
|
-
key: "magic_background",
|
|
44
|
-
label: "Enable Magic Background",
|
|
45
|
-
initial_value: false,
|
|
46
|
-
type: "switch",
|
|
47
|
-
label_tooltip:
|
|
48
|
-
"Enable if you want to have adaptive background gradient based on audio background image.",
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
key: "audio_player_background_image_query",
|
|
52
|
-
label: "Audio Player Image Query",
|
|
53
|
-
initial_value: "",
|
|
54
|
-
type: "text_input",
|
|
55
|
-
label_tooltip:
|
|
56
|
-
"Set the query params which control the size of the image e.g width, height. This will help to optimize the loading time, when magic background is enabled.",
|
|
57
|
-
},
|
|
58
42
|
{
|
|
59
43
|
key: "audio_player_background_image_default_color",
|
|
60
44
|
label: "Audio Player Background Image Default Color",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { complement, compose, isNil, map, min, prop, take, uniq } from "ramda";
|
|
2
2
|
import { useDispatch } from "react-redux";
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
import { useZappPipesFeeds } from "@applicaster/zapp-react-native-redux/hooks
|
|
4
|
+
import { useZappPipesFeeds } from "@applicaster/zapp-react-native-redux/hooks";
|
|
5
5
|
import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
|
|
6
6
|
import { isNilOrEmpty } from "../../reactUtils/helpers";
|
|
7
7
|
import { ZappPipesSearchContext } from "@applicaster/zapp-react-native-ui-components/Contexts";
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
getInflatedDataSourceUrl,
|
|
10
10
|
getSearchContext,
|
|
11
11
|
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
12
|
+
import { isGallery } from "@applicaster/zapp-react-native-utils/componentsUtils";
|
|
12
13
|
import { useScreenContext } from "../screen/useScreenContext";
|
|
13
14
|
|
|
14
15
|
type Options = {
|
|
@@ -46,9 +47,7 @@ const filterEmptyData = (data) => {
|
|
|
46
47
|
};
|
|
47
48
|
|
|
48
49
|
const getData = (rawData) =>
|
|
49
|
-
rawData.
|
|
50
|
-
? rawData.ui_components[0].data
|
|
51
|
-
: rawData.data;
|
|
50
|
+
isGallery(rawData) ? rawData.ui_components[0].data : rawData.data;
|
|
52
51
|
|
|
53
52
|
const extractData = compose(uniq, map(getData));
|
|
54
53
|
|
|
@@ -70,13 +69,12 @@ export const useBatchLoading = (
|
|
|
70
69
|
const [hasEverBeenReady, setHasEverBeenReady] = React.useState(false);
|
|
71
70
|
|
|
72
71
|
// if first component is gallery-qb, take only one component for initial load
|
|
73
|
-
const takeSize =
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
);
|
|
72
|
+
const takeSize = isGallery(componentsToRender?.[0])
|
|
73
|
+
? 1
|
|
74
|
+
: min(
|
|
75
|
+
options.initialBatchSize ?? DEFAULT_BATCH_SIZE,
|
|
76
|
+
componentsToRender.length
|
|
77
|
+
);
|
|
80
78
|
|
|
81
79
|
const takeBatchSize = React.useCallback(take(takeSize), [takeSize]);
|
|
82
80
|
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { renderHook } from "@testing-library/react-hooks";
|
|
2
|
+
|
|
3
|
+
jest.mock(
|
|
4
|
+
"@applicaster/zapp-react-native-ui-components/Components/River/useScreenConfiguration",
|
|
5
|
+
() => ({
|
|
6
|
+
useScreenConfiguration: jest.fn(),
|
|
7
|
+
})
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
const {
|
|
11
|
+
useScreenConfiguration,
|
|
12
|
+
} = require("@applicaster/zapp-react-native-ui-components/Components/River/useScreenConfiguration");
|
|
13
|
+
|
|
14
|
+
const { useScreenBackgroundColor } = require("../useScreenBackgroundColor");
|
|
15
|
+
|
|
16
|
+
describe("useScreenBackgroundColor", () => {
|
|
17
|
+
afterEach(() => {
|
|
18
|
+
jest.clearAllMocks();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("should return the background color from screen configuration", () => {
|
|
22
|
+
useScreenConfiguration.mockReturnValue({
|
|
23
|
+
backgroundColor: "#FF0000",
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Render the hook with a screen ID
|
|
27
|
+
const { result } = renderHook(() =>
|
|
28
|
+
useScreenBackgroundColor("test-screen-id")
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
expect(result.current).toBe("#FF0000");
|
|
32
|
+
|
|
33
|
+
expect(useScreenConfiguration).toHaveBeenCalledWith("test-screen-id");
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("should return 'transparent' when background color is empty", () => {
|
|
37
|
+
useScreenConfiguration.mockReturnValue({
|
|
38
|
+
backgroundColor: "",
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const { result } = renderHook(() =>
|
|
42
|
+
useScreenBackgroundColor("test-screen-id")
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
expect(result.current).toBe("transparent");
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("should return 'transparent' when background color is null", () => {
|
|
49
|
+
useScreenConfiguration.mockReturnValue({
|
|
50
|
+
backgroundColor: null,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const { result } = renderHook(() =>
|
|
54
|
+
useScreenBackgroundColor("test-screen-id")
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
expect(result.current).toBe("transparent");
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("should return 'transparent' when background color is undefined", () => {
|
|
61
|
+
useScreenConfiguration.mockReturnValue({});
|
|
62
|
+
|
|
63
|
+
const { result } = renderHook(() =>
|
|
64
|
+
useScreenBackgroundColor("test-screen-id")
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
expect(result.current).toBe("transparent");
|
|
68
|
+
});
|
|
69
|
+
});
|
|
@@ -1,23 +1,11 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
3
1
|
import { useScreenConfiguration } from "@applicaster/zapp-react-native-ui-components/Components/River/useScreenConfiguration";
|
|
4
2
|
import { ifEmptyUseFallback } from "@applicaster/zapp-react-native-utils/cellUtils";
|
|
5
3
|
|
|
4
|
+
const DEFAULT_BACKGROUND_FALLBACK = "transparent";
|
|
5
|
+
|
|
6
6
|
export const useScreenBackgroundColor = (screenId: string): string => {
|
|
7
7
|
const { backgroundColor: screenBackgroundColor } =
|
|
8
8
|
useScreenConfiguration(screenId);
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const themeBackgroundColor = React.useMemo(
|
|
13
|
-
() => theme.app_background_color,
|
|
14
|
-
[theme.app_background_color]
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
const backgroundColor = ifEmptyUseFallback(
|
|
18
|
-
screenBackgroundColor,
|
|
19
|
-
themeBackgroundColor
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
return backgroundColor;
|
|
10
|
+
return ifEmptyUseFallback(screenBackgroundColor, DEFAULT_BACKGROUND_FALLBACK);
|
|
23
11
|
};
|