@applicaster/zapp-react-native-utils 12.0.0-rc.10 → 12.0.0-rc.101
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 +16 -8
- package/analyticsUtils/AnalyticsEvents/index.ts +13 -0
- package/analyticsUtils/AnalyticsEvents/searchEvents.ts +21 -0
- package/analyticsUtils/AnalyticsEvents/sendShareEvent.ts +21 -0
- package/analyticsUtils/__tests__/analyticsManager.test.js +75 -73
- package/analyticsUtils/analyticsPlugins.ts +25 -0
- package/analyticsUtils/events.ts +12 -0
- package/analyticsUtils/helpers/hooks.ts +1 -1
- package/analyticsUtils/index.tsx +12 -0
- package/appUtils/HooksManager/index.js +3 -1
- package/appUtils/accessibilityManager/const.ts +50 -0
- package/appUtils/accessibilityManager/hooks.ts +40 -0
- package/appUtils/accessibilityManager/index.ts +155 -0
- package/appUtils/accessibilityManager/logger.ts +5 -0
- package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +2 -3
- package/appUtils/focusManager/__tests__/focusManager.test.js +4 -24
- package/appUtils/focusManager/__tests__/index.test.ts +2 -3
- package/appUtils/focusManager/index.ts +76 -57
- package/appUtils/focusManager/treeDataStructure/Utils/index.js +75 -35
- package/appUtils/focusManager/utils/index.ts +100 -0
- package/appUtils/focusManagerAux/index.ts +76 -0
- package/appUtils/focusManagerAux/utils/index.ts +100 -0
- package/appUtils/index.js +2 -0
- package/appUtils/keyCodes/__tests__/__snapshots__/keyCodes.test.js.snap +1 -1
- package/appUtils/keyCodes/__tests__/keyCodes.test.js +80 -85
- package/appUtils/keyCodes/keys.web.js +9 -0
- package/appUtils/keyCodes/keysByPlatform.js +11 -1
- package/appUtils/platform/const.ts +25 -0
- package/appUtils/platform/index.ts +3 -0
- package/appUtils/platform/platformUtils.ts +185 -0
- package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +53 -0
- package/appUtils/playerManager/conts.ts +6 -0
- package/appUtils/playerManager/index.ts +11 -5
- package/appUtils/playerManager/nativePlayerManager.ts +12 -0
- package/appUtils/playerManager/player.ts +56 -7
- package/appUtils/playerManager/playerFactory.ts +15 -1
- package/appUtils/playerManager/playerNative.ts +40 -14
- package/appUtils/playerManager/usePlayerControllerSetup.tsx +7 -1
- package/appUtils/playerManager/usePlayerState.tsx +13 -1
- package/appUtils/playerManager/usePlayerTitleSummaryOverlay.tsx +50 -0
- package/arrayUtils/__tests__/isFilledArray.test.ts +63 -0
- package/arrayUtils/index.ts +5 -0
- package/booleanUtils/index.ts +4 -4
- package/cellUtils/__tests__/cellUtils.test.ts +48 -0
- package/cellUtils/__tests__/fixtures.ts +13 -0
- package/cellUtils/index.ts +45 -7
- package/dateUtils/index.ts +11 -0
- package/focusManager/index.ts +1 -1
- package/functionUtils/__tests__/__snapshots__/functionUtils.test.js.snap +2 -2
- package/functionUtils/__tests__/functionUtils.test.js +244 -248
- package/headersUtils/index.ts +1 -0
- package/index.d.ts +15 -0
- package/inflatedUrlUtils/index.ts +4 -4
- package/keyboardState/index.ts +0 -0
- package/localizationUtils/__tests__/localizationUtils.test.ts +78 -55
- package/localizationUtils/index.ts +13 -19
- package/logger/index.ts +1 -1
- package/manifestUtils/defaultManifestConfigurations/generalContent.js +6 -0
- package/manifestUtils/defaultManifestConfigurations/player.js +10 -1
- package/manifestUtils/index.js +5 -1
- package/manifestUtils/secondaryImage/index.js +18 -15
- package/modalState/index.ts +57 -0
- package/navigationUtils/index.ts +104 -7
- package/numberUtils/__tests__/isLikeNumber.test.ts +18 -0
- package/numberUtils/__tests__/toNumber.test.ts +2 -2
- package/numberUtils/index.ts +9 -18
- package/package.json +3 -2
- package/playerUtils/configurationGenerator.ts +11 -1
- package/pluginUtils/index.ts +20 -7
- package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +2 -0
- package/reactHooks/autoscrolling/__tests__/{useTrackedView.test.ts → useTrackedView.test.tsx} +18 -1
- package/reactHooks/cell-click/__tests__/index.test.js +16 -3
- package/reactHooks/cell-click/index.ts +14 -14
- package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +30 -70
- package/reactHooks/feed/__tests__/useFeedRefresh.test.tsx +6 -2
- package/reactHooks/feed/__tests__/useInflatedUrl.test.ts +18 -3
- package/reactHooks/feed/useBuildPipesUrl.ts +7 -10
- package/reactHooks/feed/useFeedRefresh.tsx +9 -7
- package/reactHooks/feed/useInflatedUrl.ts +44 -15
- package/reactHooks/flatList/useLoadNextPageIfNeeded.ts +16 -9
- package/reactHooks/index.ts +2 -0
- package/reactHooks/layout/__tests__/{index.test.js → index.test.tsx} +66 -59
- package/reactHooks/layout/getDeviceInfo/index.ts +4 -2
- package/reactHooks/layout/types/index.ts +2 -0
- package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.native.test.js +11 -16
- package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.test.js +12 -14
- package/reactHooks/layout/useDimensions/useDimensions.ts +13 -7
- package/reactHooks/navigation/__mocks__/index.ts +15 -0
- package/reactHooks/navigation/__mocks__/useNavigation.ts +7 -0
- package/reactHooks/navigation/__tests__/index.test.tsx +240 -81
- package/reactHooks/navigation/index.ts +239 -80
- package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +3 -1
- package/reactHooks/screen/__mocks__/useScreenContext.ts +3 -1
- package/reactHooks/screen/__tests__/useCurrentScreenData.test.tsx +21 -23
- package/reactHooks/screen/index.ts +4 -0
- package/reactHooks/screen/useScreenBackgroundColor.ts +23 -0
- package/reactHooks/screen/useScreenContext.ts +4 -4
- package/reactHooks/screen/useScreenData.ts +1 -1
- package/reactHooks/screen/useTargetScreenData.ts +7 -0
- package/reactHooks/state/useRivers.ts +3 -1
- package/reactHooks/useListenEventBusEvent.ts +1 -4
- package/reactHooks/videoModal/hooks/useVideoModalScreenData.tsx +10 -9
- package/reactUtils/index.ts +105 -0
- package/riverComponetsMeasurementProvider/index.tsx +2 -2
- package/stringUtils/index.ts +5 -0
- package/testUtils/getByTestId.ts +14 -0
- package/testUtils/index.tsx +38 -23
- package/types.ts +4 -0
- package/appUtils/focusManager/FocusableEvents.ts +0 -8
- package/appUtils/focusManager/treeDataStructure/Utils/__tests__/Utils_android.test.js +0 -1094
- package/appUtils/focusManager/treeDataStructure/Utils/index.android.js +0 -261
package/cellUtils/index.ts
CHANGED
|
@@ -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";
|
|
@@ -30,13 +31,12 @@ export const getKeyForLabel = (dataKey, customKey) => {
|
|
|
30
31
|
* This method will return true if the argument passed to it is either empty or nil
|
|
31
32
|
* The method prevents zero from being evaluated as falsey in an || condition
|
|
32
33
|
* i.e. - NaN, null, {}, "", [], should all return true
|
|
33
|
-
* @param {*} argument - argument passed to it could be any type
|
|
34
34
|
* @returns {Boolean} returns true if empty or nil
|
|
35
|
+
* @param value
|
|
35
36
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
);
|
|
37
|
+
|
|
38
|
+
export const isEmptyOrNil = (value: any): boolean =>
|
|
39
|
+
Number.isNaN(value) || value == null || R.isEmpty(value);
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* This method is used to find the appropriate label for any given text field.
|
|
@@ -181,8 +181,8 @@ export const getHeight = (width, aspectRatio) => {
|
|
|
181
181
|
* @returns {string} duration
|
|
182
182
|
*/
|
|
183
183
|
|
|
184
|
-
export const getDurationInMinutes = (seconds
|
|
185
|
-
if (seconds
|
|
184
|
+
export const getDurationInMinutes = (seconds?: number): string => {
|
|
185
|
+
if (!seconds) return "00:00";
|
|
186
186
|
const minutes = Math.floor(Number(seconds) / 60);
|
|
187
187
|
const secondsReminder = Math.floor(Number(seconds)) % 60;
|
|
188
188
|
const pad = (num: number): string => `${num < 10 ? "0" : ""}${num}`;
|
|
@@ -319,6 +319,7 @@ export const ifElseFocusedSelected = (
|
|
|
319
319
|
* @param {Object} stylesObj styles object with keys from zapp { button_icon_width: "10" }
|
|
320
320
|
* @returns {*} value, returns any type that can be used as styles
|
|
321
321
|
*/
|
|
322
|
+
|
|
322
323
|
export const getValue = (stylesObj) => (key) => {
|
|
323
324
|
return R.propOr(null, key, stylesObj);
|
|
324
325
|
};
|
|
@@ -343,6 +344,19 @@ export const ifElseFocused = R.curry(
|
|
|
343
344
|
state === "focused" ? focusedValue : defaultValue
|
|
344
345
|
);
|
|
345
346
|
|
|
347
|
+
export const ifElseSelected = R.curry(
|
|
348
|
+
(state: string, selectedValue, defaultValue) => {
|
|
349
|
+
switch (state) {
|
|
350
|
+
case "selected":
|
|
351
|
+
return selectedValue;
|
|
352
|
+
case "focused_selected":
|
|
353
|
+
return selectedValue;
|
|
354
|
+
default:
|
|
355
|
+
return defaultValue;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
);
|
|
359
|
+
|
|
346
360
|
/**
|
|
347
361
|
* Map textAlign values to their corresponding alignSelf values
|
|
348
362
|
* This is so that we could use the same field for both properties
|
|
@@ -430,3 +444,27 @@ export const toResizeMode = (
|
|
|
430
444
|
resizeMode: "contain",
|
|
431
445
|
};
|
|
432
446
|
};
|
|
447
|
+
|
|
448
|
+
type GetColorFromData = {
|
|
449
|
+
data: Record<string, any>;
|
|
450
|
+
valueFromLayout: string;
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
export const getColorFromData = ({
|
|
454
|
+
data,
|
|
455
|
+
valueFromLayout,
|
|
456
|
+
}: GetColorFromData): string => {
|
|
457
|
+
// Temporary hack to fix color validation when alpha is floating point number
|
|
458
|
+
// https://github.com/dreamyguy/validate-color/issues/44
|
|
459
|
+
if (validateColor(valueFromLayout.replace(".00", ""))) {
|
|
460
|
+
return valueFromLayout;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
const pathValue = R.path(valueFromLayout.split("."), data);
|
|
464
|
+
|
|
465
|
+
if (pathValue && validateColor(pathValue)) {
|
|
466
|
+
return pathValue;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
return valueFromLayout;
|
|
470
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import utc from "dayjs/plugin/utc";
|
|
3
|
+
import timezone from "dayjs/plugin/timezone";
|
|
4
|
+
import isoWeek from "dayjs/plugin/isoWeek";
|
|
5
|
+
|
|
6
|
+
// Extend dayjs with plugins
|
|
7
|
+
dayjs.extend(utc);
|
|
8
|
+
dayjs.extend(timezone);
|
|
9
|
+
dayjs.extend(isoWeek);
|
|
10
|
+
|
|
11
|
+
export { dayjs };
|
package/focusManager/index.ts
CHANGED
|
@@ -86,7 +86,7 @@ export const isFocusable = (component: ZappEntry | ZappUIComponent | any) =>
|
|
|
86
86
|
|
|
87
87
|
type Props = {
|
|
88
88
|
component: ZappUIComponent;
|
|
89
|
-
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 {},
|