@applicaster/zapp-react-native-ui-components 16.0.0-rc.9 → 16.0.0-rc.91
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/AudioPlayer/tv/__tests__/audioPlayer.test.js +19 -0
- package/Components/AudioPlayer/tv/__tests__/index.test.tsx +120 -0
- package/Components/AudioPlayer/tv/index.tsx +5 -1
- package/Components/Cell/Cell.tsx +3 -6
- package/Components/Cell/TvOSCellComponent.tsx +0 -1
- 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 +54 -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__/skipExpression.test.ts +294 -0
- package/Components/GeneralContentScreen/hookAdapter/__tests__/validationHelper.test.ts +188 -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/skipExpression.ts +252 -0
- package/Components/GeneralContentScreen/hookAdapter/validationHelper.ts +90 -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/MasterCell/DefaultComponents/ActionButton.tsx +21 -6
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/placement.test.ts +47 -21
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/components/ActionButtonController.tsx +19 -4
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/components/__tests__/ActionButtonController.test.tsx +43 -1
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/placement.ts +34 -6
- package/Components/MasterCell/DefaultComponents/Button.tsx +1 -0
- package/Components/MasterCell/DefaultComponents/Image/hoc/utils/__tests__/withDimensions.test.ts +420 -125
- package/Components/MasterCell/DefaultComponents/Image/hoc/utils/index.ts +114 -19
- package/Components/MasterCell/DefaultComponents/Image/hoc/withDimensions.tsx +19 -8
- 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/Toggle.tsx +36 -14
- package/Components/MasterCell/DefaultComponents/__tests__/Toggle.test.tsx +167 -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/SharedUI/CollapsibleTextContainer/__tests__/factory.test.ts +32 -0
- package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +1 -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/ActionsBottomSheet/ActionButton.tsx +56 -0
- package/Components/ModalComponent/ActionsBottomSheet/__tests__/openActionsBottomSheet.test.ts +38 -0
- package/Components/ModalComponent/ActionsBottomSheet/boundActionButton.tsx +24 -0
- package/Components/ModalComponent/ActionsBottomSheet/index.ts +9 -0
- package/Components/ModalComponent/ActionsBottomSheet/openActionsBottomSheet.ts +61 -0
- package/Components/ModalComponent/AudioPlayer/Components/Button.tsx +392 -0
- package/Components/ModalComponent/AudioPlayer/Components/Header.tsx +728 -0
- package/Components/ModalComponent/AudioPlayer/Components/Input.tsx +628 -0
- package/Components/ModalComponent/AudioPlayer/Components/Item.tsx +982 -0
- package/Components/ModalComponent/AudioPlayer/Components/NowPlayingHeaderSection.tsx +94 -0
- package/Components/ModalComponent/AudioPlayer/Components/__tests__/Item.test.tsx +113 -0
- package/Components/ModalComponent/AudioPlayer/Components/index.ts +9 -0
- package/Components/ModalComponent/AudioPlayer/utils/__tests__/mergeStyles.test.ts +248 -0
- package/Components/ModalComponent/AudioPlayer/utils/mergeStyles.ts +386 -0
- package/Components/ModalComponent/BottomSheetDragArea.tsx +33 -0
- package/Components/ModalComponent/BottomSheetModalContent.tsx +419 -50
- package/Components/ModalComponent/Button/index.tsx +5 -3
- package/Components/ModalComponent/Header/CloseButton.tsx +12 -0
- package/Components/ModalComponent/Header/__tests__/CloseButton.test.tsx +72 -0
- package/Components/ModalComponent/Header/index.tsx +20 -7
- package/Components/ModalComponent/Header/utils.ts +1 -1
- package/Components/ModalComponent/ModalBlocksStyleContext.tsx +10 -0
- package/Components/ModalComponent/SortableList.tsx +157 -0
- package/Components/ModalComponent/SortableList.web.tsx +34 -0
- package/Components/ModalComponent/TextInputContent.tsx +112 -0
- package/Components/ModalComponent/__tests__/BottomSheetDragArea.test.tsx +74 -0
- package/Components/ModalComponent/__tests__/BottomSheetModalContent.test.tsx +270 -0
- package/Components/ModalComponent/__tests__/SortableList.web.test.tsx +16 -0
- package/Components/ModalComponent/__tests__/TextInputContent.test.tsx +156 -0
- package/Components/ModalComponent/__tests__/showTextInput.test.ts +95 -0
- package/Components/ModalComponent/index.tsx +18 -9
- package/Components/ModalComponent/presets/__tests__/getCell.test.ts +90 -0
- package/Components/ModalComponent/presets/dynamicCollectionCell.tsx +78 -0
- package/Components/ModalComponent/presets/index.ts +27 -0
- package/Components/ModalComponent/presets/selectableCell.tsx +28 -0
- package/Components/ModalComponent/presets/standardCell.tsx +41 -0
- package/Components/ModalComponent/presets/types.ts +35 -0
- package/Components/ModalComponent/showTextInput.ts +43 -0
- package/Components/ModalComponent/utils.ts +82 -21
- 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 +111 -0
- package/Components/OfflineHandler/index.tsx +51 -73
- package/Components/OfflineHandler/utils/index.ts +1 -13
- package/Components/PlayerContainer/PlayerContainer.tsx +25 -17
- package/Components/PlayerContainer/ProgramInfo/index.tsx +3 -4
- package/Components/PlayerContainer/__tests__/PlayerContainer.test.tsx +337 -0
- package/Components/PreloaderWrapper/index.tsx +1 -1
- package/Components/River/ComponentsMap/ComponentsMap.tsx +87 -61
- package/Components/River/River.tsx +4 -0
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +140 -89
- package/Components/River/__tests__/componentsMap.test.js +8 -3
- package/Components/River/__tests__/resultCallback.test.tsx +47 -0
- package/Components/Screen/index.tsx +8 -4
- package/Components/Screen/navigationHandler.ts +8 -8
- package/Components/ScreenFeedLoader/ScreenFeedLoader.tsx +5 -3
- package/Components/ScreenResolverFeedProvider/ScreenResolverFeedProvider.tsx +1 -1
- package/Components/ScreenRevealManager/ScreenRevealManager.ts +18 -2
- package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +36 -0
- package/Components/ScreenRevealManager/__tests__/withScreenRevealManager.test.tsx +56 -0
- package/Components/ScreenRevealManager/withScreenRevealManager.tsx +21 -4
- package/Components/TopCutoffOverlay/index.tsx +2 -2
- package/Components/Transitioner/Transitioner.tsx +28 -17
- package/Components/VideoLive/LiveImageManager.ts +1 -1
- 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/Contexts/ModalNavigationContext/__tests__/index.test.tsx +15 -0
- package/Contexts/ModalNavigationContext/index.tsx +2 -2
- package/Helpers/ComponentCellSelectionHelper/index.js +0 -6
- package/Helpers/index.js +0 -39
- package/Hooks/useEntryActionsExpander.ts +63 -0
- package/package.json +6 -5
- 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/BackgroundImage/{BackgroundImage.tv.android.tsx → BackgroundImage.android.tv.tsx} +0 -0
- /package/Components/BackgroundImage/{BackgroundImage.tv.ios.tsx → BackgroundImage.ios.tv.tsx} +0 -0
- /package/Components/MasterCell/DefaultComponents/ButtonContainerView/{index.tv.android.tsx → index.android.tv.tsx} +0 -0
- /package/Decorators/ZappPipesDataConnector/__tests__/{Hero.js → Hero.tsx} +0 -0
|
@@ -4,6 +4,7 @@ import { Title, TitleProps } from "./Title";
|
|
|
4
4
|
import { CloseButton, CloseButtonProps } from "./CloseButton";
|
|
5
5
|
import { getCloseButtonProps, getTitleProps } from "./utils";
|
|
6
6
|
import { PluginConfiguration } from "../index";
|
|
7
|
+
import { useModalBlocksStyle } from "../ModalBlocksStyleContext";
|
|
7
8
|
|
|
8
9
|
type Props = {
|
|
9
10
|
dismiss: () => void;
|
|
@@ -28,6 +29,14 @@ const styles = StyleSheet.create({
|
|
|
28
29
|
|
|
29
30
|
export function ModalHeader(props: Props) {
|
|
30
31
|
const { configuration, dismiss, onLayout, summary, title } = props;
|
|
32
|
+
const modalBlocksStyle = useModalBlocksStyle();
|
|
33
|
+
const headerBlock = modalBlocksStyle?.header;
|
|
34
|
+
|
|
35
|
+
const containerStyle = useMemo(() => {
|
|
36
|
+
const bg = headerBlock?.container?.default?.backgroundColor;
|
|
37
|
+
|
|
38
|
+
return [styles.container, bg ? { backgroundColor: bg } : null];
|
|
39
|
+
}, [headerBlock?.container?.default?.backgroundColor]);
|
|
31
40
|
|
|
32
41
|
const closeButtonProps = useMemo<CloseButtonProps>(
|
|
33
42
|
() => ({
|
|
@@ -37,13 +46,17 @@ export function ModalHeader(props: Props) {
|
|
|
37
46
|
[configuration, dismiss]
|
|
38
47
|
);
|
|
39
48
|
|
|
40
|
-
const titleProps = useMemo<TitleProps>(
|
|
41
|
-
|
|
42
|
-
|
|
49
|
+
const titleProps = useMemo<TitleProps>(() => {
|
|
50
|
+
const baseProps = getTitleProps(configuration, "title");
|
|
51
|
+
const titleOverride = headerBlock?.title?.default;
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
...baseProps,
|
|
43
55
|
text: title,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
56
|
+
...(titleOverride?.fontColor ? { color: titleOverride.fontColor } : {}),
|
|
57
|
+
...(titleOverride?.fontSize ? { fontSize: titleOverride.fontSize } : {}),
|
|
58
|
+
};
|
|
59
|
+
}, [configuration, title, headerBlock?.title?.default]);
|
|
47
60
|
|
|
48
61
|
const summaryProps = useMemo<TitleProps>(
|
|
49
62
|
() => ({
|
|
@@ -59,7 +72,7 @@ export function ModalHeader(props: Props) {
|
|
|
59
72
|
configuration.modal_bottom_sheet_close_margin_right;
|
|
60
73
|
|
|
61
74
|
return (
|
|
62
|
-
<View onLayout={onLayout} style={
|
|
75
|
+
<View onLayout={onLayout} style={containerStyle}>
|
|
63
76
|
<View style={styles.flex}>
|
|
64
77
|
{title ? <Title {...titleProps} /> : null}
|
|
65
78
|
{summary ? <Title {...summaryProps} /> : null}
|
|
@@ -18,7 +18,7 @@ export function getCloseButtonProps(config: PluginConfiguration) {
|
|
|
18
18
|
return {
|
|
19
19
|
asset: modal_bottom_sheet_close_asset,
|
|
20
20
|
assetFocused: modal_bottom_sheet_close_focus_asset,
|
|
21
|
-
enabled: modal_bottom_sheet_close_switch,
|
|
21
|
+
enabled: modal_bottom_sheet_close_switch !== false,
|
|
22
22
|
width: modal_bottom_sheet_close_width,
|
|
23
23
|
height: modal_bottom_sheet_close_height,
|
|
24
24
|
marginTop: modal_bottom_sheet_close_margin_top,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { useContext } from "react";
|
|
2
|
+
import type { ModalBlocksConfig } from "@applicaster/zapp-react-native-utils/configurationUtils/modalBlocksParser";
|
|
3
|
+
|
|
4
|
+
export const ModalBlocksStyleContext = React.createContext<
|
|
5
|
+
ModalBlocksConfig | Record<string, any> | undefined
|
|
6
|
+
>(undefined);
|
|
7
|
+
|
|
8
|
+
export const useModalBlocksStyle = () => {
|
|
9
|
+
return useContext(ModalBlocksStyleContext);
|
|
10
|
+
};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
|
+
import Sortable from "react-native-sortables";
|
|
3
|
+
import { Text, View, ViewStyle } from "react-native";
|
|
4
|
+
import Animated, { useAnimatedRef } from "react-native-reanimated";
|
|
5
|
+
|
|
6
|
+
const DEFAULT_HEADERS: any[] = [];
|
|
7
|
+
const DEFAULT_SORTABLE_DATA: any[] = [];
|
|
8
|
+
|
|
9
|
+
const renderHeaderComponent = (component: any) => {
|
|
10
|
+
if (!component) return null;
|
|
11
|
+
if (React.isValidElement(component)) return component;
|
|
12
|
+
|
|
13
|
+
if (typeof component === "function") {
|
|
14
|
+
const HeaderComponent = component;
|
|
15
|
+
|
|
16
|
+
return <HeaderComponent />;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return null;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const SortableListHeader = ({
|
|
23
|
+
title,
|
|
24
|
+
style,
|
|
25
|
+
}: {
|
|
26
|
+
title?: string;
|
|
27
|
+
style?: ViewStyle;
|
|
28
|
+
}) => {
|
|
29
|
+
const displayTitle = typeof title === "string" ? title : String(title ?? "");
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<View style={style}>
|
|
33
|
+
{displayTitle ? <Text>{displayTitle}</Text> : null}
|
|
34
|
+
</View>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type SortableListProps = {
|
|
39
|
+
scrollViewStyle?: ViewStyle;
|
|
40
|
+
contentContainerStyle?: ViewStyle;
|
|
41
|
+
itemStyle?: ViewStyle;
|
|
42
|
+
headerStyle?: ViewStyle;
|
|
43
|
+
columns?: number;
|
|
44
|
+
rowGap?: number;
|
|
45
|
+
columnGap?: number;
|
|
46
|
+
spacing?: number;
|
|
47
|
+
keyExtractor?: (item: any, index?: number) => string;
|
|
48
|
+
renderItem: ({
|
|
49
|
+
item,
|
|
50
|
+
index,
|
|
51
|
+
renderHandle,
|
|
52
|
+
}: {
|
|
53
|
+
item: any;
|
|
54
|
+
index: number;
|
|
55
|
+
renderHandle: (children: React.ReactElement) => React.ReactElement;
|
|
56
|
+
}) => React.ReactNode;
|
|
57
|
+
sortableData?: any[];
|
|
58
|
+
headers?: { index: number; title?: string; component: any }[];
|
|
59
|
+
onDragEnd?: (params: {
|
|
60
|
+
fromIndex?: number;
|
|
61
|
+
toIndex?: number;
|
|
62
|
+
from?: number;
|
|
63
|
+
to?: number;
|
|
64
|
+
data: any[];
|
|
65
|
+
}) => void;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const defaultKeyExtractor = (item, index) =>
|
|
69
|
+
`sortable-item-${item?.id ?? item?.title ?? index}`;
|
|
70
|
+
|
|
71
|
+
export const SortableList = ({
|
|
72
|
+
scrollViewStyle,
|
|
73
|
+
contentContainerStyle,
|
|
74
|
+
itemStyle,
|
|
75
|
+
headerStyle,
|
|
76
|
+
columns = 1,
|
|
77
|
+
rowGap = 0,
|
|
78
|
+
columnGap = 0,
|
|
79
|
+
keyExtractor = defaultKeyExtractor,
|
|
80
|
+
renderItem,
|
|
81
|
+
sortableData = DEFAULT_SORTABLE_DATA,
|
|
82
|
+
headers = DEFAULT_HEADERS,
|
|
83
|
+
onDragEnd,
|
|
84
|
+
}: SortableListProps) => {
|
|
85
|
+
const scrollableRef = useAnimatedRef<Animated.ScrollView>();
|
|
86
|
+
|
|
87
|
+
const [localData, setLocalData] = useState(sortableData);
|
|
88
|
+
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
setLocalData((localData) =>
|
|
91
|
+
localData !== sortableData ? sortableData : localData
|
|
92
|
+
);
|
|
93
|
+
}, [sortableData]);
|
|
94
|
+
|
|
95
|
+
const handleDragEnd = useCallback(
|
|
96
|
+
(params: any) => {
|
|
97
|
+
if (params?.data) {
|
|
98
|
+
setLocalData(params.data);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (onDragEnd) {
|
|
102
|
+
onDragEnd(params);
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
[onDragEnd]
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
const _renderItem = useCallback(
|
|
109
|
+
({ item, index }) => (
|
|
110
|
+
<View key={keyExtractor(item, index)} style={itemStyle}>
|
|
111
|
+
{renderItem({
|
|
112
|
+
item,
|
|
113
|
+
index,
|
|
114
|
+
renderHandle: (children) => (
|
|
115
|
+
<Sortable.Handle>{children}</Sortable.Handle>
|
|
116
|
+
),
|
|
117
|
+
})}
|
|
118
|
+
</View>
|
|
119
|
+
),
|
|
120
|
+
[itemStyle, keyExtractor, renderItem]
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
const renderHeader = useMemo(
|
|
124
|
+
() =>
|
|
125
|
+
(headers || []).map((header, idx) => (
|
|
126
|
+
<View key={`static-header-${idx}`} style={headerStyle}>
|
|
127
|
+
{header.title ? (
|
|
128
|
+
<SortableListHeader title={header.title} />
|
|
129
|
+
) : (
|
|
130
|
+
renderHeaderComponent(header.component)
|
|
131
|
+
)}
|
|
132
|
+
</View>
|
|
133
|
+
)),
|
|
134
|
+
[headers, headerStyle]
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
return (
|
|
138
|
+
<Animated.ScrollView
|
|
139
|
+
ref={scrollableRef}
|
|
140
|
+
style={scrollViewStyle}
|
|
141
|
+
contentContainerStyle={contentContainerStyle}
|
|
142
|
+
>
|
|
143
|
+
{renderHeader}
|
|
144
|
+
<Sortable.Grid
|
|
145
|
+
scrollableRef={scrollableRef}
|
|
146
|
+
customHandle
|
|
147
|
+
columns={columns}
|
|
148
|
+
rowGap={rowGap}
|
|
149
|
+
columnGap={columnGap}
|
|
150
|
+
data={localData}
|
|
151
|
+
keyExtractor={keyExtractor}
|
|
152
|
+
onDragEnd={handleDragEnd}
|
|
153
|
+
renderItem={_renderItem}
|
|
154
|
+
/>
|
|
155
|
+
</Animated.ScrollView>
|
|
156
|
+
);
|
|
157
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ViewStyle } from "react-native";
|
|
3
|
+
|
|
4
|
+
export type SortableListProps = {
|
|
5
|
+
scrollViewStyle?: ViewStyle;
|
|
6
|
+
contentContainerStyle?: ViewStyle;
|
|
7
|
+
itemStyle?: ViewStyle;
|
|
8
|
+
headerStyle?: ViewStyle;
|
|
9
|
+
columns?: number;
|
|
10
|
+
rowGap?: number;
|
|
11
|
+
columnGap?: number;
|
|
12
|
+
spacing?: number;
|
|
13
|
+
keyExtractor?: (item: any, index?: number) => string;
|
|
14
|
+
renderItem: ({
|
|
15
|
+
item,
|
|
16
|
+
index,
|
|
17
|
+
renderHandle,
|
|
18
|
+
}: {
|
|
19
|
+
item: any;
|
|
20
|
+
index: number;
|
|
21
|
+
renderHandle: (children: React.ReactElement) => React.ReactElement;
|
|
22
|
+
}) => React.ReactNode;
|
|
23
|
+
sortableData?: any[];
|
|
24
|
+
headers?: { index: number; title?: string; component: any }[];
|
|
25
|
+
onDragEnd?: (params: {
|
|
26
|
+
fromIndex?: number;
|
|
27
|
+
toIndex?: number;
|
|
28
|
+
from?: number;
|
|
29
|
+
to?: number;
|
|
30
|
+
data: any[];
|
|
31
|
+
}) => void;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const SortableList = (_props: SortableListProps) => null;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React, { useCallback, useState } from "react";
|
|
2
|
+
import { StyleSheet, View } from "react-native";
|
|
3
|
+
import { actionExecutor } from "@applicaster/zapp-react-native-utils/actionsExecutor/ActionExecutor";
|
|
4
|
+
import {
|
|
5
|
+
AudioPlayerInput,
|
|
6
|
+
VARIANT_NAME_PLAYLIST_INPUT,
|
|
7
|
+
} from "./AudioPlayer/Components/Input";
|
|
8
|
+
import {
|
|
9
|
+
AudioPlayerButton,
|
|
10
|
+
VARIANT_TEXT_ONLY,
|
|
11
|
+
} from "./AudioPlayer/Components/Button";
|
|
12
|
+
|
|
13
|
+
export type TextInputContentProps = {
|
|
14
|
+
/** Injected by the sheet host; unused for layout (header is owned by ModalComponent). */
|
|
15
|
+
dismiss?: () => void;
|
|
16
|
+
width?: number;
|
|
17
|
+
maxHeight?: number;
|
|
18
|
+
currentRoute?: boolean;
|
|
19
|
+
inputLabel?: string;
|
|
20
|
+
defaultValue?: string;
|
|
21
|
+
buttonLabel: string;
|
|
22
|
+
actions: ActionType[];
|
|
23
|
+
actionContext?: Record<string, any>;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const styles = StyleSheet.create({
|
|
27
|
+
container: {
|
|
28
|
+
paddingHorizontal: 20,
|
|
29
|
+
paddingBottom: 8,
|
|
30
|
+
},
|
|
31
|
+
inputWrap: {
|
|
32
|
+
marginTop: 8,
|
|
33
|
+
marginBottom: 24,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Modal body only — input + submit.
|
|
39
|
+
* Standard dismiss header comes from BottomSheetModalContent / ModalHeader.
|
|
40
|
+
*/
|
|
41
|
+
export function TextInputContent(props: TextInputContentProps) {
|
|
42
|
+
const {
|
|
43
|
+
inputLabel,
|
|
44
|
+
defaultValue = "",
|
|
45
|
+
buttonLabel,
|
|
46
|
+
actions,
|
|
47
|
+
actionContext,
|
|
48
|
+
} = props;
|
|
49
|
+
|
|
50
|
+
const [textValue, setTextValue] = useState(defaultValue);
|
|
51
|
+
const [submitting, setSubmitting] = useState(false);
|
|
52
|
+
|
|
53
|
+
const onSubmit = useCallback(async () => {
|
|
54
|
+
if (submitting) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
setSubmitting(true);
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
const updatedActions = (actions || []).map((item) => {
|
|
62
|
+
if (item.type === "sendCloudEvent" || item.options?.data) {
|
|
63
|
+
return {
|
|
64
|
+
...item,
|
|
65
|
+
options: {
|
|
66
|
+
...item.options,
|
|
67
|
+
data: {
|
|
68
|
+
...(item.options?.data || {}),
|
|
69
|
+
name: textValue,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return item;
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
if (actionContext) {
|
|
79
|
+
await actionExecutor.handleActions(updatedActions, actionContext);
|
|
80
|
+
} else {
|
|
81
|
+
await actionExecutor.handleActions(updatedActions);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
await actionExecutor.handleAction({ type: "dismissBottomSheet" });
|
|
85
|
+
} finally {
|
|
86
|
+
setSubmitting(false);
|
|
87
|
+
}
|
|
88
|
+
}, [submitting, actions, textValue, actionContext]);
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<View style={styles.container}>
|
|
92
|
+
<View style={styles.inputWrap}>
|
|
93
|
+
<AudioPlayerInput
|
|
94
|
+
configuration={VARIANT_NAME_PLAYLIST_INPUT}
|
|
95
|
+
data={{
|
|
96
|
+
placeholder: inputLabel || "",
|
|
97
|
+
label: inputLabel,
|
|
98
|
+
}}
|
|
99
|
+
value={textValue}
|
|
100
|
+
onChangeText={setTextValue}
|
|
101
|
+
onClearPress={() => setTextValue("")}
|
|
102
|
+
/>
|
|
103
|
+
</View>
|
|
104
|
+
<AudioPlayerButton
|
|
105
|
+
configuration={VARIANT_TEXT_ONLY}
|
|
106
|
+
data={{ title: buttonLabel }}
|
|
107
|
+
onPress={onSubmit}
|
|
108
|
+
disabled={submitting}
|
|
109
|
+
/>
|
|
110
|
+
</View>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Text } from "react-native";
|
|
3
|
+
import { render, screen } from "@testing-library/react-native";
|
|
4
|
+
import { BottomSheetDragArea } from "../BottomSheetDragArea";
|
|
5
|
+
import { BottomSheetContext } from "@applicaster/zapp-react-native-utils/bottomSheet";
|
|
6
|
+
|
|
7
|
+
// Reveal PanGestureHandler and capture its props.
|
|
8
|
+
jest.mock("react-native-gesture-handler", () => {
|
|
9
|
+
const { View } = require("react-native");
|
|
10
|
+
const actual = jest.requireActual("react-native-gesture-handler");
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
__esModule: true,
|
|
14
|
+
...actual,
|
|
15
|
+
PanGestureHandler: ({
|
|
16
|
+
children,
|
|
17
|
+
onGestureEvent,
|
|
18
|
+
onHandlerStateChange,
|
|
19
|
+
simultaneousHandlers,
|
|
20
|
+
}: any) => (
|
|
21
|
+
<View
|
|
22
|
+
testID="drag-pan"
|
|
23
|
+
onGestureEvent={onGestureEvent}
|
|
24
|
+
onHandlerStateChange={onHandlerStateChange}
|
|
25
|
+
simultaneousHandlers={simultaneousHandlers}
|
|
26
|
+
>
|
|
27
|
+
{children}
|
|
28
|
+
</View>
|
|
29
|
+
),
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const makeValue = () => ({
|
|
34
|
+
scrollRef: React.createRef<any>(),
|
|
35
|
+
masterDrawerRef: React.createRef<any>(),
|
|
36
|
+
drawerRef: React.createRef<any>(),
|
|
37
|
+
onScroll: jest.fn(),
|
|
38
|
+
setBodyDragEnabled: jest.fn(),
|
|
39
|
+
onDragGestureEvent: jest.fn(),
|
|
40
|
+
onDragStateChange: jest.fn(),
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe("BottomSheetDragArea", () => {
|
|
44
|
+
it("wraps children in a sheet-wired PanGestureHandler when inside a sheet", () => {
|
|
45
|
+
const value = makeValue();
|
|
46
|
+
|
|
47
|
+
render(
|
|
48
|
+
<BottomSheetContext.Provider value={value}>
|
|
49
|
+
<BottomSheetDragArea>
|
|
50
|
+
<Text testID="child">hi</Text>
|
|
51
|
+
</BottomSheetDragArea>
|
|
52
|
+
</BottomSheetContext.Provider>
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const pan = screen.getByTestId("drag-pan");
|
|
56
|
+
expect(pan.props.onGestureEvent).toBe(value.onDragGestureEvent);
|
|
57
|
+
expect(pan.props.onHandlerStateChange).toBe(value.onDragStateChange);
|
|
58
|
+
|
|
59
|
+
expect(pan.props.simultaneousHandlers).toEqual([value.masterDrawerRef]);
|
|
60
|
+
|
|
61
|
+
expect(screen.getByTestId("child")).toBeTruthy();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("renders children bare when used outside a sheet", () => {
|
|
65
|
+
render(
|
|
66
|
+
<BottomSheetDragArea>
|
|
67
|
+
<Text testID="child">hi</Text>
|
|
68
|
+
</BottomSheetDragArea>
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
expect(screen.queryByTestId("drag-pan")).toBeNull();
|
|
72
|
+
expect(screen.getByTestId("child")).toBeTruthy();
|
|
73
|
+
});
|
|
74
|
+
});
|