@tamagui/image 2.0.0-rc.4 → 2.0.0-rc.40
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/dist/cjs/Image.cjs +42 -40
- package/dist/cjs/Image.native.js +17 -15
- package/dist/cjs/Image.native.js.map +1 -1
- package/dist/cjs/createImage.cjs +123 -88
- package/dist/cjs/createImage.native.js +128 -95
- package/dist/cjs/createImage.native.js.map +1 -1
- package/dist/cjs/index.cjs +7 -5
- package/dist/cjs/index.native.js +7 -5
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/types.cjs +7 -5
- package/dist/cjs/types.native.js +7 -5
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/cjs/v1/Image.cjs +63 -48
- package/dist/cjs/v1/Image.native.js +91 -73
- package/dist/cjs/v1/Image.native.js.map +1 -1
- package/dist/cjs/v1/index.cjs +7 -5
- package/dist/cjs/v1/index.native.js +7 -5
- package/dist/cjs/v1/index.native.js.map +1 -1
- package/dist/esm/Image.mjs +28 -28
- package/dist/esm/Image.mjs.map +1 -1
- package/dist/esm/createImage.mjs +109 -76
- package/dist/esm/createImage.mjs.map +1 -1
- package/dist/esm/createImage.native.js +113 -82
- package/dist/esm/createImage.native.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -6
- package/dist/esm/v1/Image.mjs +34 -21
- package/dist/esm/v1/Image.mjs.map +1 -1
- package/dist/esm/v1/Image.native.js +62 -46
- package/dist/esm/v1/Image.native.js.map +1 -1
- package/dist/jsx/Image.mjs +28 -28
- package/dist/jsx/Image.mjs.map +1 -1
- package/dist/jsx/Image.native.js +17 -15
- package/dist/jsx/Image.native.js.map +1 -1
- package/dist/jsx/createImage.mjs +109 -76
- package/dist/jsx/createImage.mjs.map +1 -1
- package/dist/jsx/createImage.native.js +128 -95
- package/dist/jsx/createImage.native.js.map +1 -1
- package/dist/jsx/index.js +2 -2
- package/dist/jsx/index.js.map +1 -6
- package/dist/jsx/index.native.js +7 -5
- package/dist/jsx/types.native.js +7 -5
- package/dist/jsx/v1/Image.mjs +34 -21
- package/dist/jsx/v1/Image.mjs.map +1 -1
- package/dist/jsx/v1/Image.native.js +91 -73
- package/dist/jsx/v1/Image.native.js.map +1 -1
- package/dist/jsx/v1/index.native.js +7 -5
- package/package.json +9 -12
- package/src/createImage.tsx +20 -6
- package/src/types.ts +1 -1
- package/types/Image.native.d.ts +1 -1
- package/types/createImage.d.ts +2 -2
- package/types/createImage.d.ts.map +1 -1
- package/types/types.d.ts +1 -1
- package/types/types.d.ts.map +1 -1
- package/dist/cjs/Image.js +0 -55
- package/dist/cjs/Image.js.map +0 -6
- package/dist/cjs/createImage.js +0 -127
- package/dist/cjs/createImage.js.map +0 -6
- package/dist/cjs/index.js +0 -16
- package/dist/cjs/index.js.map +0 -6
- package/dist/cjs/types.js +0 -14
- package/dist/cjs/types.js.map +0 -6
- package/dist/cjs/v1/Image.js +0 -72
- package/dist/cjs/v1/Image.js.map +0 -6
- package/dist/cjs/v1/index.js +0 -15
- package/dist/cjs/v1/index.js.map +0 -6
- package/dist/esm/Image.js +0 -40
- package/dist/esm/Image.js.map +0 -6
- package/dist/esm/createImage.js +0 -112
- package/dist/esm/createImage.js.map +0 -6
- package/dist/esm/types.js +0 -1
- package/dist/esm/types.js.map +0 -6
- package/dist/esm/v1/Image.js +0 -52
- package/dist/esm/v1/Image.js.map +0 -6
- package/dist/esm/v1/index.js +0 -2
- package/dist/esm/v1/index.js.map +0 -6
- package/dist/jsx/Image.js +0 -40
- package/dist/jsx/Image.js.map +0 -6
- package/dist/jsx/createImage.js +0 -112
- package/dist/jsx/createImage.js.map +0 -6
- package/dist/jsx/types.js +0 -1
- package/dist/jsx/types.js.map +0 -6
- package/dist/jsx/v1/Image.js +0 -52
- package/dist/jsx/v1/Image.js.map +0 -6
- package/dist/jsx/v1/index.js +0 -2
- package/dist/jsx/v1/index.js.map +0 -6
package/dist/cjs/Image.cjs
CHANGED
|
@@ -3,57 +3,59 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
14
|
get: () => from[key],
|
|
14
15
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
18
20
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value:
|
|
21
|
+
value: true
|
|
20
22
|
}), mod);
|
|
21
23
|
var Image_exports = {};
|
|
22
24
|
__export(Image_exports, {
|
|
23
25
|
Image: () => Image
|
|
24
26
|
});
|
|
25
27
|
module.exports = __toCommonJS(Image_exports);
|
|
26
|
-
var import_web = require("@tamagui/web")
|
|
27
|
-
|
|
28
|
+
var import_web = require("@tamagui/web");
|
|
29
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
28
30
|
const StyledImage = (0, import_web.styled)(import_web.View, {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
31
|
+
name: "Image",
|
|
32
|
+
render: "img"
|
|
33
|
+
});
|
|
34
|
+
const Image = StyledImage.styleable((inProps, ref) => {
|
|
35
|
+
const {
|
|
36
|
+
// exclude native only props
|
|
37
|
+
blurRadius,
|
|
38
|
+
capInsets,
|
|
39
|
+
defaultSource,
|
|
40
|
+
fadeDuration,
|
|
41
|
+
loadingIndicatorSource,
|
|
42
|
+
onLoadEnd,
|
|
43
|
+
onPartialLoad,
|
|
44
|
+
progressiveRenderingEnabled,
|
|
45
|
+
resizeMethod,
|
|
46
|
+
tintColor,
|
|
47
|
+
...rest
|
|
48
|
+
} = inProps;
|
|
49
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(StyledImage, {
|
|
50
|
+
ref,
|
|
51
|
+
...rest
|
|
52
|
+
});
|
|
53
|
+
}, {
|
|
54
|
+
staticConfig: {
|
|
55
|
+
memo: true
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
const func = () => {};
|
|
57
59
|
Image.getSize = func;
|
|
58
60
|
Image.getSizeWithHeaders = func;
|
|
59
61
|
Image.prefetch = func;
|
package/dist/cjs/Image.native.js
CHANGED
|
@@ -5,29 +5,31 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value:
|
|
23
|
+
value: true
|
|
22
24
|
}), mod);
|
|
23
25
|
var Image_native_exports = {};
|
|
24
26
|
__export(Image_native_exports, {
|
|
25
27
|
Image: () => Image
|
|
26
28
|
});
|
|
27
29
|
module.exports = __toCommonJS(Image_native_exports);
|
|
28
|
-
var import_react_native = require("react-native")
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
var import_react_native = require("react-native");
|
|
31
|
+
var import_createImage = require("./createImage.native.js");
|
|
32
|
+
var Image = (0, import_createImage.createImage)({
|
|
33
|
+
Component: import_react_native.Image
|
|
34
|
+
});
|
|
33
35
|
//# sourceMappingURL=Image.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Image_native_exports","__export","Image","module","exports","__toCommonJS","import_react_native","require","import_createImage","createImage","Component"],"sources":["../../src/Image.native.tsx"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"names":["Image_native_exports","__export","Image","module","exports","__toCommonJS","import_react_native","require","import_createImage","createImage","Component"],"sources":["../../src/Image.native.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,oBAAA;AAAAC,QAAA,CAAAD,oBAAA;EAAAE,KAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAC,YAAA,CAAAL,oBAAA;AAAA,IAAAM,mBAAA,GAAiCC,OAAA;AACjC,IAAAC,kBAAA,GAA4BD,OAAA;AACrB,IAAIL,KAAA,OAAQM,kBAAA,CAAAC,WAAA,EAAY;EAC3BC,SAAA,EAAWJ,mBAAA,CAAAJ;AACf,CAAC","ignoreList":[]}
|
package/dist/cjs/createImage.cjs
CHANGED
|
@@ -3,103 +3,127 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
14
|
get: () => from[key],
|
|
14
15
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
18
20
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value:
|
|
21
|
+
value: true
|
|
20
22
|
}), mod);
|
|
21
23
|
var createImage_exports = {};
|
|
22
24
|
__export(createImage_exports, {
|
|
23
25
|
createImage: () => createImage
|
|
24
26
|
});
|
|
25
27
|
module.exports = __toCommonJS(createImage_exports);
|
|
26
|
-
var import_web = require("@tamagui/web")
|
|
27
|
-
|
|
28
|
+
var import_web = require("@tamagui/web");
|
|
29
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
28
30
|
const defaultObjectFitMap = objectFit => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
switch (objectFit) {
|
|
32
|
+
case "fill":
|
|
33
|
+
return "stretch";
|
|
34
|
+
case "none":
|
|
35
|
+
return "center";
|
|
36
|
+
case "scale-down":
|
|
37
|
+
return "contain";
|
|
38
|
+
case "contain":
|
|
39
|
+
return "contain";
|
|
40
|
+
default:
|
|
41
|
+
return "cover";
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const defaultTransformSource = props => {
|
|
45
|
+
const {
|
|
46
|
+
src,
|
|
47
|
+
source,
|
|
48
|
+
width,
|
|
49
|
+
height
|
|
50
|
+
} = props;
|
|
51
|
+
if (source) return source;
|
|
52
|
+
if (src && typeof src !== "string") return src;
|
|
53
|
+
return {
|
|
54
|
+
uri: src,
|
|
55
|
+
width,
|
|
56
|
+
height
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
function createImage(options) {
|
|
60
|
+
const {
|
|
61
|
+
Component,
|
|
62
|
+
mapObjectFitToResizeMode = defaultObjectFitMap,
|
|
63
|
+
resizeModePropName = "resizeMode",
|
|
64
|
+
objectPositionPropName,
|
|
65
|
+
transformSource = defaultTransformSource
|
|
66
|
+
} = options;
|
|
67
|
+
const inlinePropsSet = /* @__PURE__ */new Set(["source", "placeholder", "transition", "contentFit", "contentPosition", "cachePolicy", "recyclingKey", "allowDownscaling", "autoplay", "blurRadius", "priority", "placeholderContentFit", "responsivePolicy", "onLoadStart", "onProgress", "onLoadEnd"]);
|
|
68
|
+
const StyledImage = (0, import_web.styled)(Component, {
|
|
69
|
+
name: "Image"
|
|
70
|
+
}, {
|
|
71
|
+
inlineProps: inlinePropsSet
|
|
72
|
+
});
|
|
73
|
+
const ImageComponent = StyledImage.styleable((incomingProps, ref) => {
|
|
74
|
+
const props = incomingProps;
|
|
43
75
|
const {
|
|
44
76
|
src,
|
|
45
|
-
source,
|
|
46
77
|
width,
|
|
47
|
-
height
|
|
78
|
+
height,
|
|
79
|
+
borderRadius,
|
|
80
|
+
objectFit,
|
|
81
|
+
objectPosition,
|
|
82
|
+
// web only props - filter out on native
|
|
83
|
+
decoding,
|
|
84
|
+
elementTiming,
|
|
85
|
+
fetchpriority,
|
|
86
|
+
isMap,
|
|
87
|
+
loading,
|
|
88
|
+
sizes,
|
|
89
|
+
useMap,
|
|
90
|
+
onLoad,
|
|
91
|
+
onError,
|
|
92
|
+
...rest
|
|
48
93
|
} = props;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
94
|
+
const resolvedWidth = typeof width === "string" && width[0] === "$" ? (0, import_web.getTokenValue)(width, "size") : width;
|
|
95
|
+
const resolvedHeight = typeof height === "string" && height[0] === "$" ? (0, import_web.getTokenValue)(height, "size") : height;
|
|
96
|
+
const finalSource = transformSource({
|
|
97
|
+
src,
|
|
98
|
+
width: resolvedWidth,
|
|
99
|
+
height: resolvedHeight
|
|
53
100
|
});
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
ImageComponent = (0, import_web.styled)(Component, {
|
|
64
|
-
name: "Image"
|
|
65
|
-
}, {
|
|
66
|
-
inlineProps: /* @__PURE__ */new Set(["source", "placeholder", "transition", "contentFit", "contentPosition", "cachePolicy", "recyclingKey", "allowDownscaling", "autoplay", "blurRadius", "priority", "placeholderContentFit", "responsivePolicy", "onLoadStart", "onProgress", "onLoadEnd"])
|
|
67
|
-
}).styleable((incomingProps, ref) => {
|
|
68
|
-
const props = incomingProps,
|
|
69
|
-
{
|
|
70
|
-
src,
|
|
71
|
-
width,
|
|
72
|
-
height,
|
|
73
|
-
objectFit,
|
|
74
|
-
objectPosition,
|
|
75
|
-
// web only props - filter out on native
|
|
76
|
-
decoding,
|
|
77
|
-
elementTiming,
|
|
78
|
-
fetchpriority,
|
|
79
|
-
isMap,
|
|
80
|
-
loading,
|
|
81
|
-
sizes,
|
|
82
|
-
useMap,
|
|
83
|
-
onLoad,
|
|
84
|
-
onError,
|
|
85
|
-
...rest
|
|
86
|
-
} = props,
|
|
87
|
-
resolvedWidth = typeof width == "string" && width[0] === "$" ? (0, import_web.getTokenValue)(width) : width,
|
|
88
|
-
resolvedHeight = typeof height == "string" && height[0] === "$" ? (0, import_web.getTokenValue)(height) : height,
|
|
89
|
-
finalSource = transformSource({
|
|
90
|
-
src,
|
|
91
|
-
width: resolvedWidth,
|
|
92
|
-
height: resolvedHeight
|
|
101
|
+
const incomingStyle = Array.isArray(rest.style) ? Object.assign({}, ...rest.style.flat()) : rest.style;
|
|
102
|
+
const resolvedBorderRadius = typeof borderRadius === "string" && borderRadius[0] === "$" ? (0, import_web.getTokenValue)(borderRadius, "radius") : borderRadius;
|
|
103
|
+
const finalProps = {
|
|
104
|
+
...rest,
|
|
105
|
+
source: finalSource,
|
|
106
|
+
style: {
|
|
107
|
+
...incomingStyle,
|
|
108
|
+
...(resolvedBorderRadius !== void 0 && {
|
|
109
|
+
borderRadius: resolvedBorderRadius
|
|
93
110
|
}),
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
111
|
+
...(resolvedWidth !== void 0 && {
|
|
112
|
+
width: resolvedWidth
|
|
113
|
+
}),
|
|
114
|
+
...(resolvedHeight !== void 0 && {
|
|
115
|
+
height: resolvedHeight
|
|
116
|
+
})
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
if (objectFit) {
|
|
120
|
+
finalProps[resizeModePropName] = mapObjectFitToResizeMode(objectFit);
|
|
121
|
+
}
|
|
122
|
+
if (objectPositionPropName && objectPosition) {
|
|
123
|
+
finalProps[objectPositionPropName] = objectPosition;
|
|
124
|
+
}
|
|
125
|
+
if (onLoad) {
|
|
126
|
+
finalProps.onLoad = e => {
|
|
103
127
|
const source = e?.nativeEvent?.source || e?.source || {};
|
|
104
128
|
onLoad({
|
|
105
129
|
target: {
|
|
@@ -108,15 +132,26 @@ function createImage(options) {
|
|
|
108
132
|
},
|
|
109
133
|
type: "load"
|
|
110
134
|
});
|
|
111
|
-
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
if (onError) {
|
|
138
|
+
finalProps.onError = () => {
|
|
112
139
|
onError({
|
|
113
140
|
type: "error"
|
|
114
141
|
});
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Component, {
|
|
145
|
+
ref,
|
|
146
|
+
...finalProps
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
const comp = Component;
|
|
150
|
+
ImageComponent.getSize = comp.getSize || (() => {});
|
|
151
|
+
ImageComponent.getSizeWithHeaders = comp.getSizeWithHeaders || (() => {});
|
|
152
|
+
ImageComponent.prefetch = comp.prefetch || (() => {});
|
|
153
|
+
ImageComponent.prefetchWithMetadata = comp.prefetchWithMetadata || (() => {});
|
|
154
|
+
ImageComponent.abortPrefetch = comp.abortPrefetch || (() => {});
|
|
155
|
+
ImageComponent.queryCache = comp.queryCache || (() => {});
|
|
156
|
+
return ImageComponent;
|
|
122
157
|
}
|
|
@@ -5,124 +5,157 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value:
|
|
23
|
+
value: true
|
|
22
24
|
}), mod);
|
|
23
25
|
var createImage_exports = {};
|
|
24
26
|
__export(createImage_exports, {
|
|
25
27
|
createImage: () => createImage
|
|
26
28
|
});
|
|
27
29
|
module.exports = __toCommonJS(createImage_exports);
|
|
28
|
-
var import_jsx_runtime = require("react/jsx-runtime")
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
var import_web = require("@tamagui/web");
|
|
32
|
+
var defaultObjectFitMap = function (objectFit) {
|
|
33
|
+
switch (objectFit) {
|
|
34
|
+
case "fill":
|
|
35
|
+
return "stretch";
|
|
36
|
+
case "none":
|
|
37
|
+
return "center";
|
|
38
|
+
case "scale-down":
|
|
39
|
+
return "contain";
|
|
40
|
+
case "contain":
|
|
41
|
+
return "contain";
|
|
42
|
+
default:
|
|
43
|
+
return "cover";
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
var defaultTransformSource = function (props) {
|
|
47
|
+
var {
|
|
48
|
+
src,
|
|
49
|
+
source,
|
|
50
|
+
width,
|
|
51
|
+
height
|
|
52
|
+
} = props;
|
|
53
|
+
if (source) return source;
|
|
54
|
+
if (src && typeof src !== "string") return src;
|
|
55
|
+
return {
|
|
56
|
+
uri: src,
|
|
57
|
+
width,
|
|
58
|
+
height
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
function createImage(options) {
|
|
62
|
+
var {
|
|
63
|
+
Component,
|
|
64
|
+
mapObjectFitToResizeMode = defaultObjectFitMap,
|
|
65
|
+
resizeModePropName = "resizeMode",
|
|
66
|
+
objectPositionPropName,
|
|
67
|
+
transformSource = defaultTransformSource
|
|
68
|
+
} = options;
|
|
69
|
+
var inlinePropsSet = /* @__PURE__ */new Set(["source", "placeholder", "transition", "contentFit", "contentPosition", "cachePolicy", "recyclingKey", "allowDownscaling", "autoplay", "blurRadius", "priority", "placeholderContentFit", "responsivePolicy", "onLoadStart", "onProgress", "onLoadEnd"]);
|
|
70
|
+
var StyledImage = (0, import_web.styled)(Component, {
|
|
71
|
+
name: "Image"
|
|
72
|
+
}, {
|
|
73
|
+
inlineProps: inlinePropsSet
|
|
74
|
+
});
|
|
75
|
+
var ImageComponent = StyledImage.styleable(function (incomingProps, ref) {
|
|
76
|
+
var props = incomingProps;
|
|
45
77
|
var {
|
|
46
78
|
src,
|
|
47
|
-
source,
|
|
48
79
|
width,
|
|
49
|
-
height
|
|
80
|
+
height,
|
|
81
|
+
borderRadius,
|
|
82
|
+
objectFit,
|
|
83
|
+
objectPosition,
|
|
84
|
+
// web only props - filter out on native
|
|
85
|
+
decoding,
|
|
86
|
+
elementTiming,
|
|
87
|
+
fetchpriority,
|
|
88
|
+
isMap,
|
|
89
|
+
loading,
|
|
90
|
+
sizes,
|
|
91
|
+
useMap,
|
|
92
|
+
onLoad,
|
|
93
|
+
onError,
|
|
94
|
+
...rest
|
|
50
95
|
} = props;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
96
|
+
var resolvedWidth = typeof width === "string" && width[0] === "$" ? (0, import_web.getTokenValue)(width, "size") : width;
|
|
97
|
+
var resolvedHeight = typeof height === "string" && height[0] === "$" ? (0, import_web.getTokenValue)(height, "size") : height;
|
|
98
|
+
var finalSource = transformSource({
|
|
99
|
+
src,
|
|
100
|
+
width: resolvedWidth,
|
|
101
|
+
height: resolvedHeight
|
|
55
102
|
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
inlinePropsSet = /* @__PURE__ */new Set(["source", "placeholder", "transition", "contentFit", "contentPosition", "cachePolicy", "recyclingKey", "allowDownscaling", "autoplay", "blurRadius", "priority", "placeholderContentFit", "responsivePolicy", "onLoadStart", "onProgress", "onLoadEnd"]),
|
|
66
|
-
StyledImage = (0, import_web.styled)(Component, {
|
|
67
|
-
name: "Image"
|
|
68
|
-
}, {
|
|
69
|
-
inlineProps: inlinePropsSet
|
|
70
|
-
}),
|
|
71
|
-
ImageComponent = StyledImage.styleable(function (incomingProps, ref) {
|
|
72
|
-
var props = incomingProps,
|
|
73
|
-
{
|
|
74
|
-
src,
|
|
75
|
-
width,
|
|
76
|
-
height,
|
|
77
|
-
objectFit,
|
|
78
|
-
objectPosition,
|
|
79
|
-
// web only props - filter out on native
|
|
80
|
-
decoding,
|
|
81
|
-
elementTiming,
|
|
82
|
-
fetchpriority,
|
|
83
|
-
isMap,
|
|
84
|
-
loading,
|
|
85
|
-
sizes,
|
|
86
|
-
useMap,
|
|
87
|
-
onLoad,
|
|
88
|
-
onError,
|
|
89
|
-
...rest
|
|
90
|
-
} = props,
|
|
91
|
-
resolvedWidth = typeof width == "string" && width[0] === "$" ? (0, import_web.getTokenValue)(width) : width,
|
|
92
|
-
resolvedHeight = typeof height == "string" && height[0] === "$" ? (0, import_web.getTokenValue)(height) : height,
|
|
93
|
-
finalSource = transformSource({
|
|
94
|
-
src,
|
|
95
|
-
width: resolvedWidth,
|
|
96
|
-
height: resolvedHeight
|
|
103
|
+
var incomingStyle = Array.isArray(rest.style) ? Object.assign({}, ...rest.style.flat()) : rest.style;
|
|
104
|
+
var resolvedBorderRadius = typeof borderRadius === "string" && borderRadius[0] === "$" ? (0, import_web.getTokenValue)(borderRadius, "radius") : borderRadius;
|
|
105
|
+
var finalProps = {
|
|
106
|
+
...rest,
|
|
107
|
+
source: finalSource,
|
|
108
|
+
style: {
|
|
109
|
+
...incomingStyle,
|
|
110
|
+
...(resolvedBorderRadius !== void 0 && {
|
|
111
|
+
borderRadius: resolvedBorderRadius
|
|
97
112
|
}),
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
113
|
+
...(resolvedWidth !== void 0 && {
|
|
114
|
+
width: resolvedWidth
|
|
115
|
+
}),
|
|
116
|
+
...(resolvedHeight !== void 0 && {
|
|
117
|
+
height: resolvedHeight
|
|
118
|
+
})
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
if (objectFit) {
|
|
122
|
+
finalProps[resizeModePropName] = mapObjectFitToResizeMode(objectFit);
|
|
123
|
+
}
|
|
124
|
+
if (objectPositionPropName && objectPosition) {
|
|
125
|
+
finalProps[objectPositionPropName] = objectPosition;
|
|
126
|
+
}
|
|
127
|
+
if (onLoad) {
|
|
128
|
+
finalProps.onLoad = function (e) {
|
|
129
|
+
var _e_nativeEvent;
|
|
130
|
+
var source = (e === null || e === void 0 ? void 0 : (_e_nativeEvent = e.nativeEvent) === null || _e_nativeEvent === void 0 ? void 0 : _e_nativeEvent.source) || (e === null || e === void 0 ? void 0 : e.source) || {};
|
|
109
131
|
onLoad({
|
|
110
132
|
target: {
|
|
111
|
-
naturalHeight: source
|
|
112
|
-
naturalWidth: source
|
|
133
|
+
naturalHeight: source === null || source === void 0 ? void 0 : source.height,
|
|
134
|
+
naturalWidth: source === null || source === void 0 ? void 0 : source.width
|
|
113
135
|
},
|
|
114
136
|
type: "load"
|
|
115
137
|
});
|
|
116
|
-
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
if (onError) {
|
|
141
|
+
finalProps.onError = function () {
|
|
117
142
|
onError({
|
|
118
143
|
type: "error"
|
|
119
144
|
});
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Component, {
|
|
148
|
+
ref,
|
|
149
|
+
...finalProps
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
var comp = Component;
|
|
153
|
+
ImageComponent.getSize = comp.getSize || function () {};
|
|
154
|
+
ImageComponent.getSizeWithHeaders = comp.getSizeWithHeaders || function () {};
|
|
155
|
+
ImageComponent.prefetch = comp.prefetch || function () {};
|
|
156
|
+
ImageComponent.prefetchWithMetadata = comp.prefetchWithMetadata || function () {};
|
|
157
|
+
ImageComponent.abortPrefetch = comp.abortPrefetch || function () {};
|
|
158
|
+
ImageComponent.queryCache = comp.queryCache || function () {};
|
|
159
|
+
return ImageComponent;
|
|
127
160
|
}
|
|
128
161
|
//# sourceMappingURL=createImage.native.js.map
|