@tamagui/image 2.7.7 → 3.0.0-beta.1091.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 +24 -45
- package/dist/cjs/Image.native.cjs +28 -0
- package/dist/cjs/Image.native.js +15 -20
- package/dist/cjs/Image.native.js.map +1 -1
- package/dist/cjs/createImage.cjs +111 -145
- package/dist/cjs/createImage.native.cjs +132 -0
- package/dist/cjs/createImage.native.js +115 -145
- package/dist/cjs/createImage.native.js.map +1 -1
- package/dist/cjs/index.cjs +9 -11
- package/dist/cjs/index.native.cjs +21 -0
- package/dist/cjs/index.native.js +9 -10
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/types.cjs +9 -11
- package/dist/cjs/types.native.cjs +18 -0
- package/dist/cjs/types.native.js +9 -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 +28 -0
- package/dist/jsx/Image.native.js +15 -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 +132 -0
- package/dist/jsx/createImage.native.js +115 -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 +21 -0
- package/dist/jsx/index.native.js +9 -10
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/types.mjs +0 -2
- package/dist/jsx/types.native.cjs +18 -0
- package/dist/jsx/types.native.js +9 -10
- package/dist/jsx/types.native.js.map +1 -1
- package/package.json +11 -8
- package/src/Image.tsx +5 -4
- package/src/createImage.tsx +100 -90
- package/src/types.ts +1 -1
- package/types/Image.d.ts.map +1 -1
- package/types/Image.native.d.ts +12 -13
- package/types/Image.native.d.ts.map +1 -1
- package/types/createImage.d.ts +12 -12
- 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/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
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __copyProps = (to, from, except, desc) => {
|
|
8
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
10
|
-
get: () => from[key],
|
|
11
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
17
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
18
|
-
value: true
|
|
19
|
-
}), mod);
|
|
20
|
-
var v1_exports = {};
|
|
21
|
-
module.exports = __toCommonJS(v1_exports);
|
|
22
|
-
__reExport(v1_exports, require("./Image.native.js"), module.exports);
|
|
23
|
-
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../../src/v1/index.ts"],"sourcesContent":[null],"mappings":"AAAA","ignoreList":[]}
|
package/src/v1/Image.tsx
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { isWeb } from '@tamagui/constants'
|
|
3
|
-
import type {
|
|
4
|
-
GetProps,
|
|
5
|
-
RadiusTokens,
|
|
6
|
-
SizeTokens,
|
|
7
|
-
ViewProps,
|
|
8
|
-
ThemeValueFallback,
|
|
9
|
-
} from '@tamagui/web'
|
|
10
|
-
import { styled, usePropsAndStyle } from '@tamagui/web'
|
|
11
|
-
import type { FC } from 'react'
|
|
12
|
-
import { Image as RNImage } from 'react-native'
|
|
13
|
-
|
|
14
|
-
const StyledImage = styled(RNImage, {
|
|
15
|
-
name: 'Image',
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
type StyledImageProps = Omit<GetProps<typeof StyledImage>, 'borderRadius'> & {
|
|
19
|
-
borderRadius?: RadiusTokens
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
type BaseProps = Omit<
|
|
23
|
-
StyledImageProps,
|
|
24
|
-
'width' | 'height' | 'style' | 'onLayout' | 'resizeMode'
|
|
25
|
-
> & {
|
|
26
|
-
width?: string | number | SizeTokens | ThemeValueFallback
|
|
27
|
-
height?: string | number | SizeTokens | ThemeValueFallback
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @deprecated use `source` instead to disambiguate width/height style from width/height of the actual image
|
|
31
|
-
*/
|
|
32
|
-
src?: string | StyledImageProps['source']
|
|
33
|
-
/** @deprecated use objectFit instead */
|
|
34
|
-
resizeMode?: StyledImageProps['resizeMode']
|
|
35
|
-
objectFit?: React.CSSProperties['objectFit']
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export type ImageProps = BaseProps & Omit<ViewProps, keyof BaseProps>
|
|
39
|
-
|
|
40
|
-
type RNImageType = typeof RNImage
|
|
41
|
-
|
|
42
|
-
type ImageType = FC<ImageProps> & {
|
|
43
|
-
getSize: RNImageType['getSize']
|
|
44
|
-
getSizeWithHeaders: RNImageType['getSizeWithHeaders']
|
|
45
|
-
prefetch: RNImageType['prefetch']
|
|
46
|
-
prefetchWithMetadata: RNImageType['prefetchWithMetadata']
|
|
47
|
-
abortPrefetch: RNImageType['abortPrefetch']
|
|
48
|
-
queryCache: RNImageType['queryCache']
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
let hasWarned = false
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* @summary An image is a component that displays an image.
|
|
55
|
-
* @see — Docs https://tamagui.dev/ui/image
|
|
56
|
-
*/
|
|
57
|
-
export const Image = StyledImage.styleable<ImageProps>((inProps, ref) => {
|
|
58
|
-
const [props, style] = usePropsAndStyle(inProps)
|
|
59
|
-
const { src, source, objectFit, ...rest } = props
|
|
60
|
-
|
|
61
|
-
if (process.env.NODE_ENV === 'development') {
|
|
62
|
-
if (typeof src === 'string') {
|
|
63
|
-
if (
|
|
64
|
-
(typeof props.width === 'string' && props.width[0] !== '$') ||
|
|
65
|
-
(typeof props.height === 'string' && props.height[0] !== '$')
|
|
66
|
-
) {
|
|
67
|
-
if (!hasWarned) {
|
|
68
|
-
hasWarned = true
|
|
69
|
-
console.warn(
|
|
70
|
-
`React Native expects a numerical width/height. If you want to use a percent you must define the "source" prop with width, height, and uri.`
|
|
71
|
-
)
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
let finalSource =
|
|
78
|
-
typeof src === 'string'
|
|
79
|
-
? {
|
|
80
|
-
uri: src,
|
|
81
|
-
...(isWeb && {
|
|
82
|
-
width: props.width || style?.width,
|
|
83
|
-
height: props.height || style?.height,
|
|
84
|
-
}),
|
|
85
|
-
}
|
|
86
|
-
: (source ?? src)
|
|
87
|
-
|
|
88
|
-
if (finalSource && typeof finalSource === 'object') {
|
|
89
|
-
if (process.env.TAMAGUI_TARGET === 'native') {
|
|
90
|
-
// fix: normalize import style images
|
|
91
|
-
if (!Array.isArray(finalSource)) {
|
|
92
|
-
if (typeof finalSource.uri === 'number') {
|
|
93
|
-
finalSource = finalSource.uri
|
|
94
|
-
if (source && typeof source === 'object' && !Array.isArray(source)) {
|
|
95
|
-
// @ts-ignore
|
|
96
|
-
style.width ??= source.width
|
|
97
|
-
// @ts-ignore
|
|
98
|
-
style.height ??= source.height
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (process.env.NODE_ENV === 'development' && process.env.TAMAGUI_IMAGE_CHECK_ERROR) {
|
|
105
|
-
// lets add an onload timeout and warning if it fails to load in console
|
|
106
|
-
React.useEffect(() => {
|
|
107
|
-
async function run() {
|
|
108
|
-
if (typeof src === 'string') {
|
|
109
|
-
try {
|
|
110
|
-
await fetch(src).then((res) => res.text())
|
|
111
|
-
} catch (err) {
|
|
112
|
-
console.error(`Error loading image: ${src}`, { props })
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
run()
|
|
118
|
-
}, [src])
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// require compat across native/web
|
|
122
|
-
if (finalSource['default']) {
|
|
123
|
-
finalSource = finalSource['default']
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// must set defaultSource to allow SSR, default it to the same as src
|
|
128
|
-
return (
|
|
129
|
-
<RNImage
|
|
130
|
-
resizeMode={objectFit}
|
|
131
|
-
ref={ref}
|
|
132
|
-
source={finalSource}
|
|
133
|
-
style={style}
|
|
134
|
-
{...(rest as any)}
|
|
135
|
-
/>
|
|
136
|
-
)
|
|
137
|
-
}) as any as ImageType
|
|
138
|
-
|
|
139
|
-
Image.getSize = RNImage.getSize
|
|
140
|
-
Image.getSizeWithHeaders = RNImage.getSizeWithHeaders
|
|
141
|
-
Image.prefetch = RNImage.prefetch
|
|
142
|
-
Image.prefetchWithMetadata = RNImage.prefetchWithMetadata
|
|
143
|
-
Image.abortPrefetch = RNImage.abortPrefetch
|
|
144
|
-
Image.queryCache = RNImage.queryCache
|
package/src/v1/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Image'
|
package/types/v1/Image.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { GetProps, RadiusTokens, SizeTokens, ViewProps, ThemeValueFallback } from '@tamagui/web';
|
|
3
|
-
import type { FC } from 'react';
|
|
4
|
-
import { Image as RNImage } from 'react-native';
|
|
5
|
-
declare const StyledImage: import("@tamagui/web").TamaguiComponent<import("@tamagui/web").TamaDefer, RNImage, import("@tamagui/web").TamaguiComponentPropsBaseBase & import("react-native").ImageProps, import("@tamagui/web").StackStyleBase, {}, import("@tamagui/web").StaticConfigPublic>;
|
|
6
|
-
type StyledImageProps = Omit<GetProps<typeof StyledImage>, 'borderRadius'> & {
|
|
7
|
-
borderRadius?: RadiusTokens;
|
|
8
|
-
};
|
|
9
|
-
type BaseProps = Omit<StyledImageProps, 'width' | 'height' | 'style' | 'onLayout' | 'resizeMode'> & {
|
|
10
|
-
width?: string | number | SizeTokens | ThemeValueFallback;
|
|
11
|
-
height?: string | number | SizeTokens | ThemeValueFallback;
|
|
12
|
-
/**
|
|
13
|
-
* @deprecated use `source` instead to disambiguate width/height style from width/height of the actual image
|
|
14
|
-
*/
|
|
15
|
-
src?: string | StyledImageProps['source'];
|
|
16
|
-
/** @deprecated use objectFit instead */
|
|
17
|
-
resizeMode?: StyledImageProps['resizeMode'];
|
|
18
|
-
objectFit?: React.CSSProperties['objectFit'];
|
|
19
|
-
};
|
|
20
|
-
export type ImageProps = BaseProps & Omit<ViewProps, keyof BaseProps>;
|
|
21
|
-
type RNImageType = typeof RNImage;
|
|
22
|
-
type ImageType = FC<ImageProps> & {
|
|
23
|
-
getSize: RNImageType['getSize'];
|
|
24
|
-
getSizeWithHeaders: RNImageType['getSizeWithHeaders'];
|
|
25
|
-
prefetch: RNImageType['prefetch'];
|
|
26
|
-
prefetchWithMetadata: RNImageType['prefetchWithMetadata'];
|
|
27
|
-
abortPrefetch: RNImageType['abortPrefetch'];
|
|
28
|
-
queryCache: RNImageType['queryCache'];
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* @summary An image is a component that displays an image.
|
|
32
|
-
* @see — Docs https://tamagui.dev/ui/image
|
|
33
|
-
*/
|
|
34
|
-
export declare const Image: ImageType;
|
|
35
|
-
export {};
|
|
36
|
-
//# sourceMappingURL=Image.d.ts.map
|
package/types/v1/Image.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../../src/v1/Image.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EACV,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,SAAS,EACT,kBAAkB,EACnB,MAAM,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,MAAM,cAAc,CAAA;AAE/C,QAAA,MAAM,WAAW,oQAEf,CAAA;AAEF,KAAK,gBAAgB,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,WAAW,CAAC,EAAE,cAAc,CAAC,GAAG;IAC3E,YAAY,CAAC,EAAE,YAAY,CAAA;CAC5B,CAAA;AAED,KAAK,SAAS,GAAG,IAAI,CACnB,gBAAgB,EAChB,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,GAAG,YAAY,CACzD,GAAG;IACF,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,kBAAkB,CAAA;IACzD,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,kBAAkB,CAAA;IAE1D;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAA;IACzC,wCAAwC;IACxC,UAAU,CAAC,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAA;IAC3C,SAAS,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,CAAA;CAC7C,CAAA;AAED,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,MAAM,SAAS,CAAC,CAAA;AAErE,KAAK,WAAW,GAAG,OAAO,OAAO,CAAA;AAEjC,KAAK,SAAS,GAAG,EAAE,CAAC,UAAU,CAAC,GAAG;IAChC,OAAO,EAAE,WAAW,CAAC,SAAS,CAAC,CAAA;IAC/B,kBAAkB,EAAE,WAAW,CAAC,oBAAoB,CAAC,CAAA;IACrD,QAAQ,EAAE,WAAW,CAAC,UAAU,CAAC,CAAA;IACjC,oBAAoB,EAAE,WAAW,CAAC,sBAAsB,CAAC,CAAA;IACzD,aAAa,EAAE,WAAW,CAAC,eAAe,CAAC,CAAA;IAC3C,UAAU,EAAE,WAAW,CAAC,YAAY,CAAC,CAAA;CACtC,CAAA;AAID;;;GAGG;AACH,eAAO,MAAM,KAAK,EAgFL,SAAS,CAAA"}
|
package/types/v1/index.d.ts
DELETED
package/types/v1/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/v1/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA"}
|