@applicaster/zapp-react-native-ui-components 15.1.13 → 15.1.15-alpha.4236143002
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/MasterCell/DefaultComponents/ActionButton.tsx +4 -1
- 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/Action.tsx +33 -87
- package/Components/ModalComponent/AudioPlayer/Components/Button.tsx +57 -74
- package/Components/ModalComponent/AudioPlayer/Components/Header.tsx +142 -107
- package/Components/ModalComponent/AudioPlayer/Components/Input.tsx +653 -0
- package/Components/ModalComponent/AudioPlayer/Components/Item.tsx +427 -159
- package/Components/ModalComponent/AudioPlayer/Components/NowPlayingHeaderSection.tsx +89 -0
- package/Components/ModalComponent/AudioPlayer/Components/__tests__/Item.test.tsx +66 -0
- package/Components/ModalComponent/AudioPlayer/Components/index.ts +8 -4
- package/Components/ModalComponent/AudioPlayer/utils/__tests__/mergeStyles.test.ts +230 -0
- package/Components/ModalComponent/AudioPlayer/utils/mergeStyles.ts +332 -0
- package/Components/ModalComponent/BottomSheetModalContent.tsx +379 -61
- package/Components/ModalComponent/Button/index.tsx +5 -3
- 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 +142 -0
- package/Components/ModalComponent/SortableList.web.tsx +102 -0
- package/Components/ModalComponent/TextInputContent.tsx +112 -0
- package/Components/ModalComponent/__tests__/BottomSheetModalContent.test.tsx +238 -0
- package/Components/ModalComponent/__tests__/TextInputContent.test.tsx +156 -0
- package/Components/ModalComponent/__tests__/showTextInput.test.ts +95 -0
- package/Components/ModalComponent/index.tsx +11 -0
- 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/VideoLive/LiveImageManager.ts +8 -2
- package/Hooks/useEntryActionsExpander.ts +63 -0
- package/package.json +6 -5
- /package/Decorators/ZappPipesDataConnector/__tests__/{Hero.js → Hero.tsx} +0 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StyleSheet, View } from "react-native";
|
|
3
|
+
import {
|
|
4
|
+
AudioPlayerTrackItem,
|
|
5
|
+
VARIANT_NOW_PLAYING,
|
|
6
|
+
mapMenuItemToNowPlayingData,
|
|
7
|
+
} from "./Item";
|
|
8
|
+
import { AudioPlayerHeader, VARIANT_SECTION_HEADER } from "./Header";
|
|
9
|
+
import type { MenuItem } from "@applicaster/zapp-react-native-utils/modalState/types";
|
|
10
|
+
import { usePlayer } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/usePlayer";
|
|
11
|
+
import { usePlayerState } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/usePlayerState";
|
|
12
|
+
|
|
13
|
+
const styles = StyleSheet.create({
|
|
14
|
+
divider: {
|
|
15
|
+
height: StyleSheet.hairlineWidth,
|
|
16
|
+
backgroundColor: "rgba(255, 255, 255, 0.1)",
|
|
17
|
+
marginHorizontal: 20,
|
|
18
|
+
marginVertical: 8,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
type NowPlayingHeaderSectionProps = {
|
|
23
|
+
onClear?: () => void;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export function NowPlayingHeaderSection({
|
|
27
|
+
onClear,
|
|
28
|
+
}: NowPlayingHeaderSectionProps) {
|
|
29
|
+
const player = usePlayer();
|
|
30
|
+
const playerState = usePlayerState("queue-now-playing-section");
|
|
31
|
+
|
|
32
|
+
const renderNowPlayingTrack = () => {
|
|
33
|
+
if (!player?.entry) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const mediaGroup = player.entry.media_group;
|
|
38
|
+
|
|
39
|
+
const imageGroup = Array.isArray(mediaGroup)
|
|
40
|
+
? mediaGroup.find((g: any) => g.type === "image")
|
|
41
|
+
: null;
|
|
42
|
+
|
|
43
|
+
const firstImage = Array.isArray(imageGroup?.media_item)
|
|
44
|
+
? imageGroup.media_item[0]?.src
|
|
45
|
+
: imageGroup?.media_item?.src;
|
|
46
|
+
|
|
47
|
+
const nowPlayingItem: MenuItem = {
|
|
48
|
+
id: String(player.entry.id ?? "now_playing"),
|
|
49
|
+
title: (player.entry.title as string) || String(player.entry.id),
|
|
50
|
+
summary: (player.entry.summary as string) ?? "",
|
|
51
|
+
icon: firstImage,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const data = mapMenuItemToNowPlayingData(
|
|
55
|
+
nowPlayingItem,
|
|
56
|
+
playerState?.isPaused
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const handlePlayPause = () => {
|
|
60
|
+
if (playerState?.isPaused) {
|
|
61
|
+
player?.play();
|
|
62
|
+
} else {
|
|
63
|
+
player?.pause();
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<View>
|
|
69
|
+
<AudioPlayerTrackItem
|
|
70
|
+
configuration={VARIANT_NOW_PLAYING}
|
|
71
|
+
data={data}
|
|
72
|
+
onTrailingButtonPress={handlePlayPause}
|
|
73
|
+
/>
|
|
74
|
+
<View style={styles.divider} />
|
|
75
|
+
</View>
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<View>
|
|
81
|
+
{renderNowPlayingTrack()}
|
|
82
|
+
<AudioPlayerHeader
|
|
83
|
+
configuration={VARIANT_SECTION_HEADER}
|
|
84
|
+
data={{ title: "Next Up" }}
|
|
85
|
+
onClear={onClear}
|
|
86
|
+
/>
|
|
87
|
+
</View>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Pressable } from "react-native";
|
|
3
|
+
import { fireEvent, render, screen } from "@testing-library/react-native";
|
|
4
|
+
import { AudioPlayerTrackItem, VARIANT_PLAYLIST_ITEM } from "../Item";
|
|
5
|
+
|
|
6
|
+
const playlistItemData = {
|
|
7
|
+
textLabel1: "Queue",
|
|
8
|
+
textLabel2: "",
|
|
9
|
+
trailingButton: "multiSelect" as const,
|
|
10
|
+
isSelected: false,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
describe("AudioPlayerTrackItem multiSelect checkbox", () => {
|
|
14
|
+
it("invokes onPress when the checkbox is pressed even if onTrailingButtonPress is omitted", () => {
|
|
15
|
+
const onPress = jest.fn();
|
|
16
|
+
|
|
17
|
+
render(
|
|
18
|
+
<AudioPlayerTrackItem
|
|
19
|
+
configuration={VARIANT_PLAYLIST_ITEM}
|
|
20
|
+
data={playlistItemData}
|
|
21
|
+
onPress={onPress}
|
|
22
|
+
/>
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const pressables = screen.UNSAFE_getAllByType(Pressable);
|
|
26
|
+
fireEvent.press(pressables[pressables.length - 1]);
|
|
27
|
+
|
|
28
|
+
expect(onPress).toHaveBeenCalledTimes(1);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("invokes onTrailingButtonPress instead of onPress when a dedicated trailing handler is provided", () => {
|
|
32
|
+
const onPress = jest.fn();
|
|
33
|
+
const onTrailingButtonPress = jest.fn();
|
|
34
|
+
|
|
35
|
+
render(
|
|
36
|
+
<AudioPlayerTrackItem
|
|
37
|
+
configuration={VARIANT_PLAYLIST_ITEM}
|
|
38
|
+
data={playlistItemData}
|
|
39
|
+
onPress={onPress}
|
|
40
|
+
onTrailingButtonPress={onTrailingButtonPress}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
const pressables = screen.UNSAFE_getAllByType(Pressable);
|
|
45
|
+
fireEvent.press(pressables[pressables.length - 1]);
|
|
46
|
+
|
|
47
|
+
expect(onTrailingButtonPress).toHaveBeenCalledTimes(1);
|
|
48
|
+
expect(onPress).not.toHaveBeenCalled();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("invokes onPress when the row is pressed", () => {
|
|
52
|
+
const onPress = jest.fn();
|
|
53
|
+
|
|
54
|
+
render(
|
|
55
|
+
<AudioPlayerTrackItem
|
|
56
|
+
configuration={VARIANT_PLAYLIST_ITEM}
|
|
57
|
+
data={playlistItemData}
|
|
58
|
+
onPress={onPress}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
fireEvent.press(screen.UNSAFE_getAllByType(Pressable)[0]);
|
|
63
|
+
|
|
64
|
+
expect(onPress).toHaveBeenCalledTimes(1);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { AudioPlayerAction } from "./Action";
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { AudioPlayerButton, VARIANT_WITH_ICON } from "./Button";
|
|
4
4
|
|
|
5
|
-
export {
|
|
5
|
+
export { AudioPlayerHeader } from "./Header";
|
|
6
6
|
|
|
7
|
-
export {
|
|
7
|
+
export { AudioPlayerTrackItem } from "./Item";
|
|
8
|
+
|
|
9
|
+
export { NowPlayingHeaderSection } from "./NowPlayingHeaderSection";
|
|
10
|
+
|
|
11
|
+
export { AudioPlayerInput } from "./Input";
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import {
|
|
2
|
+
mergeItemConfiguration,
|
|
3
|
+
mergeButtonConfiguration,
|
|
4
|
+
} from "../mergeStyles";
|
|
5
|
+
|
|
6
|
+
const base = {
|
|
7
|
+
background: {
|
|
8
|
+
defaultColor: "transparent",
|
|
9
|
+
focusedColor: "rgba(62, 62, 62, 1)",
|
|
10
|
+
cornerRadius: 12,
|
|
11
|
+
},
|
|
12
|
+
image: {
|
|
13
|
+
width: 48,
|
|
14
|
+
height: 48,
|
|
15
|
+
borderWidth: 1,
|
|
16
|
+
borderColor: "rgba(255, 255, 255, 0.1)",
|
|
17
|
+
cornerRadius: 6,
|
|
18
|
+
},
|
|
19
|
+
nowPlayingAsset: {},
|
|
20
|
+
nowPlayingLabel: { fontColor: "#fff", fontSize: 12 },
|
|
21
|
+
textLabel1: { fontColor: "#fff", fontSize: 15 },
|
|
22
|
+
textLabel2: { fontColor: "#999", fontSize: 13 },
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
describe("mergeItemConfiguration background", () => {
|
|
26
|
+
it("applies Studio focus background to focusedColor", () => {
|
|
27
|
+
const merged = mergeItemConfiguration(base as any, {
|
|
28
|
+
background: {
|
|
29
|
+
default: { backgroundColor: "transparent" },
|
|
30
|
+
focused: { backgroundColor: "#FF3B30" },
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
expect(merged.background.defaultColor).toBe("transparent");
|
|
35
|
+
expect(merged.background.focusedColor).toBe("#FF3B30");
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("accepts focus alias bucket from parser output", () => {
|
|
39
|
+
const merged = mergeItemConfiguration(base as any, {
|
|
40
|
+
background: {
|
|
41
|
+
default: { backgroundColor: "transparent" },
|
|
42
|
+
focus: { backgroundColor: "#00FF66" },
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
expect(merged.background.focusedColor).toBe("#00FF66");
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("merges text label lineHeight from Studio keys", () => {
|
|
50
|
+
const merged = mergeItemConfiguration(base as any, {
|
|
51
|
+
textLabel1: {
|
|
52
|
+
default: { fontSize: 28, lineHeight: 40 },
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
expect(merged.textLabel1.fontSize).toBe(28);
|
|
57
|
+
expect(merged.textLabel1.lineHeight).toBe(40);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("merges background padding from Studio keys", () => {
|
|
61
|
+
const merged = mergeItemConfiguration(base as any, {
|
|
62
|
+
background: {
|
|
63
|
+
default: {
|
|
64
|
+
backgroundColor: "#2E7D32",
|
|
65
|
+
paddingTop: 32,
|
|
66
|
+
paddingBottom: 32,
|
|
67
|
+
paddingLeft: 40,
|
|
68
|
+
paddingRight: 40,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
expect(merged.background.paddingTop).toBe(32);
|
|
74
|
+
expect(merged.background.paddingBottom).toBe(32);
|
|
75
|
+
expect(merged.background.paddingLeft).toBe(40);
|
|
76
|
+
expect(merged.background.paddingRight).toBe(40);
|
|
77
|
+
// Default-only override must not steal the base focused highlight color.
|
|
78
|
+
expect(merged.background.focusedColor).toBe("rgba(62, 62, 62, 1)");
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("preserves base focusedColor when only default background is set", () => {
|
|
82
|
+
const merged = mergeItemConfiguration(base as any, {
|
|
83
|
+
background: {
|
|
84
|
+
default: { backgroundColor: "#2E7D32" },
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
expect(merged.background.defaultColor).toBe("#2E7D32");
|
|
89
|
+
expect(merged.background.focusedColor).toBe("rgba(62, 62, 62, 1)");
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("applies Studio checkbox assets onto checkboxAssets", () => {
|
|
93
|
+
const merged = mergeItemConfiguration(base as any, {
|
|
94
|
+
checkbox: {
|
|
95
|
+
default: {
|
|
96
|
+
asset: "https://placehold.co/24x24/FF3B30/FFFFFF/png?text=CB",
|
|
97
|
+
checkedAsset: "https://placehold.co/24x24/FFD60A/000000/png?text=CK",
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
expect(merged.checkboxAssets?.asset).toBe(
|
|
103
|
+
"https://placehold.co/24x24/FF3B30/FFFFFF/png?text=CB"
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
expect(merged.checkboxAssets?.checkedAsset).toBe(
|
|
107
|
+
"https://placehold.co/24x24/FFD60A/000000/png?text=CK"
|
|
108
|
+
);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("applies Studio reorder/remove assets onto actionButtonAssets", () => {
|
|
112
|
+
const merged = mergeItemConfiguration(base as any, {
|
|
113
|
+
actionButtons: {
|
|
114
|
+
default: {
|
|
115
|
+
removeAsset: "https://placehold.co/24x24/00FF00/000000/png?text=RM",
|
|
116
|
+
dragAsset: "https://placehold.co/24x24/FF3B30/FFFFFF/png?text=RH",
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
expect(merged.actionButtonAssets?.removeAsset).toBe(
|
|
122
|
+
"https://placehold.co/24x24/00FF00/000000/png?text=RM"
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
expect(merged.actionButtonAssets?.dragAsset).toBe(
|
|
126
|
+
"https://placehold.co/24x24/FF3B30/FFFFFF/png?text=RH"
|
|
127
|
+
);
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
describe("mergeButtonConfiguration background", () => {
|
|
132
|
+
const buttonBase = {
|
|
133
|
+
background: {
|
|
134
|
+
defaultColor: "#FFFFFF",
|
|
135
|
+
focusedColor: "#E0E0E0",
|
|
136
|
+
inactiveColor: "#CCCCCC",
|
|
137
|
+
cornerRadius: 12,
|
|
138
|
+
paddingTop: 12,
|
|
139
|
+
paddingRight: 12,
|
|
140
|
+
paddingBottom: 12,
|
|
141
|
+
paddingLeft: 12,
|
|
142
|
+
horizontalGutter: 8,
|
|
143
|
+
},
|
|
144
|
+
title: {
|
|
145
|
+
fontColor: "#000000",
|
|
146
|
+
focusedFontColor: "#000000",
|
|
147
|
+
inactiveFontColor: "#666666",
|
|
148
|
+
iosFontFamily: "SFProText-Semibold",
|
|
149
|
+
androidFontFamily: "Roboto-Medium",
|
|
150
|
+
fontSize: 15,
|
|
151
|
+
lineHeight: 24,
|
|
152
|
+
iosLetterSpacing: 0,
|
|
153
|
+
androidLetterSpacing: 0,
|
|
154
|
+
textTransform: "default" as const,
|
|
155
|
+
},
|
|
156
|
+
icons: {
|
|
157
|
+
width: 24,
|
|
158
|
+
height: 24,
|
|
159
|
+
leadingIcon: { enabled: true },
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
it("applies Studio button focus background to focusedColor", () => {
|
|
164
|
+
const merged = mergeButtonConfiguration(buttonBase as any, {
|
|
165
|
+
background: {
|
|
166
|
+
default: { backgroundColor: "#FFFFFF" },
|
|
167
|
+
focused: { backgroundColor: "#00FF00" },
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
expect(merged.background.defaultColor).toBe("#FFFFFF");
|
|
172
|
+
expect(merged.background.focusedColor).toBe("#00FF00");
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it("applies Studio button title lineHeight", () => {
|
|
176
|
+
const merged = mergeButtonConfiguration(buttonBase as any, {
|
|
177
|
+
title: {
|
|
178
|
+
default: { fontColor: "#000000", fontSize: 15, lineHeight: 40 },
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
expect(merged.title.lineHeight).toBe(40);
|
|
183
|
+
expect(merged.title.fontSize).toBe(15);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it("applies Studio button background padding", () => {
|
|
187
|
+
const merged = mergeButtonConfiguration(buttonBase as any, {
|
|
188
|
+
background: {
|
|
189
|
+
default: {
|
|
190
|
+
backgroundColor: "#FFFFFF",
|
|
191
|
+
paddingTop: 32,
|
|
192
|
+
paddingRight: 20,
|
|
193
|
+
paddingBottom: 8,
|
|
194
|
+
paddingLeft: 4,
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
expect(merged.background.paddingTop).toBe(32);
|
|
200
|
+
expect(merged.background.paddingRight).toBe(20);
|
|
201
|
+
expect(merged.background.paddingBottom).toBe(8);
|
|
202
|
+
expect(merged.background.paddingLeft).toBe(4);
|
|
203
|
+
expect(merged.background.focusedColor).toBe("#E0E0E0");
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it("preserves base button focusedColor when only default background is set", () => {
|
|
207
|
+
const merged = mergeButtonConfiguration(buttonBase as any, {
|
|
208
|
+
background: {
|
|
209
|
+
default: { backgroundColor: "#ABCDEF" },
|
|
210
|
+
},
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
expect(merged.background.defaultColor).toBe("#ABCDEF");
|
|
214
|
+
expect(merged.background.focusedColor).toBe("#E0E0E0");
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it("applies Studio create-new leading icon asset", () => {
|
|
218
|
+
const merged = mergeButtonConfiguration(buttonBase as any, {
|
|
219
|
+
leadingIcon: {
|
|
220
|
+
default: {
|
|
221
|
+
asset: "https://placehold.co/24x24/FF00FF/FFFFFF/png?text=CN",
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
expect(merged.icons.leadingIcon.asset).toBe(
|
|
227
|
+
"https://placehold.co/24x24/FF00FF/FFFFFF/png?text=CN"
|
|
228
|
+
);
|
|
229
|
+
});
|
|
230
|
+
});
|