@cleartrip/ct-design-image 5.12.0-SNAPSHOT-native-main.2 → 5.12.0-SNAPSHOT-native-main.22
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/Image.native.d.ts +1 -1
- package/dist/Image.native.d.ts.map +1 -1
- package/dist/type.d.ts +3 -2
- package/dist/type.d.ts.map +1 -1
- package/package.json +7 -6
- package/src/Image.native.tsx +26 -8
- package/src/type.ts +6 -2
package/dist/Image.native.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IImageProps } from './type';
|
|
2
2
|
declare const Image: {
|
|
3
|
-
({ src, alt, width, height, fallbackUrl, styleConfig, onClick, onLoad, onError, resizeMode, }: IImageProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
({ src, alt, width, height, fallbackUrl, styleConfig, onClick, onLoad, onError, resizeMode, zoomTransition, }: IImageProps): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
displayName: string;
|
|
5
5
|
};
|
|
6
6
|
export default Image;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.native.d.ts","sourceRoot":"","sources":["../packages/components/Image/src/Image.native.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"Image.native.d.ts","sourceRoot":"","sources":["../packages/components/Image/src/Image.native.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAqBrC,QAAA,MAAM,KAAK;mHAYR,WAAW;;CA0Fb,CAAC;AAIF,eAAe,KAAK,CAAC"}
|
package/dist/type.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComponentType, SyntheticEvent } from 'react';
|
|
2
|
-
import type { ImageStyle } from '@cleartrip/ct-design-types';
|
|
2
|
+
import type { ImageStyle, INativeUIEvent } from '@cleartrip/ct-design-types';
|
|
3
3
|
export interface IImageStyleConfig {
|
|
4
4
|
root?: Omit<ImageStyle, 'backgroundColor' | 'overlayColor' | 'borderColor'>[];
|
|
5
5
|
}
|
|
@@ -25,7 +25,7 @@ export interface IImageProps {
|
|
|
25
25
|
height?: ImageStyle['height'];
|
|
26
26
|
fallbackUrl?: string;
|
|
27
27
|
styleConfig?: IImageStyleConfig;
|
|
28
|
-
onClick?: () => void;
|
|
28
|
+
onClick?: (event: INativeUIEvent) => void;
|
|
29
29
|
onLoad?: () => void;
|
|
30
30
|
onError?: (e: SyntheticEvent<HTMLImageElement, Event>) => void;
|
|
31
31
|
Component?: ComponentType<IImageWebRendererProps>;
|
|
@@ -34,5 +34,6 @@ export interface IImageProps {
|
|
|
34
34
|
loading?: 'eager' | 'lazy';
|
|
35
35
|
blurDataURL?: string;
|
|
36
36
|
fill?: boolean;
|
|
37
|
+
zoomTransition?: boolean;
|
|
37
38
|
}
|
|
38
39
|
//# sourceMappingURL=type.d.ts.map
|
package/dist/type.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../packages/components/Image/src/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../packages/components/Image/src/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE3D,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAW7E,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,EAAE,IAAI,CAAC,UAAU,EAAE,iBAAiB,GAAG,cAAc,GAAG,aAAa,CAAC,EAAE,CAAC;CAC/E;AAOD,MAAM,WAA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,OAAO,CAAC;IAInB,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAI3B,WAAW,CAAC,EAAE,MAAM,CAAC;IAIrB,IAAI,CAAC,EAAE,OAAO,CAAC;IAIf,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cleartrip/ct-design-image",
|
|
3
|
-
"version": "5.12.0-SNAPSHOT-native-main.
|
|
3
|
+
"version": "5.12.0-SNAPSHOT-native-main.22",
|
|
4
4
|
"description": "Image component — web <img>/custom component, native FastImage + SvgUri.",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "./dist/ct-design-image.cjs.js",
|
|
@@ -24,14 +24,15 @@
|
|
|
24
24
|
"src"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@cleartrip/ct-design-conditional-wrap": "5.12.0-SNAPSHOT-native-main.
|
|
28
|
-
"@cleartrip/ct-design-event-propagation": "5.12.0-SNAPSHOT-native-main.
|
|
29
|
-
"@cleartrip/ct-design-style-manager": "5.
|
|
30
|
-
"@cleartrip/ct-design-theme": "5.11.0-SNAPSHOT-native-main.
|
|
27
|
+
"@cleartrip/ct-design-conditional-wrap": "5.12.0-SNAPSHOT-native-main.22",
|
|
28
|
+
"@cleartrip/ct-design-event-propagation": "5.12.0-SNAPSHOT-native-main.22",
|
|
29
|
+
"@cleartrip/ct-design-style-manager": "5.10.1-SNAPSHOT-native-main.0",
|
|
30
|
+
"@cleartrip/ct-design-theme": "5.11.0-SNAPSHOT-native-main.0",
|
|
31
|
+
"@cleartrip/ct-design-common-utils": "5.10.1-SNAPSHOT-native-main.0"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"next": "^14.2.35",
|
|
34
|
-
"@cleartrip/ct-design-types": "5.11.0-SNAPSHOT-native-main.
|
|
35
|
+
"@cleartrip/ct-design-types": "5.11.0-SNAPSHOT-native-main.0"
|
|
35
36
|
},
|
|
36
37
|
"peerDependencies": {
|
|
37
38
|
"react": ">=16.8.0",
|
package/src/Image.native.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SyntheticEvent, useEffect, useState } from 'react';
|
|
1
|
+
import { SyntheticEvent, useEffect, useRef, useState } from 'react';
|
|
2
2
|
|
|
3
|
-
import { Pressable } from 'react-native';
|
|
3
|
+
import { findNodeHandle, Pressable } from 'react-native';
|
|
4
4
|
import FastImage, { ImageStyle as FastImageStyle } from 'react-native-fast-image';
|
|
5
5
|
import { SvgUri } from 'react-native-svg';
|
|
6
6
|
|
|
@@ -9,6 +9,8 @@ import EventCollectorProvider, { useMergeEvents, useTriggerEvents } from '@clear
|
|
|
9
9
|
|
|
10
10
|
import { IImageProps } from './type';
|
|
11
11
|
import { isSvg } from './style';
|
|
12
|
+
import { INativeUIEvent } from 'packages/core/types/dist';
|
|
13
|
+
import { isIOS } from '@cleartrip/ct-design-common-utils';
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Native implementation of `Image`.
|
|
@@ -37,30 +39,38 @@ const Image = ({
|
|
|
37
39
|
onLoad,
|
|
38
40
|
onError,
|
|
39
41
|
resizeMode,
|
|
42
|
+
zoomTransition = false,
|
|
40
43
|
}: IImageProps) => {
|
|
41
44
|
const [imageSource, setImageSource] = useState<{ uri: string }>({
|
|
42
45
|
uri: src || fallbackUrl || '',
|
|
43
46
|
});
|
|
44
|
-
const { root: customRootStyles = [] } = styleConfig || {};
|
|
45
|
-
|
|
46
|
-
const aspectRatio = customRootStyles.find((style) => style.aspectRatio);
|
|
47
47
|
|
|
48
|
+
const nodeElement = useRef<number | null>(null);
|
|
48
49
|
const imageStyles = useStyles(
|
|
49
50
|
() => ({
|
|
50
51
|
image: {
|
|
51
|
-
height
|
|
52
|
+
height,
|
|
52
53
|
width,
|
|
53
54
|
},
|
|
54
55
|
}),
|
|
55
56
|
[height, width],
|
|
56
57
|
);
|
|
57
58
|
|
|
59
|
+
const { root: customRootStyles = [] } = styleConfig || {};
|
|
60
|
+
|
|
58
61
|
const mergedImageStyles = useNativeMergeStyles(
|
|
59
62
|
[imageStyles.image, ...customRootStyles],
|
|
60
63
|
[imageStyles, customRootStyles],
|
|
61
64
|
);
|
|
62
65
|
|
|
63
|
-
const
|
|
66
|
+
const clickWithNodeElement = (e: INativeUIEvent) => {
|
|
67
|
+
if (zoomTransition && nodeElement.current) {
|
|
68
|
+
e.nodeElement = nodeElement.current;
|
|
69
|
+
}
|
|
70
|
+
onClick?.(e);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const mergedEvents = useMergeEvents({ onClick: clickWithNodeElement ? [clickWithNodeElement] : [] });
|
|
64
74
|
const { onClick: onClickEvent } = useTriggerEvents(mergedEvents);
|
|
65
75
|
|
|
66
76
|
useEffect(() => {
|
|
@@ -107,7 +117,15 @@ const Image = ({
|
|
|
107
117
|
|
|
108
118
|
return (
|
|
109
119
|
<EventCollectorProvider value={mergedEvents}>
|
|
110
|
-
<Pressable
|
|
120
|
+
<Pressable
|
|
121
|
+
ref={(ref) => {
|
|
122
|
+
if (isIOS()) {
|
|
123
|
+
nodeElement.current = findNodeHandle(ref);
|
|
124
|
+
}
|
|
125
|
+
}}
|
|
126
|
+
style={mergedImageStyles}
|
|
127
|
+
onPress={onClickEvent}
|
|
128
|
+
>
|
|
111
129
|
{imageElement}
|
|
112
130
|
</Pressable>
|
|
113
131
|
</EventCollectorProvider>
|
package/src/type.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ComponentType, SyntheticEvent } from 'react';
|
|
2
2
|
|
|
3
|
-
import type { ImageStyle } from '@cleartrip/ct-design-types';
|
|
3
|
+
import type { ImageStyle, INativeUIEvent } from '@cleartrip/ct-design-types';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Style-config slot shape shared by web + native. On web each entry is
|
|
@@ -67,7 +67,7 @@ export interface IImageProps {
|
|
|
67
67
|
/** Fine-grained style overrides for the image element. */
|
|
68
68
|
styleConfig?: IImageStyleConfig;
|
|
69
69
|
/** Fired when the user activates the image (click / press). */
|
|
70
|
-
onClick?: () => void;
|
|
70
|
+
onClick?: (event: INativeUIEvent) => void;
|
|
71
71
|
/** Fired once the image finishes loading. */
|
|
72
72
|
onLoad?: () => void;
|
|
73
73
|
/**
|
|
@@ -104,4 +104,8 @@ export interface IImageProps {
|
|
|
104
104
|
* fill
|
|
105
105
|
*/
|
|
106
106
|
fill?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* zoom transition of the image
|
|
109
|
+
*/
|
|
110
|
+
zoomTransition?: boolean;
|
|
107
111
|
}
|