@applicaster/zapp-react-native-ui-components 14.0.0-alpha.4385101226 → 14.0.0-alpha.4520122433

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 (69) hide show
  1. package/Components/BaseFocusable/index.tsx +23 -12
  2. package/Components/Cell/Cell.tsx +91 -64
  3. package/Components/Cell/CellWithFocusable.tsx +3 -0
  4. package/Components/Cell/__tests__/CellWIthFocusable.test.js +3 -2
  5. package/Components/FeedLoader/FeedLoader.tsx +7 -16
  6. package/Components/FeedLoader/FeedLoaderHOC.tsx +21 -0
  7. package/Components/FeedLoader/index.js +2 -8
  8. package/Components/Focusable/Focusable.tsx +10 -3
  9. package/Components/Focusable/FocusableTvOS.tsx +2 -2
  10. package/Components/Focusable/Touchable.tsx +5 -3
  11. package/Components/Focusable/index.android.tsx +8 -4
  12. package/Components/FocusableGroup/FocusableTvOS.tsx +1 -1
  13. package/Components/FocusableList/FocusableItem.tsx +4 -3
  14. package/Components/FocusableList/FocusableListItemWrapper.tsx +2 -1
  15. package/Components/FocusableList/hooks/useCellState.android.ts +13 -3
  16. package/Components/FocusableList/index.tsx +16 -9
  17. package/Components/FreezeWithCallback/__tests__/index.test.tsx +67 -43
  18. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +5 -6
  19. package/Components/Layout/TV/__tests__/index.test.tsx +0 -1
  20. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +6 -2
  21. package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +0 -12
  22. package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +65 -17
  23. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/Image.test.tsx +21 -3
  24. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +6 -3
  25. package/Components/MasterCell/DefaultComponents/Text/index.tsx +26 -6
  26. package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +10 -10
  27. package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +18 -18
  28. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/index.test.tsx +10 -10
  29. package/Components/MasterCell/utils/behaviorProvider.ts +82 -14
  30. package/Components/MasterCell/utils/index.ts +11 -5
  31. package/Components/OfflineHandler/__tests__/index.test.tsx +6 -13
  32. package/Components/PlayerContainer/PlayerContainer.tsx +4 -1
  33. package/Components/River/ComponentsMap/hooks/__tests__/useLoadingState.test.ts +0 -1
  34. package/Components/River/RefreshControl.tsx +11 -19
  35. package/Components/River/__tests__/river.test.js +12 -26
  36. package/Components/Screen/__tests__/Screen.test.tsx +5 -17
  37. package/Components/Screen/__tests__/navigationHandler.test.ts +133 -22
  38. package/Components/Screen/navigationHandler.ts +20 -2
  39. package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +2 -2
  40. package/Components/Tabs/TV/Tabs.android.tsx +1 -1
  41. package/Components/Tabs/Tabs.tsx +2 -3
  42. package/Components/TextInputTv/__tests__/__snapshots__/TextInputTv.test.js.snap +13 -0
  43. package/Components/TextInputTv/index.tsx +11 -0
  44. package/Components/Touchable/__tests__/touchable.test.tsx +12 -17
  45. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +3 -9
  46. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.web.tsx +294 -0
  47. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.web.tsx +93 -0
  48. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +42 -22
  49. package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +5 -5
  50. package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +9 -1
  51. package/Components/VideoModal/hooks/useDelayedPlayerDetails.ts +40 -15
  52. package/Components/VideoModal/hooks/utils/__tests__/showDetails.test.ts +2 -2
  53. package/Components/VideoModal/hooks/utils/index.ts +4 -0
  54. package/Contexts/CellFocusedStateContext/index.tsx +27 -0
  55. package/Contexts/ConfigutaionContext/__tests__/ConfigurationProvider.test.tsx +3 -3
  56. package/Contexts/ScreenContext/index.tsx +46 -6
  57. package/Decorators/ConfigurationWrapper/__tests__/withConfigurationProvider.test.tsx +3 -3
  58. package/Decorators/RiverFeedLoader/__tests__/__snapshots__/riverFeedLoader.test.tsx.snap +221 -209
  59. package/Decorators/RiverFeedLoader/__tests__/riverFeedLoader.test.tsx +14 -16
  60. package/Decorators/RiverFeedLoader/__tests__/utils.test.ts +0 -20
  61. package/Decorators/RiverFeedLoader/index.tsx +22 -4
  62. package/Decorators/RiverFeedLoader/utils/index.ts +0 -18
  63. package/Decorators/ZappPipesDataConnector/__tests__/UrlFeedResolver.test.tsx +27 -27
  64. package/Decorators/ZappPipesDataConnector/resolvers/UrlFeedResolver.tsx +35 -10
  65. package/Decorators/ZappPipesDataConnector/utils/mongoFilter.ts +738 -0
  66. package/Decorators/ZappPipesDataConnector/utils/useFilter.tsx +157 -0
  67. package/events/index.ts +3 -0
  68. package/package.json +5 -5
  69. package/Components/River/__tests__/__snapshots__/river.test.js.snap +0 -27
@@ -20,27 +20,34 @@ import { FocusableScrollView } from "../FocusableScrollView";
20
20
  const mapIndexed = R.addIndex(R.map);
21
21
 
22
22
  export type IListRenderItem<ItemT> = (
23
- info: IListRenderItemInfo<ItemT> & {
23
+ info: {
24
24
  focused: boolean;
25
25
  onLoadFinished: () => void;
26
26
  onLoadFailed: () => void;
27
- }
27
+ } & IListRenderItemInfo<ItemT>
28
28
  ) => React.ReactElement | null;
29
29
 
30
30
  export const getFocusableId = (parentId, index) =>
31
31
  `${parentId}___index:${index}`;
32
32
 
33
+ type Item = ZappEntry | ZappUIComponent | any;
34
+
33
35
  export type Props<ItemT> = FlatListProps<ItemT> & {
34
36
  id?: number | string;
35
37
  horizontal?: boolean;
36
38
  loop?: boolean;
37
39
  numColumns?: number;
38
40
  data: ZappEntry[] | ZappUIComponent[] | any[];
39
- onListElementFocus?: (any, RenderItemProps, Direction) => void;
40
- onListElementBlur?: (any, RenderItemProps, Direction) => void;
41
- onListElementPress?: (any, RenderItemProps) => void;
42
- onListElementPressOut?: (any, RenderItemProps) => void;
43
- onListElementLongPress?: (any, RenderItemProps) => void;
41
+ onListElementFocus?: (
42
+ element: FocusManager.FocusableRef,
43
+ renderItemProps: { item: Item; index: number },
44
+ options: FocusManager.Android.CallbackOptions,
45
+ context: FocusManager.FocusContext
46
+ ) => void;
47
+ onListElementBlur?: (element, renderItemProps, direction) => void;
48
+ onListElementPress?: (element, renderItemProps) => void;
49
+ onListElementPressOut?: (element, renderItemProps) => void;
50
+ onListElementLongPress?: (element, renderItemProps) => void;
44
51
  focusableItemProps?: any;
45
52
  focused?: boolean;
46
53
  initialScrollIndex?: number;
@@ -138,11 +145,11 @@ function FocusableListComponent<ItemT>(props: Props<ItemT>, ref) {
138
145
  );
139
146
 
140
147
  const onFocus = React.useCallback(
141
- (element, renderArgs, direction) => {
148
+ (element, renderArgs, options, context) => {
142
149
  const { index } = renderArgs;
143
150
 
144
151
  updateFocusedIndex?.(index);
145
- onListElementFocus?.(element, renderArgs, direction);
152
+ onListElementFocus?.(element, renderArgs, options, context);
146
153
  },
147
154
  [onListElementFocus, updateFocusedIndex]
148
155
  );
@@ -1,19 +1,18 @@
1
1
  import React, { Dispatch, useEffect, useState } from "react";
2
- import {
3
- act,
4
- create,
5
- ReactTestRenderer,
6
- ReactTestRendererJSON,
7
- } from "react-test-renderer";
2
+ import { act, render } from "@testing-library/react-native";
3
+ import { View } from "react-native";
8
4
  import { FreezeWithCallback } from "../index";
9
5
 
10
- const SimpleContent = () => <div />;
6
+ const SimpleContent = () => <View testID="simple-content" />;
11
7
 
12
8
  interface InnerProps {
13
9
  value: number;
14
10
  }
11
+
15
12
  // eslint-disable-next-line unused-imports/no-unused-vars
16
- const Inner = ({ value }: InnerProps) => <div />;
13
+ const Inner = ({ value }: InnerProps) => (
14
+ <View testID="inner-component" data-value={value} />
15
+ );
17
16
 
18
17
  interface TestSubscriber {
19
18
  renderCount: number;
@@ -51,24 +50,20 @@ const Container = ({ freeze, children }: ContainerProps) => (
51
50
  );
52
51
 
53
52
  function setupTest(initialFreeze: boolean = false) {
54
- let testRenderer: ReactTestRenderer | undefined;
55
53
  const [Subscriber, subscriberState] = createSubscriberComponent();
56
54
 
57
- act(() => {
58
- testRenderer = create(
59
- <Container freeze={initialFreeze}>
60
- <Subscriber />
61
- </Container>
62
- );
63
- });
55
+ const renderResult = render(
56
+ <Container freeze={initialFreeze}>
57
+ <Subscriber />
58
+ </Container>
59
+ );
64
60
 
65
61
  return {
66
- testRenderer,
67
- testInstance: testRenderer?.root,
62
+ renderResult,
68
63
  subscriberState,
69
64
  updateFreeze: (freeze: boolean) => {
70
65
  act(() =>
71
- testRenderer?.update(
66
+ renderResult.rerender(
72
67
  <Container freeze={freeze}>
73
68
  <Subscriber />
74
69
  </Container>
@@ -80,91 +75,120 @@ function setupTest(initialFreeze: boolean = false) {
80
75
 
81
76
  describe("FreezeWithCallback", () => {
82
77
  test("Renders stuff not frozen", () => {
83
- const testRenderer = create(
78
+ const { getByTestId } = render(
84
79
  <Container freeze={false}>
85
80
  <SimpleContent />
86
81
  </Container>
87
82
  );
88
83
 
89
- expect(testRenderer.root.findByType(SimpleContent)).toBeTruthy();
84
+ expect(getByTestId("simple-content")).toBeTruthy();
90
85
  });
91
86
 
92
87
  test("Does not render stuff when frozen", () => {
93
- const testRenderer = create(
88
+ const { queryByTestId } = render(
94
89
  <Container freeze>
95
90
  <SimpleContent />
96
91
  </Container>
97
92
  );
98
93
 
99
- expect(testRenderer.root.findAllByType(SimpleContent)).toHaveLength(0);
94
+ expect(queryByTestId("simple-content")).toBe(null);
100
95
  });
101
96
 
102
97
  test("Stuff is gone after freeze", () => {
103
- const testRenderer = create(
98
+ const { toJSON, getByTestId, rerender } = render(
104
99
  <Container freeze={false}>
105
100
  <SimpleContent />
106
101
  </Container>
107
102
  );
108
103
 
109
- expect(testRenderer.root.findByType(SimpleContent)).toBeTruthy();
104
+ expect(getByTestId("simple-content")).toBeTruthy();
110
105
 
111
106
  act(() =>
112
- testRenderer.update(
107
+ rerender(
113
108
  <Container freeze>
114
109
  <SimpleContent />
115
110
  </Container>
116
111
  )
117
112
  );
118
113
 
119
- expect(testRenderer.toJSON()).toBe(null);
114
+ expect(toJSON()).toBe(null);
120
115
  });
121
116
 
122
117
  test("Updates work when not frozen", () => {
123
- const { testInstance, subscriberState } = setupTest();
118
+ const { renderResult, subscriberState } = setupTest();
119
+
120
+ expect(
121
+ renderResult.getByTestId("inner-component").props["data-value"]
122
+ ).toEqual(0);
124
123
 
125
- expect(testInstance?.findByType(Inner).props.value).toEqual(0);
126
124
  act(() => subscriberState.subscription(1));
127
- expect(testInstance?.findByType(Inner).props.value).toEqual(1);
125
+
126
+ expect(
127
+ renderResult.getByTestId("inner-component").props["data-value"]
128
+ ).toEqual(1);
129
+
128
130
  expect(subscriberState.renderCount).toBe(2);
129
131
  });
130
132
 
131
133
  test("Updates does not propagate when frozen", () => {
132
- const { testInstance, subscriberState, updateFreeze } = setupTest();
134
+ const { renderResult, subscriberState, updateFreeze } = setupTest();
135
+
136
+ expect(
137
+ renderResult.getByTestId("inner-component").props["data-value"]
138
+ ).toEqual(0);
133
139
 
134
- expect(testInstance?.findByType(Inner).props.value).toEqual(0);
135
140
  updateFreeze(true);
136
141
  act(() => subscriberState.subscription(1));
137
- expect(testInstance?.findByType(Inner).props.value).toEqual(0);
142
+
143
+ expect(
144
+ renderResult.getByTestId("inner-component").props["data-value"]
145
+ ).toEqual(0);
146
+
138
147
  expect(subscriberState.renderCount).toBe(1);
139
148
  });
140
149
 
141
150
  test("State persists after defrost", () => {
142
- const { testInstance, subscriberState, updateFreeze, testRenderer } =
143
- setupTest();
151
+ const { renderResult, subscriberState, updateFreeze } = setupTest();
152
+
153
+ expect(
154
+ renderResult.getByTestId("inner-component").props["data-value"]
155
+ ).toEqual(0);
144
156
 
145
- expect(testInstance?.findByType(Inner).props.value).toEqual(0);
146
157
  act(() => subscriberState.subscription(1));
147
- expect(testInstance?.findByType(Inner).props.value).toEqual(1);
158
+
159
+ expect(
160
+ renderResult.getByTestId("inner-component").props["data-value"]
161
+ ).toEqual(1);
148
162
 
149
163
  updateFreeze(true);
150
- expect(testRenderer?.toJSON()).toBe(null);
164
+ expect(renderResult.toJSON()).toBe(null);
151
165
 
152
166
  updateFreeze(false);
153
- expect((testRenderer?.toJSON() as ReactTestRendererJSON).type).toBe("div");
154
- expect(testInstance?.findByType(Inner).props.value).toEqual(1);
167
+ expect(renderResult.getByTestId("inner-component")).toBeTruthy();
168
+
169
+ expect(
170
+ renderResult.getByTestId("inner-component").props["data-value"]
171
+ ).toEqual(1);
155
172
  });
156
173
 
157
174
  test("Update propagate after defrost", () => {
158
- const { testInstance, subscriberState, updateFreeze } = setupTest();
175
+ const { renderResult, subscriberState, updateFreeze } = setupTest();
159
176
 
160
177
  updateFreeze(true);
161
178
  act(() => subscriberState.subscription(1));
162
179
  act(() => subscriberState.subscription(2));
163
180
  act(() => subscriberState.subscription(3));
164
- expect(testInstance?.findByType(Inner).props.value).toEqual(0);
181
+
182
+ expect(
183
+ renderResult.getByTestId("inner-component").props["data-value"]
184
+ ).toEqual(0);
165
185
 
166
186
  updateFreeze(false);
167
- expect(testInstance?.findByType(Inner).props.value).toEqual(3);
187
+
188
+ expect(
189
+ renderResult.getByTestId("inner-component").props["data-value"]
190
+ ).toEqual(3);
191
+
168
192
  expect(subscriberState.renderCount).toBe(2);
169
193
  });
170
194
  });
@@ -3,8 +3,6 @@ import { all, equals, path, prop, isEmpty, pluck, values } from "ramda";
3
3
  import { useEffect, useMemo } from "react";
4
4
 
5
5
  import {
6
- ZappPipes,
7
- useAppDispatch,
8
6
  useLayoutPresets,
9
7
  useZappPipesFeed,
10
8
  } from "@applicaster/zapp-react-native-redux";
@@ -25,6 +23,7 @@ import {
25
23
  } from "@applicaster/zapp-react-native-utils/reactHooks/feed/useInflatedUrl";
26
24
 
27
25
  import { produce } from "immer";
26
+ import { useLoadPipesDataDispatch } from "@applicaster/zapp-react-native-utils/reactHooks";
28
27
  // types reference
29
28
 
30
29
  declare interface CurationEntry {
@@ -126,8 +125,6 @@ export const getFinalComponents = (
126
125
  export const useCurationAPI = (
127
126
  components: Array<ZappUIComponent>
128
127
  ): ZappUIComponent[] => {
129
- const dispatch = useAppDispatch();
130
-
131
128
  const smartComponents = useMemo(
132
129
  () => components?.filter?.(isSmartComponent) ?? [],
133
130
  [components]
@@ -163,17 +160,19 @@ export const useCurationAPI = (
163
160
 
164
161
  const urls = useMemo<string[]>(() => Object.values(urlsMap), [urlsMap]);
165
162
 
163
+ const loadPipesDataDispatcher = useLoadPipesDataDispatch();
164
+
166
165
  useEffect(() => {
167
166
  urls.forEach((url, index) => {
168
167
  if (url) {
169
- dispatch(ZappPipes.loadPipesData(url, { clearCache: false }));
168
+ loadPipesDataDispatcher(url, { clearCache: false });
170
169
  } else {
171
170
  logger.log_error("Curation url is empty", {
172
171
  componentId: smartComponents?.[index]?.id,
173
172
  });
174
173
  }
175
174
  });
176
- }, [urls]);
175
+ }, [urls, loadPipesDataDispatcher]);
177
176
 
178
177
  const feeds = useZappPipesFeed(urls);
179
178
  const layoutPresets = useLayoutPresets();
@@ -7,7 +7,6 @@ import { NavigationContext } from "@applicaster/zapp-react-native-ui-components/
7
7
  import configureStore from "redux-mock-store";
8
8
  import Layout from "../index.web";
9
9
 
10
- // mock useTheme to provide app_background_color
11
10
  jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
12
11
  useTheme: () => ({
13
12
  app_background_color: "#000000",
@@ -23,6 +23,7 @@ type Props = {
23
23
  style: ViewStyle;
24
24
  testID?: string;
25
25
  accessibilityLabel?: string;
26
+ accessibilityHint?: string;
26
27
  cellUUID?: string;
27
28
  extraProps?: Record<string, any>;
28
29
  };
@@ -48,7 +49,9 @@ function getAssetValue(asset, flavour, fallbackAsset = null) {
48
49
  return asset.src || fallbackAsset;
49
50
  }
50
51
 
51
- export function ActionButton(props: Props) {
52
+ export const ActionButton = React.memo(function ActionButtonComponent(
53
+ props: Props
54
+ ) {
52
55
  const { item, action, asset, flavour = "flavour_1", cellUUID } = props;
53
56
  const actionContext = useActions(action?.identifier);
54
57
 
@@ -98,6 +101,7 @@ export function ActionButton(props: Props) {
98
101
  onPress={onPress}
99
102
  testID={props?.testID || `${item?.id}`}
100
103
  accessibilityLabel={props?.accessibilityLabel || `${item?.id}`}
104
+ accessibilityHint={props?.accessibilityHint}
101
105
  accessible={!!(props?.testID || props?.accessibilityLabel)}
102
106
  style={props?.style}
103
107
  >
@@ -118,4 +122,4 @@ export function ActionButton(props: Props) {
118
122
  )}
119
123
  </TouchableOpacity>
120
124
  );
121
- }
125
+ });
@@ -4,7 +4,6 @@ import { Focusable } from "@applicaster/zapp-react-native-ui-components/Componen
4
4
  import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
5
5
  import { getXray } from "@applicaster/zapp-react-native-utils/logger";
6
6
  import { toBooleanWithDefaultFalse } from "@applicaster/zapp-react-native-utils/booleanUtils";
7
- import { useAccessibilityManager } from "@applicaster/zapp-react-native-utils/appUtils/accessibilityManager/hooks";
8
7
 
9
8
  const { Logger } = getXray();
10
9
 
@@ -44,11 +43,6 @@ export function FocusableView({ style, children, item, ...otherProps }: Props) {
44
43
 
45
44
  const actionContext = useActions(pluginIdentifier);
46
45
 
47
- const accessibilityManager = useAccessibilityManager({});
48
-
49
- const { ttsLabel = "" } =
50
- actionContext?.initialEntryState(item)?.getAccessibility?.(item) || {};
51
-
52
46
  const onPress = (event) => {
53
47
  event?.preventDefault?.();
54
48
 
@@ -71,12 +65,6 @@ export function FocusableView({ style, children, item, ...otherProps }: Props) {
71
65
  focusedButtonId,
72
66
  mouse: focusable.mouse,
73
67
  });
74
-
75
- if (ttsLabel) {
76
- accessibilityManager.readText({
77
- text: ttsLabel,
78
- });
79
- }
80
68
  };
81
69
 
82
70
  const handleBlur = (_focusable, _direction) => {
@@ -28,17 +28,10 @@ interface Props {
28
28
  onAsyncRender: () => void;
29
29
  }
30
30
 
31
- const SecondaryImageComponent = (props: Props) => {
32
- const {
33
- uri,
34
- style,
35
- displayMode,
36
- imageSizing,
37
- fitPosition,
38
- fixedHeight,
39
- fixedWidth,
40
- onAsyncRender,
41
- } = props;
31
+ /** Secondary Image Dynamic does not render until the image is loaded */
32
+ const SecondaryImageDynamic = (props: Props) => {
33
+ const { uri, style, displayMode, imageSizing, fitPosition, onAsyncRender } =
34
+ props;
42
35
 
43
36
  const imageDimension = useGetImageDimensions(
44
37
  uri,
@@ -46,13 +39,9 @@ const SecondaryImageComponent = (props: Props) => {
46
39
  isImageSizingFit(imageSizing) ? undefined : (style.height as number)
47
40
  );
48
41
 
49
- const containerHeight = isDisplayModeFixed(displayMode)
50
- ? fixedHeight
51
- : imageDimension?.height;
42
+ const containerHeight = imageDimension?.height;
52
43
 
53
- const containerWidth = isDisplayModeFixed(displayMode)
54
- ? fixedWidth
55
- : style?.width;
44
+ const containerWidth = style?.width;
56
45
 
57
46
  if (isNil(imageDimension?.aspectRatio)) {
58
47
  return null;
@@ -80,4 +69,63 @@ const SecondaryImageComponent = (props: Props) => {
80
69
  );
81
70
  };
82
71
 
72
+ /** Secondary Image Fixed does not render the image until the image is loaded, but keep container rendered */
73
+ const SecondaryImageFixed = (props: Props) => {
74
+ const {
75
+ uri,
76
+ style,
77
+ displayMode,
78
+ imageSizing,
79
+ fitPosition,
80
+ fixedHeight,
81
+ fixedWidth,
82
+ onAsyncRender,
83
+ } = props;
84
+
85
+ const imageDimension = useGetImageDimensions(
86
+ uri,
87
+ style.width as number,
88
+ isImageSizingFit(imageSizing) ? undefined : (style.height as number)
89
+ );
90
+
91
+ return (
92
+ <View style={style} onLayout={onAsyncRender}>
93
+ {isNil(imageDimension?.aspectRatio) ? null : (
94
+ <Image
95
+ {...props}
96
+ source={{ uri }}
97
+ style={{
98
+ ...getStyle({
99
+ imageSizing,
100
+ fitPosition,
101
+ displayMode,
102
+ imageDimension,
103
+ containerHeight: fixedHeight,
104
+ containerWidth: fixedWidth,
105
+ }),
106
+ borderRadius: style.borderRadius,
107
+ aspectRatio: imageDimension.aspectRatio,
108
+ }}
109
+ />
110
+ )}
111
+ </View>
112
+ );
113
+ };
114
+
115
+ const SecondaryImageComponent = (props: Props) => {
116
+ const { uri, displayMode } = props;
117
+
118
+ if (!uri) {
119
+ return null;
120
+ }
121
+
122
+ const isFixed = isDisplayModeFixed(displayMode);
123
+
124
+ return isFixed ? (
125
+ <SecondaryImageFixed {...props} />
126
+ ) : (
127
+ <SecondaryImageDynamic {...props} />
128
+ );
129
+ };
130
+
83
131
  export const SecondaryImage = withAsyncRenderHOC(SecondaryImageComponent);
@@ -4,9 +4,26 @@ import { render } from "@testing-library/react-native";
4
4
  import { SecondaryImage } from "../Image";
5
5
 
6
6
  describe("SecondaryImage - Image", () => {
7
- it("SecondaryImage should not render if no aspect ratio", async () => {
7
+ it("SecondaryImage should not render if no uri", async () => {
8
8
  const wrapper = await render(
9
- <SecondaryImage uri="" style={{ width: 100 }} />
9
+ <SecondaryImage
10
+ displayMode="dynamic"
11
+ uri={undefined}
12
+ style={{ width: 100 }}
13
+ />
14
+ );
15
+
16
+ expect(wrapper.toJSON()).toEqual(null);
17
+ expect(wrapper.toJSON()).toMatchSnapshot();
18
+ });
19
+
20
+ it("SecondaryImage should not render if no aspect ratio (dynamic)", async () => {
21
+ const wrapper = await render(
22
+ <SecondaryImage
23
+ displayMode="dynamic"
24
+ uri="someurl"
25
+ style={{ width: 100 }}
26
+ />
10
27
  );
11
28
 
12
29
  expect(wrapper.toJSON()).toEqual(null);
@@ -16,7 +33,8 @@ describe("SecondaryImage - Image", () => {
16
33
  it("SecondaryImage should render if known dimensions", async () => {
17
34
  const wrapper = await render(
18
35
  <SecondaryImage
19
- uri=""
36
+ uri="someUrl"
37
+ displayMode="dynamic"
20
38
  style={{ width: 100, height: 100, borderRadius: 10 }}
21
39
  />
22
40
  );
@@ -1,6 +1,8 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`SecondaryImage - Image SecondaryImage should not render if no aspect ratio 1`] = `null`;
3
+ exports[`SecondaryImage - Image SecondaryImage should not render if no aspect ratio (dynamic) 1`] = `null`;
4
+
5
+ exports[`SecondaryImage - Image SecondaryImage should not render if no uri 1`] = `null`;
4
6
 
5
7
  exports[`SecondaryImage - Image SecondaryImage should render if known dimensions 1`] = `
6
8
  <View
@@ -14,10 +16,11 @@ exports[`SecondaryImage - Image SecondaryImage should render if known dimensions
14
16
  }
15
17
  >
16
18
  <Image
19
+ displayMode="dynamic"
17
20
  onAsyncRender={[Function]}
18
21
  source={
19
22
  {
20
- "uri": "",
23
+ "uri": "someUrl",
21
24
  }
22
25
  }
23
26
  style={
@@ -28,7 +31,7 @@ exports[`SecondaryImage - Image SecondaryImage should render if known dimensions
28
31
  "width": 100,
29
32
  }
30
33
  }
31
- uri=""
34
+ uri="someUrl"
32
35
  />
33
36
  </View>
34
37
  `;
@@ -11,6 +11,8 @@ import { withScaledLineHeight } from "./utils";
11
11
  import { toNumber } from "@applicaster/zapp-react-native-utils/numberUtils";
12
12
  import { MeasurementPortalContext } from "../../../MeasurmentsPortal";
13
13
  import { isNilOrEmpty } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
14
+ import { CellFocusedStateContext } from "@applicaster/zapp-react-native-ui-components/Contexts/CellFocusedStateContext";
15
+ import { useAccessibilityManager } from "@applicaster/zapp-react-native-utils/appUtils/accessibilityManager/hooks";
14
16
 
15
17
  type Props = {
16
18
  style: any;
@@ -35,10 +37,9 @@ const _Text = ({
35
37
  }: Props) => {
36
38
  const _label = useTextLabel({ label, entry });
37
39
  const isMeasurement = React.useContext(MeasurementPortalContext);
40
+ const cellFocused = React.useContext(CellFocusedStateContext);
38
41
 
39
- if (isNilOrEmpty(_label)) {
40
- return null;
41
- }
42
+ const accessibilityManager = useAccessibilityManager({});
42
43
 
43
44
  // set maximum possible height for the text in case of measurement
44
45
  const height =
@@ -46,6 +47,27 @@ const _Text = ({
46
47
  ? toNumber(otherProps.numberOfLines) * toNumber(style.lineHeight)
47
48
  : undefined;
48
49
 
50
+ const textLabel = dateTransformEnabled
51
+ ? dateFormat(dateTransform, label)
52
+ : textTransform(transformText, _label);
53
+
54
+ React.useLayoutEffect(() => {
55
+ // For FocusableCells with action buttons
56
+ if (otherProps.state) {
57
+ if (otherProps.state === "focused" && cellFocused === true) {
58
+ accessibilityManager.addHeading(textLabel);
59
+ }
60
+ } else {
61
+ if (cellFocused === true) {
62
+ accessibilityManager.addHeading(textLabel);
63
+ }
64
+ }
65
+ }, [cellFocused, otherProps.state, textLabel]);
66
+
67
+ if (isNilOrEmpty(_label)) {
68
+ return null;
69
+ }
70
+
49
71
  return (
50
72
  <Text
51
73
  style={[
@@ -55,9 +77,7 @@ const _Text = ({
55
77
  allowFontScaling={false}
56
78
  {...withoutLabel(otherProps)}
57
79
  >
58
- {dateTransformEnabled
59
- ? dateFormat(dateTransform, label)
60
- : textTransform(transformText, _label)}
80
+ {textLabel}
61
81
  </Text>
62
82
  );
63
83
  };
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import TestRenderer from "react-test-renderer";
2
+ import { render } from "@testing-library/react-native";
3
3
  import { Image } from "react-native";
4
4
 
5
5
  jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
@@ -10,35 +10,35 @@ const CustomImage = require("../Image").default;
10
10
 
11
11
  describe("image with no source", () => {
12
12
  it("Uses provided placeholder image string", () => {
13
- const testRenderer = TestRenderer.create(
13
+ const { UNSAFE_getByType } = render(
14
14
  <CustomImage placeholderImage={"foo"} />
15
15
  );
16
16
 
17
- const testInstance = testRenderer.root;
17
+ const imageComponent = UNSAFE_getByType(Image);
18
18
 
19
- expect(testInstance.findByType(Image).props.source).toEqual({
19
+ expect(imageComponent.props.source).toEqual({
20
20
  uri: "foo",
21
21
  });
22
22
  });
23
23
 
24
24
  it("Uses provided placeholder image object", () => {
25
- const testRenderer = TestRenderer.create(
25
+ const { UNSAFE_getByType } = render(
26
26
  <CustomImage placeholderImage={"foo"} />
27
27
  );
28
28
 
29
- const testInstance = testRenderer.root;
29
+ const imageComponent = UNSAFE_getByType(Image);
30
30
 
31
- expect(testInstance.findByType(Image).props.source).toEqual({
31
+ expect(imageComponent.props.source).toEqual({
32
32
  uri: "foo",
33
33
  });
34
34
  });
35
35
 
36
36
  it("Returns empty string if no image or placeholder defined", () => {
37
- const testRenderer = TestRenderer.create(
37
+ const { UNSAFE_getByType } = render(
38
38
  <CustomImage placeholderImage={null} />
39
39
  );
40
40
 
41
- const testInstance = testRenderer.root;
42
- expect(testInstance.findByType(Image).props.source).toBeUndefined();
41
+ const imageComponent = UNSAFE_getByType(Image);
42
+ expect(imageComponent.props.source).toBeUndefined();
43
43
  });
44
44
  });