@alexgorbatchev/shadcn 0.0.70 → 0.0.71

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 (27) hide show
  1. package/README.md +56 -1
  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/index.js +23 -23
  21. package/dist/prototype.js +5 -1
  22. package/llms/components/data-display/ImageComparison.md +153 -0
  23. package/llms/components/data-display/ImageViewer.md +117 -0
  24. package/llms/components/data-display/ImageZoomToggle.md +82 -0
  25. package/llms/setup.md +56 -1
  26. package/llms.txt +3 -0
  27. package/package.json +5 -1
@@ -0,0 +1,19 @@
1
+ import type { IImageDiff, IImageDiffOptions } from "./types.js";
2
+ export interface IMeasureImageDifferencesOptions extends IImageDiffOptions {
3
+ signal?: AbortSignal;
4
+ /** Milliseconds of comparison work per task before yielding to the browser. */
5
+ sliceBudget?: number;
6
+ /** Resolves when the browser may handle input and rendering. */
7
+ yieldToMain?: () => Promise<void>;
8
+ now?: () => number;
9
+ }
10
+ /** Explains why image pixels could not be read, or returns undefined for cancellation. */
11
+ export declare function describeImageReadError(error: unknown): string | undefined;
12
+ /** Checks with a one-pixel draw whether the image's pixels are readable, resolving the reason when they are not. */
13
+ export declare function getImageReadFailure(image: HTMLImageElement): Promise<string | undefined>;
14
+ /**
15
+ * Compares two loaded images at the after image's natural size, drawing the before image inside that box with
16
+ * `contain` scaling. Pixel rows are read and compared in slices that yield between tasks, so large screenshots do not
17
+ * block input or rendering.
18
+ */
19
+ export declare function measureImageDifferences(before: HTMLImageElement, after: HTMLImageElement, { signal, sliceBudget, yieldToMain: yieldTask, now, ...options }?: IMeasureImageDifferencesOptions): Promise<IImageDiff>;
@@ -0,0 +1,84 @@
1
+ import type { StackDirection } from "../../layout/types.js";
2
+ /** `fit` scales the image down to the viewport; `original` shows it at its natural size in CSS pixels. */
3
+ export type ImageZoom = "fit" | "original";
4
+ /** How ImageComparison presents the before and after images. */
5
+ export type ImageComparisonMode = "toggle" | "swipe" | "side-by-side";
6
+ /** Side-by-side pane arrangement: `horizontal` places panes left and right, `vertical` top and bottom. */
7
+ export type ImageComparisonOrientation = StackDirection;
8
+ export interface IImageSize {
9
+ width: number;
10
+ height: number;
11
+ }
12
+ export interface IImageRect extends IImageSize {
13
+ x: number;
14
+ y: number;
15
+ }
16
+ /** A position inside an image, from 0 (left or top edge) to 1 (right or bottom edge). */
17
+ export interface INormalizedImagePoint {
18
+ x: number;
19
+ y: number;
20
+ }
21
+ export interface IImageStageSize extends IImageSize {
22
+ /** Rendered CSS pixels per natural image pixel. */
23
+ scale: number;
24
+ }
25
+ export interface IImageComparisonSource {
26
+ src: string;
27
+ alt: string;
28
+ /** CORS mode for the image request. Cross-origin pixels can only be compared when the server allows CORS. */
29
+ crossOrigin?: "anonymous" | "use-credentials";
30
+ }
31
+ /** RGBA pixels in row-major order, such as an `ImageData`. */
32
+ export interface IImagePixels {
33
+ width: number;
34
+ height: number;
35
+ data: ArrayLike<number>;
36
+ }
37
+ export interface IImageDiffOptions {
38
+ /** Largest per-channel difference, from 0 to 255, still treated as unchanged. Defaults to 32. */
39
+ threshold?: number;
40
+ /** Side length in pixels of the square cells that changed pixels are aggregated into. Defaults to 16. */
41
+ cellSize?: number;
42
+ /** Changed pixels a cell needs before it counts as changed, which filters isolated noise. Defaults to 2. */
43
+ minChangedPixels?: number;
44
+ }
45
+ /** A connected group of changed cells, bounded tightly around its changed pixels in image pixel coordinates. */
46
+ export interface IImageDiffRegion extends IImageRect {
47
+ changedPixels: number;
48
+ }
49
+ export interface IImageDiff {
50
+ width: number;
51
+ height: number;
52
+ cellSize: number;
53
+ columns: number;
54
+ rows: number;
55
+ /** One entry per cell in row-major order: 1 when the cell changed, otherwise 0. */
56
+ cells: Uint8Array;
57
+ /** Changed regions ordered from top to bottom, then left to right. */
58
+ regions: IImageDiffRegion[];
59
+ /** Changed pixels inside changed cells. */
60
+ changedPixels: number;
61
+ }
62
+ export interface IImageDiffAccumulator {
63
+ /**
64
+ * Compares `rowCount` image rows starting at row `startY`. Both buffers hold RGBA rows that span the full image
65
+ * width, starting with row `startY`.
66
+ */
67
+ addRows(before: ArrayLike<number>, after: ArrayLike<number>, startY: number, rowCount: number): void;
68
+ finish(): IImageDiff;
69
+ }
70
+ export interface IImageLoadState {
71
+ status: "loading" | "loaded" | "error";
72
+ /** Natural size once the image has loaded. */
73
+ size?: IImageSize;
74
+ }
75
+ /** Pixel comparison progress; `reason` explains why pixels could not be read. */
76
+ export type ImageDifferenceState = {
77
+ status: "idle" | "measuring";
78
+ } | {
79
+ status: "ready";
80
+ diff: IImageDiff;
81
+ } | {
82
+ status: "unavailable";
83
+ reason: string;
84
+ };
package/dist/index.js CHANGED
@@ -172,29 +172,6 @@ import {
172
172
  DashboardLayout2,
173
173
  BillingUsage2
174
174
  } from "./chunk-pr5s27j8.js";
175
- import {
176
- Tabs2,
177
- tabsListVariants2,
178
- TabsList2,
179
- TabsTrigger2,
180
- TabsContent2,
181
- DragDropPreview2,
182
- DragDropProvider2,
183
- useDragDrop2,
184
- useDragSource2,
185
- DragSource2,
186
- useDropTarget2,
187
- DropTarget2,
188
- Kanban2
189
- } from "./chunk-k45r2rz0.js";
190
- import {
191
- Toolbar2,
192
- ToolbarButton2,
193
- ToolbarLink2,
194
- ToolbarInput2,
195
- ToolbarGroup2,
196
- ToolbarSeparator2
197
- } from "./chunk-7srpghny.js";
198
175
  import {
199
176
  Combobox2,
200
177
  ComboboxValue2,
@@ -220,6 +197,29 @@ import {
220
197
  NumberFieldScrubArea2,
221
198
  NumberFieldScrubAreaCursor2
222
199
  } from "./chunk-31wptjv4.js";
200
+ import {
201
+ Tabs2,
202
+ tabsListVariants2,
203
+ TabsList2,
204
+ TabsTrigger2,
205
+ TabsContent2,
206
+ DragDropPreview2,
207
+ DragDropProvider2,
208
+ useDragDrop2,
209
+ useDragSource2,
210
+ DragSource2,
211
+ useDropTarget2,
212
+ DropTarget2,
213
+ Kanban2
214
+ } from "./chunk-k45r2rz0.js";
215
+ import {
216
+ Toolbar2,
217
+ ToolbarButton2,
218
+ ToolbarLink2,
219
+ ToolbarInput2,
220
+ ToolbarGroup2,
221
+ ToolbarSeparator2
222
+ } from "./chunk-7srpghny.js";
223
223
  import {
224
224
  Slider2
225
225
  } from "./chunk-7cq1s2ey.js";
package/dist/prototype.js CHANGED
@@ -2051,7 +2051,7 @@ var program = new Command;
2051
2051
  // package.json
2052
2052
  var package_default = {
2053
2053
  name: "@alexgorbatchev/shadcn",
2054
- version: "0.0.70",
2054
+ version: "0.0.71",
2055
2055
  description: "Sharp, monospace React components with compact and comfortable densities.",
2056
2056
  license: "MIT",
2057
2057
  repository: {
@@ -3063,6 +3063,10 @@ var package_default = {
3063
3063
  types: "./dist/components/image-crop/index.d.ts",
3064
3064
  import: "./dist/components/image-crop/index.js"
3065
3065
  },
3066
+ "./image-viewer": {
3067
+ types: "./dist/components/image-viewer/index.d.ts",
3068
+ import: "./dist/components/image-viewer/index.js"
3069
+ },
3066
3070
  "./editor": {
3067
3071
  types: "./dist/components/editor/index.d.ts",
3068
3072
  import: "./dist/components/editor/index.js"
@@ -0,0 +1,153 @@
1
+ # ImageComparison
2
+
3
+ Import from `@alexgorbatchev/shadcn/image-viewer`. ImageComparison fills its container and compares `before` and `after` images (`{ src, alt, crossOrigin? }`) labelled by `beforeLabel` and `afterLabel` (default "Before" and "After"). `toggle` (the default) shows the after image and the "Hold to show before" button shows the before image while a pointer, Space, or Enter is held. `swipe` stacks both images; the divider is a slider (0–100, arrows ±1, Page Up/Page Down ±10, Home/End) whose handle drags with pointer capture. `side-by-side` shows labelled panes left and right (`horizontal`) or top and bottom (`vertical`) that scroll in sync at original size. Every mode starts fitted and offers original size. A differently sized before image is drawn inside the after image box, and the toolbar reports the mismatch. "Highlight differences" compares pixels on first use, caches the result per image pair, outlines changed regions, and summarizes them; it is disabled with a reason when pixels cannot be read. `mode`, `orientation`, `zoom`, and `showDifferences` are controllable with matching `default*` and `on*Change` props; `showToolbar={false}` hides the controls, which sit beside wide comparisons and below narrow ones.
4
+
5
+ Story: @alexgorbatchev/shadcn/components/data-display/ImageComparison
6
+ Source: src/components/stories/data-display/ImageComparison.stories.tsx
7
+
8
+ [Full source and local helpers](https://github.com/alexgorbatchev/shadcn/blob/main/src/components/stories/data-display/ImageComparison.stories.tsx)
9
+
10
+ ## Public imports
11
+
12
+ ```tsx
13
+ import { ImageComparison, type IImageComparisonProps, type ImageComparisonMode, type ImageComparisonOrientation, type ImageZoom } from "@alexgorbatchev/shadcn/image-viewer";
14
+ import { Button, Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from "@alexgorbatchev/shadcn";
15
+ ```
16
+
17
+ ## Supporting imports
18
+
19
+ ```tsx
20
+ import { useState, type ReactElement } from "react";
21
+ ```
22
+
23
+ ## Default component
24
+
25
+ ```tsx
26
+ ImageComparison
27
+ ```
28
+
29
+ ## Story controls
30
+
31
+ ```tsx
32
+ {
33
+ defaultMode: { control: "inline-radio", options: ["toggle", "swipe", "side-by-side"] },
34
+ defaultOrientation: { control: "inline-radio", options: ["horizontal", "vertical"] },
35
+ defaultZoom: { control: "inline-radio", options: ["fit", "original"] },
36
+ defaultShowDifferences: { control: "boolean" },
37
+ showToolbar: { control: "boolean" },
38
+ density: { control: "select", options: ["compact", "comfortable"] },
39
+ }
40
+ ```
41
+
42
+ ## Default args
43
+
44
+ ```tsx
45
+ {
46
+ before: { src: fixture_beforeScreenshot, alt: BEFORE_ALT },
47
+ after: { src: fixture_afterScreenshot, alt: AFTER_ALT },
48
+ onModeChange: fn(),
49
+ onOrientationChange: fn(),
50
+ onZoomChange: fn(),
51
+ onShowDifferencesChange: fn(),
52
+ }
53
+ ```
54
+
55
+ ## Default render
56
+
57
+ ```tsx
58
+ (args) => (<div className="h-[36rem] w-full border border-border">
59
+ <ImageComparison {...args}/>
60
+ </div>)
61
+ ```
62
+
63
+ ## Examples
64
+
65
+ Storybook CSF excerpts. Default args and render apply unless overridden. Local helpers, fixtures, decorators, and providers may be required; these are reference excerpts, not standalone consumer modules. Interaction tests are omitted.
66
+
67
+ ### Toggle
68
+
69
+ ```tsx
70
+ {}
71
+ ```
72
+
73
+ ### Swipe
74
+
75
+ ```tsx
76
+ {
77
+ args: { defaultMode: "swipe" }
78
+ }
79
+ ```
80
+
81
+ ### SideBySide
82
+
83
+ ```tsx
84
+ {
85
+ args: { defaultMode: "side-by-side" }
86
+ }
87
+ ```
88
+
89
+ ### HighlightDifferences
90
+
91
+ ```tsx
92
+ {}
93
+ ```
94
+
95
+ ### NoDifferences
96
+
97
+ ```tsx
98
+ {
99
+ args: {
100
+ before: { src: fixture_afterScreenshot, alt: BEFORE_ALT },
101
+ defaultShowDifferences: true,
102
+ defaultMode: "swipe",
103
+ }
104
+ }
105
+ ```
106
+
107
+ ### SizeMismatch
108
+
109
+ ```tsx
110
+ {
111
+ args: { before: { src: fixture_widerBeforeScreenshot, alt: BEFORE_ALT }, defaultMode: "side-by-side" }
112
+ }
113
+ ```
114
+
115
+ ### UnreadablePixels
116
+
117
+ ```tsx
118
+ {
119
+ args: { before: { src: fixture_brokenImage, alt: BEFORE_ALT } }
120
+ }
121
+ ```
122
+
123
+ ### ModeChangesKeepViewedCenter
124
+
125
+ ```tsx
126
+ {
127
+ args: { defaultZoom: "original" }
128
+ }
129
+ ```
130
+
131
+ ### Controlled
132
+
133
+ ```tsx
134
+ {
135
+ render: (args) => <ControlledComparison {...args}/>
136
+ }
137
+ ```
138
+
139
+ ### WithoutToolbar
140
+
141
+ ```tsx
142
+ {
143
+ args: { showToolbar: false, defaultMode: "swipe", beforeLabel: "Baseline", afterLabel: "Candidate" }
144
+ }
145
+ ```
146
+
147
+ ### FullscreenDialog
148
+
149
+ ```tsx
150
+ {
151
+ render: (args) => <FullscreenComparison {...args}/>
152
+ }
153
+ ```
@@ -0,0 +1,117 @@
1
+ # ImageViewer
2
+
3
+ Import from `@alexgorbatchev/shadcn/image-viewer`. ImageViewer fills the container it is given, such as a `DialogContent size="fullscreen"` body, and shows one image in a native scroll viewport. `fit` (the default) scales the image down proportionally to fit both dimensions, centered and without scrollbars, and never upscales it; `original` shows natural size in CSS pixels, centered on axes where it is smaller and scrolling where it is larger. Switching zoom keeps the viewed center. Control zoom with `zoom` and `onZoomChange`, or leave it uncontrolled with `defaultZoom`; place `ImageZoomToggle` in a header or toolbar, or set `showZoomControl` for the built-in toggle. `overlay` renders content sized and positioned exactly over the rendered image at every zoom, `imageRef` and `overlayRef` expose the rendered image box, and `getNormalizedImagePoint(event, box)` maps pointer coordinates to 0–1 image coordinates.
4
+
5
+ Story: @alexgorbatchev/shadcn/components/data-display/ImageViewer
6
+ Source: src/components/stories/data-display/ImageViewer.stories.tsx
7
+
8
+ [Full source and local helpers](https://github.com/alexgorbatchev/shadcn/blob/main/src/components/stories/data-display/ImageViewer.stories.tsx)
9
+
10
+ ## Public imports
11
+
12
+ ```tsx
13
+ import { ImageViewer, ImageZoomToggle, getNormalizedImagePoint, type IImageViewerProps, type INormalizedImagePoint, type ImageZoom } from "@alexgorbatchev/shadcn/image-viewer";
14
+ import { Button, Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from "@alexgorbatchev/shadcn";
15
+ ```
16
+
17
+ ## Supporting imports
18
+
19
+ ```tsx
20
+ import { useState, type ReactElement } from "react";
21
+ ```
22
+
23
+ ## Default component
24
+
25
+ ```tsx
26
+ ImageViewer
27
+ ```
28
+
29
+ ## Story controls
30
+
31
+ ```tsx
32
+ {
33
+ defaultZoom: { control: "inline-radio", options: ["fit", "original"] },
34
+ showZoomControl: { control: "boolean" },
35
+ density: { control: "select", options: ["compact", "comfortable"] },
36
+ }
37
+ ```
38
+
39
+ ## Default args
40
+
41
+ ```tsx
42
+ { src: fixture_largeScreenshot, alt: "Dashboard screenshot", onZoomChange: fn() }
43
+ ```
44
+
45
+ ## Default render
46
+
47
+ ```tsx
48
+ (args) => (<div className="h-80 w-full border border-border">
49
+ <ImageViewer {...args}/>
50
+ </div>)
51
+ ```
52
+
53
+ ## Examples
54
+
55
+ Storybook CSF excerpts. Default args and render apply unless overridden. Local helpers, fixtures, decorators, and providers may be required; these are reference excerpts, not standalone consumer modules. Interaction tests are omitted.
56
+
57
+ ### FitToScreen
58
+
59
+ ```tsx
60
+ {}
61
+ ```
62
+
63
+ ### OriginalSize
64
+
65
+ ```tsx
66
+ {
67
+ args: { defaultZoom: "original" }
68
+ }
69
+ ```
70
+
71
+ ### SmallImage
72
+
73
+ ```tsx
74
+ {
75
+ args: { src: fixture_smallScreenshot, alt: "Toolbar screenshot" }
76
+ }
77
+ ```
78
+
79
+ ### BuiltInZoomControl
80
+
81
+ ```tsx
82
+ {
83
+ args: { showZoomControl: true }
84
+ }
85
+ ```
86
+
87
+ ### RestoresViewedCenter
88
+
89
+ ```tsx
90
+ {
91
+ args: { showZoomControl: true, defaultZoom: "original" }
92
+ }
93
+ ```
94
+
95
+ ### OverlayCoordinates
96
+
97
+ ```tsx
98
+ {
99
+ render: (args) => <OverlayExample {...args}/>
100
+ }
101
+ ```
102
+
103
+ ### FullscreenDialog
104
+
105
+ ```tsx
106
+ {
107
+ render: (args) => <FullscreenExample {...args}/>
108
+ }
109
+ ```
110
+
111
+ ### LoadError
112
+
113
+ ```tsx
114
+ {
115
+ args: { src: fixture_brokenImage, alt: "Missing screenshot" }
116
+ }
117
+ ```
@@ -0,0 +1,82 @@
1
+ # ImageZoomToggle
2
+
3
+ Import from `@alexgorbatchev/shadcn/image-viewer`. A two-option toggle for ImageViewer and ImageComparison zoom that consumers place in a header or toolbar. "Fit to screen" and "Original size" are pressed-state toggles with constant names, so assistive technology announces the active zoom through `aria-pressed`. One option always stays pressed. `label` names the group (default "Zoom"); `size`, `orientation`, `layout`, `disabled`, and `density` follow ToggleGroup.
4
+
5
+ Story: @alexgorbatchev/shadcn/components/data-display/ImageZoomToggle
6
+ Source: src/components/stories/data-display/ImageZoomToggle.stories.tsx
7
+
8
+ [Full source and local helpers](https://github.com/alexgorbatchev/shadcn/blob/main/src/components/stories/data-display/ImageZoomToggle.stories.tsx)
9
+
10
+ ## Public imports
11
+
12
+ ```tsx
13
+ import { ImageZoomToggle, type ImageZoom } from "@alexgorbatchev/shadcn/image-viewer";
14
+ ```
15
+
16
+ ## Supporting imports
17
+
18
+ ```tsx
19
+ import { useState } from "react";
20
+ ```
21
+
22
+ ## Default component
23
+
24
+ ```tsx
25
+ ImageZoomToggle
26
+ ```
27
+
28
+ ## Story controls
29
+
30
+ ```tsx
31
+ {
32
+ zoom: { control: "inline-radio", options: ["fit", "original"] },
33
+ size: { control: "select", options: ["sm", "default", "lg"] },
34
+ orientation: { control: "inline-radio", options: ["horizontal", "vertical"] },
35
+ layout: { control: "inline-radio", options: ["content", "fill"] },
36
+ density: { control: "select", options: ["compact", "comfortable"] },
37
+ }
38
+ ```
39
+
40
+ ## Default args
41
+
42
+ ```tsx
43
+ { zoom: "fit", onZoomChange: fn() }
44
+ ```
45
+
46
+ ## Default render
47
+
48
+ ```tsx
49
+ function Render(args) {
50
+ const [zoom, setZoom] = useState<ImageZoom>(args.zoom);
51
+ return (<ImageZoomToggle {...args} zoom={zoom} onZoomChange={(next) => {
52
+ setZoom(next);
53
+ args.onZoomChange(next);
54
+ }}/>);
55
+ }
56
+ ```
57
+
58
+ ## Examples
59
+
60
+ Storybook CSF excerpts. Default args and render apply unless overridden. Local helpers, fixtures, decorators, and providers may be required; these are reference excerpts, not standalone consumer modules. Interaction tests are omitted.
61
+
62
+ ### Default
63
+
64
+ ```tsx
65
+ {}
66
+ ```
67
+
68
+ ### VerticalFill
69
+
70
+ ```tsx
71
+ {
72
+ args: { orientation: "vertical", layout: "fill", label: "Screenshot zoom", zoom: "original" }
73
+ }
74
+ ```
75
+
76
+ ### Disabled
77
+
78
+ ```tsx
79
+ {
80
+ args: { disabled: true }
81
+ }
82
+ ```
package/llms/setup.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 |
@@ -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.
package/llms.txt CHANGED
@@ -340,6 +340,9 @@ Generated from the public package exports and Storybook sources.
340
340
  - [DataGridSelectHeader](./llms/components/data-display/DataGridSelectHeader.md)
341
341
  - [DataViewer](./llms/components/data-display/DataViewer.md)
342
342
  - [Heading](./llms/components/data-display/Heading.md): Heading renders `h1`–`h6` from the required `level` so the document outline stays correct, while `size` (sm, base, lg, xl) sets the visual size independently. Sizes default by level: 1 xl, 2 lg, 3 base, 4–6 sm. `truncate` keeps one line.
343
+ - [ImageComparison](./llms/components/data-display/ImageComparison.md): Import from `@alexgorbatchev/shadcn/image-viewer`. ImageComparison fills its container and compares `before` and `after` images (`{ src, alt, crossOrigin? }`) labelled by `beforeLabel` and `afterLabel` (default "Before" and "After"). `toggle` (the default) shows the after image and the "Hold to show before" button shows the before image while a pointer, Space, or Enter is held. `swipe` stacks both images; the divider is a slider (0–100, arrows ±1, Page Up/Page Down ±10, Home/End) whose handle drags with pointer capture. `side-by-side` shows labelled panes left and right (`horizontal`) or top and bottom (`vertical`) that scroll in sync at original size. Every mode starts fitted and offers original size. A differently sized before image is drawn inside the after image box, and the toolbar reports the mismatch. "Highlight differences" compares pixels on first use, caches the result per image pair, outlines changed regions, and summarizes them; it is disabled with a reason when pixels cannot be read. `mode`, `orientation`, `zoom`, and `showDifferences` are controllable with matching `default*` and `on*Change` props; `showToolbar={false}` hides the controls, which sit beside wide comparisons and below narrow ones.
344
+ - [ImageViewer](./llms/components/data-display/ImageViewer.md): Import from `@alexgorbatchev/shadcn/image-viewer`. ImageViewer fills the container it is given, such as a `DialogContent size="fullscreen"` body, and shows one image in a native scroll viewport. `fit` (the default) scales the image down proportionally to fit both dimensions, centered and without scrollbars, and never upscales it; `original` shows natural size in CSS pixels, centered on axes where it is smaller and scrolling where it is larger. Switching zoom keeps the viewed center. Control zoom with `zoom` and `onZoomChange`, or leave it uncontrolled with `defaultZoom`; place `ImageZoomToggle` in a header or toolbar, or set `showZoomControl` for the built-in toggle. `overlay` renders content sized and positioned exactly over the rendered image at every zoom, `imageRef` and `overlayRef` expose the rendered image box, and `getNormalizedImagePoint(event, box)` maps pointer coordinates to 0–1 image coordinates.
345
+ - [ImageZoomToggle](./llms/components/data-display/ImageZoomToggle.md): Import from `@alexgorbatchev/shadcn/image-viewer`. A two-option toggle for ImageViewer and ImageComparison zoom that consumers place in a header or toolbar. "Fit to screen" and "Original size" are pressed-state toggles with constant names, so assistive technology announces the active zoom through `aria-pressed`. One option always stays pressed. `label` names the group (default "Zoom"); `size`, `orientation`, `layout`, `disabled`, and `density` follow ToggleGroup.
343
346
  - [Item](./llms/components/data-display/Item.md)
344
347
  - [JsonRender](./llms/components/data-display/JsonRender.md)
345
348
  - [JsonViewer](./llms/components/data-display/JsonViewer.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexgorbatchev/shadcn",
3
- "version": "0.0.70",
3
+ "version": "0.0.71",
4
4
  "description": "Sharp, monospace React components with compact and comfortable densities.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1012,6 +1012,10 @@
1012
1012
  "types": "./dist/components/image-crop/index.d.ts",
1013
1013
  "import": "./dist/components/image-crop/index.js"
1014
1014
  },
1015
+ "./image-viewer": {
1016
+ "types": "./dist/components/image-viewer/index.d.ts",
1017
+ "import": "./dist/components/image-viewer/index.js"
1018
+ },
1015
1019
  "./editor": {
1016
1020
  "types": "./dist/components/editor/index.d.ts",
1017
1021
  "import": "./dist/components/editor/index.js"