@draftbit/core 50.6.2-bbb0a5.2 → 50.6.2-eac111.2
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/lib/commonjs/components/Image.js +1 -1
- package/lib/typescript/src/components/Image.d.ts +2 -18
- package/lib/typescript/src/components/Image.js +4 -19
- package/lib/typescript/src/components/Image.js.map +1 -1
- package/lib/typescript/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -4
- package/src/components/Image.js +4 -19
- package/src/components/Image.js.map +1 -1
- package/src/components/Image.tsx +12 -73
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@draftbit/core",
|
|
3
|
-
"version": "50.6.2-
|
|
3
|
+
"version": "50.6.2-eac111.2+eac111a",
|
|
4
4
|
"description": "Core (non-native) Components",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"types": "lib/typescript/src/index.d.ts",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@date-io/date-fns": "^1.3.13",
|
|
43
43
|
"@dotlottie/react-player": "1.6.1",
|
|
44
44
|
"@draftbit/react-theme-provider": "^2.1.1",
|
|
45
|
-
"@draftbit/theme": "^50.6.2-
|
|
45
|
+
"@draftbit/theme": "^50.6.2-eac111.2+eac111a",
|
|
46
46
|
"@expo/vector-icons": "^14.0.0",
|
|
47
47
|
"@gorhom/bottom-sheet": "5.0.0-alpha.7",
|
|
48
48
|
"@lottiefiles/react-lottie-player": "3.5.3",
|
|
@@ -55,7 +55,6 @@
|
|
|
55
55
|
"date-fns": "^2.16.1",
|
|
56
56
|
"dateformat": "^3.0.3",
|
|
57
57
|
"expo-av": "~13.10.6",
|
|
58
|
-
"expo-image": "1.10.6",
|
|
59
58
|
"lodash.isequal": "^4.5.0",
|
|
60
59
|
"lodash.isnumber": "^3.0.3",
|
|
61
60
|
"lodash.omit": "^4.5.0",
|
|
@@ -123,5 +122,5 @@
|
|
|
123
122
|
],
|
|
124
123
|
"testEnvironment": "node"
|
|
125
124
|
},
|
|
126
|
-
"gitHead": "
|
|
125
|
+
"gitHead": "eac111a68eb904b8b046d959dac40f2d30c14fd7"
|
|
127
126
|
}
|
package/src/components/Image.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/* README: Internal Image component used for stuff like Card. DO NOT EXPORT! */
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { StyleSheet } from "react-native";
|
|
4
|
-
import { Image as ExpoImage, } from "expo-image";
|
|
3
|
+
import { Image as NativeImage, StyleSheet, } from "react-native";
|
|
5
4
|
import Config from "./Config";
|
|
6
5
|
import AspectRatio from "./AspectRatio";
|
|
7
6
|
const generateDimensions = ({ aspectRatio, width, height, }) => {
|
|
@@ -27,29 +26,15 @@ const generateDimensions = ({ aspectRatio, width, height, }) => {
|
|
|
27
26
|
}
|
|
28
27
|
return { width, height };
|
|
29
28
|
};
|
|
30
|
-
const
|
|
31
|
-
// Convert deprecated resizeMode prop to contentFit prop used in expo-image
|
|
32
|
-
// Maps RN Image resizeMode values to their equivalent expo-image contentFit values
|
|
33
|
-
const mapping = {
|
|
34
|
-
cover: "cover",
|
|
35
|
-
contain: "contain",
|
|
36
|
-
stretch: "fill",
|
|
37
|
-
repeat: "none",
|
|
38
|
-
center: "scale-down",
|
|
39
|
-
};
|
|
40
|
-
return mapping[resizeMode] || "cover";
|
|
41
|
-
};
|
|
42
|
-
const Image = ({ source, resizeMode = "cover", style, placeholder, transition = 300, contentFit = "cover", contentPosition = "center", cachePolicy = "memory-disk", allowDownscaling = true, recyclingKey, ...props }) => {
|
|
29
|
+
const Image = ({ source, resizeMode = "cover", style, ...props }) => {
|
|
43
30
|
let imageSource = source === null || source === undefined
|
|
44
31
|
? Config.placeholderImageURL
|
|
45
32
|
: source;
|
|
46
33
|
const styles = StyleSheet.flatten(style || {});
|
|
47
34
|
const { aspectRatio, width, height } = generateDimensions(styles);
|
|
48
|
-
// Use contentFit if provided, otherwise fall back to resizeMode
|
|
49
|
-
const finalContentFit = contentFit || resizeModeToContentFit(resizeMode);
|
|
50
35
|
if (aspectRatio) {
|
|
51
36
|
return (React.createElement(AspectRatio, { style: [style, { width, height, aspectRatio }] },
|
|
52
|
-
React.createElement(
|
|
37
|
+
React.createElement(NativeImage, { ...props, source: imageSource, resizeMode: resizeMode, style: [
|
|
53
38
|
style,
|
|
54
39
|
{
|
|
55
40
|
height: "100%",
|
|
@@ -57,7 +42,7 @@ const Image = ({ source, resizeMode = "cover", style, placeholder, transition =
|
|
|
57
42
|
},
|
|
58
43
|
] })));
|
|
59
44
|
}
|
|
60
|
-
return (React.createElement(
|
|
45
|
+
return (React.createElement(NativeImage, { ...props, source: source, resizeMode: resizeMode, style: style }));
|
|
61
46
|
};
|
|
62
47
|
export default Image;
|
|
63
48
|
//# sourceMappingURL=Image.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.js","sourceRoot":"","sources":["Image.tsx"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,
|
|
1
|
+
{"version":3,"file":"Image.js","sourceRoot":"","sources":["Image.tsx"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,KAAK,IAAI,WAAW,EAEpB,UAAU,GAGX,MAAM,cAAc,CAAC;AACtB,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,OAAO,WAAW,MAAM,eAAe,CAAC;AAQxC,MAAM,kBAAkB,GAAG,CAAC,EAC1B,WAAW,EACX,KAAK,EACL,MAAM,GACS,EAIf,EAAE;IACF,IAAI,WAAW,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,EAAE;QACpC,OAAO;YACL,WAAW;YACX,KAAK,EAAE,MAAM;SACd,CAAC;KACH;IAED,IAAI,WAAW,IAAI,MAAM,EAAE;QACzB,OAAO;YACL,WAAW;YACX,MAA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|
/* README: Internal Image component used for stuff like Card. DO NOT EXPORT! */
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { StyleSheet, ImageSourcePropType, DimensionValue } from "react-native";
|
|
4
3
|
import {
|
|
5
|
-
Image as
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
Image as NativeImage,
|
|
5
|
+
ImageProps,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
ImageSourcePropType,
|
|
8
|
+
DimensionValue,
|
|
9
|
+
} from "react-native";
|
|
9
10
|
import Config from "./Config";
|
|
11
|
+
|
|
10
12
|
import AspectRatio from "./AspectRatio";
|
|
11
13
|
|
|
12
14
|
type ImageStyleProp = {
|
|
@@ -15,32 +17,6 @@ type ImageStyleProp = {
|
|
|
15
17
|
aspectRatio?: number;
|
|
16
18
|
};
|
|
17
19
|
|
|
18
|
-
interface ExtendedImageProps extends ExpoImageProps {
|
|
19
|
-
placeholder?: {
|
|
20
|
-
blurhash?: string;
|
|
21
|
-
thumbhash?: string;
|
|
22
|
-
};
|
|
23
|
-
transition?:
|
|
24
|
-
| number
|
|
25
|
-
| {
|
|
26
|
-
duration?: number;
|
|
27
|
-
effect?:
|
|
28
|
-
| "cross-dissolve"
|
|
29
|
-
| "flip-from-top"
|
|
30
|
-
| "flip-from-right"
|
|
31
|
-
| "flip-from-bottom"
|
|
32
|
-
| "flip-from-left"
|
|
33
|
-
| "curl-up"
|
|
34
|
-
| "curl-down";
|
|
35
|
-
timing?: "ease-in-out" | "ease-in" | "ease-out" | "linear";
|
|
36
|
-
};
|
|
37
|
-
contentFit?: "cover" | "contain" | "fill" | "none" | "scale-down";
|
|
38
|
-
contentPosition?: ImageContentPosition;
|
|
39
|
-
cachePolicy?: "none" | "disk" | "memory" | "memory-disk";
|
|
40
|
-
allowDownscaling?: boolean;
|
|
41
|
-
recyclingKey?: string;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
20
|
const generateDimensions = ({
|
|
45
21
|
aspectRatio,
|
|
46
22
|
width,
|
|
@@ -76,32 +52,10 @@ const generateDimensions = ({
|
|
|
76
52
|
return { width, height };
|
|
77
53
|
};
|
|
78
54
|
|
|
79
|
-
const
|
|
80
|
-
resizeMode: "cover" | "contain" | "stretch" | "repeat" | "center"
|
|
81
|
-
) => {
|
|
82
|
-
// Convert deprecated resizeMode prop to contentFit prop used in expo-image
|
|
83
|
-
// Maps RN Image resizeMode values to their equivalent expo-image contentFit values
|
|
84
|
-
const mapping = {
|
|
85
|
-
cover: "cover",
|
|
86
|
-
contain: "contain",
|
|
87
|
-
stretch: "fill",
|
|
88
|
-
repeat: "none",
|
|
89
|
-
center: "scale-down",
|
|
90
|
-
};
|
|
91
|
-
return mapping[resizeMode] || "cover";
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const Image: React.FC<ExtendedImageProps> = ({
|
|
55
|
+
const Image: React.FC<ImageProps> = ({
|
|
95
56
|
source,
|
|
96
57
|
resizeMode = "cover",
|
|
97
58
|
style,
|
|
98
|
-
placeholder,
|
|
99
|
-
transition = 300,
|
|
100
|
-
contentFit = "cover",
|
|
101
|
-
contentPosition = "center",
|
|
102
|
-
cachePolicy = "memory-disk",
|
|
103
|
-
allowDownscaling = true,
|
|
104
|
-
recyclingKey,
|
|
105
59
|
...props
|
|
106
60
|
}) => {
|
|
107
61
|
let imageSource =
|
|
@@ -114,22 +68,13 @@ const Image: React.FC<ExtendedImageProps> = ({
|
|
|
114
68
|
styles as ImageStyleProp
|
|
115
69
|
);
|
|
116
70
|
|
|
117
|
-
// Use contentFit if provided, otherwise fall back to resizeMode
|
|
118
|
-
const finalContentFit = contentFit || resizeModeToContentFit(resizeMode);
|
|
119
|
-
|
|
120
71
|
if (aspectRatio) {
|
|
121
72
|
return (
|
|
122
73
|
<AspectRatio style={[style, { width, height, aspectRatio }]}>
|
|
123
|
-
<
|
|
74
|
+
<NativeImage
|
|
124
75
|
{...props}
|
|
125
76
|
source={imageSource as ImageSourcePropType}
|
|
126
|
-
|
|
127
|
-
placeholder={placeholder}
|
|
128
|
-
transition={transition}
|
|
129
|
-
contentPosition={contentPosition}
|
|
130
|
-
cachePolicy={cachePolicy}
|
|
131
|
-
allowDownscaling={allowDownscaling}
|
|
132
|
-
recyclingKey={recyclingKey}
|
|
77
|
+
resizeMode={resizeMode}
|
|
133
78
|
style={[
|
|
134
79
|
style,
|
|
135
80
|
{
|
|
@@ -143,16 +88,10 @@ const Image: React.FC<ExtendedImageProps> = ({
|
|
|
143
88
|
}
|
|
144
89
|
|
|
145
90
|
return (
|
|
146
|
-
<
|
|
91
|
+
<NativeImage
|
|
147
92
|
{...props}
|
|
148
93
|
source={source as ImageSourcePropType}
|
|
149
|
-
|
|
150
|
-
placeholder={placeholder}
|
|
151
|
-
transition={transition}
|
|
152
|
-
contentPosition={contentPosition}
|
|
153
|
-
cachePolicy={cachePolicy}
|
|
154
|
-
allowDownscaling={allowDownscaling}
|
|
155
|
-
recyclingKey={recyclingKey}
|
|
94
|
+
resizeMode={resizeMode}
|
|
156
95
|
style={style}
|
|
157
96
|
/>
|
|
158
97
|
);
|