@applicaster/zapp-react-native-utils 15.1.5-rc.2 → 15.1.6-alpha.2015591222
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/actionsExecutor/ActionExecutor.ts +8 -10
- package/actionsExecutor/ActionExecutorContext.tsx +49 -340
- package/actionsExecutor/actions/__tests__/dismissBottomSheet.test.ts +22 -0
- package/actionsExecutor/actions/__tests__/loadItemsFromSource.test.ts +88 -0
- package/actionsExecutor/actions/__tests__/openBottomSheet.customContent.test.ts +76 -0
- package/actionsExecutor/actions/__tests__/showToast.test.ts +63 -0
- package/actionsExecutor/actions/appRestart.ts +24 -0
- package/actionsExecutor/actions/confirmDialog.ts +53 -0
- package/actionsExecutor/actions/dismissBottomSheet.ts +22 -0
- package/actionsExecutor/actions/index.ts +34 -0
- package/actionsExecutor/actions/localStorageRemove.ts +27 -0
- package/actionsExecutor/actions/localStorageSet.ts +28 -0
- package/actionsExecutor/actions/localStorageToggleFlag.ts +28 -0
- package/actionsExecutor/actions/navigateToScreen.ts +123 -0
- package/actionsExecutor/actions/openBottomSheet.ts +318 -0
- package/actionsExecutor/actions/refreshComponent.ts +85 -0
- package/actionsExecutor/actions/screenSetVariable.ts +35 -0
- package/actionsExecutor/actions/screenToggleFlag.ts +38 -0
- package/actionsExecutor/actions/sendCloudEvent.ts +96 -0
- package/actionsExecutor/actions/sessionStorageRemove.ts +19 -0
- package/actionsExecutor/actions/sessionStorageSet.ts +20 -0
- package/actionsExecutor/actions/sessionStorageToggleFlag.ts +15 -0
- package/actionsExecutor/actions/showToast.ts +31 -0
- package/actionsExecutor/actions/switchLayout.ts +40 -0
- package/actionsExecutor/feedDecorator.ts +6 -6
- package/actionsExecutor/types.ts +59 -0
- package/analyticsUtils/PlayerAnalyticsManager.ts +1 -1
- package/appUtils/playerManager/OverlayObserver/OverlaysObserver.ts +12 -6
- package/appUtils/playerManager/__tests__/playerFactory.test.ts +1 -1
- package/appUtils/playerManager/{conts.ts → const.ts} +20 -0
- package/appUtils/playerManager/index.ts +1 -1
- package/appUtils/playerManager/player.ts +1 -1
- package/appUtils/playerManager/playerFactory.ts +1 -1
- package/appUtils/playerManager/playerNative.ts +1 -1
- package/appUtils/playerManager/usePlayerControllerSetup.tsx +1 -1
- package/appUtils/playerManager/userLanguagePreference.ts +1 -1
- package/manifestUtils/defaultManifestConfigurations/player.js +4 -4
- package/modalState/ContentViewModel.ts +111 -0
- package/modalState/EditableCollection.ts +17 -0
- package/modalState/EditableCollectionRegistry.ts +51 -0
- package/modalState/ModalOrchestrator.ts +198 -0
- package/modalState/RemoteEditableCollection.ts +189 -0
- package/modalState/__tests__/ContentViewModel.editable.test.ts +69 -0
- package/modalState/__tests__/ContentViewModel.test.ts +165 -0
- package/modalState/__tests__/EditableCollectionRegistry.test.ts +112 -0
- package/modalState/__tests__/ModalOrchestrator.phase3.test.ts +28 -0
- package/modalState/__tests__/RemoteEditableCollection.test.ts +259 -0
- package/modalState/__tests__/useBottomSheetContent.test.ts +372 -0
- package/modalState/index.ts +30 -83
- package/modalState/store.ts +102 -0
- package/modalState/types.ts +110 -0
- package/modalState/useBottomSheetContent.ts +98 -0
- package/package.json +2 -2
- package/reactHooks/layout/index.ts +1 -1
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import React, { useState, useEffect } from "react";
|
|
2
|
+
import { toBooleanWithDefaultFalse } from "@applicaster/zapp-react-native-utils/booleanUtils";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
isPresentSubMenuAction,
|
|
6
|
+
MenuItem,
|
|
7
|
+
modalOrchestrator,
|
|
8
|
+
} from "./ModalOrchestrator";
|
|
9
|
+
|
|
10
|
+
import { ContentViewModel } from "./ContentViewModel";
|
|
11
|
+
import type { SelectionBehavior } from "./types";
|
|
12
|
+
import type { EditableCollection } from "./EditableCollection";
|
|
13
|
+
|
|
14
|
+
type Props = {
|
|
15
|
+
viewModel?: ContentViewModel | null;
|
|
16
|
+
onPress: (item: MenuItem) => void | Promise<void>;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type Return = {
|
|
20
|
+
items: MenuItem[];
|
|
21
|
+
isLoading: boolean;
|
|
22
|
+
error?: Error | string;
|
|
23
|
+
showCentralLoading: boolean; // isLoading && items.length === 0
|
|
24
|
+
canGoBack: boolean; // modalOrchestrator.canGoBack
|
|
25
|
+
handleItemPress: (item: MenuItem) => Promise<void>;
|
|
26
|
+
goBackOrClose: () => void; // canGoBack ? back() : close()
|
|
27
|
+
close: () => void; // modalOrchestrator.close()
|
|
28
|
+
role?: string;
|
|
29
|
+
behavior?: SelectionBehavior;
|
|
30
|
+
editableCollection?: EditableCollection | null;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const useBottomSheetContent = (props: Props): Return => {
|
|
34
|
+
const { onPress, viewModel } = props;
|
|
35
|
+
|
|
36
|
+
const [state, setState] = useState(viewModel?.getState());
|
|
37
|
+
|
|
38
|
+
const [editableItems, setEditableItems] = useState<MenuItem[]>([]);
|
|
39
|
+
|
|
40
|
+
// Subscribe to the viewModel state changes
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
return viewModel?.subscribe((nextState) => {
|
|
43
|
+
setState(nextState);
|
|
44
|
+
});
|
|
45
|
+
}, [viewModel]);
|
|
46
|
+
|
|
47
|
+
// Subscribe to editable collection items
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (viewModel?.editableCollection) {
|
|
50
|
+
const subscription =
|
|
51
|
+
viewModel.editableCollection.items$.subscribe(setEditableItems);
|
|
52
|
+
|
|
53
|
+
return () => subscription.unsubscribe();
|
|
54
|
+
}
|
|
55
|
+
}, [viewModel?.editableCollection]);
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Handles an item press:
|
|
59
|
+
* - Delegates to the parent onPress (which runs the action and awaits it).
|
|
60
|
+
* - If the item was a leaf action (not a submenu), triggers viewModel.refetch()
|
|
61
|
+
* so that checkmarks (isSelected) reflect the updated server state.
|
|
62
|
+
*/
|
|
63
|
+
const handleItemPress = async (item: MenuItem) => {
|
|
64
|
+
const isSubMenu =
|
|
65
|
+
(item.submenu && item.submenu.length > 0) ||
|
|
66
|
+
(item.action && isPresentSubMenuAction(item.action));
|
|
67
|
+
|
|
68
|
+
await onPress(item);
|
|
69
|
+
|
|
70
|
+
if (!isSubMenu) {
|
|
71
|
+
await viewModel?.refetch();
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const goBackOrClose = React.useCallback(() => {
|
|
76
|
+
if (modalOrchestrator.canGoBack) {
|
|
77
|
+
modalOrchestrator.back();
|
|
78
|
+
} else {
|
|
79
|
+
modalOrchestrator.close();
|
|
80
|
+
}
|
|
81
|
+
}, [modalOrchestrator.canGoBack]);
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
items: viewModel?.editableCollection ? editableItems : state?.items,
|
|
85
|
+
isLoading: toBooleanWithDefaultFalse(state?.isLoading),
|
|
86
|
+
error: state?.error,
|
|
87
|
+
showCentralLoading: toBooleanWithDefaultFalse(
|
|
88
|
+
state?.isLoading && state?.items.length === 0
|
|
89
|
+
),
|
|
90
|
+
canGoBack: modalOrchestrator.canGoBack,
|
|
91
|
+
handleItemPress,
|
|
92
|
+
goBackOrClose,
|
|
93
|
+
close: () => modalOrchestrator.close(),
|
|
94
|
+
role: state?.role,
|
|
95
|
+
behavior: state?.behavior,
|
|
96
|
+
editableCollection: viewModel?.editableCollection,
|
|
97
|
+
};
|
|
98
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "15.1.
|
|
3
|
+
"version": "15.1.6-alpha.2015591222",
|
|
4
4
|
"description": "Applicaster Zapp React Native utilities package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@applicaster/applicaster-types": "15.1.
|
|
30
|
+
"@applicaster/applicaster-types": "15.1.6-alpha.2015591222",
|
|
31
31
|
"buffer": "^5.2.1",
|
|
32
32
|
"camelize": "^1.0.0",
|
|
33
33
|
"dayjs": "^1.11.10",
|