@applicaster/zapp-react-native-ui-components 17.0.0-rc.2 → 17.0.0-rc.4

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 (43) hide show
  1. package/Components/AudioPlayer/index.web.tsx +10 -0
  2. package/Components/Cell/PlatformCellComponent.ts +9 -0
  3. package/Components/Cell/PlatformCellComponent.web.ts +3 -0
  4. package/Components/Cell/index.js +2 -9
  5. package/Components/CellRendererResolver/index.ts +20 -1
  6. package/Components/ComponentResolver/ComponentResolver.ts +4 -0
  7. package/Components/Focusable/index.web.tsx +3 -0
  8. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +29 -4
  9. package/Components/MasterCell/DefaultComponents/ButtonContainerView/index.android.tv.tsx +7 -4
  10. package/Components/MasterCell/DefaultComponents/ButtonContainerView/types.ts +1 -0
  11. package/Components/MasterCell/DefaultComponents/FocusableView/index.android.tsx +10 -4
  12. package/Components/MasterCell/DefaultComponents/Image/index.web.ts +7 -0
  13. package/Components/MasterCell/DefaultComponents/LiveImage/__tests__/prepareEntry.test.ts +30 -0
  14. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +22 -4
  15. package/Components/MasterCell/DefaultComponents/__tests__/ActionButton.missingPlugin.test.tsx +66 -0
  16. package/Components/MasterCell/__tests__/masterCell.test.js +56 -0
  17. package/Components/MasterCell/index.tsx +17 -2
  18. package/Components/MasterCell/utils/__tests__/getFocusableElementId.test.ts +38 -0
  19. package/Components/MasterCell/utils/index.ts +39 -1
  20. package/Components/ModalComponent/Button/index.tsx +3 -1
  21. package/Components/ModalComponent/presets/__tests__/getCell.test.ts +29 -2
  22. package/Components/ModalComponent/presets/index.ts +2 -3
  23. package/Components/River/ComponentsMap/index.web.tsx +3 -0
  24. package/Components/River/RiverItem.tsx +4 -0
  25. package/Components/River/TV/River.tsx +7 -1
  26. package/Components/ScreenResolver/index.tsx +4 -1
  27. package/Components/Tabs/TV/index.web.tsx +5 -0
  28. package/Components/TopCutoffOverlay/__tests__/TopCutoffOverlay.test.tsx +56 -10
  29. package/Components/TopCutoffOverlay/index.tsx +41 -10
  30. package/Components/VideoLive/__tests__/LiveImageManager.test.ts +30 -0
  31. package/Components/VideoModal/PlayerDetails.tsx +27 -2
  32. package/Components/VideoModal/PlayerWrapper.tsx +5 -1
  33. package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +84 -0
  34. package/Components/VideoModal/__tests__/playerWrapperStyle.test.ts +206 -1
  35. package/Components/VideoModal/__tests__/playerWrapperUtils.test.ts +110 -1
  36. package/Components/VideoModal/playerWrapperStyle.ts +41 -20
  37. package/Components/VideoModal/playerWrapperUtils.ts +134 -0
  38. package/Components/__tests__/webVariants.test.js +73 -0
  39. package/Components/default-cell-renderer/containerStyles/index.web.ts +6 -0
  40. package/Components/default-cell-renderer/viewTrees/index.web.ts +10 -0
  41. package/Decorators/RiverResolver/__tests__/riverResolver.missingRiver.test.tsx +52 -0
  42. package/Decorators/RiverResolver/index.tsx +25 -0
  43. package/package.json +5 -5
@@ -0,0 +1,10 @@
1
+ import * as React from "react";
2
+
3
+ import { AudioPlayerTV } from "./tv";
4
+
5
+ import { Props } from "./types";
6
+
7
+ // isTV() is true on every web platform, so web builds always render the TV audio player and leave the mobile one out.
8
+ export function AudioPlayer(props: Props) {
9
+ return <AudioPlayerTV {...props} />;
10
+ }
@@ -0,0 +1,9 @@
1
+ import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
2
+
3
+ import { CellComponent } from "./Cell";
4
+ import { TvOSCellComponent } from "./TvOSCellComponent";
5
+
6
+ export const PlatformCellComponent = platformSelect({
7
+ tvos: TvOSCellComponent,
8
+ default: CellComponent,
9
+ });
@@ -0,0 +1,3 @@
1
+ // Web builds always select the default cell, so the tvOS one stays out of web
2
+ // bundles.
3
+ export { CellComponent as PlatformCellComponent } from "./Cell";
@@ -1,7 +1,6 @@
1
1
  import * as R from "ramda";
2
2
 
3
3
  import { connectToStore } from "@applicaster/zapp-react-native-redux/utils/connectToStore";
4
- import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
5
4
 
6
5
  import {
7
6
  HorizontalScrollContext,
@@ -9,8 +8,7 @@ import {
9
8
  ScreenScrollingContext,
10
9
  } from "../../Contexts";
11
10
 
12
- import { CellComponent } from "./Cell";
13
- import { TvOSCellComponent } from "./TvOSCellComponent";
11
+ import { PlatformCellComponent } from "./PlatformCellComponent";
14
12
  import { withConsumer } from "../../Contexts/HeaderOffsetContext";
15
13
 
16
14
  import { ScreenLayoutContextConsumer } from "../../Contexts/ScreenLayoutContext";
@@ -23,11 +21,6 @@ export const ScrollInterceptorContext = createContext(
23
21
  (_) => _
24
22
  );
25
23
 
26
- const Component = platformSelect({
27
- tvos: TvOSCellComponent,
28
- default: CellComponent,
29
- });
30
-
31
24
  export const Cell = R.compose(
32
25
  connectToStore(R.pick(["remoteConfigurations", "appData"])),
33
26
  ScrollInterceptorContext.withConsumer,
@@ -37,4 +30,4 @@ export const Cell = R.compose(
37
30
  withConsumer,
38
31
  ScreenLayoutContextConsumer,
39
32
  withComponentsMapOffsetContextConsumer
40
- )(Component);
33
+ )(PlatformCellComponent);
@@ -82,9 +82,28 @@ export function CellRendererResolver({
82
82
  const cellRendererPlugin = getRendererPlugin(component, plugins, cellStyles);
83
83
 
84
84
  if (!cellRendererPlugin && !isGroup(component)) {
85
+ const cellStyleId = component?.styles?.cell_plugin_configuration_id;
86
+
85
87
  logger.warning({
86
88
  message: `Could not resolve cell builder plugin: ${component?.component_type}`,
87
- data: { component },
89
+ data: {
90
+ // For X-Ray diagnostics: keep when the message is reworded. Only for a component that
91
+ // takes a cell style (the key is in its styles) and once cell styles are loaded.
92
+ ...(component?.id &&
93
+ cellStyles &&
94
+ "cell_plugin_configuration_id" in (component.styles ?? {}) && {
95
+ diagnostic: {
96
+ code: "cell-style",
97
+ case: !cellStyleId
98
+ ? "not_chosen"
99
+ : !cellStyles[cellStyleId]
100
+ ? "deleted"
101
+ : "plugin_missing",
102
+ },
103
+ plugin_id: cellStyles[cellStyleId]?.plugin_identifier,
104
+ }),
105
+ component,
106
+ },
88
107
  });
89
108
  }
90
109
 
@@ -59,6 +59,10 @@ export function ComponentResolver({
59
59
  if (!Component) {
60
60
  logger.warning({
61
61
  message: `Component ${component_type} cannot be found - it is skipped from rendering`,
62
+ data: {
63
+ diagnostic: { code: "component-plugin-missing" },
64
+ component,
65
+ },
62
66
  });
63
67
 
64
68
  return null;
@@ -0,0 +1,3 @@
1
+ // Web builds always select the default Focusable, so the tvOS and iOS ones stay out
2
+ // of web bundles.
3
+ export { Focusable } from "./Focusable";
@@ -4,6 +4,8 @@ import { TouchableOpacity, ViewStyle } from "react-native";
4
4
  import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
5
5
  import { useUIComponentContext } from "@applicaster/zapp-react-native-ui-components/Contexts/UIComponentContext";
6
6
 
7
+ import { masterCellLogger } from "../logger";
8
+
7
9
  import Image from "./Image";
8
10
  type Props = {
9
11
  item: ZappEntry | ZappFeed;
@@ -60,23 +62,46 @@ export const ActionButton = React.memo(function ActionButtonComponent(
60
62
  const actionContext = useActions(action?.identifier);
61
63
  const component = useUIComponentContext();
62
64
 
65
+ useEffect(() => {
66
+ if (!actionContext && action?.identifier) {
67
+ masterCellLogger.warning({
68
+ message: `ActionButton: action plugin "${action.identifier}" is not available or not installed - the button is not displayed`,
69
+ data: {
70
+ diagnostic: { code: "action-plugin-missing" },
71
+ identifier: action.identifier,
72
+ entryId: item?.id,
73
+ component_id: component?.id,
74
+ },
75
+ });
76
+ }
77
+ }, [actionContext, action?.identifier, item?.id]);
78
+
63
79
  // TODO: add subscription API for action availability
64
80
  const actionDisabled =
65
81
  typeof actionContext?.isActionAvailable === "function" &&
66
82
  !actionContext.isActionAvailable(item);
67
83
 
68
- // Note: in theory initialization is not needed anymore, we are using useEffect
69
84
  const [actionState, setActionState] = React.useState(
70
- actionDisabled || !actionContext
85
+ actionDisabled ||
86
+ !actionContext ||
87
+ typeof actionContext?.initialEntryState !== "function"
71
88
  ? null
72
89
  : actionContext.initialEntryState(item)
73
90
  );
74
91
 
75
92
  useEffect(() => {
76
- if (!((actionDisabled || !actionContext) && actionState !== null)) {
93
+ if (actionDisabled || !actionContext) {
94
+ if (actionState !== null) {
95
+ setActionState(null);
96
+ }
97
+
98
+ return;
99
+ }
100
+
101
+ if (typeof actionContext?.initialEntryState === "function") {
77
102
  setActionState(actionContext.initialEntryState(item));
78
103
  }
79
- }, [actionDisabled, item?.id, actionContext, action, setActionState]);
104
+ }, [actionDisabled, item?.id, actionContext, action]);
80
105
 
81
106
  const onPress = useCallback(() => {
82
107
  actionContext.invokeAction(item, {
@@ -9,6 +9,7 @@ import {
9
9
 
10
10
  import {
11
11
  cloneChildrenWithIds,
12
+ getFocusableElementId,
12
13
  insertBetween,
13
14
  unwrapDataProviderChild,
14
15
  useFilterChildren,
@@ -17,8 +18,6 @@ import {
17
18
  import type { ContainerProps, ContainerChildren } from "./types";
18
19
  import { HorizontalSeparator } from "./components/HorizontalSeparator";
19
20
 
20
- const generateId = (cellUUID, suffixId) => `${cellUUID}--${suffixId}`;
21
-
22
21
  export function ButtonContainerView({
23
22
  style,
24
23
  children,
@@ -31,9 +30,13 @@ export function ButtonContainerView({
31
30
 
32
31
  const buttonIds = filteredChildren.map((child) => {
33
32
  const wrappedChild = unwrapDataProviderChild(child) as ContainerChildren;
34
- const { cellUUID, suffixId } = wrappedChild.props;
33
+ const { cellUUID, cellInstanceId, suffixId } = wrappedChild.props;
35
34
 
36
- return generateId(cellUUID, suffixId);
35
+ return getFocusableElementId({
36
+ playerId: cellUUID,
37
+ cellInstanceId,
38
+ suffix: suffixId,
39
+ });
37
40
  });
38
41
 
39
42
  useInitialFocus(otherProps.state === "focused", R.head(buttonIds));
@@ -5,6 +5,7 @@ export type ContainerChildProps = {
5
5
  item: any;
6
6
  pluginIdentifier: string;
7
7
  cellUUID: string;
8
+ cellInstanceId?: string;
8
9
  suffixId: string;
9
10
  nextFocusLeft?: string;
10
11
  nextFocusRight?: string;
@@ -4,14 +4,15 @@ import { Focusable } from "@applicaster/zapp-react-native-ui-components/Componen
4
4
  import { useFocusable } from "@applicaster/zapp-react-native-ui-components/Components/Focusable/index.android";
5
5
  import { useIsRTL } from "@applicaster/zapp-react-native-utils/localizationUtils";
6
6
 
7
- import { recursiveCloneElementsWithState } from "../../utils";
7
+ import {
8
+ recursiveCloneElementsWithState,
9
+ getFocusableElementId,
10
+ } from "../../utils";
8
11
 
9
12
  type ButtonProps = Record<string, any> & {
10
13
  style: ImageStyle;
11
14
  };
12
15
 
13
- const generateId = (cellUUID, suffixId) => `${cellUUID}--${suffixId}`;
14
-
15
16
  const getNextFocusLeft = ({ nextFocusLeft, parentFocus, isRTL }) => {
16
17
  return (
17
18
  nextFocusLeft ||
@@ -32,6 +33,7 @@ export function FocusableViewComponent(
32
33
  ) {
33
34
  const {
34
35
  cellUUID,
36
+ cellInstanceId,
35
37
  groupId,
36
38
  suffixId,
37
39
  normalStyles,
@@ -58,7 +60,11 @@ export function FocusableViewComponent(
58
60
 
59
61
  return (
60
62
  <Focusable
61
- id={generateId(cellUUID, suffixId)}
63
+ id={getFocusableElementId({
64
+ playerId: cellUUID,
65
+ cellInstanceId,
66
+ suffix: suffixId,
67
+ })}
62
68
  disableFocus={disableFocus}
63
69
  groupId={groupId}
64
70
  onPress={otherProps.onPress}
@@ -0,0 +1,7 @@
1
+ import ImageWeb from "./Image.web";
2
+
3
+ import { withDimensionsHOC } from "./hoc/withDimensions";
4
+
5
+ // Web builds always select the web image, so the Android and iOS ones stay out of
6
+ // web bundles.
7
+ export default withDimensionsHOC(ImageWeb);
@@ -258,6 +258,36 @@ describe("prepareEntry", () => {
258
258
 
259
259
  expect(prepareEntry(entry)).toBeNull();
260
260
  });
261
+
262
+ it("should return entry when the media extension is followed by a query or hash", () => {
263
+ const entry = makeEntry({
264
+ extensions: {
265
+ autoplay_settings: { start_time: "00:10", end_time: "00:35" },
266
+ },
267
+ content: { src: "https://example.com/video.m3u8?token=abc#t=10" },
268
+ });
269
+
270
+ expect(prepareEntry(entry)).toBe(entry);
271
+ });
272
+
273
+ it("should return entry for an HLS or DASH content type without a file extension", () => {
274
+ const types = [
275
+ "application/x-mpegURL",
276
+ "application/vnd.apple.mpegurl",
277
+ "application/dash+xml",
278
+ ];
279
+
280
+ for (const type of types) {
281
+ const entry = makeEntry({
282
+ extensions: {
283
+ autoplay_settings: { start_time: "00:10", end_time: "00:35" },
284
+ },
285
+ content: { src: "https://example.com/stream", type },
286
+ });
287
+
288
+ expect(prepareEntry(entry)).toBe(entry);
289
+ }
290
+ });
261
291
  });
262
292
 
263
293
  describe("priority order", () => {
@@ -67,10 +67,28 @@ const isSupportedTVForLiveImage = () => {
67
67
  }
68
68
  };
69
69
 
70
+ // HLS and DASH are not `video/*`. Trimming (`autoplay_settings`) plays `content.src`,
71
+ // so these types have to count. A preview URL skips this check.
72
+ const playableStreamTypes = new Set([
73
+ "application/x-mpegurl",
74
+ "application/vnd.apple.mpegurl",
75
+ "application/dash+xml",
76
+ ]);
77
+
78
+ const isPlayableContentType = (type?: string): boolean => {
79
+ const normalized = type?.split(";")[0].trim().toLowerCase();
80
+
81
+ return (
82
+ !!normalized &&
83
+ (normalized.startsWith("video") || playableStreamTypes.has(normalized))
84
+ );
85
+ };
86
+
70
87
  const isVideoUrl = (streamUrl: string): boolean => {
71
- // TODO: Not the best. Will fail if there is query params
88
+ const path = streamUrl.split(/[?#]/)[0];
89
+
72
90
  for (const key in knownMediaExtensions) {
73
- if (streamUrl.endsWith(key)) {
91
+ if (path.endsWith(key)) {
74
92
  return true;
75
93
  }
76
94
  }
@@ -140,11 +158,11 @@ export const prepareEntry = (entry: ZappEntry) => {
140
158
  return null;
141
159
  }
142
160
 
143
- if (entry.content?.type?.startsWith("video")) {
161
+ if (isPlayableContentType(entry.content?.type) || isVideoUrl(src)) {
144
162
  return entry;
145
163
  }
146
164
 
147
- return isVideoUrl(src) ? entry : null;
165
+ return null;
148
166
  };
149
167
 
150
168
  const getPlayableEntry = (entry) => {
@@ -0,0 +1,66 @@
1
+ import React from "react";
2
+ import { render } from "@testing-library/react-native";
3
+ import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
4
+ import { masterCellLogger } from "../../logger";
5
+
6
+ import { ActionButton } from "../ActionButton";
7
+
8
+ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/actions", () => ({
9
+ useActions: jest.fn(),
10
+ }));
11
+
12
+ jest.mock("../../logger", () => ({
13
+ masterCellLogger: {
14
+ warning: jest.fn(),
15
+ error: jest.fn(),
16
+ info: jest.fn(),
17
+ debug: jest.fn(),
18
+ },
19
+ }));
20
+
21
+ describe("ActionButton", () => {
22
+ beforeEach(() => {
23
+ jest.clearAllMocks();
24
+ });
25
+
26
+ it("does not crash when actionContext is undefined and logs a warning", () => {
27
+ (useActions as jest.Mock).mockReturnValue(undefined);
28
+
29
+ const item = { id: "entry-1", title: "Test" } as any;
30
+ const action = { identifier: "uninstalled-action-plugin" };
31
+
32
+ const { toJSON } = render(
33
+ <ActionButton item={item} action={action} style={{}} />
34
+ );
35
+
36
+ expect(toJSON()).toBeNull();
37
+
38
+ expect(masterCellLogger.warning).toHaveBeenCalledWith(
39
+ expect.objectContaining({
40
+ message: expect.stringContaining(
41
+ 'action plugin "uninstalled-action-plugin" is not available'
42
+ ),
43
+ data: expect.objectContaining({
44
+ diagnostic: { code: "action-plugin-missing" },
45
+ identifier: "uninstalled-action-plugin",
46
+ entryId: "entry-1",
47
+ }),
48
+ })
49
+ );
50
+ });
51
+
52
+ it("does not crash when actionContext has no initialEntryState method", () => {
53
+ (useActions as jest.Mock).mockReturnValue({
54
+ invokeAction: jest.fn(),
55
+ });
56
+
57
+ const item = { id: "entry-2", title: "Test 2" } as any;
58
+ const action = { identifier: "legacy-action-plugin" };
59
+
60
+ const { toJSON } = render(
61
+ <ActionButton item={item} action={action} style={{}} />
62
+ );
63
+
64
+ expect(toJSON()).toBeNull();
65
+ });
66
+ });
@@ -136,6 +136,62 @@ describe("masterCellBuilder", () => {
136
136
  });
137
137
  });
138
138
 
139
+ describe("live-image cell ids", () => {
140
+ const component = {
141
+ id: "rail",
142
+ component_type: "horizontal_list_qb",
143
+ styles: { cell_plugin_configuration_id: "cell-style" },
144
+ rules: {
145
+ enable_video_preview: true,
146
+ player_screen_id: "player-screen",
147
+ },
148
+ };
149
+
150
+ const dataAdapter = () => () => [
151
+ {
152
+ type: "LiveImage",
153
+ style: {},
154
+ props: { testID: "live-image" },
155
+ },
156
+ ];
157
+
158
+ const LiveImage = (props) => <View {...props} />;
159
+
160
+ const MasterCell = masterCellBuilder({
161
+ cellConfiguration: singleView,
162
+ dataAdapter,
163
+ components: { LiveImage },
164
+ cellOptions: { component },
165
+ });
166
+
167
+ const firstEntry = { ...entry, id: "entry-1" };
168
+ const secondEntry = { ...entry, id: "entry-2" };
169
+
170
+ const renderEntries = (firstState, secondState) => (
171
+ <>
172
+ <MasterCell item={firstEntry} state={firstState} />
173
+ <MasterCell item={secondEntry} state={secondState} />
174
+ </>
175
+ );
176
+
177
+ it("gives each entry its own id and keeps it when focus changes", () => {
178
+ const wrapper = renderWithProviders(renderEntries(null, null));
179
+
180
+ const [firstCell, secondCell] = wrapper.getAllByTestId("live-image");
181
+
182
+ expect(firstCell.props.cellUUID).toBe("rail-cell-style-entry-1");
183
+ expect(secondCell.props.cellUUID).toBe("rail-cell-style-entry-2");
184
+
185
+ wrapper.rerender(renderEntries("focused", "focused"));
186
+
187
+ const [focusedFirst, focusedSecond] =
188
+ wrapper.getAllByTestId("live-image");
189
+
190
+ expect(focusedFirst.props.cellUUID).toBe(firstCell.props.cellUUID);
191
+ expect(focusedSecond.props.cellUUID).toBe(secondCell.props.cellUUID);
192
+ });
193
+ });
194
+
139
195
  describe.skip("when using custom default components", () => {
140
196
  // the collapsable prop is added here to easily check from the snapshot that the mock
141
197
  // component is being used instead of the default one
@@ -11,6 +11,7 @@ import { defaultComponents } from "./DefaultComponents";
11
11
  import { defaultDataAdapter } from "./dataAdapter";
12
12
  import { elementMapper, mapElementWithKey } from "./elementMapper";
13
13
  import {
14
+ getCellInstanceId,
14
15
  getEntryState,
15
16
  hasFocusableInsideBuilder,
16
17
  withoutFocusedState,
@@ -130,8 +131,11 @@ export function masterCellBuilder({
130
131
 
131
132
  const isHL = isHorizontalList(component);
132
133
 
133
- return isHL && isLiveImage
134
- ? `${component?.id}-${component?.styles?.cell_plugin_configuration_id}`
134
+ const entryId = item?.id;
135
+
136
+ // Player ids are unique. The entry id keeps each cell on its own player.
137
+ return isHL && isLiveImage && entryId
138
+ ? `${component?.id}-${component?.styles?.cell_plugin_configuration_id}-${entryId}`
135
139
  : uuid();
136
140
  }, [
137
141
  component?.id,
@@ -142,11 +146,22 @@ export function masterCellBuilder({
142
146
  item?.id,
143
147
  ]);
144
148
 
149
+ // cellUUID is the player id shared by every copy of this entry.
150
+ // cellInstanceId distinguishes each rendered copy for focus only.
151
+ const focusIndex = (item as { focusIndex?: number } | undefined)
152
+ ?.focusIndex;
153
+
154
+ const cellInstanceId = React.useMemo(
155
+ () => getCellInstanceId(item?.id, focusIndex),
156
+ [item?.id, focusIndex]
157
+ );
158
+
145
159
  const remapElements = mapElementWithKey(
146
160
  elementMapper(componentsMap, {
147
161
  ...otherProps,
148
162
  wrapperRef,
149
163
  cellUUID,
164
+ cellInstanceId,
150
165
  skipButtons,
151
166
  hasFocusableInside,
152
167
  entry: item,
@@ -0,0 +1,38 @@
1
+ import { getCellInstanceId, getFocusableElementId } from "..";
2
+
3
+ describe("getFocusableElementId", () => {
4
+ it("uses the player id and the focusable suffix when there is no entry", () => {
5
+ expect(
6
+ getFocusableElementId({
7
+ playerId: "player-1",
8
+ suffix: "tv_buttons_button_1",
9
+ })
10
+ ).toBe("player-1--tv_buttons_button_1");
11
+ });
12
+
13
+ it("adds the cell instance id for one rendered entry", () => {
14
+ const cellInstanceId = getCellInstanceId("entry-a");
15
+
16
+ expect(
17
+ getFocusableElementId({
18
+ playerId: "player-1",
19
+ cellInstanceId,
20
+ suffix: "tv_buttons_button_1",
21
+ })
22
+ ).toBe("player-1--entry-a--tv_buttons_button_1");
23
+ });
24
+
25
+ it("keeps a zero clone index on the cell instance id", () => {
26
+ const cellInstanceId = getCellInstanceId("entry-a", 0);
27
+
28
+ expect(cellInstanceId).toBe("entry-a--0");
29
+
30
+ expect(
31
+ getFocusableElementId({
32
+ playerId: "player-1",
33
+ cellInstanceId,
34
+ suffix: "tv_buttons_button_1",
35
+ })
36
+ ).toBe("player-1--entry-a--0--tv_buttons_button_1");
37
+ });
38
+ });
@@ -237,7 +237,12 @@ export const useFilterChildren = <
237
237
 
238
238
  masterCellLogger.error({
239
239
  message: `Action plugin for ${actionIdentifier} could not be found, check the configuration of your action button`,
240
- data: { item, action: wrappedChild.props.pluginIdentifier },
240
+ data: {
241
+ diagnostic: { code: "action-plugin-missing" },
242
+ identifier: actionIdentifier,
243
+ item,
244
+ action: actionIdentifier,
245
+ },
241
246
  });
242
247
 
243
248
  return false;
@@ -330,6 +335,39 @@ export const getFocusedButtonId = (focusable) => {
330
335
  });
331
336
  };
332
337
 
338
+ // One rendered copy of an entry. focusIndex separates auto-loop clones.
339
+ // Omitted when the entry has no id; the player id is already unique per mount.
340
+ export const getCellInstanceId = (
341
+ entryId?: string | number,
342
+ focusIndex?: number
343
+ ): string | undefined => {
344
+ if (entryId == null || entryId === "") {
345
+ return undefined;
346
+ }
347
+
348
+ const indexSuffix = typeof focusIndex === "number" ? `--${focusIndex}` : "";
349
+
350
+ return `${entryId}${indexSuffix}`;
351
+ };
352
+
353
+ // Final FocusManager id. playerId is the shared playback identity (cellUUID).
354
+ // Registration and initial-focus lookup both call this.
355
+ export const getFocusableElementId = ({
356
+ playerId,
357
+ cellInstanceId,
358
+ suffix,
359
+ }: {
360
+ playerId: string;
361
+ cellInstanceId?: string;
362
+ suffix: string;
363
+ }): string => {
364
+ const instanceId = cellInstanceId
365
+ ? `${playerId}--${cellInstanceId}`
366
+ : playerId;
367
+
368
+ return `${instanceId}--${suffix}`;
369
+ };
370
+
333
371
  export const useCellState = ({
334
372
  item,
335
373
  behavior,
@@ -43,7 +43,9 @@ export function Button({
43
43
  }: ButtonProps) {
44
44
  const [focused, setFocused] = useState(false);
45
45
 
46
- const selected = selectedItem && item?.value === selectedItem?.value;
46
+ const selected = Boolean(
47
+ item?.isSelected || (selectedItem && item?.value === selectedItem?.value)
48
+ );
47
49
 
48
50
  const itemIconPropsAssets = useMemo<ItemIconProps["asset"]>(
49
51
  () =>
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  import { Pressable } from "react-native";
3
3
  import { fireEvent, render, screen } from "@testing-library/react-native";
4
+ import { Button } from "../../Button";
4
5
  import { getCell } from "../index";
5
6
  import { standardCell } from "../standardCell";
6
7
  import { selectableCell } from "../selectableCell";
@@ -12,8 +13,8 @@ describe("getCell", () => {
12
13
  expect(getCell("collection_selector")).toBe(selectableCell);
13
14
  });
14
15
 
15
- it("returns selectable cell for preference_editor", () => {
16
- expect(getCell("preference_editor")).toBe(selectableCell);
16
+ it("returns standard cell for preference_editor", () => {
17
+ expect(getCell("preference_editor")).toBe(standardCell);
17
18
  });
18
19
 
19
20
  it("returns standard cell when role is undefined", () => {
@@ -88,3 +89,29 @@ describe("selectableCell checkbox press", () => {
88
89
  expect(onPress).toHaveBeenCalledWith(item);
89
90
  });
90
91
  });
92
+
93
+ describe("standardCell selection via item.isSelected", () => {
94
+ it("highlights row and renders selected icon when item.isSelected is true", () => {
95
+ render(
96
+ standardCell.renderItem({
97
+ item: { id: "1", title: "1x", isSelected: true },
98
+ index: 0,
99
+ onPress: jest.fn(),
100
+ context: {
101
+ theme: {},
102
+ ButtonComponent: Button,
103
+ current_selection: null,
104
+ iconBaseProps: { width: 16, height: 16 },
105
+ itemBaseProps: { selectedBackgroundColor: "#3E3E3E" } as any,
106
+ labelBaseProps: { selectedColor: "#EFEFEF" } as any,
107
+ getSelectedItemIcon: () => "https://example.com/check.png",
108
+ getDefaultItemIcon: () => null,
109
+ } as any,
110
+ }) as React.ReactElement
111
+ );
112
+
113
+ expect(screen.getByText("1x").props.style).toMatchObject({
114
+ color: "#EFEFEF",
115
+ });
116
+ });
117
+ });