@tamagui/image 2.7.7 → 3.0.0-beta.643.1
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 +25 -45
- package/dist/cjs/Image.native.cjs +29 -0
- package/dist/cjs/Image.native.js +16 -20
- package/dist/cjs/Image.native.js.map +1 -1
- package/dist/cjs/createImage.cjs +112 -145
- package/dist/cjs/createImage.native.cjs +133 -0
- package/dist/cjs/createImage.native.js +116 -145
- package/dist/cjs/createImage.native.js.map +1 -1
- package/dist/cjs/index.cjs +10 -11
- package/dist/cjs/index.native.cjs +22 -0
- package/dist/cjs/index.native.js +10 -10
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/types.cjs +10 -11
- package/dist/cjs/types.native.cjs +19 -0
- package/dist/cjs/types.native.js +10 -10
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/esm/Image.mjs +13 -28
- package/dist/esm/Image.mjs.map +1 -1
- package/dist/esm/Image.native.js +4 -4
- package/dist/esm/Image.native.js.map +1 -1
- package/dist/esm/createImage.mjs +100 -128
- package/dist/esm/createImage.mjs.map +1 -1
- package/dist/esm/createImage.native.js +105 -130
- package/dist/esm/createImage.native.js.map +1 -1
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.mjs +3 -3
- package/dist/esm/index.native.js +3 -3
- package/dist/esm/types.mjs +0 -2
- package/dist/esm/types.native.js +0 -2
- package/dist/jsx/Image.mjs +13 -28
- package/dist/jsx/Image.mjs.map +1 -1
- package/dist/jsx/Image.native.cjs +29 -0
- package/dist/jsx/Image.native.js +16 -20
- package/dist/jsx/Image.native.js.map +1 -1
- package/dist/jsx/createImage.mjs +100 -128
- package/dist/jsx/createImage.mjs.map +1 -1
- package/dist/jsx/createImage.native.cjs +133 -0
- package/dist/jsx/createImage.native.js +116 -145
- package/dist/jsx/createImage.native.js.map +1 -1
- package/dist/jsx/index.js +3 -3
- package/dist/jsx/index.mjs +3 -3
- package/dist/jsx/index.native.cjs +22 -0
- package/dist/jsx/index.native.js +10 -10
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/types.mjs +0 -2
- package/dist/jsx/types.native.cjs +19 -0
- package/dist/jsx/types.native.js +10 -10
- package/dist/jsx/types.native.js.map +1 -1
- package/package.json +8 -7
- package/src/Image.tsx +5 -4
- package/src/createImage.tsx +99 -89
- package/types/Image.d.ts.map +1 -1
- package/types/Image.native.d.ts +4 -4
- package/types/Image.native.d.ts.map +1 -1
- package/types/createImage.d.ts +4 -4
- package/types/createImage.d.ts.map +1 -1
- package/dist/cjs/v1/Image.cjs +0 -101
- package/dist/cjs/v1/Image.native.js +0 -123
- package/dist/cjs/v1/Image.native.js.map +0 -1
- package/dist/cjs/v1/index.cjs +0 -20
- package/dist/cjs/v1/index.native.js +0 -23
- package/dist/cjs/v1/index.native.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
- package/dist/esm/types.mjs.map +0 -1
- package/dist/esm/types.native.js.map +0 -1
- package/dist/esm/v1/Image.mjs +0 -65
- package/dist/esm/v1/Image.mjs.map +0 -1
- package/dist/esm/v1/Image.native.js +0 -84
- package/dist/esm/v1/Image.native.js.map +0 -1
- package/dist/esm/v1/index.mjs +0 -2
- package/dist/esm/v1/index.mjs.map +0 -1
- package/dist/esm/v1/index.native.js +0 -2
- package/dist/esm/v1/index.native.js.map +0 -1
- package/dist/jsx/index.js.map +0 -1
- package/dist/jsx/index.mjs.map +0 -1
- package/dist/jsx/types.mjs.map +0 -1
- package/dist/jsx/v1/Image.mjs +0 -65
- package/dist/jsx/v1/Image.mjs.map +0 -1
- package/dist/jsx/v1/Image.native.js +0 -123
- package/dist/jsx/v1/Image.native.js.map +0 -1
- package/dist/jsx/v1/index.mjs +0 -2
- package/dist/jsx/v1/index.mjs.map +0 -1
- package/dist/jsx/v1/index.native.js +0 -23
- package/dist/jsx/v1/index.native.js.map +0 -1
- package/src/v1/Image.tsx +0 -144
- package/src/v1/index.ts +0 -1
- package/types/v1/Image.d.ts +0 -36
- package/types/v1/Image.d.ts.map +0 -1
- package/types/v1/index.d.ts +0 -2
- package/types/v1/index.d.ts.map +0 -1
package/dist/jsx/Image.mjs
CHANGED
|
@@ -1,39 +1,24 @@
|
|
|
1
|
-
import { View, styled } from "@tamagui/web";
|
|
1
|
+
import { View, createStyledHOC, styled } from "@tamagui/web";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
|
|
3
4
|
const StyledImage = styled(View, {
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
displayName: "Image",
|
|
6
|
+
render: "img"
|
|
6
7
|
});
|
|
7
|
-
const Image = StyledImage
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
onLoadEnd,
|
|
16
|
-
onPartialLoad,
|
|
17
|
-
progressiveRenderingEnabled,
|
|
18
|
-
resizeMethod,
|
|
19
|
-
tintColor,
|
|
20
|
-
...rest
|
|
21
|
-
} = inProps;
|
|
22
|
-
return /* @__PURE__ */jsx(StyledImage, {
|
|
23
|
-
ref,
|
|
24
|
-
...rest
|
|
25
|
-
});
|
|
26
|
-
}, {
|
|
27
|
-
staticConfig: {
|
|
28
|
-
memo: true
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
const func = () => {};
|
|
8
|
+
const Image = createStyledHOC(StyledImage, (inProps, ref) => {
|
|
9
|
+
const { blurRadius, capInsets, defaultSource, fadeDuration, loadingIndicatorSource, onLoadEnd, onPartialLoad, progressiveRenderingEnabled, resizeMethod, tintColor, ...rest } = inProps;
|
|
10
|
+
return /* @__PURE__ */ jsx(StyledImage, {
|
|
11
|
+
ref,
|
|
12
|
+
...rest
|
|
13
|
+
});
|
|
14
|
+
}, { staticConfig: { memo: true } });
|
|
15
|
+
const func = (() => {});
|
|
32
16
|
Image.getSize = func;
|
|
33
17
|
Image.getSizeWithHeaders = func;
|
|
34
18
|
Image.prefetch = func;
|
|
35
19
|
Image.prefetchWithMetadata = func;
|
|
36
20
|
Image.abortPrefetch = func;
|
|
37
21
|
Image.queryCache = func;
|
|
22
|
+
|
|
38
23
|
export { Image };
|
|
39
24
|
//# sourceMappingURL=Image.mjs.map
|
package/dist/jsx/Image.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"Image.js","names":[],"sources":["jsx/Image.js"],"sourcesContent":["import { createStyledHOC, View, styled } from \"@tamagui/web\";\nimport { jsx } from \"react/jsx-runtime\";\nconst StyledImage = styled(View, {\n displayName: \"Image\",\n render: \"img\"\n});\nconst Image = createStyledHOC(\n StyledImage,\n (inProps, ref) => {\n const {\n // exclude native only props\n blurRadius,\n capInsets,\n defaultSource,\n fadeDuration,\n loadingIndicatorSource,\n onLoadEnd,\n onPartialLoad,\n progressiveRenderingEnabled,\n resizeMethod,\n tintColor,\n ...rest\n } = inProps;\n return /* @__PURE__ */ jsx(StyledImage, { ref, ...rest });\n },\n {\n staticConfig: {\n memo: true\n }\n }\n);\nconst func = (() => {\n});\nImage.getSize = func;\nImage.getSizeWithHeaders = func;\nImage.prefetch = func;\nImage.prefetchWithMetadata = func;\nImage.abortPrefetch = func;\nImage.queryCache = func;\nexport {\n Image\n};\n//# sourceMappingURL=Image.js.map\n"],"mappings":";;;;AAEA,MAAM,cAAc,OAAO,MAAM;CAC/B,aAAa;CACb,QAAQ;AACV,CAAC;AACD,MAAM,QAAQ,gBACZ,cACC,SAAS,QAAQ;CAChB,MAAM,EAEJ,YACA,WACA,eACA,cACA,wBACA,WACA,eACA,6BACA,cACA,WACA,GAAG,SACD;CACJ,OAAuB,oBAAI,aAAa;EAAE;EAAK,GAAG;CAAK,CAAC;AAC1D,GACA,EACE,cAAc,EACZ,MAAM,KACR,EACF,CACF;AACA,MAAM,cAAc,CACpB;AACA,MAAM,UAAU;AAChB,MAAM,qBAAqB;AAC3B,MAAM,WAAW;AACjB,MAAM,uBAAuB;AAC7B,MAAM,gBAAgB;AACtB,MAAM,aAAa"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var Image_native_exports = {};
|
|
25
|
+
__export(Image_native_exports, { Image: () => Image });
|
|
26
|
+
module.exports = __toCommonJS(Image_native_exports);
|
|
27
|
+
var import_react_native = require("react-native");
|
|
28
|
+
var import_createImage = require("./createImage.native.js");
|
|
29
|
+
var Image = (0, import_createImage.createImage)({ Component: import_react_native.Image });
|
package/dist/jsx/Image.native.js
CHANGED
|
@@ -1,35 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
8
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
12
13
|
};
|
|
13
14
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
21
22
|
};
|
|
22
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
-
value: true
|
|
24
|
-
}), mod);
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
24
|
var Image_native_exports = {};
|
|
26
|
-
__export(Image_native_exports, {
|
|
27
|
-
Image: () => Image
|
|
28
|
-
});
|
|
25
|
+
__export(Image_native_exports, { Image: () => Image });
|
|
29
26
|
module.exports = __toCommonJS(Image_native_exports);
|
|
30
27
|
var import_react_native = require("react-native");
|
|
31
28
|
var import_createImage = require("./createImage.native.js");
|
|
32
|
-
var Image = (0, import_createImage.createImage)({
|
|
33
|
-
|
|
34
|
-
});
|
|
29
|
+
var Image = (0, import_createImage.createImage)({ Component: import_react_native.Image });
|
|
30
|
+
|
|
35
31
|
//# sourceMappingURL=Image.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"Image.native.js","names":[],"sources":["jsx/Image.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar Image_native_exports = {};\n__export(Image_native_exports, {\n Image: () => Image\n});\nmodule.exports = __toCommonJS(Image_native_exports);\nvar import_react_native = require(\"react-native\");\nvar import_createImage = require(\"./createImage\");\nvar Image = (0, import_createImage.createImage)({\n Component: import_react_native.Image\n});\n//# sourceMappingURL=Image.native.js.map\n"],"mappings":";;;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,uBAAuB,CAAC;AAC5B,SAAS,sBAAsB,EAC7B,aAAa,MACf,CAAC;AACD,OAAO,UAAU,aAAa,oBAAoB;AAClD,IAAI,sBAAsB,QAAQ,cAAc;AAChD,IAAI,qBAAqB,QAAQ,yBAAe;AAChD,IAAI,SAAS,GAAG,mBAAmB,aAAa,EAC9C,WAAW,oBAAoB,MACjC,CAAC"}
|
package/dist/jsx/createImage.mjs
CHANGED
|
@@ -1,135 +1,107 @@
|
|
|
1
|
-
import { getTokenValue, styled } from "@tamagui/web";
|
|
1
|
+
import { createStyledHOC, getTokenValue, styled } from "@tamagui/web";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return "contain";
|
|
13
|
-
default:
|
|
14
|
-
return "cover";
|
|
15
|
-
}
|
|
3
|
+
|
|
4
|
+
const defaultObjectFitMap = (objectFit) => {
|
|
5
|
+
switch (objectFit) {
|
|
6
|
+
case "fill": return "stretch";
|
|
7
|
+
case "none": return "center";
|
|
8
|
+
case "scale-down": return "contain";
|
|
9
|
+
case "contain": return "contain";
|
|
10
|
+
default: return "cover";
|
|
11
|
+
}
|
|
16
12
|
};
|
|
17
|
-
const defaultTransformSource = props => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
if (source !== void 0 && source !== null) return source;
|
|
28
|
-
if (src !== void 0 && src !== null) return src;
|
|
29
|
-
return {
|
|
30
|
-
uri: src
|
|
31
|
-
};
|
|
13
|
+
const defaultTransformSource = (props) => {
|
|
14
|
+
const { src, source } = props;
|
|
15
|
+
if (typeof src === "string") {
|
|
16
|
+
return { uri: src };
|
|
17
|
+
}
|
|
18
|
+
if (source !== void 0 && source !== null) return source;
|
|
19
|
+
if (src !== void 0 && src !== null) return src;
|
|
20
|
+
return { uri: src };
|
|
32
21
|
};
|
|
33
22
|
function createImage(options) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
onError({
|
|
116
|
-
type: "error"
|
|
117
|
-
});
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
return /* @__PURE__ */jsx(StyledImage, {
|
|
121
|
-
ref,
|
|
122
|
-
...finalProps
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
const comp = Component;
|
|
126
|
-
ImageComponent.getSize = comp.getSize || (() => {});
|
|
127
|
-
ImageComponent.getSizeWithHeaders = comp.getSizeWithHeaders || (() => {});
|
|
128
|
-
ImageComponent.prefetch = comp.prefetch || (() => {});
|
|
129
|
-
ImageComponent.prefetchWithMetadata = comp.prefetchWithMetadata || (() => {});
|
|
130
|
-
ImageComponent.abortPrefetch = comp.abortPrefetch || (() => {});
|
|
131
|
-
ImageComponent.queryCache = comp.queryCache || (() => {});
|
|
132
|
-
return ImageComponent;
|
|
23
|
+
const { Component, mapObjectFitToResizeMode = defaultObjectFitMap, resizeModePropName = "resizeMode", objectPositionPropName, transformSource = defaultTransformSource } = options;
|
|
24
|
+
const inlinePropsSet = /* @__PURE__ */ new Set([
|
|
25
|
+
"source",
|
|
26
|
+
"placeholder",
|
|
27
|
+
"transition",
|
|
28
|
+
"contentFit",
|
|
29
|
+
"contentPosition",
|
|
30
|
+
"cachePolicy",
|
|
31
|
+
"recyclingKey",
|
|
32
|
+
"allowDownscaling",
|
|
33
|
+
"autoplay",
|
|
34
|
+
"blurRadius",
|
|
35
|
+
"priority",
|
|
36
|
+
"placeholderContentFit",
|
|
37
|
+
"responsivePolicy",
|
|
38
|
+
"onLoadStart",
|
|
39
|
+
"onProgress",
|
|
40
|
+
"onLoadEnd"
|
|
41
|
+
]);
|
|
42
|
+
const StyledImage = styled(Component, { displayName: "Image" }, { inlineProps: inlinePropsSet });
|
|
43
|
+
const ImageComponent = createStyledHOC(StyledImage, (incomingProps, ref) => {
|
|
44
|
+
const props = incomingProps;
|
|
45
|
+
const { src, source, width, height, borderRadius, objectFit, objectPosition, decoding, elementTiming, fetchpriority, isMap, loading, sizes, useMap, onLoad, onError, ...rest } = props;
|
|
46
|
+
const resolvedWidth = typeof width === "string" ? getTokenValue(width, "size") ?? width : width;
|
|
47
|
+
const resolvedHeight = typeof height === "string" ? getTokenValue(height, "size") ?? height : height;
|
|
48
|
+
const finalSource = transformSource({
|
|
49
|
+
src,
|
|
50
|
+
source,
|
|
51
|
+
width: resolvedWidth,
|
|
52
|
+
height: resolvedHeight
|
|
53
|
+
});
|
|
54
|
+
const incomingStyle = Array.isArray(rest.style) ? Object.assign({}, ...rest.style.flat()) : rest.style;
|
|
55
|
+
const resolvedBorderRadius = typeof borderRadius === "string" ? getTokenValue(borderRadius, "radius") ?? borderRadius : borderRadius;
|
|
56
|
+
const finalProps = {
|
|
57
|
+
...rest,
|
|
58
|
+
source: finalSource,
|
|
59
|
+
style: {
|
|
60
|
+
...incomingStyle,
|
|
61
|
+
...resolvedBorderRadius !== void 0 && { borderRadius: resolvedBorderRadius },
|
|
62
|
+
...resolvedWidth !== void 0 && { width: resolvedWidth },
|
|
63
|
+
...resolvedHeight !== void 0 && { height: resolvedHeight },
|
|
64
|
+
...objectFit !== void 0 && { objectFit },
|
|
65
|
+
...objectPosition !== void 0 && { objectPosition }
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
if (objectFit) {
|
|
69
|
+
finalProps[resizeModePropName] = mapObjectFitToResizeMode(objectFit);
|
|
70
|
+
}
|
|
71
|
+
if (objectPositionPropName && objectPosition) {
|
|
72
|
+
finalProps[objectPositionPropName] = objectPosition;
|
|
73
|
+
}
|
|
74
|
+
if (onLoad) {
|
|
75
|
+
finalProps.onLoad = (e) => {
|
|
76
|
+
const source2 = e?.nativeEvent?.source || e?.source || {};
|
|
77
|
+
onLoad({
|
|
78
|
+
target: {
|
|
79
|
+
naturalHeight: source2?.height,
|
|
80
|
+
naturalWidth: source2?.width
|
|
81
|
+
},
|
|
82
|
+
type: "load"
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if (onError) {
|
|
87
|
+
finalProps.onError = () => {
|
|
88
|
+
onError({ type: "error" });
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return /* @__PURE__ */ jsx(StyledImage, {
|
|
92
|
+
ref,
|
|
93
|
+
...finalProps
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
const comp = Component;
|
|
97
|
+
ImageComponent.getSize = comp.getSize || (() => {});
|
|
98
|
+
ImageComponent.getSizeWithHeaders = comp.getSizeWithHeaders || (() => {});
|
|
99
|
+
ImageComponent.prefetch = comp.prefetch || (() => {});
|
|
100
|
+
ImageComponent.prefetchWithMetadata = comp.prefetchWithMetadata || (() => {});
|
|
101
|
+
ImageComponent.abortPrefetch = comp.abortPrefetch || (() => {});
|
|
102
|
+
ImageComponent.queryCache = comp.queryCache || (() => {});
|
|
103
|
+
return ImageComponent;
|
|
133
104
|
}
|
|
105
|
+
|
|
134
106
|
export { createImage };
|
|
135
107
|
//# sourceMappingURL=createImage.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"createImage.js","names":[],"sources":["jsx/createImage.js"],"sourcesContent":["import { createStyledHOC, getTokenValue, styled } from \"@tamagui/web\";\nimport { jsx } from \"react/jsx-runtime\";\nconst defaultObjectFitMap = (objectFit) => {\n switch (objectFit) {\n case \"fill\":\n return \"stretch\";\n case \"none\":\n return \"center\";\n case \"scale-down\":\n return \"contain\";\n case \"contain\":\n return \"contain\";\n default:\n return \"cover\";\n }\n};\nconst defaultTransformSource = (props) => {\n const { src, source } = props;\n if (typeof src === \"string\") {\n return {\n uri: src\n };\n }\n if (source !== void 0 && source !== null) return source;\n if (src !== void 0 && src !== null) return src;\n return {\n uri: src\n };\n};\nfunction createImage(options) {\n const {\n Component,\n mapObjectFitToResizeMode = defaultObjectFitMap,\n resizeModePropName = \"resizeMode\",\n objectPositionPropName,\n transformSource = defaultTransformSource\n } = options;\n const inlinePropsSet = /* @__PURE__ */ new Set([\n \"source\",\n \"placeholder\",\n \"transition\",\n \"contentFit\",\n \"contentPosition\",\n \"cachePolicy\",\n \"recyclingKey\",\n \"allowDownscaling\",\n \"autoplay\",\n \"blurRadius\",\n \"priority\",\n \"placeholderContentFit\",\n \"responsivePolicy\",\n \"onLoadStart\",\n \"onProgress\",\n \"onLoadEnd\"\n ]);\n const StyledImage = styled(\n Component,\n {\n displayName: \"Image\"\n },\n {\n inlineProps: inlinePropsSet\n }\n );\n const ImageComponent = createStyledHOC(\n StyledImage,\n (incomingProps, ref) => {\n const props = incomingProps;\n const {\n src,\n source,\n width,\n height,\n borderRadius,\n objectFit,\n objectPosition,\n // web only props - filter out on native\n decoding,\n elementTiming,\n fetchpriority,\n isMap,\n loading,\n sizes,\n useMap,\n onLoad,\n onError,\n ...rest\n } = props;\n const resolvedWidth = typeof width === \"string\" ? getTokenValue(width, \"size\") ?? width : width;\n const resolvedHeight = typeof height === \"string\" ? getTokenValue(height, \"size\") ?? height : height;\n const finalSource = transformSource({\n src,\n source,\n width: resolvedWidth,\n height: resolvedHeight\n });\n const incomingStyle = Array.isArray(rest.style) ? Object.assign({}, ...rest.style.flat()) : rest.style;\n const resolvedBorderRadius = typeof borderRadius === \"string\" ? getTokenValue(borderRadius, \"radius\") ?? borderRadius : borderRadius;\n const finalProps = {\n ...rest,\n source: finalSource,\n style: {\n ...incomingStyle,\n ...resolvedBorderRadius !== void 0 && {\n borderRadius: resolvedBorderRadius\n },\n ...resolvedWidth !== void 0 && { width: resolvedWidth },\n ...resolvedHeight !== void 0 && { height: resolvedHeight },\n // RN 0.76+ reads objectFit from style natively on Image; harmless on older.\n // Also forwarded to the resize-mode prop below for back-compat / non-RN components.\n ...objectFit !== void 0 && { objectFit },\n // RN doesn't currently read objectPosition from style; expo-image uses\n // contentPosition (handled via objectPositionPropName below). Forwarding\n // through style is a no-op there but matches CSS shape and is forward-compatible.\n ...objectPosition !== void 0 && { objectPosition }\n }\n };\n if (objectFit) {\n finalProps[resizeModePropName] = mapObjectFitToResizeMode(objectFit);\n }\n if (objectPositionPropName && objectPosition) {\n finalProps[objectPositionPropName] = objectPosition;\n }\n if (onLoad) {\n finalProps.onLoad = (e) => {\n const source2 = e?.nativeEvent?.source || e?.source || {};\n onLoad({\n target: {\n naturalHeight: source2?.height,\n naturalWidth: source2?.width\n },\n type: \"load\"\n });\n };\n }\n if (onError) {\n finalProps.onError = () => {\n onError({\n type: \"error\"\n });\n };\n }\n return /* @__PURE__ */ jsx(StyledImage, { ref, ...finalProps });\n }\n );\n const comp = Component;\n ImageComponent.getSize = comp.getSize || (() => {\n });\n ImageComponent.getSizeWithHeaders = comp.getSizeWithHeaders || (() => {\n });\n ImageComponent.prefetch = comp.prefetch || (() => {\n });\n ImageComponent.prefetchWithMetadata = comp.prefetchWithMetadata || (() => {\n });\n ImageComponent.abortPrefetch = comp.abortPrefetch || (() => {\n });\n ImageComponent.queryCache = comp.queryCache || (() => {\n });\n return ImageComponent;\n}\nexport {\n createImage\n};\n//# sourceMappingURL=createImage.js.map\n"],"mappings":"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"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var createImage_exports = {};
|
|
25
|
+
__export(createImage_exports, { createImage: () => createImage });
|
|
26
|
+
module.exports = __toCommonJS(createImage_exports);
|
|
27
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
28
|
+
var import_web = require("@tamagui/web");
|
|
29
|
+
var defaultObjectFitMap = function(objectFit) {
|
|
30
|
+
switch (objectFit) {
|
|
31
|
+
case "fill": return "stretch";
|
|
32
|
+
case "none": return "center";
|
|
33
|
+
case "scale-down": return "contain";
|
|
34
|
+
case "contain": return "contain";
|
|
35
|
+
default: return "cover";
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var defaultTransformSource = function(props) {
|
|
39
|
+
var { src, source } = props;
|
|
40
|
+
if (typeof src === "string") {
|
|
41
|
+
return { uri: src };
|
|
42
|
+
}
|
|
43
|
+
if (source !== void 0 && source !== null) return source;
|
|
44
|
+
if (src !== void 0 && src !== null) return src;
|
|
45
|
+
return { uri: src };
|
|
46
|
+
};
|
|
47
|
+
function createImage(options) {
|
|
48
|
+
var { Component, mapObjectFitToResizeMode = defaultObjectFitMap, resizeModePropName = "resizeMode", objectPositionPropName, transformSource = defaultTransformSource } = options;
|
|
49
|
+
var inlinePropsSet = /* @__PURE__ */ new Set([
|
|
50
|
+
"source",
|
|
51
|
+
"placeholder",
|
|
52
|
+
"transition",
|
|
53
|
+
"contentFit",
|
|
54
|
+
"contentPosition",
|
|
55
|
+
"cachePolicy",
|
|
56
|
+
"recyclingKey",
|
|
57
|
+
"allowDownscaling",
|
|
58
|
+
"autoplay",
|
|
59
|
+
"blurRadius",
|
|
60
|
+
"priority",
|
|
61
|
+
"placeholderContentFit",
|
|
62
|
+
"responsivePolicy",
|
|
63
|
+
"onLoadStart",
|
|
64
|
+
"onProgress",
|
|
65
|
+
"onLoadEnd"
|
|
66
|
+
]);
|
|
67
|
+
var StyledImage = (0, import_web.styled)(Component, { displayName: "Image" }, { inlineProps: inlinePropsSet });
|
|
68
|
+
var ImageComponent = (0, import_web.createStyledHOC)(StyledImage, function(incomingProps, ref) {
|
|
69
|
+
var props = incomingProps;
|
|
70
|
+
var { src, source, width, height, borderRadius, objectFit, objectPosition, decoding, elementTiming, fetchpriority, isMap, loading, sizes, useMap, onLoad, onError, ...rest } = props;
|
|
71
|
+
var _getTokenValue;
|
|
72
|
+
var resolvedWidth = typeof width === "string" ? (_getTokenValue = (0, import_web.getTokenValue)(width, "size")) !== null && _getTokenValue !== void 0 ? _getTokenValue : width : width;
|
|
73
|
+
var _getTokenValue1;
|
|
74
|
+
var resolvedHeight = typeof height === "string" ? (_getTokenValue1 = (0, import_web.getTokenValue)(height, "size")) !== null && _getTokenValue1 !== void 0 ? _getTokenValue1 : height : height;
|
|
75
|
+
var finalSource = transformSource({
|
|
76
|
+
src,
|
|
77
|
+
source,
|
|
78
|
+
width: resolvedWidth,
|
|
79
|
+
height: resolvedHeight
|
|
80
|
+
});
|
|
81
|
+
var incomingStyle = Array.isArray(rest.style) ? Object.assign({}, ...rest.style.flat()) : rest.style;
|
|
82
|
+
var _getTokenValue2;
|
|
83
|
+
var resolvedBorderRadius = typeof borderRadius === "string" ? (_getTokenValue2 = (0, import_web.getTokenValue)(borderRadius, "radius")) !== null && _getTokenValue2 !== void 0 ? _getTokenValue2 : borderRadius : borderRadius;
|
|
84
|
+
var finalProps = {
|
|
85
|
+
...rest,
|
|
86
|
+
source: finalSource,
|
|
87
|
+
style: {
|
|
88
|
+
...incomingStyle,
|
|
89
|
+
...resolvedBorderRadius !== void 0 && { borderRadius: resolvedBorderRadius },
|
|
90
|
+
...resolvedWidth !== void 0 && { width: resolvedWidth },
|
|
91
|
+
...resolvedHeight !== void 0 && { height: resolvedHeight },
|
|
92
|
+
...objectFit !== void 0 && { objectFit },
|
|
93
|
+
...objectPosition !== void 0 && { objectPosition }
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
if (objectFit) {
|
|
97
|
+
finalProps[resizeModePropName] = mapObjectFitToResizeMode(objectFit);
|
|
98
|
+
}
|
|
99
|
+
if (objectPositionPropName && objectPosition) {
|
|
100
|
+
finalProps[objectPositionPropName] = objectPosition;
|
|
101
|
+
}
|
|
102
|
+
if (onLoad) {
|
|
103
|
+
finalProps.onLoad = function(e) {
|
|
104
|
+
var _e_nativeEvent;
|
|
105
|
+
var source2 = (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) || {};
|
|
106
|
+
onLoad({
|
|
107
|
+
target: {
|
|
108
|
+
naturalHeight: source2 === null || source2 === void 0 ? void 0 : source2.height,
|
|
109
|
+
naturalWidth: source2 === null || source2 === void 0 ? void 0 : source2.width
|
|
110
|
+
},
|
|
111
|
+
type: "load"
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
if (onError) {
|
|
116
|
+
finalProps.onError = function() {
|
|
117
|
+
onError({ type: "error" });
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StyledImage, {
|
|
121
|
+
ref,
|
|
122
|
+
...finalProps
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
var comp = Component;
|
|
126
|
+
ImageComponent.getSize = comp.getSize || function() {};
|
|
127
|
+
ImageComponent.getSizeWithHeaders = comp.getSizeWithHeaders || function() {};
|
|
128
|
+
ImageComponent.prefetch = comp.prefetch || function() {};
|
|
129
|
+
ImageComponent.prefetchWithMetadata = comp.prefetchWithMetadata || function() {};
|
|
130
|
+
ImageComponent.abortPrefetch = comp.abortPrefetch || function() {};
|
|
131
|
+
ImageComponent.queryCache = comp.queryCache || function() {};
|
|
132
|
+
return ImageComponent;
|
|
133
|
+
}
|