@tamagui/image 2.7.7 → 3.0.0-beta.1093.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
package/src/createImage.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getTokenValue, styled } from '@tamagui/web'
|
|
1
|
+
import { createStyledHOC, getTokenValue, styled } from '@tamagui/web'
|
|
2
2
|
import type { ComponentType } from 'react'
|
|
3
|
-
import type { ImageResizeMode } from 'react-native'
|
|
3
|
+
import type { ImageResizeMode } from '@tamagui/react-native-types'
|
|
4
4
|
import type { ImageProps, ImageType } from './types'
|
|
5
5
|
|
|
6
6
|
type GetProps<T> = T extends ComponentType<infer P> ? P : never
|
|
@@ -131,7 +131,7 @@ export function createImage<C extends ComponentType<any>>(
|
|
|
131
131
|
const StyledImage = styled(
|
|
132
132
|
Component as ComponentType<any>,
|
|
133
133
|
{
|
|
134
|
-
|
|
134
|
+
displayName: 'Image',
|
|
135
135
|
},
|
|
136
136
|
{
|
|
137
137
|
inlineProps: inlinePropsSet,
|
|
@@ -141,100 +141,110 @@ export function createImage<C extends ComponentType<any>>(
|
|
|
141
141
|
// Combined props: ImageProps (Tamagui) + Component's native props
|
|
142
142
|
type CombinedProps = ImageProps & Omit<GetProps<C>, keyof ImageProps>
|
|
143
143
|
|
|
144
|
-
const ImageComponent =
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
typeof width === 'string' && width[0] === '$'
|
|
169
|
-
? getTokenValue(width as any, 'size')
|
|
170
|
-
: width
|
|
171
|
-
const resolvedHeight =
|
|
172
|
-
typeof height === 'string' && height[0] === '$'
|
|
173
|
-
? getTokenValue(height as any, 'size')
|
|
174
|
-
: height
|
|
175
|
-
|
|
176
|
-
const finalSource = transformSource({
|
|
177
|
-
src,
|
|
178
|
-
source,
|
|
179
|
-
width: resolvedWidth,
|
|
180
|
-
height: resolvedHeight,
|
|
181
|
-
})
|
|
182
|
-
|
|
183
|
-
const incomingStyle = Array.isArray(rest.style)
|
|
184
|
-
? Object.assign({}, ...rest.style.flat())
|
|
185
|
-
: rest.style
|
|
186
|
-
|
|
187
|
-
const resolvedBorderRadius =
|
|
188
|
-
typeof borderRadius === 'string' && borderRadius[0] === '$'
|
|
189
|
-
? getTokenValue(borderRadius as any, 'radius')
|
|
190
|
-
: borderRadius
|
|
191
|
-
|
|
192
|
-
const finalProps: any = {
|
|
193
|
-
...rest,
|
|
194
|
-
source: finalSource,
|
|
195
|
-
style: {
|
|
196
|
-
...incomingStyle,
|
|
197
|
-
...(resolvedBorderRadius !== undefined && { borderRadius: resolvedBorderRadius }),
|
|
198
|
-
...(resolvedWidth !== undefined && { width: resolvedWidth }),
|
|
199
|
-
...(resolvedHeight !== undefined && { height: resolvedHeight }),
|
|
200
|
-
},
|
|
201
|
-
}
|
|
144
|
+
const ImageComponent = createStyledHOC(
|
|
145
|
+
StyledImage,
|
|
146
|
+
(incomingProps: CombinedProps, ref) => {
|
|
147
|
+
const props = incomingProps as any
|
|
148
|
+
const {
|
|
149
|
+
src,
|
|
150
|
+
source,
|
|
151
|
+
width,
|
|
152
|
+
height,
|
|
153
|
+
borderRadius,
|
|
154
|
+
objectFit,
|
|
155
|
+
objectPosition,
|
|
156
|
+
// web only props - filter out on native
|
|
157
|
+
decoding,
|
|
158
|
+
elementTiming,
|
|
159
|
+
fetchpriority,
|
|
160
|
+
isMap,
|
|
161
|
+
loading,
|
|
162
|
+
sizes,
|
|
163
|
+
useMap,
|
|
164
|
+
onLoad,
|
|
165
|
+
onError,
|
|
166
|
+
...rest
|
|
167
|
+
} = props
|
|
202
168
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
169
|
+
const resolvedWidth =
|
|
170
|
+
typeof width === 'string' ? (getTokenValue(width as any, 'size') ?? width) : width
|
|
171
|
+
const resolvedHeight =
|
|
172
|
+
typeof height === 'string'
|
|
173
|
+
? (getTokenValue(height as any, 'size') ?? height)
|
|
174
|
+
: height
|
|
207
175
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
176
|
+
const finalSource = transformSource({
|
|
177
|
+
src,
|
|
178
|
+
source,
|
|
179
|
+
width: resolvedWidth,
|
|
180
|
+
height: resolvedHeight,
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
const incomingStyle = Array.isArray(rest.style)
|
|
184
|
+
? Object.assign({}, ...rest.style.flat())
|
|
185
|
+
: rest.style
|
|
212
186
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
187
|
+
const resolvedBorderRadius =
|
|
188
|
+
typeof borderRadius === 'string'
|
|
189
|
+
? (getTokenValue(borderRadius as any, 'radius') ?? borderRadius)
|
|
190
|
+
: borderRadius
|
|
191
|
+
|
|
192
|
+
const finalProps: any = {
|
|
193
|
+
...rest,
|
|
194
|
+
source: finalSource,
|
|
195
|
+
style: {
|
|
196
|
+
...incomingStyle,
|
|
197
|
+
...(resolvedBorderRadius !== undefined && {
|
|
198
|
+
borderRadius: resolvedBorderRadius,
|
|
199
|
+
}),
|
|
200
|
+
...(resolvedWidth !== undefined && { width: resolvedWidth }),
|
|
201
|
+
...(resolvedHeight !== undefined && { height: resolvedHeight }),
|
|
202
|
+
// RN 0.76+ reads objectFit from style natively on Image; harmless on older.
|
|
203
|
+
// Also forwarded to the resize-mode prop below for back-compat / non-RN components.
|
|
204
|
+
...(objectFit !== undefined && { objectFit }),
|
|
205
|
+
// RN doesn't currently read objectPosition from style; expo-image uses
|
|
206
|
+
// contentPosition (handled via objectPositionPropName below). Forwarding
|
|
207
|
+
// through style is a no-op there but matches CSS shape and is forward-compatible.
|
|
208
|
+
...(objectPosition !== undefined && { objectPosition }),
|
|
209
|
+
},
|
|
224
210
|
}
|
|
225
|
-
}
|
|
226
211
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
onError({
|
|
231
|
-
type: 'error',
|
|
232
|
-
} as any)
|
|
212
|
+
// Set resize mode / content fit
|
|
213
|
+
if (objectFit) {
|
|
214
|
+
finalProps[resizeModePropName] = mapObjectFitToResizeMode(objectFit)
|
|
233
215
|
}
|
|
234
|
-
}
|
|
235
216
|
|
|
236
|
-
|
|
237
|
-
|
|
217
|
+
// Add object position if supported (e.g. expo-image's contentPosition)
|
|
218
|
+
if (objectPositionPropName && objectPosition) {
|
|
219
|
+
finalProps[objectPositionPropName] = objectPosition
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Normalize onLoad event
|
|
223
|
+
if (onLoad) {
|
|
224
|
+
finalProps.onLoad = (e: any) => {
|
|
225
|
+
const source = e?.nativeEvent?.source || e?.source || {}
|
|
226
|
+
onLoad({
|
|
227
|
+
target: {
|
|
228
|
+
naturalHeight: source?.height,
|
|
229
|
+
naturalWidth: source?.width,
|
|
230
|
+
},
|
|
231
|
+
type: 'load',
|
|
232
|
+
} as any)
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Normalize onError event
|
|
237
|
+
if (onError) {
|
|
238
|
+
finalProps.onError = () => {
|
|
239
|
+
onError({
|
|
240
|
+
type: 'error',
|
|
241
|
+
} as any)
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return <StyledImage ref={ref} {...finalProps} />
|
|
246
|
+
}
|
|
247
|
+
) as unknown as ImageType & React.FC<CombinedProps>
|
|
238
248
|
|
|
239
249
|
// Add static methods if the component has them
|
|
240
250
|
const comp = Component as any
|
package/src/types.ts
CHANGED
package/types/Image.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../src/Image.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,SAAS,EAAE,MAAM,SAAS,CAAA;AAOpD,eAAO,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../src/Image.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,SAAS,EAAE,MAAM,SAAS,CAAA;AAOpD,eAAO,MAAM,KAAK,EAwBF,SAAS,CAAA"}
|
package/types/Image.native.d.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { Image as RNImage } from 'react-native';
|
|
2
1
|
export declare const Image: import("react").FC<Partial<import("./types").ImageProps>> & {
|
|
3
|
-
getSize: typeof
|
|
4
|
-
getSizeWithHeaders: typeof
|
|
5
|
-
prefetch: typeof
|
|
6
|
-
prefetchWithMetadata: typeof
|
|
7
|
-
abortPrefetch: typeof
|
|
8
|
-
queryCache: typeof
|
|
9
|
-
} & import("react").FC<import("@tamagui/web").StackNonStyleProps & import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStyleBase> & import("@tamagui/web").
|
|
2
|
+
getSize: typeof import("@tamagui/react-native-types/src").Image.getSize;
|
|
3
|
+
getSizeWithHeaders: typeof import("@tamagui/react-native-types/src").Image.getSizeWithHeaders;
|
|
4
|
+
prefetch: typeof import("@tamagui/react-native-types/src").Image.prefetch;
|
|
5
|
+
prefetchWithMetadata: typeof import("@tamagui/react-native-types/src").Image.prefetchWithMetadata;
|
|
6
|
+
abortPrefetch: typeof import("@tamagui/react-native-types/src").Image.abortPrefetch | undefined;
|
|
7
|
+
queryCache: typeof import("@tamagui/react-native-types/src").Image.queryCache | undefined;
|
|
8
|
+
} & import("react").FC<import("@tamagui/web").StackNonStyleProps & import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStyleBase> & import("@tamagui/web").WithFlatVariantValues<{}> & import("@tamagui/web").WithShorthands<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStyleBase>> & Omit<import("@tamagui/react-native-types/src").ImageProps, "resizeMode" | "source" | keyof import("@tamagui/web").StackNonStyleProps | keyof import("@tamagui/web").StackStyleBase> & {
|
|
10
9
|
src?: string | number;
|
|
11
|
-
source?: import("react-native").ImageSourcePropType;
|
|
12
|
-
resizeMode?: import("react-native").ImageResizeMode;
|
|
13
|
-
objectFit?: React.CSSProperties[
|
|
14
|
-
objectPosition?: React.CSSProperties[
|
|
15
|
-
} & Omit<import("react").ImgHTMLAttributes<HTMLImageElement>,
|
|
10
|
+
source?: import("@tamagui/react-native-types/src").ImageSourcePropType;
|
|
11
|
+
resizeMode?: import("@tamagui/react-native-types/src").ImageResizeMode;
|
|
12
|
+
objectFit?: React.CSSProperties['objectFit'];
|
|
13
|
+
objectPosition?: React.CSSProperties['objectPosition'];
|
|
14
|
+
} & Omit<import("react").ImgHTMLAttributes<HTMLImageElement>, "src" | keyof import("@tamagui/web").StackNonStyleProps | keyof import("@tamagui/web").StackStyleBase> & Omit<import("react").ImgHTMLAttributes<HTMLImageElement>, "height" | "src" | "style" | "width"> & Omit<import("react-native").ImageProps, "about" | "accessKey" | "alt" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-dropeffect" | "aria-errormessage" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-invalid" | "aria-keyshortcuts" | "aria-level" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-setsize" | "aria-sort" | "autoCapitalize" | "autoCorrect" | "autoFocus" | "autoSave" | "blurRadius" | "capInsets" | "content" | "contentEditable" | "contextMenu" | "crossOrigin" | "datatype" | "decoding" | "defaultChecked" | "defaultSource" | "defaultValue" | "dir" | "draggable" | "enterKeyHint" | "exportparts" | "fadeDuration" | "fetchPriority" | "hidden" | "inert" | "inlist" | "inputMode" | "is" | "itemID" | "itemProp" | "itemRef" | "itemScope" | "itemType" | "lang" | "loading" | "loadingIndicatorSource" | "nonce" | "objectPosition" | "onAbort" | "onAbortCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAuxClick" | "onAuxClickCapture" | "onBeforeInputCapture" | "onBeforeToggle" | "onBlurCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onChangeCapture" | "onClickCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onContextMenuCapture" | "onCopyCapture" | "onCutCapture" | "onDoubleClickCapture" | "onDragCapture" | "onDragEndCapture" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeaveCapture" | "onDragOverCapture" | "onDragStartCapture" | "onDropCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onError" | "onErrorCapture" | "onFocusCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onInputCapture" | "onInvalid" | "onInvalidCapture" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUpCapture" | "onLayout" | "onLoad" | "onLoadCapture" | "onLoadEnd" | "onLoadStart" | "onLoadStartCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onMouseDownCapture" | "onMouseMoveCapture" | "onMouseOutCapture" | "onMouseOverCapture" | "onMouseUpCapture" | "onPartialLoad" | "onPasteCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onPointerOut" | "onPointerOutCapture" | "onPointerOver" | "onPointerOverCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onReset" | "onResetCapture" | "onScrollCapture" | "onScrollEnd" | "onScrollEndCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onSelect" | "onSelectCapture" | "onStalled" | "onStalledCapture" | "onSubmit" | "onSubmitCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onToggle" | "onTouchCancelCapture" | "onTouchMoveCapture" | "onTouchStartCapture" | "onTransitionCancel" | "onTransitionCancelCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "onTransitionRun" | "onTransitionRunCapture" | "onTransitionStart" | "onTransitionStartCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onWheelCapture" | "part" | "popover" | "popoverTarget" | "popoverTargetAction" | "prefix" | "progressiveRenderingEnabled" | "property" | "radioGroup" | "referrerPolicy" | "rel" | "resizeMethod" | "resizeMode" | "resource" | "results" | "rev" | "security" | "sizes" | "slot" | "source" | "spellCheck" | "src" | "srcSet" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "tintColor" | "title" | "translate" | "typeof" | "unselectable" | "useMap" | "vocab" | keyof import("@tamagui/web").StackNonStyleProps | keyof import("@tamagui/web").StackStyleBase>>;
|
|
16
15
|
//# sourceMappingURL=Image.native.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.native.d.ts","sourceRoot":"","sources":["../src/Image.native.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Image.native.d.ts","sourceRoot":"","sources":["../src/Image.native.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,KAAK;;;;;;;;;;;;;gqJAEhB,CAAA"}
|
package/types/createImage.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComponentType } from 'react';
|
|
2
|
-
import type { ImageResizeMode } from 'react-native';
|
|
2
|
+
import type { ImageResizeMode } from '@tamagui/react-native-types';
|
|
3
3
|
import type { ImageProps } from './types';
|
|
4
4
|
type GetProps<T> = T extends ComponentType<infer P> ? P : never;
|
|
5
5
|
export type CreateImageOptions<C extends ComponentType<any>> = {
|
|
@@ -60,18 +60,18 @@ export type CreateImageOptions<C extends ComponentType<any>> = {
|
|
|
60
60
|
* />
|
|
61
61
|
*/
|
|
62
62
|
export declare function createImage<C extends ComponentType<any>>(options: CreateImageOptions<C>): import("react").FC<Partial<ImageProps>> & {
|
|
63
|
-
getSize: typeof import("react-native").Image.getSize;
|
|
64
|
-
getSizeWithHeaders: typeof import("react-native").Image.getSizeWithHeaders;
|
|
65
|
-
prefetch: typeof import("react-native").Image.prefetch;
|
|
66
|
-
prefetchWithMetadata: typeof import("react-native").Image.prefetchWithMetadata;
|
|
67
|
-
abortPrefetch: typeof import("react-native").Image.abortPrefetch | undefined;
|
|
68
|
-
queryCache: typeof import("react-native").Image.queryCache | undefined;
|
|
69
|
-
} & import("react").FC<import("@tamagui/web").StackNonStyleProps & import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStyleBase> & import("@tamagui/web").
|
|
63
|
+
getSize: typeof import("@tamagui/react-native-types").Image.getSize;
|
|
64
|
+
getSizeWithHeaders: typeof import("@tamagui/react-native-types").Image.getSizeWithHeaders;
|
|
65
|
+
prefetch: typeof import("@tamagui/react-native-types").Image.prefetch;
|
|
66
|
+
prefetchWithMetadata: typeof import("@tamagui/react-native-types").Image.prefetchWithMetadata;
|
|
67
|
+
abortPrefetch: typeof import("@tamagui/react-native-types").Image.abortPrefetch | undefined;
|
|
68
|
+
queryCache: typeof import("@tamagui/react-native-types").Image.queryCache | undefined;
|
|
69
|
+
} & import("react").FC<import("@tamagui/web").StackNonStyleProps & import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStyleBase> & import("@tamagui/web").WithFlatVariantValues<{}> & import("@tamagui/web").WithShorthands<import("@tamagui/web").WithThemeValues<import("@tamagui/web").StackStyleBase>> & Omit<import("@tamagui/react-native-types").ImageProps, "resizeMode" | "source" | keyof import("@tamagui/web").StackNonStyleProps | keyof import("@tamagui/web").StackStyleBase> & {
|
|
70
70
|
src?: string | number;
|
|
71
|
-
source?: import("react-native").ImageSourcePropType;
|
|
71
|
+
source?: import("@tamagui/react-native-types").ImageSourcePropType;
|
|
72
72
|
resizeMode?: ImageResizeMode;
|
|
73
|
-
objectFit?: React.CSSProperties[
|
|
74
|
-
objectPosition?: React.CSSProperties[
|
|
75
|
-
} & Omit<import("react").ImgHTMLAttributes<HTMLImageElement>,
|
|
73
|
+
objectFit?: React.CSSProperties['objectFit'];
|
|
74
|
+
objectPosition?: React.CSSProperties['objectPosition'];
|
|
75
|
+
} & Omit<import("react").ImgHTMLAttributes<HTMLImageElement>, "src" | keyof import("@tamagui/web").StackNonStyleProps | keyof import("@tamagui/web").StackStyleBase> & Omit<import("react").ImgHTMLAttributes<HTMLImageElement>, "height" | "src" | "style" | "width"> & Omit<GetProps<C>, "about" | "accessKey" | "alt" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-dropeffect" | "aria-errormessage" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-invalid" | "aria-keyshortcuts" | "aria-level" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-setsize" | "aria-sort" | "autoCapitalize" | "autoCorrect" | "autoFocus" | "autoSave" | "blurRadius" | "capInsets" | "content" | "contentEditable" | "contextMenu" | "crossOrigin" | "datatype" | "decoding" | "defaultChecked" | "defaultSource" | "defaultValue" | "dir" | "draggable" | "enterKeyHint" | "exportparts" | "fadeDuration" | "fetchPriority" | "hidden" | "inert" | "inlist" | "inputMode" | "is" | "itemID" | "itemProp" | "itemRef" | "itemScope" | "itemType" | "lang" | "loading" | "loadingIndicatorSource" | "nonce" | "objectPosition" | "onAbort" | "onAbortCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAuxClick" | "onAuxClickCapture" | "onBeforeInputCapture" | "onBeforeToggle" | "onBlurCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onChangeCapture" | "onClickCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onContextMenuCapture" | "onCopyCapture" | "onCutCapture" | "onDoubleClickCapture" | "onDragCapture" | "onDragEndCapture" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeaveCapture" | "onDragOverCapture" | "onDragStartCapture" | "onDropCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onError" | "onErrorCapture" | "onFocusCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onInputCapture" | "onInvalid" | "onInvalidCapture" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUpCapture" | "onLayout" | "onLoad" | "onLoadCapture" | "onLoadEnd" | "onLoadStart" | "onLoadStartCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onMouseDownCapture" | "onMouseMoveCapture" | "onMouseOutCapture" | "onMouseOverCapture" | "onMouseUpCapture" | "onPartialLoad" | "onPasteCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onPointerOut" | "onPointerOutCapture" | "onPointerOver" | "onPointerOverCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onReset" | "onResetCapture" | "onScrollCapture" | "onScrollEnd" | "onScrollEndCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onSelect" | "onSelectCapture" | "onStalled" | "onStalledCapture" | "onSubmit" | "onSubmitCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onToggle" | "onTouchCancelCapture" | "onTouchMoveCapture" | "onTouchStartCapture" | "onTransitionCancel" | "onTransitionCancelCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "onTransitionRun" | "onTransitionRunCapture" | "onTransitionStart" | "onTransitionStartCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onWheelCapture" | "part" | "popover" | "popoverTarget" | "popoverTargetAction" | "prefix" | "progressiveRenderingEnabled" | "property" | "radioGroup" | "referrerPolicy" | "rel" | "resizeMethod" | "resizeMode" | "resource" | "results" | "rev" | "security" | "sizes" | "slot" | "source" | "spellCheck" | "src" | "srcSet" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "tintColor" | "title" | "translate" | "typeof" | "unselectable" | "useMap" | "vocab" | keyof import("@tamagui/web").StackNonStyleProps | keyof import("@tamagui/web").StackStyleBase>>;
|
|
76
76
|
export {};
|
|
77
77
|
//# sourceMappingURL=createImage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createImage.d.ts","sourceRoot":"","sources":["../src/createImage.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"createImage.d.ts","sourceRoot":"","sources":["../src/createImage.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,SAAS,CAAA;AAEpD,KAAK,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;AAE/D,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,aAAa,CAAC,GAAG,CAAC,IAAI;IAC7D;;;OAGG;IACH,SAAS,EAAE,CAAC,CAAA;IACZ;;;OAGG;IACH,wBAAwB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAA;IACxD;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAA;IAC/B;;;OAGG;IACH,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE;QACxB,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;QACrB,MAAM,CAAC,EAAE,GAAG,CAAA;QACZ,KAAK,CAAC,EAAE,GAAG,CAAA;QACX,MAAM,CAAC,EAAE,GAAG,CAAA;KACb,KAAK,GAAG,CAAA;CACV,CAAA;AAoCD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,aAAa,CAAC,GAAG,CAAC,EACtD,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC;;;;;;;;;;;;;mnJA8J/B"}
|
package/types/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ViewProps } from '@tamagui/web';
|
|
2
|
-
import type { ImageResizeMode, ImageSourcePropType, Image as RNImage, ImageProps as RNImageProps } from 'react-native';
|
|
2
|
+
import type { ImageResizeMode, ImageSourcePropType, Image as RNImage, ImageProps as RNImageProps } from '@tamagui/react-native-types';
|
|
3
3
|
type RNImageType = typeof RNImage;
|
|
4
4
|
type KeyofViewProps = keyof ViewProps;
|
|
5
5
|
export type ImageProps = ViewProps & Omit<RNImageProps, KeyofViewProps | 'source' | 'resizeMode' | 'style'> & {
|
package/types/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,KAAK,EACV,eAAe,EACf,mBAAmB,EACnB,KAAK,IAAI,OAAO,EAChB,UAAU,IAAI,YAAY,EAC3B,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,KAAK,EACV,eAAe,EACf,mBAAmB,EACnB,KAAK,IAAI,OAAO,EAChB,UAAU,IAAI,YAAY,EAC3B,MAAM,6BAA6B,CAAA;AAEpC,KAAK,WAAW,GAAG,OAAO,OAAO,CAAA;AAEjC,KAAK,cAAc,GAAG,MAAM,SAAS,CAAA;AAErC,MAAM,MAAM,UAAU,GAAG,SAAS,GAChC,IAAI,CAAC,YAAY,EAAE,cAAc,GAAG,QAAQ,GAAG,YAAY,GAAG,OAAO,CAAC,GAAG;IACvE;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACrB;;;OAGG;IACH,MAAM,CAAC,EAAE,mBAAmB,CAAA;IAC5B;;;OAGG;IACH,UAAU,CAAC,EAAE,eAAe,CAAA;IAC5B;;;OAGG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,CAAA;IAC5C;;;;OAIG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAA;CACvD,GAAG,IAAI,CACN,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,EACzC,OAAO,GAAG,QAAQ,GAAG,cAAc,GAAG,KAAK,CAC5C,GACD,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,CAAC,CAAA;AAEvF,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG;IACtD,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"}
|
package/dist/cjs/v1/Image.cjs
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
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, {
|
|
16
|
-
get: () => from[key],
|
|
17
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
-
value: mod,
|
|
29
|
-
enumerable: true
|
|
30
|
-
}) : target, mod));
|
|
31
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
-
value: true
|
|
33
|
-
}), mod);
|
|
34
|
-
var Image_exports = {};
|
|
35
|
-
__export(Image_exports, {
|
|
36
|
-
Image: () => Image
|
|
37
|
-
});
|
|
38
|
-
module.exports = __toCommonJS(Image_exports);
|
|
39
|
-
var import_react = __toESM(require("react"), 1);
|
|
40
|
-
var import_constants = require("@tamagui/constants");
|
|
41
|
-
var import_web = require("@tamagui/web");
|
|
42
|
-
var import_react_native = require("react-native-web");
|
|
43
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
44
|
-
const StyledImage = (0, import_web.styled)(import_react_native.Image, {
|
|
45
|
-
name: "Image"
|
|
46
|
-
});
|
|
47
|
-
let hasWarned = false;
|
|
48
|
-
const Image = StyledImage.styleable((inProps, ref) => {
|
|
49
|
-
const [props, style] = (0, import_web.usePropsAndStyle)(inProps);
|
|
50
|
-
const {
|
|
51
|
-
src,
|
|
52
|
-
source,
|
|
53
|
-
objectFit,
|
|
54
|
-
...rest
|
|
55
|
-
} = props;
|
|
56
|
-
if (process.env.NODE_ENV === "development") {
|
|
57
|
-
if (typeof src === "string") {
|
|
58
|
-
if (typeof props.width === "string" && props.width[0] !== "$" || typeof props.height === "string" && props.height[0] !== "$") {
|
|
59
|
-
if (!hasWarned) {
|
|
60
|
-
hasWarned = true;
|
|
61
|
-
console.warn(`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.`);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
let finalSource = typeof src === "string" ? {
|
|
67
|
-
uri: src,
|
|
68
|
-
...(import_constants.isWeb && {
|
|
69
|
-
width: props.width || style?.width,
|
|
70
|
-
height: props.height || style?.height
|
|
71
|
-
})
|
|
72
|
-
} : source ?? src;
|
|
73
|
-
if (finalSource && typeof finalSource === "object") {
|
|
74
|
-
if (process.env.NODE_ENV === "development" && process.env.TAMAGUI_IMAGE_CHECK_ERROR) import_react.default.useEffect(() => {
|
|
75
|
-
async function run() {
|
|
76
|
-
if (typeof src === "string") try {
|
|
77
|
-
await fetch(src).then(res => res.text());
|
|
78
|
-
} catch (err) {
|
|
79
|
-
console.error(`Error loading image: ${src}`, {
|
|
80
|
-
props
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
run();
|
|
85
|
-
}, [src]);
|
|
86
|
-
if (finalSource["default"]) finalSource = finalSource["default"];
|
|
87
|
-
}
|
|
88
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_native.Image, {
|
|
89
|
-
resizeMode: objectFit,
|
|
90
|
-
ref,
|
|
91
|
-
source: finalSource,
|
|
92
|
-
style,
|
|
93
|
-
...rest
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
Image.getSize = import_react_native.Image.getSize;
|
|
97
|
-
Image.getSizeWithHeaders = import_react_native.Image.getSizeWithHeaders;
|
|
98
|
-
Image.prefetch = import_react_native.Image.prefetch;
|
|
99
|
-
Image.prefetchWithMetadata = import_react_native.Image.prefetchWithMetadata;
|
|
100
|
-
Image.abortPrefetch = import_react_native.Image.abortPrefetch;
|
|
101
|
-
Image.queryCache = import_react_native.Image.queryCache;
|