@alexgorbatchev/shadcn 0.0.105 → 0.0.106

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.
@@ -0,0 +1,110 @@
1
+ import {
2
+ useDensity
3
+ } from "./chunk-e6hk39ev.js";
4
+ import {
5
+ cn2
6
+ } from "./chunk-en44w1pn.js";
7
+ import {
8
+ useAnalyticsCallback
9
+ } from "./chunk-5mydsjp3.js";
10
+
11
+ // src/components/NumberField.tsx
12
+ import { NumberField as NumberFieldPrimitive } from "@base-ui/react/number-field";
13
+ import { MinusIcon, PlusIcon, MoveHorizontalIcon } from "lucide-react";
14
+ import { jsx } from "react/jsx-runtime";
15
+ function NumberField2({
16
+ analytics,
17
+ density,
18
+ className,
19
+ ...props
20
+ }) {
21
+ const trackedOnValueCommitted = useAnalyticsCallback("NumberField", analytics, { name: "ui.commit" }, props.onValueCommitted);
22
+ return /* @__PURE__ */ jsx(NumberFieldPrimitive.Root, {
23
+ "data-density": density,
24
+ "data-slot": "number-field",
25
+ className: (state) => cn2("flex min-w-0 flex-col gap-field-gap", typeof className === "function" ? className(state) : className),
26
+ ...props,
27
+ onValueCommitted: trackedOnValueCommitted
28
+ });
29
+ }
30
+ function NumberFieldGroup2({
31
+ density,
32
+ className,
33
+ ...props
34
+ }) {
35
+ return /* @__PURE__ */ jsx(NumberFieldPrimitive.Group, {
36
+ "data-density": density,
37
+ "data-slot": "number-field-group",
38
+ className: (state) => cn2("flex h-control min-w-0 items-stretch rounded-sm border border-input bg-secondary text-foreground transition-colors focus-within:border-ring focus-within:ring-1 focus-within:ring-ring data-disabled:opacity-50 motion-reduce:transition-none", typeof className === "function" ? className(state) : className),
39
+ ...props
40
+ });
41
+ }
42
+ function NumberFieldInput2({
43
+ density,
44
+ className,
45
+ ...props
46
+ }) {
47
+ return /* @__PURE__ */ jsx(NumberFieldPrimitive.Input, {
48
+ "data-density": density,
49
+ "data-slot": "number-field-input",
50
+ className: (state) => cn2("min-w-0 flex-1 bg-transparent px-control-x text-center text-sm tabular-nums outline-none disabled:cursor-not-allowed", typeof className === "function" ? className(state) : className),
51
+ ...props
52
+ });
53
+ }
54
+ function NumberFieldDecrement2({
55
+ density,
56
+ className,
57
+ children = /* @__PURE__ */ jsx(MinusIcon, {}),
58
+ ...props
59
+ }) {
60
+ return /* @__PURE__ */ jsx(NumberFieldPrimitive.Decrement, {
61
+ "data-density": density,
62
+ "data-slot": "number-field-decrement",
63
+ className: (state) => cn2("flex w-control shrink-0 items-center justify-center rounded-s-sm outline-none hover:bg-muted focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-3.5", typeof className === "function" ? className(state) : className),
64
+ ...props,
65
+ children
66
+ });
67
+ }
68
+ function NumberFieldIncrement2({
69
+ density,
70
+ className,
71
+ children = /* @__PURE__ */ jsx(PlusIcon, {}),
72
+ ...props
73
+ }) {
74
+ return /* @__PURE__ */ jsx(NumberFieldPrimitive.Increment, {
75
+ "data-density": density,
76
+ "data-slot": "number-field-increment",
77
+ className: (state) => cn2("flex w-control shrink-0 items-center justify-center rounded-e-sm outline-none hover:bg-muted focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-3.5", typeof className === "function" ? className(state) : className),
78
+ ...props,
79
+ children
80
+ });
81
+ }
82
+ function NumberFieldScrubArea2({
83
+ density,
84
+ className,
85
+ ...props
86
+ }) {
87
+ return /* @__PURE__ */ jsx(NumberFieldPrimitive.ScrubArea, {
88
+ "data-density": density,
89
+ "data-slot": "number-field-scrub-area",
90
+ className: (state) => cn2("flex w-fit cursor-ew-resize items-center gap-control-gap text-sm font-medium", typeof className === "function" ? className(state) : className),
91
+ ...props
92
+ });
93
+ }
94
+ function NumberFieldScrubAreaCursor2({
95
+ density,
96
+ className,
97
+ children = /* @__PURE__ */ jsx(MoveHorizontalIcon, {}),
98
+ ...props
99
+ }) {
100
+ const resolvedDensity = useDensity(density);
101
+ return /* @__PURE__ */ jsx(NumberFieldPrimitive.ScrubAreaCursor, {
102
+ "data-density": resolvedDensity,
103
+ "data-slot": "number-field-scrub-area-cursor",
104
+ className: (state) => cn2("z-50 font-sans text-sm text-foreground [&_svg]:size-5", typeof className === "function" ? className(state) : className),
105
+ ...props,
106
+ children
107
+ });
108
+ }
109
+
110
+ export { NumberField2, NumberFieldGroup2, NumberFieldInput2, NumberFieldDecrement2, NumberFieldIncrement2, NumberFieldScrubArea2, NumberFieldScrubAreaCursor2 };
@@ -273,103 +273,4 @@ function useComboboxAnchor2() {
273
273
  return useRef(null);
274
274
  }
275
275
 
276
- // src/components/NumberField.tsx
277
- import { NumberField as NumberFieldPrimitive } from "@base-ui/react/number-field";
278
- import { MinusIcon, PlusIcon, MoveHorizontalIcon } from "lucide-react";
279
- import { jsx as jsx2 } from "react/jsx-runtime";
280
- function NumberField2({
281
- analytics,
282
- density,
283
- className,
284
- ...props
285
- }) {
286
- const trackedOnValueCommitted = useAnalyticsCallback("NumberField", analytics, { name: "ui.commit" }, props.onValueCommitted);
287
- return /* @__PURE__ */ jsx2(NumberFieldPrimitive.Root, {
288
- "data-density": density,
289
- "data-slot": "number-field",
290
- className: (state) => cn2("flex min-w-0 flex-col gap-field-gap", typeof className === "function" ? className(state) : className),
291
- ...props,
292
- onValueCommitted: trackedOnValueCommitted
293
- });
294
- }
295
- function NumberFieldGroup2({
296
- density,
297
- className,
298
- ...props
299
- }) {
300
- return /* @__PURE__ */ jsx2(NumberFieldPrimitive.Group, {
301
- "data-density": density,
302
- "data-slot": "number-field-group",
303
- className: (state) => cn2("flex h-control min-w-0 items-stretch rounded-sm border border-input bg-secondary text-foreground transition-colors focus-within:border-ring focus-within:ring-1 focus-within:ring-ring data-disabled:opacity-50 motion-reduce:transition-none", typeof className === "function" ? className(state) : className),
304
- ...props
305
- });
306
- }
307
- function NumberFieldInput2({
308
- density,
309
- className,
310
- ...props
311
- }) {
312
- return /* @__PURE__ */ jsx2(NumberFieldPrimitive.Input, {
313
- "data-density": density,
314
- "data-slot": "number-field-input",
315
- className: (state) => cn2("min-w-0 flex-1 bg-transparent px-control-x text-center text-sm tabular-nums outline-none disabled:cursor-not-allowed", typeof className === "function" ? className(state) : className),
316
- ...props
317
- });
318
- }
319
- function NumberFieldDecrement2({
320
- density,
321
- className,
322
- children = /* @__PURE__ */ jsx2(MinusIcon, {}),
323
- ...props
324
- }) {
325
- return /* @__PURE__ */ jsx2(NumberFieldPrimitive.Decrement, {
326
- "data-density": density,
327
- "data-slot": "number-field-decrement",
328
- className: (state) => cn2("flex w-control shrink-0 items-center justify-center rounded-s-sm outline-none hover:bg-muted focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-3.5", typeof className === "function" ? className(state) : className),
329
- ...props,
330
- children
331
- });
332
- }
333
- function NumberFieldIncrement2({
334
- density,
335
- className,
336
- children = /* @__PURE__ */ jsx2(PlusIcon, {}),
337
- ...props
338
- }) {
339
- return /* @__PURE__ */ jsx2(NumberFieldPrimitive.Increment, {
340
- "data-density": density,
341
- "data-slot": "number-field-increment",
342
- className: (state) => cn2("flex w-control shrink-0 items-center justify-center rounded-e-sm outline-none hover:bg-muted focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-3.5", typeof className === "function" ? className(state) : className),
343
- ...props,
344
- children
345
- });
346
- }
347
- function NumberFieldScrubArea2({
348
- density,
349
- className,
350
- ...props
351
- }) {
352
- return /* @__PURE__ */ jsx2(NumberFieldPrimitive.ScrubArea, {
353
- "data-density": density,
354
- "data-slot": "number-field-scrub-area",
355
- className: (state) => cn2("flex w-fit cursor-ew-resize items-center gap-control-gap text-sm font-medium", typeof className === "function" ? className(state) : className),
356
- ...props
357
- });
358
- }
359
- function NumberFieldScrubAreaCursor2({
360
- density,
361
- className,
362
- children = /* @__PURE__ */ jsx2(MoveHorizontalIcon, {}),
363
- ...props
364
- }) {
365
- const resolvedDensity = useDensity(density);
366
- return /* @__PURE__ */ jsx2(NumberFieldPrimitive.ScrubAreaCursor, {
367
- "data-density": resolvedDensity,
368
- "data-slot": "number-field-scrub-area-cursor",
369
- className: (state) => cn2("z-50 font-sans text-sm text-foreground [&_svg]:size-5", typeof className === "function" ? className(state) : className),
370
- ...props,
371
- children
372
- });
373
- }
374
-
375
- export { Combobox2, ComboboxValue2, ComboboxTrigger2, ComboboxInput2, ComboboxContent2, ComboboxList2, ComboboxItem2, ComboboxGroup2, ComboboxLabel2, ComboboxCollection2, ComboboxEmpty2, ComboboxSeparator2, ComboboxChips2, ComboboxChip2, ComboboxChipsInput2, useComboboxAnchor2, NumberField2, NumberFieldGroup2, NumberFieldInput2, NumberFieldDecrement2, NumberFieldIncrement2, NumberFieldScrubArea2, NumberFieldScrubAreaCursor2 };
276
+ export { Combobox2, ComboboxValue2, ComboboxTrigger2, ComboboxInput2, ComboboxContent2, ComboboxList2, ComboboxItem2, ComboboxGroup2, ComboboxLabel2, ComboboxCollection2, ComboboxEmpty2, ComboboxSeparator2, ComboboxChips2, ComboboxChip2, ComboboxChipsInput2, useComboboxAnchor2 };
@@ -101,7 +101,7 @@ import {
101
101
  ComboboxChip2,
102
102
  ComboboxChipsInput2,
103
103
  useComboboxAnchor2
104
- } from "./chunk-23ppkypt.js";
104
+ } from "./chunk-me64e034.js";
105
105
  import {
106
106
  Empty2,
107
107
  EmptyHeader2,
@@ -45,16 +45,18 @@ import {
45
45
  ComboboxChips2,
46
46
  ComboboxChip2,
47
47
  ComboboxChipsInput2,
48
- useComboboxAnchor2,
49
- NumberField2,
50
- NumberFieldGroup2,
51
- NumberFieldInput2
52
- } from "../../chunk-23ppkypt.js";
48
+ useComboboxAnchor2
49
+ } from "../../chunk-me64e034.js";
53
50
  import {
54
51
  Badge2
55
52
  } from "../../chunk-9t530p75.js";
56
53
  import"../../chunk-9k5b62qf.js";
57
54
  import"../../chunk-mm3a9s11.js";
55
+ import {
56
+ NumberField2,
57
+ NumberFieldGroup2,
58
+ NumberFieldInput2
59
+ } from "../../chunk-38barrma.js";
58
60
  import {
59
61
  ScrollArea2
60
62
  } from "../../chunk-f9sm5zpv.js";
@@ -0,0 +1,15 @@
1
+ import { type ReactElement } from "react";
2
+ import type { IDensityProps } from "../../density/types.js";
3
+ import type { IImageRect } from "./types.js";
4
+ export interface IImageRegionFieldsProps extends IDensityProps {
5
+ region: IImageRect;
6
+ onRegionChange: (region: IImageRect) => void;
7
+ /** Accessible name of the group. Defaults to "Region". */
8
+ label?: string;
9
+ className?: string;
10
+ }
11
+ /**
12
+ * A placed region's Left, Top, Width and Height as four percent fields that take typed values, for steps finer than
13
+ * the arrow keys' 5%. Values outside the image are pulled back inside it.
14
+ */
15
+ export declare function ImageRegionFields({ region, onRegionChange, label, className, density, }: IImageRegionFieldsProps): ReactElement;
@@ -1,12 +1,17 @@
1
1
  import { type ReactElement } from "react";
2
2
  import type { IImageRect } from "./types.js";
3
3
  export interface IImageRegionSelectProps {
4
- /** Receives the drawn region in normalized image coordinates, each value from 0 to 1. */
5
- onSelect: (region: IImageRect) => void;
4
+ /** The placed region, drawn until it changes or is removed. */
5
+ region?: IImageRect;
6
+ /** Receives each placed region in normalized image coordinates, each value from 0 to 1. */
7
+ onRegionChange: (region: IImageRect) => void;
6
8
  }
7
9
  /**
8
- * Region tool for an `ImageViewer` overlay: a drag with one pointer draws a region and reports it in normalized image
9
- * coordinates. Render it only while the person has turned a region tool on, so pans and pinches stay navigation
10
- * otherwise. Its pointer is kept from panning the stage; a second finger cancels the drawing and pinch-zooms instead.
10
+ * Region tool for an `ImageViewer` overlay. A drag with one pointer draws a region; a click without a drag places a
11
+ * region half the image's size centred on the click, and a second click before anything else changes it makes the two
12
+ * clicks opposite corners, the non-drag alternative WCAG 2.5.7 asks for. Pair it with `applyImageRegionKey` and
13
+ * `placeImageRegion` on the stage's keys and `ImageRegionFields` for typed values. Render it only while the person has
14
+ * turned a region tool on, so pans and pinches stay navigation otherwise. Its pointer is kept from panning the stage; a
15
+ * second finger cancels the drawing and pinch-zooms instead.
11
16
  */
12
- export declare function ImageRegionSelect({ onSelect }: IImageRegionSelectProps): ReactElement;
17
+ export declare function ImageRegionSelect({ region, onRegionChange }: IImageRegionSelectProps): ReactElement;
@@ -0,0 +1,21 @@
1
+ import type { IImageRect, INormalizedImagePoint } from "./types.js";
2
+ /** How far one arrow press moves or resizes a placed region, as a fraction of the image. */
3
+ export declare const IMAGE_REGION_STEP = 0.05;
4
+ /** The smallest width or height a placed region keeps, as a fraction of the image. */
5
+ export declare const MIN_IMAGE_REGION_SIZE = 0.01;
6
+ /** Keeps a region inside the image and at least the minimum size. */
7
+ export declare function clampImageRegion(region: IImageRect): IImageRect;
8
+ /**
9
+ * Places a region half the image's width and height, centred on `center` and kept inside the image. Without a center
10
+ * it sits in the image's middle, as Enter places it on a focused stage.
11
+ */
12
+ export declare function placeImageRegion(center?: INormalizedImagePoint): IImageRect;
13
+ /** The region whose opposite corners are two clicked points. */
14
+ export declare function getImageRegionFromCorners(first: INormalizedImagePoint, second: INormalizedImagePoint): IImageRect;
15
+ /**
16
+ * Applies an arrow key to a placed region: an arrow moves it by one step and Shift with an arrow resizes it, growing
17
+ * to the right and down and shrinking from there. Returns undefined for any other key, so the stage keeps panning.
18
+ */
19
+ export declare function applyImageRegionKey(region: IImageRect, key: string, isResize: boolean, step?: number): IImageRect | undefined;
20
+ /** A region's text form, which is also its accessible name: "Region 60% × 50% at 25%, 25%". */
21
+ export declare function formatImageRegion(region: IImageRect): string;
@@ -6,6 +6,9 @@ export { ImageZoomControl } from "./ImageZoomControl.js";
6
6
  export type { IImageZoomControlProps } from "./ImageZoomControl.js";
7
7
  export { ImageRegionSelect } from "./ImageRegionSelect.js";
8
8
  export type { IImageRegionSelectProps } from "./ImageRegionSelect.js";
9
+ export { ImageRegionFields } from "./ImageRegionFields.js";
10
+ export type { IImageRegionFieldsProps } from "./ImageRegionFields.js";
11
+ export { IMAGE_REGION_STEP, MIN_IMAGE_REGION_SIZE, applyImageRegionKey, clampImageRegion, formatImageRegion, getImageRegionFromCorners, placeImageRegion, } from "./imageRegion.js";
9
12
  export { FramedImage } from "./FramedImage.js";
10
13
  export type { FramedImageSize, IFramedImageProps } from "./FramedImage.js";
11
14
  export { ImageComparison } from "./ImageComparison.js";
@@ -14,19 +14,24 @@ import {
14
14
  ToggleGroup2,
15
15
  ToggleGroupItem2
16
16
  } from "../../chunk-9n617bte.js";
17
- import {
18
- FramedImage2
19
- } from "../../chunk-2jsgsjas.js";
17
+ import"../../chunk-m32ptxf3.js";
20
18
  import {
21
19
  Separator2
22
20
  } from "../../chunk-52aadmkc.js";
23
- import"../../chunk-m32ptxf3.js";
24
21
  import {
25
22
  Field2,
26
23
  FieldContent2,
27
24
  FieldLabel2,
28
25
  FieldDescription2
29
26
  } from "../../chunk-bfv4qesg.js";
27
+ import {
28
+ NumberField2,
29
+ NumberFieldGroup2,
30
+ NumberFieldInput2
31
+ } from "../../chunk-38barrma.js";
32
+ import {
33
+ FramedImage2
34
+ } from "../../chunk-2jsgsjas.js";
30
35
  import {
31
36
  Switch2
32
37
  } from "../../chunk-m98d89xc.js";
@@ -644,6 +649,58 @@ function getNormalizedImagePoint(point, box) {
644
649
  };
645
650
  }
646
651
 
652
+ // src/components/image-viewer/imageRegion.ts
653
+ var IMAGE_REGION_STEP = 0.05;
654
+ var MIN_IMAGE_REGION_SIZE = 0.01;
655
+ var DEFAULT_SIZE = 0.5;
656
+ function clamp2(value, min, max) {
657
+ return Math.min(max, Math.max(min, value));
658
+ }
659
+ function round(value) {
660
+ return Math.round(value * 1e4) / 1e4;
661
+ }
662
+ function clampImageRegion(region) {
663
+ const width = clamp2(region.width, MIN_IMAGE_REGION_SIZE, 1);
664
+ const height = clamp2(region.height, MIN_IMAGE_REGION_SIZE, 1);
665
+ return {
666
+ x: round(clamp2(region.x, 0, 1 - width)),
667
+ y: round(clamp2(region.y, 0, 1 - height)),
668
+ width: round(width),
669
+ height: round(height)
670
+ };
671
+ }
672
+ function placeImageRegion(center = { x: 0.5, y: 0.5 }) {
673
+ return clampImageRegion({
674
+ x: center.x - DEFAULT_SIZE / 2,
675
+ y: center.y - DEFAULT_SIZE / 2,
676
+ width: DEFAULT_SIZE,
677
+ height: DEFAULT_SIZE
678
+ });
679
+ }
680
+ function getImageRegionFromCorners(first, second) {
681
+ return clampImageRegion({
682
+ x: Math.min(first.x, second.x),
683
+ y: Math.min(first.y, second.y),
684
+ width: Math.abs(second.x - first.x),
685
+ height: Math.abs(second.y - first.y)
686
+ });
687
+ }
688
+ function applyImageRegionKey(region, key, isResize, step = IMAGE_REGION_STEP) {
689
+ const delta = { ArrowLeft: [-step, 0], ArrowRight: [step, 0], ArrowUp: [0, -step], ArrowDown: [0, step] }[key];
690
+ if (!delta)
691
+ return;
692
+ const [dx = 0, dy = 0] = delta;
693
+ if (isResize)
694
+ return clampImageRegion({ ...region, width: region.width + dx, height: region.height + dy });
695
+ return clampImageRegion({ ...region, x: region.x + dx, y: region.y + dy });
696
+ }
697
+ function percent(value) {
698
+ return `${round(value * 100)}%`;
699
+ }
700
+ function formatImageRegion(region) {
701
+ return `Region ${percent(region.width)} × ${percent(region.height)} at ${percent(region.x)}, ${percent(region.y)}`;
702
+ }
703
+
647
704
  // src/components/image-viewer/ImageRegionMarker.tsx
648
705
  import { cva } from "class-variance-authority";
649
706
  import { jsx as jsx5 } from "react/jsx-runtime";
@@ -699,14 +756,35 @@ function toRegion(start, end) {
699
756
  height: Math.abs(end.y - start.y)
700
757
  };
701
758
  }
702
- function ImageRegionSelect({ onSelect }) {
759
+ function toBox(region) {
760
+ return {
761
+ left: `${region.x * 100}%`,
762
+ top: `${region.y * 100}%`,
763
+ width: `${region.width * 100}%`,
764
+ height: `${region.height * 100}%`
765
+ };
766
+ }
767
+ function ImageRegionSelect({ region, onRegionChange }) {
703
768
  const drag = useRef3(null);
769
+ const pendingClick = useRef3(null);
704
770
  const [draft, setDraft] = useState4();
705
771
  const point = (event) => getNormalizedImagePoint(event, event.currentTarget.getBoundingClientRect());
706
772
  function cancel() {
707
773
  drag.current = null;
708
774
  setDraft(undefined);
709
775
  }
776
+ function click(at) {
777
+ const pending = pendingClick.current;
778
+ if (pending && pending.region === region) {
779
+ pendingClick.current = null;
780
+ onRegionChange(getImageRegionFromCorners(pending.point, at));
781
+ return;
782
+ }
783
+ const placed = placeImageRegion(at);
784
+ pendingClick.current = { point: at, region: placed };
785
+ onRegionChange(placed);
786
+ }
787
+ const shown = draft ?? region;
710
788
  return /* @__PURE__ */ jsx6("div", {
711
789
  "data-slot": "image-region-select",
712
790
  className: "absolute inset-0 cursor-crosshair touch-none",
@@ -721,51 +799,120 @@ function ImageRegionSelect({ onSelect }) {
721
799
  event.preventDefault();
722
800
  event.currentTarget.setPointerCapture(event.pointerId);
723
801
  drag.current = { pointerId: event.pointerId, start: point(event) };
724
- setDraft(undefined);
725
802
  },
726
803
  onPointerMove: (event) => {
727
- if (drag.current?.pointerId === event.pointerId)
728
- setDraft(toRegion(drag.current.start, point(event)));
804
+ const current = drag.current;
805
+ if (current?.pointerId !== event.pointerId)
806
+ return;
807
+ const moved = toRegion(current.start, point(event));
808
+ const bounds = event.currentTarget.getBoundingClientRect();
809
+ if (moved.width * bounds.width >= MINIMUM_DRAG || moved.height * bounds.height >= MINIMUM_DRAG)
810
+ setDraft(moved);
729
811
  },
730
812
  onPointerUp: (event) => {
731
813
  const current = drag.current;
732
814
  if (current?.pointerId !== event.pointerId)
733
815
  return;
734
816
  cancel();
735
- const region = toRegion(current.start, point(event));
817
+ const end = point(event);
818
+ const dragged = toRegion(current.start, end);
736
819
  const bounds = event.currentTarget.getBoundingClientRect();
737
- if (region.width * bounds.width < MINIMUM_DRAG && region.height * bounds.height < MINIMUM_DRAG)
820
+ if (dragged.width * bounds.width < MINIMUM_DRAG && dragged.height * bounds.height < MINIMUM_DRAG) {
821
+ click(end);
738
822
  return;
739
- onSelect(region);
823
+ }
824
+ pendingClick.current = null;
825
+ onRegionChange(dragged);
740
826
  },
741
827
  onPointerCancel: cancel,
742
- children: draft && /* @__PURE__ */ jsx6(ImageRegionMarker, {
828
+ children: shown && /* @__PURE__ */ jsx6(ImageRegionMarker, {
743
829
  variant: "draft",
744
- "aria-hidden": "true",
830
+ role: draft ? undefined : "img",
831
+ "aria-hidden": draft ? "true" : undefined,
832
+ "aria-label": draft ? undefined : formatImageRegion(shown),
745
833
  "data-slot": "image-region-select-draft",
746
- region: {
747
- left: `${draft.x * 100}%`,
748
- top: `${draft.y * 100}%`,
749
- width: `${draft.width * 100}%`,
750
- height: `${draft.height * 100}%`
751
- }
834
+ region: toBox(shown)
752
835
  })
753
836
  });
754
837
  }
838
+ // src/components/image-viewer/ImageRegionFields.tsx
839
+ import { useId } from "react";
840
+ import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
841
+ var FIELDS = [
842
+ ["x", "Left"],
843
+ ["y", "Top"],
844
+ ["width", "Width"],
845
+ ["height", "Height"]
846
+ ];
847
+ function toPercent(value) {
848
+ return Math.round(value * 1000) / 10;
849
+ }
850
+ function ImageRegionFields({
851
+ region,
852
+ onRegionChange,
853
+ label = "Region",
854
+ className,
855
+ density
856
+ }) {
857
+ const id = useId();
858
+ return /* @__PURE__ */ jsxs4("div", {
859
+ role: "group",
860
+ "aria-label": label,
861
+ "data-slot": "image-region-fields",
862
+ "data-density": density,
863
+ className: cn2("flex flex-wrap items-end gap-control-gap", className),
864
+ children: [
865
+ FIELDS.map(([key, name]) => /* @__PURE__ */ jsxs4(Field2, {
866
+ className: "w-20",
867
+ children: [
868
+ /* @__PURE__ */ jsx7(FieldLabel2, {
869
+ htmlFor: `${id}-${key}`,
870
+ children: name
871
+ }),
872
+ /* @__PURE__ */ jsx7(NumberField2, {
873
+ id: `${id}-${key}`,
874
+ density,
875
+ value: toPercent(region[key]),
876
+ min: 0,
877
+ max: 100,
878
+ step: 1,
879
+ smallStep: 0.1,
880
+ format: { maximumFractionDigits: 1 },
881
+ onValueChange: (value) => {
882
+ if (value === null)
883
+ return;
884
+ onRegionChange(clampImageRegion({ ...region, [key]: value / 100 }));
885
+ },
886
+ children: /* @__PURE__ */ jsx7(NumberFieldGroup2, {
887
+ children: /* @__PURE__ */ jsx7(NumberFieldInput2, {
888
+ "aria-describedby": `${id}-unit`
889
+ })
890
+ })
891
+ })
892
+ ]
893
+ }, key)),
894
+ /* @__PURE__ */ jsx7("span", {
895
+ id: `${id}-unit`,
896
+ className: "sr-only",
897
+ children: "percent of the image"
898
+ })
899
+ ]
900
+ });
901
+ }
755
902
  // src/components/image-viewer/ImageComparison.tsx
756
903
  import { useControlled as useControlled2 } from "@base-ui/utils/useControlled";
757
904
  import { useRef as useRef5, useState as useState6 } from "react";
758
905
 
759
906
  // src/components/image-viewer/ImageComparisonToolbar.tsx
760
907
  import { Columns2Icon, Rows2Icon } from "lucide-react";
761
- import { useId } from "react";
762
- import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
908
+ import { useId as useId2 } from "react";
909
+ import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
763
910
  function ToolbarSection({ title, titleId, children }) {
764
- return /* @__PURE__ */ jsxs4("div", {
911
+ return /* @__PURE__ */ jsxs5("div", {
765
912
  "data-slot": "image-comparison-toolbar-section",
766
913
  className: "flex min-w-0 flex-col gap-1.5",
767
914
  children: [
768
- /* @__PURE__ */ jsx7("span", {
915
+ /* @__PURE__ */ jsx8("span", {
769
916
  id: titleId,
770
917
  className: "sr-only text-xs font-medium text-muted-foreground @3xl:not-sr-only",
771
918
  children: title
@@ -812,21 +959,21 @@ function ImageComparisonToolbar({
812
959
  afterSize,
813
960
  density
814
961
  }) {
815
- const id = useId();
962
+ const id = useId2();
816
963
  const isUnavailable = differences.status === "unavailable";
817
964
  const releasePeek = () => onPeekChange(false);
818
965
  const sizeMismatch = beforeSize && afterSize && (beforeSize.width !== afterSize.width || beforeSize.height !== afterSize.height) ? `Sizes differ: ${beforeLabel} ${formatSize(beforeSize)}, ${afterLabel} ${formatSize(afterSize)}. ` + `${beforeLabel} is fitted inside the ${afterLabel} image box.` : undefined;
819
- return /* @__PURE__ */ jsxs4("div", {
966
+ return /* @__PURE__ */ jsxs5("div", {
820
967
  role: "group",
821
968
  "aria-label": "Comparison controls",
822
969
  "data-slot": "image-comparison-toolbar",
823
970
  "data-density": density,
824
971
  className: "flex shrink-0 flex-wrap items-end gap-x-panel gap-y-3 border-t border-border p-panel-sm @3xl:w-72 @3xl:flex-col @3xl:flex-nowrap @3xl:items-stretch @3xl:overflow-y-auto @3xl:border-t-0 @3xl:border-s",
825
972
  children: [
826
- /* @__PURE__ */ jsx7(ToolbarSection, {
973
+ /* @__PURE__ */ jsx8(ToolbarSection, {
827
974
  title: "Mode",
828
975
  titleId: `${id}-mode`,
829
- children: /* @__PURE__ */ jsxs4(ToggleGroup2, {
976
+ children: /* @__PURE__ */ jsxs5(ToggleGroup2, {
830
977
  "aria-labelledby": `${id}-mode`,
831
978
  required: true,
832
979
  value: [mode],
@@ -835,25 +982,25 @@ function ImageComparisonToolbar({
835
982
  size: "sm",
836
983
  spacing: 0,
837
984
  children: [
838
- /* @__PURE__ */ jsx7(ToggleGroupItem2, {
985
+ /* @__PURE__ */ jsx8(ToggleGroupItem2, {
839
986
  value: "toggle",
840
987
  children: "Toggle"
841
988
  }),
842
- /* @__PURE__ */ jsx7(ToggleGroupItem2, {
989
+ /* @__PURE__ */ jsx8(ToggleGroupItem2, {
843
990
  value: "swipe",
844
991
  children: "Swipe"
845
992
  }),
846
- /* @__PURE__ */ jsx7(ToggleGroupItem2, {
993
+ /* @__PURE__ */ jsx8(ToggleGroupItem2, {
847
994
  value: "side-by-side",
848
995
  children: "Side by side"
849
996
  })
850
997
  ]
851
998
  })
852
999
  }),
853
- /* @__PURE__ */ jsx7(ToolbarSection, {
1000
+ /* @__PURE__ */ jsx8(ToolbarSection, {
854
1001
  title: "Orientation",
855
1002
  titleId: `${id}-orientation`,
856
- children: /* @__PURE__ */ jsxs4(ToggleGroup2, {
1003
+ children: /* @__PURE__ */ jsxs5(ToggleGroup2, {
857
1004
  "aria-labelledby": `${id}-orientation`,
858
1005
  required: true,
859
1006
  value: [orientation],
@@ -863,19 +1010,19 @@ function ImageComparisonToolbar({
863
1010
  spacing: 0,
864
1011
  disabled: mode !== "side-by-side",
865
1012
  children: [
866
- /* @__PURE__ */ jsxs4(ToggleGroupItem2, {
1013
+ /* @__PURE__ */ jsxs5(ToggleGroupItem2, {
867
1014
  value: "horizontal",
868
1015
  children: [
869
- /* @__PURE__ */ jsx7(Columns2Icon, {
1016
+ /* @__PURE__ */ jsx8(Columns2Icon, {
870
1017
  "data-icon": "inline-start"
871
1018
  }),
872
1019
  "Horizontal"
873
1020
  ]
874
1021
  }),
875
- /* @__PURE__ */ jsxs4(ToggleGroupItem2, {
1022
+ /* @__PURE__ */ jsxs5(ToggleGroupItem2, {
876
1023
  value: "vertical",
877
1024
  children: [
878
- /* @__PURE__ */ jsx7(Rows2Icon, {
1025
+ /* @__PURE__ */ jsx8(Rows2Icon, {
879
1026
  "data-icon": "inline-start"
880
1027
  }),
881
1028
  "Vertical"
@@ -884,15 +1031,15 @@ function ImageComparisonToolbar({
884
1031
  ]
885
1032
  })
886
1033
  }),
887
- /* @__PURE__ */ jsx7(ToolbarSection, {
1034
+ /* @__PURE__ */ jsx8(ToolbarSection, {
888
1035
  title: "Zoom",
889
1036
  titleId: `${id}-zoom`,
890
- children: /* @__PURE__ */ jsx7(ImageZoomToggle, {
1037
+ children: /* @__PURE__ */ jsx8(ImageZoomToggle, {
891
1038
  zoom,
892
1039
  onZoomChange
893
1040
  })
894
1041
  }),
895
- /* @__PURE__ */ jsx7(Button2, {
1042
+ /* @__PURE__ */ jsx8(Button2, {
896
1043
  variant: "outline",
897
1044
  size: "sm",
898
1045
  disabled: mode !== "toggle",
@@ -916,27 +1063,27 @@ function ImageComparisonToolbar({
916
1063
  onContextMenu: (event) => event.preventDefault(),
917
1064
  children: "Hold to show before"
918
1065
  }),
919
- /* @__PURE__ */ jsxs4(Field2, {
1066
+ /* @__PURE__ */ jsxs5(Field2, {
920
1067
  orientation: "horizontal",
921
1068
  children: [
922
- /* @__PURE__ */ jsx7(Switch2, {
1069
+ /* @__PURE__ */ jsx8(Switch2, {
923
1070
  id: `${id}-differences`,
924
1071
  "aria-describedby": `${id}-differences-status`,
925
1072
  checked: showDifferences && !isUnavailable,
926
1073
  disabled: isUnavailable,
927
1074
  onCheckedChange: onShowDifferencesChange
928
1075
  }),
929
- /* @__PURE__ */ jsxs4(FieldContent2, {
1076
+ /* @__PURE__ */ jsxs5(FieldContent2, {
930
1077
  children: [
931
- /* @__PURE__ */ jsx7(FieldLabel2, {
1078
+ /* @__PURE__ */ jsx8(FieldLabel2, {
932
1079
  htmlFor: `${id}-differences`,
933
1080
  children: "Highlight differences"
934
1081
  }),
935
- showDifferences && differences.status === "ready" && /* @__PURE__ */ jsxs4(FieldDescription2, {
1082
+ showDifferences && differences.status === "ready" && /* @__PURE__ */ jsxs5(FieldDescription2, {
936
1083
  "data-slot": "image-comparison-legend",
937
1084
  className: "flex items-center gap-1.5",
938
1085
  children: [
939
- /* @__PURE__ */ jsx7("span", {
1086
+ /* @__PURE__ */ jsx8("span", {
940
1087
  "aria-hidden": "true",
941
1088
  className: "mx-[3px] size-2.5 shrink-0 rounded-xs bg-warning/10 ring-1 ring-background outline-2 outline-offset-1 outline-warning"
942
1089
  }),
@@ -947,16 +1094,16 @@ function ImageComparisonToolbar({
947
1094
  })
948
1095
  ]
949
1096
  }),
950
- /* @__PURE__ */ jsxs4("div", {
1097
+ /* @__PURE__ */ jsxs5("div", {
951
1098
  "data-slot": "image-comparison-status",
952
1099
  className: "flex min-w-0 flex-col gap-1 text-xs text-muted-foreground",
953
1100
  children: [
954
- /* @__PURE__ */ jsx7("p", {
1101
+ /* @__PURE__ */ jsx8("p", {
955
1102
  id: `${id}-differences-status`,
956
1103
  role: "status",
957
1104
  children: describeDifferences(differences, showDifferences)
958
1105
  }),
959
- sizeMismatch && /* @__PURE__ */ jsx7("p", {
1106
+ sizeMismatch && /* @__PURE__ */ jsx8("p", {
960
1107
  "data-slot": "image-comparison-size-mismatch",
961
1108
  children: sizeMismatch
962
1109
  })
@@ -967,23 +1114,23 @@ function ImageComparisonToolbar({
967
1114
  }
968
1115
 
969
1116
  // src/components/image-viewer/ImageDifferenceOverlay.tsx
970
- import { jsx as jsx8 } from "react/jsx-runtime";
971
- function toPercent(value, total) {
1117
+ import { jsx as jsx9 } from "react/jsx-runtime";
1118
+ function toPercent2(value, total) {
972
1119
  return `${value / total * 100}%`;
973
1120
  }
974
1121
  function ImageDifferenceOverlay({ diff }) {
975
- return /* @__PURE__ */ jsx8("div", {
1122
+ return /* @__PURE__ */ jsx9("div", {
976
1123
  "data-slot": "image-difference-overlay",
977
1124
  "aria-hidden": "true",
978
1125
  className: "pointer-events-none absolute inset-0",
979
- children: diff.regions.map((region) => /* @__PURE__ */ jsx8(ImageRegionMarker, {
1126
+ children: diff.regions.map((region) => /* @__PURE__ */ jsx9(ImageRegionMarker, {
980
1127
  "data-slot": "image-difference-region",
981
1128
  variant: "difference",
982
1129
  region: {
983
- left: toPercent(region.x, diff.width),
984
- top: toPercent(region.y, diff.height),
985
- width: toPercent(region.width, diff.width),
986
- height: toPercent(region.height, diff.height)
1130
+ left: toPercent2(region.x, diff.width),
1131
+ top: toPercent2(region.y, diff.height),
1132
+ width: toPercent2(region.width, diff.width),
1133
+ height: toPercent2(region.height, diff.height)
987
1134
  }
988
1135
  }, `${region.x}:${region.y}:${region.width}:${region.height}`))
989
1136
  });
@@ -993,16 +1140,16 @@ function ImageDifferenceOverlay({ diff }) {
993
1140
  import { DirectionProvider } from "@base-ui/react/direction-provider";
994
1141
  import { Slider as SliderPrimitive } from "@base-ui/react/slider";
995
1142
  import { ChevronsLeftRightIcon } from "lucide-react";
996
- import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
1143
+ import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
997
1144
  function ImageSwipeDivider({
998
1145
  value,
999
1146
  onValueChange,
1000
1147
  beforeLabel,
1001
1148
  afterLabel
1002
1149
  }) {
1003
- return /* @__PURE__ */ jsx9(DirectionProvider, {
1150
+ return /* @__PURE__ */ jsx10(DirectionProvider, {
1004
1151
  direction: "ltr",
1005
- children: /* @__PURE__ */ jsx9(SliderPrimitive.Root, {
1152
+ children: /* @__PURE__ */ jsx10(SliderPrimitive.Root, {
1006
1153
  dir: "ltr",
1007
1154
  "data-slot": "image-swipe-divider",
1008
1155
  value,
@@ -1012,22 +1159,22 @@ function ImageSwipeDivider({
1012
1159
  step: 1,
1013
1160
  largeStep: 10,
1014
1161
  className: "pointer-events-none absolute inset-0",
1015
- children: /* @__PURE__ */ jsx9(SliderPrimitive.Control, {
1162
+ children: /* @__PURE__ */ jsx10(SliderPrimitive.Control, {
1016
1163
  className: "pointer-events-none absolute inset-0",
1017
- children: /* @__PURE__ */ jsxs5(SliderPrimitive.Thumb, {
1164
+ children: /* @__PURE__ */ jsxs6(SliderPrimitive.Thumb, {
1018
1165
  "data-slot": "image-swipe-divider-handle",
1019
1166
  getAriaLabel: () => "Swipe divider",
1020
1167
  getAriaValueText: (_formatted, current) => `${beforeLabel} ${current}%, ${afterLabel} ${100 - current}%`,
1021
1168
  className: "group/divider pointer-events-auto flex h-full w-6 cursor-ew-resize touch-none flex-col items-center justify-center select-none",
1022
1169
  children: [
1023
- /* @__PURE__ */ jsx9("span", {
1170
+ /* @__PURE__ */ jsx10("span", {
1024
1171
  "aria-hidden": "true",
1025
1172
  className: "absolute inset-y-0 start-1/2 w-0.5 -translate-x-1/2 bg-foreground ring-1 ring-background"
1026
1173
  }),
1027
- /* @__PURE__ */ jsx9("span", {
1174
+ /* @__PURE__ */ jsx10("span", {
1028
1175
  "aria-hidden": "true",
1029
1176
  className: "relative flex h-8 w-5 items-center justify-center rounded-sm border border-border bg-background text-foreground shadow-frame group-has-[:focus-visible]/divider:border-ring group-has-[:focus-visible]/divider:ring-1 group-has-[:focus-visible]/divider:ring-ring group-data-dragging/divider:border-ring",
1030
- children: /* @__PURE__ */ jsx9(ChevronsLeftRightIcon, {
1177
+ children: /* @__PURE__ */ jsx10(ChevronsLeftRightIcon, {
1031
1178
  className: "size-3.5"
1032
1179
  })
1033
1180
  })
@@ -1293,14 +1440,14 @@ function useImageDifferences({
1293
1440
  }
1294
1441
 
1295
1442
  // src/components/image-viewer/ImageComparison.tsx
1296
- import { jsx as jsx10, jsxs as jsxs6, Fragment } from "react/jsx-runtime";
1443
+ import { jsx as jsx11, jsxs as jsxs7, Fragment } from "react/jsx-runtime";
1297
1444
  function ComparisonPane({ header, children }) {
1298
- return /* @__PURE__ */ jsxs6("div", {
1445
+ return /* @__PURE__ */ jsxs7("div", {
1299
1446
  "data-slot": "image-comparison-pane",
1300
1447
  "data-scroll": "none",
1301
1448
  className: "flex min-h-0 min-w-0 flex-1 flex-col",
1302
1449
  children: [
1303
- /* @__PURE__ */ jsx10("div", {
1450
+ /* @__PURE__ */ jsx11("div", {
1304
1451
  "data-slot": "image-comparison-pane-header",
1305
1452
  className: "flex h-control shrink-0 items-center justify-between gap-2 px-control-x text-xs font-medium text-muted-foreground",
1306
1453
  children: header
@@ -1375,10 +1522,10 @@ ${after.src}`,
1375
1522
  afterRef
1376
1523
  });
1377
1524
  const isShowingBefore = mode === "toggle" && isPeeking;
1378
- const overlay = showDifferences && differences.status === "ready" ? /* @__PURE__ */ jsx10(ImageDifferenceOverlay, {
1525
+ const overlay = showDifferences && differences.status === "ready" ? /* @__PURE__ */ jsx11(ImageDifferenceOverlay, {
1379
1526
  diff: differences.diff
1380
1527
  }) : null;
1381
- const fallback = failedLabel ? /* @__PURE__ */ jsxs6("p", {
1528
+ const fallback = failedLabel ? /* @__PURE__ */ jsxs7("p", {
1382
1529
  "data-slot": "image-comparison-error",
1383
1530
  className: "m-auto p-panel text-center text-sm text-muted-foreground",
1384
1531
  children: [
@@ -1416,7 +1563,7 @@ ${after.src}`,
1416
1563
  }
1417
1564
  }
1418
1565
  function renderAfterImage(className) {
1419
- return /* @__PURE__ */ jsx10("img", {
1566
+ return /* @__PURE__ */ jsx11("img", {
1420
1567
  ref: afterRef,
1421
1568
  src: after.src,
1422
1569
  alt: after.alt,
@@ -1429,7 +1576,7 @@ ${after.src}`,
1429
1576
  });
1430
1577
  }
1431
1578
  function renderBeforeImage(className, style) {
1432
- return /* @__PURE__ */ jsx10("img", {
1579
+ return /* @__PURE__ */ jsx11("img", {
1433
1580
  ref: beforeRef,
1434
1581
  src: before.src,
1435
1582
  alt: before.alt,
@@ -1444,15 +1591,15 @@ ${after.src}`,
1444
1591
  }
1445
1592
  let content;
1446
1593
  if (mode === "side-by-side") {
1447
- content = /* @__PURE__ */ jsxs6("div", {
1594
+ content = /* @__PURE__ */ jsxs7("div", {
1448
1595
  "data-slot": "image-comparison-panes",
1449
1596
  className: cn2("flex min-h-0 min-w-0 flex-1", orientation === "vertical" ? "flex-col" : "flex-row"),
1450
1597
  children: [
1451
- /* @__PURE__ */ jsx10(ComparisonPane, {
1452
- header: /* @__PURE__ */ jsx10("span", {
1598
+ /* @__PURE__ */ jsx11(ComparisonPane, {
1599
+ header: /* @__PURE__ */ jsx11("span", {
1453
1600
  children: beforeLabel
1454
1601
  }),
1455
- children: /* @__PURE__ */ jsxs6(ImageViewport, {
1602
+ children: /* @__PURE__ */ jsxs7(ImageViewport, {
1456
1603
  label: beforeLabel,
1457
1604
  zoom,
1458
1605
  naturalSize: afterImage.size,
@@ -1467,14 +1614,14 @@ ${after.src}`,
1467
1614
  ]
1468
1615
  })
1469
1616
  }),
1470
- /* @__PURE__ */ jsx10(Separator2, {
1617
+ /* @__PURE__ */ jsx11(Separator2, {
1471
1618
  orientation: orientation === "vertical" ? "horizontal" : "vertical"
1472
1619
  }),
1473
- /* @__PURE__ */ jsx10(ComparisonPane, {
1474
- header: /* @__PURE__ */ jsx10("span", {
1620
+ /* @__PURE__ */ jsx11(ComparisonPane, {
1621
+ header: /* @__PURE__ */ jsx11("span", {
1475
1622
  children: afterLabel
1476
1623
  }),
1477
- children: /* @__PURE__ */ jsxs6(ImageViewport, {
1624
+ children: /* @__PURE__ */ jsxs7(ImageViewport, {
1478
1625
  label: afterLabel,
1479
1626
  zoom,
1480
1627
  naturalSize: afterImage.size,
@@ -1492,18 +1639,18 @@ ${after.src}`,
1492
1639
  ]
1493
1640
  });
1494
1641
  } else if (mode === "swipe") {
1495
- content = /* @__PURE__ */ jsx10(ComparisonPane, {
1496
- header: /* @__PURE__ */ jsxs6(Fragment, {
1642
+ content = /* @__PURE__ */ jsx11(ComparisonPane, {
1643
+ header: /* @__PURE__ */ jsxs7(Fragment, {
1497
1644
  children: [
1498
- /* @__PURE__ */ jsx10("span", {
1645
+ /* @__PURE__ */ jsx11("span", {
1499
1646
  children: beforeLabel
1500
1647
  }),
1501
- /* @__PURE__ */ jsx10("span", {
1648
+ /* @__PURE__ */ jsx11("span", {
1502
1649
  children: afterLabel
1503
1650
  })
1504
1651
  ]
1505
1652
  }),
1506
- children: /* @__PURE__ */ jsxs6(ImageViewport, {
1653
+ children: /* @__PURE__ */ jsxs7(ImageViewport, {
1507
1654
  label: `${beforeLabel} and ${afterLabel}`,
1508
1655
  zoom,
1509
1656
  naturalSize: afterImage.size,
@@ -1514,7 +1661,7 @@ ${after.src}`,
1514
1661
  renderAfterImage(),
1515
1662
  renderBeforeImage(undefined, { clipPath: `inset(0 ${100 - position}% 0 0)` }),
1516
1663
  overlay,
1517
- /* @__PURE__ */ jsx10(ImageSwipeDivider, {
1664
+ /* @__PURE__ */ jsx11(ImageSwipeDivider, {
1518
1665
  value: position,
1519
1666
  onValueChange: setPosition,
1520
1667
  beforeLabel,
@@ -1525,8 +1672,8 @@ ${after.src}`,
1525
1672
  });
1526
1673
  } else {
1527
1674
  const showingLabel = isShowingBefore ? beforeLabel : afterLabel;
1528
- content = /* @__PURE__ */ jsx10(ComparisonPane, {
1529
- header: /* @__PURE__ */ jsxs6("span", {
1675
+ content = /* @__PURE__ */ jsx11(ComparisonPane, {
1676
+ header: /* @__PURE__ */ jsxs7("span", {
1530
1677
  "data-slot": "image-comparison-showing",
1531
1678
  "aria-live": "polite",
1532
1679
  children: [
@@ -1534,7 +1681,7 @@ ${after.src}`,
1534
1681
  showingLabel
1535
1682
  ]
1536
1683
  }),
1537
- children: /* @__PURE__ */ jsxs6(ImageViewport, {
1684
+ children: /* @__PURE__ */ jsxs7(ImageViewport, {
1538
1685
  label: showingLabel,
1539
1686
  zoom,
1540
1687
  naturalSize: afterImage.size,
@@ -1549,7 +1696,7 @@ ${after.src}`,
1549
1696
  })
1550
1697
  });
1551
1698
  }
1552
- return /* @__PURE__ */ jsx10("div", {
1699
+ return /* @__PURE__ */ jsx11("div", {
1553
1700
  role: "group",
1554
1701
  "aria-label": label,
1555
1702
  "data-slot": "image-comparison",
@@ -1560,16 +1707,16 @@ ${after.src}`,
1560
1707
  "data-zoom": zoom,
1561
1708
  "data-showing": isShowingBefore ? "before" : "after",
1562
1709
  className: "@container flex size-full min-h-0 min-w-0 flex-1",
1563
- children: /* @__PURE__ */ jsxs6("div", {
1710
+ children: /* @__PURE__ */ jsxs7("div", {
1564
1711
  className: "flex min-h-0 min-w-0 flex-1 flex-col @3xl:flex-row",
1565
1712
  children: [
1566
- /* @__PURE__ */ jsx10("div", {
1713
+ /* @__PURE__ */ jsx11("div", {
1567
1714
  "data-slot": "image-comparison-stage",
1568
1715
  "data-scroll": "none",
1569
1716
  className: "flex min-h-0 min-w-0 flex-1",
1570
1717
  children: content
1571
1718
  }),
1572
- showToolbar && /* @__PURE__ */ jsx10(ImageComparisonToolbar, {
1719
+ showToolbar && /* @__PURE__ */ jsx11(ImageComparisonToolbar, {
1573
1720
  mode,
1574
1721
  onModeChange: setMode,
1575
1722
  orientation,
@@ -1592,8 +1739,10 @@ ${after.src}`,
1592
1739
  }
1593
1740
  export {
1594
1741
  FramedImage2 as FramedImage,
1742
+ IMAGE_REGION_STEP,
1595
1743
  IMAGE_ZOOM_STEPS,
1596
1744
  ImageComparison,
1745
+ ImageRegionFields,
1597
1746
  ImageRegionMarker,
1598
1747
  ImageRegionMarkerBadge,
1599
1748
  ImageRegionSelect,
@@ -1601,12 +1750,18 @@ export {
1601
1750
  ImageZoomControl,
1602
1751
  ImageZoomToggle,
1603
1752
  MAX_IMAGE_ZOOM,
1753
+ MIN_IMAGE_REGION_SIZE,
1754
+ applyImageRegionKey,
1755
+ clampImageRegion,
1604
1756
  computeImageDiff,
1757
+ formatImageRegion,
1605
1758
  formatImageZoom,
1759
+ getImageRegionFromCorners,
1606
1760
  getImageZoomScales,
1607
1761
  getNextImageZoom,
1608
1762
  getNormalizedImagePoint,
1609
1763
  getOpeningImageZoom,
1610
1764
  getPreviousImageZoom,
1765
+ placeImageRegion,
1611
1766
  resolveImageZoomScale
1612
1767
  };
@@ -26,7 +26,7 @@ import {
26
26
  PaginationPrevious2,
27
27
  PaginationNext2,
28
28
  PaginationEllipsis2
29
- } from "../../chunk-19bkeafb.js";
29
+ } from "../../chunk-rxmcz0j1.js";
30
30
  import {
31
31
  MenuPopup,
32
32
  MenuItem2,
@@ -94,7 +94,7 @@ import {
94
94
  CardContent2
95
95
  } from "../../chunk-r7krv555.js";
96
96
  import"../../chunk-mm3a9s11.js";
97
- import"../../chunk-23ppkypt.js";
97
+ import"../../chunk-me64e034.js";
98
98
  import {
99
99
  Tabs2,
100
100
  TabsList2,
@@ -155,6 +155,7 @@ import"../../chunk-m4geb1s5.js";
155
155
  import"../../chunk-9ecf92s6.js";
156
156
  import"../../chunk-fe33dx54.js";
157
157
  import"../../chunk-tcefvfr8.js";
158
+ import"../../chunk-38barrma.js";
158
159
  import"../../chunk-tcbjvdem.js";
159
160
  import {
160
161
  Carousel2,
package/dist/index.js CHANGED
@@ -180,7 +180,7 @@ import {
180
180
  StatusTracker2,
181
181
  DashboardLayout2,
182
182
  BillingUsage2
183
- } from "./chunk-19bkeafb.js";
183
+ } from "./chunk-rxmcz0j1.js";
184
184
  import {
185
185
  Combobox2,
186
186
  ComboboxValue2,
@@ -197,15 +197,8 @@ import {
197
197
  ComboboxChips2,
198
198
  ComboboxChip2,
199
199
  ComboboxChipsInput2,
200
- useComboboxAnchor2,
201
- NumberField2,
202
- NumberFieldGroup2,
203
- NumberFieldInput2,
204
- NumberFieldDecrement2,
205
- NumberFieldIncrement2,
206
- NumberFieldScrubArea2,
207
- NumberFieldScrubAreaCursor2
208
- } from "./chunk-23ppkypt.js";
200
+ useComboboxAnchor2
201
+ } from "./chunk-me64e034.js";
209
202
  import {
210
203
  Tabs2,
211
204
  tabsListVariants2,
@@ -221,6 +214,15 @@ import {
221
214
  DropTarget2,
222
215
  Kanban2
223
216
  } from "./chunk-02220n6y.js";
217
+ import {
218
+ NumberField2,
219
+ NumberFieldGroup2,
220
+ NumberFieldInput2,
221
+ NumberFieldDecrement2,
222
+ NumberFieldIncrement2,
223
+ NumberFieldScrubArea2,
224
+ NumberFieldScrubAreaCursor2
225
+ } from "./chunk-38barrma.js";
224
226
  import {
225
227
  Toolbar2,
226
228
  ToolbarButton2,
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.105",
2054
+ version: "0.0.106",
2055
2055
  description: "Sharp, monospace React components with compact and comfortable densities.",
2056
2056
  license: "MIT",
2057
2057
  repository: {
@@ -1,6 +1,6 @@
1
1
  # ImageViewer
2
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 framed image in a native scroll viewport. `fit` scales the image down proportionally to fit both dimensions, centered and without scrollbars, and never upscales it; `fit-width` fills the width and scrolls vertically; a number is a scale from the fitted one up to 4 (400%), so `1` shows natural size. Without `zoom` or `defaultZoom` it opens at `fit`, or at `fit-width` for an image much taller than the stage, and never narrower than `openingWidth`. Zooming keeps the viewed center. The stage, named "<alt>, <percent>", owns its gestures: a drag pans, two fingers pinch-zoom and Mod+wheel zooms around the pointer, so a touch never reaches overlay content unless it handles the pointer itself, such as `ImageRegionSelect`; while focused it takes + or = (zoom in), − (zoom out), 0 (fit), 1 (100%) and arrows (pan while larger than the stage), and `onStageKeyDown` runs first to add or replace keys. `showZoomControl` shows the zoom bar (Fit, Fit width, −, percent, +) in a toolbar row, and `toolbar` adds further controls to that row, which wraps onto further rows when its controls do not fit. `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.
3
+ Import from `@alexgorbatchev/shadcn/image-viewer`. ImageViewer fills the container it is given, such as a `DialogContent size="fullscreen"` body, and shows one framed image in a native scroll viewport. `fit` scales the image down proportionally to fit both dimensions, centered and without scrollbars, and never upscales it; `fit-width` fills the width and scrolls vertically; a number is a scale from the fitted one up to 4 (400%), so `1` shows natural size. Without `zoom` or `defaultZoom` it opens at `fit`, or at `fit-width` for an image much taller than the stage, and never narrower than `openingWidth`. Zooming keeps the viewed center. The stage, named "<alt>, <percent>", owns its gestures: a drag pans, two fingers pinch-zoom and Mod+wheel zooms around the pointer, so a touch never reaches overlay content unless it handles the pointer itself, such as `ImageRegionSelect`; while focused it takes + or = (zoom in), − (zoom out), 0 (fit), 1 (100%) and arrows (pan while larger than the stage), and `onStageKeyDown` runs first to add or replace keys. `showZoomControl` shows the zoom bar (Fit, Fit width, −, percent, +) in a toolbar row, and `toolbar` adds further controls to that row, which wraps onto further rows when its controls do not fit. `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. `ImageRegionSelect` is a region tool for the overlay: a drag draws a region, a click places a half-size region centred on it and a second click makes the two clicks opposite corners; it reports each region through `onRegionChange` and draws the placed `region` with its text form (`formatImageRegion`, "Region 60% × 50% at 25%, 25%") as its accessible name. For keyboard placement, `placeImageRegion()` gives the half-size region in the middle and `applyImageRegionKey(region, key, shiftKey)` moves it by 5% with arrows or resizes it with Shift+arrows from `onStageKeyDown`; `ImageRegionFields` shows Left, Top, Width and Height as percent fields that take typed values.
4
4
 
5
5
  Story: @alexgorbatchev/shadcn/components/data-display/ImageViewer
6
6
  Source: src/components/stories/data-display/ImageViewer.stories.tsx
@@ -10,7 +10,7 @@ Source: src/components/stories/data-display/ImageViewer.stories.tsx
10
10
  ## Public imports
11
11
 
12
12
  ```tsx
13
- import { ImageRegionMarker, ImageRegionSelect, ImageViewer, ImageZoomToggle, getNormalizedImagePoint, type IImageRect, type IImageViewerProps, type INormalizedImagePoint, type ImageZoom } from "@alexgorbatchev/shadcn/image-viewer";
13
+ import { ImageRegionFields, ImageRegionSelect, applyImageRegionKey, formatImageRegion, placeImageRegion, ImageViewer, ImageZoomToggle, getNormalizedImagePoint, type IImageRect, type IImageViewerProps, type INormalizedImagePoint, type ImageZoom } from "@alexgorbatchev/shadcn/image-viewer";
14
14
  import { Button, Toggle, Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from "@alexgorbatchev/shadcn";
15
15
  ```
16
16
 
package/llms.txt CHANGED
@@ -346,7 +346,7 @@ Generated from the public package exports and Storybook sources.
346
346
  - [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.
347
347
  - [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 when zoomed. Every mode starts fitted and offers original size (zoom `1`); the focused stage also takes the ImageViewer stage keys, Mod+wheel and pinch, and its name ends with the zoom percent. 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.
348
348
  - [ImageRegionMarker](./llms/components/data-display/ImageRegionMarker.md): Import from `@alexgorbatchev/shadcn/image-viewer`. Outlines a region over an image: a 2px outline 1px outside the region over a 4px halo in the page background, so the outline keeps 3:1 against any screenshot in both themes; forced colours draw it in Highlight. Variants: `comment` (a saved comment's region), `draft` (dashed, a region being drawn) and `difference` (changed pixels, used by ImageComparison's Highlight differences). Position it with `region` (left, top, width, height in pixels or any CSS length) over a positioned image box. `ImageRegionMarkerBadge` pins an interactive control, such as a comment count, beside the marker with the same outline and halo; place it with `position`, and pass `interactive={false}` while another gesture owns the pointer. The theme's `target-emphasis` utility is the matching two-tone mark for a jump target on the page.
349
- - [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 framed image in a native scroll viewport. `fit` scales the image down proportionally to fit both dimensions, centered and without scrollbars, and never upscales it; `fit-width` fills the width and scrolls vertically; a number is a scale from the fitted one up to 4 (400%), so `1` shows natural size. Without `zoom` or `defaultZoom` it opens at `fit`, or at `fit-width` for an image much taller than the stage, and never narrower than `openingWidth`. Zooming keeps the viewed center. The stage, named "<alt>, <percent>", owns its gestures: a drag pans, two fingers pinch-zoom and Mod+wheel zooms around the pointer, so a touch never reaches overlay content unless it handles the pointer itself, such as `ImageRegionSelect`; while focused it takes + or = (zoom in), − (zoom out), 0 (fit), 1 (100%) and arrows (pan while larger than the stage), and `onStageKeyDown` runs first to add or replace keys. `showZoomControl` shows the zoom bar (Fit, Fit width, −, percent, +) in a toolbar row, and `toolbar` adds further controls to that row, which wraps onto further rows when its controls do not fit. `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.
349
+ - [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 framed image in a native scroll viewport. `fit` scales the image down proportionally to fit both dimensions, centered and without scrollbars, and never upscales it; `fit-width` fills the width and scrolls vertically; a number is a scale from the fitted one up to 4 (400%), so `1` shows natural size. Without `zoom` or `defaultZoom` it opens at `fit`, or at `fit-width` for an image much taller than the stage, and never narrower than `openingWidth`. Zooming keeps the viewed center. The stage, named "<alt>, <percent>", owns its gestures: a drag pans, two fingers pinch-zoom and Mod+wheel zooms around the pointer, so a touch never reaches overlay content unless it handles the pointer itself, such as `ImageRegionSelect`; while focused it takes + or = (zoom in), − (zoom out), 0 (fit), 1 (100%) and arrows (pan while larger than the stage), and `onStageKeyDown` runs first to add or replace keys. `showZoomControl` shows the zoom bar (Fit, Fit width, −, percent, +) in a toolbar row, and `toolbar` adds further controls to that row, which wraps onto further rows when its controls do not fit. `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. `ImageRegionSelect` is a region tool for the overlay: a drag draws a region, a click places a half-size region centred on it and a second click makes the two clicks opposite corners; it reports each region through `onRegionChange` and draws the placed `region` with its text form (`formatImageRegion`, "Region 60% × 50% at 25%, 25%") as its accessible name. For keyboard placement, `placeImageRegion()` gives the half-size region in the middle and `applyImageRegionKey(region, key, shiftKey)` moves it by 5% with arrows or resizes it with Shift+arrows from `onStageKeyDown`; `ImageRegionFields` shows Left, Top, Width and Height as percent fields that take typed values.
350
350
  - [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`. Original size sets zoom `1`; other numeric zooms, such as 150% from the ImageViewer zoom bar, press neither option. `label` names the group (default "Zoom"); `size`, `orientation`, `layout`, `disabled`, and `density` follow ToggleGroup.
351
351
  - [Item](./llms/components/data-display/Item.md)
352
352
  - [JsonRender](./llms/components/data-display/JsonRender.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexgorbatchev/shadcn",
3
- "version": "0.0.105",
3
+ "version": "0.0.106",
4
4
  "description": "Sharp, monospace React components with compact and comfortable densities.",
5
5
  "license": "MIT",
6
6
  "repository": {