@applicaster/zapp-react-native-ui-components 16.0.0-alpha.2024822855 → 16.0.0-alpha.2105365027

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 (95) hide show
  1. package/Components/Cell/Cell.tsx +3 -6
  2. package/Components/Cell/TvOSCellComponent.tsx +0 -1
  3. package/Components/FocusableList/index.tsx +7 -0
  4. package/Components/GeneralContentScreen/GeneralContentScreen.tsx +7 -0
  5. package/Components/GeneralContentScreen/GeneralContentScreenHookAdapter.tsx +15 -0
  6. package/Components/GeneralContentScreen/hookAdapter/__tests__/skipExpression.test.ts +294 -0
  7. package/Components/GeneralContentScreen/hookAdapter/__tests__/validationHelper.test.ts +64 -0
  8. package/Components/GeneralContentScreen/hookAdapter/skipExpression.ts +252 -0
  9. package/Components/GeneralContentScreen/hookAdapter/validationHelper.ts +18 -0
  10. package/Components/LinkHandler/LinkHandler.tsx +2 -7
  11. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +5 -1
  12. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/components/ActionButtonController.tsx +19 -4
  13. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/components/__tests__/ActionButtonController.test.tsx +43 -1
  14. package/Components/MasterCell/DefaultComponents/Button.tsx +1 -0
  15. package/Components/MasterCell/DefaultComponents/LiveImage/executePreloadHooks.ts +2 -4
  16. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +14 -6
  17. package/Components/MasterCell/DefaultComponents/Toggle.tsx +1 -8
  18. package/Components/MasterCell/DefaultComponents/__tests__/Toggle.test.tsx +10 -6
  19. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/ActionButton.tsx +1 -1
  20. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/PressableView.test.tsx +4 -2
  21. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/factory.test.ts +32 -0
  22. package/Components/MasterCell/__tests__/masterCell.test.js +60 -0
  23. package/Components/MasterCell/index.tsx +60 -11
  24. package/Components/MasterCell/utils/__tests__/withoutFocusedState.test.js +20 -0
  25. package/Components/MasterCell/utils/index.ts +18 -0
  26. package/Components/ModalComponent/ActionsBottomSheet/ActionButton.tsx +56 -0
  27. package/Components/ModalComponent/ActionsBottomSheet/__tests__/openActionsBottomSheet.test.ts +38 -0
  28. package/Components/ModalComponent/ActionsBottomSheet/boundActionButton.tsx +24 -0
  29. package/Components/ModalComponent/ActionsBottomSheet/index.ts +9 -0
  30. package/Components/ModalComponent/ActionsBottomSheet/openActionsBottomSheet.ts +61 -0
  31. package/Components/ModalComponent/AudioPlayer/Components/Button.tsx +70 -73
  32. package/Components/ModalComponent/AudioPlayer/Components/Header.tsx +65 -56
  33. package/Components/ModalComponent/AudioPlayer/Components/Input.tsx +140 -65
  34. package/Components/ModalComponent/AudioPlayer/Components/Item.tsx +202 -48
  35. package/Components/ModalComponent/AudioPlayer/Components/NowPlayingHeaderSection.tsx +148 -32
  36. package/Components/ModalComponent/AudioPlayer/Components/__tests__/Item.test.tsx +164 -0
  37. package/Components/ModalComponent/AudioPlayer/Components/__tests__/NowPlayingHeaderSection.test.tsx +36 -0
  38. package/Components/ModalComponent/AudioPlayer/Components/index.ts +0 -2
  39. package/Components/ModalComponent/AudioPlayer/utils/__tests__/mergeStyles.test.ts +433 -0
  40. package/Components/ModalComponent/AudioPlayer/utils/mergeStyles.ts +389 -25
  41. package/Components/ModalComponent/BottomSheetModalContent.tsx +126 -77
  42. package/Components/ModalComponent/Header/CloseButton.tsx +12 -0
  43. package/Components/ModalComponent/Header/__tests__/CloseButton.test.tsx +72 -0
  44. package/Components/ModalComponent/SortableList.tsx +36 -22
  45. package/Components/ModalComponent/SortableList.web.tsx +2 -70
  46. package/Components/ModalComponent/TextInputContent.tsx +42 -7
  47. package/Components/ModalComponent/__tests__/BottomSheetModalContent.test.tsx +111 -6
  48. package/Components/ModalComponent/__tests__/SortableList.web.test.tsx +16 -0
  49. package/Components/ModalComponent/__tests__/TextInputContent.test.tsx +50 -1
  50. package/Components/ModalComponent/__tests__/showTextInput.test.ts +25 -0
  51. package/Components/ModalComponent/index.tsx +7 -9
  52. package/Components/ModalComponent/presets/__tests__/getCell.test.ts +24 -0
  53. package/Components/ModalComponent/presets/dynamicCollectionCell.tsx +1 -1
  54. package/Components/ModalComponent/presets/selectableCell.tsx +1 -1
  55. package/Components/ModalComponent/showTextInput.ts +13 -2
  56. package/Components/ModalComponent/utils.ts +6 -1
  57. package/Components/OfflineHandler/__tests__/index.test.tsx +109 -0
  58. package/Components/OfflineHandler/hooks.ts +0 -12
  59. package/Components/OfflineHandler/index.tsx +42 -4
  60. package/Components/PlayerContainer/PlayerContainer.tsx +8 -1
  61. package/Components/River/ComponentsMap/ComponentsMap.tsx +89 -60
  62. package/Components/River/River.tsx +4 -0
  63. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +140 -75
  64. package/Components/River/__tests__/componentsMap.test.js +8 -3
  65. package/Components/River/__tests__/resultCallback.test.tsx +47 -0
  66. package/Components/Screen/__tests__/Screen.test.tsx +24 -0
  67. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +2 -0
  68. package/Components/Screen/index.tsx +5 -0
  69. package/Components/Screen/navigationHandler.ts +8 -8
  70. package/Components/ScreenRevealManager/ScreenRevealManager.ts +18 -2
  71. package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +36 -0
  72. package/Components/ScreenRevealManager/__tests__/withScreenRevealManager.test.tsx +56 -0
  73. package/Components/ScreenRevealManager/withScreenRevealManager.tsx +21 -4
  74. package/Components/Transitioner/AnimationManager.js +1 -1
  75. package/Components/Transitioner/Scene.tsx +4 -3
  76. package/Components/Transitioner/Transitioner.tsx +71 -33
  77. package/Components/Transitioner/__tests__/transitioner.test.js +372 -3
  78. package/Components/VideoLive/LiveImageManager.ts +8 -2
  79. package/Components/VideoLive/__tests__/LiveImageManager.test.ts +59 -0
  80. package/Components/VideoModal/PlayerWrapper.tsx +4 -1
  81. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -0
  82. package/Components/VideoModal/__tests__/playerWrapperStyle.test.ts +58 -0
  83. package/Components/VideoModal/__tests__/playerWrapperUtils.test.ts +16 -0
  84. package/Components/VideoModal/playerWrapperStyle.ts +21 -3
  85. package/Components/VideoModal/playerWrapperUtils.ts +7 -1
  86. package/Contexts/ModalNavigationContext/__tests__/index.test.tsx +15 -0
  87. package/Contexts/ModalNavigationContext/index.tsx +2 -2
  88. package/Decorators/ZappPipesDataConnector/__tests__/screenToolbox.test.ts +347 -0
  89. package/Decorators/ZappPipesDataConnector/__tests__/screenToolboxUnavailable.test.ts +53 -0
  90. package/Decorators/ZappPipesDataConnector/index.tsx +19 -4
  91. package/Decorators/ZappPipesDataConnector/screenToolbox.ts +384 -0
  92. package/Hooks/useEntryActionsExpander.ts +63 -0
  93. package/assets/empty-Info.png +0 -0
  94. package/package.json +5 -5
  95. package/Components/ModalComponent/AudioPlayer/Components/Action.tsx +0 -314
@@ -76,6 +76,66 @@ describe("masterCellBuilder", () => {
76
76
  });
77
77
  });
78
78
 
79
+ describe("cellOptions.interactive", () => {
80
+ // renders a single View tagged with the state the cell was built with
81
+ const dataAdapter =
82
+ () =>
83
+ ({ state }) => [
84
+ { type: "View", style: {}, props: { testID: `state-${state}` } },
85
+ ];
86
+
87
+ // Only the root View gets this testID: cell elements pass their own testID, which overrides it
88
+ const ROOT_TEST_ID = "master-cell-root";
89
+
90
+ // forwardRef: MasterCell attaches a ref to its root View
91
+ const TestView = React.forwardRef((props, ref) => (
92
+ <View testID={ROOT_TEST_ID} {...props} ref={ref} />
93
+ ));
94
+
95
+ const renderCell = (cellOptions, state) => {
96
+ const MasterCell = masterCellBuilder({
97
+ cellConfiguration: singleView,
98
+ dataAdapter,
99
+ components: { View: TestView },
100
+ cellOptions,
101
+ });
102
+
103
+ return renderWithProviders(<MasterCell item={entry} state={state} />);
104
+ };
105
+
106
+ const getRoot = (wrapper) => wrapper.getByTestId(ROOT_TEST_ID);
107
+
108
+ it("keeps focused state and default root props when omitted", () => {
109
+ const wrapper = renderCell(undefined, "focused");
110
+ const root = getRoot(wrapper);
111
+
112
+ expect(wrapper.getByTestId("state-focused")).toBeDefined();
113
+ expect(root.props.onStartShouldSetResponder).toBeUndefined();
114
+ expect(root.props.collapsable).toBeUndefined();
115
+ });
116
+
117
+ it("claims body touches on a non-collapsable root when false", () => {
118
+ const wrapper = renderCell({ interactive: false }, "default");
119
+ const root = getRoot(wrapper);
120
+
121
+ expect(root.props.onStartShouldSetResponder()).toBe(true);
122
+ expect(root.props.collapsable).toBe(false);
123
+ });
124
+
125
+ it("renders focused as default when false", () => {
126
+ const wrapper = renderCell({ interactive: false }, "focused");
127
+
128
+ expect(wrapper.getByTestId("state-default")).toBeDefined();
129
+ expect(wrapper.queryByTestId("state-focused")).toBeNull();
130
+ });
131
+
132
+ it("renders focused_selected as selected when false", () => {
133
+ const wrapper = renderCell({ interactive: false }, "focused_selected");
134
+
135
+ expect(wrapper.getByTestId("state-selected")).toBeDefined();
136
+ });
137
+ });
138
+
79
139
  describe.skip("when using custom default components", () => {
80
140
  // the collapsable prop is added here to easily check from the snapshot that the mock
81
141
  // component is being used instead of the default one
@@ -1,5 +1,10 @@
1
1
  import * as R from "ramda";
2
2
  import * as React from "react";
3
+ import {
4
+ countRender,
5
+ countCellRender,
6
+ measureSync,
7
+ } from "@applicaster/zapp-react-native-utils/perfTracker";
3
8
  import { v4 as uuid } from "uuid";
4
9
 
5
10
  import { isHorizontalList } from "@applicaster/zapp-react-native-utils/componentsUtils";
@@ -10,7 +15,11 @@ import { useScreenState } from "@applicaster/zapp-react-native-utils/screenState
10
15
  import { defaultComponents } from "./DefaultComponents";
11
16
  import { defaultDataAdapter } from "./dataAdapter";
12
17
  import { elementMapper, mapElementWithKey } from "./elementMapper";
13
- import { getEntryState, hasFocusableInsideBuilder } from "./utils";
18
+ import {
19
+ getEntryState,
20
+ hasFocusableInsideBuilder,
21
+ withoutFocusedState,
22
+ } from "./utils";
14
23
 
15
24
  type Props = {
16
25
  item: ZappEntry;
@@ -19,6 +28,16 @@ type Props = {
19
28
 
20
29
  const defaultContainerStyle = { flex: 1 };
21
30
 
31
+ /**
32
+ * Root props of a non-interactive cell: the root view claims touches on the cell body,
33
+ * so the host list's touchable never fires (buttons, being deeper, still receive theirs).
34
+ * `collapsable: false` keeps Android / Fabric from flattening the view away.
35
+ */
36
+ const nonInteractiveRootProps = {
37
+ onStartShouldSetResponder: () => true,
38
+ collapsable: false,
39
+ };
40
+
22
41
  /**
23
42
  * Constructs a MasterCell with the provided options
24
43
  * @param {Object} options
@@ -27,6 +46,8 @@ const defaultContainerStyle = { flex: 1 };
27
46
  * @param {Function} options.dataAdapter optional dataAdapter to use instead of the default one.
28
47
  * See dataAdapter.js for more info
29
48
  * @param {containerStyles} options.containerStyle style to apply at the top level of the master cell
49
+ * @param {Object} options.cellOptions optional cell options. `interactive: false` makes the cell body
50
+ * ignore taps and render without focused / pressed states (inner buttons keep working). Defaults to `true`.
30
51
  * @returns {Function} Functional React Component to render the masterCell with the provided options
31
52
  */
32
53
 
@@ -39,6 +60,7 @@ type MasterCellBuilderOptions = {
39
60
  isRTL?: boolean;
40
61
  skipButtons?: boolean;
41
62
  component?: ZappComponent;
63
+ interactive?: boolean;
42
64
  };
43
65
  };
44
66
 
@@ -49,15 +71,25 @@ export function masterCellBuilder({
49
71
  containerStyle = defaultContainerStyle,
50
72
  cellOptions = {},
51
73
  }: MasterCellBuilderOptions) {
52
- const { skipButtons = false, component } = cellOptions;
74
+ countRender("masterCellBuilder_factory", {
75
+ hasCellConfig: !!cellConfiguration,
76
+ });
77
+
78
+ const { skipButtons = false, component, interactive = true } = cellOptions;
53
79
 
54
80
  const componentsMap = R.merge(defaultComponents, components);
55
81
  const { View } = componentsMap;
56
- const elementsBuilder = dataAdapter(cellConfiguration);
82
+
83
+ const elementsBuilder = measureSync("MasterCell:dataAdapter", () =>
84
+ dataAdapter(cellConfiguration)
85
+ );
57
86
 
58
87
  // This is very expensive operation
59
88
  // Keep calls to minimum
60
- const hasFocusableInside = hasFocusableInsideBuilder(elementsBuilder);
89
+ const hasFocusableInside = measureSync(
90
+ "MasterCell:hasFocusableInsideBuilder",
91
+ () => hasFocusableInsideBuilder(elementsBuilder)
92
+ );
61
93
 
62
94
  /**
63
95
  * Functional React Component to use to render the master cell
@@ -67,6 +99,11 @@ export function masterCellBuilder({
67
99
  * @param {"selected" | "focused" | null} props.state state of the component
68
100
  */
69
101
  function MasterCell({ item, state, ...otherProps }: Props) {
102
+ countCellRender("MasterCell", item?.id, {
103
+ state,
104
+ title: item?.title,
105
+ });
106
+
70
107
  const { screenData } = useRoute();
71
108
  const theme = useTheme();
72
109
 
@@ -86,12 +123,20 @@ export function masterCellBuilder({
86
123
 
87
124
  const elements = React.useMemo(
88
125
  () =>
89
- elementsBuilder({
90
- entry: item,
91
- state: getEntryState(state, entryIsSelected),
92
- allowDynamicColorsOutsideExtensions:
93
- theme?.allow_dynamic_colors_outside_extensions,
94
- }),
126
+ measureSync(
127
+ "MasterCell:elementsBuilder",
128
+ () =>
129
+ elementsBuilder({
130
+ entry: item,
131
+ state: getEntryState(
132
+ interactive ? state : withoutFocusedState(state),
133
+ entryIsSelected
134
+ ),
135
+ allowDynamicColorsOutsideExtensions:
136
+ theme?.allow_dynamic_colors_outside_extensions,
137
+ }),
138
+ { itemId: item?.id }
139
+ ),
95
140
  [
96
141
  state,
97
142
  item,
@@ -134,7 +179,11 @@ export function masterCellBuilder({
134
179
  );
135
180
 
136
181
  return (
137
- <View style={containerStyle} ref={wrapperRef}>
182
+ <View
183
+ style={containerStyle}
184
+ ref={wrapperRef}
185
+ {...(interactive ? undefined : nonInteractiveRootProps)}
186
+ >
138
187
  {elements.map(remapElements)}
139
188
  </View>
140
189
  );
@@ -0,0 +1,20 @@
1
+ import { withoutFocusedState } from "..";
2
+
3
+ describe("withoutFocusedState", () => {
4
+ it("maps focused to default", () => {
5
+ expect(withoutFocusedState("focused")).toBe("default");
6
+ });
7
+
8
+ it("maps focused_selected to selected", () => {
9
+ expect(withoutFocusedState("focused_selected")).toBe("selected");
10
+ });
11
+
12
+ it("keeps default and selected states", () => {
13
+ expect(withoutFocusedState("default")).toBe("default");
14
+ expect(withoutFocusedState("selected")).toBe("selected");
15
+ });
16
+
17
+ it("keeps a missing state", () => {
18
+ expect(withoutFocusedState(undefined)).toBeUndefined();
19
+ });
20
+ });
@@ -386,3 +386,21 @@ export function getEntryState(state, selected) {
386
386
 
387
387
  return selected ? "selected" : "default";
388
388
  }
389
+
390
+ /**
391
+ * Drops focused (pressed) variants of a cell state, so a non-interactive cell
392
+ * always renders its idle look. `selected` is kept – it is not touch feedback.
393
+ */
394
+ export function withoutFocusedState(
395
+ state?: CellState | null
396
+ ): CellState | null | undefined {
397
+ if (state === "focused_selected") {
398
+ return "selected";
399
+ }
400
+
401
+ if (state === "focused") {
402
+ return "default";
403
+ }
404
+
405
+ return state;
406
+ }
@@ -0,0 +1,56 @@
1
+ import React from "react";
2
+ import { useEntryActionState } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
3
+ import {
4
+ isActionAvailableFor,
5
+ RegisteredAction,
6
+ } from "@applicaster/zapp-react-native-utils/uiActionsRegistrator";
7
+
8
+ import { Button } from "../Button";
9
+
10
+ export type ActionButtonProps = {
11
+ entry: ZappEntry;
12
+ item: RegisteredAction;
13
+ configuration: any;
14
+ width: number;
15
+ component?: ZappUIComponent & { parent?: ZappUIComponent };
16
+ };
17
+
18
+ type Props = ActionButtonProps & {
19
+ onPress?: (item: any) => void;
20
+ };
21
+
22
+ /**
23
+ * Unified action button for the modal bottom sheet.
24
+ *
25
+ * Every item is a `RegisteredAction` resolved from the registry (entry actions,
26
+ * registry actions and legacy context-provider actions alike), so the button
27
+ * simply reads `item.action` and drives it through `useEntryActionState`
28
+ * (backed by the action's observable / `addListener`).
29
+ */
30
+ export function ActionButton(props: Props) {
31
+ const { item, entry, onPress: onItemPress, component } = props;
32
+
33
+ const action = item?.action;
34
+
35
+ const { state, invokeAction } = useEntryActionState(action, entry);
36
+
37
+ const onPress = React.useCallback(
38
+ (_item) => {
39
+ invokeAction({
40
+ context: "toast",
41
+ dismiss: () => onItemPress?.(item),
42
+ ...(component ? { component } : {}),
43
+ });
44
+ },
45
+ [invokeAction, item, onItemPress, component]
46
+ );
47
+
48
+ if (!isActionAvailableFor(action, entry as ZappEntry)) return null;
49
+
50
+ return (
51
+ <Button {...props} item={state} onPress={onPress} label={state?.label} />
52
+ );
53
+ }
54
+
55
+ // Explicitly set display name for the component
56
+ ActionButton.displayName = "ActionButton";
@@ -0,0 +1,38 @@
1
+ import { openBottomSheetModal } from "@applicaster/zapp-react-native-utils/modalState";
2
+ import { boundActionButton } from "../boundActionButton";
3
+ import { openActionsBottomSheet } from "../openActionsBottomSheet";
4
+
5
+ jest.mock("@applicaster/zapp-react-native-utils/modalState", () => ({
6
+ openBottomSheetModal: jest.fn(),
7
+ }));
8
+
9
+ jest.mock("../boundActionButton", () => ({
10
+ boundActionButton: jest.fn(() => jest.fn()),
11
+ }));
12
+
13
+ describe("openActionsBottomSheet", () => {
14
+ beforeEach(() => {
15
+ jest.clearAllMocks();
16
+ });
17
+
18
+ it("binds the List component into the sheet row button", () => {
19
+ const entry = { id: "entry-1" } as ZappEntry;
20
+
21
+ const component = {
22
+ data: { source: "https://example.com/user/collections/abc" },
23
+ };
24
+
25
+ const actions = [
26
+ { identifier: "entry_action_0", action: { invokeAction: jest.fn() } },
27
+ ];
28
+
29
+ openActionsBottomSheet({
30
+ entry,
31
+ actions: actions as any,
32
+ component: component as any,
33
+ });
34
+
35
+ expect(boundActionButton).toHaveBeenCalledWith(entry, component);
36
+ expect(openBottomSheetModal).toHaveBeenCalledTimes(1);
37
+ });
38
+ });
@@ -0,0 +1,24 @@
1
+ import React from "react";
2
+
3
+ import { ActionButton, ActionButtonProps } from "./ActionButton";
4
+
5
+ /**
6
+ * Binds an entry to the sheet's row button.
7
+ *
8
+ * `BottomSheetModalContent` renders `buttonComponent` per item and does not
9
+ * know about entries, so the entry is closed over here instead.
10
+ */
11
+ export const boundActionButton = (
12
+ entry: ZappEntry | ZappFeed,
13
+ component?: ZappUIComponent & { parent?: ZappUIComponent }
14
+ ) => {
15
+ const ActionButtonWithEntry = (props: ActionButtonProps) => (
16
+ <ActionButton {...props} entry={entry as ZappEntry} component={component} />
17
+ );
18
+
19
+ ActionButtonWithEntry.displayName = "ActionButtonWithEntry";
20
+
21
+ return ActionButtonWithEntry;
22
+ };
23
+
24
+ boundActionButton.displayName = "boundActionButton";
@@ -0,0 +1,9 @@
1
+ export { ActionButton } from "./ActionButton";
2
+
3
+ export type { ActionButtonProps } from "./ActionButton";
4
+
5
+ export { boundActionButton } from "./boundActionButton";
6
+
7
+ export { openActionsBottomSheet } from "./openActionsBottomSheet";
8
+
9
+ export type { OpenActionsBottomSheetArgs } from "./openActionsBottomSheet";
@@ -0,0 +1,61 @@
1
+ import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
2
+ import { openBottomSheetModal } from "@applicaster/zapp-react-native-utils/modalState";
3
+ import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
4
+ import { RegisteredAction } from "@applicaster/zapp-react-native-utils/uiActionsRegistrator";
5
+
6
+ import { boundActionButton } from "./boundActionButton";
7
+
8
+ const { log_warning } = createLogger({
9
+ subsystem: "ActionsBottomSheet",
10
+ category: "Presentation",
11
+ });
12
+
13
+ export type OpenActionsBottomSheetArgs = {
14
+ /** Entry the actions act on; bound into every row button. */
15
+ entry: ZappEntry | ZappFeed;
16
+ /** Already resolved and merged actions, in the order they should appear. */
17
+ actions: RegisteredAction[];
18
+ title?: string;
19
+ summary?: string;
20
+ /** List that opened the sheet; forwarded into row invokeAction context. */
21
+ component?: ZappUIComponent & { parent?: ZappUIComponent };
22
+ };
23
+
24
+ /**
25
+ * Presents a list of resolved actions in the shared bottom sheet.
26
+ *
27
+ * This is the core entry point for "show these actions in a sheet": the
28
+ * open-modal-bottom-sheet plugin uses it for its configured list, and the
29
+ * player overflow uses it for the actions that did not fit on the overlay.
30
+ * Neither has to know about the other, and neither needs the plugin installed.
31
+ */
32
+ export function openActionsBottomSheet({
33
+ entry,
34
+ actions,
35
+ title,
36
+ summary,
37
+ component,
38
+ }: OpenActionsBottomSheetArgs): void {
39
+ if (!actions?.length) {
40
+ // Every action resolved away - unavailable for this entry, or not
41
+ // invokable. An empty sheet looks broken, so say why and stay put.
42
+ log_warning(
43
+ "openActionsBottomSheet: nothing to present - not opening the sheet",
44
+ { entryId: (entry as ZappEntry)?.id }
45
+ );
46
+
47
+ return;
48
+ }
49
+
50
+ openBottomSheetModal({
51
+ modalBottomSheetContentProps: {
52
+ // TODO: should be optional - the button handles its own tap, but
53
+ // BottomSheetModalContent still requires an onPress.
54
+ onPress: noop,
55
+ items: actions,
56
+ buttonComponent: boundActionButton(entry, component),
57
+ title,
58
+ summary,
59
+ },
60
+ });
61
+ }
@@ -17,6 +17,9 @@ import {
17
17
  Text,
18
18
  View,
19
19
  } from "react-native";
20
+ import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
21
+
22
+ const logger = createLogger({ category: "ModalComponent:AudioPlayerButton" });
20
23
 
21
24
  const styles = StyleSheet.create({
22
25
  container: {
@@ -81,6 +84,8 @@ export type LeadingIconConfiguration = {
81
84
  enabled: boolean;
82
85
  /** Decides which icon will be displayed when enabled */
83
86
  actionType?: ButtonActionType;
87
+ /** Optional Studio / modal-blocks asset URI (overrides actionType mapping) */
88
+ asset?: string;
84
89
  };
85
90
 
86
91
  export type IconsConfiguration = {
@@ -128,6 +133,28 @@ export const DEFAULT_ICONS_CONFIGURATION: IconsConfiguration = {
128
133
  },
129
134
  };
130
135
 
136
+ // ---------------------------------------------------------------------------
137
+ // Variant configurations
138
+ // ---------------------------------------------------------------------------
139
+
140
+ export const VARIANT_TEXT_ONLY: ButtonConfiguration = {
141
+ background: DEFAULT_BACKGROUND_CONFIGURATION,
142
+ title: DEFAULT_TITLE_CONFIGURATION,
143
+ icons: DEFAULT_ICONS_CONFIGURATION,
144
+ };
145
+
146
+ export const VARIANT_WITH_ICON: ButtonConfiguration = {
147
+ background: DEFAULT_BACKGROUND_CONFIGURATION,
148
+ title: DEFAULT_TITLE_CONFIGURATION,
149
+ icons: {
150
+ ...DEFAULT_ICONS_CONFIGURATION,
151
+ leadingIcon: {
152
+ enabled: true,
153
+ actionType: "addToPlaylist",
154
+ },
155
+ },
156
+ };
157
+
131
158
  // ---------------------------------------------------------------------------
132
159
  // Data (runtime / localization — not styling config)
133
160
  // ---------------------------------------------------------------------------
@@ -138,30 +165,15 @@ export type ButtonData = {
138
165
  };
139
166
 
140
167
  export type AudioPlayerButtonProps = {
141
- configuration: ButtonConfiguration;
142
- data: ButtonData;
168
+ configuration?: ButtonConfiguration;
169
+ data?: ButtonData;
143
170
  disabled?: boolean;
144
171
  focused?: boolean;
145
172
  onPress?: () => void;
146
173
  };
147
174
 
148
- // ---------------------------------------------------------------------------
149
- // Hardcoded spec values (black fields)
150
- // ---------------------------------------------------------------------------
151
-
152
- // Hardcoded: action type → icon asset mapping (base64 PNG)
153
- const ACTION_ICON_ASSETS: Record<ButtonActionType, string> = {
154
- addToQueue:
155
- "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAKUlEQVR42mNgGAVDCfxHw6MWjFpAvEGk4lELKLdgNJmOWkA7C0YBbQAAwiZvkR9eFgQAAAAASUVORK5CYII=",
156
- addToPlaylist:
157
- "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAJklEQVR42mNgGAUjFvzHgmluATF4cFswGsmjkTwayaORPAqGLwAA6Jpxj9Ms9QMAAAAASUVORK5CYII=",
158
- goToPlaylist:
159
- "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAALklEQVR42mNgGAWjYNiD/7Q2/D8tLflPiSX/ycQ0t+D/yLGAEkeMWjAKRgG9AQB4zlSshwSzWwAAAABJRU5ErkJggg==",
160
- confirm:
161
- "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAJElEQVR42mNgGAWjYBSQCv4TwKMWDHELho/hNE/3o2AUDDcAAPv0QMAyy1CtAAAAAElFTkSuQmCC",
162
- cancel:
163
- "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAASElEQVR42mNgGAWjGvynkVoUTf+pqA6nxv8UqiHbEooNx2cQ1QzHZiDVDcdlCcOQsoCmQUTTSKZpMqV5RqNLUUHTwm4UDBMAALBLQ73LTvoyAAAAAElFTkSuQmCC",
164
- };
175
+ const PLACEHOLDER_RED_BOX =
176
+ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAJ0lEQVR4nO3NMQEAAAjDsIF/z2ACvlRAU5NMHuvPOQAAAAAAAMBdC/07Ai5sNw+CAAAAAElFTkSuQmCC";
165
177
 
166
178
  function getTextTransformStyle(
167
179
  textTransform: TextTransform
@@ -170,7 +182,9 @@ function getTextTransformStyle(
170
182
  }
171
183
 
172
184
  function shouldShowLeadingIcon(leadingIcon: LeadingIconConfiguration) {
173
- return leadingIcon.enabled && !!leadingIcon.actionType;
185
+ return (
186
+ leadingIcon.enabled && (!!leadingIcon.actionType || !!leadingIcon.asset)
187
+ );
174
188
  }
175
189
 
176
190
  // ---------------------------------------------------------------------------
@@ -268,17 +282,31 @@ function ButtonTitle({
268
282
  }
269
283
 
270
284
  type ButtonLeadingIconProps = {
271
- actionType: ButtonActionType;
285
+ actionType?: ButtonActionType;
272
286
  configuration: IconsConfiguration;
273
287
  };
274
288
 
275
- function ButtonLeadingIcon({
276
- actionType,
277
- configuration,
278
- }: ButtonLeadingIconProps) {
289
+ function ButtonLeadingIcon({ configuration }: ButtonLeadingIconProps) {
290
+ const asset = configuration.leadingIcon.asset || PLACEHOLDER_RED_BOX;
291
+
292
+ React.useEffect(() => {
293
+ if (!configuration.leadingIcon.asset) {
294
+ logger.log_warning(
295
+ "AudioPlayerButton has leadingIcon enabled but no asset was provided. Falling back to placeholder red box. Ensure the relevant plugin (e.g. playlist-experience) provides leadingIcon.asset in styleOverrides.",
296
+ {
297
+ leadingIcon: configuration.leadingIcon,
298
+ }
299
+ );
300
+ }
301
+ }, [configuration.leadingIcon.asset]);
302
+
303
+ if (!asset) {
304
+ return null;
305
+ }
306
+
279
307
  return (
280
308
  <Image
281
- source={{ uri: ACTION_ICON_ASSETS[actionType] }}
309
+ source={{ uri: asset }}
282
310
  style={{
283
311
  width: configuration.width,
284
312
  height: configuration.height,
@@ -296,13 +324,14 @@ import { useModalBlocksStyle } from "../../ModalBlocksStyleContext";
296
324
  import { mergeButtonConfiguration } from "../utils/mergeStyles";
297
325
 
298
326
  export function AudioPlayerButton({
299
- configuration,
300
- data,
327
+ configuration = VARIANT_WITH_ICON,
328
+ data = { title: undefined },
301
329
  disabled,
302
330
  focused = false,
303
331
  onPress,
304
332
  }: AudioPlayerButtonProps) {
305
333
  const modalBlocksStyle = useModalBlocksStyle();
334
+
306
335
  const buttonBlock = modalBlocksStyle?.button;
307
336
  const actionBlock = modalBlocksStyle?.action;
308
337
 
@@ -316,9 +345,21 @@ export function AudioPlayerButton({
316
345
  icons: iconsConfiguration,
317
346
  } = effectiveConfig;
318
347
 
319
- const { title } = data;
348
+ const title = data?.title || buttonBlock?.title.default;
320
349
  const isDisabled = disabled ?? data.disabled ?? false;
321
350
 
351
+ React.useEffect(() => {
352
+ if (!title) {
353
+ logger.log_warning(
354
+ "Create New Playlist button rendering with empty title. Ensure data.title is set for AudioPlayerButton or styleOverrides providing button title.",
355
+ {
356
+ leadingIcon: iconsConfiguration.leadingIcon,
357
+ modalBlocksStyle: modalBlocksStyle,
358
+ }
359
+ );
360
+ }
361
+ }, [title]);
362
+
322
363
  const { leadingIcon } = iconsConfiguration;
323
364
  const showIcon = shouldShowLeadingIcon(leadingIcon);
324
365
 
@@ -349,47 +390,3 @@ export function AudioPlayerButton({
349
390
  </ButtonContainer>
350
391
  );
351
392
  }
352
-
353
- // ---------------------------------------------------------------------------
354
- // Snack demo — two Button variants from configuration only
355
- // ---------------------------------------------------------------------------
356
-
357
- export const VARIANT_TEXT_ONLY: ButtonConfiguration = {
358
- background: DEFAULT_BACKGROUND_CONFIGURATION,
359
- title: DEFAULT_TITLE_CONFIGURATION,
360
- icons: DEFAULT_ICONS_CONFIGURATION,
361
- };
362
-
363
- export const VARIANT_WITH_ICON: ButtonConfiguration = {
364
- background: DEFAULT_BACKGROUND_CONFIGURATION,
365
- title: DEFAULT_TITLE_CONFIGURATION,
366
- icons: {
367
- ...DEFAULT_ICONS_CONFIGURATION,
368
- leadingIcon: {
369
- enabled: true,
370
- actionType: "addToPlaylist",
371
- },
372
- },
373
- };
374
-
375
- export const VARIANT_UPPERCASE_TITLE: ButtonConfiguration = {
376
- background: DEFAULT_BACKGROUND_CONFIGURATION,
377
- title: {
378
- ...DEFAULT_TITLE_CONFIGURATION,
379
- textTransform: "uppercase",
380
- },
381
- icons: DEFAULT_ICONS_CONFIGURATION,
382
- };
383
-
384
- export const VARIANT_LARGE_ICON: ButtonConfiguration = {
385
- background: DEFAULT_BACKGROUND_CONFIGURATION,
386
- title: DEFAULT_TITLE_CONFIGURATION,
387
- icons: {
388
- width: 32,
389
- height: 32,
390
- leadingIcon: {
391
- enabled: true,
392
- actionType: "addToQueue",
393
- },
394
- },
395
- };