@applicaster/zapp-react-native-ui-components 16.0.0-rc.4 → 16.0.0-rc.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/Components/BackgroundImage/BackgroundImage.android.tv.tsx +28 -0
  2. package/Components/BackgroundImage/BackgroundImage.ios.tv.tsx +24 -0
  3. package/Components/BackgroundImage/BackgroundImage.tsx +42 -0
  4. package/Components/BackgroundImage/index.ts +1 -0
  5. package/Components/CellRendererResolver/index.ts +2 -2
  6. package/Components/ComponentResolver/__tests__/componentResolver.test.js +1 -1
  7. package/Components/FocusableGroup/FocusableTvOS.tsx +11 -7
  8. package/Components/GeneralContentScreen/GeneralContentScreenHookAdapter.tsx +39 -0
  9. package/Components/GeneralContentScreen/__tests__/GeneralContentScreenHookAdapter.test.tsx +64 -0
  10. package/Components/GeneralContentScreen/__tests__/HookContentFocusGroup.web.test.tsx +91 -0
  11. package/Components/GeneralContentScreen/hookAdapter/__tests__/networkService.test.ts +74 -0
  12. package/Components/GeneralContentScreen/hookAdapter/__tests__/runInBackground.test.ts +139 -0
  13. package/Components/GeneralContentScreen/hookAdapter/__tests__/validationHelper.test.ts +124 -0
  14. package/Components/GeneralContentScreen/hookAdapter/logger.ts +6 -0
  15. package/Components/GeneralContentScreen/hookAdapter/networkService.ts +53 -0
  16. package/Components/GeneralContentScreen/hookAdapter/runInBackground.ts +48 -0
  17. package/Components/GeneralContentScreen/hookAdapter/validationHelper.ts +72 -0
  18. package/Components/GeneralContentScreen/hookFocus/index.tsx +13 -0
  19. package/Components/GeneralContentScreen/hookFocus/index.web.tsx +69 -0
  20. package/Components/GeneralContentScreen/index.ts +2 -0
  21. package/Components/Layout/FullWidthRow.tsx +38 -0
  22. package/Components/Layout/TV/ScreenContainer.tsx +5 -0
  23. package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +0 -1
  24. package/Components/Layout/TV/index.tsx +3 -4
  25. package/Components/Layout/TV/index.web.tsx +2 -3
  26. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +16 -5
  27. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/placement.test.ts +47 -21
  28. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/placement.ts +34 -6
  29. package/Components/MasterCell/DefaultComponents/ButtonContainerView/index.tsx +1 -1
  30. package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -3
  31. package/Components/MasterCell/DefaultComponents/PressableView.tsx +29 -9
  32. package/Components/MasterCell/DefaultComponents/Text/hooks/useText.ts +4 -0
  33. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/ActionButton.tsx +154 -100
  34. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/AssetComponent.tsx +15 -4
  35. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Button.ts +56 -22
  36. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Spacer.ts +6 -4
  37. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/TextLabelsContainer.ts +3 -1
  38. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/PressableView.test.tsx +32 -21
  39. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/index.test.ts +15 -4
  40. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/index.ts +23 -16
  41. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/__tests__/insertButtons.test.ts +8 -3
  42. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/index.ts +2 -2
  43. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/__tests__/insertButtonsBetweenLabels.test.ts +45 -13
  44. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/index.ts +2 -2
  45. package/Components/MasterCell/contexts/PressedStateContext.ts +3 -0
  46. package/Components/MasterCell/dataAdapter.ts +15 -5
  47. package/Components/MasterCell/hooks/index.ts +2 -0
  48. package/Components/MasterCell/hooks/usePressedState.ts +4 -0
  49. package/Components/MasterCell/index.tsx +30 -5
  50. package/Components/MasterCell/utils/__tests__/resolveColor.test.js +169 -132
  51. package/Components/MasterCell/utils/__tests__/resolveColorForProp.test.js +92 -0
  52. package/Components/MasterCell/utils/index.ts +85 -46
  53. package/Components/ModalComponent/AudioPlayer/Components/Action.tsx +332 -0
  54. package/Components/ModalComponent/AudioPlayer/Components/Button.tsx +402 -0
  55. package/Components/ModalComponent/AudioPlayer/Components/Header.tsx +811 -0
  56. package/Components/ModalComponent/AudioPlayer/Components/Input.tsx +671 -0
  57. package/Components/ModalComponent/AudioPlayer/Components/Item.tsx +878 -0
  58. package/Components/ModalComponent/AudioPlayer/Components/index.ts +9 -0
  59. package/Components/ModalComponent/BottomSheetModalContent.tsx +34 -18
  60. package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +4 -85
  61. package/Components/OfflineHandler/__tests__/index.test.tsx +78 -18
  62. package/Components/OfflineHandler/hooks.ts +123 -0
  63. package/Components/OfflineHandler/index.tsx +51 -73
  64. package/Components/OfflineHandler/utils/index.ts +1 -13
  65. package/Components/PlayerContainer/PlayerContainer.tsx +14 -10
  66. package/Components/PlayerContainer/__tests__/PlayerContainer.test.tsx +284 -0
  67. package/Components/PreloaderWrapper/index.tsx +1 -1
  68. package/Components/River/ComponentsMap/ComponentsMap.tsx +2 -2
  69. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +3 -15
  70. package/Components/Screen/TV/hooks/__tests__/useAfterPaint.test.ts +60 -0
  71. package/Components/Screen/TV/hooks/index.ts +2 -0
  72. package/Components/Screen/TV/hooks/useAfterPaint.ts +23 -0
  73. package/Components/Screen/TV/index.web.tsx +16 -7
  74. package/Components/Screen/index.tsx +8 -4
  75. package/Components/ScreenFeedLoader/ScreenFeedLoader.tsx +5 -3
  76. package/Components/ScreenResolverFeedProvider/ScreenResolverFeedProvider.tsx +1 -1
  77. package/Components/ScreenRevealManager/Overlay.tsx +34 -0
  78. package/Components/ScreenRevealManager/__tests__/Overlay.test.tsx +88 -0
  79. package/Components/ScreenRevealManager/withScreenRevealManager.tsx +8 -19
  80. package/Components/TopCutoffOverlay/index.tsx +2 -2
  81. package/Components/Transitioner/Transitioner.tsx +28 -17
  82. package/Components/VideoLive/LiveImageManager.ts +56 -45
  83. package/Components/VideoLive/PlayerLiveImageComponent.tsx +4 -2
  84. package/Components/VideoModal/utils.ts +6 -1
  85. package/Components/ZappFrameworkComponents/BarView/BarView.tsx +12 -5
  86. package/Components/ZappFrameworkComponents/BarView/__tests__/BarView.test.tsx +2 -2
  87. package/Contexts/CachedDimensionsContext/__tests__/index.test.ts +154 -0
  88. package/Contexts/CachedDimensionsContext/index.ts +17 -2
  89. package/Helpers/ComponentCellSelectionHelper/index.js +0 -6
  90. package/Helpers/index.js +7 -40
  91. package/package.json +5 -5
  92. package/Components/Layout/TV/LayoutBackground.tsx +0 -31
  93. package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +0 -112
  94. package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +0 -107
  95. package/Components/OfflineHandler/NotificationView/NotificationView.tsx +0 -153
  96. package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +0 -66
  97. package/Components/OfflineHandler/NotificationView/utils.ts +0 -34
  98. package/Components/Screen/utils.ts +0 -16
  99. package/Helpers/Analytics/index.js +0 -95
  100. /package/Components/MasterCell/DefaultComponents/ButtonContainerView/{index.tv.android.tsx → index.android.tv.tsx} +0 -0
@@ -0,0 +1,402 @@
1
+ /**
2
+ * Modal Building Block — Button
3
+ *
4
+ * Single-file Expo Snack demo for the Button building block spec.
5
+ * Two variants (with / without leading icon) are driven only by configuration + data.
6
+ *
7
+ * Green (configurable): background, title, icons (size + leading icon enable/action type)
8
+ * Black (hardcoded): action type → icon asset mapping
9
+ */
10
+
11
+ import React from "react";
12
+ import {
13
+ Image,
14
+ Platform,
15
+ Pressable,
16
+ StyleSheet,
17
+ Text,
18
+ View,
19
+ } from "react-native";
20
+
21
+ const styles = StyleSheet.create({
22
+ container: {
23
+ alignSelf: "stretch",
24
+ alignItems: "center",
25
+ justifyContent: "center",
26
+ },
27
+ contentRow: {
28
+ flexDirection: "row",
29
+ alignItems: "center",
30
+ justifyContent: "center",
31
+ },
32
+ title: {
33
+ textAlign: "center",
34
+ },
35
+ demoScreen: {
36
+ flex: 1,
37
+ backgroundColor: "#1C1C1E",
38
+ paddingTop: 64,
39
+ paddingHorizontal: 24,
40
+ gap: 12,
41
+ },
42
+ demoHeading: {
43
+ color: "#FFFFFF",
44
+ fontSize: 20,
45
+ fontWeight: "600",
46
+ marginBottom: 8,
47
+ },
48
+ demoLabel: {
49
+ color: "#999999",
50
+ fontSize: 13,
51
+ marginTop: 8,
52
+ },
53
+ });
54
+
55
+ // ---------------------------------------------------------------------------
56
+ // Configuration (green / editable fields from spec)
57
+ // ---------------------------------------------------------------------------
58
+
59
+ export type ButtonActionType =
60
+ | "addToQueue"
61
+ | "addToPlaylist"
62
+ | "goToPlaylist"
63
+ | "confirm"
64
+ | "cancel";
65
+
66
+ export type TextTransform =
67
+ | "default"
68
+ | "lowercase"
69
+ | "uppercase"
70
+ | "capitalize";
71
+
72
+ export type BackgroundConfiguration = {
73
+ defaultColor: string;
74
+ focusedColor: string;
75
+ inactiveColor: string;
76
+ cornerRadius: number;
77
+ paddingTop: number;
78
+ paddingRight: number;
79
+ paddingBottom: number;
80
+ paddingLeft: number;
81
+ horizontalGutter: number;
82
+ };
83
+
84
+ export type TitleConfiguration = {
85
+ fontColor: string;
86
+ focusedFontColor: string;
87
+ inactiveFontColor: string;
88
+ iosFontFamily: string;
89
+ androidFontFamily: string;
90
+ fontSize: number;
91
+ lineHeight: number;
92
+ iosLetterSpacing: number;
93
+ androidLetterSpacing: number;
94
+ textTransform: TextTransform;
95
+ };
96
+
97
+ export type LeadingIconConfiguration = {
98
+ /** Enable: On / Off */
99
+ enabled: boolean;
100
+ /** Decides which icon will be displayed when enabled */
101
+ actionType?: ButtonActionType;
102
+ };
103
+
104
+ export type IconsConfiguration = {
105
+ width: number;
106
+ height: number;
107
+ leadingIcon: LeadingIconConfiguration;
108
+ };
109
+
110
+ export type ButtonConfiguration = {
111
+ background: BackgroundConfiguration;
112
+ title: TitleConfiguration;
113
+ icons: IconsConfiguration;
114
+ };
115
+
116
+ export const DEFAULT_BACKGROUND_CONFIGURATION: BackgroundConfiguration = {
117
+ defaultColor: "#FFFFFF",
118
+ focusedColor: "#E0E0E0",
119
+ inactiveColor: "#999999",
120
+ cornerRadius: 12,
121
+ paddingTop: 12,
122
+ paddingRight: 12,
123
+ paddingBottom: 12,
124
+ paddingLeft: 12,
125
+ horizontalGutter: 6,
126
+ };
127
+
128
+ export const DEFAULT_TITLE_CONFIGURATION: TitleConfiguration = {
129
+ fontColor: "#000000",
130
+ focusedFontColor: "#000000",
131
+ inactiveFontColor: "#000000",
132
+ iosFontFamily: "SFProText-Bold",
133
+ androidFontFamily: "Roboto-Bold",
134
+ fontSize: 15,
135
+ lineHeight: 24,
136
+ iosLetterSpacing: -0.2,
137
+ androidLetterSpacing: 0,
138
+ textTransform: "default",
139
+ };
140
+
141
+ export const DEFAULT_ICONS_CONFIGURATION: IconsConfiguration = {
142
+ width: 24,
143
+ height: 24,
144
+ leadingIcon: {
145
+ enabled: false,
146
+ },
147
+ };
148
+
149
+ // ---------------------------------------------------------------------------
150
+ // Data (runtime / localization — not styling config)
151
+ // ---------------------------------------------------------------------------
152
+
153
+ export type ButtonData = {
154
+ title: string;
155
+ disabled?: boolean;
156
+ };
157
+
158
+ export type AudioPlayerButtonProps = {
159
+ configuration: ButtonConfiguration;
160
+ data: ButtonData;
161
+ disabled?: boolean;
162
+ focused?: boolean;
163
+ onPress?: () => void;
164
+ };
165
+
166
+ // ---------------------------------------------------------------------------
167
+ // Hardcoded spec values (black fields)
168
+ // ---------------------------------------------------------------------------
169
+
170
+ // Hardcoded: action type → icon asset mapping (base64 PNG)
171
+ const ACTION_ICON_ASSETS: Record<ButtonActionType, string> = {
172
+ addToQueue:
173
+ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAKUlEQVR42mNgGAVDCfxHw6MWjFpAvEGk4lELKLdgNJmOWkA7C0YBbQAAwiZvkR9eFgQAAAAASUVORK5CYII=",
174
+ addToPlaylist:
175
+ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAJklEQVR42mNgGAUjFvzHgmluATF4cFswGsmjkTwayaORPAqGLwAA6Jpxj9Ms9QMAAAAASUVORK5CYII=",
176
+ goToPlaylist:
177
+ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAALklEQVR42mNgGAWjYNiD/7Q2/D8tLflPiSX/ycQ0t+D/yLGAEkeMWjAKRgG9AQB4zlSshwSzWwAAAABJRU5ErkJggg==",
178
+ confirm:
179
+ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAJElEQVR42mNgGAWjYBSQCv4TwKMWDHELho/hNE/3o2AUDDcAAPv0QMAyy1CtAAAAAElFTkSuQmCC",
180
+ cancel:
181
+ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAASElEQVR42mNgGAWjGvynkVoUTf+pqA6nxv8UqiHbEooNx2cQ1QzHZiDVDcdlCcOQsoCmQUTTSKZpMqV5RqNLUUHTwm4UDBMAALBLQ73LTvoyAAAAAElFTkSuQmCC",
182
+ };
183
+
184
+ function getTextTransformStyle(
185
+ textTransform: TextTransform
186
+ ): "none" | "lowercase" | "uppercase" | "capitalize" {
187
+ return textTransform === "default" ? "none" : textTransform;
188
+ }
189
+
190
+ function shouldShowLeadingIcon(leadingIcon: LeadingIconConfiguration) {
191
+ return leadingIcon.enabled && !!leadingIcon.actionType;
192
+ }
193
+
194
+ // ---------------------------------------------------------------------------
195
+ // Inner components (hardcoded styling lives here)
196
+ // ---------------------------------------------------------------------------
197
+
198
+ type ButtonContainerProps = {
199
+ focused: boolean;
200
+ disabled: boolean;
201
+ configuration: BackgroundConfiguration;
202
+ children: React.ReactNode;
203
+ onPress?: () => void;
204
+ };
205
+
206
+ function ButtonContainer({
207
+ focused,
208
+ disabled,
209
+ configuration,
210
+ children,
211
+ onPress,
212
+ }: ButtonContainerProps) {
213
+ const defaultBgColor = disabled
214
+ ? configuration.inactiveColor
215
+ : focused
216
+ ? configuration.focusedColor
217
+ : configuration.defaultColor;
218
+
219
+ return (
220
+ <Pressable
221
+ onPress={disabled ? undefined : onPress}
222
+ style={({ pressed }) => [
223
+ styles.container,
224
+ {
225
+ backgroundColor:
226
+ pressed && !disabled ? configuration.focusedColor : defaultBgColor,
227
+ borderRadius: configuration.cornerRadius,
228
+ paddingTop: configuration.paddingTop,
229
+ paddingRight: configuration.paddingRight,
230
+ paddingBottom: configuration.paddingBottom,
231
+ paddingLeft: configuration.paddingLeft,
232
+ },
233
+ ]}
234
+ >
235
+ {children}
236
+ </Pressable>
237
+ );
238
+ }
239
+
240
+ type ButtonTitleProps = {
241
+ title: string;
242
+ focused: boolean;
243
+ disabled: boolean;
244
+ configuration: TitleConfiguration;
245
+ };
246
+
247
+ function ButtonTitle({
248
+ title,
249
+ focused,
250
+ disabled,
251
+ configuration,
252
+ }: ButtonTitleProps) {
253
+ const color = disabled
254
+ ? configuration.inactiveFontColor
255
+ : focused
256
+ ? configuration.focusedFontColor
257
+ : configuration.fontColor;
258
+
259
+ const letterSpacing =
260
+ Platform.OS === "ios"
261
+ ? configuration.iosLetterSpacing
262
+ : configuration.androidLetterSpacing;
263
+
264
+ return (
265
+ <Text
266
+ style={[
267
+ styles.title,
268
+ {
269
+ color,
270
+ fontSize: configuration.fontSize,
271
+ lineHeight: configuration.lineHeight,
272
+ letterSpacing,
273
+ fontFamily: Platform.select({
274
+ ios: configuration.iosFontFamily,
275
+ android: configuration.androidFontFamily,
276
+ default: configuration.androidFontFamily,
277
+ }),
278
+ textTransform: getTextTransformStyle(configuration.textTransform),
279
+ },
280
+ ]}
281
+ numberOfLines={1}
282
+ >
283
+ {title}
284
+ </Text>
285
+ );
286
+ }
287
+
288
+ type ButtonLeadingIconProps = {
289
+ actionType: ButtonActionType;
290
+ configuration: IconsConfiguration;
291
+ };
292
+
293
+ function ButtonLeadingIcon({
294
+ actionType,
295
+ configuration,
296
+ }: ButtonLeadingIconProps) {
297
+ return (
298
+ <Image
299
+ source={{ uri: ACTION_ICON_ASSETS[actionType] }}
300
+ style={{
301
+ width: configuration.width,
302
+ height: configuration.height,
303
+ }}
304
+ resizeMode="contain"
305
+ />
306
+ );
307
+ }
308
+
309
+ // ---------------------------------------------------------------------------
310
+ // AudioPlayerButton — single building block driven by configuration + data
311
+ // ---------------------------------------------------------------------------
312
+
313
+ export function AudioPlayerButton({
314
+ configuration,
315
+ data,
316
+ disabled,
317
+ focused = false,
318
+ onPress,
319
+ }: AudioPlayerButtonProps) {
320
+ const {
321
+ background: backgroundConfiguration,
322
+ title: titleConfiguration,
323
+ icons: iconsConfiguration,
324
+ } = configuration;
325
+
326
+ const { title } = data;
327
+ const isDisabled = disabled ?? data.disabled ?? false;
328
+
329
+ const { leadingIcon } = iconsConfiguration;
330
+ const showIcon = shouldShowLeadingIcon(leadingIcon);
331
+
332
+ return (
333
+ <ButtonContainer
334
+ focused={focused}
335
+ disabled={isDisabled}
336
+ configuration={backgroundConfiguration}
337
+ onPress={onPress}
338
+ >
339
+ <View style={styles.contentRow}>
340
+ {showIcon ? (
341
+ <>
342
+ <ButtonLeadingIcon
343
+ actionType={leadingIcon.actionType}
344
+ configuration={iconsConfiguration}
345
+ />
346
+ <View style={{ width: backgroundConfiguration.horizontalGutter }} />
347
+ </>
348
+ ) : null}
349
+ <ButtonTitle
350
+ title={title}
351
+ focused={focused}
352
+ disabled={isDisabled}
353
+ configuration={titleConfiguration}
354
+ />
355
+ </View>
356
+ </ButtonContainer>
357
+ );
358
+ }
359
+
360
+ // ---------------------------------------------------------------------------
361
+ // Snack demo — two Button variants from configuration only
362
+ // ---------------------------------------------------------------------------
363
+
364
+ export const VARIANT_TEXT_ONLY: ButtonConfiguration = {
365
+ background: DEFAULT_BACKGROUND_CONFIGURATION,
366
+ title: DEFAULT_TITLE_CONFIGURATION,
367
+ icons: DEFAULT_ICONS_CONFIGURATION,
368
+ };
369
+
370
+ export const VARIANT_WITH_ICON: ButtonConfiguration = {
371
+ background: DEFAULT_BACKGROUND_CONFIGURATION,
372
+ title: DEFAULT_TITLE_CONFIGURATION,
373
+ icons: {
374
+ ...DEFAULT_ICONS_CONFIGURATION,
375
+ leadingIcon: {
376
+ enabled: true,
377
+ actionType: "addToPlaylist",
378
+ },
379
+ },
380
+ };
381
+
382
+ export const VARIANT_UPPERCASE_TITLE: ButtonConfiguration = {
383
+ background: DEFAULT_BACKGROUND_CONFIGURATION,
384
+ title: {
385
+ ...DEFAULT_TITLE_CONFIGURATION,
386
+ textTransform: "uppercase",
387
+ },
388
+ icons: DEFAULT_ICONS_CONFIGURATION,
389
+ };
390
+
391
+ export const VARIANT_LARGE_ICON: ButtonConfiguration = {
392
+ background: DEFAULT_BACKGROUND_CONFIGURATION,
393
+ title: DEFAULT_TITLE_CONFIGURATION,
394
+ icons: {
395
+ width: 32,
396
+ height: 32,
397
+ leadingIcon: {
398
+ enabled: true,
399
+ actionType: "addToQueue",
400
+ },
401
+ },
402
+ };