@lonik/oh-image 2.6.0 → 2.7.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.
@@ -1,6 +1,7 @@
1
- import { s as ImageLoaderOptions } from "./index-DMC2sGIO.js";
2
- import { n as BaseLoaderOptions, t as BaseGlobalLoaderOptions } from "./base-loader-options-DScvwZAJ.js";
3
- import * as react_jsx_runtime5 from "react/jsx-runtime";
1
+ import { n as ImageLoaderOptions } from "./types-BEgZ3W30.js";
2
+ import "./index-C-1t5-gk.js";
3
+ import { n as BaseLoaderOptions, t as BaseGlobalLoaderOptions } from "./base-loader-options-DCLkYppY.js";
4
+ import * as react_jsx_runtime8 from "react/jsx-runtime";
4
5
 
5
6
  //#region src/loaders/contentful/contentful-options.d.ts
6
7
  type ContentfulTransforms = Partial<{
@@ -38,6 +39,6 @@ declare const useContentfulContext: () => ContentfulGlobalOptions, ContentfulLoa
38
39
  ...props
39
40
  }: {
40
41
  children: React.ReactNode;
41
- } & Partial<ContentfulGlobalOptions>) => react_jsx_runtime5.JSX.Element, useContentfulLoader: (options?: ContentfulGlobalOptions | undefined) => (() => undefined) | ((imageOptions: ImageLoaderOptions) => string);
42
+ } & Partial<ContentfulGlobalOptions>) => react_jsx_runtime8.JSX.Element, useContentfulLoader: (options?: ContentfulGlobalOptions | undefined) => (() => undefined) | ((imageOptions: ImageLoaderOptions) => string);
42
43
  //#endregion
43
44
  export { ContentfulGlobalOptions, ContentfulLoaderProvider, ContentfulOptions, ContentfulTransforms, useContentfulContext, useContentfulLoader };
@@ -1,6 +1,7 @@
1
- import { s as ImageLoaderOptions } from "./index-DMC2sGIO.js";
2
- import { n as BaseLoaderOptions, t as BaseGlobalLoaderOptions } from "./base-loader-options-DScvwZAJ.js";
3
- import * as react_jsx_runtime1 from "react/jsx-runtime";
1
+ import { n as ImageLoaderOptions } from "./types-BEgZ3W30.js";
2
+ import "./index-C-1t5-gk.js";
3
+ import { n as BaseLoaderOptions, t as BaseGlobalLoaderOptions } from "./base-loader-options-DCLkYppY.js";
4
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
4
5
 
5
6
  //#region src/loaders/imgproxy/imgproxy-options.d.ts
6
7
  type ResizeType = "fit" | "fill" | "fill-down" | "force" | "auto";
@@ -383,6 +384,6 @@ declare const useImgproxyContext: () => ImgproxyGlobalOptions, ImgproxyLoaderPro
383
384
  ...props
384
385
  }: {
385
386
  children: React.ReactNode;
386
- } & Partial<ImgproxyGlobalOptions>) => react_jsx_runtime1.JSX.Element, useImgproxyLoader: (options?: ImgproxyGlobalOptions | undefined) => (() => undefined) | ((imageOptions: ImageLoaderOptions) => string);
387
+ } & Partial<ImgproxyGlobalOptions>) => react_jsx_runtime0.JSX.Element, useImgproxyLoader: (options?: ImgproxyGlobalOptions | undefined) => (() => undefined) | ((imageOptions: ImageLoaderOptions) => string);
387
388
  //#endregion
388
389
  export { ImgproxyGlobalOptions, ImgproxyLoaderProvider, ImgproxyOptions, ImgproxyTransforms, useImgproxyContext, useImgproxyLoader };
@@ -0,0 +1,52 @@
1
+ import { r as ImageProps, t as ImageLoader } from "./types-BEgZ3W30.js";
2
+ import * as react_jsx_runtime6 from "react/jsx-runtime";
3
+
4
+ //#region src/react/image.d.ts
5
+ declare function Image(props: ImageProps): react_jsx_runtime6.JSX.Element;
6
+ //#endregion
7
+ //#region src/react/image-factory.d.ts
8
+ declare function __imageFactory(defaultProps: any): (props: any) => react_jsx_runtime6.JSX.Element;
9
+ //#endregion
10
+ //#region src/react/use-img-loaded.d.ts
11
+ /**
12
+ * A hook that tracks whether an image element has finished loading.
13
+ *
14
+ * Handles all edge cases:
15
+ * - Image already cached/complete on mount
16
+ * - Normal load via event listener
17
+ * - Errors (resets to `false`)
18
+ * - `src` changes (resets to `false` until the new source loads)
19
+ * - Element unmount / ref set to `null`
20
+ *
21
+ * @returns `[ref, isLoaded]` — attach the ref callback to an `<img>` element.
22
+ *
23
+ * @example
24
+ * ```tsx
25
+ * function Avatar({ src }: { src: string }) {
26
+ * const [imgRef, isLoaded] = useImgLoaded(src);
27
+ * return (
28
+ * <img
29
+ * ref={imgRef}
30
+ * src={src}
31
+ * style={{ opacity: isLoaded ? 1 : 0 }}
32
+ * />
33
+ * );
34
+ * }
35
+ * ```
36
+ */
37
+ declare function useImgLoaded(src: string | undefined): [(img: HTMLImageElement | null) => void, boolean];
38
+ //#endregion
39
+ //#region src/react/image-context.d.ts
40
+ interface ImageContextValue extends Pick<ImageProps, "placeholder" | "breakpoints" | "loader"> {
41
+ breakpoints: number[];
42
+ loader: ImageLoader | null;
43
+ }
44
+ declare function useImageContext(): ImageContextValue;
45
+ declare function ImageProvider({
46
+ children,
47
+ ...props
48
+ }: {
49
+ children: React.ReactNode;
50
+ } & Partial<ImageContextValue>): react_jsx_runtime6.JSX.Element;
51
+ //#endregion
52
+ export { Image as a, __imageFactory as i, useImageContext as n, useImgLoaded as r, ImageProvider as t };
package/dist/kontent.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { s as ImageLoaderOptions } from "./index-DMC2sGIO.js";
2
- import { n as BaseLoaderOptions, t as BaseGlobalLoaderOptions } from "./base-loader-options-DScvwZAJ.js";
3
- import * as react_jsx_runtime0 from "react/jsx-runtime";
1
+ import { n as ImageLoaderOptions } from "./types-BEgZ3W30.js";
2
+ import "./index-C-1t5-gk.js";
3
+ import { n as BaseLoaderOptions, t as BaseGlobalLoaderOptions } from "./base-loader-options-DCLkYppY.js";
4
+ import * as react_jsx_runtime7 from "react/jsx-runtime";
4
5
 
5
6
  //#region src/loaders/kontent/kontent-options.d.ts
6
7
  type KontentTransforms = Partial<{
@@ -43,6 +44,6 @@ declare const useKontentContext: () => KontentGlobalOptions, KontentLoaderProvid
43
44
  ...props
44
45
  }: {
45
46
  children: React.ReactNode;
46
- } & Partial<KontentGlobalOptions>) => react_jsx_runtime0.JSX.Element, useKontentLoader: (options?: KontentGlobalOptions | undefined) => (() => undefined) | ((imageOptions: ImageLoaderOptions) => string);
47
+ } & Partial<KontentGlobalOptions>) => react_jsx_runtime7.JSX.Element, useKontentLoader: (options?: KontentGlobalOptions | undefined) => (() => undefined) | ((imageOptions: ImageLoaderOptions) => string);
47
48
  //#endregion
48
49
  export { KontentGlobalOptions, KontentLoaderProvider, KontentOptions, KontentTransforms, useKontentContext, useKontentLoader };
package/dist/netlify.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { s as ImageLoaderOptions } from "./index-DMC2sGIO.js";
2
- import { n as BaseLoaderOptions, t as BaseGlobalLoaderOptions } from "./base-loader-options-DScvwZAJ.js";
3
- import * as react_jsx_runtime2 from "react/jsx-runtime";
1
+ import { n as ImageLoaderOptions } from "./types-BEgZ3W30.js";
2
+ import "./index-C-1t5-gk.js";
3
+ import { n as BaseLoaderOptions, t as BaseGlobalLoaderOptions } from "./base-loader-options-DCLkYppY.js";
4
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
4
5
 
5
6
  //#region src/loaders/netlify/netlify-options.d.ts
6
7
  type NetlifyTransforms = Partial<{
@@ -20,6 +21,6 @@ declare const useNetlifyContext: () => NetlifyGlobalOptions, NetlifyLoaderProvid
20
21
  ...props
21
22
  }: {
22
23
  children: React.ReactNode;
23
- } & Partial<NetlifyGlobalOptions>) => react_jsx_runtime2.JSX.Element, useNetlifyLoader: (options?: NetlifyGlobalOptions | undefined) => (() => undefined) | ((imageOptions: ImageLoaderOptions) => string);
24
+ } & Partial<NetlifyGlobalOptions>) => react_jsx_runtime0.JSX.Element, useNetlifyLoader: (options?: NetlifyGlobalOptions | undefined) => (() => undefined) | ((imageOptions: ImageLoaderOptions) => string);
24
25
  //#endregion
25
26
  export { NetlifyGlobalOptions, NetlifyLoaderProvider, NetlifyOptions, NetlifyTransforms, useNetlifyContext, useNetlifyLoader };
package/dist/react.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- import { a as Image, c as ImageProps, i as __imageFactory, n as useImageContext, o as ImageLoader, r as useImgLoaded, s as ImageLoaderOptions, t as ImageProvider } from "./index-DMC2sGIO.js";
1
+ import { n as ImageLoaderOptions, r as ImageProps, t as ImageLoader } from "./types-BEgZ3W30.js";
2
+ import { a as Image, i as __imageFactory, n as useImageContext, r as useImgLoaded, t as ImageProvider } from "./index-C-1t5-gk.js";
2
3
  export { Image, ImageLoader, ImageLoaderOptions, ImageProps, ImageProvider, __imageFactory, useImageContext, useImgLoaded };
@@ -0,0 +1,31 @@
1
+ import { ImgHTMLAttributes } from "react";
2
+
3
+ //#region src/react/types.d.ts
4
+ interface ImageLoaderOptions {
5
+ src: string;
6
+ width?: number | null | undefined;
7
+ height?: number | null | undefined;
8
+ isPlaceholder?: boolean;
9
+ }
10
+ type ImageLoader = (options: ImageLoaderOptions) => string | undefined;
11
+ interface ImageProps extends Partial<Pick<ImgHTMLAttributes<HTMLImageElement>, "fetchPriority" | "decoding" | "loading" | "srcSet" | "className" | "sizes" | "style">> {
12
+ /** Alternative text for the image, required for accessibility. Use an empty string for decorative images. */
13
+ alt: string;
14
+ /** Configures the Image component to load the image immediately. */
15
+ priority?: boolean;
16
+ /** */
17
+ src: string;
18
+ /** The URL of the placeholder image to display while loading. */
19
+ placeholder?: string | undefined | boolean | null;
20
+ /**
21
+ * Sets the image to "fill mode", which eliminates the height/width requirement and adds
22
+ * styles such that the image fills its containing element.
23
+ */
24
+ fill?: boolean;
25
+ loader?: ImageLoader | null;
26
+ width?: number | undefined;
27
+ height?: number | undefined;
28
+ breakpoints?: number[];
29
+ }
30
+ //#endregion
31
+ export { ImageLoaderOptions as n, ImageProps as r, ImageLoader as t };
@@ -1,6 +1,7 @@
1
- import { s as ImageLoaderOptions } from "./index-DMC2sGIO.js";
2
- import { n as BaseLoaderOptions, t as BaseGlobalLoaderOptions } from "./base-loader-options-DScvwZAJ.js";
3
- import * as react_jsx_runtime3 from "react/jsx-runtime";
1
+ import { n as ImageLoaderOptions } from "./types-BEgZ3W30.js";
2
+ import "./index-C-1t5-gk.js";
3
+ import { n as BaseLoaderOptions, t as BaseGlobalLoaderOptions } from "./base-loader-options-DCLkYppY.js";
4
+ import * as react_jsx_runtime1 from "react/jsx-runtime";
4
5
 
5
6
  //#region src/loaders/wordpress/wordpress-options.d.ts
6
7
  type WordpressTransforms = Partial<{
@@ -30,6 +31,6 @@ declare const useWordpressContext: () => WordpressGlobalOptions, WordpressLoader
30
31
  ...props
31
32
  }: {
32
33
  children: React.ReactNode;
33
- } & Partial<WordpressGlobalOptions>) => react_jsx_runtime3.JSX.Element, useWordpressLoader: (options?: WordpressGlobalOptions | undefined) => (() => undefined) | ((imageOptions: ImageLoaderOptions) => string);
34
+ } & Partial<WordpressGlobalOptions>) => react_jsx_runtime1.JSX.Element, useWordpressLoader: (options?: WordpressGlobalOptions | undefined) => (() => undefined) | ((imageOptions: ImageLoaderOptions) => string);
34
35
  //#endregion
35
36
  export { WordpressGlobalOptions, WordpressLoaderProvider, WordpressOptions, WordpressTransforms, useWordpressContext, useWordpressLoader };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lonik/oh-image",
3
3
  "type": "module",
4
- "version": "2.6.0",
4
+ "version": "2.7.0",
5
5
  "description": "A React component library for optimized image handling.",
6
6
  "author": "Luka Onikadze <lukonik@gmail.com>",
7
7
  "license": "MIT",
@@ -81,6 +81,7 @@
81
81
  "sharp": ">=0.34.5"
82
82
  },
83
83
  "devDependencies": {
84
+ "@cloudinary/url-gen": "^1.22.0",
84
85
  "@commitlint/config-conventional": "^20.4.1",
85
86
  "@eslint/js": "^9.39.2",
86
87
  "@tailwindcss/vite": "^4.1.18",
@@ -1,80 +0,0 @@
1
- import { ImgHTMLAttributes } from "react";
2
- import * as react_jsx_runtime7 from "react/jsx-runtime";
3
-
4
- //#region src/react/types.d.ts
5
- interface ImageLoaderOptions {
6
- src: string;
7
- width?: number | null | undefined;
8
- height?: number | null | undefined;
9
- isPlaceholder?: boolean;
10
- }
11
- type ImageLoader = (options: ImageLoaderOptions) => string | undefined;
12
- interface ImageProps extends Partial<Pick<ImgHTMLAttributes<HTMLImageElement>, "fetchPriority" | "decoding" | "loading" | "srcSet" | "className" | "sizes" | "style">> {
13
- /** Alternative text for the image, required for accessibility. Use an empty string for decorative images. */
14
- alt: string;
15
- /** Configures the Image component to load the image immediately. */
16
- priority?: boolean;
17
- /** */
18
- src: string;
19
- /** The URL of the placeholder image to display while loading. */
20
- placeholder?: string | undefined | boolean | null;
21
- /**
22
- * Sets the image to "fill mode", which eliminates the height/width requirement and adds
23
- * styles such that the image fills its containing element.
24
- */
25
- fill?: boolean;
26
- loader?: ImageLoader | null;
27
- width?: number | undefined;
28
- height?: number | undefined;
29
- breakpoints?: number[];
30
- }
31
- //#endregion
32
- //#region src/react/image.d.ts
33
- declare function Image(props: ImageProps): react_jsx_runtime7.JSX.Element;
34
- //#endregion
35
- //#region src/react/image-factory.d.ts
36
- declare function __imageFactory(defaultProps: any): (props: any) => react_jsx_runtime7.JSX.Element;
37
- //#endregion
38
- //#region src/react/use-img-loaded.d.ts
39
- /**
40
- * A hook that tracks whether an image element has finished loading.
41
- *
42
- * Handles all edge cases:
43
- * - Image already cached/complete on mount
44
- * - Normal load via event listener
45
- * - Errors (resets to `false`)
46
- * - `src` changes (resets to `false` until the new source loads)
47
- * - Element unmount / ref set to `null`
48
- *
49
- * @returns `[ref, isLoaded]` — attach the ref callback to an `<img>` element.
50
- *
51
- * @example
52
- * ```tsx
53
- * function Avatar({ src }: { src: string }) {
54
- * const [imgRef, isLoaded] = useImgLoaded(src);
55
- * return (
56
- * <img
57
- * ref={imgRef}
58
- * src={src}
59
- * style={{ opacity: isLoaded ? 1 : 0 }}
60
- * />
61
- * );
62
- * }
63
- * ```
64
- */
65
- declare function useImgLoaded(src: string | undefined): [(img: HTMLImageElement | null) => void, boolean];
66
- //#endregion
67
- //#region src/react/image-context.d.ts
68
- interface ImageContextValue extends Pick<ImageProps, "placeholder" | "breakpoints" | "loader"> {
69
- breakpoints: number[];
70
- loader: ImageLoader | null;
71
- }
72
- declare function useImageContext(): ImageContextValue;
73
- declare function ImageProvider({
74
- children,
75
- ...props
76
- }: {
77
- children: React.ReactNode;
78
- } & Partial<ImageContextValue>): react_jsx_runtime7.JSX.Element;
79
- //#endregion
80
- export { Image as a, ImageProps as c, __imageFactory as i, useImageContext as n, ImageLoader as o, useImgLoaded as r, ImageLoaderOptions as s, ImageProvider as t };