@tamagui/image 1.0.1-beta.100
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.js +84 -0
- package/dist/cjs/Image.js.map +7 -0
- package/dist/cjs/index.js +18 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/esm/Image.js +60 -0
- package/dist/esm/Image.js.map +7 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/jsx/Image.js +26 -0
- package/dist/jsx/Image.js.map +7 -0
- package/dist/jsx/index.js +2 -0
- package/dist/jsx/index.js.map +7 -0
- package/package.json +38 -0
- package/src/Image.tsx +50 -0
- package/src/index.ts +1 -0
- package/types/Image.d.ts +21 -0
- package/types/Image.d.ts.map +1 -0
- package/types/index.d.ts +2 -0
- package/types/index.d.ts.map +1 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __objRest = (source, exclude) => {
|
|
25
|
+
var target = {};
|
|
26
|
+
for (var prop in source)
|
|
27
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
if (source != null && __getOwnPropSymbols)
|
|
30
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
31
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
32
|
+
target[prop] = source[prop];
|
|
33
|
+
}
|
|
34
|
+
return target;
|
|
35
|
+
};
|
|
36
|
+
var __export = (target, all) => {
|
|
37
|
+
for (var name in all)
|
|
38
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
39
|
+
};
|
|
40
|
+
var __copyProps = (to, from, except, desc) => {
|
|
41
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
42
|
+
for (let key of __getOwnPropNames(from))
|
|
43
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
44
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
45
|
+
}
|
|
46
|
+
return to;
|
|
47
|
+
};
|
|
48
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
49
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
50
|
+
var Image_exports = {};
|
|
51
|
+
__export(Image_exports, {
|
|
52
|
+
Image: () => Image
|
|
53
|
+
});
|
|
54
|
+
module.exports = __toCommonJS(Image_exports);
|
|
55
|
+
var import_core = require("@tamagui/core");
|
|
56
|
+
var import_react = __toESM(require("react"));
|
|
57
|
+
var import_react_native = require("react-native");
|
|
58
|
+
import_react.default["createElement"];
|
|
59
|
+
const StyledImage = (0, import_core.styled)(import_react_native.Image, {
|
|
60
|
+
name: "Image",
|
|
61
|
+
position: "relative",
|
|
62
|
+
source: { uri: "" },
|
|
63
|
+
zIndex: 1
|
|
64
|
+
}, {
|
|
65
|
+
inlineProps: /* @__PURE__ */ new Set(["src", "width", "height"])
|
|
66
|
+
});
|
|
67
|
+
const Image = StyledImage.extractable((inProps) => {
|
|
68
|
+
const props = (0, import_core.getExpandedShorthands)(inProps);
|
|
69
|
+
const _a = props, { src, width = 100, height = 100 } = _a, rest = __objRest(_a, ["src", "width", "height"]);
|
|
70
|
+
const source = typeof src === "string" ? __spreadValues({ uri: src }, import_core.isWeb && { width, height }) : src;
|
|
71
|
+
const defaultSource = Array.isArray(source) ? source[0] : source;
|
|
72
|
+
if (!defaultSource) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
return /* @__PURE__ */ import_react.default.createElement(StyledImage, __spreadValues(__spreadProps(__spreadValues({}, !import_core.isWeb && { style: { width, height } }), {
|
|
76
|
+
defaultSource,
|
|
77
|
+
source
|
|
78
|
+
}), rest));
|
|
79
|
+
});
|
|
80
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
+
0 && (module.exports = {
|
|
82
|
+
Image
|
|
83
|
+
});
|
|
84
|
+
//# sourceMappingURL=Image.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/Image.tsx"],
|
|
4
|
+
"sourcesContent": ["import { GetProps, StackProps, getExpandedShorthands, isWeb, styled } from '@tamagui/core'\nimport React from 'react'\nimport { Image as RNImage } from 'react-native'\n\nReact['createElement']\n\nconst StyledImage = styled(\n RNImage,\n {\n name: 'Image',\n position: 'relative',\n source: { uri: '' },\n zIndex: 1,\n },\n {\n inlineProps: new Set(['src', 'width', 'height']),\n }\n)\n\ntype StyledImageProps = GetProps<typeof StyledImage>\n\ntype BaseProps = Omit<StyledImageProps, 'source' | 'width' | 'height' | 'style' | 'onLayout'> & {\n width: number\n height: number\n src: string | StyledImageProps['source']\n}\n\nexport type ImageProps = BaseProps & Omit<StackProps, keyof BaseProps>\n\nexport const Image: React.FC<ImageProps> = StyledImage.extractable((inProps) => {\n const props = getExpandedShorthands(inProps)\n const { src, width = 100, height = 100, ...rest } = props\n const source = typeof src === 'string' ? { uri: src, ...(isWeb && { width, height }) } : src\n const defaultSource = Array.isArray(source) ? source[0] : source\n\n if (!defaultSource) {\n // placeholder with customizability\n return null\n }\n\n // must set defaultSource to allow SSR, default it to the same as src\n return (\n <StyledImage\n {...(!isWeb && { style: { width, height } })}\n defaultSource={defaultSource}\n source={source}\n {...(rest as any)}\n />\n )\n})\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA2E;AAC3E,mBAAkB;AAClB,0BAAiC;AAEjC,qBAAM;AAEN,MAAM,cAAc,wBAClB,2BACA;AAAA,EACE,MAAM;AAAA,EACN,UAAU;AAAA,EACV,QAAQ,EAAE,KAAK,GAAG;AAAA,EAClB,QAAQ;AACV,GACA;AAAA,EACE,aAAa,oBAAI,IAAI,CAAC,OAAO,SAAS,QAAQ,CAAC;AACjD,CACF;AAYO,MAAM,QAA8B,YAAY,YAAY,CAAC,YAAY;AAC9E,QAAM,QAAQ,uCAAsB,OAAO;AAC3C,QAAoD,YAA5C,OAAK,QAAQ,KAAK,SAAS,QAAiB,IAAT,iBAAS,IAAT,CAAnC,OAAK,SAAa;AAC1B,QAAM,SAAS,OAAO,QAAQ,WAAW,iBAAE,KAAK,OAAS,qBAAS,EAAE,OAAO,OAAO,KAAO;AACzF,QAAM,gBAAgB,MAAM,QAAQ,MAAM,IAAI,OAAO,KAAK;AAE1D,MAAI,CAAC,eAAe;AAElB,WAAO;AAAA,EACT;AAGA,SACE,mDAAC,6DACM,CAAC,qBAAS,EAAE,OAAO,EAAE,OAAO,OAAO,EAAE,IAD3C;AAAA,IAEC;AAAA,IACA;AAAA,MACK,KACP;AAEJ,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var src_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(src_exports);
|
|
17
|
+
__reExport(src_exports, require("./Image"), module.exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
import { getExpandedShorthands, isWeb, styled } from "@tamagui/core";
|
|
33
|
+
import React from "react";
|
|
34
|
+
import { Image as RNImage } from "react-native";
|
|
35
|
+
React["createElement"];
|
|
36
|
+
const StyledImage = styled(RNImage, {
|
|
37
|
+
name: "Image",
|
|
38
|
+
position: "relative",
|
|
39
|
+
source: { uri: "" },
|
|
40
|
+
zIndex: 1
|
|
41
|
+
}, {
|
|
42
|
+
inlineProps: /* @__PURE__ */ new Set(["src", "width", "height"])
|
|
43
|
+
});
|
|
44
|
+
const Image = StyledImage.extractable((inProps) => {
|
|
45
|
+
const props = getExpandedShorthands(inProps);
|
|
46
|
+
const _a = props, { src, width = 100, height = 100 } = _a, rest = __objRest(_a, ["src", "width", "height"]);
|
|
47
|
+
const source = typeof src === "string" ? __spreadValues({ uri: src }, isWeb && { width, height }) : src;
|
|
48
|
+
const defaultSource = Array.isArray(source) ? source[0] : source;
|
|
49
|
+
if (!defaultSource) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return /* @__PURE__ */ React.createElement(StyledImage, __spreadValues(__spreadProps(__spreadValues({}, !isWeb && { style: { width, height } }), {
|
|
53
|
+
defaultSource,
|
|
54
|
+
source
|
|
55
|
+
}), rest));
|
|
56
|
+
});
|
|
57
|
+
export {
|
|
58
|
+
Image
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=Image.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/Image.tsx"],
|
|
4
|
+
"sourcesContent": ["import { GetProps, StackProps, getExpandedShorthands, isWeb, styled } from '@tamagui/core'\nimport React from 'react'\nimport { Image as RNImage } from 'react-native'\n\nReact['createElement']\n\nconst StyledImage = styled(\n RNImage,\n {\n name: 'Image',\n position: 'relative',\n source: { uri: '' },\n zIndex: 1,\n },\n {\n inlineProps: new Set(['src', 'width', 'height']),\n }\n)\n\ntype StyledImageProps = GetProps<typeof StyledImage>\n\ntype BaseProps = Omit<StyledImageProps, 'source' | 'width' | 'height' | 'style' | 'onLayout'> & {\n width: number\n height: number\n src: string | StyledImageProps['source']\n}\n\nexport type ImageProps = BaseProps & Omit<StackProps, keyof BaseProps>\n\nexport const Image: React.FC<ImageProps> = StyledImage.extractable((inProps) => {\n const props = getExpandedShorthands(inProps)\n const { src, width = 100, height = 100, ...rest } = props\n const source = typeof src === 'string' ? { uri: src, ...(isWeb && { width, height }) } : src\n const defaultSource = Array.isArray(source) ? source[0] : source\n\n if (!defaultSource) {\n // placeholder with customizability\n return null\n }\n\n // must set defaultSource to allow SSR, default it to the same as src\n return (\n <StyledImage\n {...(!isWeb && { style: { width, height } })}\n defaultSource={defaultSource}\n source={source}\n {...(rest as any)}\n />\n )\n})\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AAEA,MAAM;AAEN,MAAM,cAAc,OAClB,SACA;AAAA,EACE,MAAM;AAAA,EACN,UAAU;AAAA,EACV,QAAQ,EAAE,KAAK,GAAG;AAAA,EAClB,QAAQ;AACV,GACA;AAAA,EACE,aAAa,oBAAI,IAAI,CAAC,OAAO,SAAS,QAAQ,CAAC;AACjD,CACF;AAYO,MAAM,QAA8B,YAAY,YAAY,CAAC,YAAY;AAC9E,QAAM,QAAQ,sBAAsB,OAAO;AAC3C,QAAoD,YAA5C,OAAK,QAAQ,KAAK,SAAS,QAAiB,IAAT,iBAAS,IAAT,CAAnC,OAAK,SAAa;AAC1B,QAAM,SAAS,OAAO,QAAQ,WAAW,iBAAE,KAAK,OAAS,SAAS,EAAE,OAAO,OAAO,KAAO;AACzF,QAAM,gBAAgB,MAAM,QAAQ,MAAM,IAAI,OAAO,KAAK;AAE1D,MAAI,CAAC,eAAe;AAElB,WAAO;AAAA,EACT;AAGA,SACE,oCAAC,6DACM,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,OAAO,EAAE,IAD3C;AAAA,IAEC;AAAA,IACA;AAAA,MACK,KACP;AAEJ,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getExpandedShorthands, isWeb, styled } from "@tamagui/core";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Image as RNImage } from "react-native";
|
|
4
|
+
React["createElement"];
|
|
5
|
+
const StyledImage = styled(RNImage, {
|
|
6
|
+
name: "Image",
|
|
7
|
+
position: "relative",
|
|
8
|
+
source: { uri: "" },
|
|
9
|
+
zIndex: 1
|
|
10
|
+
}, {
|
|
11
|
+
inlineProps: /* @__PURE__ */ new Set(["src", "width", "height"])
|
|
12
|
+
});
|
|
13
|
+
const Image = StyledImage.extractable((inProps) => {
|
|
14
|
+
const props = getExpandedShorthands(inProps);
|
|
15
|
+
const { src, width = 100, height = 100, ...rest } = props;
|
|
16
|
+
const source = typeof src === "string" ? { uri: src, ...isWeb && { width, height } } : src;
|
|
17
|
+
const defaultSource = Array.isArray(source) ? source[0] : source;
|
|
18
|
+
if (!defaultSource) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return <StyledImage {...!isWeb && { style: { width, height } }} defaultSource={defaultSource} source={source} {...rest} />;
|
|
22
|
+
});
|
|
23
|
+
export {
|
|
24
|
+
Image
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=Image.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/Image.tsx"],
|
|
4
|
+
"sourcesContent": ["import { GetProps, StackProps, getExpandedShorthands, isWeb, styled } from '@tamagui/core'\nimport React from 'react'\nimport { Image as RNImage } from 'react-native'\n\nReact['createElement']\n\nconst StyledImage = styled(\n RNImage,\n {\n name: 'Image',\n position: 'relative',\n source: { uri: '' },\n zIndex: 1,\n },\n {\n inlineProps: new Set(['src', 'width', 'height']),\n }\n)\n\ntype StyledImageProps = GetProps<typeof StyledImage>\n\ntype BaseProps = Omit<StyledImageProps, 'source' | 'width' | 'height' | 'style' | 'onLayout'> & {\n width: number\n height: number\n src: string | StyledImageProps['source']\n}\n\nexport type ImageProps = BaseProps & Omit<StackProps, keyof BaseProps>\n\nexport const Image: React.FC<ImageProps> = StyledImage.extractable((inProps) => {\n const props = getExpandedShorthands(inProps)\n const { src, width = 100, height = 100, ...rest } = props\n const source = typeof src === 'string' ? { uri: src, ...(isWeb && { width, height }) } : src\n const defaultSource = Array.isArray(source) ? source[0] : source\n\n if (!defaultSource) {\n // placeholder with customizability\n return null\n }\n\n // must set defaultSource to allow SSR, default it to the same as src\n return (\n <StyledImage\n {...(!isWeb && { style: { width, height } })}\n defaultSource={defaultSource}\n source={source}\n {...(rest as any)}\n />\n )\n})\n"],
|
|
5
|
+
"mappings": "AAAA;AACA;AACA;AAEA,MAAM;AAEN,MAAM,cAAc,OAClB,SACA;AAAA,EACE,MAAM;AAAA,EACN,UAAU;AAAA,EACV,QAAQ,EAAE,KAAK,GAAG;AAAA,EAClB,QAAQ;AACV,GACA;AAAA,EACE,aAAa,oBAAI,IAAI,CAAC,OAAO,SAAS,QAAQ,CAAC;AACjD,CACF;AAYO,MAAM,QAA8B,YAAY,YAAY,CAAC,YAAY;AAC9E,QAAM,QAAQ,sBAAsB,OAAO;AAC3C,QAAM,EAAE,KAAK,QAAQ,KAAK,SAAS,QAAQ,SAAS;AACpD,QAAM,SAAS,OAAO,QAAQ,WAAW,EAAE,KAAK,KAAK,GAAI,SAAS,EAAE,OAAO,OAAO,EAAG,IAAI;AACzF,QAAM,gBAAgB,MAAM,QAAQ,MAAM,IAAI,OAAO,KAAK;AAE1D,MAAI,CAAC,eAAe;AAElB,WAAO;AAAA,EACT;AAGA,SACE,CAAC,gBACM,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,OAAO,EAAE,GAC1C,eAAe,eACf,QAAQ,YACH,MACP;AAEJ,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tamagui/image",
|
|
3
|
+
"version": "1.0.1-beta.100",
|
|
4
|
+
"sideEffects": [
|
|
5
|
+
"*.css"
|
|
6
|
+
],
|
|
7
|
+
"source": "src/index.ts",
|
|
8
|
+
"types": "./types/index.d.ts",
|
|
9
|
+
"main": "dist/cjs",
|
|
10
|
+
"module": "dist/esm",
|
|
11
|
+
"module:jsx": "dist/jsx",
|
|
12
|
+
"files": [
|
|
13
|
+
"src",
|
|
14
|
+
"types",
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tamagui-build",
|
|
19
|
+
"watch": "tamagui-build --watch",
|
|
20
|
+
"clean": "tamagui-build clean",
|
|
21
|
+
"clean:build": "tamagui-build clean:build"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@tamagui/core": "^1.0.1-beta.100"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"react": "*",
|
|
28
|
+
"react-native": "*"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@tamagui/build": "^1.0.1-beta.100",
|
|
32
|
+
"react": "*",
|
|
33
|
+
"react-native": "*"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
}
|
|
38
|
+
}
|
package/src/Image.tsx
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { GetProps, StackProps, getExpandedShorthands, isWeb, styled } from '@tamagui/core'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { Image as RNImage } from 'react-native'
|
|
4
|
+
|
|
5
|
+
React['createElement']
|
|
6
|
+
|
|
7
|
+
const StyledImage = styled(
|
|
8
|
+
RNImage,
|
|
9
|
+
{
|
|
10
|
+
name: 'Image',
|
|
11
|
+
position: 'relative',
|
|
12
|
+
source: { uri: '' },
|
|
13
|
+
zIndex: 1,
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
inlineProps: new Set(['src', 'width', 'height']),
|
|
17
|
+
}
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
type StyledImageProps = GetProps<typeof StyledImage>
|
|
21
|
+
|
|
22
|
+
type BaseProps = Omit<StyledImageProps, 'source' | 'width' | 'height' | 'style' | 'onLayout'> & {
|
|
23
|
+
width: number
|
|
24
|
+
height: number
|
|
25
|
+
src: string | StyledImageProps['source']
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type ImageProps = BaseProps & Omit<StackProps, keyof BaseProps>
|
|
29
|
+
|
|
30
|
+
export const Image: React.FC<ImageProps> = StyledImage.extractable((inProps) => {
|
|
31
|
+
const props = getExpandedShorthands(inProps)
|
|
32
|
+
const { src, width = 100, height = 100, ...rest } = props
|
|
33
|
+
const source = typeof src === 'string' ? { uri: src, ...(isWeb && { width, height }) } : src
|
|
34
|
+
const defaultSource = Array.isArray(source) ? source[0] : source
|
|
35
|
+
|
|
36
|
+
if (!defaultSource) {
|
|
37
|
+
// placeholder with customizability
|
|
38
|
+
return null
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// must set defaultSource to allow SSR, default it to the same as src
|
|
42
|
+
return (
|
|
43
|
+
<StyledImage
|
|
44
|
+
{...(!isWeb && { style: { width, height } })}
|
|
45
|
+
defaultSource={defaultSource}
|
|
46
|
+
source={source}
|
|
47
|
+
{...(rest as any)}
|
|
48
|
+
/>
|
|
49
|
+
)
|
|
50
|
+
})
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Image'
|
package/types/Image.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { GetProps, StackProps } from '@tamagui/core';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
declare const StyledImage: import("@tamagui/core").TamaguiComponent<(import("react-native").ImageProps & Omit<StackProps, keyof import("react-native").ImageProps>) | (import("react-native").ImageProps & Omit<StackProps, keyof import("react-native").ImageProps> & Omit<{}, string | number> & {
|
|
4
|
+
[x: string]: undefined;
|
|
5
|
+
} & import("@tamagui/core").MediaProps<Partial<import("react-native").ImageProps & Omit<StackProps, keyof import("react-native").ImageProps> & Omit<{}, string | number> & {
|
|
6
|
+
[x: string]: undefined;
|
|
7
|
+
}>> & import("@tamagui/core").PseudoProps<Partial<import("react-native").ImageProps & Omit<StackProps, keyof import("react-native").ImageProps> & Omit<{}, string | number> & {
|
|
8
|
+
[x: string]: undefined;
|
|
9
|
+
}>>), any, import("react-native").ImageProps & Omit<StackProps, keyof import("react-native").ImageProps>, {} | {
|
|
10
|
+
[x: string]: undefined;
|
|
11
|
+
}>;
|
|
12
|
+
declare type StyledImageProps = GetProps<typeof StyledImage>;
|
|
13
|
+
declare type BaseProps = Omit<StyledImageProps, 'source' | 'width' | 'height' | 'style' | 'onLayout'> & {
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
src: string | StyledImageProps['source'];
|
|
17
|
+
};
|
|
18
|
+
export declare type ImageProps = BaseProps & Omit<StackProps, keyof BaseProps>;
|
|
19
|
+
export declare const Image: React.FC<ImageProps>;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=Image.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../src/Image.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAwC,MAAM,eAAe,CAAA;AAC1F,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,QAAA,MAAM,WAAW;;;;;;;;EAWhB,CAAA;AAED,aAAK,gBAAgB,GAAG,QAAQ,CAAC,OAAO,WAAW,CAAC,CAAA;AAEpD,aAAK,SAAS,GAAG,IAAI,CAAC,gBAAgB,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,CAAC,GAAG;IAC9F,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAA;CACzC,CAAA;AAED,oBAAY,UAAU,GAAG,SAAS,GAAG,IAAI,CAAC,UAAU,EAAE,MAAM,SAAS,CAAC,CAAA;AAEtE,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,UAAU,CAoBrC,CAAA"}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA"}
|