@applicaster/zapp-react-native-ui-components 16.0.0-rc.8 → 16.0.0-rc.81

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 (132) hide show
  1. package/Components/AudioPlayer/tv/__tests__/audioPlayer.test.js +19 -0
  2. package/Components/AudioPlayer/tv/__tests__/index.test.tsx +120 -0
  3. package/Components/AudioPlayer/tv/index.tsx +5 -1
  4. package/Components/Cell/Cell.tsx +3 -6
  5. package/Components/Cell/TvOSCellComponent.tsx +0 -1
  6. package/Components/CellRendererResolver/index.ts +2 -2
  7. package/Components/ComponentResolver/__tests__/componentResolver.test.js +1 -1
  8. package/Components/FocusableGroup/FocusableTvOS.tsx +11 -7
  9. package/Components/GeneralContentScreen/GeneralContentScreenHookAdapter.tsx +39 -0
  10. package/Components/GeneralContentScreen/__tests__/GeneralContentScreenHookAdapter.test.tsx +64 -0
  11. package/Components/GeneralContentScreen/__tests__/HookContentFocusGroup.web.test.tsx +91 -0
  12. package/Components/GeneralContentScreen/hookAdapter/__tests__/networkService.test.ts +74 -0
  13. package/Components/GeneralContentScreen/hookAdapter/__tests__/runInBackground.test.ts +139 -0
  14. package/Components/GeneralContentScreen/hookAdapter/__tests__/skipExpression.test.ts +294 -0
  15. package/Components/GeneralContentScreen/hookAdapter/__tests__/validationHelper.test.ts +188 -0
  16. package/Components/GeneralContentScreen/hookAdapter/logger.ts +6 -0
  17. package/Components/GeneralContentScreen/hookAdapter/networkService.ts +53 -0
  18. package/Components/GeneralContentScreen/hookAdapter/runInBackground.ts +48 -0
  19. package/Components/GeneralContentScreen/hookAdapter/skipExpression.ts +252 -0
  20. package/Components/GeneralContentScreen/hookAdapter/validationHelper.ts +90 -0
  21. package/Components/GeneralContentScreen/hookFocus/index.tsx +13 -0
  22. package/Components/GeneralContentScreen/hookFocus/index.web.tsx +69 -0
  23. package/Components/GeneralContentScreen/index.ts +2 -0
  24. package/Components/Layout/FullWidthRow.tsx +38 -0
  25. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +16 -5
  26. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/placement.test.ts +47 -21
  27. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/placement.ts +34 -6
  28. package/Components/MasterCell/DefaultComponents/Image/hoc/utils/__tests__/withDimensions.test.ts +420 -125
  29. package/Components/MasterCell/DefaultComponents/Image/hoc/utils/index.ts +114 -19
  30. package/Components/MasterCell/DefaultComponents/Image/hoc/withDimensions.tsx +19 -8
  31. package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -3
  32. package/Components/MasterCell/DefaultComponents/PressableView.tsx +29 -9
  33. package/Components/MasterCell/DefaultComponents/Text/hooks/useText.ts +4 -0
  34. package/Components/MasterCell/DefaultComponents/Toggle.tsx +36 -14
  35. package/Components/MasterCell/DefaultComponents/__tests__/Toggle.test.tsx +167 -0
  36. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/ActionButton.tsx +154 -100
  37. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/AssetComponent.tsx +15 -4
  38. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Button.ts +56 -22
  39. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Spacer.ts +6 -4
  40. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/TextLabelsContainer.ts +3 -1
  41. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/PressableView.test.tsx +32 -21
  42. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/index.test.ts +15 -4
  43. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/index.ts +23 -16
  44. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/__tests__/insertButtons.test.ts +8 -3
  45. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/index.ts +2 -2
  46. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/__tests__/insertButtonsBetweenLabels.test.ts +45 -13
  47. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/index.ts +2 -2
  48. package/Components/MasterCell/contexts/PressedStateContext.ts +3 -0
  49. package/Components/MasterCell/dataAdapter.ts +15 -5
  50. package/Components/MasterCell/hooks/index.ts +2 -0
  51. package/Components/MasterCell/hooks/usePressedState.ts +4 -0
  52. package/Components/MasterCell/index.tsx +30 -5
  53. package/Components/MasterCell/utils/__tests__/resolveColor.test.js +169 -132
  54. package/Components/MasterCell/utils/__tests__/resolveColorForProp.test.js +92 -0
  55. package/Components/MasterCell/utils/index.ts +85 -46
  56. package/Components/ModalComponent/ActionsBottomSheet/ActionButton.tsx +54 -0
  57. package/Components/ModalComponent/ActionsBottomSheet/boundActionButton.tsx +21 -0
  58. package/Components/ModalComponent/ActionsBottomSheet/index.ts +9 -0
  59. package/Components/ModalComponent/ActionsBottomSheet/openActionsBottomSheet.ts +58 -0
  60. package/Components/ModalComponent/AudioPlayer/Components/Action.tsx +314 -0
  61. package/Components/ModalComponent/AudioPlayer/Components/Button.tsx +407 -0
  62. package/Components/ModalComponent/AudioPlayer/Components/Header.tsx +763 -0
  63. package/Components/ModalComponent/AudioPlayer/Components/Input.tsx +653 -0
  64. package/Components/ModalComponent/AudioPlayer/Components/Item.tsx +960 -0
  65. package/Components/ModalComponent/AudioPlayer/Components/NowPlayingHeaderSection.tsx +89 -0
  66. package/Components/ModalComponent/AudioPlayer/Components/index.ts +11 -0
  67. package/Components/ModalComponent/AudioPlayer/utils/__tests__/mergeStyles.test.ts +230 -0
  68. package/Components/ModalComponent/AudioPlayer/utils/mergeStyles.ts +332 -0
  69. package/Components/ModalComponent/BottomSheetDragArea.tsx +33 -0
  70. package/Components/ModalComponent/BottomSheetModalContent.tsx +383 -42
  71. package/Components/ModalComponent/Button/index.tsx +5 -3
  72. package/Components/ModalComponent/Header/index.tsx +20 -7
  73. package/Components/ModalComponent/Header/utils.ts +1 -1
  74. package/Components/ModalComponent/ModalBlocksStyleContext.tsx +10 -0
  75. package/Components/ModalComponent/SortableList.tsx +142 -0
  76. package/Components/ModalComponent/SortableList.web.tsx +34 -0
  77. package/Components/ModalComponent/TextInputContent.tsx +100 -0
  78. package/Components/ModalComponent/__tests__/BottomSheetDragArea.test.tsx +74 -0
  79. package/Components/ModalComponent/__tests__/BottomSheetModalContent.test.tsx +238 -0
  80. package/Components/ModalComponent/__tests__/SortableList.web.test.tsx +16 -0
  81. package/Components/ModalComponent/__tests__/TextInputContent.test.tsx +120 -0
  82. package/Components/ModalComponent/__tests__/showTextInput.test.ts +95 -0
  83. package/Components/ModalComponent/index.tsx +11 -0
  84. package/Components/ModalComponent/presets/__tests__/getCell.test.ts +66 -0
  85. package/Components/ModalComponent/presets/dynamicCollectionCell.tsx +78 -0
  86. package/Components/ModalComponent/presets/index.ts +27 -0
  87. package/Components/ModalComponent/presets/selectableCell.tsx +28 -0
  88. package/Components/ModalComponent/presets/standardCell.tsx +41 -0
  89. package/Components/ModalComponent/presets/types.ts +35 -0
  90. package/Components/ModalComponent/showTextInput.ts +43 -0
  91. package/Components/ModalComponent/utils.ts +82 -21
  92. package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +4 -85
  93. package/Components/OfflineHandler/__tests__/index.test.tsx +78 -18
  94. package/Components/OfflineHandler/hooks.ts +111 -0
  95. package/Components/OfflineHandler/index.tsx +51 -73
  96. package/Components/OfflineHandler/utils/index.ts +1 -13
  97. package/Components/PlayerContainer/PlayerContainer.tsx +25 -17
  98. package/Components/PlayerContainer/ProgramInfo/index.tsx +3 -4
  99. package/Components/PlayerContainer/__tests__/PlayerContainer.test.tsx +337 -0
  100. package/Components/PreloaderWrapper/index.tsx +1 -1
  101. package/Components/River/ComponentsMap/ComponentsMap.tsx +2 -2
  102. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +3 -15
  103. package/Components/Screen/index.tsx +8 -4
  104. package/Components/ScreenFeedLoader/ScreenFeedLoader.tsx +5 -3
  105. package/Components/ScreenResolverFeedProvider/ScreenResolverFeedProvider.tsx +1 -1
  106. package/Components/ScreenRevealManager/ScreenRevealManager.ts +18 -2
  107. package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +36 -0
  108. package/Components/ScreenRevealManager/__tests__/withScreenRevealManager.test.tsx +56 -0
  109. package/Components/ScreenRevealManager/withScreenRevealManager.tsx +20 -3
  110. package/Components/TopCutoffOverlay/index.tsx +2 -2
  111. package/Components/Transitioner/Transitioner.tsx +28 -17
  112. package/Components/VideoLive/LiveImageManager.ts +1 -1
  113. package/Components/VideoModal/utils.ts +6 -1
  114. package/Components/ZappFrameworkComponents/BarView/BarView.tsx +12 -5
  115. package/Components/ZappFrameworkComponents/BarView/__tests__/BarView.test.tsx +2 -2
  116. package/Contexts/CachedDimensionsContext/__tests__/index.test.ts +154 -0
  117. package/Contexts/CachedDimensionsContext/index.ts +17 -2
  118. package/Helpers/ComponentCellSelectionHelper/index.js +0 -6
  119. package/Helpers/index.js +0 -39
  120. package/Hooks/useEntryActionsExpander.ts +63 -0
  121. package/package.json +6 -5
  122. package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +0 -112
  123. package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +0 -107
  124. package/Components/OfflineHandler/NotificationView/NotificationView.tsx +0 -153
  125. package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +0 -66
  126. package/Components/OfflineHandler/NotificationView/utils.ts +0 -34
  127. package/Components/Screen/utils.ts +0 -16
  128. package/Helpers/Analytics/index.js +0 -95
  129. /package/Components/BackgroundImage/{BackgroundImage.tv.android.tsx → BackgroundImage.android.tv.tsx} +0 -0
  130. /package/Components/BackgroundImage/{BackgroundImage.tv.ios.tsx → BackgroundImage.ios.tv.tsx} +0 -0
  131. /package/Components/MasterCell/DefaultComponents/ButtonContainerView/{index.tv.android.tsx → index.android.tv.tsx} +0 -0
  132. /package/Decorators/ZappPipesDataConnector/__tests__/{Hero.js → Hero.tsx} +0 -0
@@ -0,0 +1,120 @@
1
+ import React from "react";
2
+ import {
3
+ fireEvent,
4
+ render,
5
+ screen,
6
+ waitFor,
7
+ } from "@testing-library/react-native";
8
+ import { actionExecutor } from "@applicaster/zapp-react-native-utils/actionsExecutor/ActionExecutor";
9
+
10
+ jest.mock(
11
+ "@applicaster/zapp-react-native-utils/actionsExecutor/ActionExecutor",
12
+ () => ({
13
+ actionExecutor: {
14
+ handleAction: jest.fn().mockResolvedValue(undefined),
15
+ handleActions: jest.fn().mockResolvedValue(undefined),
16
+ },
17
+ ActionResult: { Success: "success", Error: "error" },
18
+ })
19
+ );
20
+
21
+ jest.mock("../AudioPlayer/Components/Input", () => ({
22
+ AudioPlayerInput: ({ value, onChangeText, data }: any) => {
23
+ const { TextInput, Text } = require("react-native");
24
+
25
+ return (
26
+ <>
27
+ <Text testID="input-label">{data?.label}</Text>
28
+ <TextInput
29
+ testID="playlist-input"
30
+ value={value}
31
+ onChangeText={onChangeText}
32
+ placeholder={data?.placeholder}
33
+ />
34
+ </>
35
+ );
36
+ },
37
+ VARIANT_NAME_PLAYLIST_INPUT: {},
38
+ }));
39
+
40
+ jest.mock("../AudioPlayer/Components/Button", () => ({
41
+ AudioPlayerButton: ({ data, onPress }: any) => {
42
+ const { Pressable, Text } = require("react-native");
43
+
44
+ return (
45
+ <Pressable testID="submit-button" onPress={onPress}>
46
+ <Text>{data?.title}</Text>
47
+ </Pressable>
48
+ );
49
+ },
50
+ VARIANT_TEXT_ONLY: {},
51
+ }));
52
+
53
+ import { TextInputContent } from "../TextInputContent";
54
+
55
+ const submitAction = {
56
+ type: "sendCloudEvent",
57
+ options: {
58
+ url: "https://server.com/cloud-events",
59
+ type: "com.applicaster.collection.create.v1",
60
+ subject: "edit_collection",
61
+ data: { collectionId: "playlist-123" },
62
+ },
63
+ };
64
+
65
+ const baseProps = {
66
+ inputLabel: "Name your playlist",
67
+ defaultValue: "Summer Hits",
68
+ buttonLabel: "Update",
69
+ actions: [submitAction],
70
+ };
71
+
72
+ describe("TextInputContent", () => {
73
+ beforeEach(() => {
74
+ jest.clearAllMocks();
75
+ });
76
+
77
+ it("renders default value and button label without a modal header", () => {
78
+ render(<TextInputContent {...baseProps} />);
79
+
80
+ expect(screen.queryByTestId("sheet-header")).toBeNull();
81
+
82
+ expect(screen.getByTestId("playlist-input").props.value).toBe(
83
+ "Summer Hits"
84
+ );
85
+
86
+ expect(screen.getByTestId("submit-button")).toBeTruthy();
87
+ expect(screen.getByText("Update")).toBeTruthy();
88
+ });
89
+
90
+ it("on submit merges name into sendCloudEvent data then dismisses", async () => {
91
+ render(<TextInputContent {...baseProps} />);
92
+
93
+ fireEvent.changeText(screen.getByTestId("playlist-input"), "New Name");
94
+ fireEvent.press(screen.getByTestId("submit-button"));
95
+
96
+ await waitFor(() => {
97
+ expect(actionExecutor.handleActions).toHaveBeenCalledTimes(1);
98
+ expect(actionExecutor.handleAction).toHaveBeenCalledTimes(1);
99
+ });
100
+
101
+ expect(actionExecutor.handleActions).toHaveBeenCalledWith([
102
+ {
103
+ type: "sendCloudEvent",
104
+ options: {
105
+ url: "https://server.com/cloud-events",
106
+ type: "com.applicaster.collection.create.v1",
107
+ subject: "edit_collection",
108
+ data: {
109
+ collectionId: "playlist-123",
110
+ name: "New Name",
111
+ },
112
+ },
113
+ },
114
+ ]);
115
+
116
+ expect(actionExecutor.handleAction).toHaveBeenCalledWith({
117
+ type: "dismissBottomSheet",
118
+ });
119
+ });
120
+ });
@@ -0,0 +1,95 @@
1
+ import {
2
+ actionExecutor,
3
+ ActionResult,
4
+ } from "@applicaster/zapp-react-native-utils/actionsExecutor/ActionExecutor";
5
+ import { TextInputContent } from "../TextInputContent";
6
+ import { showTextInputAction } from "../showTextInput";
7
+
8
+ jest.mock(
9
+ "@applicaster/zapp-react-native-utils/actionsExecutor/ActionExecutor",
10
+ () => ({
11
+ actionExecutor: {
12
+ handleAction: jest.fn().mockResolvedValue("success"),
13
+ },
14
+ ActionResult: { Success: "success", Error: "error" },
15
+ })
16
+ );
17
+
18
+ jest.mock("../TextInputContent", () => ({
19
+ TextInputContent: function MockTextInputContent() {
20
+ return null;
21
+ },
22
+ }));
23
+
24
+ describe("showTextInputAction", () => {
25
+ beforeEach(() => {
26
+ jest.clearAllMocks();
27
+ });
28
+
29
+ it("delegates to openBottomSheet with TextInputContent as body-only component", async () => {
30
+ const action = {
31
+ type: "showTextInput",
32
+ options: {
33
+ headerTitle: "Create Playlist",
34
+ inputLabel: "Name your playlist",
35
+ defaultValue: "",
36
+ buttonLabel: "Create",
37
+ actions: [
38
+ {
39
+ type: "sendCloudEvent",
40
+ options: {
41
+ url: "https://example.com/events",
42
+ type: "com.applicaster.collection.create.v1",
43
+ data: {},
44
+ },
45
+ },
46
+ {
47
+ type: "showToast",
48
+ options: {
49
+ message: "Playlist created.",
50
+ },
51
+ },
52
+ ],
53
+ },
54
+ };
55
+
56
+ const result = await showTextInputAction(action as any);
57
+
58
+ expect(result).toBe(ActionResult.Success);
59
+ expect(actionExecutor.handleAction).toHaveBeenCalledTimes(1);
60
+
61
+ expect(actionExecutor.handleAction).toHaveBeenCalledWith(
62
+ {
63
+ type: "openBottomSheet",
64
+ options: {
65
+ header: {
66
+ title: "Create Playlist",
67
+ },
68
+ content: {
69
+ component: TextInputContent,
70
+ props: {
71
+ inputLabel: "Name your playlist",
72
+ defaultValue: "",
73
+ buttonLabel: "Create",
74
+ actions: action.options.actions,
75
+ },
76
+ },
77
+ },
78
+ },
79
+ undefined
80
+ );
81
+ });
82
+
83
+ it("returns Error when required options are missing", async () => {
84
+ const action = {
85
+ type: "showTextInput",
86
+ options: {
87
+ headerTitle: "Create Playlist",
88
+ },
89
+ };
90
+
91
+ const result = await showTextInputAction(action as any);
92
+ expect(result).toBe(ActionResult.Error);
93
+ expect(actionExecutor.handleAction).not.toHaveBeenCalled();
94
+ });
95
+ });
@@ -1,7 +1,18 @@
1
1
  import React, { useCallback, useState } from "react";
2
+ import { actionExecutor } from "@applicaster/zapp-react-native-utils/actionsExecutor/ActionExecutor";
2
3
 
3
4
  import { BasicMeasurementsPortal as MeasurementsPortal } from "@applicaster/zapp-react-native-ui-components/Components/MeasurmentsPortal";
4
5
  import { BottomSheetModalContent } from "./BottomSheetModalContent";
6
+ import { showTextInputAction } from "./showTextInput";
7
+
8
+ actionExecutor.registerAction("showTextInput", showTextInputAction);
9
+
10
+ export { SortableList, type SortableListProps } from "./SortableList";
11
+
12
+ export {
13
+ TextInputContent,
14
+ type TextInputContentProps,
15
+ } from "./TextInputContent";
5
16
 
6
17
  export type PluginConfiguration = {
7
18
  [key: string]: any;
@@ -0,0 +1,66 @@
1
+ import { getCell } from "../index";
2
+ import { standardCell } from "../standardCell";
3
+ import { selectableCell } from "../selectableCell";
4
+ import { dynamicCollectionCell } from "../dynamicCollectionCell";
5
+ import { mapMenuItemToPlaylistData } from "../../AudioPlayer/Components/Item";
6
+
7
+ describe("getCell", () => {
8
+ it("returns selectable cell for collection_selector", () => {
9
+ expect(getCell("collection_selector")).toBe(selectableCell);
10
+ });
11
+
12
+ it("returns selectable cell for preference_editor", () => {
13
+ expect(getCell("preference_editor")).toBe(selectableCell);
14
+ });
15
+
16
+ it("returns standard cell when role is undefined", () => {
17
+ expect(getCell(undefined)).toBe(standardCell);
18
+ });
19
+
20
+ it("returns standard cell for unknown roles", () => {
21
+ expect(getCell("unknown_role")).toBe(standardCell);
22
+ });
23
+
24
+ it("returns the dynamic collection cell for dynamic_collection", () => {
25
+ expect(getCell("dynamic_collection")).toBe(dynamicCollectionCell);
26
+ });
27
+
28
+ it("does not use behavior to select the cell family", () => {
29
+ expect(getCell(undefined, { selectMode: "multi" })).toBe(standardCell);
30
+
31
+ expect(getCell("collection_selector", { selectMode: "single" })).toBe(
32
+ selectableCell
33
+ );
34
+ });
35
+ });
36
+
37
+ describe("mapMenuItemToPlaylistData", () => {
38
+ const item = {
39
+ title: "Playlist 1",
40
+ summary: "5 items",
41
+ icon: "https://example.com/icon.png",
42
+ };
43
+
44
+ it("defaults to multiSelect trailing button when selectMode is multi or undefined", () => {
45
+ const data1 = mapMenuItemToPlaylistData(item, { selectMode: "multi" });
46
+ expect(data1.trailingButton).toBe("multiSelect");
47
+
48
+ const data2 = mapMenuItemToPlaylistData(item);
49
+ expect(data2.trailingButton).toBe("multiSelect");
50
+ });
51
+
52
+ it("omits trailing button when behavior selectMode is none", () => {
53
+ const data = mapMenuItemToPlaylistData(item, { selectMode: "none" });
54
+ expect(data.trailingButton).toBeUndefined();
55
+ });
56
+
57
+ it("omits trailing button when item trailingButton is explicitly none", () => {
58
+ const itemWithNone = { ...item, trailingButton: "none" };
59
+
60
+ const data = mapMenuItemToPlaylistData(itemWithNone, {
61
+ selectMode: "multi",
62
+ });
63
+
64
+ expect(data.trailingButton).toBeUndefined();
65
+ });
66
+ });
@@ -0,0 +1,78 @@
1
+ import React from "react";
2
+ import {
3
+ AudioPlayerTrackItem,
4
+ VARIANT_QUEUED_ITEM,
5
+ ItemData,
6
+ } from "../AudioPlayer/Components/Item";
7
+ import type { CellRenderer, RenderItemArgs } from "./types";
8
+ import {
9
+ MenuItem,
10
+ OPERATIONS,
11
+ hasOperation,
12
+ } from "@applicaster/zapp-react-native-utils/modalState";
13
+
14
+ function mapMenuItemToDynamicData(
15
+ item: MenuItem,
16
+ operations: string[]
17
+ ): ItemData {
18
+ const hasRemove = hasOperation(operations, OPERATIONS.REMOVE);
19
+ const hasReorder = hasOperation(operations, OPERATIONS.REORDER);
20
+
21
+ const title =
22
+ typeof item?.title === "string"
23
+ ? item.title
24
+ : item?.title != null
25
+ ? String(item.title)
26
+ : "";
27
+
28
+ const summary =
29
+ typeof item?.summary === "string"
30
+ ? item.summary.trim()
31
+ : item?.summary != null
32
+ ? String(item.summary)
33
+ : "";
34
+
35
+ return {
36
+ imageUri: item?.icon,
37
+ textLabel1: title,
38
+ textLabel2: summary,
39
+ leadingButton: hasRemove ? "remove" : undefined,
40
+ trailingButton: hasReorder ? "drag" : undefined,
41
+ isSelected: item?.isSelected,
42
+ };
43
+ }
44
+
45
+ export const dynamicCollectionCell: CellRenderer = {
46
+ renderItem: ({
47
+ item,
48
+ index,
49
+ onPress,
50
+ context,
51
+ renderHandle,
52
+ }: RenderItemArgs) => {
53
+ const { editableCollection } = context;
54
+ const operations = editableCollection?.operations || [];
55
+
56
+ const handleRemove = () => {
57
+ if (editableCollection?.remove) {
58
+ editableCollection.remove(index);
59
+ }
60
+ };
61
+
62
+ const handleDrag = () => {
63
+ // Drag is managed by SortableList drag handle context
64
+ };
65
+
66
+ return (
67
+ <AudioPlayerTrackItem
68
+ key={item.id}
69
+ configuration={VARIANT_QUEUED_ITEM}
70
+ data={mapMenuItemToDynamicData(item, operations)}
71
+ onPress={() => onPress(item)}
72
+ onLeadingButtonPress={handleRemove}
73
+ onTrailingButtonPress={handleDrag}
74
+ renderHandle={renderHandle}
75
+ />
76
+ );
77
+ },
78
+ };
@@ -0,0 +1,27 @@
1
+ import type { SelectionBehavior } from "@applicaster/zapp-react-native-utils/modalState";
2
+ import { selectableCell } from "./selectableCell";
3
+ import { standardCell } from "./standardCell";
4
+ import type { CellRenderer } from "./types";
5
+
6
+ export type { CellRenderer, RenderItemArgs, SheetRenderContext } from "./types";
7
+
8
+ export { standardCell } from "./standardCell";
9
+
10
+ export { selectableCell } from "./selectableCell";
11
+
12
+ import { dynamicCollectionCell } from "./dynamicCollectionCell";
13
+
14
+ const SELECTION_ROLES = new Set(["collection_selector", "preference_editor"]);
15
+
16
+ /**
17
+ * Resolve the row cell from feed role (+ behavior for future config only).
18
+ * Unknown / none -> standard Button cell.
19
+ */
20
+ export const getCell = (
21
+ role?: string,
22
+ _behavior?: SelectionBehavior
23
+ ): CellRenderer => {
24
+ if (role === "dynamic_collection") return dynamicCollectionCell;
25
+
26
+ return role && SELECTION_ROLES.has(role) ? selectableCell : standardCell;
27
+ };
@@ -0,0 +1,28 @@
1
+ import React from "react";
2
+ import {
3
+ AudioPlayerTrackItem,
4
+ mapMenuItemToPlaylistData,
5
+ VARIANT_PLAYLIST_ITEM,
6
+ } from "../AudioPlayer/Components/Item";
7
+ import type { CellRenderer } from "./types";
8
+
9
+ export const selectableCell: CellRenderer = {
10
+ renderItem: ({ item, onPress, context }) => (
11
+ <AudioPlayerTrackItem
12
+ key={item.id}
13
+ configuration={VARIANT_PLAYLIST_ITEM}
14
+ data={mapMenuItemToPlaylistData(item, context?.behavior)}
15
+ onPress={() => onPress(item)}
16
+ onTrailingButtonPress={
17
+ item.secondaryAction?.action
18
+ ? () =>
19
+ onPress({
20
+ id: `${item.id}_secondary`,
21
+ title: item.title,
22
+ action: item.secondaryAction!.action,
23
+ })
24
+ : undefined
25
+ }
26
+ />
27
+ ),
28
+ };
@@ -0,0 +1,41 @@
1
+ import React from "react";
2
+ import type { CellRenderer } from "./types";
3
+
4
+ export const standardCell: CellRenderer = {
5
+ renderItem: ({ item, onPress, context }) => {
6
+ if (!item) {
7
+ return null;
8
+ }
9
+
10
+ const {
11
+ theme,
12
+ ButtonComponent,
13
+ current_selection,
14
+ iconBaseProps,
15
+ itemBaseProps,
16
+ labelBaseProps,
17
+ getSelectedItemIcon,
18
+ getDefaultItemIcon,
19
+ iconPlacement,
20
+ } = context;
21
+
22
+ return (
23
+ <ButtonComponent
24
+ key={item.id}
25
+ configuration={theme}
26
+ selectedItem={current_selection}
27
+ item={item}
28
+ onPress={onPress}
29
+ label={
30
+ theme[(item as any)?.label] ?? ((item as any)?.label || item?.title)
31
+ }
32
+ iconBaseProps={iconBaseProps}
33
+ itemBaseProps={itemBaseProps}
34
+ labelBaseProps={labelBaseProps}
35
+ selectedItemIcon={getSelectedItemIcon(theme)}
36
+ defaultItemIcon={getDefaultItemIcon(theme)}
37
+ iconPlacement={iconPlacement}
38
+ />
39
+ );
40
+ },
41
+ };
@@ -0,0 +1,35 @@
1
+ import type React from "react";
2
+ import type {
3
+ MenuItem,
4
+ SelectionBehavior,
5
+ } from "@applicaster/zapp-react-native-utils/modalState";
6
+ import type { EditableCollection } from "@applicaster/zapp-react-native-utils/modalState/EditableCollection";
7
+
8
+ /**
9
+ * Extra props row renderers need.
10
+ */
11
+ export type SheetRenderContext = {
12
+ theme: any;
13
+ ButtonComponent: React.ComponentType<any>;
14
+ current_selection?: any;
15
+ iconBaseProps: any;
16
+ itemBaseProps: any;
17
+ labelBaseProps: any;
18
+ getSelectedItemIcon: (theme: any) => any;
19
+ getDefaultItemIcon: (theme: any) => any;
20
+ iconPlacement?: "left" | "right";
21
+ editableCollection?: EditableCollection | null;
22
+ behavior?: SelectionBehavior;
23
+ };
24
+
25
+ export type RenderItemArgs = {
26
+ item: MenuItem;
27
+ index: number;
28
+ onPress: (item: MenuItem) => void;
29
+ context: SheetRenderContext;
30
+ renderHandle?: (children: React.ReactElement) => React.ReactElement;
31
+ };
32
+
33
+ export type CellRenderer = {
34
+ renderItem: (args: RenderItemArgs) => React.ReactNode;
35
+ };
@@ -0,0 +1,43 @@
1
+ import {
2
+ actionExecutor,
3
+ ActionResult,
4
+ } from "@applicaster/zapp-react-native-utils/actionsExecutor/ActionExecutor";
5
+ import { TextInputContent } from "./TextInputContent";
6
+
7
+ /**
8
+ * Opens a text-input bottom sheet driven by action.options.
9
+ * Uses openBottomSheet with content.component as body-only UI;
10
+ * standard ModalHeader (dismiss x) is provided by ModalComponent.
11
+ */
12
+ export async function showTextInputAction(
13
+ action: ActionType,
14
+ context?: Record<string, any>
15
+ ): Promise<ActionResult> {
16
+ const { headerTitle, inputLabel, defaultValue, buttonLabel, actions } =
17
+ action.options || {};
18
+
19
+ if (!headerTitle || !buttonLabel || !actions || !actions.length) {
20
+ return ActionResult.Error;
21
+ }
22
+
23
+ return actionExecutor.handleAction(
24
+ {
25
+ type: "openBottomSheet",
26
+ options: {
27
+ header: {
28
+ title: headerTitle,
29
+ },
30
+ content: {
31
+ component: TextInputContent,
32
+ props: {
33
+ inputLabel,
34
+ defaultValue: defaultValue ?? "",
35
+ buttonLabel,
36
+ actions,
37
+ },
38
+ },
39
+ },
40
+ },
41
+ context
42
+ );
43
+ }