@applicaster/zapp-react-native-ui-components 16.0.0-alpha.1740103407 → 16.0.0-alpha.1803625751

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 (33) hide show
  1. package/Components/GeneralContentScreen/GeneralContentScreenHookAdapter.tsx +39 -0
  2. package/Components/GeneralContentScreen/__tests__/GeneralContentScreenHookAdapter.test.tsx +64 -0
  3. package/Components/GeneralContentScreen/__tests__/HookContentFocusGroup.web.test.tsx +91 -0
  4. package/Components/GeneralContentScreen/hookAdapter/__tests__/networkService.test.ts +74 -0
  5. package/Components/GeneralContentScreen/hookAdapter/__tests__/runInBackground.test.ts +139 -0
  6. package/Components/GeneralContentScreen/hookAdapter/__tests__/validationHelper.test.ts +124 -0
  7. package/Components/GeneralContentScreen/hookAdapter/logger.ts +6 -0
  8. package/Components/GeneralContentScreen/hookAdapter/networkService.ts +53 -0
  9. package/Components/GeneralContentScreen/hookAdapter/runInBackground.ts +48 -0
  10. package/Components/GeneralContentScreen/hookAdapter/validationHelper.ts +72 -0
  11. package/Components/GeneralContentScreen/hookFocus/index.tsx +13 -0
  12. package/Components/GeneralContentScreen/hookFocus/index.web.tsx +69 -0
  13. package/Components/GeneralContentScreen/index.ts +2 -0
  14. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/placement.test.ts +47 -21
  15. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/placement.ts +34 -6
  16. package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +4 -3
  17. package/Components/MasterCell/DefaultComponents/PressableView.tsx +3 -3
  18. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/ActionButton.tsx +38 -2
  19. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/AssetComponent.tsx +15 -4
  20. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Button.ts +30 -16
  21. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/TextLabelsContainer.ts +3 -0
  22. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/index.ts +2 -1
  23. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/__tests__/insertButtons.test.ts +8 -3
  24. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/index.ts +2 -2
  25. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/__tests__/insertButtonsBetweenLabels.test.ts +45 -13
  26. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/index.ts +2 -2
  27. package/Components/River/ComponentsMap/ComponentsMap.tsx +103 -186
  28. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +22 -1
  29. package/Helpers/ComponentCellSelectionHelper/index.js +0 -6
  30. package/Helpers/index.js +0 -39
  31. package/package.json +5 -5
  32. package/Components/Layout/FullWidthRow.tsx +0 -38
  33. package/Helpers/Analytics/index.js +0 -95
@@ -0,0 +1,72 @@
1
+ import { getNamespaceAndKey } from "@applicaster/zapp-react-native-utils/appUtils/contextKeysManager/utils";
2
+ import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
3
+ import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
4
+ import { log_error, log_info } from "./logger";
5
+
6
+ type ParseKey = { key: string; namespace?: string };
7
+
8
+ export function parseKeyEntries(input: string): ParseKey[] {
9
+ return input.split(",").flatMap((item) => {
10
+ const trimmed = item.trim();
11
+
12
+ return trimmed ? getNamespaceAndKey(trimmed) : [];
13
+ });
14
+ }
15
+
16
+ export const getKeyToSkipHook = async (key: string, namespace?: string) => {
17
+ const value = await sessionStorage.getItem(key, namespace);
18
+
19
+ if (value) {
20
+ return value;
21
+ }
22
+
23
+ return await localStorage.getItem(key, namespace);
24
+ };
25
+
26
+ export const shouldSkipHook = async (
27
+ skipHookIfKeysExist?: string
28
+ ): Promise<boolean> => {
29
+ if (!skipHookIfKeysExist?.trim()) {
30
+ log_info("shouldSkipHook: No skipping condition provided");
31
+
32
+ return false;
33
+ }
34
+
35
+ const keyEntries = parseKeyEntries(skipHookIfKeysExist);
36
+
37
+ if (keyEntries.length === 0) {
38
+ log_info("shouldSkipHook: No valid keys provided");
39
+
40
+ return false;
41
+ }
42
+
43
+ for (const entry of keyEntries) {
44
+ try {
45
+ const value = await getKeyToSkipHook(entry.key, entry.namespace);
46
+
47
+ if (value) {
48
+ log_info(
49
+ `shouldSkipHook: Hook will be skipped due to: ${
50
+ entry.namespace ?? ""
51
+ } ${entry.key}. Finishing hook flow`
52
+ );
53
+
54
+ return true;
55
+ }
56
+ } catch (error) {
57
+ log_error(
58
+ `shouldSkipHook: Error: ${error.message} checking key: ${
59
+ entry.namespace ?? ""
60
+ } ${entry.key}`,
61
+ { error }
62
+ );
63
+ }
64
+ }
65
+
66
+ log_info(
67
+ // eslint-disable-next-line max-len
68
+ "shouldSkipHook: No skipping condition met, none of the provided keys found in storage, proceeding with hook"
69
+ );
70
+
71
+ return false;
72
+ };
@@ -0,0 +1,13 @@
1
+ import * as React from "react";
2
+
3
+ type Props = {
4
+ children: React.ReactElement;
5
+ };
6
+
7
+ /**
8
+ * On native platforms the river `ComponentsMap` registers its own initial focus,
9
+ * so a hook-presented general content screen needs no extra focus wrapper here.
10
+ * The web counterpart (`index.web.tsx`) recreates the content focus group that
11
+ * the `River` wrapper would normally provide.
12
+ */
13
+ export const HookContentFocusGroup = ({ children }: Props) => <>{children}</>;
@@ -0,0 +1,69 @@
1
+ import * as React from "react";
2
+ import { StyleSheet } from "react-native";
3
+ import { shallow } from "zustand/shallow";
4
+
5
+ import { FocusableGroup } from "../../FocusableGroup";
6
+ import {
7
+ useContentId,
8
+ useNavbarId,
9
+ usePathname,
10
+ } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
11
+ import { useZappHookModalStore } from "../../../Contexts/ZappHookModalContext";
12
+
13
+ import { useInitialFocus } from "../../Screen/TV/hooks";
14
+
15
+ const styles = StyleSheet.create({
16
+ container: { flex: 1 },
17
+ });
18
+
19
+ type Props = {
20
+ children: React.ReactElement;
21
+ };
22
+
23
+ /**
24
+ * A general content screen presented as a full-screen hook is rendered straight
25
+ * through `ComponentsMap`, bypassing the web `River` wrapper. That wrapper is what
26
+ * normally creates the `quick-brick-content` FocusableGroup (with `preferredFocus`)
27
+ * the focus manager relies on and what lets initial focus land on the content.
28
+ *
29
+ * Without it the hook screen renders but nothing is focusable on web TV. This
30
+ * recreates that content group and triggers initial focus, mirroring `River`.
31
+ */
32
+ const FocusedHookContent = ({ children }: Props) => {
33
+ const contentId = useContentId();
34
+ const navbarId = useNavbarId();
35
+ const pathname = usePathname();
36
+
37
+ useInitialFocus();
38
+
39
+ return (
40
+ <FocusableGroup
41
+ id={contentId}
42
+ // Nest under the hook-modal route so the focus manager treats this as the
43
+ // active screen's content node; `useInitialFocus` targets the same route.
44
+ groupId={pathname}
45
+ nextFocusUp={navbarId}
46
+ preferredFocus
47
+ shouldUsePreferredFocus
48
+ style={styles.container}
49
+ >
50
+ {React.cloneElement(children, { groupId: contentId })}
51
+ </FocusableGroup>
52
+ );
53
+ };
54
+
55
+ export const HookContentFocusGroup = ({ children }: Props) => {
56
+ const isRunningInBackground = useZappHookModalStore(
57
+ (state) => state.isRunningInBackground,
58
+ shallow
59
+ );
60
+
61
+ // A hook presented full screen (either as a `/hooks/<id>` screen or a
62
+ // full-screen modal) needs the content focus group. Only background runs,
63
+ // which render invisibly, must be left alone so they don't steal focus.
64
+ if (isRunningInBackground) {
65
+ return <>{children}</>;
66
+ }
67
+
68
+ return <FocusedHookContent>{children}</FocusedHookContent>;
69
+ };
@@ -1 +1,3 @@
1
1
  export { GeneralContentScreen } from "./GeneralContentScreen";
2
+
3
+ export { GeneralContentScreenHookAdapter } from "./GeneralContentScreenHookAdapter";
@@ -6,28 +6,54 @@ import {
6
6
  describe("ActionButtonsCore placement", () => {
7
7
  const buttons = { type: "View", name: "buttons" };
8
8
 
9
- const above_labels = [
10
- { name: "above_label_1" },
11
- { name: "above_label_2" },
12
- { name: "above_label_3" },
9
+ const slots = [
10
+ { name: "text_label_1", element: { type: "View", id: "label_1" } },
11
+ { name: "text_label_2", element: { type: "View", id: "label_2" } },
12
+ { name: "text_label_3", element: { type: "View", id: "label_3" } },
13
13
  ];
14
14
 
15
- const below_labels = [
16
- { name: "below_label_1" },
17
- { name: "below_label_2" },
18
- { name: "below_label_3" },
19
- ];
15
+ const labels = slots.map((slot) => slot.element);
20
16
 
21
17
  it("inserts buttons after the matching label", () => {
22
18
  expect(
23
- insertBetweenLabels({ position: "below_label_2" }, buttons, below_labels)
24
- ).toEqual([below_labels[0], below_labels[1], buttons, below_labels[2]]);
19
+ insertBetweenLabels({ position: "below_text_label_2" }, buttons, slots)
20
+ ).toEqual([labels[0], labels[1], buttons, labels[2]]);
25
21
  });
26
22
 
27
23
  it("inserts buttons before the matching label", () => {
28
24
  expect(
29
- insertBetweenLabels({ position: "above_label_2" }, buttons, above_labels)
30
- ).toEqual([above_labels[0], buttons, above_labels[1], above_labels[2]]);
25
+ insertBetweenLabels({ position: "above_text_label_2" }, buttons, slots)
26
+ ).toEqual([labels[0], buttons, labels[1], labels[2]]);
27
+ });
28
+
29
+ it("inserts buttons after the matching label on a plain name match", () => {
30
+ expect(
31
+ insertBetweenLabels({ position: "text_label_2" }, buttons, slots)
32
+ ).toEqual([labels[0], labels[1], buttons, labels[2]]);
33
+ });
34
+
35
+ it("keeps the slot when its label is empty (null element)", () => {
36
+ const slotsWithEmpty = [
37
+ { name: "text_label_1", element: { id: "label_1" } },
38
+ { name: "text_label_2", element: null },
39
+ { name: "text_label_3", element: { id: "label_3" } },
40
+ ];
41
+
42
+ expect(
43
+ insertBetweenLabels(
44
+ { position: "above_text_label_2" },
45
+ buttons,
46
+ slotsWithEmpty
47
+ )
48
+ ).toEqual([{ id: "label_1" }, buttons, { id: "label_3" }]);
49
+
50
+ expect(
51
+ insertBetweenLabels(
52
+ { position: "below_text_label_2" },
53
+ buttons,
54
+ slotsWithEmpty
55
+ )
56
+ ).toEqual([{ id: "label_1" }, buttons, { id: "label_3" }]);
31
57
  });
32
58
 
33
59
  it("prepends buttons only when on_top is allowed", () => {
@@ -35,17 +61,17 @@ describe("ActionButtonsCore placement", () => {
35
61
  insertBetweenLabels(
36
62
  { position: "on_top", allowOnTop: true },
37
63
  buttons,
38
- below_labels
64
+ slots
39
65
  )
40
- ).toEqual([buttons, ...below_labels]);
66
+ ).toEqual([buttons, ...labels]);
41
67
 
42
68
  expect(
43
69
  insertBetweenLabels(
44
70
  { position: "on_top", allowOnTop: false },
45
71
  buttons,
46
- below_labels
72
+ slots
47
73
  )
48
- ).toEqual(below_labels);
74
+ ).toEqual(labels);
49
75
  });
50
76
 
51
77
  it("appends buttons when appendWhenMissing is enabled", () => {
@@ -53,9 +79,9 @@ describe("ActionButtonsCore placement", () => {
53
79
  insertBetweenLabels(
54
80
  { position: "unknown", appendWhenMissing: true },
55
81
  buttons,
56
- below_labels
82
+ slots
57
83
  )
58
- ).toEqual([...below_labels, buttons]);
84
+ ).toEqual([...labels, buttons]);
59
85
  });
60
86
 
61
87
  it("returns labels unchanged when appendWhenMissing is disabled", () => {
@@ -63,9 +89,9 @@ describe("ActionButtonsCore placement", () => {
63
89
  insertBetweenLabels(
64
90
  { position: "unknown", appendWhenMissing: false },
65
91
  buttons,
66
- below_labels
92
+ slots
67
93
  )
68
- ).toEqual(below_labels);
94
+ ).toEqual(labels);
69
95
  });
70
96
 
71
97
  const labelContainers = [
@@ -17,6 +17,11 @@ type InsertOptions = {
17
17
  appendWhenMissing?: boolean;
18
18
  };
19
19
 
20
+ type Slot = {
21
+ name: string;
22
+ element?: unknown;
23
+ };
24
+
20
25
  const hasLabelName = (value: unknown): value is Label =>
21
26
  !!value &&
22
27
  typeof value === "object" &&
@@ -100,8 +105,14 @@ const containsNestedLabel = (
100
105
  export const insertBetweenLabels = (
101
106
  { position, allowOnTop = false, appendWhenMissing = false }: InsertOptions,
102
107
  buttons: unknown,
103
- labels: Label[] = []
108
+ slots: Slot[] = []
104
109
  ) => {
110
+ // Slots are defined by the canonical label list, so an empty (null) label
111
+ // still keeps its position — buttons placed above/below it survive.
112
+ const labels = slots
113
+ .map((slot) => slot.element)
114
+ .filter((element) => element != null);
115
+
105
116
  if (buttons == null) {
106
117
  return labels;
107
118
  }
@@ -110,14 +121,31 @@ export const insertBetweenLabels = (
110
121
  return [buttons, ...labels];
111
122
  }
112
123
 
113
- const labelsWithButtons = withButtons(position, buttons, labels);
114
- const inserted = labelsWithButtons.length !== labels.length;
124
+ let inserted = false;
125
+ const result: unknown[] = [];
126
+
127
+ for (const { name, element } of slots) {
128
+ if (position === `above_${name}`) {
129
+ result.push(buttons);
130
+ inserted = true;
131
+ }
132
+
133
+ if (element != null) {
134
+ result.push(element);
135
+ }
136
+
137
+ // Insert after on `below_*` or a plain label-name match.
138
+ if (position === `below_${name}` || position === name) {
139
+ result.push(buttons);
140
+ inserted = true;
141
+ }
142
+ }
115
143
 
116
- if (!inserted && appendWhenMissing) {
117
- return [...labels, buttons];
144
+ if (!inserted) {
145
+ return appendWhenMissing ? [...labels, buttons] : labels;
118
146
  }
119
147
 
120
- return inserted ? labelsWithButtons : [...labels];
148
+ return result;
121
149
  };
122
150
 
123
151
  export const insertBetweenLabelContainers = (
@@ -1,13 +1,14 @@
1
- import React from "react";
1
+ import React, { PropsWithChildren } from "react";
2
2
  import { isVideoPreviewEnabled } from "@applicaster/zapp-react-native-ui-components/Components/MasterCell/utils";
3
3
  import { LiveImage } from "../LiveImage";
4
4
  import PureImage from "../Image";
5
5
  import { useIsScreenActive } from "@applicaster/zapp-react-native-utils/reactHooks";
6
6
 
7
- type Props = {
7
+ type Props = PropsWithChildren<{
8
8
  enable_video_preview: boolean;
9
9
  player_screen_id: string;
10
- };
10
+ uri?: string;
11
+ }>;
11
12
 
12
13
  export const ImageContainer = (props: Props) => {
13
14
  const isActive = useIsScreenActive();
@@ -1,9 +1,9 @@
1
1
  import React from "react";
2
- import { TouchableOpacity } from "react-native";
2
+ import { TouchableOpacity, ViewStyle } from "react-native";
3
3
 
4
4
  type Props = {
5
5
  children?: React.ReactNode;
6
- style?: Record<string, unknown>;
6
+ style?: ViewStyle | ViewStyle[];
7
7
  testID?: string;
8
8
  accessibilityLabel?: string;
9
9
  accessibilityHint?: string;
@@ -12,7 +12,7 @@ type Props = {
12
12
 
13
13
  export function PressableView({
14
14
  children,
15
- style = {},
15
+ style,
16
16
  testID,
17
17
  accessibilityLabel,
18
18
  accessibilityHint,
@@ -1,4 +1,5 @@
1
1
  import React from "react";
2
+ import { StyleSheet, View, ViewStyle } from "react-native";
2
3
  import { PressableView } from "../../PressableView";
3
4
 
4
5
  import { ActionButtonController } from "../../ActionButtonsCore/components";
@@ -15,6 +16,22 @@ type ChildElementProps = {
15
16
  entry?: any;
16
17
  };
17
18
 
19
+ const styles = StyleSheet.create({
20
+ pressableView: {
21
+ overflow: "hidden",
22
+ flexDirection: "row",
23
+ },
24
+ maxWidthFull: {
25
+ width: "100%",
26
+ },
27
+ innerWrapper: {
28
+ flexDirection: "row",
29
+ flexGrow: 0,
30
+ flexShrink: 1,
31
+ overflow: "hidden",
32
+ },
33
+ });
34
+
18
35
  const isValidElement = (
19
36
  child: React.ReactNode
20
37
  ): child is React.ReactElement<ChildElementProps> =>
@@ -121,12 +138,31 @@ export const ActionButton = ({ style, children, action, entry, ...props }) => {
121
138
  return (
122
139
  <PressableView
123
140
  testID={props.testID || `${entry?.id}`}
124
- style={isActive ? { ...style, ...props.focusedStyles } : style}
141
+ style={[
142
+ isActive
143
+ ? {
144
+ ...(style as ViewStyle),
145
+ ...(props.focusedStyles as ViewStyle),
146
+ }
147
+ : (style as ViewStyle),
148
+ styles.pressableView,
149
+ ]}
125
150
  onPress={onPress}
126
151
  accessibilityLabel={props.accessibilityLabel || `${entry?.id}`}
127
152
  accessibilityHint={props.accessibilityHint}
128
153
  >
129
- {_cloneChildrenWithState(children)}
154
+ <View
155
+ style={{
156
+ maxWidth: (style as ViewStyle).maxWidth,
157
+ ...((style as ViewStyle).maxWidth
158
+ ? styles.maxWidthFull
159
+ : undefined),
160
+ }}
161
+ >
162
+ <View style={[styles.innerWrapper, props.alignment]}>
163
+ {_cloneChildrenWithState(children)}
164
+ </View>
165
+ </View>
130
166
  </PressableView>
131
167
  );
132
168
  }}
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { View } from "react-native";
2
+ import { StyleSheet, View } from "react-native";
3
3
  import { ImageContainer } from "../../ImageContainer";
4
4
 
5
5
  type Props = {
@@ -10,13 +10,24 @@ type Props = {
10
10
  cellUUID?: string;
11
11
  };
12
12
 
13
+ const styles = StyleSheet.create({
14
+ assetContainer: {
15
+ flexShrink: 0,
16
+ justifyContent: "center",
17
+ alignItems: "center",
18
+ },
19
+ });
20
+
13
21
  export const AssetComponent = (props: Props & Record<string, unknown>) => {
14
22
  return props.asset && React.isValidElement(props.asset) ? (
15
- <View style={props.style} testID={props.testID}>
23
+ <View style={[styles.assetContainer, props.style]} testID={props.testID}>
16
24
  {React.cloneElement(props.asset, { cellUUID: props.cellUUID })}
17
25
  </View>
18
26
  ) : (
19
- // @ts-ignore
20
- <ImageContainer {...props} uri={props.uri} />
27
+ <ImageContainer
28
+ style={[styles.assetContainer, props.style]}
29
+ {...(props as any)}
30
+ uri={props.uri}
31
+ />
21
32
  );
22
33
  };
@@ -10,23 +10,33 @@ import {
10
10
  getPressableStyles,
11
11
  getTextLabelStyles,
12
12
  } from "./utils";
13
+ import { ViewStyle } from "react-native";
13
14
 
14
15
  const displayModeStyle = (value) => {
15
16
  const mode = value("display_mode") || "dynamic";
16
17
 
17
- if (mode === "fixed") {
18
- return {
19
- width: toNumberWithDefault(140, value("width")),
20
- };
21
- }
18
+ const defaultStyle = {
19
+ flexShrink: 1,
20
+ };
22
21
 
23
- if (mode === "fill") {
24
- return {
25
- flex: 1,
26
- };
22
+ switch (mode) {
23
+ case "fixed":
24
+ return {
25
+ ...defaultStyle,
26
+ width: toNumberWithDefault(140, value("width")),
27
+ maxWidth: toNumberWithDefault(140, value("width")),
28
+ };
29
+ case "fill":
30
+ return {
31
+ ...defaultStyle,
32
+ flex: 1,
33
+ };
34
+ case "dynamic":
35
+ default:
36
+ return {
37
+ ...defaultStyle,
38
+ };
27
39
  }
28
-
29
- return {};
30
40
  };
31
41
 
32
42
  type Props = {
@@ -34,7 +44,7 @@ type Props = {
34
44
  value: Function;
35
45
  stylePrefix: string;
36
46
  specificPrefix: string;
37
- spacingStyle: Record<string, unknown>;
47
+ spacingStyle: ViewStyle;
38
48
  };
39
49
 
40
50
  export const Button = ({
@@ -75,14 +85,17 @@ export const Button = ({
75
85
  type: "MobileActionButton",
76
86
  style: {
77
87
  flexDirection: getContentDirection(assetAlignment),
78
- alignContent: "center",
79
- alignItems: getContentsAlignment(contentsAlignment, assetAlignment),
80
- justifyContent: getContentsAlignment(contentsAlignment, assetAlignment),
88
+ // alignContent: "center", Why do we need this?
81
89
  ...getPressableStyles(getValue),
82
90
  ...displayModeStyle(getValue),
83
91
  ...spacingStyle,
84
92
  },
85
93
  additionalProps: {
94
+ alignment: {
95
+ alignContent: "center",
96
+ alignItems: getContentsAlignment(contentsAlignment, assetAlignment),
97
+ justifyContent: getContentsAlignment(contentsAlignment, assetAlignment),
98
+ },
86
99
  action: {
87
100
  identifier: actionIdentifier,
88
101
  flavour: actionAssetFlavour,
@@ -114,7 +127,8 @@ export const Button = ({
114
127
  color: getValue("focused_font_color"),
115
128
  },
116
129
  transformText: getValue("text_transform") || "default",
117
- numberOfLines: getValue("number_of_lines"),
130
+ numberOfLines: getValue("number_of_lines") || 1,
131
+ ellipseMode: "tail",
118
132
  },
119
133
  actionIdentifier,
120
134
  testID,
@@ -14,6 +14,9 @@ export const TextLabelsContainer = ({
14
14
  }: Props) => {
15
15
  return {
16
16
  type: "View",
17
+ style: {
18
+ flexShrink: 1,
19
+ },
17
20
  additionalProps: {
18
21
  mobileActionRole: "label_container",
19
22
  },
@@ -6,6 +6,7 @@ import {
6
6
  } from "./utils";
7
7
  import { Button } from "./Button";
8
8
  import { buildActionButtonsModel } from "../../ActionButtonsCore/model";
9
+ import { ViewStyle } from "react-native";
9
10
 
10
11
  const CONTAINER_PREFIX = "mobile_buttons_container";
11
12
  const BUTTON_PREFIX = "mobile_button";
@@ -81,7 +82,7 @@ export const MobileActionButtons = ({
81
82
  const isVertical = stacking === "vertical";
82
83
  const gutter = isVertical ? verticalGutter : horizontalGutter;
83
84
 
84
- const spacingStyle = {
85
+ const spacingStyle: ViewStyle = {
85
86
  [isVertical ? "marginBottom" : "marginRight"]: isNotLast ? gutter : 0,
86
87
  };
87
88
 
@@ -5,14 +5,19 @@ import {
5
5
  } from "..";
6
6
 
7
7
  describe("mobile action insertion helpers", () => {
8
- const labels = [{ name: "text_label_1" }, { name: "text_label_2" }];
8
+ const slots = [
9
+ { name: "text_label_1", element: { type: "View", id: "text_label_1" } },
10
+ { name: "text_label_2", element: { type: "View", id: "text_label_2" } },
11
+ ];
12
+
13
+ const labels = slots.map((slot) => slot.element);
9
14
  const buttons = { type: "View", name: "buttons" };
10
15
 
11
16
  it("inserts label buttons below target label", () => {
12
17
  const result = insertButtonsBetweenLabels(
13
18
  { mobile_buttons_container_position: "below_text_label_1" },
14
19
  buttons,
15
- labels
20
+ slots
16
21
  );
17
22
 
18
23
  expect(result).toEqual([labels[0], buttons, labels[1]]);
@@ -22,7 +27,7 @@ describe("mobile action insertion helpers", () => {
22
27
  const result = insertButtonsBetweenLabels(
23
28
  { mobile_buttons_container_position: "unknown" },
24
29
  buttons,
25
- labels
30
+ slots
26
31
  );
27
32
 
28
33
  expect(result).toEqual([labels[0], labels[1]]);
@@ -8,7 +8,7 @@ import { Platform } from "react-native";
8
8
  export const insertButtonsBetweenLabels = (
9
9
  configuration: Record<string, unknown>,
10
10
  buttons,
11
- labels = []
11
+ slots = [] // { name, element } per canonical text label slot
12
12
  ) =>
13
13
  insertBetweenLabels(
14
14
  {
@@ -19,7 +19,7 @@ export const insertButtonsBetweenLabels = (
19
19
  appendWhenMissing: false,
20
20
  },
21
21
  buttons,
22
- labels // "text_label_1", "text_label_2", "text_label_3", "text_label_4"
22
+ slots
23
23
  );
24
24
 
25
25
  export const insertButtonsBetweenLabelContainers = (