@applicaster/zapp-react-native-ui-components 16.0.0-alpha.1151561937 → 16.0.0-alpha.1180700101

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 (34) hide show
  1. package/Components/Cell/Cell.tsx +3 -6
  2. package/Components/Cell/TvOSCellComponent.tsx +0 -1
  3. package/Components/GeneralContentScreen/hookAdapter/__tests__/skipExpression.test.ts +294 -0
  4. package/Components/GeneralContentScreen/hookAdapter/__tests__/validationHelper.test.ts +64 -0
  5. package/Components/GeneralContentScreen/hookAdapter/skipExpression.ts +252 -0
  6. package/Components/GeneralContentScreen/hookAdapter/validationHelper.ts +18 -0
  7. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +1 -0
  8. package/Components/MasterCell/DefaultComponents/Button.tsx +1 -0
  9. package/Components/MasterCell/DefaultComponents/Toggle.tsx +1 -8
  10. package/Components/MasterCell/DefaultComponents/__tests__/Toggle.test.tsx +10 -6
  11. package/Components/ModalComponent/ActionsBottomSheet/ActionButton.tsx +54 -0
  12. package/Components/ModalComponent/ActionsBottomSheet/boundActionButton.tsx +21 -0
  13. package/Components/ModalComponent/ActionsBottomSheet/index.ts +9 -0
  14. package/Components/ModalComponent/ActionsBottomSheet/openActionsBottomSheet.ts +58 -0
  15. package/Components/ModalComponent/AudioPlayer/Components/Button.tsx +15 -3
  16. package/Components/ModalComponent/AudioPlayer/Components/Item.tsx +91 -5
  17. package/Components/ModalComponent/AudioPlayer/utils/__tests__/mergeStyles.test.ts +230 -0
  18. package/Components/ModalComponent/AudioPlayer/utils/mergeStyles.ts +151 -18
  19. package/Components/ModalComponent/Header/CloseButton.tsx +12 -0
  20. package/Components/ModalComponent/Header/__tests__/CloseButton.test.tsx +72 -0
  21. package/Components/ModalComponent/SortableList.web.tsx +2 -70
  22. package/Components/ModalComponent/__tests__/SortableList.web.test.tsx +16 -0
  23. package/Components/ModalComponent/presets/dynamicCollectionCell.tsx +1 -1
  24. package/Components/ModalComponent/utils.ts +6 -1
  25. package/Components/OfflineHandler/hooks.ts +0 -12
  26. package/Components/River/ComponentsMap/ComponentsMap.tsx +78 -51
  27. package/Components/River/River.tsx +4 -0
  28. package/Components/River/__tests__/resultCallback.test.tsx +47 -0
  29. package/Components/ScreenRevealManager/ScreenRevealManager.ts +18 -2
  30. package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +36 -0
  31. package/Components/ScreenRevealManager/__tests__/withScreenRevealManager.test.tsx +56 -0
  32. package/Components/ScreenRevealManager/withScreenRevealManager.tsx +20 -3
  33. package/Hooks/useEntryActionsExpander.ts +63 -0
  34. package/package.json +5 -5
@@ -91,6 +91,7 @@ function ButtonComponent(props: Props) {
91
91
  onPress={onPress}
92
92
  testID={props?.testID || `${item?.id}`}
93
93
  accessibilityLabel={props?.accessibilityLabel || `${item?.id}`}
94
+ accessibilityRole="button"
94
95
  accessible={!!(props?.testID || props?.accessibilityLabel)}
95
96
  style={props?.style}
96
97
  >
@@ -16,13 +16,7 @@ type Props = {
16
16
  export const Toggle = (props: Props) => {
17
17
  const { style, item, action, cellState } = props;
18
18
 
19
- const {
20
- trackColor,
21
- trackColorActive,
22
- thumbColor,
23
- thumbColorActive,
24
- iosBackgroundColor,
25
- } = style;
19
+ const { trackColor, trackColorActive, thumbColor, thumbColorActive } = style;
26
20
 
27
21
  // `focused_selected` is the selected state with a finger on the row, so the
28
22
  // switch has to read as on for both. Leaving it out reads a pressed selected
@@ -73,7 +67,6 @@ export const Toggle = (props: Props) => {
73
67
  <Switch
74
68
  trackColor={{ false: trackColor, true: trackColorActive }}
75
69
  thumbColor={isSelected ? thumbColorActive : thumbColor}
76
- ios_backgroundColor={iosBackgroundColor}
77
70
  onValueChange={onPress}
78
71
  value={isSelected}
79
72
  />
@@ -25,7 +25,6 @@ const style = {
25
25
  trackColorActive: "rgba(4,207,153,1)",
26
26
  thumbColor: "rgba(255,255,255,1)",
27
27
  thumbColorActive: "rgba(255,255,255,1)",
28
- iosBackgroundColor: "rgba(0,0,0,1)",
29
28
  } as any;
30
29
 
31
30
  const item = { id: "true", title: "I agree" } as any;
@@ -87,10 +86,6 @@ describe("Toggle with an empty action identifier", () => {
87
86
  expect(mockInitialEntryState).not.toHaveBeenCalled();
88
87
  });
89
88
 
90
- // ios_backgroundColor paints behind the track, so trackColor does not cover
91
- // it and it has to be forwarded on its own. It was dropped once while the
92
- // destructure feeding it was being reformatted, and nothing caught that.
93
- //
94
89
  // Asserted on the Switch element rather than the rendered host component:
95
90
  // what Toggle owns is the props it hands to Switch, and React Native rewrites
96
91
  // them into platform-specific ones (tintColor, a style entry) underneath.
@@ -100,9 +95,18 @@ describe("Toggle with an empty action identifier", () => {
100
95
  expect(UNSAFE_getByType(Switch).props).toMatchObject({
101
96
  trackColor: { false: style.trackColor, true: style.trackColorActive },
102
97
  thumbColor: style.thumbColor,
103
- ios_backgroundColor: style.iosBackgroundColor,
104
98
  });
105
99
  });
100
+
101
+ // ios_backgroundColor paints an opaque layer behind the track that the track
102
+ // color cannot cover, which on iOS reads as a halo around the switch. The
103
+ // switch is left on its platform default instead, so the prop must stay
104
+ // unset even if a style happens to carry a color for it.
105
+ it("does not set an iOS background color on the switch", () => {
106
+ const { UNSAFE_getByType } = renderToggle("", "default");
107
+
108
+ expect(UNSAFE_getByType(Switch).props.ios_backgroundColor).toBeUndefined();
109
+ });
106
110
  });
107
111
 
108
112
  describe("Toggle with an action plugin identifier", () => {
@@ -0,0 +1,54 @@
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
+ };
16
+
17
+ type Props = ActionButtonProps & {
18
+ onPress?: (item: any) => void;
19
+ };
20
+
21
+ /**
22
+ * Unified action button for the modal bottom sheet.
23
+ *
24
+ * Every item is a `RegisteredAction` resolved from the registry (entry actions,
25
+ * registry actions and legacy context-provider actions alike), so the button
26
+ * simply reads `item.action` and drives it through `useEntryActionState`
27
+ * (backed by the action's observable / `addListener`).
28
+ */
29
+ export function ActionButton(props: Props) {
30
+ const { item, entry, onPress: onItemPress } = props;
31
+
32
+ const action = item?.action;
33
+
34
+ const { state, invokeAction } = useEntryActionState(action, entry);
35
+
36
+ const onPress = React.useCallback(
37
+ (_item) => {
38
+ invokeAction({
39
+ context: "toast",
40
+ dismiss: () => onItemPress?.(item),
41
+ });
42
+ },
43
+ [invokeAction, item, onItemPress]
44
+ );
45
+
46
+ if (!isActionAvailableFor(action, entry as ZappEntry)) return null;
47
+
48
+ return (
49
+ <Button {...props} item={state} onPress={onPress} label={state?.label} />
50
+ );
51
+ }
52
+
53
+ // Explicitly set display name for the component
54
+ ActionButton.displayName = "ActionButton";
@@ -0,0 +1,21 @@
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 = (entry: ZappEntry | ZappFeed) => {
12
+ const ActionButtonWithEntry = (props: ActionButtonProps) => (
13
+ <ActionButton {...props} entry={entry as ZappEntry} />
14
+ );
15
+
16
+ ActionButtonWithEntry.displayName = "ActionButtonWithEntry";
17
+
18
+ return ActionButtonWithEntry;
19
+ };
20
+
21
+ 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,58 @@
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
+ };
21
+
22
+ /**
23
+ * Presents a list of resolved actions in the shared bottom sheet.
24
+ *
25
+ * This is the core entry point for "show these actions in a sheet": the
26
+ * open-modal-bottom-sheet plugin uses it for its configured list, and the
27
+ * player overflow uses it for the actions that did not fit on the overlay.
28
+ * Neither has to know about the other, and neither needs the plugin installed.
29
+ */
30
+ export function openActionsBottomSheet({
31
+ entry,
32
+ actions,
33
+ title,
34
+ summary,
35
+ }: OpenActionsBottomSheetArgs): void {
36
+ if (!actions?.length) {
37
+ // Every action resolved away - unavailable for this entry, or not
38
+ // invokable. An empty sheet looks broken, so say why and stay put.
39
+ log_warning(
40
+ "openActionsBottomSheet: nothing to present - not opening the sheet",
41
+ { entryId: (entry as ZappEntry)?.id }
42
+ );
43
+
44
+ return;
45
+ }
46
+
47
+ openBottomSheetModal({
48
+ modalBottomSheetContentProps: {
49
+ // TODO: should be optional - the button handles its own tap, but
50
+ // BottomSheetModalContent still requires an onPress.
51
+ onPress: noop,
52
+ items: actions,
53
+ buttonComponent: boundActionButton(entry),
54
+ title,
55
+ summary,
56
+ },
57
+ });
58
+ }
@@ -81,6 +81,8 @@ export type LeadingIconConfiguration = {
81
81
  enabled: boolean;
82
82
  /** Decides which icon will be displayed when enabled */
83
83
  actionType?: ButtonActionType;
84
+ /** Optional Studio / modal-blocks asset URI (overrides actionType mapping) */
85
+ asset?: string;
84
86
  };
85
87
 
86
88
  export type IconsConfiguration = {
@@ -170,7 +172,9 @@ function getTextTransformStyle(
170
172
  }
171
173
 
172
174
  function shouldShowLeadingIcon(leadingIcon: LeadingIconConfiguration) {
173
- return leadingIcon.enabled && !!leadingIcon.actionType;
175
+ return (
176
+ leadingIcon.enabled && (!!leadingIcon.actionType || !!leadingIcon.asset)
177
+ );
174
178
  }
175
179
 
176
180
  // ---------------------------------------------------------------------------
@@ -268,7 +272,7 @@ function ButtonTitle({
268
272
  }
269
273
 
270
274
  type ButtonLeadingIconProps = {
271
- actionType: ButtonActionType;
275
+ actionType?: ButtonActionType;
272
276
  configuration: IconsConfiguration;
273
277
  };
274
278
 
@@ -276,9 +280,17 @@ function ButtonLeadingIcon({
276
280
  actionType,
277
281
  configuration,
278
282
  }: ButtonLeadingIconProps) {
283
+ const asset =
284
+ configuration.leadingIcon.asset ||
285
+ (actionType ? ACTION_ICON_ASSETS[actionType] : undefined);
286
+
287
+ if (!asset) {
288
+ return null;
289
+ }
290
+
279
291
  return (
280
292
  <Image
281
- source={{ uri: ACTION_ICON_ASSETS[actionType] }}
293
+ source={{ uri: asset }}
282
294
  style={{
283
295
  width: configuration.width,
284
296
  height: configuration.height,
@@ -56,6 +56,10 @@ export type BackgroundConfiguration = {
56
56
  defaultColor: string;
57
57
  focusedColor: string;
58
58
  cornerRadius: number;
59
+ paddingTop?: number;
60
+ paddingRight?: number;
61
+ paddingBottom?: number;
62
+ paddingLeft?: number;
59
63
  };
60
64
 
61
65
  export type ImageConfiguration = {
@@ -82,6 +86,20 @@ export type NowPlayingAssetConfiguration = {
82
86
  asset?: string;
83
87
  };
84
88
 
89
+ export type CheckboxAssetsConfiguration = {
90
+ /** Unchecked multiSelect control (item.checkbox_asset). */
91
+ asset?: string;
92
+ /** Checked multiSelect control (item.checked_checkbox_asset). */
93
+ checkedAsset?: string;
94
+ };
95
+
96
+ export type ActionButtonAssetsConfiguration = {
97
+ /** Leading remove control on Edit Order rows. */
98
+ removeAsset?: string;
99
+ /** Trailing drag handle on Edit Order / queue rows. */
100
+ dragAsset?: string;
101
+ };
102
+
85
103
  export type ItemConfiguration = {
86
104
  background: BackgroundConfiguration;
87
105
  image: ImageConfiguration;
@@ -89,6 +107,8 @@ export type ItemConfiguration = {
89
107
  nowPlayingLabel: LabelConfiguration;
90
108
  textLabel1: LabelConfiguration;
91
109
  textLabel2: LabelConfiguration;
110
+ checkboxAssets?: CheckboxAssetsConfiguration;
111
+ actionButtonAssets?: ActionButtonAssetsConfiguration;
92
112
  };
93
113
 
94
114
  export const DEFAULT_TEXT_LABEL_1_CONFIGURATION: LabelConfiguration = {
@@ -301,10 +321,13 @@ export function mapMenuItemToPlaylistData(
301
321
  const showSelectionWidget =
302
322
  behavior?.selectMode !== "none" && item.trailingButton !== "none";
303
323
 
324
+ const summary =
325
+ typeof item.summary === "string" ? item.summary.trim() : item.summary;
326
+
304
327
  return {
305
328
  imageUri: item.icon,
306
329
  textLabel1: item.title,
307
- textLabel2: item.summary ?? "",
330
+ textLabel2: summary || "",
308
331
  trailingButton: showSelectionWidget
309
332
  ? item.trailingButton || ("multiSelect" as ItemButtonAction)
310
333
  : undefined,
@@ -340,10 +363,10 @@ function ItemContainer({
340
363
  style={({ pressed }) => ({
341
364
  backgroundColor: pressed ? background.focusedColor : bg,
342
365
  borderRadius: background.cornerRadius,
343
- paddingTop: container.paddingTop,
344
- paddingRight: container.paddingRight,
345
- paddingBottom: container.paddingBottom,
346
- paddingLeft: container.paddingLeft,
366
+ paddingTop: background.paddingTop ?? container.paddingTop,
367
+ paddingRight: background.paddingRight ?? container.paddingRight,
368
+ paddingBottom: background.paddingBottom ?? container.paddingBottom,
369
+ paddingLeft: background.paddingLeft ?? container.paddingLeft,
347
370
  })}
348
371
  >
349
372
  {children}
@@ -450,6 +473,8 @@ type ItemButtonProps = {
450
473
  focused?: boolean;
451
474
  onPress?: () => void;
452
475
  isSelected?: boolean;
476
+ checkboxAssets?: CheckboxAssetsConfiguration;
477
+ actionButtonAssets?: ActionButtonAssetsConfiguration;
453
478
  };
454
479
 
455
480
  function ItemButton({
@@ -457,6 +482,8 @@ function ItemButton({
457
482
  focused = false,
458
483
  onPress,
459
484
  isSelected = false,
485
+ checkboxAssets,
486
+ actionButtonAssets,
460
487
  }: ItemButtonProps) {
461
488
  const layout = BUTTON_LAYOUT_SPEC[action];
462
489
 
@@ -531,6 +558,19 @@ function ItemButton({
531
558
  }
532
559
 
533
560
  case "drag": {
561
+ if (actionButtonAssets?.dragAsset) {
562
+ return (
563
+ <Image
564
+ source={{ uri: actionButtonAssets.dragAsset }}
565
+ style={{
566
+ width: layout.assetWidth,
567
+ height: layout.assetHeight,
568
+ }}
569
+ resizeMode="contain"
570
+ />
571
+ );
572
+ }
573
+
534
574
  return (
535
575
  <View
536
576
  style={{
@@ -565,6 +605,19 @@ function ItemButton({
565
605
  }
566
606
 
567
607
  case "remove": {
608
+ if (actionButtonAssets?.removeAsset) {
609
+ return (
610
+ <Image
611
+ source={{ uri: actionButtonAssets.removeAsset }}
612
+ style={{
613
+ width: layout.assetWidth,
614
+ height: layout.assetHeight,
615
+ }}
616
+ resizeMode="contain"
617
+ />
618
+ );
619
+ }
620
+
568
621
  return (
569
622
  <View
570
623
  style={{
@@ -590,6 +643,23 @@ function ItemButton({
590
643
  }
591
644
 
592
645
  case "multiSelect": {
646
+ const studioAsset = isSelected
647
+ ? checkboxAssets?.checkedAsset
648
+ : checkboxAssets?.asset;
649
+
650
+ if (studioAsset) {
651
+ return (
652
+ <Image
653
+ source={{ uri: studioAsset }}
654
+ style={{
655
+ width: layout.assetWidth,
656
+ height: layout.assetHeight,
657
+ }}
658
+ resizeMode="contain"
659
+ />
660
+ );
661
+ }
662
+
593
663
  if (!isSelected) {
594
664
  return (
595
665
  <View
@@ -666,6 +736,8 @@ type ItemButtonsProps = {
666
736
  onTrailingButtonPress?: () => void;
667
737
  isSelected?: boolean;
668
738
  renderHandle?: (element: React.ReactElement) => React.ReactElement;
739
+ checkboxAssets?: CheckboxAssetsConfiguration;
740
+ actionButtonAssets?: ActionButtonAssetsConfiguration;
669
741
  };
670
742
 
671
743
  function ItemButtons({
@@ -677,6 +749,8 @@ function ItemButtons({
677
749
  onTrailingButtonPress,
678
750
  isSelected = false,
679
751
  renderHandle,
752
+ checkboxAssets,
753
+ actionButtonAssets,
680
754
  }: ItemButtonsProps) {
681
755
  if (!leadingButton && !trailingButton) {
682
756
  return null;
@@ -691,6 +765,8 @@ function ItemButtons({
691
765
  focused={focusedLeadingButton}
692
766
  onPress={onLeadingButtonPress}
693
767
  isSelected={isSelected}
768
+ checkboxAssets={checkboxAssets}
769
+ actionButtonAssets={actionButtonAssets}
694
770
  />
695
771
  <View style={{ width: BUTTONS_CONTAINER_HORIZONTAL_GUTTER }} />
696
772
  </>
@@ -704,6 +780,8 @@ function ItemButtons({
704
780
  focused={focusedTrailingButton}
705
781
  onPress={onTrailingButtonPress}
706
782
  isSelected={isSelected}
783
+ checkboxAssets={checkboxAssets}
784
+ actionButtonAssets={actionButtonAssets}
707
785
  />
708
786
  )
709
787
  ) : (
@@ -712,6 +790,8 @@ function ItemButtons({
712
790
  focused={focusedTrailingButton}
713
791
  onPress={onTrailingButtonPress}
714
792
  isSelected={isSelected}
793
+ checkboxAssets={checkboxAssets}
794
+ actionButtonAssets={actionButtonAssets}
715
795
  />
716
796
  )
717
797
  ) : (
@@ -720,6 +800,8 @@ function ItemButtons({
720
800
  focused={focusedTrailingButton}
721
801
  onPress={onTrailingButtonPress}
722
802
  isSelected={isSelected}
803
+ checkboxAssets={checkboxAssets}
804
+ actionButtonAssets={actionButtonAssets}
723
805
  />
724
806
  )
725
807
  ) : null}
@@ -761,6 +843,8 @@ export function AudioPlayerTrackItem({
761
843
  textLabel2,
762
844
  nowPlayingLabel,
763
845
  nowPlayingAsset,
846
+ checkboxAssets,
847
+ actionButtonAssets,
764
848
  } = effectiveConfig;
765
849
 
766
850
  const container = resolveContainerSpec(image);
@@ -803,6 +887,8 @@ export function AudioPlayerTrackItem({
803
887
  onTrailingButtonPress={onTrailingButtonPress}
804
888
  isSelected={data.isSelected}
805
889
  renderHandle={renderHandle}
890
+ checkboxAssets={checkboxAssets}
891
+ actionButtonAssets={actionButtonAssets}
806
892
  />
807
893
  </View>
808
894
  </ItemContainer>