@applicaster/zapp-react-native-ui-components 13.0.0-alpha.5033140607 → 13.0.0-alpha.5112402674
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/AppContainer/__tests__/__snapshots__/AppContainer.test.js.snap +1 -1
- package/Components/AudioPlayer/__tests__/__snapshots__/Runtime.test.js.snap +4 -4
- package/Components/AudioPlayer/__tests__/__snapshots__/artWork.test.js.snap +3 -3
- package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +6 -6
- package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayerLayout.test.js.snap +7 -7
- package/Components/AudioPlayer/__tests__/__snapshots__/channel.test.js.snap +3 -3
- package/Components/AudioPlayer/__tests__/__snapshots__/summary.test.js.snap +2 -2
- package/Components/AudioPlayer/__tests__/__snapshots__/title.test.js.snap +2 -2
- package/Components/BaseFocusable/index.tsx +65 -28
- package/Components/Cell/Cell.tsx +11 -9
- package/Components/Cell/CellWithFocusable.tsx +1 -1
- package/Components/Cell/TvOSCellComponent.tsx +23 -30
- package/Components/Cell/index.js +3 -1
- package/Components/CellRendererResolver/__tests__/__snapshots__/cellRendererResolver.test.js.snap +20 -20
- package/Components/CellRendererResolver/__tests__/cellRendererResolver.test.js +5 -3
- package/Components/ComponentResolver/__tests__/__snapshots__/componentResolver.test.js.snap +5 -5
- package/Components/ComponentResolver/__tests__/componentResolver.test.js +11 -9
- package/Components/DisplayState/__tests__/__snapshots__/displayState.test.js.snap +2 -2
- package/Components/Focusable/Focusable.tsx +0 -54
- package/Components/Focusable/FocusableTvOS.tsx +6 -2
- package/Components/FocusableList/index.tsx +26 -10
- package/Components/FocusableScrollView/index.tsx +39 -12
- package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +76 -7
- package/Components/GeneralContentScreen/utils/useCurationAPI.ts +53 -9
- package/Components/Layout/TV/NavBarContainer.tsx +8 -7
- package/Components/Layout/TV/__tests__/ScreenContainer.test.tsx +1 -0
- package/Components/Layout/TV/__tests__/__snapshots__/LayoutContainer.test.tsx.snap +1 -1
- package/Components/Layout/TV/__tests__/__snapshots__/NavBarContainer.test.tsx.snap +4 -4
- package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +10 -10
- package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +1 -1
- package/Components/Layout/TV/__tests__/index.test.tsx +7 -3
- package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +1 -1
- package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +3 -3
- package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/__snapshots__/index.test.tsx.snap +1 -1
- package/Components/MasterCell/__tests__/__snapshots__/dataAdapter.test.js.snap +180 -180
- package/Components/MasterCell/__tests__/__snapshots__/elementMapper.test.js.snap +7 -7
- package/Components/MasterCell/__tests__/__snapshots__/masterCell.test.js.snap +34 -34
- package/Components/MasterCell/hooks/useAsyncRendering/index.ts +2 -2
- package/Components/NativeFocusables/{index.js → index.ts} +4 -2
- package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +7 -7
- package/Components/OfflineHandler/__tests__/index.test.tsx +28 -25
- package/Components/PlayerContainer/PlayerContainer.tsx +5 -11
- package/Components/PlayerContainer/PlayerContainerContext.tsx +9 -0
- package/Components/River/RefreshControl.tsx +1 -1
- package/Components/River/TV/index.tsx +6 -1
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +17 -17
- package/Components/River/__tests__/__snapshots__/river.test.js.snap +12 -12
- package/Components/River/__tests__/componentsMap.test.js +47 -12
- package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +1 -1
- package/Components/RouteManager/__tests__/__snapshots__/testId.test.js.snap +1 -1
- package/Components/Screen/__tests__/Screen.test.tsx +41 -27
- package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +4 -4
- package/Components/ScreenResolver/__tests__/__snapshots__/screenResolver.test.js.snap +2 -2
- package/Components/ScreenResolver/__tests__/screenResolver.test.js +31 -27
- package/Components/Tabs/Tab.tsx +1 -0
- package/Components/TextInputTv/__tests__/TextInputTv.test.js +42 -42
- package/Components/TextInputTv/__tests__/__snapshots__/TextInputTv.test.js.snap +7 -0
- package/Components/TextInputTv/index.tsx +2 -2
- package/Components/Touchable/__tests__/__snapshots__/touchable.test.tsx.snap +2 -2
- package/Components/Transitioner/__tests__/__snapshots__/AnimationManager.test.js.snap +26 -26
- package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +9 -9
- package/Components/Transitioner/__tests__/__snapshots__/config.test.js.snap +20 -20
- package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +2 -2
- package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +12 -7
- package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +6 -6
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +5 -1
- package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +5 -1
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +1 -1
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +4 -10
- package/Components/VideoModal/ModalAnimation/index.ts +2 -1
- package/Components/VideoModal/ModalAnimation/useModalAnimationContext.ts +6 -0
- package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +5 -2
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +12 -9
- package/Components/VideoModal/__tests__/__snapshots__/PlayerDetails.test.tsx.snap +4 -4
- package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +78 -78
- package/Components/VideoModal/utils.ts +2 -4
- package/Components/Viewport/ViewportAware/__tests__/__snapshots__/viewportAware.test.js.snap +2 -2
- package/Components/Viewport/ViewportTracker/__tests__/__snapshots__/viewportTracker.test.js.snap +1 -1
- package/Components/ZappUIComponent/__tests__/__snapshots__/ZappUIComponent.test.js.snap +11 -11
- package/Components/default-cell-renderer/__tests__/__snapshots__/defaultCellRenderer.test.tsx.snap +30 -30
- package/Contexts/ComponentsMapOffsetContext/index.tsx +46 -0
- package/Contexts/ConfigutaionContext/__tests__/__snapshots__/ConfigurationProvider.test.tsx.snap +1 -1
- package/Decorators/Analytics/{index.js → index.tsx} +11 -11
- package/Decorators/Navigator/__tests__/__snapshots__/navigator.test.js.snap +2 -2
- package/Decorators/RiverFeedLoader/__tests__/__snapshots__/riverFeedLoader.test.tsx.snap +77 -77
- package/Decorators/RiverFeedLoader/__tests__/riverFeedLoader.test.tsx +34 -39
- package/Decorators/RiverFeedLoader/__tests__/utils.test.ts +0 -9
- package/Decorators/RiverFeedLoader/index.tsx +1 -1
- package/Decorators/RiverFeedLoader/utils/getDatasourceUrl.ts +39 -0
- package/Decorators/RiverFeedLoader/utils/index.ts +29 -0
- package/Decorators/RiverFeedLoader/utils/usePipesContexts.ts +40 -0
- package/Decorators/RiverResolver/__tests__/__snapshots__/riverResolver.test.tsx.snap +5 -5
- package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +16 -10
- package/Decorators/ZappPipesDataConnector/index.tsx +1 -1
- package/package.json +12 -6
- package/Decorators/RiverFeedLoader/utils.ts +0 -100
|
@@ -3,73 +3,68 @@ import * as R from "ramda";
|
|
|
3
3
|
import { View } from "react-native";
|
|
4
4
|
import { render } from "@testing-library/react-native";
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
entryContext,
|
|
8
|
-
navigator,
|
|
9
|
-
river,
|
|
10
|
-
riverDataSources,
|
|
11
|
-
screenContext,
|
|
12
|
-
screenData,
|
|
13
|
-
searchContext,
|
|
14
|
-
} from "./fixtures";
|
|
6
|
+
import * as mock_fixtures from "./fixtures";
|
|
15
7
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
const mockUsePipesContexts = () => ({
|
|
9
|
+
entry: mock_fixtures.entryContext,
|
|
10
|
+
screen: mock_fixtures.screenContext,
|
|
11
|
+
search: mock_fixtures.searchContext,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const mockGetDatasourceUrl = jest.fn(
|
|
15
|
+
R.curry((_, component) => component.data.source)
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
jest.mock(
|
|
19
|
+
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useRoute",
|
|
20
|
+
() => ({
|
|
21
|
+
useRoute: jest.fn(() => ({ screenData: mock_fixtures.screenData })),
|
|
22
|
+
})
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
jest.mock(
|
|
26
|
+
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation",
|
|
27
|
+
() => ({
|
|
28
|
+
useNavigation: jest.fn(() => mock_fixtures.navigator),
|
|
29
|
+
})
|
|
30
|
+
);
|
|
20
31
|
|
|
21
32
|
jest.mock("../utils", () => ({
|
|
22
|
-
|
|
33
|
+
...jest.requireActual("../utils"),
|
|
23
34
|
loadDatasources: jest.fn(),
|
|
24
|
-
getDatasourceUrl:
|
|
25
|
-
usePipesContexts:
|
|
26
|
-
entryContext,
|
|
27
|
-
searchContext,
|
|
28
|
-
screenContext,
|
|
29
|
-
})),
|
|
30
|
-
ignoreComponentsWithClearCacheFlag: R.reject(
|
|
31
|
-
R.pathEq(["rules", "clear_cache_on_reload"], true)
|
|
32
|
-
),
|
|
35
|
+
getDatasourceUrl: mockGetDatasourceUrl,
|
|
36
|
+
usePipesContexts: mockUsePipesContexts,
|
|
33
37
|
}));
|
|
34
38
|
|
|
35
|
-
const { WithRiverFeedLoader } = require("../index");
|
|
36
|
-
|
|
37
39
|
const River = function (props) {
|
|
38
40
|
return <View {...props} />;
|
|
39
41
|
};
|
|
40
42
|
|
|
41
43
|
const riverProps = {
|
|
42
|
-
river,
|
|
44
|
+
river: mock_fixtures.river,
|
|
43
45
|
dispatch: jest.fn(),
|
|
44
46
|
};
|
|
45
47
|
|
|
46
|
-
const DecoratedRiver = WithRiverFeedLoader(River);
|
|
47
|
-
|
|
48
48
|
const { loadDatasources, getDatasourceUrl } = require("../utils");
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
const getWrapper = () => render(<DecoratedRiver {...riverProps} />);
|
|
50
|
+
const { WithRiverFeedLoader } = require("..");
|
|
52
51
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
});
|
|
52
|
+
describe("WithRiverFeedLoader", () => {
|
|
53
|
+
const DecoratedRiver = WithRiverFeedLoader(River);
|
|
54
|
+
const wrapper = render(<DecoratedRiver {...riverProps} />);
|
|
57
55
|
|
|
58
56
|
it("renders correctly", () => {
|
|
59
|
-
const wrapper = getWrapper();
|
|
60
57
|
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
61
58
|
});
|
|
62
59
|
|
|
63
60
|
it("collects the datasources in the screen and loads them", () => {
|
|
64
|
-
getWrapper();
|
|
65
|
-
|
|
66
61
|
expect(getDatasourceUrl).toHaveBeenCalledTimes(1);
|
|
67
62
|
expect(loadDatasources).toHaveBeenCalledTimes(1);
|
|
68
63
|
|
|
69
64
|
expect(loadDatasources).toHaveBeenNthCalledWith(
|
|
70
65
|
1,
|
|
71
|
-
riverDataSources,
|
|
72
|
-
river.id,
|
|
66
|
+
mock_fixtures.riverDataSources,
|
|
67
|
+
mock_fixtures.river.id,
|
|
73
68
|
riverProps.dispatch
|
|
74
69
|
);
|
|
75
70
|
});
|
|
@@ -14,7 +14,6 @@ jest.mock("@applicaster/zapp-react-native-redux/ZappPipes", () => ({
|
|
|
14
14
|
}));
|
|
15
15
|
|
|
16
16
|
const {
|
|
17
|
-
DATASOURCE_CHUNKS,
|
|
18
17
|
loadDatasources,
|
|
19
18
|
riverIsCurrentRoute,
|
|
20
19
|
getDatasourceUrl,
|
|
@@ -27,14 +26,6 @@ const {
|
|
|
27
26
|
|
|
28
27
|
const dispatch = (value) => Promise.resolve(value);
|
|
29
28
|
|
|
30
|
-
describe("DATASOURCE_CHUNKS", () => {
|
|
31
|
-
const DEFAULT_DATASOURCE_CHUNKS = 10;
|
|
32
|
-
|
|
33
|
-
it("has the correct value", () => {
|
|
34
|
-
expect(DATASOURCE_CHUNKS).toBe(DEFAULT_DATASOURCE_CHUNKS);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
29
|
describe("loadDataSource", () => {
|
|
39
30
|
it("calls loadPipesData for each provided urls", async () => {
|
|
40
31
|
const urls = [
|
|
@@ -2,7 +2,7 @@ import React, { ComponentClass, FC, useEffect } from "react";
|
|
|
2
2
|
import * as R from "ramda";
|
|
3
3
|
import { DispatchProp } from "react-redux";
|
|
4
4
|
|
|
5
|
-
import { useRoute } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
5
|
+
import { useRoute } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useRoute";
|
|
6
6
|
|
|
7
7
|
import { mapAndSplit } from "@applicaster/zapp-react-native-utils/arrayUtils";
|
|
8
8
|
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as R from "ramda";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
getInflatedDataSourceUrl,
|
|
5
|
+
getSearchContext,
|
|
6
|
+
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
7
|
+
|
|
8
|
+
import { ZappPipesEntryContext } from "../../../Contexts";
|
|
9
|
+
|
|
10
|
+
export const getDatasourceUrl: (
|
|
11
|
+
contexts: {
|
|
12
|
+
screenData?: Record<string, any>;
|
|
13
|
+
entryContext: ReturnType<
|
|
14
|
+
typeof ZappPipesEntryContext.useZappPipesContext
|
|
15
|
+
>[0];
|
|
16
|
+
searchContext: string;
|
|
17
|
+
screenContext: ZappRiver;
|
|
18
|
+
},
|
|
19
|
+
component?: ZappUIComponent
|
|
20
|
+
) => string | null = R.curry(
|
|
21
|
+
(
|
|
22
|
+
{ screenData, entryContext, searchContext, screenContext },
|
|
23
|
+
component: ZappUIComponent
|
|
24
|
+
) => {
|
|
25
|
+
const { source, mapping } = R.propOr({}, ["data"], component);
|
|
26
|
+
|
|
27
|
+
if (mapping) {
|
|
28
|
+
const contexts = {
|
|
29
|
+
entry: entryContext,
|
|
30
|
+
screen: screenContext || screenData,
|
|
31
|
+
search: getSearchContext(searchContext, mapping),
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
return getInflatedDataSourceUrl({ source, mapping, contexts });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return source;
|
|
38
|
+
}
|
|
39
|
+
);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as R from "ramda";
|
|
2
|
+
import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
mapPromises,
|
|
6
|
+
reducePromises,
|
|
7
|
+
} from "@applicaster/zapp-react-native-utils/arrayUtils";
|
|
8
|
+
|
|
9
|
+
export { riverIsCurrentRoute, usePipesContexts } from "./usePipesContexts";
|
|
10
|
+
|
|
11
|
+
export { getDatasourceUrl } from "./getDatasourceUrl";
|
|
12
|
+
|
|
13
|
+
export const DATASOURCE_CHUNKS = 10;
|
|
14
|
+
|
|
15
|
+
export async function loadDatasources(urls: string[][], riverId, dispatch) {
|
|
16
|
+
return reducePromises<string, void>(
|
|
17
|
+
mapPromises<string, void>((url) => {
|
|
18
|
+
if (url) {
|
|
19
|
+
return dispatch(loadPipesData(url, { riverId }));
|
|
20
|
+
}
|
|
21
|
+
}),
|
|
22
|
+
undefined,
|
|
23
|
+
urls
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const ignoreComponentsWithClearCacheFlag = R.reject(
|
|
28
|
+
R.pathEq(["rules", "clear_cache_on_reload"], true)
|
|
29
|
+
);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as R from "ramda";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ZappPipesEntryContext,
|
|
5
|
+
ZappPipesScreenContext,
|
|
6
|
+
ZappPipesSearchContext,
|
|
7
|
+
} from "../../../Contexts";
|
|
8
|
+
|
|
9
|
+
export function riverIsCurrentRoute(riverId, route) {
|
|
10
|
+
const routeRiverId = R.compose(R.last, R.split("/"))(route);
|
|
11
|
+
|
|
12
|
+
return typeof riverId === "undefined" || routeRiverId === riverId;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function usePipesContexts(
|
|
16
|
+
riverId: string,
|
|
17
|
+
route: string
|
|
18
|
+
): {
|
|
19
|
+
entryContext: ReturnType<typeof ZappPipesEntryContext.useZappPipesContext>[0];
|
|
20
|
+
searchContext: string;
|
|
21
|
+
screenContext: ZappRiver;
|
|
22
|
+
} {
|
|
23
|
+
const isNestedScreen = !riverIsCurrentRoute(riverId, route);
|
|
24
|
+
|
|
25
|
+
const routeForEntry = isNestedScreen ? `${route}/river/${riverId}` : route;
|
|
26
|
+
|
|
27
|
+
const [entryContext] = ZappPipesEntryContext.useZappPipesContext(
|
|
28
|
+
routeForEntry,
|
|
29
|
+
isNestedScreen
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const [searchContext] = ZappPipesSearchContext.useZappPipesContext();
|
|
33
|
+
const [screenContext] = ZappPipesScreenContext.useZappPipesContext();
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
entryContext,
|
|
37
|
+
searchContext,
|
|
38
|
+
screenContext,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -4,22 +4,22 @@ exports[`withRiver HoC renders correctly 1`] = `
|
|
|
4
4
|
<mockConstructor
|
|
5
5
|
otherProp="otherProp"
|
|
6
6
|
river={
|
|
7
|
-
|
|
7
|
+
{
|
|
8
8
|
"id": "A123",
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
rivers={
|
|
12
|
-
|
|
13
|
-
"A123":
|
|
12
|
+
{
|
|
13
|
+
"A123": {
|
|
14
14
|
"id": "A123",
|
|
15
15
|
},
|
|
16
|
-
"B345":
|
|
16
|
+
"B345": {
|
|
17
17
|
"id": "B345",
|
|
18
18
|
},
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
screenData={
|
|
22
|
-
|
|
22
|
+
{
|
|
23
23
|
"id": "A123",
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { shallow } from "enzyme";
|
|
3
3
|
import { View } from "react-native";
|
|
4
4
|
import { shallowToJson } from "enzyme-to-json";
|
|
5
|
-
import * as
|
|
5
|
+
import * as usePathnameHooks from "@applicaster/zapp-react-native-utils/reactHooks/navigation/usePathname";
|
|
6
6
|
|
|
7
7
|
const rivers = {
|
|
8
8
|
A123: {
|
|
@@ -13,15 +13,21 @@ const rivers = {
|
|
|
13
13
|
},
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
jest.doMock(
|
|
17
|
-
usePickFromState
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
jest.doMock(
|
|
17
|
+
"@applicaster/zapp-react-native-redux/hooks/usePickFromState",
|
|
18
|
+
() => ({
|
|
19
|
+
usePickFromState: jest.fn(() => ({ rivers })),
|
|
20
|
+
})
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
jest.mock(
|
|
24
|
+
"@applicaster/zapp-react-native-utils/reactHooks/layout/useLayoutVersion",
|
|
25
|
+
() => ({
|
|
26
|
+
useLayoutVersion: jest.fn(() => true),
|
|
27
|
+
})
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
jest.spyOn(usePathnameHooks, "usePathname").mockReturnValue("/home");
|
|
25
31
|
|
|
26
32
|
// mocks useNavigator to return currentRoute: "/home"
|
|
27
33
|
jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
17
17
|
|
|
18
18
|
import { ZappPipesSearchContext } from "@applicaster/zapp-react-native-ui-components/Contexts";
|
|
19
|
-
import { useScreenContext } from "@applicaster/zapp-react-native-utils/reactHooks/screen";
|
|
19
|
+
import { useScreenContext } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
|
|
20
20
|
|
|
21
21
|
import { isVerticalListOrGrid } from "./utils";
|
|
22
22
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-ui-components",
|
|
3
|
-
"version": "13.0.0-alpha.
|
|
3
|
+
"version": "13.0.0-alpha.5112402674",
|
|
4
4
|
"description": "Applicaster Zapp React Native ui components for the Quick Brick App",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -34,20 +34,26 @@
|
|
|
34
34
|
"redux-mock-store": "^1.5.3"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@applicaster/applicaster-types": "13.0.0-alpha.
|
|
38
|
-
"@applicaster/zapp-react-native-bridge": "13.0.0-alpha.
|
|
39
|
-
"@applicaster/zapp-react-native-redux": "13.0.0-alpha.
|
|
40
|
-
"@applicaster/zapp-react-native-utils": "13.0.0-alpha.
|
|
37
|
+
"@applicaster/applicaster-types": "13.0.0-alpha.5112402674",
|
|
38
|
+
"@applicaster/zapp-react-native-bridge": "13.0.0-alpha.5112402674",
|
|
39
|
+
"@applicaster/zapp-react-native-redux": "13.0.0-alpha.5112402674",
|
|
40
|
+
"@applicaster/zapp-react-native-utils": "13.0.0-alpha.5112402674",
|
|
41
41
|
"promise": "^8.3.0",
|
|
42
42
|
"react-router-native": "^5.1.2",
|
|
43
43
|
"url": "^0.11.0",
|
|
44
44
|
"uuid": "^3.3.2"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
+
"@applicaster/zapp-pipes-v2-client": "*",
|
|
47
48
|
"@react-native-community/netinfo": "*",
|
|
49
|
+
"@types/node": "*",
|
|
50
|
+
"immer": "*",
|
|
48
51
|
"react": "17.0.2",
|
|
49
52
|
"react-native": "0.68.6",
|
|
50
53
|
"react-native-safe-area-context": "*",
|
|
51
|
-
"react-native-svg": "*"
|
|
54
|
+
"react-native-svg": "*",
|
|
55
|
+
"uglify-js": "*",
|
|
56
|
+
"validate-color": "*",
|
|
57
|
+
"zustand": "*"
|
|
52
58
|
}
|
|
53
59
|
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import * as R from "ramda";
|
|
2
|
-
import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
getInflatedDataSourceUrl,
|
|
6
|
-
getSearchContext,
|
|
7
|
-
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
mapPromises,
|
|
11
|
-
reducePromises,
|
|
12
|
-
} from "@applicaster/zapp-react-native-utils/arrayUtils";
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
ZappPipesEntryContext,
|
|
16
|
-
ZappPipesScreenContext,
|
|
17
|
-
ZappPipesSearchContext,
|
|
18
|
-
} from "../../Contexts";
|
|
19
|
-
|
|
20
|
-
export const DATASOURCE_CHUNKS = 10;
|
|
21
|
-
|
|
22
|
-
export async function loadDatasources(urls: string[][], riverId, dispatch) {
|
|
23
|
-
return reducePromises<string, void>(
|
|
24
|
-
mapPromises<string, void>((url) => {
|
|
25
|
-
if (url) {
|
|
26
|
-
return dispatch(loadPipesData(url, { riverId }));
|
|
27
|
-
}
|
|
28
|
-
}),
|
|
29
|
-
undefined,
|
|
30
|
-
urls
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function riverIsCurrentRoute(riverId, route) {
|
|
35
|
-
const routeRiverId = R.compose(R.last, R.split("/"))(route);
|
|
36
|
-
|
|
37
|
-
return typeof riverId === "undefined" || routeRiverId === riverId;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export const ignoreComponentsWithClearCacheFlag = R.reject(
|
|
41
|
-
R.pathEq(["rules", "clear_cache_on_reload"], true)
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
export const getDatasourceUrl: (
|
|
45
|
-
contexts: {
|
|
46
|
-
screenData?: Record<string, any>;
|
|
47
|
-
entryContext: ReturnType<
|
|
48
|
-
typeof ZappPipesEntryContext.useZappPipesContext
|
|
49
|
-
>[0];
|
|
50
|
-
searchContext: string;
|
|
51
|
-
screenContext: ZappRiver;
|
|
52
|
-
},
|
|
53
|
-
component?: ZappUIComponent
|
|
54
|
-
) => string | null = R.curry(
|
|
55
|
-
(
|
|
56
|
-
{ screenData, entryContext, searchContext, screenContext },
|
|
57
|
-
component: ZappUIComponent
|
|
58
|
-
) => {
|
|
59
|
-
const { source, mapping } = R.propOr({}, ["data"], component);
|
|
60
|
-
|
|
61
|
-
if (mapping) {
|
|
62
|
-
const contexts = {
|
|
63
|
-
entry: entryContext,
|
|
64
|
-
screen: screenContext || screenData,
|
|
65
|
-
search: getSearchContext(searchContext, mapping),
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
return getInflatedDataSourceUrl({ source, mapping, contexts });
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return source;
|
|
72
|
-
}
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
export function usePipesContexts(
|
|
76
|
-
riverId: string,
|
|
77
|
-
route: string
|
|
78
|
-
): {
|
|
79
|
-
entryContext: ReturnType<typeof ZappPipesEntryContext.useZappPipesContext>[0];
|
|
80
|
-
searchContext: string;
|
|
81
|
-
screenContext: ZappRiver;
|
|
82
|
-
} {
|
|
83
|
-
const isNestedScreen = !riverIsCurrentRoute(riverId, route);
|
|
84
|
-
|
|
85
|
-
const routeForEntry = isNestedScreen ? `${route}/river/${riverId}` : route;
|
|
86
|
-
|
|
87
|
-
const [entryContext] = ZappPipesEntryContext.useZappPipesContext(
|
|
88
|
-
routeForEntry,
|
|
89
|
-
isNestedScreen
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
const [searchContext] = ZappPipesSearchContext.useZappPipesContext();
|
|
93
|
-
const [screenContext] = ZappPipesScreenContext.useZappPipesContext();
|
|
94
|
-
|
|
95
|
-
return {
|
|
96
|
-
entryContext,
|
|
97
|
-
searchContext,
|
|
98
|
-
screenContext,
|
|
99
|
-
};
|
|
100
|
-
}
|