@applicaster/zapp-react-native-ui-components 15.1.0-rc.8 → 16.0.0-alpha.1833861900
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.tsx +42 -0
- package/Components/BackgroundImage/BackgroundImage.tv.android.tsx +28 -0
- package/Components/BackgroundImage/BackgroundImage.tv.ios.tsx +24 -0
- package/Components/BackgroundImage/index.ts +1 -0
- package/Components/BaseFocusable/index.ios.ts +12 -2
- package/Components/Cell/FocusableWrapper.tsx +3 -0
- package/Components/Cell/TvOSCellComponent.tsx +6 -3
- package/Components/CellRendererResolver/index.ts +1 -1
- package/Components/ComponentResolver/__tests__/componentResolver.test.js +1 -1
- package/Components/Focusable/Focusable.tsx +4 -2
- package/Components/Focusable/FocusableTvOS.tsx +18 -1
- package/Components/Focusable/__tests__/__snapshots__/FocusableTvOS.test.tsx.snap +1 -0
- package/Components/FocusableGroup/FocusableTvOS.tsx +41 -8
- package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +1 -1
- package/Components/HandlePlayable/HandlePlayable.tsx +13 -8
- package/Components/Layout/TV/NavBarContainer.tsx +1 -10
- package/Components/Layout/TV/ScreenContainer.tsx +2 -6
- package/Components/Layout/TV/__tests__/__snapshots__/NavBarContainer.test.tsx.snap +7 -12
- package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +7 -12
- package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +0 -1
- package/Components/Layout/TV/index.tsx +5 -7
- package/Components/Layout/TV/index.web.tsx +5 -7
- package/Components/LinkHandler/LinkHandler.tsx +2 -2
- package/Components/MasterCell/CONFIG_BUILDER_TO_REACT_COMPONENT.md +144 -0
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +16 -5
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/model.test.ts +80 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/placement.test.ts +187 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/selectors.test.ts +45 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/style.test.ts +49 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/components/ActionButtonController.tsx +165 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/components/__tests__/ActionButtonController.test.tsx +405 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/components/index.ts +1 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/model.ts +47 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/placement.ts +170 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/selectors.ts +26 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/style.ts +29 -0
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/types.ts +37 -0
- package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +4 -10
- package/Components/MasterCell/DefaultComponents/Button.tsx +0 -15
- package/Components/MasterCell/DefaultComponents/ButtonContainerView/components/HorizontalSeparator.tsx +8 -0
- package/Components/MasterCell/DefaultComponents/ButtonContainerView/index.tsx +15 -0
- package/Components/MasterCell/DefaultComponents/ButtonContainerView/index.tv.android.tsx +58 -0
- package/Components/MasterCell/DefaultComponents/{tv/ButtonContainerView/index.tsx → ButtonContainerView/index.tv.tsx} +3 -11
- package/Components/MasterCell/DefaultComponents/ButtonContainerView/index.web.ts +1 -0
- package/Components/MasterCell/DefaultComponents/ButtonContainerView/types.ts +40 -0
- package/Components/MasterCell/DefaultComponents/DataProvider/index.tsx +163 -0
- package/Components/MasterCell/DefaultComponents/FocusableView/index.android.tsx +2 -23
- package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +4 -22
- package/Components/MasterCell/DefaultComponents/Image/Image.android.tsx +8 -2
- package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +11 -3
- package/Components/MasterCell/DefaultComponents/Image/Image.web.tsx +9 -1
- package/Components/MasterCell/DefaultComponents/Image/hooks/useImage.ts +15 -14
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +1 -2
- package/Components/MasterCell/DefaultComponents/PressableView.tsx +34 -0
- package/Components/MasterCell/DefaultComponents/SecondaryImage/hooks/__tests__/useGetImageDimensions.test.ts +7 -6
- package/Components/MasterCell/DefaultComponents/Text/hooks/useText.ts +11 -0
- package/Components/MasterCell/DefaultComponents/__tests__/DataProvider.test.tsx +141 -0
- package/Components/MasterCell/DefaultComponents/index.ts +9 -3
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/ActionButton.tsx +135 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Asset.ts +33 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/AssetComponent.tsx +22 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Button.ts +125 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Spacer.ts +16 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/TextLabel.ts +67 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/TextLabelsContainer.ts +37 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/PressableView.test.tsx +393 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/builders.test.ts +141 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/index.test.ts +343 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/helpers.ts +105 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/index.ts +122 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/__tests__/insertButtons.test.ts +118 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/index.ts +238 -0
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/Asset.ts +4 -18
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/Button.ts +24 -73
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/TextLabelsContainer.ts +37 -18
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/TvActionButton.tsx +27 -0
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/__tests__/index.test.ts +89 -0
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/__tests__/renderedTree.test.tsx +231 -0
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/index.ts +47 -48
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/__tests__/getPluginIdentifier.test.ts +115 -29
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/index.ts +101 -144
- package/Components/MasterCell/MappingFunctions/index.js +3 -2
- package/Components/MasterCell/README.md +4 -0
- package/Components/MasterCell/__tests__/__snapshots__/dataAdapter.test.js.snap +24 -0
- package/Components/MasterCell/__tests__/configInflater.test.js +1 -0
- package/Components/MasterCell/__tests__/elementMapper.test.js +46 -0
- package/Components/MasterCell/dataAdapter.ts +4 -1
- package/Components/MasterCell/elementMapper.tsx +52 -7
- package/Components/MasterCell/utils/__tests__/cloneChildrenWithIds.test.tsx +43 -0
- package/Components/MasterCell/utils/__tests__/useFilterChildren.test.tsx +80 -0
- package/Components/MasterCell/utils/index.ts +85 -15
- package/Components/OfflineHandler/NotificationView/NotificationView.tsx +2 -2
- package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +17 -18
- package/Components/OfflineHandler/__tests__/index.test.tsx +27 -18
- package/Components/PlayerContainer/PlayerContainer.tsx +15 -14
- package/Components/PlayerContainer/__tests__/PlayerContainer.test.tsx +284 -0
- package/Components/River/ComponentsMap/ComponentsMap.tsx +6 -19
- package/Components/River/ComponentsMap/hooks/__tests__/useLoadingState.test.ts +1 -1
- package/Components/River/RefreshControl.tsx +19 -88
- package/Components/River/River.tsx +9 -82
- package/Components/River/TV/River.tsx +31 -14
- package/Components/River/TV/index.tsx +8 -4
- package/Components/River/TV/utils/__tests__/toStringOrEmpty.test.ts +30 -0
- package/Components/River/TV/utils/index.ts +4 -0
- package/Components/River/TV/withFocusableGroupForContent.tsx +71 -0
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +1 -0
- package/Components/River/__tests__/componentsMap.test.js +38 -0
- package/Components/River/hooks/__tests__/usePullToRefresh.test.ts +132 -0
- package/Components/River/hooks/index.ts +1 -0
- package/Components/River/hooks/usePullToRefresh.ts +51 -0
- package/Components/Screen/TV/index.web.tsx +4 -2
- package/Components/Screen/__tests__/Screen.test.tsx +65 -42
- package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +68 -44
- package/Components/Screen/hooks.ts +2 -3
- package/Components/Screen/index.tsx +2 -3
- package/Components/Screen/orientationHandler.ts +3 -3
- package/Components/ScreenResolver/index.tsx +9 -5
- package/Components/ScreenRevealManager/Overlay.tsx +34 -0
- package/Components/ScreenRevealManager/ScreenRevealManager.ts +40 -8
- package/Components/ScreenRevealManager/__tests__/Overlay.test.tsx +88 -0
- package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +86 -69
- package/Components/ScreenRevealManager/withScreenRevealManager.tsx +9 -20
- package/Components/Tabs/TabContent.tsx +7 -4
- package/Components/TopCutoffOverlay/__tests__/TopCutoffOverlay.test.tsx +201 -0
- package/Components/TopCutoffOverlay/hooks/__tests__/useMarginTop.test.ts +130 -0
- package/Components/TopCutoffOverlay/hooks/index.ts +1 -0
- package/Components/TopCutoffOverlay/hooks/useMarginTop.ts +59 -0
- package/Components/TopCutoffOverlay/index.tsx +55 -0
- package/Components/Transitioner/index.js +3 -3
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +5 -5
- package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +15 -7
- package/Components/VideoModal/utils.ts +18 -10
- package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +0 -2
- package/Components/Viewport/ViewportAware/index.tsx +16 -7
- package/Components/Viewport/ViewportEvents/__tests__/viewportEvents.test.js +1 -1
- package/Components/ZappFrameworkComponents/BarView/BarView.tsx +4 -6
- package/Components/ZappFrameworkComponents/BarView/__tests__/BarView.test.tsx +2 -2
- package/Components/default-cell-renderer/viewTrees/mobile/index.ts +0 -3
- package/Contexts/ScreenContext/index.tsx +25 -18
- package/Contexts/ScreenTrackedViewPositionsContext/__tests__/index.test.tsx +1 -1
- package/Decorators/Analytics/index.tsx +6 -5
- package/Decorators/ConfigurationWrapper/__tests__/__snapshots__/withConfigurationProvider.test.tsx.snap +1 -0
- package/Decorators/ConfigurationWrapper/const.ts +1 -0
- package/Decorators/ZappPipesDataConnector/__tests__/UrlFeedResolver.test.tsx +39 -21
- package/Decorators/ZappPipesDataConnector/__tests__/zappPipesDataConnector.test.js +1 -1
- package/Decorators/ZappPipesDataConnector/index.tsx +2 -2
- package/Decorators/ZappPipesDataConnector/resolvers/StaticFeedResolver.tsx +1 -1
- package/Decorators/ZappPipesDataConnector/resolvers/UrlFeedResolver.tsx +18 -7
- package/Helpers/DataSourceHelper/__tests__/itemLimitForData.test.ts +80 -0
- package/Helpers/DataSourceHelper/index.ts +19 -0
- package/Helpers/index.js +7 -1
- package/package.json +5 -5
- package/Components/Layout/TV/LayoutBackground.tsx +0 -28
- package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.android.tsx +0 -135
- package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/types.ts +0 -25
- package/Components/River/TV/withTVEventHandler.tsx +0 -36
- package/Helpers/DataSourceHelper/index.js +0 -19
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { PressableView } from "../../PressableView";
|
|
3
|
+
|
|
4
|
+
import { ActionButtonController } from "../../ActionButtonsCore/components";
|
|
5
|
+
|
|
6
|
+
import { masterCellLogger } from "../../../logger";
|
|
7
|
+
import { resolveLabelText, selectByAssetFlavour } from "./utils";
|
|
8
|
+
|
|
9
|
+
type ChildElementProps = {
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
mobileActionRole?: "asset" | "label" | "label_container";
|
|
12
|
+
uri?: string;
|
|
13
|
+
asset?: React.ReactNode;
|
|
14
|
+
state?: "default" | "focused";
|
|
15
|
+
entry?: any;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const isValidElement = (
|
|
19
|
+
child: React.ReactNode
|
|
20
|
+
): child is React.ReactElement<ChildElementProps> =>
|
|
21
|
+
React.isValidElement(child);
|
|
22
|
+
|
|
23
|
+
export const ActionButton = ({ style, children, action, entry, ...props }) => {
|
|
24
|
+
return (
|
|
25
|
+
<ActionButtonController
|
|
26
|
+
action={action}
|
|
27
|
+
entry={entry}
|
|
28
|
+
onMissingActionContext={(identifier) => {
|
|
29
|
+
masterCellLogger.warning(
|
|
30
|
+
`You're missing an action plugin(${identifier || action?.identifier}) required by your mobile action button.`
|
|
31
|
+
);
|
|
32
|
+
}}
|
|
33
|
+
>
|
|
34
|
+
{({ actionContext, actionState, isActive, onPress }) => {
|
|
35
|
+
const supportsEntryState =
|
|
36
|
+
typeof actionContext?.initialEntryState === "function";
|
|
37
|
+
|
|
38
|
+
const shouldRenderAsset = Boolean(
|
|
39
|
+
supportsEntryState ? actionState?.mobileButtonAssets : false
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const shouldRenderLabel = Boolean(
|
|
43
|
+
supportsEntryState && resolveLabelText(actionState?.label)
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const _cloneChildrenWithState = (
|
|
47
|
+
nodes?: React.ReactNode
|
|
48
|
+
): React.ReactNode => {
|
|
49
|
+
return React.Children.map(nodes, (child) => {
|
|
50
|
+
if (!isValidElement(child)) {
|
|
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}
|
|
128
|
+
>
|
|
129
|
+
{_cloneChildrenWithState(children)}
|
|
130
|
+
</PressableView>
|
|
131
|
+
);
|
|
132
|
+
}}
|
|
133
|
+
</ActionButtonController>
|
|
134
|
+
);
|
|
135
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AssetComponent } from "./AssetComponent";
|
|
2
|
+
|
|
3
|
+
type Props = {
|
|
4
|
+
testID?: string;
|
|
5
|
+
style?: Record<string, unknown>;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
type AssetNode = {
|
|
9
|
+
type: "ReactComponent";
|
|
10
|
+
style?: Record<string, unknown>;
|
|
11
|
+
additionalProps: {
|
|
12
|
+
component: typeof AssetComponent;
|
|
13
|
+
requiresCellUUID: true;
|
|
14
|
+
renderChildren: false;
|
|
15
|
+
mobileActionRole: "asset";
|
|
16
|
+
testID?: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/** Asset used in conjunction with ActionButton inside mobile action buttons, uri is provided by ActionButton */
|
|
21
|
+
export const Asset = ({ testID, style }: Props): AssetNode => {
|
|
22
|
+
return {
|
|
23
|
+
type: "ReactComponent",
|
|
24
|
+
style,
|
|
25
|
+
additionalProps: {
|
|
26
|
+
component: AssetComponent,
|
|
27
|
+
requiresCellUUID: true,
|
|
28
|
+
renderChildren: false,
|
|
29
|
+
mobileActionRole: "asset",
|
|
30
|
+
testID: testID ? `${testID}-asset` : undefined,
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import { ImageContainer } from "../../ImageContainer";
|
|
4
|
+
|
|
5
|
+
type Props = {
|
|
6
|
+
style?: Record<string, unknown>;
|
|
7
|
+
uri?: string;
|
|
8
|
+
asset?: React.ReactNode;
|
|
9
|
+
testID?: string;
|
|
10
|
+
cellUUID?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const AssetComponent = (props: Props & Record<string, unknown>) => {
|
|
14
|
+
return props.asset && React.isValidElement(props.asset) ? (
|
|
15
|
+
<View style={props.style} testID={props.testID}>
|
|
16
|
+
{React.cloneElement(props.asset, { cellUUID: props.cellUUID })}
|
|
17
|
+
</View>
|
|
18
|
+
) : (
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
<ImageContainer {...props} uri={props.uri} />
|
|
21
|
+
);
|
|
22
|
+
};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { toNumberWithDefault } from "@applicaster/zapp-react-native-utils/numberUtils";
|
|
2
|
+
import { compact } from "@applicaster/zapp-react-native-utils/cellUtils";
|
|
3
|
+
|
|
4
|
+
import { Asset } from "./Asset";
|
|
5
|
+
import { TextLabelsContainer } from "./TextLabelsContainer";
|
|
6
|
+
import {
|
|
7
|
+
getAssetStyles,
|
|
8
|
+
getContentDirection,
|
|
9
|
+
getContentsAlignment,
|
|
10
|
+
getPressableStyles,
|
|
11
|
+
getTextLabelStyles,
|
|
12
|
+
} from "./utils";
|
|
13
|
+
|
|
14
|
+
const displayModeStyle = (value) => {
|
|
15
|
+
const mode = value("display_mode") || "dynamic";
|
|
16
|
+
|
|
17
|
+
if (mode === "fixed") {
|
|
18
|
+
return {
|
|
19
|
+
width: toNumberWithDefault(140, value("width")),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (mode === "fill") {
|
|
24
|
+
return {
|
|
25
|
+
flex: 1,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return {};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
type Props = {
|
|
33
|
+
index: number;
|
|
34
|
+
value: Function;
|
|
35
|
+
stylePrefix: string;
|
|
36
|
+
specificPrefix: string;
|
|
37
|
+
spacingStyle: Record<string, unknown>;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const Button = ({
|
|
41
|
+
index,
|
|
42
|
+
value,
|
|
43
|
+
stylePrefix,
|
|
44
|
+
specificPrefix,
|
|
45
|
+
spacingStyle,
|
|
46
|
+
}: Props) => {
|
|
47
|
+
// Retrives values depending to the slot
|
|
48
|
+
const getSlotBasedValue = (property: string) =>
|
|
49
|
+
value(`${specificPrefix}_${property}`);
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Retrieves values depending to the independ_style toggle:
|
|
53
|
+
* (e.g for button value button_2_label_enabled returns button_1_label_enabled when independent_style: false)
|
|
54
|
+
*/
|
|
55
|
+
const getValue = (property: string) => value(`${stylePrefix}_${property}`);
|
|
56
|
+
|
|
57
|
+
const assetEnabled = getValue("asset_enabled");
|
|
58
|
+
const labelEnabled = getValue("label_enabled");
|
|
59
|
+
|
|
60
|
+
if (!getSlotBasedValue("button_enabled")) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (!assetEnabled && !labelEnabled) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const testID = `mobile_action_button_${index + 1}`;
|
|
69
|
+
const actionIdentifier = getSlotBasedValue("assign_action");
|
|
70
|
+
const assetAlignment = getValue("asset_alignment") || "left";
|
|
71
|
+
const actionAssetFlavour = getValue("action_asset_flavour");
|
|
72
|
+
const contentsAlignment = getValue("contents_alignment") || "center";
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
type: "MobileActionButton",
|
|
76
|
+
style: {
|
|
77
|
+
flexDirection: getContentDirection(assetAlignment),
|
|
78
|
+
alignContent: "center",
|
|
79
|
+
alignItems: getContentsAlignment(contentsAlignment, assetAlignment),
|
|
80
|
+
justifyContent: getContentsAlignment(contentsAlignment, assetAlignment),
|
|
81
|
+
...getPressableStyles(getValue),
|
|
82
|
+
...displayModeStyle(getValue),
|
|
83
|
+
...spacingStyle,
|
|
84
|
+
},
|
|
85
|
+
additionalProps: {
|
|
86
|
+
action: {
|
|
87
|
+
identifier: actionIdentifier,
|
|
88
|
+
flavour: actionAssetFlavour,
|
|
89
|
+
width: toNumberWithDefault(24, getValue("asset_width")),
|
|
90
|
+
height: toNumberWithDefault(24, getValue("asset_height")),
|
|
91
|
+
},
|
|
92
|
+
focusedStyles: {
|
|
93
|
+
backgroundColor: getValue("focused_background_color"),
|
|
94
|
+
borderColor: getValue("focused_border_color"),
|
|
95
|
+
},
|
|
96
|
+
testID,
|
|
97
|
+
},
|
|
98
|
+
elements: compact([
|
|
99
|
+
assetEnabled
|
|
100
|
+
? Asset({
|
|
101
|
+
style: getAssetStyles(getValue),
|
|
102
|
+
testID,
|
|
103
|
+
})
|
|
104
|
+
: null,
|
|
105
|
+
|
|
106
|
+
labelEnabled
|
|
107
|
+
? TextLabelsContainer({
|
|
108
|
+
style: getTextLabelStyles(getValue),
|
|
109
|
+
extraProps: {
|
|
110
|
+
normalStyles: {
|
|
111
|
+
color: getValue("font_color"),
|
|
112
|
+
},
|
|
113
|
+
focusedStyles: {
|
|
114
|
+
color: getValue("focused_font_color"),
|
|
115
|
+
},
|
|
116
|
+
transformText: getValue("text_transform") || "default",
|
|
117
|
+
numberOfLines: getValue("number_of_lines"),
|
|
118
|
+
},
|
|
119
|
+
actionIdentifier,
|
|
120
|
+
testID,
|
|
121
|
+
})
|
|
122
|
+
: null,
|
|
123
|
+
]),
|
|
124
|
+
};
|
|
125
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Platform } from "react-native";
|
|
2
|
+
|
|
3
|
+
import { toNumberWithDefaultZero } from "@applicaster/zapp-react-native-utils/numberUtils";
|
|
4
|
+
|
|
5
|
+
type Props = {
|
|
6
|
+
prefix: string;
|
|
7
|
+
value: Function;
|
|
8
|
+
actionIdentifier: string;
|
|
9
|
+
testID?: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const TextLabel = ({
|
|
13
|
+
prefix,
|
|
14
|
+
value,
|
|
15
|
+
actionIdentifier,
|
|
16
|
+
testID,
|
|
17
|
+
}: Props) => {
|
|
18
|
+
if (!value(`${prefix}_label_enabled`)) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
type: "Text",
|
|
24
|
+
style: {
|
|
25
|
+
color: value(`${prefix}_font_color`),
|
|
26
|
+
fontSize: toNumberWithDefaultZero(value(`${prefix}_font_size`)),
|
|
27
|
+
lineHeight: toNumberWithDefaultZero(value(`${prefix}_line_height`)),
|
|
28
|
+
marginTop: toNumberWithDefaultZero(value(`${prefix}_margin_top`)),
|
|
29
|
+
marginRight: toNumberWithDefaultZero(value(`${prefix}_margin_right`)),
|
|
30
|
+
marginBottom: toNumberWithDefaultZero(value(`${prefix}_margin_bottom`)),
|
|
31
|
+
marginLeft: toNumberWithDefaultZero(value(`${prefix}_margin_left`)),
|
|
32
|
+
fontFamily:
|
|
33
|
+
Platform.OS === "ios"
|
|
34
|
+
? value(`${prefix}_ios_font_family`)
|
|
35
|
+
: value(`${prefix}_android_font_family`),
|
|
36
|
+
letterSpacing: toNumberWithDefaultZero(
|
|
37
|
+
Platform.OS === "ios"
|
|
38
|
+
? value(`${prefix}_ios_letter_spacing`)
|
|
39
|
+
: value(`${prefix}_android_letter_spacing`)
|
|
40
|
+
),
|
|
41
|
+
},
|
|
42
|
+
data: [
|
|
43
|
+
{
|
|
44
|
+
func: (entry) => entry,
|
|
45
|
+
args: [],
|
|
46
|
+
propName: "entry",
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
additionalProps: {
|
|
50
|
+
label: {
|
|
51
|
+
context: actionIdentifier,
|
|
52
|
+
name: "label_1",
|
|
53
|
+
},
|
|
54
|
+
normalStyles: {
|
|
55
|
+
color: value(`${prefix}_font_color`),
|
|
56
|
+
},
|
|
57
|
+
focusedStyles: {
|
|
58
|
+
color: value(`${prefix}_focused_font_color`),
|
|
59
|
+
},
|
|
60
|
+
state: "default",
|
|
61
|
+
mobileActionRole: "label",
|
|
62
|
+
transformText: value(`${prefix}_text_transform`) || "default",
|
|
63
|
+
numberOfLines: value(`${prefix}_number_of_lines`),
|
|
64
|
+
testID: testID ? `${testID}-label` : undefined,
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
};
|
package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/TextLabelsContainer.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
type Props = {
|
|
2
|
+
actionIdentifier: string;
|
|
3
|
+
testID?: string;
|
|
4
|
+
style?: object;
|
|
5
|
+
labelEnabled?: boolean;
|
|
6
|
+
extraProps?: object;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const TextLabelsContainer = ({
|
|
10
|
+
actionIdentifier,
|
|
11
|
+
testID,
|
|
12
|
+
style,
|
|
13
|
+
extraProps,
|
|
14
|
+
}: Props) => {
|
|
15
|
+
return {
|
|
16
|
+
type: "View",
|
|
17
|
+
additionalProps: {
|
|
18
|
+
mobileActionRole: "label_container",
|
|
19
|
+
},
|
|
20
|
+
elements: [
|
|
21
|
+
{
|
|
22
|
+
type: "Text",
|
|
23
|
+
style: style,
|
|
24
|
+
additionalProps: {
|
|
25
|
+
label: {
|
|
26
|
+
context: actionIdentifier,
|
|
27
|
+
name: "label_1",
|
|
28
|
+
},
|
|
29
|
+
state: "default",
|
|
30
|
+
mobileActionRole: "label",
|
|
31
|
+
testID: testID ? `${testID}-label` : undefined,
|
|
32
|
+
...extraProps,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
};
|