@draftbit/core 50.6.1 → 50.6.2-88131d.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@draftbit/core",
3
- "version": "50.6.1",
3
+ "version": "50.6.2-88131d.2+88131db",
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.1",
45
+ "@draftbit/theme": "^50.6.2-88131d.2+88131db",
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": "34c5fe73043fbb66d05c432482196a1d2349e6b0"
126
+ "gitHead": "88131dbdb6546d351c39877dd3159f74ab265e0e"
126
127
  }
@@ -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 { Image as NativeImage, StyleSheet, } from "react-native";
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 Image = ({ source, resizeMode = "cover", style, ...props }) => {
30
+ const resizeModeToContentFit = (resizeMode) => {
31
+ var _a;
32
+ const mapping = {
33
+ cover: "cover",
34
+ contain: "contain",
35
+ stretch: "fill",
36
+ repeat: "none",
37
+ center: "scale-down",
38
+ };
39
+ return (_a = mapping[resizeMode]) !== null && _a !== void 0 ? _a : "cover";
40
+ };
41
+ const Image = ({ source, resizeMode = "cover", style, placeholder, transition = 300, contentFit = "cover", contentPosition = "center", cachePolicy = "memory-disk", allowDownscaling = true, recyclingKey, ...props }) => {
30
42
  let imageSource = source === null || source === undefined
31
43
  ? Config.placeholderImageURL
32
44
  : source;
33
45
  const styles = StyleSheet.flatten(style || {});
34
46
  const { aspectRatio, width, height } = generateDimensions(styles);
47
+ const finalContentFit = resizeMode
48
+ ? resizeModeToContentFit(resizeMode)
49
+ : contentFit;
35
50
  if (aspectRatio) {
36
51
  return (React.createElement(AspectRatio, { style: [style, { width, height, aspectRatio }] },
37
- React.createElement(NativeImage, { ...props, source: imageSource, resizeMode: resizeMode, style: [
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(NativeImage, { ...props, source: source, resizeMode: resizeMode, style: style }));
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,"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,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"}
@@ -1,14 +1,13 @@
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 NativeImage,
5
- ImageProps,
6
- StyleSheet,
7
- ImageSourcePropType,
8
- DimensionValue,
9
- } from "react-native";
5
+ Image as ExpoImage,
6
+ ImageContentPosition,
7
+ ImageProps as ExpoImageProps,
8
+ ImageContentFit,
9
+ } from "expo-image";
10
10
  import Config from "./Config";
11
-
12
11
  import AspectRatio from "./AspectRatio";
13
12
 
14
13
  type ImageStyleProp = {
@@ -17,6 +16,32 @@ type ImageStyleProp = {
17
16
  aspectRatio?: number;
18
17
  };
19
18
 
19
+ interface ExtendedImageProps extends ExpoImageProps {
20
+ placeholder?: {
21
+ blurhash?: string;
22
+ thumbhash?: string;
23
+ };
24
+ transition?:
25
+ | number
26
+ | {
27
+ duration?: number;
28
+ effect?:
29
+ | "cross-dissolve"
30
+ | "flip-from-top"
31
+ | "flip-from-right"
32
+ | "flip-from-bottom"
33
+ | "flip-from-left"
34
+ | "curl-up"
35
+ | "curl-down";
36
+ timing?: "ease-in-out" | "ease-in" | "ease-out" | "linear";
37
+ };
38
+ contentFit?: "cover" | "contain" | "fill" | "none" | "scale-down";
39
+ contentPosition?: ImageContentPosition;
40
+ cachePolicy?: "none" | "disk" | "memory" | "memory-disk";
41
+ allowDownscaling?: boolean;
42
+ recyclingKey?: string;
43
+ }
44
+
20
45
  const generateDimensions = ({
21
46
  aspectRatio,
22
47
  width,
@@ -52,10 +77,30 @@ const generateDimensions = ({
52
77
  return { width, height };
53
78
  };
54
79
 
55
- const Image: React.FC<ImageProps> = ({
80
+ const resizeModeToContentFit = (
81
+ resizeMode: "cover" | "contain" | "stretch" | "repeat" | "center"
82
+ ): ImageContentFit => {
83
+ const mapping: Record<typeof resizeMode, ImageContentFit> = {
84
+ cover: "cover",
85
+ contain: "contain",
86
+ stretch: "fill",
87
+ repeat: "none",
88
+ center: "scale-down",
89
+ } as const;
90
+ return mapping[resizeMode] ?? "cover";
91
+ };
92
+
93
+ const Image: React.FC<ExtendedImageProps> = ({
56
94
  source,
57
95
  resizeMode = "cover",
58
96
  style,
97
+ placeholder,
98
+ transition = 300,
99
+ contentFit = "cover",
100
+ contentPosition = "center",
101
+ cachePolicy = "memory-disk",
102
+ allowDownscaling = true,
103
+ recyclingKey,
59
104
  ...props
60
105
  }) => {
61
106
  let imageSource =
@@ -68,13 +113,23 @@ const Image: React.FC<ImageProps> = ({
68
113
  styles as ImageStyleProp
69
114
  );
70
115
 
116
+ const finalContentFit = resizeMode
117
+ ? resizeModeToContentFit(resizeMode)
118
+ : contentFit;
119
+
71
120
  if (aspectRatio) {
72
121
  return (
73
122
  <AspectRatio style={[style, { width, height, aspectRatio }]}>
74
- <NativeImage
123
+ <ExpoImage
75
124
  {...props}
76
125
  source={imageSource as ImageSourcePropType}
77
- resizeMode={resizeMode}
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
- <NativeImage
146
+ <ExpoImage
92
147
  {...props}
93
148
  source={source as ImageSourcePropType}
94
- resizeMode={resizeMode}
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
  );