@ichaingo/image 1.1.0
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/README.md +11 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +46 -0
- package/package.json +26 -0
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ImageProps, StaticImageData } from 'next/image';
|
|
3
|
+
interface CustomImageProps extends Omit<ImageProps, 'src' | 'alt' | 'width' | 'height'> {
|
|
4
|
+
src: string | StaticImageData;
|
|
5
|
+
width?: number;
|
|
6
|
+
height?: number;
|
|
7
|
+
errorSrc?: string;
|
|
8
|
+
alt?: string;
|
|
9
|
+
className?: string;
|
|
10
|
+
objectFit?: 'contain' | 'cover' | 'fill' | 'none' | 'scale-down';
|
|
11
|
+
}
|
|
12
|
+
declare const _default: React.NamedExoticComponent<CustomImageProps>;
|
|
13
|
+
export default _default;
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAkC,MAAM,OAAO,CAAC;AACvD,OAAc,EAAe,UAAU,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7E,UAAU,gBAAiB,SAAQ,IAAI,CAAC,UAAU,EAAE,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;IACrF,GAAG,EAAE,MAAM,GAAG,eAAe,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,YAAY,CAAC;CAClE;;AA2ED,wBAAiC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
3
|
+
import { memo as l, useState as p, useMemo as g } from "react";
|
|
4
|
+
import h from "next/image";
|
|
5
|
+
const c = ({ src: t, width: o }) => {
|
|
6
|
+
if (typeof t != "string" || t.includes("default_image_bd46f9a3d8.png") || t.includes("default_f7fac00bf2.png"))
|
|
7
|
+
return t;
|
|
8
|
+
if (t.includes("ichainfo.com") || t.includes("ichaingo.com")) {
|
|
9
|
+
const e = new URL(t.startsWith("//") ? "https:" + t : t);
|
|
10
|
+
return e.searchParams.set("format", "auto"), e.searchParams.set("width", o.toString()), e.toString();
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
}, _ = ({
|
|
14
|
+
src: t = "https://cdn.ichaingo.com/uploads/default_image_bd46f9a3d8.png",
|
|
15
|
+
width: o = 24,
|
|
16
|
+
height: e = 24,
|
|
17
|
+
alt: r,
|
|
18
|
+
objectFit: f = "cover",
|
|
19
|
+
errorSrc: i = "https://cdn.ichaingo.com/uploads/default_f7fac00bf2.png",
|
|
20
|
+
...u
|
|
21
|
+
}) => {
|
|
22
|
+
const [n, d] = p(!1);
|
|
23
|
+
(!t || typeof t == "string" && t.trim() === "") && (t = i);
|
|
24
|
+
const m = () => {
|
|
25
|
+
n || d(!0);
|
|
26
|
+
}, a = g(() => typeof t != "string" ? !1 : t.includes("ichainfo.com") || t.includes("ichaingo.com"), [t]);
|
|
27
|
+
return /* @__PURE__ */ s(
|
|
28
|
+
h,
|
|
29
|
+
{
|
|
30
|
+
src: n ? i : t,
|
|
31
|
+
alt: r || "",
|
|
32
|
+
"data-link": t,
|
|
33
|
+
width: o,
|
|
34
|
+
height: e,
|
|
35
|
+
suppressHydrationWarning: !0,
|
|
36
|
+
style: { objectFit: f },
|
|
37
|
+
onError: m,
|
|
38
|
+
loader: a ? c : void 0,
|
|
39
|
+
unoptimized: !a,
|
|
40
|
+
...u
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
}, x = l(_);
|
|
44
|
+
export {
|
|
45
|
+
x as default
|
|
46
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ichaingo/image",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"!**/*.tsbuildinfo"
|
|
18
|
+
],
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"next": "^15.4.5",
|
|
21
|
+
"react": "^19.1.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"rollup-plugin-preserve-use-client": "^1.0.0"
|
|
25
|
+
}
|
|
26
|
+
}
|