@lambdaimg/react 0.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 +28 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/package.json +47 -0
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# @lambdaimg/react
|
|
2
|
+
|
|
3
|
+
A tiny React component for LambdaImg. It renders one plain `<img>` with generated `srcSet` values.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
import { Image } from "@lambdaimg/react";
|
|
7
|
+
|
|
8
|
+
<Image
|
|
9
|
+
baseUrl="https://images.example.com"
|
|
10
|
+
src="products/chair.jpeg"
|
|
11
|
+
width={640}
|
|
12
|
+
height={480}
|
|
13
|
+
alt="Walnut chair"
|
|
14
|
+
/>;
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Use `priority` for above-the-fold images:
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
<Image
|
|
21
|
+
priority
|
|
22
|
+
baseUrl="https://images.example.com"
|
|
23
|
+
src="hero.jpeg"
|
|
24
|
+
width={1440}
|
|
25
|
+
height={810}
|
|
26
|
+
alt="Showroom"
|
|
27
|
+
/>
|
|
28
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ImageWidth } from "@lambdaimg/core";
|
|
2
|
+
import type * as React from "react";
|
|
3
|
+
export interface ImageProps extends Omit<React.ImgHTMLAttributes<HTMLImageElement>, "alt" | "src" | "srcSet" | "sizes" | "loading" | "decoding"> {
|
|
4
|
+
alt: string;
|
|
5
|
+
src: string;
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
widths?: readonly ImageWidth[];
|
|
8
|
+
sizes?: string;
|
|
9
|
+
priority?: boolean;
|
|
10
|
+
loading?: "eager" | "lazy";
|
|
11
|
+
decoding?: "async" | "auto" | "sync";
|
|
12
|
+
}
|
|
13
|
+
export declare function Image({ alt, src, baseUrl, widths, sizes, priority, loading, decoding, ...props }: ImageProps): React.JSX.Element;
|
|
14
|
+
export type { ImageWidth };
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,UAAU,EAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AAEpC,MAAM,WAAW,UAAW,SAAQ,IAAI,CACtC,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,EACzC,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,UAAU,CAC5D;IACC,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;CACtC;AAED,wBAAgB,KAAK,CAAC,EACpB,GAAG,EACH,GAAG,EACH,OAAO,EACP,MAA6B,EAC7B,KAAe,EACf,QAAgB,EAChB,OAAO,EACP,QAAkB,EAClB,GAAG,KAAK,EACT,EAAE,UAAU,qBAgBZ;AAED,YAAY,EAAE,UAAU,EAAE,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ALLOWED_IMAGE_WIDTHS, buildOriginalUrl, buildSrcSet, } from "@lambdaimg/core";
|
|
3
|
+
export function Image({ alt, src, baseUrl, widths = ALLOWED_IMAGE_WIDTHS, sizes = "100vw", priority = false, loading, decoding = "async", ...props }) {
|
|
4
|
+
const resolvedLoading = loading ?? (priority ? "eager" : "lazy");
|
|
5
|
+
const fetchPriority = priority ? "high" : props.fetchPriority;
|
|
6
|
+
return (_jsx("img", { ...props, alt: alt, src: buildOriginalUrl(src, { baseUrl }), srcSet: buildSrcSet(src, { baseUrl, widths }), sizes: sizes, loading: resolvedLoading, decoding: decoding, fetchPriority: fetchPriority }));
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,WAAW,GAEZ,MAAM,iBAAiB,CAAC;AAiBzB,MAAM,UAAU,KAAK,CAAC,EACpB,GAAG,EACH,GAAG,EACH,OAAO,EACP,MAAM,GAAG,oBAAoB,EAC7B,KAAK,GAAG,OAAO,EACf,QAAQ,GAAG,KAAK,EAChB,OAAO,EACP,QAAQ,GAAG,OAAO,EAClB,GAAG,KAAK,EACG;IACX,MAAM,eAAe,GAAG,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IACjE,MAAM,aAAa,GAAG,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC;IAE9D,OAAO,CACL,iBACM,KAAK,EACT,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,gBAAgB,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,CAAC,EACvC,MAAM,EAAE,WAAW,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,EAC7C,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,aAAa,GAC5B,CACH,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lambdaimg/react",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "React image component for LambdaImg.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/jperezrealini/lambdaimg.git",
|
|
9
|
+
"directory": "packages/react"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"type": "module",
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"default": "./dist/index.js",
|
|
20
|
+
"types": "./dist/index.d.ts"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsc -p tsconfig.build.json",
|
|
28
|
+
"check": "oxlint && oxfmt --check && tsc --noEmit -p tsconfig.json",
|
|
29
|
+
"fix": "oxlint --fix && oxfmt",
|
|
30
|
+
"test": "bun test"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@lambdaimg/core": "workspace:*"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/bun": "catalog:",
|
|
37
|
+
"@types/node": "catalog:",
|
|
38
|
+
"@types/react": "^19.2.0",
|
|
39
|
+
"@types/react-dom": "^19.2.0",
|
|
40
|
+
"react": "^19.2.0",
|
|
41
|
+
"react-dom": "^19.2.0",
|
|
42
|
+
"typescript": "^5.9.3"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"react": ">=18.2.0"
|
|
46
|
+
}
|
|
47
|
+
}
|