@applicaster/zapp-react-native-ui-components 16.0.0-rc.98 → 17.0.0-alpha.1984136194
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/CellRendererResolver/index.ts +2 -2
- package/Components/ComponentResolver/ComponentResolver.ts +2 -2
- package/Components/ComponentResolver/__tests__/componentResolver.test.js +13 -5
- package/Components/ContentScreen/index.js +2 -2
- package/Components/FocusableList/hooks/useCheckItemIdsForUnique.ts +2 -7
- package/Components/GeneralContentScreen/GeneralContentScreen.tsx +1 -1
- package/Components/GeneralContentScreen/hookAdapter/logger.ts +1 -1
- package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +158 -1
- package/Components/GeneralContentScreen/utils/index.ts +2 -2
- package/Components/GeneralContentScreen/utils/logger.ts +3 -4
- package/Components/GeneralContentScreen/utils/useCurationAPI.ts +32 -10
- package/Components/HandlePlayable/utils.ts +2 -7
- package/Components/HookRenderer/HookRenderer.tsx +2 -2
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +13 -0
- package/Components/MasterCell/DefaultComponents/Image/hoc/utils/__tests__/withDimensions.test.ts +1 -1
- package/Components/MasterCell/DefaultComponents/Image/hoc/utils/index.ts +2 -4
- package/Components/MasterCell/DefaultComponents/Image/hooks/checkTooBigImageSize.ts +2 -7
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +12 -3
- package/Components/MasterCell/DefaultComponents/PressableView.tsx +3 -0
- package/Components/MasterCell/DefaultComponents/Text/hooks/useText.ts +2 -7
- package/Components/MasterCell/DefaultComponents/__tests__/ActionButton.test.tsx +288 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/ActionButton.tsx +2 -1
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/PressableView.test.tsx +4 -2
- package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/factory.test.ts +2 -2
- package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +2 -1
- package/Components/MasterCell/__tests__/masterCell.test.js +60 -0
- package/Components/MasterCell/index.tsx +28 -4
- package/Components/MasterCell/logger.ts +2 -2
- package/Components/MasterCell/utils/__tests__/useIsCellSelected.test.ts +91 -0
- package/Components/MasterCell/utils/__tests__/withoutFocusedState.test.js +20 -0
- package/Components/MasterCell/utils/behaviorProvider.ts +57 -38
- package/Components/MasterCell/utils/index.ts +21 -18
- package/Components/ModalComponent/ActionsBottomSheet/openActionsBottomSheet.ts +1 -1
- package/Components/ModalComponent/AudioPlayer/Components/Button.tsx +7 -3
- package/Components/ModalComponent/AudioPlayer/Components/Item.tsx +22 -1
- package/Components/ModalComponent/AudioPlayer/Components/__tests__/Item.test.tsx +52 -1
- package/Components/ModalComponent/AudioPlayer/utils/__tests__/mergeStyles.test.ts +77 -0
- package/Components/ModalComponent/AudioPlayer/utils/mergeStyles.ts +58 -16
- package/Components/ModalComponent/BottomSheetDragArea.web.tsx +15 -0
- package/Components/ModalComponent/BottomSheetModalContent.tsx +51 -82
- package/Components/ModalComponent/SortableList.tsx +2 -3
- package/Components/ModalComponent/__tests__/BottomSheetDragArea.test.tsx +30 -0
- package/Components/ModalComponent/__tests__/BottomSheetModalContent.test.tsx +237 -17
- package/Components/ModalComponent/__tests__/showTextInput.test.ts +25 -0
- package/Components/ModalComponent/showTextInput.ts +2 -0
- package/Components/OfflineHandler/__tests__/index.test.tsx +136 -0
- package/Components/OfflineHandler/index.tsx +45 -6
- package/Components/PlayerContainer/PlayerContainer.tsx +30 -6
- package/Components/PlayerContainer/__tests__/PlayerContainer.test.tsx +51 -0
- package/Components/PlayerContainer/logger.ts +9 -5
- package/Components/River/ComponentsMap/ComponentsMap.tsx +4 -1
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +2 -0
- package/Components/ScreenFeedLoader/ScreenFeedLoader.tsx +2 -2
- package/Components/ScreenResolver/index.tsx +2 -3
- package/Components/Transitioner/AnimationManager.js +1 -1
- package/Components/Transitioner/Scene.tsx +4 -3
- package/Components/Transitioner/Transitioner.tsx +71 -33
- package/Components/Transitioner/__tests__/transitioner.test.js +372 -3
- package/Components/VideoLive/LiveImageManager.ts +126 -12
- package/Components/VideoLive/MuteUnmuteController.ts +135 -0
- package/Components/VideoLive/PlayerLiveImageComponent.tsx +15 -19
- package/Components/VideoLive/__tests__/LiveImageMuteState.test.ts +311 -0
- package/Components/VideoLive/__tests__/MuteUnmuteController.test.ts +135 -0
- package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +63 -1
- package/Components/VideoLive/loggerHelper.ts +2 -2
- package/Components/VideoModal/PlayerWrapper.tsx +4 -1
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -0
- package/Components/VideoModal/__tests__/playerWrapperStyle.test.ts +58 -0
- package/Components/VideoModal/__tests__/playerWrapperUtils.test.ts +16 -0
- package/Components/VideoModal/hooks/useModalSize.ts +2 -7
- package/Components/VideoModal/playerWrapperStyle.ts +21 -3
- package/Components/VideoModal/playerWrapperUtils.ts +7 -1
- package/Contexts/ZappPipesContext/ZappPipesContextFactory.tsx +3 -5
- package/Decorators/ZappPipesDataConnector/__tests__/UrlFeedResolver.test.tsx +4 -3
- package/Decorators/ZappPipesDataConnector/__tests__/screenToolbox.test.ts +347 -0
- package/Decorators/ZappPipesDataConnector/__tests__/screenToolboxUnavailable.test.ts +53 -0
- package/Decorators/ZappPipesDataConnector/index.tsx +19 -4
- package/Decorators/ZappPipesDataConnector/resolvers/UrlFeedResolver.tsx +2 -21
- package/Decorators/ZappPipesDataConnector/screenToolbox.ts +384 -0
- package/Decorators/ZappPipesDataConnector/utils/mongoFilter.ts +1 -1
- package/Decorators/ZappPipesDataConnector/utils/useFilter.tsx +1 -1
- package/Helpers/logger.js +2 -2
- package/package.json +5 -5
|
@@ -69,45 +69,8 @@ const getDataSourceProvider = (
|
|
|
69
69
|
return null;
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
-
export const useBehaviorUpdate = (behavior: Behavior) => {
|
|
73
|
-
const [lastUpdate, setLastUpdate] = React.useState<number | null>(null);
|
|
74
|
-
const screenRoute = useRoute()?.pathname || "";
|
|
75
|
-
const screenStateStore = useScreenStateStore();
|
|
76
|
-
const player = usePlayer();
|
|
77
|
-
|
|
78
|
-
const triggerUpdate = () => setLastUpdate(Date.now());
|
|
79
|
-
|
|
80
|
-
useEffect(() => {
|
|
81
|
-
if (!behavior) return;
|
|
82
|
-
|
|
83
|
-
const dataSource = getDataSourceProvider(
|
|
84
|
-
behavior,
|
|
85
|
-
screenRoute,
|
|
86
|
-
screenStateStore
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
if (dataSource) {
|
|
90
|
-
const subscription = dataSource.subscribe(triggerUpdate);
|
|
91
|
-
|
|
92
|
-
return () => subscription.unsubscribe();
|
|
93
|
-
}
|
|
94
|
-
}, [behavior]);
|
|
95
|
-
|
|
96
|
-
useEffect(() => {
|
|
97
|
-
if (!behavior || !player || behavior.selection_source !== "now_playing") {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const subscription = player.getEntryObservable().subscribe(triggerUpdate);
|
|
102
|
-
|
|
103
|
-
return () => subscription.unsubscribe();
|
|
104
|
-
}, [behavior, player]);
|
|
105
|
-
|
|
106
|
-
return lastUpdate;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
72
|
// We cant use async in this function (its inside render),
|
|
110
|
-
// so we rely on
|
|
73
|
+
// so we rely on useIsCellSelected to trigger re-render when the value changes
|
|
111
74
|
export const isCellSelected = ({
|
|
112
75
|
item,
|
|
113
76
|
screenRoute,
|
|
@@ -202,3 +165,59 @@ export const isCellSelected = ({
|
|
|
202
165
|
|
|
203
166
|
return false;
|
|
204
167
|
};
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Every cell observes the same provider, so a plain "something changed" trigger
|
|
171
|
+
* re-renders the whole list on each tap. Re-render only the cell whose own
|
|
172
|
+
* selected state changed.
|
|
173
|
+
*/
|
|
174
|
+
export const useIsCellSelected = (
|
|
175
|
+
behavior: Behavior,
|
|
176
|
+
item: ZappEntry
|
|
177
|
+
): boolean => {
|
|
178
|
+
const [, forceUpdate] = React.useState(0);
|
|
179
|
+
const screenRoute = useRoute()?.pathname || "";
|
|
180
|
+
const screenStateStore = useScreenStateStore();
|
|
181
|
+
const player = usePlayer();
|
|
182
|
+
|
|
183
|
+
const isSelected = () =>
|
|
184
|
+
isCellSelected({ item, screenRoute, screenStateStore, behavior });
|
|
185
|
+
|
|
186
|
+
const selected = isSelected();
|
|
187
|
+
const latest = React.useRef({ isSelected, selected });
|
|
188
|
+
latest.current = { isSelected, selected };
|
|
189
|
+
|
|
190
|
+
const triggerUpdate = () => {
|
|
191
|
+
if (latest.current.isSelected() !== latest.current.selected) {
|
|
192
|
+
forceUpdate((n) => n + 1);
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
useEffect(() => {
|
|
197
|
+
if (!behavior) return;
|
|
198
|
+
|
|
199
|
+
const dataSource = getDataSourceProvider(
|
|
200
|
+
behavior,
|
|
201
|
+
screenRoute,
|
|
202
|
+
screenStateStore
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
if (dataSource) {
|
|
206
|
+
const subscription = dataSource.subscribe(triggerUpdate);
|
|
207
|
+
|
|
208
|
+
return () => subscription.unsubscribe();
|
|
209
|
+
}
|
|
210
|
+
}, [behavior]);
|
|
211
|
+
|
|
212
|
+
useEffect(() => {
|
|
213
|
+
if (!behavior || !player || behavior.selection_source !== "now_playing") {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const subscription = player.getEntryObservable().subscribe(triggerUpdate);
|
|
218
|
+
|
|
219
|
+
return () => subscription.unsubscribe();
|
|
220
|
+
}, [behavior, player]);
|
|
221
|
+
|
|
222
|
+
return selected;
|
|
223
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from "react";
|
|
2
2
|
import * as R from "ramda";
|
|
3
3
|
import memoizee from "memoizee";
|
|
4
4
|
|
|
@@ -8,12 +8,10 @@ import { isValidColor } from "@applicaster/zapp-react-native-utils/colorUtils";
|
|
|
8
8
|
import { getColorFromData } from "@applicaster/zapp-react-native-utils/cellUtils";
|
|
9
9
|
import { pathOr, get, isNil } from "@applicaster/zapp-react-native-utils/utils";
|
|
10
10
|
import { isNilOrEmpty } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
|
|
11
|
-
import { useRoute } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
12
|
-
import { useScreenStateStore } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useScreenStateStore";
|
|
13
11
|
import { isNotEmptyString } from "@applicaster/zapp-react-native-utils/stringUtils";
|
|
14
12
|
import { masterCellLogger } from "../logger";
|
|
15
13
|
import { getCellState } from "../../Cell/utils";
|
|
16
|
-
import {
|
|
14
|
+
import { useIsCellSelected } from "./behaviorProvider";
|
|
17
15
|
import { DataProvider } from "../DefaultComponents/DataProvider";
|
|
18
16
|
|
|
19
17
|
const hasElementSpecificViewType = (viewType) => (element) => {
|
|
@@ -341,20 +339,7 @@ export const useCellState = ({
|
|
|
341
339
|
behavior: Behavior;
|
|
342
340
|
focused: boolean;
|
|
343
341
|
}): CellState => {
|
|
344
|
-
const
|
|
345
|
-
const router = useRoute();
|
|
346
|
-
const screenStateStore = useScreenStateStore();
|
|
347
|
-
|
|
348
|
-
const _isSelected = useMemo(
|
|
349
|
-
() =>
|
|
350
|
-
isCellSelected({
|
|
351
|
-
item,
|
|
352
|
-
screenRoute: router?.pathname,
|
|
353
|
-
screenStateStore,
|
|
354
|
-
behavior,
|
|
355
|
-
}),
|
|
356
|
-
[behavior, item, lastUpdate]
|
|
357
|
-
);
|
|
342
|
+
const _isSelected = useIsCellSelected(behavior, item);
|
|
358
343
|
|
|
359
344
|
return getCellState({ focused, selected: _isSelected });
|
|
360
345
|
};
|
|
@@ -386,3 +371,21 @@ export function getEntryState(state, selected) {
|
|
|
386
371
|
|
|
387
372
|
return selected ? "selected" : "default";
|
|
388
373
|
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Drops focused (pressed) variants of a cell state, so a non-interactive cell
|
|
377
|
+
* always renders its idle look. `selected` is kept – it is not touch feedback.
|
|
378
|
+
*/
|
|
379
|
+
export function withoutFocusedState(
|
|
380
|
+
state?: CellState | null
|
|
381
|
+
): CellState | null | undefined {
|
|
382
|
+
if (state === "focused_selected") {
|
|
383
|
+
return "selected";
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
if (state === "focused") {
|
|
387
|
+
return "default";
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
return state;
|
|
391
|
+
}
|
|
@@ -6,7 +6,7 @@ import { RegisteredAction } from "@applicaster/zapp-react-native-utils/uiActions
|
|
|
6
6
|
import { boundActionButton } from "./boundActionButton";
|
|
7
7
|
|
|
8
8
|
const { log_warning } = createLogger({
|
|
9
|
-
subsystem: "
|
|
9
|
+
subsystem: "ui/bottom_sheet",
|
|
10
10
|
category: "Presentation",
|
|
11
11
|
});
|
|
12
12
|
|
|
@@ -19,7 +19,10 @@ import {
|
|
|
19
19
|
} from "react-native";
|
|
20
20
|
import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
|
|
21
21
|
|
|
22
|
-
const logger = createLogger({
|
|
22
|
+
const logger = createLogger({
|
|
23
|
+
category: "ModalComponent:AudioPlayerButton",
|
|
24
|
+
subsystem: "player/audio",
|
|
25
|
+
});
|
|
23
26
|
|
|
24
27
|
const styles = StyleSheet.create({
|
|
25
28
|
container: {
|
|
@@ -345,13 +348,14 @@ export function AudioPlayerButton({
|
|
|
345
348
|
icons: iconsConfiguration,
|
|
346
349
|
} = effectiveConfig;
|
|
347
350
|
|
|
348
|
-
const title = data
|
|
351
|
+
const title = data.title;
|
|
352
|
+
|
|
349
353
|
const isDisabled = disabled ?? data.disabled ?? false;
|
|
350
354
|
|
|
351
355
|
React.useEffect(() => {
|
|
352
356
|
if (!title) {
|
|
353
357
|
logger.log_warning(
|
|
354
|
-
"
|
|
358
|
+
"AudioPlayerButton rendering with empty title. Ensure data.title is set.",
|
|
355
359
|
{
|
|
356
360
|
leadingIcon: iconsConfiguration.leadingIcon,
|
|
357
361
|
modalBlocksStyle: modalBlocksStyle,
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Green (configurable): background, image, nowPlayingAsset, nowPlayingLabel,
|
|
7
7
|
* textLabel1, textLabel2
|
|
8
8
|
* White (hardcoded): container padding/gutters, nowPlaying container layout,
|
|
9
|
-
* button sizes/padding/assets
|
|
9
|
+
* button sizes/padding. Play/pause icons use plugin assets when set.
|
|
10
10
|
*
|
|
11
11
|
* Variants (VARIANT_*) are preset configuration bundles — not passed as a field.
|
|
12
12
|
*/
|
|
@@ -94,6 +94,10 @@ export type ActionButtonAssetsConfiguration = {
|
|
|
94
94
|
removeAsset?: string;
|
|
95
95
|
/** Trailing drag handle on Edit Order / queue rows. */
|
|
96
96
|
dragAsset?: string;
|
|
97
|
+
/** Shown on the Now Playing row while the track is paused. */
|
|
98
|
+
playAsset?: string;
|
|
99
|
+
/** Shown on the Now Playing row while the track is playing. */
|
|
100
|
+
pauseAsset?: string;
|
|
97
101
|
};
|
|
98
102
|
|
|
99
103
|
export type ItemConfiguration = {
|
|
@@ -504,6 +508,23 @@ function ItemButton({
|
|
|
504
508
|
const renderIcon = () => {
|
|
505
509
|
switch (action) {
|
|
506
510
|
case "playPause": {
|
|
511
|
+
const playbackAsset = isSelected
|
|
512
|
+
? actionButtonAssets?.pauseAsset
|
|
513
|
+
: actionButtonAssets?.playAsset;
|
|
514
|
+
|
|
515
|
+
if (playbackAsset) {
|
|
516
|
+
return (
|
|
517
|
+
<Image
|
|
518
|
+
source={{ uri: playbackAsset }}
|
|
519
|
+
style={{
|
|
520
|
+
width: layout.assetWidth,
|
|
521
|
+
height: layout.assetHeight,
|
|
522
|
+
}}
|
|
523
|
+
resizeMode="contain"
|
|
524
|
+
/>
|
|
525
|
+
);
|
|
526
|
+
}
|
|
527
|
+
|
|
507
528
|
const iconSize = layout.assetWidth;
|
|
508
529
|
const iconRadius = iconSize / 2;
|
|
509
530
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Pressable } from "react-native";
|
|
2
|
+
import { Image, Pressable } from "react-native";
|
|
3
3
|
import { fireEvent, render, screen } from "@testing-library/react-native";
|
|
4
|
+
import { ModalBlocksStyleContext } from "../../../ModalBlocksStyleContext";
|
|
4
5
|
import {
|
|
5
6
|
AudioPlayerTrackItem,
|
|
7
|
+
VARIANT_NOW_PLAYING,
|
|
6
8
|
VARIANT_PLAYLIST_ITEM,
|
|
7
9
|
mapMenuItemToNowPlayingData,
|
|
8
10
|
} from "../Item";
|
|
@@ -101,6 +103,55 @@ describe("mapMenuItemToNowPlayingData", () => {
|
|
|
101
103
|
expect(data.textLabel2).toBe("Artist Name");
|
|
102
104
|
});
|
|
103
105
|
|
|
106
|
+
it("uses the plugin play asset while paused and the pause asset while playing", () => {
|
|
107
|
+
const menuItem = {
|
|
108
|
+
id: "item_1",
|
|
109
|
+
title: "Track Title",
|
|
110
|
+
summary: "Artist Name",
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const style = {
|
|
114
|
+
nowPlayingItem: {
|
|
115
|
+
actionButtons: {
|
|
116
|
+
default: {
|
|
117
|
+
playAsset: "https://example.com/play.png",
|
|
118
|
+
pauseAsset: "https://example.com/pause.png",
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const { UNSAFE_getAllByType, rerender } = render(
|
|
125
|
+
<ModalBlocksStyleContext.Provider value={style}>
|
|
126
|
+
<AudioPlayerTrackItem
|
|
127
|
+
configuration={VARIANT_NOW_PLAYING}
|
|
128
|
+
data={mapMenuItemToNowPlayingData(menuItem as any, true)}
|
|
129
|
+
/>
|
|
130
|
+
</ModalBlocksStyleContext.Provider>
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
expect(
|
|
134
|
+
UNSAFE_getAllByType(Image).some(
|
|
135
|
+
(node) => node.props.source?.uri === "https://example.com/play.png"
|
|
136
|
+
)
|
|
137
|
+
).toBe(true);
|
|
138
|
+
|
|
139
|
+
rerender(
|
|
140
|
+
<ModalBlocksStyleContext.Provider value={style}>
|
|
141
|
+
<AudioPlayerTrackItem
|
|
142
|
+
configuration={VARIANT_NOW_PLAYING}
|
|
143
|
+
data={mapMenuItemToNowPlayingData(menuItem as any, false)}
|
|
144
|
+
/>
|
|
145
|
+
</ModalBlocksStyleContext.Provider>
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
expect(
|
|
149
|
+
UNSAFE_getAllByType(Image).some(
|
|
150
|
+
(node) => node.props.source?.uri === "https://example.com/pause.png"
|
|
151
|
+
)
|
|
152
|
+
).toBe(true);
|
|
153
|
+
});
|
|
154
|
+
|
|
104
155
|
it("uses custom nowPlayingLabel when provided", () => {
|
|
105
156
|
const data = mapMenuItemToNowPlayingData(
|
|
106
157
|
item as any,
|
|
@@ -131,6 +131,43 @@ describe("mergeItemConfiguration background", () => {
|
|
|
131
131
|
"https://placehold.co/24x24/FF3B30/FFFFFF/png?text=RH"
|
|
132
132
|
);
|
|
133
133
|
});
|
|
134
|
+
|
|
135
|
+
it("applies a text label font family and ignores a non-string font family", () => {
|
|
136
|
+
const withFont = mergeItemConfiguration(base as any, {
|
|
137
|
+
textLabel1: { default: { fontFamily: "Roboto-Bold" } },
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
expect(withFont.textLabel1.iosFontFamily).toBe("Roboto-Bold");
|
|
141
|
+
expect(withFont.textLabel1.androidFontFamily).toBe("Roboto-Bold");
|
|
142
|
+
|
|
143
|
+
const withEmpty = mergeItemConfiguration(base as any, {
|
|
144
|
+
textLabel1: {
|
|
145
|
+
default: { fontFamily: {}, iosFontFamily: "SFProText-Semibold" },
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
expect(withEmpty.textLabel1.iosFontFamily).toBe("SFProText-Semibold");
|
|
150
|
+
expect(withEmpty.textLabel1.androidFontFamily).toBeUndefined();
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it("applies play and pause assets onto actionButtonAssets", () => {
|
|
154
|
+
const merged = mergeItemConfiguration(base as any, {
|
|
155
|
+
actionButtons: {
|
|
156
|
+
default: {
|
|
157
|
+
playAsset: "https://example.com/play.png",
|
|
158
|
+
pauseAsset: "https://example.com/pause.png",
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
expect(merged.actionButtonAssets?.playAsset).toBe(
|
|
164
|
+
"https://example.com/play.png"
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
expect(merged.actionButtonAssets?.pauseAsset).toBe(
|
|
168
|
+
"https://example.com/pause.png"
|
|
169
|
+
);
|
|
170
|
+
});
|
|
134
171
|
});
|
|
135
172
|
|
|
136
173
|
describe("mergeButtonConfiguration background", () => {
|
|
@@ -250,6 +287,46 @@ describe("mergeButtonConfiguration background", () => {
|
|
|
250
287
|
expect(merged.title.androidLetterSpacing).toBe(-0.5);
|
|
251
288
|
expect(merged.title.textTransform).toBe("uppercase");
|
|
252
289
|
});
|
|
290
|
+
|
|
291
|
+
it("uses the family string inside a font-selector object and ignores {}", () => {
|
|
292
|
+
const fromObject = mergeButtonConfiguration(buttonBase as any, {
|
|
293
|
+
title: {
|
|
294
|
+
default: { fontFamily: { fontFamily: "GreycliffCF-Bold" } },
|
|
295
|
+
},
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
expect(fromObject.title.iosFontFamily).toBe("GreycliffCF-Bold");
|
|
299
|
+
expect(fromObject.title.androidFontFamily).toBe("GreycliffCF-Bold");
|
|
300
|
+
|
|
301
|
+
const fromEmpty = mergeButtonConfiguration(buttonBase as any, {
|
|
302
|
+
title: {
|
|
303
|
+
default: { fontFamily: {} },
|
|
304
|
+
},
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
expect(fromEmpty.title.iosFontFamily).toBe(buttonBase.title.iosFontFamily);
|
|
308
|
+
|
|
309
|
+
expect(fromEmpty.title.androidFontFamily).toBe(
|
|
310
|
+
buttonBase.title.androidFontFamily
|
|
311
|
+
);
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
it("maps inactive color, gutter, and focused and inactive font colors", () => {
|
|
315
|
+
const merged = mergeButtonConfiguration(buttonBase as any, {
|
|
316
|
+
background: {
|
|
317
|
+
default: { inactiveColor: "#999999", horizontalGutter: 6 },
|
|
318
|
+
},
|
|
319
|
+
title: {
|
|
320
|
+
default: { inactiveFontColor: "#111111" },
|
|
321
|
+
focused: { fontColor: "#222222" },
|
|
322
|
+
},
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
expect(merged.background.inactiveColor).toBe("#999999");
|
|
326
|
+
expect(merged.background.horizontalGutter).toBe(6);
|
|
327
|
+
expect(merged.title.inactiveFontColor).toBe("#111111");
|
|
328
|
+
expect(merged.title.focusedFontColor).toBe("#222222");
|
|
329
|
+
});
|
|
253
330
|
});
|
|
254
331
|
|
|
255
332
|
describe("mergeHeaderConfiguration section header (Variant 3)", () => {
|
|
@@ -82,7 +82,7 @@ function mergeItemLabel(
|
|
|
82
82
|
...(override.lineHeight !== undefined
|
|
83
83
|
? { lineHeight: override.lineHeight }
|
|
84
84
|
: {}),
|
|
85
|
-
...(override.fontFamily
|
|
85
|
+
...(typeof override.fontFamily === "string" && override.fontFamily
|
|
86
86
|
? {
|
|
87
87
|
iosFontFamily: override.fontFamily,
|
|
88
88
|
androidFontFamily: override.fontFamily,
|
|
@@ -147,6 +147,8 @@ function mergeItemActionButtonAssets(
|
|
|
147
147
|
...base,
|
|
148
148
|
...(override.removeAsset ? { removeAsset: override.removeAsset } : {}),
|
|
149
149
|
...(override.dragAsset ? { dragAsset: override.dragAsset } : {}),
|
|
150
|
+
...(override.playAsset ? { playAsset: override.playAsset } : {}),
|
|
151
|
+
...(override.pauseAsset ? { pauseAsset: override.pauseAsset } : {}),
|
|
150
152
|
};
|
|
151
153
|
}
|
|
152
154
|
|
|
@@ -379,6 +381,22 @@ export function mergeHeaderConfiguration(
|
|
|
379
381
|
// Button Merging Helpers
|
|
380
382
|
// ---------------------------------------------------------------------------
|
|
381
383
|
|
|
384
|
+
function fontFamilyName(value: unknown): string | undefined {
|
|
385
|
+
if (typeof value === "string" && value.trim()) {
|
|
386
|
+
return value;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
if (value && typeof value === "object") {
|
|
390
|
+
const family = (value as { fontFamily?: unknown }).fontFamily;
|
|
391
|
+
|
|
392
|
+
if (typeof family === "string" && family.trim()) {
|
|
393
|
+
return family;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
return undefined;
|
|
398
|
+
}
|
|
399
|
+
|
|
382
400
|
function mergeButtonBackground(
|
|
383
401
|
base: ButtonBackgroundConfiguration,
|
|
384
402
|
defaultOverride?: Record<string, any>,
|
|
@@ -397,6 +415,9 @@ function mergeButtonBackground(
|
|
|
397
415
|
...(defaultOverride?.backgroundColor
|
|
398
416
|
? { defaultColor: defaultOverride.backgroundColor }
|
|
399
417
|
: {}),
|
|
418
|
+
...(defaultOverride?.inactiveColor
|
|
419
|
+
? { inactiveColor: defaultOverride.inactiveColor }
|
|
420
|
+
: {}),
|
|
400
421
|
...(focusedColor != null && focusedColor !== "" ? { focusedColor } : {}),
|
|
401
422
|
...(defaultOverride?.borderRadius !== undefined
|
|
402
423
|
? { cornerRadius: defaultOverride.borderRadius }
|
|
@@ -413,47 +434,62 @@ function mergeButtonBackground(
|
|
|
413
434
|
...(defaultOverride?.paddingLeft !== undefined
|
|
414
435
|
? { paddingLeft: defaultOverride.paddingLeft }
|
|
415
436
|
: {}),
|
|
437
|
+
...(defaultOverride?.horizontalGutter !== undefined
|
|
438
|
+
? { horizontalGutter: defaultOverride.horizontalGutter }
|
|
439
|
+
: {}),
|
|
416
440
|
};
|
|
417
441
|
}
|
|
418
442
|
|
|
419
443
|
function mergeButtonTitle(
|
|
420
444
|
base: ButtonTitleConfiguration,
|
|
421
|
-
override?: Record<string, any
|
|
445
|
+
override?: Record<string, any>,
|
|
446
|
+
focusedOverride?: Record<string, any>
|
|
422
447
|
): ButtonTitleConfiguration {
|
|
423
|
-
if (!override) return base;
|
|
448
|
+
if (!override && !focusedOverride) return base;
|
|
449
|
+
|
|
450
|
+
const fontFamily = fontFamilyName(override?.fontFamily);
|
|
451
|
+
|
|
452
|
+
const focusedFontColor =
|
|
453
|
+
focusedOverride?.fontColor || override?.focusedFontColor;
|
|
454
|
+
|
|
455
|
+
const inactiveFontColor = override?.inactiveFontColor;
|
|
424
456
|
|
|
425
457
|
return {
|
|
426
458
|
...base,
|
|
427
|
-
...(override
|
|
428
|
-
...(
|
|
429
|
-
...(
|
|
459
|
+
...(override?.fontColor ? { fontColor: override.fontColor } : {}),
|
|
460
|
+
...(focusedFontColor ? { focusedFontColor } : {}),
|
|
461
|
+
...(inactiveFontColor ? { inactiveFontColor } : {}),
|
|
462
|
+
...(override?.fontSize !== undefined
|
|
463
|
+
? { fontSize: override.fontSize }
|
|
464
|
+
: {}),
|
|
465
|
+
...(override?.lineHeight !== undefined
|
|
430
466
|
? { lineHeight: override.lineHeight }
|
|
431
467
|
: {}),
|
|
432
|
-
...(
|
|
468
|
+
...(fontFamily
|
|
433
469
|
? {
|
|
434
|
-
iosFontFamily:
|
|
435
|
-
androidFontFamily:
|
|
470
|
+
iosFontFamily: fontFamily,
|
|
471
|
+
androidFontFamily: fontFamily,
|
|
436
472
|
}
|
|
437
473
|
: {}),
|
|
438
|
-
...(override
|
|
474
|
+
...(override?.iosFontFamily
|
|
439
475
|
? { iosFontFamily: override.iosFontFamily }
|
|
440
476
|
: {}),
|
|
441
|
-
...(override
|
|
477
|
+
...(override?.androidFontFamily
|
|
442
478
|
? { androidFontFamily: override.androidFontFamily }
|
|
443
479
|
: {}),
|
|
444
|
-
...(override
|
|
480
|
+
...(override?.letterSpacing !== undefined
|
|
445
481
|
? {
|
|
446
482
|
iosLetterSpacing: override.letterSpacing,
|
|
447
483
|
androidLetterSpacing: override.letterSpacing,
|
|
448
484
|
}
|
|
449
485
|
: {}),
|
|
450
|
-
...(override
|
|
486
|
+
...(override?.iosLetterSpacing !== undefined
|
|
451
487
|
? { iosLetterSpacing: override.iosLetterSpacing }
|
|
452
488
|
: {}),
|
|
453
|
-
...(override
|
|
489
|
+
...(override?.androidLetterSpacing !== undefined
|
|
454
490
|
? { androidLetterSpacing: override.androidLetterSpacing }
|
|
455
491
|
: {}),
|
|
456
|
-
...(override
|
|
492
|
+
...(override?.textTransform
|
|
457
493
|
? { textTransform: override.textTransform }
|
|
458
494
|
: {}),
|
|
459
495
|
};
|
|
@@ -509,13 +545,19 @@ export function mergeButtonConfiguration(
|
|
|
509
545
|
const titleOverride =
|
|
510
546
|
buttonBlock?.title?.default || actionBlock?.title?.default;
|
|
511
547
|
|
|
548
|
+
const titleFocused =
|
|
549
|
+
buttonBlock?.title?.focused ||
|
|
550
|
+
buttonBlock?.title?.focus ||
|
|
551
|
+
actionBlock?.title?.focused ||
|
|
552
|
+
actionBlock?.title?.focus;
|
|
553
|
+
|
|
512
554
|
const iconsOverride = buttonBlock?.icons || actionBlock?.icons;
|
|
513
555
|
const leadingOverride = buttonBlock?.leadingIcon || actionBlock?.leadingIcon;
|
|
514
556
|
|
|
515
557
|
return {
|
|
516
558
|
...base,
|
|
517
559
|
background: mergeButtonBackground(base.background, bgDefault, bgFocused),
|
|
518
|
-
title: mergeButtonTitle(base.title, titleOverride),
|
|
560
|
+
title: mergeButtonTitle(base.title, titleOverride, titleFocused),
|
|
519
561
|
icons: mergeButtonIcons(base.icons, iconsOverride, leadingOverride),
|
|
520
562
|
};
|
|
521
563
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Web builds have no draggable bottom sheet: `ModalProvider` renders `null` on web,
|
|
5
|
+
* so nothing mounts `BottomSheetContext` and the native component's `useBottomSheet()`
|
|
6
|
+
* is always null there — it already renders its children unchanged.
|
|
7
|
+
*
|
|
8
|
+
* This variant keeps that behaviour and keeps `react-native-gesture-handler`, which the
|
|
9
|
+
* native implementation imports for `PanGestureHandler`, out of web bundles entirely.
|
|
10
|
+
*/
|
|
11
|
+
export const BottomSheetDragArea = ({
|
|
12
|
+
children,
|
|
13
|
+
}: {
|
|
14
|
+
children: React.ReactElement;
|
|
15
|
+
}) => children;
|