@alexgorbatchev/shadcn 0.0.70 → 0.0.72

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 (30) hide show
  1. package/README.md +57 -2
  2. package/dist/components/image-viewer/ImageComparison.d.ts +41 -0
  3. package/dist/components/image-viewer/ImageComparisonToolbar.d.ts +22 -0
  4. package/dist/components/image-viewer/ImageDifferenceOverlay.d.ts +8 -0
  5. package/dist/components/image-viewer/ImageSwipeDivider.d.ts +15 -0
  6. package/dist/components/image-viewer/ImageViewer.d.ts +34 -0
  7. package/dist/components/image-viewer/ImageViewport.d.ts +23 -0
  8. package/dist/components/image-viewer/ImageZoomToggle.d.ts +19 -0
  9. package/dist/components/image-viewer/computeImageDiff.d.ts +11 -0
  10. package/dist/components/image-viewer/getContainedRect.d.ts +3 -0
  11. package/dist/components/image-viewer/getImageStageSize.d.ts +6 -0
  12. package/dist/components/image-viewer/getNormalizedImagePoint.d.ts +7 -0
  13. package/dist/components/image-viewer/hooks/useElementSize.d.ts +4 -0
  14. package/dist/components/image-viewer/hooks/useImageDifferences.d.ts +20 -0
  15. package/dist/components/image-viewer/hooks/useImageLoad.d.ts +9 -0
  16. package/dist/components/image-viewer/index.d.ts +9 -0
  17. package/dist/components/image-viewer/index.js +1114 -0
  18. package/dist/components/image-viewer/measureImageDifferences.d.ts +19 -0
  19. package/dist/components/image-viewer/types.d.ts +84 -0
  20. package/dist/components/tree/TreeItem.d.ts +4 -1
  21. package/dist/components/tree/index.js +3 -1
  22. package/dist/index.js +23 -23
  23. package/dist/prototype.js +5 -1
  24. package/llms/components/data-display/ImageComparison.md +153 -0
  25. package/llms/components/data-display/ImageViewer.md +117 -0
  26. package/llms/components/data-display/ImageZoomToggle.md +82 -0
  27. package/llms/components/navigation/Tree.md +8 -0
  28. package/llms/setup.md +57 -2
  29. package/llms.txt +3 -0
  30. package/package.json +5 -1
package/README.md CHANGED
@@ -71,6 +71,7 @@ Import shared controls and providers from `@alexgorbatchev/shadcn`. Import the f
71
71
  | `/file-upload` | FileUpload selection and validation | `bun add react-dropzone@^20.1.4` |
72
72
  | `/color-picker` | ColorPicker | `bun add react-colorful@^5.8.1` |
73
73
  | `/image-crop` | ImageCrop and native export helpers | `bun add react-image-crop@^11.1.2` |
74
+ | `/image-viewer` | ImageViewer, ImageZoomToggle, ImageComparison, and image helpers | Existing core peers |
74
75
  | `/tree` | Tree, native hooks and features | `bun add @headless-tree/core@^1.8.0 @headless-tree/react@^1.8.0`; patched runtimes are bundled |
75
76
  | `/editor` | RichTextEditor, native Tiptap hooks and StarterKit | `bun add @tiptap/core@^3.32.0 @tiptap/react@^3.32.0 @tiptap/pm@^3.32.0 @tiptap/starter-kit@^3.32.0` |
76
77
  | `/event-calendar` | EventCalendar, EventForm and native calendar APIs | `bun add date-fns@^4.4.0`; TypeScript: `bun add -d @types/react-big-calendar@^1.16.3` |
@@ -269,7 +270,7 @@ The npm package includes the same index at `llms.txt` in its root and its linked
269
270
  | Forms and selections | AuthForm, Calendar, Checkbox, Combobox, Command, EmailCodeAuthForm, Field, Input, InputGroup, InputOTP, Label, OptionSelect, Questionnaire, RadioGroup, Select, Slider, Switch, Textarea |
270
271
  | Structure and navigation | Accordion, AspectRatio, Avatar, Breadcrumb, Card, Carousel, Chart, Collapsible, Empty, Item, Kbd, Menubar, NavigationMenu, Pagination, Resizable, ScrollArea, Separator, Sidebar, Table, Tabs |
271
272
  | Layout and typography | AppShell, Container, Grid, GridItem, Heading, PageHeader, PageIntro, Stack, Text |
272
- | Data display | WeatherForecast, WeatherSummary |
273
+ | Data display | ImageComparison, ImageViewer, WeatherForecast, WeatherSummary |
273
274
  | Overlays | AlertDialog, ContextMenu, Dialog, Drawer, DropdownMenu, HoverCard, Popover, Sheet, Tooltip |
274
275
  | Loading | Progress, Skeleton, Spinner |
275
276
  | Conversations | Attachment, Bubble, Marker, Message, MessageScroller |
@@ -451,7 +452,7 @@ Keep preferred widths separate from the table's rendered sizing atom. In `onFitW
451
452
 
452
453
  For nested layouts, compose `ActionsMenuTrigger`, `ActionsMenuContextTarget`, and `ActionsMenuContextContent` explicitly inside `ActionsMenu`. The dropdown trigger owns its local native dropdown root and popup; the context target and content share an independent context root. A tree row can use `TreeItem render={<ActionsMenuContextTarget />}` and put the trigger in its action slot. For a table row, render the context target as the actual `tr`, then place the dropdown trigger and context content inside a `td`: native popup portals insert focus guards at their declaration, which must remain valid table children.
453
454
 
454
- `TreeItem linkProps` places the registered tree item, roving focus, and native drag handlers on an anchor. Pass `href` and anchor events directly, or compose a router link through `linkProps.render`. The outer `render` and `ref` remain available for row overlays; disclosure and `endEnhancer` controls remain siblings of the link. Enter and modified clicks retain native link behavior, while tree arrows retain navigation and expansion behavior. Optional `dropHint={{ content, open, side }}` displays caller-controlled drag feedback without adding a focus target.
455
+ `TreeItem linkProps` places the registered tree item, roving focus, and native drag handlers on an anchor. Pass `href` and anchor events directly, or compose a router link through `linkProps.render`. The outer `render` and `ref` remain available for row overlays; disclosure and `endEnhancer` controls remain siblings of the link. Enter and modified clicks retain native link behavior, while tree arrows retain navigation and expansion behavior. Optional `dropHint={{ content, open, side }}` displays caller-controlled drag feedback without adding a focus target. `isDimmed` fades a settled row, such as completed work, to 70% opacity and exposes `data-dimmed`; hovering or focusing anything in the row restores full opacity, and the row stays interactive.
455
456
 
456
457
  Embedded actions, links, menus, editable fields, and media controls retain their own keyboard behavior. Registered anchor and button rows still participate in tree navigation; rename and search inputs retain their completion and cancellation shortcuts.
457
458
 
@@ -477,6 +478,60 @@ Embedded actions, links, menus, editable fields, and media controls retain their
477
478
 
478
479
  `TableHead` and `TableCell` accept `textAlign="start"`, `"center"`, or `"end"` to align labels and numeric columns consistently in either text direction.
479
480
 
481
+ # Image viewing and comparison
482
+
483
+ Import `ImageViewer`, `ImageZoomToggle`, and `ImageComparison` from `@alexgorbatchev/shadcn/image-viewer`. Both viewers fill the container they are given, such as a `DialogContent size="fullscreen"` body, and use only the core peers.
484
+
485
+ ```tsx
486
+ import { useState } from "react";
487
+ import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@alexgorbatchev/shadcn";
488
+ import {
489
+ ImageViewer,
490
+ ImageZoomToggle,
491
+ getNormalizedImagePoint,
492
+ type INormalizedImagePoint,
493
+ type ImageZoom,
494
+ } from "@alexgorbatchev/shadcn/image-viewer";
495
+
496
+ function Screenshot({ src, onPick }: { src: string; onPick: (point: INormalizedImagePoint) => void }) {
497
+ const [zoom, setZoom] = useState<ImageZoom>("fit");
498
+ return (
499
+ <Dialog defaultOpen>
500
+ <DialogContent size="fullscreen">
501
+ <DialogHeader>
502
+ <DialogTitle>Checkout page</DialogTitle>
503
+ <ImageZoomToggle zoom={zoom} onZoomChange={setZoom} />
504
+ </DialogHeader>
505
+ <ImageViewer
506
+ src={src}
507
+ alt="Checkout page"
508
+ zoom={zoom}
509
+ onZoomChange={setZoom}
510
+ overlay={
511
+ <div
512
+ className="absolute inset-0 cursor-crosshair"
513
+ onPointerDown={(event) =>
514
+ onPick(getNormalizedImagePoint(event, event.currentTarget.getBoundingClientRect()))
515
+ }
516
+ />
517
+ }
518
+ />
519
+ </DialogContent>
520
+ </Dialog>
521
+ );
522
+ }
523
+ ```
524
+
525
+ `ImageViewer` zoom is `"fit"` or `"original"`, controlled with `zoom` and `onZoomChange` or uncontrolled with `defaultZoom` (default `"fit"`). Fit scales the image down proportionally to fit both viewport dimensions, centered and without scrollbars, and never upscales it. Original shows the natural size in CSS pixels, centered on any axis where it is smaller than the viewport and scrolling on any axis where it is larger; switching zoom keeps the viewed center. The viewport is a focusable native scroll region named by `label` (default `alt`) for keyboard scrolling. Place `ImageZoomToggle` in a header or toolbar, or set `showZoomControl` for a built-in toggle above the image; its "Fit to screen" and "Original size" options report their state with `aria-pressed`.
526
+
527
+ `overlay` renders inside a box sized and positioned exactly over the rendered image at every zoom level, so children positioned in percentages stay aligned with the image. `imageRef` and `overlayRef` expose the rendered image box; `getNormalizedImagePoint(point, box)` maps viewport coordinates, such as a pointer event, to 0–1 image coordinates within that box and clamps points outside it. Multiply by the image's `naturalWidth` and `naturalHeight` for pixel coordinates. A failed load shows "Image could not be loaded." and sets `data-status="error"` on the viewer root.
528
+
529
+ `ImageComparison` compares `before` and `after` sources (`{ src, alt, crossOrigin? }`) labelled by `beforeLabel` and `afterLabel` (default "Before" and "After"). `mode` is `"toggle"` (default), `"swipe"`, or `"side-by-side"`; `orientation` is `"horizontal"` (panes left and right, default) or `"vertical"` (top and bottom); `zoom` is shared by every mode; `showDifferences` defaults to false. Each is controlled with its value and `on*Change` callback or uncontrolled with its `default*` prop. Toggle shows the after image while "Hold to show before" shows the before image as long as a pointer, Space, or Enter is held, returning on release, pointer leave, cancel, or blur. Swipe stacks both images behind a divider that is a native slider (0–100; arrows ±1, Page Up/Page Down ±10, Home/End) whose handle drags with pointer capture; the rest of the image keeps native panning. Side-by-side panes scroll in sync at original size. When the image sizes differ, the before image is drawn inside the after image box with `contain` scaling, and the toolbar reports both sizes.
530
+
531
+ "Highlight differences" draws both images at the after image's natural size and compares premultiplied channels against a threshold. Changed pixels are aggregated into 16px cells and connected regions, outlined with the warning token over the after image (toggle and swipe) or both panes (side-by-side), and summarized as "3 changed regions" or "No visible differences". The comparison runs in time-boxed slices that yield to the browser and is cached per image pair for the component's lifetime. When pixels cannot be read, such as a cross-origin image served without CORS or an image that failed to decode, the switch is disabled and the reason is shown. Pass `crossOrigin: "anonymous"` only when the image server sends CORS headers. `computeImageDiff(before, after, options)` exposes the same pure comparison for equally sized `ImageData`.
532
+
533
+ The toolbar holds the mode, orientation (enabled for side-by-side), zoom, hold-to-show-before (enabled for toggle), and highlight controls with the legend and status. It sits beside a comparison at least 48rem wide and wraps below narrower ones; `showToolbar={false}` hides it, leaving consumers to control the props themselves.
534
+
480
535
  # Drag and drop
481
536
 
482
537
  Wrap draggable sources and drop targets in `DragDropProvider`. `DragSource` and `DropTarget` accept Base UI's `render` composition, so a button, table row, or sidebar item keeps its native element. For compositions that already manage rendering, use `useDragSource` and `useDropTarget` and spread their `props` onto the existing element.
@@ -0,0 +1,41 @@
1
+ import { type ReactElement } from "react";
2
+ import type { IDensityProps } from "../../density/types.js";
3
+ import type { IImageComparisonSource, ImageComparisonMode, ImageComparisonOrientation, ImageZoom } from "./types.js";
4
+ export interface IImageComparisonProps extends IDensityProps {
5
+ before: IImageComparisonSource;
6
+ after: IImageComparisonSource;
7
+ /** Defaults to "Before". */
8
+ beforeLabel?: string;
9
+ /** Defaults to "After". */
10
+ afterLabel?: string;
11
+ /** Controlled presentation mode. */
12
+ mode?: ImageComparisonMode;
13
+ /** Initial mode when uncontrolled. Defaults to `toggle`. */
14
+ defaultMode?: ImageComparisonMode;
15
+ onModeChange?: (mode: ImageComparisonMode) => void;
16
+ /** Controlled side-by-side arrangement. */
17
+ orientation?: ImageComparisonOrientation;
18
+ /** Initial side-by-side arrangement when uncontrolled. Defaults to `horizontal` (left and right). */
19
+ defaultOrientation?: ImageComparisonOrientation;
20
+ onOrientationChange?: (orientation: ImageComparisonOrientation) => void;
21
+ /** Controlled zoom shared by every mode. */
22
+ zoom?: ImageZoom;
23
+ /** Initial zoom when uncontrolled. Defaults to `fit`. */
24
+ defaultZoom?: ImageZoom;
25
+ onZoomChange?: (zoom: ImageZoom) => void;
26
+ /** Controlled difference highlighting. */
27
+ showDifferences?: boolean;
28
+ /** Initial difference highlighting when uncontrolled. Defaults to false. */
29
+ defaultShowDifferences?: boolean;
30
+ onShowDifferencesChange?: (showDifferences: boolean) => void;
31
+ /** Shows the comparison controls. Defaults to true. */
32
+ showToolbar?: boolean;
33
+ /** Accessible name of the comparison. Defaults to "Image comparison". */
34
+ label?: string;
35
+ }
36
+ /**
37
+ * Compares before and after images by toggling, swiping a divider, or showing them side by side. Every mode starts
38
+ * fitted to the available space and offers original size with scrolling. A differently sized before image is drawn
39
+ * inside the after image's box. Highlighting differences compares pixels on first use and caches the result per pair.
40
+ */
41
+ export declare function ImageComparison({ before, after, beforeLabel, afterLabel, mode: modeProp, defaultMode, onModeChange, orientation: orientationProp, defaultOrientation, onOrientationChange, zoom: zoomProp, defaultZoom, onZoomChange, showDifferences: showDifferencesProp, defaultShowDifferences, onShowDifferencesChange, showToolbar, label, density, }: IImageComparisonProps): ReactElement;
@@ -0,0 +1,22 @@
1
+ import { type ReactElement } from "react";
2
+ import type { IDensityProps } from "../../density/types.js";
3
+ import type { IImageSize, ImageComparisonMode, ImageComparisonOrientation, ImageDifferenceState, ImageZoom } from "./types.js";
4
+ interface IImageComparisonToolbarProps extends IDensityProps {
5
+ mode: ImageComparisonMode;
6
+ onModeChange: (mode: ImageComparisonMode) => void;
7
+ orientation: ImageComparisonOrientation;
8
+ onOrientationChange: (orientation: ImageComparisonOrientation) => void;
9
+ zoom: ImageZoom;
10
+ onZoomChange: (zoom: ImageZoom) => void;
11
+ showDifferences: boolean;
12
+ onShowDifferencesChange: (showDifferences: boolean) => void;
13
+ differences: ImageDifferenceState;
14
+ onPeekChange: (isPeeking: boolean) => void;
15
+ beforeLabel: string;
16
+ afterLabel: string;
17
+ beforeSize?: IImageSize;
18
+ afterSize?: IImageSize;
19
+ }
20
+ /** Comparison controls: a side panel when the comparison is wide and a wrapping bar below it when narrow. */
21
+ export declare function ImageComparisonToolbar({ mode, onModeChange, orientation, onOrientationChange, zoom, onZoomChange, showDifferences, onShowDifferencesChange, differences, onPeekChange, beforeLabel, afterLabel, beforeSize, afterSize, density, }: IImageComparisonToolbarProps): ReactElement;
22
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { ReactElement } from "react";
2
+ import type { IImageDiff } from "./types.js";
3
+ interface IImageDifferenceOverlayProps {
4
+ diff: IImageDiff;
5
+ }
6
+ /** Outlines changed regions over the after image box; percentages keep the outlines aligned at every zoom level. */
7
+ export declare function ImageDifferenceOverlay({ diff }: IImageDifferenceOverlayProps): ReactElement;
8
+ export {};
@@ -0,0 +1,15 @@
1
+ import type { ReactElement } from "react";
2
+ interface IImageSwipeDividerProps {
3
+ /** Percentage of the image width showing the before image, from the left edge. */
4
+ value: number;
5
+ onValueChange: (value: number) => void;
6
+ beforeLabel: string;
7
+ afterLabel: string;
8
+ }
9
+ /**
10
+ * Draggable divider between the before (left) and after (right) images. Base UI's slider supplies the native range
11
+ * semantics, keyboard steps and pointer capture; only the handle accepts pointer input so the rest of the image keeps
12
+ * native panning. The layout is physical, so it stays left-to-right in right-to-left documents.
13
+ */
14
+ export declare function ImageSwipeDivider({ value, onValueChange, beforeLabel, afterLabel, }: IImageSwipeDividerProps): ReactElement;
15
+ export {};
@@ -0,0 +1,34 @@
1
+ import { type ReactElement, type ReactNode, type Ref, type SyntheticEvent } from "react";
2
+ import type { IDensityProps } from "../../density/types.js";
3
+ import type { ImageZoom } from "./types.js";
4
+ export interface IImageViewerProps extends IDensityProps {
5
+ src: string;
6
+ alt: string;
7
+ /** CORS mode for the image request. */
8
+ crossOrigin?: "anonymous" | "use-credentials";
9
+ /** Controlled zoom. */
10
+ zoom?: ImageZoom;
11
+ /** Initial zoom when uncontrolled. Defaults to `fit`. */
12
+ defaultZoom?: ImageZoom;
13
+ onZoomChange?: (zoom: ImageZoom) => void;
14
+ /** Shows the built-in zoom toggle above the image. Place `ImageZoomToggle` yourself to put it in a header. */
15
+ showZoomControl?: boolean;
16
+ /**
17
+ * Content sized and positioned exactly over the rendered image at every zoom level, such as region selections or
18
+ * markers. Position children in percentages, and normalize pointer positions with `getNormalizedImagePoint`.
19
+ */
20
+ overlay?: ReactNode;
21
+ /** The rendered `<img>`, whose bounding box is the rendered image box. */
22
+ imageRef?: Ref<HTMLImageElement>;
23
+ /** The overlay box, rendered only when `overlay` is provided. */
24
+ overlayRef?: Ref<HTMLDivElement>;
25
+ /** Accessible name of the scroll region. Defaults to `alt`. */
26
+ label?: string;
27
+ onLoad?: (event: SyntheticEvent<HTMLImageElement>) => void;
28
+ onError?: (event: SyntheticEvent<HTMLImageElement>) => void;
29
+ }
30
+ /**
31
+ * Shows one image inside a native scroll viewport that fills its container. `fit` scales the image down to the
32
+ * viewport without scrolling; `original` shows natural size and scrolls where the image is larger than the viewport.
33
+ */
34
+ export declare function ImageViewer({ src, alt, crossOrigin, zoom: zoomProp, defaultZoom, onZoomChange, showZoomControl, overlay, imageRef, overlayRef, label, onLoad, onError, density, }: IImageViewerProps): ReactElement;
@@ -0,0 +1,23 @@
1
+ import { type ReactElement, type ReactNode, type Ref, type RefObject } from "react";
2
+ import type { IImageSize, INormalizedImagePoint, ImageZoom } from "./types.js";
3
+ interface IImageViewportProps {
4
+ /** Accessible name of the scroll region. */
5
+ label: string;
6
+ zoom: ImageZoom;
7
+ /** Natural size of the image box; the stage stays empty until it is known. */
8
+ naturalSize: IImageSize | undefined;
9
+ /** Viewed center shared with sibling viewports; restored after zoom changes and when a viewport mounts. */
10
+ center: RefObject<INormalizedImagePoint>;
11
+ /** Stage content, positioned over the rendered image box. */
12
+ children: ReactNode;
13
+ /** Replaces the stage, for example with a load failure message. */
14
+ fallback?: ReactNode;
15
+ viewportRef?: Ref<HTMLDivElement>;
16
+ onViewportScroll?: (viewport: HTMLDivElement) => void;
17
+ }
18
+ /**
19
+ * Native scroll viewport that centers an image box. Fit zoom never scrolls; original zoom scrolls on any axis where
20
+ * the image is larger than the viewport. Auto margins center a smaller box without clipping a larger one's start edge.
21
+ */
22
+ export declare function ImageViewport({ label, zoom, naturalSize, center, children, fallback, viewportRef, onViewportScroll, }: IImageViewportProps): ReactElement;
23
+ export {};
@@ -0,0 +1,19 @@
1
+ import type { ReactElement } from "react";
2
+ import type { IDensityProps } from "../../density/types.js";
3
+ import type { ImageZoom } from "./types.js";
4
+ export interface IImageZoomToggleProps extends IDensityProps {
5
+ zoom: ImageZoom;
6
+ onZoomChange: (zoom: ImageZoom) => void;
7
+ /** Accessible name of the control group. Defaults to "Zoom". */
8
+ label?: string;
9
+ size?: "sm" | "default" | "lg";
10
+ orientation?: "horizontal" | "vertical";
11
+ /** `fill` stretches the options across the parent width. */
12
+ layout?: "content" | "fill";
13
+ disabled?: boolean;
14
+ }
15
+ /**
16
+ * Zoom selection for ImageViewer and ImageComparison. Each option is a pressed-state toggle with a constant visible
17
+ * name, so assistive technology announces the active zoom without relabelling a single button.
18
+ */
19
+ export declare function ImageZoomToggle({ zoom, onZoomChange, label, size, orientation, layout, disabled, density, }: IImageZoomToggleProps): ReactElement;
@@ -0,0 +1,11 @@
1
+ import type { IImageDiff, IImageDiffAccumulator, IImageDiffOptions, IImagePixels } from "./types.js";
2
+ /**
3
+ * Creates an incremental pixel comparison for images of the given size, so callers can feed rows in slices and yield
4
+ * between them. Every row must be added exactly once before `finish`.
5
+ */
6
+ export declare function createImageDiffAccumulator(width: number, height: number, { threshold, cellSize, minChangedPixels, }?: IImageDiffOptions): IImageDiffAccumulator;
7
+ /**
8
+ * Compares two equally sized RGBA images pixel by pixel. A pixel changes when any premultiplied channel differs by more
9
+ * than the threshold; changed pixels are aggregated into cells, and touching cells (including diagonally) form regions.
10
+ */
11
+ export declare function computeImageDiff(before: IImagePixels, after: IImagePixels, options?: IImageDiffOptions): IImageDiff;
@@ -0,0 +1,3 @@
1
+ import type { IImageRect, IImageSize } from "./types.js";
2
+ /** Centers `source` inside `frame` at the largest scale that keeps it fully visible, like `object-fit: contain`. */
3
+ export declare function getContainedRect(source: IImageSize, frame: IImageSize): IImageRect;
@@ -0,0 +1,6 @@
1
+ import type { IImageSize, IImageStageSize, ImageZoom } from "./types.js";
2
+ /**
3
+ * Sizes the rendered image box. `fit` scales the image proportionally to fit both viewport dimensions without
4
+ * upscaling it past its natural size; `original` keeps the natural size in CSS pixels.
5
+ */
6
+ export declare function getImageStageSize(natural: IImageSize, viewport: IImageSize, zoom: ImageZoom): IImageStageSize;
@@ -0,0 +1,7 @@
1
+ import type { INormalizedImagePoint } from "./types.js";
2
+ /**
3
+ * Maps viewport coordinates, such as a pointer event, to a normalized image position. Pass the bounding box of the
4
+ * ImageViewer overlay or image, which covers the rendered image exactly at every zoom level. Points outside the box
5
+ * clamp to its edges.
6
+ */
7
+ export declare function getNormalizedImagePoint(point: Pick<MouseEvent, "clientX" | "clientY">, box: Pick<DOMRectReadOnly, "left" | "top" | "width" | "height">): INormalizedImagePoint;
@@ -0,0 +1,4 @@
1
+ import { type RefObject } from "react";
2
+ import type { IImageSize } from "../types.js";
3
+ /** Tracks an element's client size, which excludes borders and scrollbars. */
4
+ export declare function useElementSize(ref: RefObject<HTMLElement | null>): IImageSize | undefined;
@@ -0,0 +1,20 @@
1
+ import { type RefObject } from "react";
2
+ import type { ImageDifferenceState } from "../types.js";
3
+ interface IUseImageDifferencesOptions {
4
+ /** Identifies the image pair; results are cached per pair for the component's lifetime. */
5
+ pairKey: string;
6
+ /** Compute differences once this becomes true for a pair. */
7
+ enabled: boolean;
8
+ /** Both images have loaded. */
9
+ loaded: boolean;
10
+ /** Why an image failed to load, which makes its pixels unavailable. */
11
+ loadFailure?: string;
12
+ beforeRef: RefObject<HTMLImageElement | null>;
13
+ afterRef: RefObject<HTMLImageElement | null>;
14
+ }
15
+ /**
16
+ * Probes pixel readability once both images load, then measures differences the first time highlighting is enabled
17
+ * for an image pair. Pending work is cancelled when the pair changes or the component unmounts.
18
+ */
19
+ export declare function useImageDifferences({ pairKey, enabled, loaded, loadFailure, beforeRef, afterRef, }: IUseImageDifferencesOptions): ImageDifferenceState;
20
+ export {};
@@ -0,0 +1,9 @@
1
+ import { type SyntheticEvent } from "react";
2
+ import type { IImageLoadState } from "../types.js";
3
+ interface IImageLoadHandlers {
4
+ onLoad: (event: SyntheticEvent<HTMLImageElement>) => void;
5
+ onError: () => void;
6
+ }
7
+ /** Tracks whether the image at `src` has loaded and its natural size; a new `src` starts loading again. */
8
+ export declare function useImageLoad(src: string): readonly [IImageLoadState, IImageLoadHandlers];
9
+ export {};
@@ -0,0 +1,9 @@
1
+ export { ImageViewer } from "./ImageViewer.js";
2
+ export type { IImageViewerProps } from "./ImageViewer.js";
3
+ export { ImageZoomToggle } from "./ImageZoomToggle.js";
4
+ export type { IImageZoomToggleProps } from "./ImageZoomToggle.js";
5
+ export { ImageComparison } from "./ImageComparison.js";
6
+ export type { IImageComparisonProps } from "./ImageComparison.js";
7
+ export { computeImageDiff } from "./computeImageDiff.js";
8
+ export { getNormalizedImagePoint } from "./getNormalizedImagePoint.js";
9
+ export type { IImageComparisonSource, IImageDiff, IImageDiffOptions, IImageDiffRegion, IImagePixels, IImageRect, IImageSize, INormalizedImagePoint, ImageComparisonMode, ImageComparisonOrientation, ImageZoom, } from "./types.js";