@applicaster/zapp-react-native-ui-components 16.0.0-rc.4 → 16.0.0-rc.41
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.
- package/Components/BackgroundImage/BackgroundImage.android.tv.tsx +28 -0
- package/Components/BackgroundImage/BackgroundImage.ios.tv.tsx +24 -0
- package/Components/BackgroundImage/BackgroundImage.tsx +42 -0
- package/Components/BackgroundImage/index.ts +1 -0
- package/Components/CellRendererResolver/index.ts +2 -2
- package/Components/ComponentResolver/__tests__/componentResolver.test.js +1 -1
- package/Components/FocusableGroup/FocusableTvOS.tsx +11 -7
- package/Components/GeneralContentScreen/GeneralContentScreenHookAdapter.tsx +39 -0
- package/Components/GeneralContentScreen/__tests__/GeneralContentScreenHookAdapter.test.tsx +64 -0
- package/Components/GeneralContentScreen/__tests__/HookContentFocusGroup.web.test.tsx +91 -0
- package/Components/GeneralContentScreen/hookAdapter/__tests__/networkService.test.ts +74 -0
- package/Components/GeneralContentScreen/hookAdapter/__tests__/runInBackground.test.ts +139 -0
- package/Components/GeneralContentScreen/hookAdapter/__tests__/validationHelper.test.ts +124 -0
- package/Components/GeneralContentScreen/hookAdapter/logger.ts +6 -0
- package/Components/GeneralContentScreen/hookAdapter/networkService.ts +53 -0
- package/Components/GeneralContentScreen/hookAdapter/runInBackground.ts +48 -0
- package/Components/GeneralContentScreen/hookAdapter/validationHelper.ts +72 -0
- package/Components/GeneralContentScreen/hookFocus/index.tsx +13 -0
- package/Components/GeneralContentScreen/hookFocus/index.web.tsx +69 -0
- package/Components/GeneralContentScreen/index.ts +2 -0
- package/Components/Layout/FullWidthRow.tsx +38 -0
- package/Components/Layout/TV/ScreenContainer.tsx +5 -0
- package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +0 -1
- package/Components/Layout/TV/index.tsx +3 -4
- package/Components/Layout/TV/index.web.tsx +2 -3
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +16 -5
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/placement.test.ts +47 -21
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/placement.ts +34 -6
- package/Components/MasterCell/DefaultComponents/ButtonContainerView/index.tsx +1 -1
- package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -3
- package/Components/MasterCell/DefaultComponents/PressableView.tsx +29 -9
- package/Components/MasterCell/DefaultComponents/Text/hooks/useText.ts +4 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/ActionButton.tsx +154 -100
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/AssetComponent.tsx +15 -4
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Button.ts +56 -22
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Spacer.ts +6 -4
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/TextLabelsContainer.ts +3 -1
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/PressableView.test.tsx +32 -21
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/index.test.ts +15 -4
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/index.ts +23 -16
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/__tests__/insertButtons.test.ts +8 -3
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/index.ts +2 -2
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/__tests__/insertButtonsBetweenLabels.test.ts +45 -13
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/index.ts +2 -2
- package/Components/MasterCell/contexts/PressedStateContext.ts +3 -0
- package/Components/MasterCell/dataAdapter.ts +15 -5
- package/Components/MasterCell/hooks/index.ts +2 -0
- package/Components/MasterCell/hooks/usePressedState.ts +4 -0
- package/Components/MasterCell/index.tsx +30 -5
- package/Components/MasterCell/utils/__tests__/resolveColor.test.js +169 -132
- package/Components/MasterCell/utils/__tests__/resolveColorForProp.test.js +92 -0
- package/Components/MasterCell/utils/index.ts +85 -46
- package/Components/ModalComponent/AudioPlayer/Components/Action.tsx +332 -0
- package/Components/ModalComponent/AudioPlayer/Components/Button.tsx +402 -0
- package/Components/ModalComponent/AudioPlayer/Components/Header.tsx +811 -0
- package/Components/ModalComponent/AudioPlayer/Components/Input.tsx +671 -0
- package/Components/ModalComponent/AudioPlayer/Components/Item.tsx +878 -0
- package/Components/ModalComponent/AudioPlayer/Components/index.ts +9 -0
- package/Components/ModalComponent/BottomSheetModalContent.tsx +34 -18
- package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +4 -85
- package/Components/OfflineHandler/__tests__/index.test.tsx +78 -18
- package/Components/OfflineHandler/hooks.ts +123 -0
- package/Components/OfflineHandler/index.tsx +51 -73
- package/Components/OfflineHandler/utils/index.ts +1 -13
- package/Components/PlayerContainer/PlayerContainer.tsx +14 -10
- package/Components/PlayerContainer/__tests__/PlayerContainer.test.tsx +284 -0
- package/Components/PreloaderWrapper/index.tsx +1 -1
- package/Components/River/ComponentsMap/ComponentsMap.tsx +2 -2
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +3 -15
- package/Components/Screen/TV/hooks/__tests__/useAfterPaint.test.ts +60 -0
- package/Components/Screen/TV/hooks/index.ts +2 -0
- package/Components/Screen/TV/hooks/useAfterPaint.ts +23 -0
- package/Components/Screen/TV/index.web.tsx +16 -7
- package/Components/Screen/index.tsx +8 -4
- package/Components/ScreenFeedLoader/ScreenFeedLoader.tsx +5 -3
- package/Components/ScreenResolverFeedProvider/ScreenResolverFeedProvider.tsx +1 -1
- package/Components/ScreenRevealManager/Overlay.tsx +34 -0
- package/Components/ScreenRevealManager/__tests__/Overlay.test.tsx +88 -0
- package/Components/ScreenRevealManager/withScreenRevealManager.tsx +8 -19
- package/Components/TopCutoffOverlay/index.tsx +2 -2
- package/Components/Transitioner/Transitioner.tsx +28 -17
- package/Components/VideoLive/LiveImageManager.ts +56 -45
- package/Components/VideoLive/PlayerLiveImageComponent.tsx +4 -2
- package/Components/VideoModal/utils.ts +6 -1
- package/Components/ZappFrameworkComponents/BarView/BarView.tsx +12 -5
- package/Components/ZappFrameworkComponents/BarView/__tests__/BarView.test.tsx +2 -2
- package/Contexts/CachedDimensionsContext/__tests__/index.test.ts +154 -0
- package/Contexts/CachedDimensionsContext/index.ts +17 -2
- package/Helpers/ComponentCellSelectionHelper/index.js +0 -6
- package/Helpers/index.js +7 -40
- package/package.json +5 -5
- package/Components/Layout/TV/LayoutBackground.tsx +0 -31
- package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +0 -112
- package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +0 -107
- package/Components/OfflineHandler/NotificationView/NotificationView.tsx +0 -153
- package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +0 -66
- package/Components/OfflineHandler/NotificationView/utils.ts +0 -34
- package/Components/Screen/utils.ts +0 -16
- package/Helpers/Analytics/index.js +0 -95
- /package/Components/MasterCell/DefaultComponents/ButtonContainerView/{index.tv.android.tsx → index.android.tv.tsx} +0 -0
|
@@ -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
|
-
|
|
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
|
-
|
|
114
|
-
const
|
|
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
|
|
117
|
-
return [...labels, buttons];
|
|
144
|
+
if (!inserted) {
|
|
145
|
+
return appendWhenMissing ? [...labels, buttons] : labels;
|
|
118
146
|
}
|
|
119
147
|
|
|
120
|
-
return
|
|
148
|
+
return result;
|
|
121
149
|
};
|
|
122
150
|
|
|
123
151
|
export const insertBetweenLabelContainers = (
|
|
@@ -1,13 +1,15 @@
|
|
|
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
|
+
[key: string]: any;
|
|
12
|
+
}>;
|
|
11
13
|
|
|
12
14
|
export const ImageContainer = (props: Props) => {
|
|
13
15
|
const isActive = useIsScreenActive();
|
|
@@ -1,34 +1,54 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import {
|
|
1
|
+
import React, { useCallback } from "react";
|
|
2
|
+
import { Pressable, ViewStyle } from "react-native";
|
|
3
|
+
import { PressedStateContext } from "../contexts/PressedStateContext";
|
|
3
4
|
|
|
4
5
|
type Props = {
|
|
5
6
|
children?: React.ReactNode;
|
|
6
|
-
style?:
|
|
7
|
+
style?: ViewStyle | ViewStyle[];
|
|
8
|
+
pressedStyle?: ViewStyle | ViewStyle[];
|
|
7
9
|
testID?: string;
|
|
8
10
|
accessibilityLabel?: string;
|
|
9
11
|
accessibilityHint?: string;
|
|
10
12
|
onPress?: () => void;
|
|
13
|
+
testOnly_pressed?: boolean;
|
|
11
14
|
};
|
|
12
15
|
|
|
13
16
|
export function PressableView({
|
|
14
17
|
children,
|
|
15
|
-
style
|
|
18
|
+
style,
|
|
16
19
|
testID,
|
|
17
20
|
accessibilityLabel,
|
|
18
21
|
accessibilityHint,
|
|
22
|
+
pressedStyle,
|
|
19
23
|
onPress,
|
|
24
|
+
testOnly_pressed = false,
|
|
20
25
|
}: Props) {
|
|
21
26
|
return (
|
|
22
|
-
<
|
|
23
|
-
|
|
27
|
+
<Pressable
|
|
28
|
+
testOnly_pressed={testOnly_pressed}
|
|
24
29
|
onPress={onPress}
|
|
25
30
|
testID={testID}
|
|
26
31
|
accessibilityLabel={accessibilityLabel}
|
|
27
32
|
accessibilityHint={accessibilityHint}
|
|
28
33
|
accessible={!!(testID || accessibilityLabel)}
|
|
29
|
-
style={
|
|
34
|
+
style={useCallback(
|
|
35
|
+
({ pressed }) => [
|
|
36
|
+
style,
|
|
37
|
+
pressed && {
|
|
38
|
+
opacity: 1,
|
|
39
|
+
},
|
|
40
|
+
pressed && pressedStyle,
|
|
41
|
+
],
|
|
42
|
+
[style, pressedStyle]
|
|
43
|
+
)}
|
|
30
44
|
>
|
|
31
|
-
{
|
|
32
|
-
|
|
45
|
+
{({ pressed }) => {
|
|
46
|
+
return (
|
|
47
|
+
<PressedStateContext.Provider value={pressed}>
|
|
48
|
+
{children}
|
|
49
|
+
</PressedStateContext.Provider>
|
|
50
|
+
);
|
|
51
|
+
}}
|
|
52
|
+
</Pressable>
|
|
33
53
|
);
|
|
34
54
|
}
|
|
@@ -83,6 +83,10 @@ export const useTextLabel = ({ label, entry }): string => {
|
|
|
83
83
|
return prepareHebrewText(label, isRTL);
|
|
84
84
|
};
|
|
85
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Uses `otherProps.state` ("focused" | "default") to select between `focusedStyles` and `normalStyles`.
|
|
88
|
+
* For mobile action buttons, map `usePressedState()` (boolean) to this state value (e.g. pressed ? "focused" : "default").
|
|
89
|
+
*/
|
|
86
90
|
export const withFocusedStyles = ({ style, otherProps }) => {
|
|
87
91
|
const state = R.path(["state"], otherProps);
|
|
88
92
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useCallback } from "react";
|
|
2
2
|
import { PressableView } from "../../PressableView";
|
|
3
|
+
import { usePressedState } from "../../../hooks";
|
|
3
4
|
|
|
4
5
|
import { ActionButtonController } from "../../ActionButtonsCore/components";
|
|
5
6
|
|
|
@@ -20,7 +21,137 @@ const isValidElement = (
|
|
|
20
21
|
): child is React.ReactElement<ChildElementProps> =>
|
|
21
22
|
React.isValidElement(child);
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
type ActionButtonContentProps = {
|
|
25
|
+
style: any;
|
|
26
|
+
children: React.ReactNode;
|
|
27
|
+
action: any;
|
|
28
|
+
focusedStyles: any;
|
|
29
|
+
entry: any;
|
|
30
|
+
props: Record<string, any>;
|
|
31
|
+
actionContext: any;
|
|
32
|
+
actionState: any;
|
|
33
|
+
isActive: boolean;
|
|
34
|
+
onPress: () => any;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const ActionButtonContent = ({
|
|
38
|
+
children,
|
|
39
|
+
action,
|
|
40
|
+
entry,
|
|
41
|
+
actionContext,
|
|
42
|
+
actionState,
|
|
43
|
+
isActive,
|
|
44
|
+
}: ActionButtonContentProps) => {
|
|
45
|
+
const isPressed = usePressedState();
|
|
46
|
+
|
|
47
|
+
const supportsEntryState =
|
|
48
|
+
typeof actionContext?.initialEntryState === "function";
|
|
49
|
+
|
|
50
|
+
const shouldRenderAsset = Boolean(
|
|
51
|
+
supportsEntryState ? actionState?.mobileButtonAssets : false
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const shouldRenderLabel = Boolean(
|
|
55
|
+
supportsEntryState && resolveLabelText(actionState?.label)
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const _cloneChildrenWithState = useCallback(
|
|
59
|
+
(nodes?: React.ReactNode): React.ReactNode => {
|
|
60
|
+
return React.Children.map(nodes, (child) => {
|
|
61
|
+
if (!isValidElement(child)) {
|
|
62
|
+
return child;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const role = child.props.mobileActionRole;
|
|
66
|
+
|
|
67
|
+
const nextChildren = _cloneChildrenWithState(child.props.children);
|
|
68
|
+
|
|
69
|
+
// Prevents of the asset rendering when the action doesn't provide asset for current entry state
|
|
70
|
+
if (role === "asset" && !shouldRenderAsset) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Prevents of the label rendering when the action doesn't provide label for current entry state.
|
|
75
|
+
// Also prevents of the label container when it doesn't have children to avoid unnecessary empty space.
|
|
76
|
+
if (role === "label" && !shouldRenderLabel) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Prevents of the label container rendering when it doesn't have children to avoid unnecessary empty space.
|
|
81
|
+
if (
|
|
82
|
+
role === "label_container" &&
|
|
83
|
+
React.Children.count(nextChildren) === 0
|
|
84
|
+
) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const nextProps: Partial<ChildElementProps> = {};
|
|
89
|
+
|
|
90
|
+
// Inject asset or uri to Asset component with role asset
|
|
91
|
+
if (role === "asset") {
|
|
92
|
+
const resolvedAsset = selectByAssetFlavour(
|
|
93
|
+
actionState,
|
|
94
|
+
action.flavour,
|
|
95
|
+
isActive
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
if (typeof resolvedAsset === "function") {
|
|
99
|
+
const AssetComponent = resolvedAsset as CellActionAssetComponent;
|
|
100
|
+
|
|
101
|
+
nextProps.asset = (
|
|
102
|
+
<AssetComponent
|
|
103
|
+
flavour={action.flavour || "flavour_1"}
|
|
104
|
+
width={action.width}
|
|
105
|
+
height={action.height}
|
|
106
|
+
/>
|
|
107
|
+
);
|
|
108
|
+
} else {
|
|
109
|
+
nextProps.uri = resolvedAsset;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Inject state and entry to Text component with role label
|
|
114
|
+
// Use isPressed state for mobile buttons to set focused state on mobile
|
|
115
|
+
if (role === "label") {
|
|
116
|
+
nextProps.state = isActive || isPressed ? "focused" : "default";
|
|
117
|
+
nextProps.entry = entry;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (nextChildren !== child.props.children) {
|
|
121
|
+
nextProps.children = nextChildren;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return React.cloneElement(child, nextProps);
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
[
|
|
128
|
+
shouldRenderAsset,
|
|
129
|
+
shouldRenderLabel,
|
|
130
|
+
actionState,
|
|
131
|
+
action.flavour,
|
|
132
|
+
action.width,
|
|
133
|
+
action.height,
|
|
134
|
+
isActive,
|
|
135
|
+
isPressed,
|
|
136
|
+
entry,
|
|
137
|
+
]
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
if (!shouldRenderAsset && !shouldRenderLabel) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return _cloneChildrenWithState(children);
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export const ActionButton = ({
|
|
148
|
+
style,
|
|
149
|
+
children,
|
|
150
|
+
action,
|
|
151
|
+
focusedStyles,
|
|
152
|
+
entry,
|
|
153
|
+
...props
|
|
154
|
+
}) => {
|
|
24
155
|
return (
|
|
25
156
|
<ActionButtonController
|
|
26
157
|
action={action}
|
|
@@ -31,105 +162,28 @@ export const ActionButton = ({ style, children, action, entry, ...props }) => {
|
|
|
31
162
|
);
|
|
32
163
|
}}
|
|
33
164
|
>
|
|
34
|
-
{(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return child;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const role = child.props.mobileActionRole;
|
|
55
|
-
|
|
56
|
-
const nextChildren = _cloneChildrenWithState(child.props.children);
|
|
57
|
-
|
|
58
|
-
// Prevents of the asset rendering when the action doesn't provide asset for current entry state
|
|
59
|
-
if (role === "asset" && !shouldRenderAsset) {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Prevents of the label rendering when the action doesn't provide label for current entry state.
|
|
64
|
-
// Also prevents of the label container when it doesn't have children to avoid unnecessary empty space.
|
|
65
|
-
if (role === "label" && !shouldRenderLabel) {
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Prevents of the label container rendering when it doesn't have children to avoid unnecessary empty space.
|
|
70
|
-
if (
|
|
71
|
-
role === "label_container" &&
|
|
72
|
-
React.Children.count(nextChildren) === 0
|
|
73
|
-
) {
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const nextProps: Partial<ChildElementProps> = {};
|
|
78
|
-
|
|
79
|
-
// Inject asset or uri to Asset component with role asset
|
|
80
|
-
if (role === "asset") {
|
|
81
|
-
const resolvedAsset = selectByAssetFlavour(
|
|
82
|
-
actionState,
|
|
83
|
-
action.flavour,
|
|
84
|
-
isActive
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
if (typeof resolvedAsset === "function") {
|
|
88
|
-
const AssetComponent =
|
|
89
|
-
resolvedAsset as CellActionAssetComponent;
|
|
90
|
-
|
|
91
|
-
nextProps.asset = (
|
|
92
|
-
<AssetComponent
|
|
93
|
-
flavour={action.flavour || "flavour_1"}
|
|
94
|
-
width={action.width}
|
|
95
|
-
height={action.height}
|
|
96
|
-
/>
|
|
97
|
-
);
|
|
98
|
-
} else {
|
|
99
|
-
nextProps.uri = resolvedAsset;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// Inject state and entry to Text component with role label
|
|
104
|
-
if (role === "label") {
|
|
105
|
-
nextProps.state = isActive ? "focused" : "default";
|
|
106
|
-
nextProps.entry = entry;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (nextChildren !== child.props.children) {
|
|
110
|
-
nextProps.children = nextChildren;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return React.cloneElement(child, nextProps);
|
|
114
|
-
});
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
if (!shouldRenderAsset && !shouldRenderLabel) {
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return (
|
|
122
|
-
<PressableView
|
|
123
|
-
testID={props.testID || `${entry?.id}`}
|
|
124
|
-
style={isActive ? { ...style, ...props.focusedStyles } : style}
|
|
125
|
-
onPress={onPress}
|
|
126
|
-
accessibilityLabel={props.accessibilityLabel || `${entry?.id}`}
|
|
127
|
-
accessibilityHint={props.accessibilityHint}
|
|
165
|
+
{(renderProps) => (
|
|
166
|
+
<PressableView
|
|
167
|
+
testOnly_pressed={props.testOnly_pressed}
|
|
168
|
+
testID={props.testID || `${entry?.id}`}
|
|
169
|
+
style={style}
|
|
170
|
+
pressedStyle={focusedStyles}
|
|
171
|
+
onPress={renderProps.onPress}
|
|
172
|
+
accessibilityLabel={props.accessibilityLabel || `${entry?.id}`}
|
|
173
|
+
accessibilityHint={props.accessibilityHint}
|
|
174
|
+
>
|
|
175
|
+
<ActionButtonContent
|
|
176
|
+
style={style}
|
|
177
|
+
action={action}
|
|
178
|
+
focusedStyles={focusedStyles}
|
|
179
|
+
entry={entry}
|
|
180
|
+
props={props}
|
|
181
|
+
{...renderProps}
|
|
128
182
|
>
|
|
129
|
-
{
|
|
130
|
-
</
|
|
131
|
-
|
|
132
|
-
}
|
|
183
|
+
{children}
|
|
184
|
+
</ActionButtonContent>
|
|
185
|
+
</PressableView>
|
|
186
|
+
)}
|
|
133
187
|
</ActionButtonController>
|
|
134
188
|
);
|
|
135
189
|
};
|
package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/AssetComponent.tsx
CHANGED
|
@@ -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
|
-
|
|
20
|
-
|
|
27
|
+
<ImageContainer
|
|
28
|
+
style={[styles.assetContainer, props.style]}
|
|
29
|
+
{...(props as any)}
|
|
30
|
+
uri={props.uri}
|
|
31
|
+
/>
|
|
21
32
|
);
|
|
22
33
|
};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
toNumberWithDefault,
|
|
3
|
+
toNumberWithDefaultZero,
|
|
4
|
+
} from "@applicaster/zapp-react-native-utils/numberUtils";
|
|
2
5
|
import { compact } from "@applicaster/zapp-react-native-utils/cellUtils";
|
|
3
6
|
|
|
4
7
|
import { Asset } from "./Asset";
|
|
@@ -10,23 +13,37 @@ import {
|
|
|
10
13
|
getPressableStyles,
|
|
11
14
|
getTextLabelStyles,
|
|
12
15
|
} from "./utils";
|
|
16
|
+
import { ViewStyle } from "react-native";
|
|
17
|
+
import { Spacer } from "./Spacer";
|
|
13
18
|
|
|
14
|
-
const displayModeStyle = (value) => {
|
|
19
|
+
const displayModeStyle = (value, isVertical: boolean) => {
|
|
15
20
|
const mode = value("display_mode") || "dynamic";
|
|
16
21
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
+
const defaultStyle = {
|
|
23
|
+
flexShrink: 1,
|
|
24
|
+
};
|
|
22
25
|
|
|
23
|
-
|
|
24
|
-
return {
|
|
25
|
-
flex: 1,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
26
|
+
const width = toNumberWithDefault(140, value("width"));
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
switch (mode) {
|
|
29
|
+
case "fixed":
|
|
30
|
+
return {
|
|
31
|
+
...defaultStyle,
|
|
32
|
+
width,
|
|
33
|
+
maxWidth: width,
|
|
34
|
+
};
|
|
35
|
+
case "fill":
|
|
36
|
+
return {
|
|
37
|
+
...defaultStyle,
|
|
38
|
+
width: isVertical ? "100%" : undefined,
|
|
39
|
+
flex: !isVertical ? 1 : undefined,
|
|
40
|
+
};
|
|
41
|
+
case "dynamic":
|
|
42
|
+
default:
|
|
43
|
+
return {
|
|
44
|
+
...defaultStyle,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
30
47
|
};
|
|
31
48
|
|
|
32
49
|
type Props = {
|
|
@@ -34,7 +51,8 @@ type Props = {
|
|
|
34
51
|
value: Function;
|
|
35
52
|
stylePrefix: string;
|
|
36
53
|
specificPrefix: string;
|
|
37
|
-
spacingStyle:
|
|
54
|
+
spacingStyle: ViewStyle;
|
|
55
|
+
isVertical: boolean;
|
|
38
56
|
};
|
|
39
57
|
|
|
40
58
|
export const Button = ({
|
|
@@ -43,8 +61,9 @@ export const Button = ({
|
|
|
43
61
|
stylePrefix,
|
|
44
62
|
specificPrefix,
|
|
45
63
|
spacingStyle,
|
|
64
|
+
isVertical,
|
|
46
65
|
}: Props) => {
|
|
47
|
-
//
|
|
66
|
+
// Retrieves values depending to the slot
|
|
48
67
|
const getSlotBasedValue = (property: string) =>
|
|
49
68
|
value(`${specificPrefix}_${property}`);
|
|
50
69
|
|
|
@@ -68,21 +87,30 @@ export const Button = ({
|
|
|
68
87
|
const testID = `mobile_action_button_${index + 1}`;
|
|
69
88
|
const actionIdentifier = getSlotBasedValue("assign_action");
|
|
70
89
|
const assetAlignment = getValue("asset_alignment") || "left";
|
|
90
|
+
|
|
91
|
+
const hasHorizontalAlignment = ["left", "right"].includes(assetAlignment);
|
|
92
|
+
const vGutter = toNumberWithDefaultZero(getValue("vertical_gutter"));
|
|
93
|
+
const hGutter = toNumberWithDefaultZero(getValue("horizontal_gutter"));
|
|
71
94
|
const actionAssetFlavour = getValue("action_asset_flavour");
|
|
72
95
|
const contentsAlignment = getValue("contents_alignment") || "center";
|
|
96
|
+
const displayMode = getValue("display_mode") || "dynamic";
|
|
73
97
|
|
|
74
98
|
return {
|
|
75
99
|
type: "MobileActionButton",
|
|
76
100
|
style: {
|
|
77
|
-
|
|
78
|
-
alignContent: "center",
|
|
79
|
-
alignItems: getContentsAlignment(contentsAlignment, assetAlignment),
|
|
80
|
-
justifyContent: getContentsAlignment(contentsAlignment, assetAlignment),
|
|
101
|
+
// alignContent: "center", Why do we need this?
|
|
81
102
|
...getPressableStyles(getValue),
|
|
82
|
-
...displayModeStyle(getValue),
|
|
103
|
+
...displayModeStyle(getValue, isVertical),
|
|
83
104
|
...spacingStyle,
|
|
84
105
|
},
|
|
85
106
|
additionalProps: {
|
|
107
|
+
displayMode,
|
|
108
|
+
alignment: {
|
|
109
|
+
alignContent: "center",
|
|
110
|
+
flexDirection: getContentDirection(assetAlignment),
|
|
111
|
+
alignItems: getContentsAlignment(contentsAlignment, assetAlignment),
|
|
112
|
+
justifyContent: getContentsAlignment(contentsAlignment, assetAlignment),
|
|
113
|
+
},
|
|
86
114
|
action: {
|
|
87
115
|
identifier: actionIdentifier,
|
|
88
116
|
flavour: actionAssetFlavour,
|
|
@@ -102,7 +130,12 @@ export const Button = ({
|
|
|
102
130
|
testID,
|
|
103
131
|
})
|
|
104
132
|
: null,
|
|
105
|
-
|
|
133
|
+
Spacer({
|
|
134
|
+
enabled: assetEnabled && labelEnabled,
|
|
135
|
+
style: hasHorizontalAlignment
|
|
136
|
+
? { width: hGutter }
|
|
137
|
+
: { height: vGutter },
|
|
138
|
+
}),
|
|
106
139
|
labelEnabled
|
|
107
140
|
? TextLabelsContainer({
|
|
108
141
|
style: getTextLabelStyles(getValue),
|
|
@@ -114,7 +147,8 @@ export const Button = ({
|
|
|
114
147
|
color: getValue("focused_font_color"),
|
|
115
148
|
},
|
|
116
149
|
transformText: getValue("text_transform") || "default",
|
|
117
|
-
numberOfLines: getValue("number_of_lines"),
|
|
150
|
+
numberOfLines: getValue("number_of_lines") || 1,
|
|
151
|
+
ellipsizeMode: "tail",
|
|
118
152
|
},
|
|
119
153
|
actionIdentifier,
|
|
120
154
|
testID,
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
type Props = {
|
|
2
2
|
enabled?: boolean;
|
|
3
|
+
style?: object;
|
|
3
4
|
};
|
|
4
5
|
|
|
5
|
-
export const Spacer = ({
|
|
6
|
+
export const Spacer = ({
|
|
7
|
+
enabled = false,
|
|
8
|
+
style = { flex: 1 },
|
|
9
|
+
}: Props = {}) => {
|
|
6
10
|
if (!enabled) {
|
|
7
11
|
return null;
|
|
8
12
|
}
|
|
9
13
|
|
|
10
14
|
return {
|
|
11
15
|
type: "View",
|
|
12
|
-
style
|
|
13
|
-
flex: 1,
|
|
14
|
-
},
|
|
16
|
+
style,
|
|
15
17
|
};
|
|
16
18
|
};
|
package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/TextLabelsContainer.ts
CHANGED
|
@@ -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
|
},
|
|
@@ -26,7 +29,6 @@ export const TextLabelsContainer = ({
|
|
|
26
29
|
context: actionIdentifier,
|
|
27
30
|
name: "label_1",
|
|
28
31
|
},
|
|
29
|
-
state: "default",
|
|
30
32
|
mobileActionRole: "label",
|
|
31
33
|
testID: testID ? `${testID}-label` : undefined,
|
|
32
34
|
...extraProps,
|