@cleartrip/ct-design-image 5.14.0-SNAPSHOT-typographyOnTextLayout.0 → 5.14.0-SNAPSHOT-native-main.35
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 +4 -3
- package/dist/type.d.ts.map +1 -1
- package/package.json +7 -6
- package/src/Image.native.tsx +23 -4
- package/src/type.ts +7 -3
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;;CA2Fb,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
|
}
|
|
@@ -9,7 +9,7 @@ export interface IImageWebRendererProps {
|
|
|
9
9
|
width?: number;
|
|
10
10
|
height?: number;
|
|
11
11
|
className?: string;
|
|
12
|
-
onClick?: () => void;
|
|
12
|
+
onClick?: (e: INativeUIEvent) => void;
|
|
13
13
|
onLoad?: () => void;
|
|
14
14
|
onError?: (e: SyntheticEvent<HTMLImageElement, Event>) => void;
|
|
15
15
|
priority?: boolean;
|
|
@@ -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>;
|
|
@@ -36,5 +36,6 @@ export interface IImageProps {
|
|
|
36
36
|
unoptimized?: boolean;
|
|
37
37
|
fetchPriority?: 'high' | 'low' | 'auto';
|
|
38
38
|
fill?: boolean;
|
|
39
|
+
zoomTransition?: boolean;
|
|
39
40
|
}
|
|
40
41
|
//# 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":"AAA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AC;IAE1C,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IAKpB,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,cAAc,CAAC,gBAAgB,EAAE,KAAK,CAAC,KAAK,IAAI,CAAC;IAQ/D,SAAS,CAAC,EAAE,aAAa,CAAC,sBAAsB,CAAC,CAAC;IAKlD,UAAU,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAC;IAIxD,QAAQ,CAAC,EAAE,OAAO,CAAC;IAInB,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAI3B,WAAW,CAAC,EAAE,MAAM,CAAC;IAIrB,WAAW,CAAC,EAAE,OAAO,CAAC;IAItB,aAAa,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC;IAIxC,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.14.0-SNAPSHOT-
|
|
3
|
+
"version": "5.14.0-SNAPSHOT-native-main.35",
|
|
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-
|
|
28
|
-
"@cleartrip/ct-design-
|
|
29
|
-
"@cleartrip/ct-design-
|
|
30
|
-
"@cleartrip/ct-design-
|
|
27
|
+
"@cleartrip/ct-design-style-manager": "5.13.0-SNAPSHOT-native-main.35",
|
|
28
|
+
"@cleartrip/ct-design-conditional-wrap": "5.14.0-SNAPSHOT-native-main.35",
|
|
29
|
+
"@cleartrip/ct-design-event-propagation": "5.14.0-SNAPSHOT-native-main.35",
|
|
30
|
+
"@cleartrip/ct-design-common-utils": "5.13.0-SNAPSHOT-native-main.35",
|
|
31
|
+
"@cleartrip/ct-design-theme": "5.13.0-SNAPSHOT-native-main.35"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"next": "^14.2.35",
|
|
34
|
-
"@cleartrip/ct-design-types": "5.13.0-SNAPSHOT-
|
|
35
|
+
"@cleartrip/ct-design-types": "5.13.0-SNAPSHOT-native-main.35"
|
|
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 '@cleartrip/ct-design-types';
|
|
13
|
+
import { isIOS } from '@cleartrip/ct-design-common-utils';
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Native implementation of `Image`.
|
|
@@ -37,6 +39,7 @@ 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 || '',
|
|
@@ -45,6 +48,7 @@ const Image = ({
|
|
|
45
48
|
|
|
46
49
|
const aspectRatio = customRootStyles.find((style) => style.aspectRatio);
|
|
47
50
|
|
|
51
|
+
const nodeElement = useRef<number | null>(null);
|
|
48
52
|
const imageStyles = useStyles(
|
|
49
53
|
() => ({
|
|
50
54
|
image: {
|
|
@@ -60,7 +64,14 @@ const Image = ({
|
|
|
60
64
|
[imageStyles, customRootStyles],
|
|
61
65
|
);
|
|
62
66
|
|
|
63
|
-
const
|
|
67
|
+
const clickWithNodeElement = (e: INativeUIEvent) => {
|
|
68
|
+
if (zoomTransition && nodeElement.current) {
|
|
69
|
+
e.nodeElement = nodeElement.current;
|
|
70
|
+
}
|
|
71
|
+
onClick?.(e);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const mergedEvents = useMergeEvents({ onClick: clickWithNodeElement ? [clickWithNodeElement] : [] });
|
|
64
75
|
const { onClick: onClickEvent } = useTriggerEvents(mergedEvents);
|
|
65
76
|
|
|
66
77
|
useEffect(() => {
|
|
@@ -107,7 +118,15 @@ const Image = ({
|
|
|
107
118
|
|
|
108
119
|
return (
|
|
109
120
|
<EventCollectorProvider value={mergedEvents}>
|
|
110
|
-
<Pressable
|
|
121
|
+
<Pressable
|
|
122
|
+
ref={(ref) => {
|
|
123
|
+
if (isIOS()) {
|
|
124
|
+
nodeElement.current = findNodeHandle(ref);
|
|
125
|
+
}
|
|
126
|
+
}}
|
|
127
|
+
style={mergedImageStyles}
|
|
128
|
+
onPress={onClickEvent}
|
|
129
|
+
>
|
|
111
130
|
{imageElement}
|
|
112
131
|
</Pressable>
|
|
113
132
|
</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
|
|
@@ -26,7 +26,7 @@ export interface IImageWebRendererProps {
|
|
|
26
26
|
width?: number;
|
|
27
27
|
height?: number;
|
|
28
28
|
className?: string;
|
|
29
|
-
onClick?: () => void;
|
|
29
|
+
onClick?: (e: INativeUIEvent) => void;
|
|
30
30
|
onLoad?: () => void;
|
|
31
31
|
onError?: (e: SyntheticEvent<HTMLImageElement, Event>) => void;
|
|
32
32
|
priority?: boolean;
|
|
@@ -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
|
/**
|
|
@@ -112,4 +112,8 @@ export interface IImageProps {
|
|
|
112
112
|
* fill
|
|
113
113
|
*/
|
|
114
114
|
fill?: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* zoom transition of the image
|
|
117
|
+
*/
|
|
118
|
+
zoomTransition?: boolean;
|
|
115
119
|
}
|