@applicaster/zapp-react-native-ui-components 15.0.0-rc.49 → 15.0.0-rc.50
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/Image/Image.android.tsx +5 -1
- package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +11 -3
- package/Components/MasterCell/DefaultComponents/Image/Image.web.tsx +9 -1
- package/Components/MasterCell/DefaultComponents/Image/hooks/useImage.ts +15 -14
- package/Decorators/ZappPipesDataConnector/resolvers/StaticFeedResolver.tsx +1 -1
- package/Helpers/DataSourceHelper/index.ts +10 -1
- package/package.json +5 -5
|
@@ -32,6 +32,7 @@ export default function Image({
|
|
|
32
32
|
placeholderImage,
|
|
33
33
|
entry,
|
|
34
34
|
withDimensions,
|
|
35
|
+
source: sourceProp,
|
|
35
36
|
...otherProps
|
|
36
37
|
}: Props) {
|
|
37
38
|
const [showDefault, setShowDefault] = React.useState(false);
|
|
@@ -48,7 +49,10 @@ export default function Image({
|
|
|
48
49
|
entry,
|
|
49
50
|
showDefault,
|
|
50
51
|
placeholderImage: placeholderImage || "",
|
|
51
|
-
otherProps
|
|
52
|
+
otherProps: {
|
|
53
|
+
source: sourceProp,
|
|
54
|
+
state: otherProps.state,
|
|
55
|
+
},
|
|
52
56
|
});
|
|
53
57
|
|
|
54
58
|
const onError = React.useCallback(() => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Image as RnImage, ImageStyle } from "react-native";
|
|
3
|
-
import { equals, omit } from "ramda";
|
|
4
3
|
|
|
5
4
|
import { useImageSource } from "./hooks";
|
|
5
|
+
import { equals } from "@applicaster/zapp-react-native-utils/utils";
|
|
6
6
|
|
|
7
7
|
type Source = {
|
|
8
8
|
uri: string;
|
|
@@ -25,11 +25,19 @@ function Image({
|
|
|
25
25
|
placeholderImage,
|
|
26
26
|
entry,
|
|
27
27
|
withDimensions,
|
|
28
|
+
source: sourceProp,
|
|
28
29
|
...otherProps
|
|
29
30
|
}: Props) {
|
|
30
31
|
const [error, setErrorState] = React.useState(null);
|
|
31
32
|
|
|
32
|
-
const source = useImageSource({
|
|
33
|
+
const source = useImageSource({
|
|
34
|
+
uri,
|
|
35
|
+
entry,
|
|
36
|
+
otherProps: {
|
|
37
|
+
source: sourceProp,
|
|
38
|
+
state: otherProps.state,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
33
41
|
|
|
34
42
|
React.useEffect(() => {
|
|
35
43
|
// reset error state on URI change as the error is referencing previous uri
|
|
@@ -49,7 +57,7 @@ function Image({
|
|
|
49
57
|
onError={React.useCallback(() => setErrorState(true), [])}
|
|
50
58
|
// as we have defaults as "" for placeholder image, we need to pass undefined to source to not throw warnings
|
|
51
59
|
source={_source?.uri ? _source : undefined}
|
|
52
|
-
{...
|
|
60
|
+
{...otherProps}
|
|
53
61
|
/>
|
|
54
62
|
);
|
|
55
63
|
}
|
|
@@ -23,9 +23,17 @@ function Image({
|
|
|
23
23
|
placeholderImage,
|
|
24
24
|
entry,
|
|
25
25
|
withDimensions,
|
|
26
|
+
source: sourceProp,
|
|
26
27
|
...otherProps
|
|
27
28
|
}: Props) {
|
|
28
|
-
const source = useImageSource({
|
|
29
|
+
const source = useImageSource({
|
|
30
|
+
uri,
|
|
31
|
+
entry,
|
|
32
|
+
otherProps: {
|
|
33
|
+
source: sourceProp,
|
|
34
|
+
state: otherProps.state,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
29
37
|
|
|
30
38
|
const updatedSource = source ? withDimensions(source) : { uri: "" };
|
|
31
39
|
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { path } from "ramda";
|
|
3
2
|
|
|
4
3
|
import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
5
4
|
import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
|
|
6
5
|
import { extractAsset } from "./utils";
|
|
7
6
|
|
|
8
7
|
type Return = { uri: string } | null;
|
|
8
|
+
type Source = { context?: string; uri?: string } | null | undefined;
|
|
9
9
|
|
|
10
|
-
const getSourceContext =
|
|
11
|
-
const getSourceUri =
|
|
12
|
-
const getState = path(["state"]);
|
|
10
|
+
const getSourceContext = (source: Source) => source?.context;
|
|
11
|
+
const getSourceUri = (source: Source) => source?.uri;
|
|
13
12
|
|
|
14
|
-
export const useImageSource = ({
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
export const useImageSource = ({
|
|
14
|
+
uri,
|
|
15
|
+
entry,
|
|
16
|
+
otherProps: { source, state: uriState },
|
|
17
|
+
}): Return => {
|
|
18
|
+
const uriContext = getSourceContext(source);
|
|
17
19
|
|
|
18
20
|
const action = useActions(uriContext);
|
|
19
21
|
|
|
@@ -38,7 +40,7 @@ export const useImageSource = ({ uri, entry, otherProps }): Return => {
|
|
|
38
40
|
return { uri };
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
const uriFromSource = getSourceUri(
|
|
43
|
+
const uriFromSource = getSourceUri(source);
|
|
42
44
|
|
|
43
45
|
if (uriFromSource) {
|
|
44
46
|
return { uri: uriFromSource };
|
|
@@ -47,7 +49,7 @@ export const useImageSource = ({ uri, entry, otherProps }): Return => {
|
|
|
47
49
|
return null;
|
|
48
50
|
};
|
|
49
51
|
|
|
50
|
-
const getSource = (uri, showDefault, placeholderImage,
|
|
52
|
+
const getSource = (uri, showDefault, placeholderImage, source) => {
|
|
51
53
|
const placeholderName = placeholderImage || "";
|
|
52
54
|
|
|
53
55
|
const defaultPath = {
|
|
@@ -60,7 +62,7 @@ const getSource = (uri, showDefault, placeholderImage, otherProps) => {
|
|
|
60
62
|
return { uri };
|
|
61
63
|
}
|
|
62
64
|
|
|
63
|
-
const uriFromSource = getSourceUri(
|
|
65
|
+
const uriFromSource = getSourceUri(source);
|
|
64
66
|
|
|
65
67
|
if (uriFromSource) {
|
|
66
68
|
return { uri: uriFromSource };
|
|
@@ -74,10 +76,9 @@ export const useImageSourceWithDefault = ({
|
|
|
74
76
|
entry,
|
|
75
77
|
showDefault,
|
|
76
78
|
placeholderImage,
|
|
77
|
-
otherProps,
|
|
79
|
+
otherProps: { state: uriState, source },
|
|
78
80
|
}): Return => {
|
|
79
|
-
const uriContext = getSourceContext(
|
|
80
|
-
const uriState = getState(otherProps);
|
|
81
|
+
const uriContext = getSourceContext(source);
|
|
81
82
|
|
|
82
83
|
const action = useActions(uriContext);
|
|
83
84
|
|
|
@@ -98,5 +99,5 @@ export const useImageSourceWithDefault = ({
|
|
|
98
99
|
return extractAsset(!isTV(), entryStateLocal.asset, uriState);
|
|
99
100
|
}
|
|
100
101
|
|
|
101
|
-
return getSource(uri, showDefault, placeholderImage,
|
|
102
|
+
return getSource(uri, showDefault, placeholderImage, source);
|
|
102
103
|
};
|
|
@@ -76,7 +76,7 @@ export function StaticFeedResolver({
|
|
|
76
76
|
|
|
77
77
|
const zappPipesDataProps = useMemo(
|
|
78
78
|
() => ({
|
|
79
|
-
zappPipesData: { url, loading, data, error },
|
|
79
|
+
zappPipesData: { url, loading, data, error }, // todo: add applyItemLimit
|
|
80
80
|
reloadData,
|
|
81
81
|
loadNextData: undefined, // Static resolver doesn't support pagination
|
|
82
82
|
}),
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { toPositiveNumberWithDefault } from "@applicaster/zapp-react-native-utils/numberUtils";
|
|
2
2
|
|
|
3
|
-
export function itemLimitForData(
|
|
3
|
+
export function itemLimitForData(
|
|
4
|
+
entry: ZappEntry[],
|
|
5
|
+
component: {
|
|
6
|
+
rules?: { item_limit?: number | string };
|
|
7
|
+
}
|
|
8
|
+
) {
|
|
9
|
+
if (!component?.rules?.item_limit) {
|
|
10
|
+
return entry;
|
|
11
|
+
}
|
|
12
|
+
|
|
4
13
|
const itemLimit = toPositiveNumberWithDefault(
|
|
5
14
|
Infinity,
|
|
6
15
|
component?.rules?.item_limit
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-ui-components",
|
|
3
|
-
"version": "15.0.0-rc.
|
|
3
|
+
"version": "15.0.0-rc.50",
|
|
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",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@applicaster/applicaster-types": "15.0.0-rc.
|
|
32
|
-
"@applicaster/zapp-react-native-bridge": "15.0.0-rc.
|
|
33
|
-
"@applicaster/zapp-react-native-redux": "15.0.0-rc.
|
|
34
|
-
"@applicaster/zapp-react-native-utils": "15.0.0-rc.
|
|
31
|
+
"@applicaster/applicaster-types": "15.0.0-rc.50",
|
|
32
|
+
"@applicaster/zapp-react-native-bridge": "15.0.0-rc.50",
|
|
33
|
+
"@applicaster/zapp-react-native-redux": "15.0.0-rc.50",
|
|
34
|
+
"@applicaster/zapp-react-native-utils": "15.0.0-rc.50",
|
|
35
35
|
"fast-json-stable-stringify": "^2.1.0",
|
|
36
36
|
"promise": "^8.3.0",
|
|
37
37
|
"url": "^0.11.0",
|