@hanzogui/image 2.0.0-rc.41-hanzoai.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.
Files changed (93) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/Image.cjs +64 -0
  3. package/dist/cjs/Image.native.js +35 -0
  4. package/dist/cjs/Image.native.js.map +1 -0
  5. package/dist/cjs/createImage.cjs +157 -0
  6. package/dist/cjs/createImage.native.js +161 -0
  7. package/dist/cjs/createImage.native.js.map +1 -0
  8. package/dist/cjs/index.cjs +21 -0
  9. package/dist/cjs/index.native.js +24 -0
  10. package/dist/cjs/index.native.js.map +1 -0
  11. package/dist/cjs/types.cjs +18 -0
  12. package/dist/cjs/types.native.js +21 -0
  13. package/dist/cjs/types.native.js.map +1 -0
  14. package/dist/cjs/v1/Image.cjs +101 -0
  15. package/dist/cjs/v1/Image.native.js +123 -0
  16. package/dist/cjs/v1/Image.native.js.map +1 -0
  17. package/dist/cjs/v1/index.cjs +20 -0
  18. package/dist/cjs/v1/index.native.js +23 -0
  19. package/dist/cjs/v1/index.native.js.map +1 -0
  20. package/dist/esm/Image.mjs +39 -0
  21. package/dist/esm/Image.mjs.map +1 -0
  22. package/dist/esm/Image.native.js +7 -0
  23. package/dist/esm/Image.native.js.map +1 -0
  24. package/dist/esm/createImage.mjs +132 -0
  25. package/dist/esm/createImage.mjs.map +1 -0
  26. package/dist/esm/createImage.native.js +133 -0
  27. package/dist/esm/createImage.native.js.map +1 -0
  28. package/dist/esm/index.js +3 -0
  29. package/dist/esm/index.js.map +1 -0
  30. package/dist/esm/index.mjs +3 -0
  31. package/dist/esm/index.mjs.map +1 -0
  32. package/dist/esm/index.native.js +3 -0
  33. package/dist/esm/index.native.js.map +1 -0
  34. package/dist/esm/types.mjs +2 -0
  35. package/dist/esm/types.mjs.map +1 -0
  36. package/dist/esm/types.native.js +2 -0
  37. package/dist/esm/types.native.js.map +1 -0
  38. package/dist/esm/v1/Image.mjs +65 -0
  39. package/dist/esm/v1/Image.mjs.map +1 -0
  40. package/dist/esm/v1/Image.native.js +84 -0
  41. package/dist/esm/v1/Image.native.js.map +1 -0
  42. package/dist/esm/v1/index.mjs +2 -0
  43. package/dist/esm/v1/index.mjs.map +1 -0
  44. package/dist/esm/v1/index.native.js +2 -0
  45. package/dist/esm/v1/index.native.js.map +1 -0
  46. package/dist/jsx/Image.mjs +39 -0
  47. package/dist/jsx/Image.mjs.map +1 -0
  48. package/dist/jsx/Image.native.js +35 -0
  49. package/dist/jsx/Image.native.js.map +1 -0
  50. package/dist/jsx/createImage.mjs +132 -0
  51. package/dist/jsx/createImage.mjs.map +1 -0
  52. package/dist/jsx/createImage.native.js +161 -0
  53. package/dist/jsx/createImage.native.js.map +1 -0
  54. package/dist/jsx/index.js +3 -0
  55. package/dist/jsx/index.js.map +1 -0
  56. package/dist/jsx/index.mjs +3 -0
  57. package/dist/jsx/index.mjs.map +1 -0
  58. package/dist/jsx/index.native.js +24 -0
  59. package/dist/jsx/index.native.js.map +1 -0
  60. package/dist/jsx/types.mjs +2 -0
  61. package/dist/jsx/types.mjs.map +1 -0
  62. package/dist/jsx/types.native.js +21 -0
  63. package/dist/jsx/types.native.js.map +1 -0
  64. package/dist/jsx/v1/Image.mjs +65 -0
  65. package/dist/jsx/v1/Image.mjs.map +1 -0
  66. package/dist/jsx/v1/Image.native.js +123 -0
  67. package/dist/jsx/v1/Image.native.js.map +1 -0
  68. package/dist/jsx/v1/index.mjs +2 -0
  69. package/dist/jsx/v1/index.mjs.map +1 -0
  70. package/dist/jsx/v1/index.native.js +23 -0
  71. package/dist/jsx/v1/index.native.js.map +1 -0
  72. package/package.json +53 -0
  73. package/src/Image.native.tsx +6 -0
  74. package/src/Image.tsx +41 -0
  75. package/src/createImage.tsx +245 -0
  76. package/src/index.ts +3 -0
  77. package/src/types.ts +54 -0
  78. package/src/v1/Image.tsx +144 -0
  79. package/src/v1/index.ts +1 -0
  80. package/types/Image.d.ts +3 -0
  81. package/types/Image.d.ts.map +1 -0
  82. package/types/Image.native.d.ts +16 -0
  83. package/types/Image.native.d.ts.map +1 -0
  84. package/types/createImage.d.ts +77 -0
  85. package/types/createImage.d.ts.map +1 -0
  86. package/types/index.d.ts +4 -0
  87. package/types/index.d.ts.map +1 -0
  88. package/types/types.d.ts +42 -0
  89. package/types/types.d.ts.map +1 -0
  90. package/types/v1/Image.d.ts +36 -0
  91. package/types/v1/Image.d.ts.map +1 -0
  92. package/types/v1/index.d.ts +2 -0
  93. package/types/v1/index.d.ts.map +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","isWeb","styled","usePropsAndStyle","Image","RNImage","jsx","StyledImage","name","hasWarned","styleable","inProps","ref","props","style","src","source","objectFit","rest","process","env","NODE_ENV","width","height","console","warn","finalSource","uri","TAMAGUI_IMAGE_CHECK_ERROR","useEffect","run","fetch","then","res","text","err","error","resizeMode","getSize","getSizeWithHeaders","prefetch","prefetchWithMetadata","abortPrefetch","queryCache"],"sources":["../../../src/v1/Image.tsx"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,KAAA,MAAW;AAClB,SAASC,KAAA,QAAa;AAQtB,SAASC,MAAA,EAAQC,gBAAA,QAAwB;AAEzC,SAASC,KAAA,IAASC,OAAA,QAAe;AAqH7B,SAAAC,GAAA;AAnHJ,MAAMC,WAAA,GAAcL,MAAA,CAAOG,OAAA,EAAS;EAAAG,IAAA;AAAA;AAAA,IAClCC,SAAM;AACR,MAACL,KAAA,GAAAG,WAAA,CAAAG,SAAA,EAAAC,OAAA,EAAAC,GAAA;EAmCD,MAAI,CAAAC,KAAA,EAAAC,KAAY,IAAAX,gBAAA,CAAAQ,OAAA;EAMT,MAAM;IAAAI,GAAA;IAAQC,MAAA;IAAAC,SAAY;IAAA,GAAsBC;EAAC,IAAAL,KAAS;EAC/D,IAAAM,OAAO,CAAAC,GAAO,CAAAC,QAAS,kBAAiB;IACxC,WAAQN,GAAK,aAAQ;MAErB,IAAI,OAAQF,KAAI,CA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M;AAAwCpC,KAAA,CAAAqC,oBACxD,GAAApC,OAAA,CAAAoC,oBAAA;AAAArC,KAAA,CAAAsC,aACF,GAAArC,OAAA,CAAAqC,aAAA;AAAAtC,KAAA,CAAAuC,UACF,GAAAtC,OAAA,CAAAsC,UAAA;AAEA,SAAAvC,KAAI","ignoreList":[]}
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all) __defProp(target, name, {
11
+ get: all[name],
12
+ enumerable: true
13
+ });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
18
+ get: () => from[key],
19
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
+ });
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
27
+ // compatible transform (i.e. "__esModule" has not been set), then set
28
+ // "default" to the CommonJS "module.exports" for node compatibility.
29
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
30
+ value: mod,
31
+ enumerable: true
32
+ }) : target, mod));
33
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
34
+ value: true
35
+ }), mod);
36
+ var Image_exports = {};
37
+ __export(Image_exports, {
38
+ Image: () => Image
39
+ });
40
+ module.exports = __toCommonJS(Image_exports);
41
+ var import_jsx_runtime = require("react/jsx-runtime");
42
+ var import_react = __toESM(require("react"), 1);
43
+ var import_constants = require("@hanzogui/constants");
44
+ var import_web = require("@hanzogui/web");
45
+ var import_react_native = require("react-native");
46
+ function _type_of(obj) {
47
+ "@swc/helpers - typeof";
48
+
49
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
50
+ }
51
+ var StyledImage = (0, import_web.styled)(import_react_native.Image, {
52
+ name: "Image"
53
+ });
54
+ var hasWarned = false;
55
+ var Image = StyledImage.styleable(function (inProps, ref) {
56
+ var [props, style] = (0, import_web.usePropsAndStyle)(inProps);
57
+ var {
58
+ src,
59
+ source,
60
+ objectFit,
61
+ ...rest
62
+ } = props;
63
+ if (process.env.NODE_ENV === "development") {
64
+ if (typeof src === "string") {
65
+ if (typeof props.width === "string" && props.width[0] !== "$" || typeof props.height === "string" && props.height[0] !== "$") {
66
+ if (!hasWarned) {
67
+ hasWarned = true;
68
+ 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.`);
69
+ }
70
+ }
71
+ }
72
+ }
73
+ var finalSource = typeof src === "string" ? {
74
+ uri: src,
75
+ ...(import_constants.isWeb && {
76
+ width: props.width || (style === null || style === void 0 ? void 0 : style.width),
77
+ height: props.height || (style === null || style === void 0 ? void 0 : style.height)
78
+ })
79
+ } : source !== null && source !== void 0 ? source : src;
80
+ if (finalSource && (typeof finalSource === "undefined" ? "undefined" : _type_of(finalSource)) === "object") {
81
+ if (!Array.isArray(finalSource)) {
82
+ if (typeof finalSource.uri === "number") {
83
+ finalSource = finalSource.uri;
84
+ if (source && (typeof source === "undefined" ? "undefined" : _type_of(source)) === "object" && !Array.isArray(source)) {
85
+ var _style, _style1;
86
+ var _width;
87
+ (_width = (_style = style).width) !== null && _width !== void 0 || (_style.width = source.width);
88
+ var _height;
89
+ (_height = (_style1 = style).height) !== null && _height !== void 0 || (_style1.height = source.height);
90
+ }
91
+ }
92
+ }
93
+ if (process.env.NODE_ENV === "development" && process.env.TAMAGUI_IMAGE_CHECK_ERROR) import_react.default.useEffect(function () {
94
+ async function run() {
95
+ if (typeof src === "string") try {
96
+ await fetch(src).then(function (res) {
97
+ return res.text();
98
+ });
99
+ } catch (err) {
100
+ console.error(`Error loading image: ${src}`, {
101
+ props
102
+ });
103
+ }
104
+ }
105
+ run();
106
+ }, [src]);
107
+ if (finalSource["default"]) finalSource = finalSource["default"];
108
+ }
109
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_native.Image, {
110
+ resizeMode: objectFit,
111
+ ref,
112
+ source: finalSource,
113
+ style,
114
+ ...rest
115
+ });
116
+ });
117
+ Image.getSize = import_react_native.Image.getSize;
118
+ Image.getSizeWithHeaders = import_react_native.Image.getSizeWithHeaders;
119
+ Image.prefetch = import_react_native.Image.prefetch;
120
+ Image.prefetchWithMetadata = import_react_native.Image.prefetchWithMetadata;
121
+ Image.abortPrefetch = import_react_native.Image.abortPrefetch;
122
+ Image.queryCache = import_react_native.Image.queryCache;
123
+ //# sourceMappingURL=Image.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__create","Object","create","__defProp","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__getProtoOf","getPrototypeOf","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toESM","mod","isNodeMode","__esModule","value","__toCommonJS","Image_exports","Image","module","exports","import_jsx_runtime","require","import_react","import_constants","import_web","import_react_native","_type_of","obj","Symbol","constructor","StyledImage","styled","hasWarned","styleable","inProps","ref","props","style","usePropsAndStyle","src","source","objectFit","rest","process","env","NODE_ENV","width","height","console","warn","finalSource","uri","isWeb","Array","isArray","_style","_style1","_width","_height"],"sources":["../../../src/v1/Image.tsx"],"sourcesContent":[null],"mappings":"AAAA,YAAO;;AACP,IAAAA,QAAS,GAAAC,MAAA,CAAaC,MAAA;AAQtB,IAAAC,SAAS,GAAAF,MAAQ,CAAAG,cAAA;AAEjB,IAAAC,gBAA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GAAA;IAAA,IAAAhB,gBAAA,CAAA6B,KAAA;MAAAN,KACC,EAAAV,KAAA,CAAAU,KAAY,KAAAT,KAAA,aAAAA,KAAA,uBAAAA,KAAA,CAAAS,KAAA;MAAAC,MACZ,EAAAX,KAAA,CAAAW,MAAA,KAAAV,KAAA,aAAAA,KAAA,uBAAAA,KAAA,CAAAU,MAAA;IAAA;EACQ,IAAAP,MACR,aAAAA,MAAA,cAAAA,MAAA,GAAAD,GAAA;EAAA,IAAAW,WACK,YAAAA,WAAA,iCAAAxB,QAAA,CAAAwB,WAAA;IAAA,KAAAG,KAAA,CAAAC,OAAA,CAAAJ,WAAA;MACP,WAAAA,WAAA,CAAAC,GAAA;QAEHD,WAAA,GAAAA,WAAA,CAAAC,GAAA;QAED,IAAMX,MAAA,IAAU,QAAQA,MAAA,iCAAAd,QAAA,CAAAc,MAAA,oBAAAa,KAAA,CAAAC,OAAA,CAAAd,MAAA;UACxB,IAAMe,MAAA,EAAAC,OAAA;UACN,IAAMC,MAAA;UACN,CAAMA,MAAA,IAAAF,MAAA,GAAAlB,KAAuB,EAAAS,KAAQ,cAAAW,MAAA,gBAAAF,MAAA,CAAAT,KAAA,GAAAN,MAAA,CAAAM,KAAA;UACrC,IAAMY,OAAA;UACN,CAAMA,OAAA,IAAAF,OAAa,GAAQnB,KAAA,EAAAU,MAAA,cAAAW,OAAA,gBAAAF,OAAA,CAAAT,MAAA,GAAAP,MAAA,CAAAO,MAAA","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export * from "./Image.mjs";
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../../src/v1/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
@@ -0,0 +1,23 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../../src/v1/index.ts"],"sourcesContent":[null],"mappings":"AAAA","ignoreList":[]}
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@hanzogui/image",
3
+ "version": "2.0.0-rc.41-hanzoai.1",
4
+ "source": "src/index.ts",
5
+ "files": [
6
+ "src",
7
+ "types",
8
+ "dist"
9
+ ],
10
+ "type": "module",
11
+ "sideEffects": [
12
+ "*.css"
13
+ ],
14
+ "main": "dist/cjs",
15
+ "module": "dist/esm",
16
+ "types": "./types/index.d.ts",
17
+ "exports": {
18
+ "./package.json": "./package.json",
19
+ ".": {
20
+ "types": "./types/index.d.ts",
21
+ "react-native": "./dist/esm/index.native.js",
22
+ "browser": "./dist/esm/index.mjs",
23
+ "module": "./dist/esm/index.mjs",
24
+ "import": "./dist/esm/index.mjs",
25
+ "require": "./dist/cjs/index.cjs",
26
+ "default": "./dist/esm/index.mjs"
27
+ }
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "scripts": {
33
+ "build": "hanzogui-build",
34
+ "watch": "hanzogui-build --watch",
35
+ "clean": "hanzogui-build clean",
36
+ "clean:build": "hanzogui-build clean:build"
37
+ },
38
+ "dependencies": {
39
+ "@hanzogui/constants": "2.0.0-rc.41-hanzoai.1",
40
+ "@hanzogui/core": "2.0.0-rc.41-hanzoai.1",
41
+ "@hanzogui/web": "2.0.0-rc.41-hanzoai.1"
42
+ },
43
+ "devDependencies": {
44
+ "@hanzogui/build": "2.0.0-rc.41-hanzoai.1",
45
+ "react": ">=19",
46
+ "react-native": "0.83.2"
47
+ },
48
+ "peerDependencies": {
49
+ "react": ">=19",
50
+ "react-native": "*"
51
+ },
52
+ "module:jsx": "dist/jsx"
53
+ }
@@ -0,0 +1,6 @@
1
+ import { Image as RNImage } from 'react-native'
2
+ import { createImage } from './createImage'
3
+
4
+ export const Image = createImage({
5
+ Component: RNImage,
6
+ })
package/src/Image.tsx ADDED
@@ -0,0 +1,41 @@
1
+ import { View, styled } from '@hanzogui/web'
2
+ import type { ImageProps, ImageType } from './types'
3
+
4
+ const StyledImage = styled(View, {
5
+ name: 'Image',
6
+ render: 'img',
7
+ })
8
+
9
+ export const Image = StyledImage.styleable<ImageProps>(
10
+ (inProps, ref) => {
11
+ const {
12
+ // exclude native only props
13
+ blurRadius,
14
+ capInsets,
15
+ defaultSource,
16
+ fadeDuration,
17
+ loadingIndicatorSource,
18
+ onLoadEnd,
19
+ onPartialLoad,
20
+ progressiveRenderingEnabled,
21
+ resizeMethod,
22
+ tintColor,
23
+ ...rest
24
+ } = inProps
25
+ return <StyledImage ref={ref} {...rest} />
26
+ },
27
+ {
28
+ staticConfig: {
29
+ memo: true,
30
+ },
31
+ }
32
+ ) as unknown as ImageType
33
+
34
+ const func = (() => {}) as any
35
+
36
+ Image.getSize = func
37
+ Image.getSizeWithHeaders = func
38
+ Image.prefetch = func
39
+ Image.prefetchWithMetadata = func
40
+ Image.abortPrefetch = func
41
+ Image.queryCache = func
@@ -0,0 +1,245 @@
1
+ import { getTokenValue, styled } from '@hanzogui/web'
2
+ import type { ComponentType } from 'react'
3
+ import type { ImageResizeMode } from 'react-native'
4
+ import type { ImageProps, ImageType } from './types'
5
+
6
+ type GetProps<T> = T extends ComponentType<infer P> ? P : never
7
+
8
+ export type CreateImageOptions<C extends ComponentType<any>> = {
9
+ /**
10
+ * The underlying image component to use.
11
+ * Can be React Native Image, expo-image, react-native-fast-image, or any compatible component.
12
+ */
13
+ Component: C
14
+ /**
15
+ * Map objectFit CSS values to the component's resize mode prop.
16
+ * Default maps to React Native's resizeMode.
17
+ */
18
+ mapObjectFitToResizeMode?: (objectFit: string) => string
19
+ /**
20
+ * The prop name used for resize mode.
21
+ * Default: 'resizeMode' (React Native)
22
+ * expo-image uses: 'contentFit'
23
+ */
24
+ resizeModePropName?: string
25
+ /**
26
+ * The prop name used for object position.
27
+ * Default: undefined (React Native doesn't support it)
28
+ * expo-image uses: 'contentPosition'
29
+ */
30
+ objectPositionPropName?: string
31
+ /**
32
+ * Custom source transformation.
33
+ * Useful for expo-image which has a different source format.
34
+ */
35
+ transformSource?: (props: {
36
+ src?: string | number
37
+ source?: any
38
+ width?: any
39
+ height?: any
40
+ }) => any
41
+ }
42
+
43
+ const defaultObjectFitMap = (objectFit: string): ImageResizeMode => {
44
+ switch (objectFit) {
45
+ case 'fill':
46
+ return 'stretch'
47
+ case 'none':
48
+ return 'center'
49
+ case 'scale-down':
50
+ return 'contain'
51
+ case 'contain':
52
+ return 'contain'
53
+ default:
54
+ return 'cover'
55
+ }
56
+ }
57
+
58
+ const defaultTransformSource = (props: {
59
+ src?: string | number
60
+ source?: any
61
+ width?: any
62
+ height?: any
63
+ }) => {
64
+ const { src, source, width, height } = props
65
+ if (source) return source
66
+ if (src && typeof src !== 'string') return src
67
+ return {
68
+ uri: src,
69
+ width,
70
+ height,
71
+ }
72
+ }
73
+
74
+ /**
75
+ * Create a custom Image component with a pluggable underlying implementation.
76
+ *
77
+ * @example
78
+ * Using with expo-image
79
+ * import { Image as ExpoImage } from 'expo-image'
80
+ * import { createImage } from '@hanzogui/image'
81
+ *
82
+ * export const Image = createImage({
83
+ * Component: ExpoImage,
84
+ * resizeModePropName: 'contentFit',
85
+ * objectPositionPropName: 'contentPosition',
86
+ * })
87
+ *
88
+ * Now you get all expo-image props (transition, placeholder, etc.)
89
+ * plus Hanzogui's unified API (src, objectFit, objectPosition)
90
+ * <Image
91
+ * src="https://example.com/photo.jpg"
92
+ * objectFit="cover"
93
+ * transition={300}
94
+ * placeholder={blurhash}
95
+ * />
96
+ */
97
+ export function createImage<C extends ComponentType<any>>(
98
+ options: CreateImageOptions<C>
99
+ ) {
100
+ const {
101
+ Component,
102
+ mapObjectFitToResizeMode = defaultObjectFitMap,
103
+ resizeModePropName = 'resizeMode',
104
+ objectPositionPropName,
105
+ transformSource = defaultTransformSource,
106
+ } = options
107
+
108
+ // Props that should pass directly to the underlying component without Hanzogui processing
109
+ const inlinePropsSet = new Set([
110
+ 'source',
111
+ 'placeholder',
112
+ 'transition',
113
+ 'contentFit',
114
+ 'contentPosition',
115
+ 'cachePolicy',
116
+ 'recyclingKey',
117
+ 'allowDownscaling',
118
+ 'autoplay',
119
+ 'blurRadius',
120
+ 'priority',
121
+ 'placeholderContentFit',
122
+ 'responsivePolicy',
123
+ 'onLoadStart',
124
+ 'onProgress',
125
+ 'onLoadEnd',
126
+ ])
127
+
128
+ const StyledImage = styled(
129
+ Component as ComponentType<any>,
130
+ {
131
+ name: 'Image',
132
+ },
133
+ {
134
+ inlineProps: inlinePropsSet,
135
+ }
136
+ )
137
+
138
+ // Combined props: ImageProps (Hanzogui) + Component's native props
139
+ type CombinedProps = ImageProps & Omit<GetProps<C>, keyof ImageProps>
140
+
141
+ const ImageComponent = StyledImage.styleable<CombinedProps>((incomingProps, ref) => {
142
+ const props = incomingProps as any
143
+ const {
144
+ src,
145
+ width,
146
+ height,
147
+ borderRadius,
148
+ objectFit,
149
+ objectPosition,
150
+ // web only props - filter out on native
151
+ decoding,
152
+ elementTiming,
153
+ fetchpriority,
154
+ isMap,
155
+ loading,
156
+ sizes,
157
+ useMap,
158
+ onLoad,
159
+ onError,
160
+ ...rest
161
+ } = props
162
+
163
+ const resolvedWidth =
164
+ typeof width === 'string' && width[0] === '$'
165
+ ? getTokenValue(width as any, 'size')
166
+ : width
167
+ const resolvedHeight =
168
+ typeof height === 'string' && height[0] === '$'
169
+ ? getTokenValue(height as any, 'size')
170
+ : height
171
+
172
+ const finalSource = transformSource({
173
+ src,
174
+ width: resolvedWidth,
175
+ height: resolvedHeight,
176
+ })
177
+
178
+ const incomingStyle = Array.isArray(rest.style)
179
+ ? Object.assign({}, ...rest.style.flat())
180
+ : rest.style
181
+
182
+ const resolvedBorderRadius =
183
+ typeof borderRadius === 'string' && borderRadius[0] === '$'
184
+ ? getTokenValue(borderRadius as any, 'radius')
185
+ : borderRadius
186
+
187
+ const finalProps: any = {
188
+ ...rest,
189
+ source: finalSource,
190
+ style: {
191
+ ...incomingStyle,
192
+ ...(resolvedBorderRadius !== undefined && { borderRadius: resolvedBorderRadius }),
193
+ ...(resolvedWidth !== undefined && { width: resolvedWidth }),
194
+ ...(resolvedHeight !== undefined && { height: resolvedHeight }),
195
+ },
196
+ }
197
+
198
+ // Set resize mode / content fit
199
+ if (objectFit) {
200
+ finalProps[resizeModePropName] = mapObjectFitToResizeMode(objectFit)
201
+ }
202
+
203
+ // Add object position if supported
204
+ if (objectPositionPropName && objectPosition) {
205
+ finalProps[objectPositionPropName] = objectPosition
206
+ }
207
+
208
+ // Normalize onLoad event
209
+ if (onLoad) {
210
+ finalProps.onLoad = (e: any) => {
211
+ const source = e?.nativeEvent?.source || e?.source || {}
212
+ onLoad({
213
+ target: {
214
+ naturalHeight: source?.height,
215
+ naturalWidth: source?.width,
216
+ },
217
+ type: 'load',
218
+ } as any)
219
+ }
220
+ }
221
+
222
+ // Normalize onError event
223
+ if (onError) {
224
+ finalProps.onError = () => {
225
+ onError({
226
+ type: 'error',
227
+ } as any)
228
+ }
229
+ }
230
+
231
+ // Render the underlying Component directly to ensure all props pass through
232
+ return <Component ref={ref} {...finalProps} />
233
+ }) as unknown as ImageType & React.FC<CombinedProps>
234
+
235
+ // Add static methods if the component has them
236
+ const comp = Component as any
237
+ ImageComponent.getSize = comp.getSize || (() => {})
238
+ ImageComponent.getSizeWithHeaders = comp.getSizeWithHeaders || (() => {})
239
+ ImageComponent.prefetch = comp.prefetch || (() => {})
240
+ ImageComponent.prefetchWithMetadata = comp.prefetchWithMetadata || (() => {})
241
+ ImageComponent.abortPrefetch = comp.abortPrefetch || (() => {})
242
+ ImageComponent.queryCache = comp.queryCache || (() => {})
243
+
244
+ return ImageComponent
245
+ }
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './Image'
2
+ export * from './createImage'
3
+ export type { ImageProps, ImageType } from './types'
package/src/types.ts ADDED
@@ -0,0 +1,54 @@
1
+ import type { ViewProps } from '@hanzogui/web'
2
+ import type {
3
+ ImageResizeMode,
4
+ ImageSourcePropType,
5
+ Image as RNImage,
6
+ ImageProps as RNImageProps,
7
+ } from 'react-native'
8
+
9
+ type RNImageType = typeof RNImage
10
+
11
+ type KeyofViewProps = keyof ViewProps
12
+
13
+ export type ImageProps = ViewProps &
14
+ Omit<RNImageProps, KeyofViewProps | 'source' | 'resizeMode' | 'style'> & {
15
+ /**
16
+ * The image source URL or require() result.
17
+ * Preferred over `source` for better web alignment.
18
+ */
19
+ src?: string | number
20
+ /**
21
+ * @deprecated
22
+ * use src instead
23
+ */
24
+ source?: ImageSourcePropType
25
+ /**
26
+ * @deprecated
27
+ * use objectFit instead
28
+ */
29
+ resizeMode?: ImageResizeMode
30
+ /**
31
+ * How the image should be resized to fit its container.
32
+ * Maps to CSS object-fit on web and resizeMode on native.
33
+ */
34
+ objectFit?: React.CSSProperties['objectFit']
35
+ /**
36
+ * How the image should be positioned within its container.
37
+ * Maps to CSS object-position on web.
38
+ * On native, requires expo-image or similar for full support.
39
+ */
40
+ objectPosition?: React.CSSProperties['objectPosition']
41
+ } & Omit<
42
+ React.ImgHTMLAttributes<HTMLImageElement>,
43
+ 'width' | 'height' | KeyofViewProps | 'src'
44
+ > &
45
+ Omit<React.ImgHTMLAttributes<HTMLImageElement>, 'width' | 'height' | 'style' | 'src'>
46
+
47
+ export type ImageType = React.FC<Partial<ImageProps>> & {
48
+ getSize: RNImageType['getSize']
49
+ getSizeWithHeaders: RNImageType['getSizeWithHeaders']
50
+ prefetch: RNImageType['prefetch']
51
+ prefetchWithMetadata: RNImageType['prefetchWithMetadata']
52
+ abortPrefetch: RNImageType['abortPrefetch']
53
+ queryCache: RNImageType['queryCache']
54
+ }