@draftbit/core 50.6.1 → 50.6.2-bbb0a5.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 +18 -2
- package/lib/typescript/src/components/Image.js +19 -4
- package/lib/typescript/src/components/Image.js.map +1 -1
- package/lib/typescript/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -3
- package/src/components/Image.js +19 -4
- package/src/components/Image.js.map +1 -1
- package/src/components/Image.tsx +73 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@draftbit/core",
|
|
3
|
-
"version": "50.6.
|
|
3
|
+
"version": "50.6.2-bbb0a5.2+bbb0a57",
|
|
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.
|
|
45
|
+
"@draftbit/theme": "^50.6.2-bbb0a5.2+bbb0a57",
|
|
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,6 +55,7 @@
|
|
|
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",
|
|
58
59
|
"lodash.isequal": "^4.5.0",
|
|
59
60
|
"lodash.isnumber": "^3.0.3",
|
|
60
61
|
"lodash.omit": "^4.5.0",
|
|
@@ -122,5 +123,5 @@
|
|
|
122
123
|
],
|
|
123
124
|
"testEnvironment": "node"
|
|
124
125
|
},
|
|
125
|
-
"gitHead": "
|
|
126
|
+
"gitHead": "bbb0a57567d569643de097c356fd097ce68d6619"
|
|
126
127
|
}
|
package/src/components/Image.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* README: Internal Image component used for stuff like Card. DO NOT EXPORT! */
|
|
2
2
|
import React from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { StyleSheet } from "react-native";
|
|
4
|
+
import { Image as ExpoImage, } from "expo-image";
|
|
4
5
|
import Config from "./Config";
|
|
5
6
|
import AspectRatio from "./AspectRatio";
|
|
6
7
|
const generateDimensions = ({ aspectRatio, width, height, }) => {
|
|
@@ -26,15 +27,29 @@ const generateDimensions = ({ aspectRatio, width, height, }) => {
|
|
|
26
27
|
}
|
|
27
28
|
return { width, height };
|
|
28
29
|
};
|
|
29
|
-
const
|
|
30
|
+
const resizeModeToContentFit = (resizeMode) => {
|
|
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 }) => {
|
|
30
43
|
let imageSource = source === null || source === undefined
|
|
31
44
|
? Config.placeholderImageURL
|
|
32
45
|
: source;
|
|
33
46
|
const styles = StyleSheet.flatten(style || {});
|
|
34
47
|
const { aspectRatio, width, height } = generateDimensions(styles);
|
|
48
|
+
// Use contentFit if provided, otherwise fall back to resizeMode
|
|
49
|
+
const finalContentFit = contentFit || resizeModeToContentFit(resizeMode);
|
|
35
50
|
if (aspectRatio) {
|
|
36
51
|
return (React.createElement(AspectRatio, { style: [style, { width, height, aspectRatio }] },
|
|
37
|
-
React.createElement(
|
|
52
|
+
React.createElement(ExpoImage, { ...props, source: imageSource, contentFit: finalContentFit, placeholder: placeholder, transition: transition, contentPosition: contentPosition, cachePolicy: cachePolicy, allowDownscaling: allowDownscaling, recyclingKey: recyclingKey, style: [
|
|
38
53
|
style,
|
|
39
54
|
{
|
|
40
55
|
height: "100%",
|
|
@@ -42,7 +57,7 @@ const Image = ({ source, resizeMode = "cover", style, ...props }) => {
|
|
|
42
57
|
},
|
|
43
58
|
] })));
|
|
44
59
|
}
|
|
45
|
-
return (React.createElement(
|
|
60
|
+
return (React.createElement(ExpoImage, { ...props, source: source, contentFit: finalContentFit, placeholder: placeholder, transition: transition, contentPosition: contentPosition, cachePolicy: cachePolicy, allowDownscaling: allowDownscaling, recyclingKey: recyclingKey, style: style }));
|
|
46
61
|
};
|
|
47
62
|
export default Image;
|
|
48
63
|
//# 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,EACL,KAAK,IAAI,
|
|
1
|
+
{"version":3,"file":"Image.js","sourceRoot":"","sources":["Image.tsx"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAuC,MAAM,cAAc,CAAC;AAC/E,OAAO,EACL,KAAK,IAAI,SAAS,GAGnB,MAAM,YAAY,CAAC;AACpB,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,WAAW,MAAM,eAAe,CAAC;AAkCxC,MAAM,kBAAkB,GAAG,CAAC,EAC1B,WAAW,EACX,KAAK,EACL,MAAM,GACS,EAIf,EA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AAW,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,kBAAkB,CACvD,MAAwB,CACzB,CAAC;IAEF,gEAAgE;IAChE,MAAM,eAAe,GAAG,UAAU,IAAI,sBAAsB,CAAC,UAAU,CAAC,CAAC;IAEzE,IAAI,WAAW,EAAE;QACf,OAAO,CACL,oBAAC,WAAW,IAAC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;YACzD,oBAAC,SAAS,OACJ,KAAK,EACT,MAAM,EAAE,WAAkC,EAC1C,UAAU,EAAE,eAAe,EAC3B,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,UAAU,EACtB,eAAe,EAAE,eAAe,EAChC,WAAW,EAAE,WAAW,EACxB,gBAAgB,EAAE,gBAAgB,EAClC,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE;oBACL,KAAK;oBACL;wBACE,MAAM,EAAE,MAAM;wBACd,KAAK,EAAE,MAAM;qBACd;iBACF,GACD,CACU,CACf,CAAC;KACH;IAED,OAAO,CACL,oBAAC,SAAS,OACJ,KAAK,EACT,MAAM,EAAE,MAA6B,EACrC,UAAU,EAAE,eAAe,EAC3B,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,UAAU,EACtB,eAAe,EAAE,eAAe,EAChC,WAAW,EAAE,WAAW,EACxB,gBAAgB,EAAE,gBAAgB,EAClC,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,KAAK,GACZ,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
package/src/components/Image.tsx
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
/* 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";
|
|
3
4
|
import {
|
|
4
|
-
Image as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
DimensionValue,
|
|
9
|
-
} from "react-native";
|
|
5
|
+
Image as ExpoImage,
|
|
6
|
+
ImageContentPosition,
|
|
7
|
+
ImageProps as ExpoImageProps,
|
|
8
|
+
} from "expo-image";
|
|
10
9
|
import Config from "./Config";
|
|
11
|
-
|
|
12
10
|
import AspectRatio from "./AspectRatio";
|
|
13
11
|
|
|
14
12
|
type ImageStyleProp = {
|
|
@@ -17,6 +15,32 @@ type ImageStyleProp = {
|
|
|
17
15
|
aspectRatio?: number;
|
|
18
16
|
};
|
|
19
17
|
|
|
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
|
+
|
|
20
44
|
const generateDimensions = ({
|
|
21
45
|
aspectRatio,
|
|
22
46
|
width,
|
|
@@ -52,10 +76,32 @@ const generateDimensions = ({
|
|
|
52
76
|
return { width, height };
|
|
53
77
|
};
|
|
54
78
|
|
|
55
|
-
const
|
|
79
|
+
const resizeModeToContentFit = (
|
|
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> = ({
|
|
56
95
|
source,
|
|
57
96
|
resizeMode = "cover",
|
|
58
97
|
style,
|
|
98
|
+
placeholder,
|
|
99
|
+
transition = 300,
|
|
100
|
+
contentFit = "cover",
|
|
101
|
+
contentPosition = "center",
|
|
102
|
+
cachePolicy = "memory-disk",
|
|
103
|
+
allowDownscaling = true,
|
|
104
|
+
recyclingKey,
|
|
59
105
|
...props
|
|
60
106
|
}) => {
|
|
61
107
|
let imageSource =
|
|
@@ -68,13 +114,22 @@ const Image: React.FC<ImageProps> = ({
|
|
|
68
114
|
styles as ImageStyleProp
|
|
69
115
|
);
|
|
70
116
|
|
|
117
|
+
// Use contentFit if provided, otherwise fall back to resizeMode
|
|
118
|
+
const finalContentFit = contentFit || resizeModeToContentFit(resizeMode);
|
|
119
|
+
|
|
71
120
|
if (aspectRatio) {
|
|
72
121
|
return (
|
|
73
122
|
<AspectRatio style={[style, { width, height, aspectRatio }]}>
|
|
74
|
-
<
|
|
123
|
+
<ExpoImage
|
|
75
124
|
{...props}
|
|
76
125
|
source={imageSource as ImageSourcePropType}
|
|
77
|
-
|
|
126
|
+
contentFit={finalContentFit}
|
|
127
|
+
placeholder={placeholder}
|
|
128
|
+
transition={transition}
|
|
129
|
+
contentPosition={contentPosition}
|
|
130
|
+
cachePolicy={cachePolicy}
|
|
131
|
+
allowDownscaling={allowDownscaling}
|
|
132
|
+
recyclingKey={recyclingKey}
|
|
78
133
|
style={[
|
|
79
134
|
style,
|
|
80
135
|
{
|
|
@@ -88,10 +143,16 @@ const Image: React.FC<ImageProps> = ({
|
|
|
88
143
|
}
|
|
89
144
|
|
|
90
145
|
return (
|
|
91
|
-
<
|
|
146
|
+
<ExpoImage
|
|
92
147
|
{...props}
|
|
93
148
|
source={source as ImageSourcePropType}
|
|
94
|
-
|
|
149
|
+
contentFit={finalContentFit}
|
|
150
|
+
placeholder={placeholder}
|
|
151
|
+
transition={transition}
|
|
152
|
+
contentPosition={contentPosition}
|
|
153
|
+
cachePolicy={cachePolicy}
|
|
154
|
+
allowDownscaling={allowDownscaling}
|
|
155
|
+
recyclingKey={recyclingKey}
|
|
95
156
|
style={style}
|
|
96
157
|
/>
|
|
97
158
|
);
|