@alexgorbatchev/shadcn 0.0.148 → 0.0.151

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.
@@ -496,23 +496,39 @@ import { RadioGroup as RadioGroupPrimitive } from "@base-ui/react/radio-group";
496
496
  import { CheckIcon } from "lucide-react";
497
497
  import { jsx as jsx6, jsxs as jsxs4, Fragment as Fragment2 } from "react/jsx-runtime";
498
498
  "use client";
499
- var GROUP_CLASS = "grid w-full gap-2";
500
- function OptionCardGroup2({ analytics, density, className, ...props }) {
499
+ function getGroupClass(layout) {
500
+ return cn2("grid w-full gap-2", layout === "row" && "grid-cols-[repeat(auto-fit,minmax(min(100%,14rem),1fr))]");
501
+ }
502
+ function OptionCardGroup2({
503
+ analytics,
504
+ density,
505
+ layout = "stack",
506
+ className,
507
+ ...props
508
+ }) {
501
509
  const trackedOnValueChange = useAnalyticsCallback("OptionCardGroup", analytics, { name: "ui.change-request" }, props.onValueChange);
502
510
  return /* @__PURE__ */ jsx6(RadioGroupPrimitive, {
503
511
  "data-density": density,
504
512
  "data-slot": "option-card-group",
505
- className: (state) => cn2(GROUP_CLASS, typeof className === "function" ? className(state) : className),
513
+ "data-layout": layout,
514
+ className: (state) => cn2(getGroupClass(layout), typeof className === "function" ? className(state) : className),
506
515
  ...props,
507
516
  onValueChange: trackedOnValueChange
508
517
  });
509
518
  }
510
- function OptionCheckboxGroup2({ analytics, density, className, ...props }) {
519
+ function OptionCheckboxGroup2({
520
+ analytics,
521
+ density,
522
+ layout = "stack",
523
+ className,
524
+ ...props
525
+ }) {
511
526
  const trackedOnValueChange = useAnalyticsCallback("OptionCheckboxGroup", analytics, { name: "ui.change-request" }, props.onValueChange);
512
527
  return /* @__PURE__ */ jsx6(CheckboxGroupPrimitive, {
513
528
  "data-density": density,
514
529
  "data-slot": "option-checkbox-group",
515
- className: (state) => cn2(GROUP_CLASS, typeof className === "function" ? className(state) : className),
530
+ "data-layout": layout,
531
+ className: (state) => cn2(getGroupClass(layout), typeof className === "function" ? className(state) : className),
516
532
  ...props,
517
533
  onValueChange: trackedOnValueChange
518
534
  });
@@ -5,18 +5,26 @@ import { Checkbox as CheckboxPrimitive } from "@base-ui/react/checkbox";
5
5
  import { CheckboxGroup as CheckboxGroupPrimitive } from "@base-ui/react/checkbox-group";
6
6
  import { Radio as RadioPrimitive } from "@base-ui/react/radio";
7
7
  import { RadioGroup as RadioGroupPrimitive } from "@base-ui/react/radio-group";
8
- type OptionCardGroupProps = IAnalyticsProps & RadioGroupPrimitive.Props & IDensityProps;
8
+ /**
9
+ * How a group places its cards: `stack` (the default) puts one card per row; `row` puts cards side by side in equal
10
+ * columns at least 14rem wide, as many as the group's width fits, so options with images can be compared at a glance.
11
+ */
12
+ type OptionCardGroupLayout = "stack" | "row";
13
+ interface IOptionCardGroupLayoutProps {
14
+ layout?: OptionCardGroupLayout;
15
+ }
16
+ type OptionCardGroupProps = IAnalyticsProps & RadioGroupPrimitive.Props & IDensityProps & IOptionCardGroupLayoutProps;
9
17
  /**
10
18
  * A single-choice group of option cards. Each card is a radio: arrow keys move the selection between cards, Space
11
19
  * selects the focused card, and `name`, `required` and `form` take part in native form submission and validation.
12
20
  */
13
- declare function OptionCardGroup({ analytics, density, className, ...props }: OptionCardGroupProps): ReactElement;
14
- type OptionCheckboxGroupProps = IAnalyticsProps & CheckboxGroupPrimitive.Props & IDensityProps;
21
+ declare function OptionCardGroup({ analytics, density, layout, className, ...props }: OptionCardGroupProps): ReactElement;
22
+ type OptionCheckboxGroupProps = IAnalyticsProps & CheckboxGroupPrimitive.Props & IDensityProps & IOptionCardGroupLayoutProps;
15
23
  /**
16
24
  * A multiple-choice group of option cards, laid out like `OptionCardGroup`. Each card is a checkbox: Tab moves between
17
25
  * cards and Space toggles the focused one. `value` lists the checked cards' values.
18
26
  */
19
- declare function OptionCheckboxGroup({ analytics, density, className, ...props }: OptionCheckboxGroupProps): ReactElement;
27
+ declare function OptionCheckboxGroup({ analytics, density, layout, className, ...props }: OptionCheckboxGroupProps): ReactElement;
20
28
  interface IOptionCardContentProps {
21
29
  /** The option's name, shown in bold and used as its accessible name. */
22
30
  label: ReactNode;
@@ -1,6 +1,6 @@
1
1
  import { type ReactElement } from "react";
2
2
  import type { IDensityProps } from "../../density/types.js";
3
- import type { IImageComparisonSource, ImageComparisonMode, ImageComparisonOrientation, ImageZoom } from "./types.js";
3
+ import type { IImageComparisonSource, ImageComparisonMode, ImageComparisonOrientation, ImageComparisonSide, ImageZoom } from "./types.js";
4
4
  export interface IImageComparisonProps extends IDensityProps {
5
5
  before: IImageComparisonSource;
6
6
  after: IImageComparisonSource;
@@ -13,6 +13,11 @@ export interface IImageComparisonProps extends IDensityProps {
13
13
  /** Initial mode when uncontrolled. Defaults to `toggle`. */
14
14
  defaultMode?: ImageComparisonMode;
15
15
  onModeChange?: (mode: ImageComparisonMode) => void;
16
+ /** Controlled image shown in `toggle` mode. */
17
+ side?: ImageComparisonSide;
18
+ /** Initial image shown in `toggle` mode when uncontrolled. Defaults to `after`. */
19
+ defaultSide?: ImageComparisonSide;
20
+ onSideChange?: (side: ImageComparisonSide) => void;
16
21
  /** Controlled side-by-side arrangement. */
17
22
  orientation?: ImageComparisonOrientation;
18
23
  /** Initial side-by-side arrangement when uncontrolled. Defaults to `horizontal` (left and right). */
@@ -38,4 +43,4 @@ export interface IImageComparisonProps extends IDensityProps {
38
43
  * fitted to the available space and offers original size with scrolling. A differently sized before image is drawn
39
44
  * inside the after image's box. Highlighting differences compares pixels on first use and caches the result per pair.
40
45
  */
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;
46
+ export declare function ImageComparison({ before, after, beforeLabel, afterLabel, mode: modeProp, defaultMode, onModeChange, side: sideProp, defaultSide, onSideChange, orientation: orientationProp, defaultOrientation, onOrientationChange, zoom: zoomProp, defaultZoom, onZoomChange, showDifferences: showDifferencesProp, defaultShowDifferences, onShowDifferencesChange, showToolbar, label, density, }: IImageComparisonProps): ReactElement;
@@ -1,9 +1,11 @@
1
1
  import { type ReactElement } from "react";
2
2
  import type { IDensityProps } from "../../density/types.js";
3
- import type { IImageSize, ImageComparisonMode, ImageComparisonOrientation, ImageDifferenceState, ImageZoom } from "./types.js";
3
+ import type { IImageSize, ImageComparisonMode, ImageComparisonOrientation, ImageComparisonSide, ImageDifferenceState, ImageZoom } from "./types.js";
4
4
  interface IImageComparisonToolbarProps extends IDensityProps {
5
5
  mode: ImageComparisonMode;
6
6
  onModeChange: (mode: ImageComparisonMode) => void;
7
+ side: ImageComparisonSide;
8
+ onSideChange: (side: ImageComparisonSide) => void;
7
9
  orientation: ImageComparisonOrientation;
8
10
  onOrientationChange: (orientation: ImageComparisonOrientation) => void;
9
11
  zoom: ImageZoom;
@@ -18,5 +20,5 @@ interface IImageComparisonToolbarProps extends IDensityProps {
18
20
  afterSize?: IImageSize;
19
21
  }
20
22
  /** 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;
23
+ export declare function ImageComparisonToolbar({ mode, onModeChange, side, onSideChange, orientation, onOrientationChange, zoom, onZoomChange, showDifferences, onShowDifferencesChange, differences, onPeekChange, beforeLabel, afterLabel, beforeSize, afterSize, density, }: IImageComparisonToolbarProps): ReactElement;
22
24
  export {};
@@ -0,0 +1,41 @@
1
+ import { type KeyboardEvent, type ReactElement, type ReactNode, type Ref } from "react";
2
+ import type { IDensityProps } from "../../density/types.js";
3
+ export interface IImageGalleryItem {
4
+ /** Stable identity of the item, such as an option value. */
5
+ key: string;
6
+ src: string;
7
+ alt: string;
8
+ /** The item's name, used in the step announcement: "Bold · 2 of 3". */
9
+ label: string;
10
+ }
11
+ export interface IImageGalleryProps extends IDensityProps {
12
+ items: readonly IImageGalleryItem[];
13
+ /** The shown item's position in `items`. */
14
+ index: number;
15
+ onIndexChange: (index: number) => void;
16
+ /** Width in CSS pixels the first shown image had where it was opened from; see `ImageViewer`. */
17
+ openingWidth?: number;
18
+ /** Accessible name of the stage, followed by the zoom percent. Defaults to the shown item's label. */
19
+ label?: string;
20
+ /** Accessible name of the step back button. Defaults to "Previous image". */
21
+ previousLabel?: string;
22
+ /** Accessible name of the step forward button. Defaults to "Next image". */
23
+ nextLabel?: string;
24
+ /** Further controls in the toolbar row after the stepper, such as a Choose action. */
25
+ toolbar?: ReactNode;
26
+ /** Content positioned over the shown image; see `ImageViewer`. */
27
+ overlay?: ReactNode;
28
+ imageRef?: Ref<HTMLImageElement>;
29
+ stageRef?: Ref<HTMLDivElement>;
30
+ /** Runs for keys on the focused stage before the gallery's own; call `preventDefault()` to replace one. */
31
+ onStageKeyDown?: (event: KeyboardEvent<HTMLDivElement>) => void;
32
+ /** Further `aria-keyshortcuts` of the stage, such as "R". */
33
+ stageKeyShortcuts?: string;
34
+ }
35
+ /**
36
+ * Steps through a set of images in one `ImageViewer`, keeping its zoom and viewed position, so the same area of each
37
+ * image can be compared. The toolbar holds the zoom bar, Previous, "2 of 3" and Next, then `toolbar`; Left and Right
38
+ * step on the focused stage only at Fit, where arrows do not pan. Each step is announced politely with the item's
39
+ * label and position. Compose it inside `MediaShell` and name the shell after the shown item.
40
+ */
41
+ export declare function ImageGallery({ items, index, onIndexChange, openingWidth, label, previousLabel, nextLabel, toolbar, overlay, imageRef, stageRef, onStageKeyDown, stageKeyShortcuts, density, }: IImageGalleryProps): ReactElement;
@@ -0,0 +1,19 @@
1
+ import type { ComponentProps, ReactElement, ReactNode } from "react";
2
+ import type { IDensityProps } from "../../density/types.js";
3
+ import { Dialog } from "../Dialog.js";
4
+ export interface IMediaShellProps extends IDensityProps {
5
+ open: boolean;
6
+ /** Receives Base UI's change details, so Escape can close an inner layer first by calling `details.cancel()`. */
7
+ onOpenChange: ComponentProps<typeof Dialog>["onOpenChange"];
8
+ /** The shown item's name, such as an image's alt text or an option's label. Truncates to one line. */
9
+ title: ReactNode;
10
+ /** A one-line hint or status under the title, such as the keys the stage takes. */
11
+ description?: ReactNode;
12
+ /** The stage: an `ImageViewer`, `ImageGallery` or `ImageComparison`, optionally inside a side panel layout. */
13
+ children: ReactNode;
14
+ }
15
+ /**
16
+ * The full-screen shell every image, comparison, gallery and diagram opens in: a header with the shown item's name, a
17
+ * hint line and an always visible Close, then a stage that fills the rest of the screen. Escape and Close close it.
18
+ */
19
+ export declare function MediaShell({ open, onOpenChange, title, description, children, density, }: IMediaShellProps): ReactElement;
@@ -11,11 +11,15 @@ export type { IImageRegionFieldsProps } from "./ImageRegionFields.js";
11
11
  export { IMAGE_REGION_STEP, MIN_IMAGE_REGION_SIZE, applyImageRegionKey, clampImageRegion, formatImageRegion, getImageRegionFromCorners, placeImageRegion, } from "./imageRegion.js";
12
12
  export { FramedImage } from "./FramedImage.js";
13
13
  export type { FramedImageSize, IFramedImageProps } from "./FramedImage.js";
14
+ export { ImageGallery } from "./ImageGallery.js";
15
+ export type { IImageGalleryItem, IImageGalleryProps } from "./ImageGallery.js";
16
+ export { MediaShell } from "./MediaShell.js";
17
+ export type { IMediaShellProps } from "./MediaShell.js";
14
18
  export { ImageComparison } from "./ImageComparison.js";
15
19
  export type { IImageComparisonProps } from "./ImageComparison.js";
16
20
  export { computeImageDiff } from "./computeImageDiff.js";
17
21
  export { getNormalizedImagePoint } from "./getNormalizedImagePoint.js";
18
22
  export { IMAGE_ZOOM_STEPS, MAX_IMAGE_ZOOM, formatImageZoom, getImageZoomScales, getNextImageZoom, getOpeningImageZoom, getPreviousImageZoom, resolveImageZoomScale, } from "./imageZoom.js";
19
- export type { IImageComparisonSource, IImageDiff, IImageDiffOptions, IImageDiffRegion, IImagePixels, IImageRect, IImageSize, IImageZoomScales, INormalizedImagePoint, ImageComparisonMode, ImageComparisonOrientation, ImageZoom, } from "./types.js";
23
+ export type { IImageComparisonSource, IImageDiff, IImageDiffOptions, IImageDiffRegion, IImagePixels, IImageRect, IImageSize, IImageZoomScales, INormalizedImagePoint, ImageComparisonMode, ImageComparisonOrientation, ImageComparisonSide, ImageZoom, } from "./types.js";
20
24
  export { ImageRegionMarker, ImageRegionMarkerBadge } from "./ImageRegionMarker.js";
21
25
  export type { IImageRegionBadgePosition, IImageRegionBox, IImageRegionMarkerProps, IImageRegionMarkerBadgeProps, ImageRegionLength, ImageRegionMarkerVariant, } from "./ImageRegionMarker.js";
@@ -35,6 +35,13 @@ import {
35
35
  import {
36
36
  FramedImage2
37
37
  } from "../../chunk-2jsgsjas.js";
38
+ import {
39
+ Dialog2,
40
+ DialogContent2,
41
+ DialogHeader2,
42
+ DialogTitle2,
43
+ DialogDescription2
44
+ } from "../../chunk-d22t4qx6.js";
38
45
  import {
39
46
  Switch2
40
47
  } from "../../chunk-m98d89xc.js";
@@ -880,20 +887,174 @@ function ImageRegionFields({
880
887
  ]
881
888
  });
882
889
  }
890
+ // src/components/image-viewer/ImageGallery.tsx
891
+ import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
892
+ import { useState as useState4 } from "react";
893
+ import { jsx as jsx8, jsxs as jsxs5, Fragment } from "react/jsx-runtime";
894
+ function isFitted(stage) {
895
+ return stage.closest("[data-slot=image-viewer]")?.getAttribute("data-zoom") === "fit";
896
+ }
897
+ function ImageGallery({
898
+ items,
899
+ index,
900
+ onIndexChange,
901
+ openingWidth,
902
+ label,
903
+ previousLabel = "Previous image",
904
+ nextLabel = "Next image",
905
+ toolbar,
906
+ overlay,
907
+ imageRef,
908
+ stageRef,
909
+ onStageKeyDown,
910
+ stageKeyShortcuts,
911
+ density
912
+ }) {
913
+ const [announcement, setAnnouncement] = useState4("");
914
+ const item = items[index];
915
+ const count = items.length;
916
+ function step(next) {
917
+ const target = items[next];
918
+ if (!target)
919
+ return;
920
+ setAnnouncement(`${target.label} · ${next + 1} of ${count}`);
921
+ onIndexChange(next);
922
+ }
923
+ function handleStageKey(event) {
924
+ onStageKeyDown?.(event);
925
+ if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)
926
+ return;
927
+ if (event.key !== "ArrowLeft" && event.key !== "ArrowRight")
928
+ return;
929
+ if (!isFitted(event.currentTarget))
930
+ return;
931
+ event.preventDefault();
932
+ step(event.key === "ArrowLeft" ? index - 1 : index + 1);
933
+ }
934
+ if (!item)
935
+ return /* @__PURE__ */ jsx8("div", {
936
+ "data-slot": "image-gallery",
937
+ "data-density": density
938
+ });
939
+ return /* @__PURE__ */ jsxs5("div", {
940
+ "data-slot": "image-gallery",
941
+ "data-scroll": "none",
942
+ "data-density": density,
943
+ className: "flex size-full min-h-0 min-w-0 flex-1 flex-col",
944
+ children: [
945
+ /* @__PURE__ */ jsx8(ImageViewer, {
946
+ src: item.src,
947
+ alt: item.alt,
948
+ label: label ?? item.label,
949
+ openingWidth,
950
+ showZoomControl: true,
951
+ imageRef,
952
+ stageRef,
953
+ overlay,
954
+ onStageKeyDown: handleStageKey,
955
+ stageKeyShortcuts,
956
+ density,
957
+ toolbar: /* @__PURE__ */ jsxs5(Fragment, {
958
+ children: [
959
+ /* @__PURE__ */ jsxs5("div", {
960
+ role: "group",
961
+ "aria-label": "Images",
962
+ "data-slot": "image-gallery-stepper",
963
+ className: "flex items-center gap-control-gap",
964
+ children: [
965
+ /* @__PURE__ */ jsx8(Button2, {
966
+ variant: "outline",
967
+ size: "icon-sm",
968
+ "aria-label": previousLabel,
969
+ disabledReason: index === 0 ? "This is the first image" : undefined,
970
+ onClick: () => step(index - 1),
971
+ children: /* @__PURE__ */ jsx8(ChevronLeftIcon, {})
972
+ }),
973
+ /* @__PURE__ */ jsxs5("span", {
974
+ "data-slot": "image-gallery-position",
975
+ className: "text-xs text-muted-foreground tabular-nums",
976
+ children: [
977
+ index + 1,
978
+ " of ",
979
+ count
980
+ ]
981
+ }),
982
+ /* @__PURE__ */ jsx8(Button2, {
983
+ variant: "outline",
984
+ size: "icon-sm",
985
+ "aria-label": nextLabel,
986
+ disabledReason: index === count - 1 ? "This is the last image" : undefined,
987
+ onClick: () => step(index + 1),
988
+ children: /* @__PURE__ */ jsx8(ChevronRightIcon, {})
989
+ })
990
+ ]
991
+ }),
992
+ toolbar
993
+ ]
994
+ })
995
+ }),
996
+ /* @__PURE__ */ jsx8("p", {
997
+ role: "status",
998
+ "data-slot": "image-gallery-status",
999
+ className: "sr-only",
1000
+ children: announcement
1001
+ })
1002
+ ]
1003
+ });
1004
+ }
1005
+ // src/components/image-viewer/MediaShell.tsx
1006
+ import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
1007
+ function MediaShell({
1008
+ open,
1009
+ onOpenChange,
1010
+ title,
1011
+ description,
1012
+ children,
1013
+ density
1014
+ }) {
1015
+ return /* @__PURE__ */ jsx9(Dialog2, {
1016
+ open,
1017
+ onOpenChange,
1018
+ children: /* @__PURE__ */ jsxs6(DialogContent2, {
1019
+ size: "fullscreen",
1020
+ density,
1021
+ "data-slot": "media-shell",
1022
+ children: [
1023
+ /* @__PURE__ */ jsxs6(DialogHeader2, {
1024
+ children: [
1025
+ /* @__PURE__ */ jsx9(DialogTitle2, {
1026
+ className: "truncate",
1027
+ children: title
1028
+ }),
1029
+ description !== undefined && /* @__PURE__ */ jsx9(DialogDescription2, {
1030
+ children: description
1031
+ })
1032
+ ]
1033
+ }),
1034
+ /* @__PURE__ */ jsx9("div", {
1035
+ "data-slot": "media-shell-stage",
1036
+ "data-scroll": "none",
1037
+ className: "flex min-h-0 min-w-0 flex-1 flex-col",
1038
+ children
1039
+ })
1040
+ ]
1041
+ })
1042
+ });
1043
+ }
883
1044
  // src/components/image-viewer/ImageComparison.tsx
884
1045
  import { useControlled as useControlled2 } from "@base-ui/utils/useControlled";
885
- import { useRef as useRef5, useState as useState5 } from "react";
1046
+ import { useRef as useRef5, useState as useState6 } from "react";
886
1047
 
887
1048
  // src/components/image-viewer/ImageComparisonToolbar.tsx
888
1049
  import { Columns2Icon, Rows2Icon } from "lucide-react";
889
1050
  import { useId as useId2 } from "react";
890
- import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
1051
+ import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
891
1052
  function ToolbarSection({ title, titleId, children }) {
892
- return /* @__PURE__ */ jsxs5("div", {
1053
+ return /* @__PURE__ */ jsxs7("div", {
893
1054
  "data-slot": "image-comparison-toolbar-section",
894
1055
  className: "flex min-w-0 flex-col gap-1.5",
895
1056
  children: [
896
- /* @__PURE__ */ jsx8("span", {
1057
+ /* @__PURE__ */ jsx10("span", {
897
1058
  id: titleId,
898
1059
  className: "sr-only text-xs font-medium text-muted-foreground @3xl:not-sr-only",
899
1060
  children: title
@@ -926,6 +1087,8 @@ function formatSize(size) {
926
1087
  function ImageComparisonToolbar({
927
1088
  mode,
928
1089
  onModeChange,
1090
+ side,
1091
+ onSideChange,
929
1092
  orientation,
930
1093
  onOrientationChange,
931
1094
  zoom,
@@ -944,17 +1107,17 @@ function ImageComparisonToolbar({
944
1107
  const isUnavailable = differences.status === "unavailable";
945
1108
  const releasePeek = () => onPeekChange(false);
946
1109
  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;
947
- return /* @__PURE__ */ jsxs5("div", {
1110
+ return /* @__PURE__ */ jsxs7("div", {
948
1111
  role: "group",
949
1112
  "aria-label": "Comparison controls",
950
1113
  "data-slot": "image-comparison-toolbar",
951
1114
  "data-density": density,
952
1115
  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",
953
1116
  children: [
954
- /* @__PURE__ */ jsx8(ToolbarSection, {
1117
+ /* @__PURE__ */ jsx10(ToolbarSection, {
955
1118
  title: "Mode",
956
1119
  titleId: `${id}-mode`,
957
- children: /* @__PURE__ */ jsxs5(ToggleGroup2, {
1120
+ children: /* @__PURE__ */ jsxs7(ToggleGroup2, {
958
1121
  "aria-labelledby": `${id}-mode`,
959
1122
  required: true,
960
1123
  value: [mode],
@@ -963,25 +1126,50 @@ function ImageComparisonToolbar({
963
1126
  size: "sm",
964
1127
  spacing: 0,
965
1128
  children: [
966
- /* @__PURE__ */ jsx8(ToggleGroupItem2, {
1129
+ /* @__PURE__ */ jsx10(ToggleGroupItem2, {
967
1130
  value: "toggle",
968
1131
  children: "Toggle"
969
1132
  }),
970
- /* @__PURE__ */ jsx8(ToggleGroupItem2, {
1133
+ /* @__PURE__ */ jsx10(ToggleGroupItem2, {
971
1134
  value: "swipe",
972
1135
  children: "Swipe"
973
1136
  }),
974
- /* @__PURE__ */ jsx8(ToggleGroupItem2, {
1137
+ /* @__PURE__ */ jsx10(ToggleGroupItem2, {
975
1138
  value: "side-by-side",
976
1139
  children: "Side by side"
977
1140
  })
978
1141
  ]
979
1142
  })
980
1143
  }),
981
- /* @__PURE__ */ jsx8(ToolbarSection, {
1144
+ /* @__PURE__ */ jsx10(ToolbarSection, {
1145
+ title: "Shown image",
1146
+ titleId: `${id}-side`,
1147
+ children: /* @__PURE__ */ jsxs7(ToggleGroup2, {
1148
+ "aria-labelledby": `${id}-side`,
1149
+ "aria-keyshortcuts": "B A",
1150
+ required: true,
1151
+ value: [side],
1152
+ onValueChange: (value) => onSideChange(value[0] === "before" ? "before" : "after"),
1153
+ variant: "outline",
1154
+ size: "sm",
1155
+ spacing: 0,
1156
+ disabled: mode !== "toggle",
1157
+ children: [
1158
+ /* @__PURE__ */ jsx10(ToggleGroupItem2, {
1159
+ value: "before",
1160
+ children: beforeLabel
1161
+ }),
1162
+ /* @__PURE__ */ jsx10(ToggleGroupItem2, {
1163
+ value: "after",
1164
+ children: afterLabel
1165
+ })
1166
+ ]
1167
+ })
1168
+ }),
1169
+ /* @__PURE__ */ jsx10(ToolbarSection, {
982
1170
  title: "Orientation",
983
1171
  titleId: `${id}-orientation`,
984
- children: /* @__PURE__ */ jsxs5(ToggleGroup2, {
1172
+ children: /* @__PURE__ */ jsxs7(ToggleGroup2, {
985
1173
  "aria-labelledby": `${id}-orientation`,
986
1174
  required: true,
987
1175
  value: [orientation],
@@ -991,19 +1179,19 @@ function ImageComparisonToolbar({
991
1179
  spacing: 0,
992
1180
  disabled: mode !== "side-by-side",
993
1181
  children: [
994
- /* @__PURE__ */ jsxs5(ToggleGroupItem2, {
1182
+ /* @__PURE__ */ jsxs7(ToggleGroupItem2, {
995
1183
  value: "horizontal",
996
1184
  children: [
997
- /* @__PURE__ */ jsx8(Columns2Icon, {
1185
+ /* @__PURE__ */ jsx10(Columns2Icon, {
998
1186
  "data-icon": "inline-start"
999
1187
  }),
1000
1188
  "Horizontal"
1001
1189
  ]
1002
1190
  }),
1003
- /* @__PURE__ */ jsxs5(ToggleGroupItem2, {
1191
+ /* @__PURE__ */ jsxs7(ToggleGroupItem2, {
1004
1192
  value: "vertical",
1005
1193
  children: [
1006
- /* @__PURE__ */ jsx8(Rows2Icon, {
1194
+ /* @__PURE__ */ jsx10(Rows2Icon, {
1007
1195
  "data-icon": "inline-start"
1008
1196
  }),
1009
1197
  "Vertical"
@@ -1012,15 +1200,15 @@ function ImageComparisonToolbar({
1012
1200
  ]
1013
1201
  })
1014
1202
  }),
1015
- /* @__PURE__ */ jsx8(ToolbarSection, {
1203
+ /* @__PURE__ */ jsx10(ToolbarSection, {
1016
1204
  title: "Zoom",
1017
1205
  titleId: `${id}-zoom`,
1018
- children: /* @__PURE__ */ jsx8(ImageZoomToggle, {
1206
+ children: /* @__PURE__ */ jsx10(ImageZoomToggle, {
1019
1207
  zoom,
1020
1208
  onZoomChange
1021
1209
  })
1022
1210
  }),
1023
- /* @__PURE__ */ jsx8(Button2, {
1211
+ /* @__PURE__ */ jsx10(Button2, {
1024
1212
  variant: "outline",
1025
1213
  size: "sm",
1026
1214
  disabled: mode !== "toggle",
@@ -1042,29 +1230,29 @@ function ImageComparisonToolbar({
1042
1230
  },
1043
1231
  onBlur: releasePeek,
1044
1232
  onContextMenu: (event) => event.preventDefault(),
1045
- children: "Hold to show before"
1233
+ children: `Hold to show ${side === "before" ? "after" : "before"}`
1046
1234
  }),
1047
- /* @__PURE__ */ jsxs5(Field2, {
1235
+ /* @__PURE__ */ jsxs7(Field2, {
1048
1236
  orientation: "horizontal",
1049
1237
  children: [
1050
- /* @__PURE__ */ jsx8(Switch2, {
1238
+ /* @__PURE__ */ jsx10(Switch2, {
1051
1239
  id: `${id}-differences`,
1052
1240
  "aria-describedby": `${id}-differences-status`,
1053
1241
  checked: showDifferences && !isUnavailable,
1054
1242
  disabled: isUnavailable,
1055
1243
  onCheckedChange: onShowDifferencesChange
1056
1244
  }),
1057
- /* @__PURE__ */ jsxs5(FieldContent2, {
1245
+ /* @__PURE__ */ jsxs7(FieldContent2, {
1058
1246
  children: [
1059
- /* @__PURE__ */ jsx8(FieldLabel2, {
1247
+ /* @__PURE__ */ jsx10(FieldLabel2, {
1060
1248
  htmlFor: `${id}-differences`,
1061
1249
  children: "Highlight differences"
1062
1250
  }),
1063
- showDifferences && differences.status === "ready" && /* @__PURE__ */ jsxs5(FieldDescription2, {
1251
+ showDifferences && differences.status === "ready" && /* @__PURE__ */ jsxs7(FieldDescription2, {
1064
1252
  "data-slot": "image-comparison-legend",
1065
1253
  className: "flex items-center gap-1.5",
1066
1254
  children: [
1067
- /* @__PURE__ */ jsx8("span", {
1255
+ /* @__PURE__ */ jsx10("span", {
1068
1256
  "aria-hidden": "true",
1069
1257
  className: "mx-[3px] size-2.5 shrink-0 rounded-xs bg-warning/10 ring-1 ring-background outline-2 outline-offset-1 outline-warning"
1070
1258
  }),
@@ -1075,16 +1263,16 @@ function ImageComparisonToolbar({
1075
1263
  })
1076
1264
  ]
1077
1265
  }),
1078
- /* @__PURE__ */ jsxs5("div", {
1266
+ /* @__PURE__ */ jsxs7("div", {
1079
1267
  "data-slot": "image-comparison-status",
1080
1268
  className: "flex min-w-0 flex-col gap-1 text-xs text-muted-foreground",
1081
1269
  children: [
1082
- /* @__PURE__ */ jsx8("p", {
1270
+ /* @__PURE__ */ jsx10("p", {
1083
1271
  id: `${id}-differences-status`,
1084
1272
  role: "status",
1085
1273
  children: describeDifferences(differences, showDifferences)
1086
1274
  }),
1087
- sizeMismatch && /* @__PURE__ */ jsx8("p", {
1275
+ sizeMismatch && /* @__PURE__ */ jsx10("p", {
1088
1276
  "data-slot": "image-comparison-size-mismatch",
1089
1277
  children: sizeMismatch
1090
1278
  })
@@ -1095,16 +1283,16 @@ function ImageComparisonToolbar({
1095
1283
  }
1096
1284
 
1097
1285
  // src/components/image-viewer/ImageDifferenceOverlay.tsx
1098
- import { jsx as jsx9 } from "react/jsx-runtime";
1286
+ import { jsx as jsx11 } from "react/jsx-runtime";
1099
1287
  function toPercent2(value, total) {
1100
1288
  return `${value / total * 100}%`;
1101
1289
  }
1102
1290
  function ImageDifferenceOverlay({ diff }) {
1103
- return /* @__PURE__ */ jsx9("div", {
1291
+ return /* @__PURE__ */ jsx11("div", {
1104
1292
  "data-slot": "image-difference-overlay",
1105
1293
  "aria-hidden": "true",
1106
1294
  className: "pointer-events-none absolute inset-0",
1107
- children: diff.regions.map((region) => /* @__PURE__ */ jsx9(ImageRegionMarker, {
1295
+ children: diff.regions.map((region) => /* @__PURE__ */ jsx11(ImageRegionMarker, {
1108
1296
  "data-slot": "image-difference-region",
1109
1297
  variant: "difference",
1110
1298
  region: {
@@ -1121,16 +1309,16 @@ function ImageDifferenceOverlay({ diff }) {
1121
1309
  import { DirectionProvider } from "@base-ui/react/direction-provider";
1122
1310
  import { Slider as SliderPrimitive } from "@base-ui/react/slider";
1123
1311
  import { ChevronsLeftRightIcon } from "lucide-react";
1124
- import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
1312
+ import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
1125
1313
  function ImageSwipeDivider({
1126
1314
  value,
1127
1315
  onValueChange,
1128
1316
  beforeLabel,
1129
1317
  afterLabel
1130
1318
  }) {
1131
- return /* @__PURE__ */ jsx10(DirectionProvider, {
1319
+ return /* @__PURE__ */ jsx12(DirectionProvider, {
1132
1320
  direction: "ltr",
1133
- children: /* @__PURE__ */ jsx10(SliderPrimitive.Root, {
1321
+ children: /* @__PURE__ */ jsx12(SliderPrimitive.Root, {
1134
1322
  dir: "ltr",
1135
1323
  "data-slot": "image-swipe-divider",
1136
1324
  value,
@@ -1140,22 +1328,22 @@ function ImageSwipeDivider({
1140
1328
  step: 1,
1141
1329
  largeStep: 10,
1142
1330
  className: "pointer-events-none absolute inset-0",
1143
- children: /* @__PURE__ */ jsx10(SliderPrimitive.Control, {
1331
+ children: /* @__PURE__ */ jsx12(SliderPrimitive.Control, {
1144
1332
  className: "pointer-events-none absolute inset-0",
1145
- children: /* @__PURE__ */ jsxs6(SliderPrimitive.Thumb, {
1333
+ children: /* @__PURE__ */ jsxs8(SliderPrimitive.Thumb, {
1146
1334
  "data-slot": "image-swipe-divider-handle",
1147
1335
  getAriaLabel: () => "Swipe divider",
1148
1336
  getAriaValueText: (_formatted, current) => `${beforeLabel} ${current}%, ${afterLabel} ${100 - current}%`,
1149
1337
  className: "group/divider pointer-events-auto flex h-full w-6 cursor-ew-resize touch-none flex-col items-center justify-center select-none",
1150
1338
  children: [
1151
- /* @__PURE__ */ jsx10("span", {
1339
+ /* @__PURE__ */ jsx12("span", {
1152
1340
  "aria-hidden": "true",
1153
1341
  className: "absolute inset-y-0 start-1/2 w-0.5 -translate-x-1/2 bg-foreground ring-1 ring-background"
1154
1342
  }),
1155
- /* @__PURE__ */ jsx10("span", {
1343
+ /* @__PURE__ */ jsx12("span", {
1156
1344
  "aria-hidden": "true",
1157
1345
  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",
1158
- children: /* @__PURE__ */ jsx10(ChevronsLeftRightIcon, {
1346
+ children: /* @__PURE__ */ jsx12(ChevronsLeftRightIcon, {
1159
1347
  className: "size-3.5"
1160
1348
  })
1161
1349
  })
@@ -1167,7 +1355,7 @@ function ImageSwipeDivider({
1167
1355
  }
1168
1356
 
1169
1357
  // src/components/image-viewer/hooks/useImageDifferences.ts
1170
- import { useEffect as useEffect2, useRef as useRef4, useState as useState4 } from "react";
1358
+ import { useEffect as useEffect2, useRef as useRef4, useState as useState5 } from "react";
1171
1359
 
1172
1360
  // src/components/image-viewer/computeImageDiff.ts
1173
1361
  var DEFAULT_THRESHOLD = 32;
@@ -1380,7 +1568,7 @@ function useImageDifferences({
1380
1568
  beforeRef,
1381
1569
  afterRef
1382
1570
  }) {
1383
- const [entries, setEntries] = useState4(() => new Map);
1571
+ const [entries, setEntries] = useState5(() => new Map);
1384
1572
  const startedRef = useRef4(new Set);
1385
1573
  const controllerRef = useRef4(undefined);
1386
1574
  useEffect2(() => () => controllerRef.current?.abort(), [pairKey]);
@@ -1421,14 +1609,14 @@ function useImageDifferences({
1421
1609
  }
1422
1610
 
1423
1611
  // src/components/image-viewer/ImageComparison.tsx
1424
- import { jsx as jsx11, jsxs as jsxs7, Fragment } from "react/jsx-runtime";
1612
+ import { jsx as jsx13, jsxs as jsxs9, Fragment as Fragment2 } from "react/jsx-runtime";
1425
1613
  function ComparisonPane({ header, children }) {
1426
- return /* @__PURE__ */ jsxs7("div", {
1614
+ return /* @__PURE__ */ jsxs9("div", {
1427
1615
  "data-slot": "image-comparison-pane",
1428
1616
  "data-scroll": "none",
1429
1617
  className: "flex min-h-0 min-w-0 flex-1 flex-col",
1430
1618
  children: [
1431
- /* @__PURE__ */ jsx11("div", {
1619
+ /* @__PURE__ */ jsx13("div", {
1432
1620
  "data-slot": "image-comparison-pane-header",
1433
1621
  className: "flex h-control shrink-0 items-center justify-between gap-2 px-control-x text-xs font-medium text-muted-foreground",
1434
1622
  children: header
@@ -1445,6 +1633,9 @@ function ImageComparison({
1445
1633
  mode: modeProp,
1446
1634
  defaultMode = "toggle",
1447
1635
  onModeChange,
1636
+ side: sideProp,
1637
+ defaultSide = "after",
1638
+ onSideChange,
1448
1639
  orientation: orientationProp,
1449
1640
  defaultOrientation = "horizontal",
1450
1641
  onOrientationChange,
@@ -1464,6 +1655,12 @@ function ImageComparison({
1464
1655
  name: "ImageComparison",
1465
1656
  state: "mode"
1466
1657
  });
1658
+ const [side, setSideState] = useControlled2({
1659
+ controlled: sideProp,
1660
+ default: defaultSide,
1661
+ name: "ImageComparison",
1662
+ state: "side"
1663
+ });
1467
1664
  const [orientation, setOrientationState] = useControlled2({
1468
1665
  controlled: orientationProp,
1469
1666
  default: defaultOrientation,
@@ -1482,8 +1679,8 @@ function ImageComparison({
1482
1679
  name: "ImageComparison",
1483
1680
  state: "showDifferences"
1484
1681
  });
1485
- const [isPeeking, setIsPeeking] = useState5(false);
1486
- const [position, setPosition] = useState5(50);
1682
+ const [isPeeking, setIsPeeking] = useState6(false);
1683
+ const [position, setPosition] = useState6(50);
1487
1684
  const [beforeImage, beforeHandlers] = useImageLoad(before.src);
1488
1685
  const [afterImage, afterHandlers] = useImageLoad(after.src);
1489
1686
  const beforeRef = useRef5(null);
@@ -1502,11 +1699,12 @@ ${after.src}`,
1502
1699
  beforeRef,
1503
1700
  afterRef
1504
1701
  });
1505
- const isShowingBefore = mode === "toggle" && isPeeking;
1506
- const overlay = showDifferences && differences.status === "ready" ? /* @__PURE__ */ jsx11(ImageDifferenceOverlay, {
1702
+ const shownSide = mode !== "toggle" ? "after" : isPeeking ? side === "before" ? "after" : "before" : side;
1703
+ const isShowingBefore = shownSide === "before";
1704
+ const overlay = showDifferences && differences.status === "ready" ? /* @__PURE__ */ jsx13(ImageDifferenceOverlay, {
1507
1705
  diff: differences.diff
1508
1706
  }) : null;
1509
- const fallback = failedLabel ? /* @__PURE__ */ jsxs7("p", {
1707
+ const fallback = failedLabel ? /* @__PURE__ */ jsxs9("p", {
1510
1708
  "data-slot": "image-comparison-error",
1511
1709
  className: "m-auto p-panel text-center text-sm text-muted-foreground",
1512
1710
  children: [
@@ -1519,6 +1717,19 @@ ${after.src}`,
1519
1717
  setModeState(next);
1520
1718
  onModeChange?.(next);
1521
1719
  }
1720
+ function setSide(next) {
1721
+ setSideState(next);
1722
+ onSideChange?.(next);
1723
+ }
1724
+ function handleToggleStageKey(event) {
1725
+ if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)
1726
+ return;
1727
+ const key = event.key.toLowerCase();
1728
+ if (key !== "b" && key !== "a")
1729
+ return;
1730
+ event.preventDefault();
1731
+ setSide(key === "b" ? "before" : "after");
1732
+ }
1522
1733
  function setOrientation(next) {
1523
1734
  setOrientationState(next);
1524
1735
  onOrientationChange?.(next);
@@ -1544,7 +1755,7 @@ ${after.src}`,
1544
1755
  }
1545
1756
  }
1546
1757
  function renderAfterImage(className) {
1547
- return /* @__PURE__ */ jsx11("img", {
1758
+ return /* @__PURE__ */ jsx13("img", {
1548
1759
  ref: afterRef,
1549
1760
  src: after.src,
1550
1761
  alt: after.alt,
@@ -1557,7 +1768,7 @@ ${after.src}`,
1557
1768
  });
1558
1769
  }
1559
1770
  function renderBeforeImage(className, style) {
1560
- return /* @__PURE__ */ jsx11("img", {
1771
+ return /* @__PURE__ */ jsx13("img", {
1561
1772
  ref: beforeRef,
1562
1773
  src: before.src,
1563
1774
  alt: before.alt,
@@ -1572,15 +1783,15 @@ ${after.src}`,
1572
1783
  }
1573
1784
  let content;
1574
1785
  if (mode === "side-by-side") {
1575
- content = /* @__PURE__ */ jsxs7("div", {
1786
+ content = /* @__PURE__ */ jsxs9("div", {
1576
1787
  "data-slot": "image-comparison-panes",
1577
1788
  className: cn2("flex min-h-0 min-w-0 flex-1", orientation === "vertical" ? "flex-col" : "flex-row"),
1578
1789
  children: [
1579
- /* @__PURE__ */ jsx11(ComparisonPane, {
1580
- header: /* @__PURE__ */ jsx11("span", {
1790
+ /* @__PURE__ */ jsx13(ComparisonPane, {
1791
+ header: /* @__PURE__ */ jsx13("span", {
1581
1792
  children: beforeLabel
1582
1793
  }),
1583
- children: /* @__PURE__ */ jsxs7(ImageViewport, {
1794
+ children: /* @__PURE__ */ jsxs9(ImageViewport, {
1584
1795
  label: beforeLabel,
1585
1796
  zoom,
1586
1797
  naturalSize: afterImage.size,
@@ -1595,14 +1806,14 @@ ${after.src}`,
1595
1806
  ]
1596
1807
  })
1597
1808
  }),
1598
- /* @__PURE__ */ jsx11(Separator2, {
1809
+ /* @__PURE__ */ jsx13(Separator2, {
1599
1810
  orientation: orientation === "vertical" ? "horizontal" : "vertical"
1600
1811
  }),
1601
- /* @__PURE__ */ jsx11(ComparisonPane, {
1602
- header: /* @__PURE__ */ jsx11("span", {
1812
+ /* @__PURE__ */ jsx13(ComparisonPane, {
1813
+ header: /* @__PURE__ */ jsx13("span", {
1603
1814
  children: afterLabel
1604
1815
  }),
1605
- children: /* @__PURE__ */ jsxs7(ImageViewport, {
1816
+ children: /* @__PURE__ */ jsxs9(ImageViewport, {
1606
1817
  label: afterLabel,
1607
1818
  zoom,
1608
1819
  naturalSize: afterImage.size,
@@ -1620,18 +1831,18 @@ ${after.src}`,
1620
1831
  ]
1621
1832
  });
1622
1833
  } else if (mode === "swipe") {
1623
- content = /* @__PURE__ */ jsx11(ComparisonPane, {
1624
- header: /* @__PURE__ */ jsxs7(Fragment, {
1834
+ content = /* @__PURE__ */ jsx13(ComparisonPane, {
1835
+ header: /* @__PURE__ */ jsxs9(Fragment2, {
1625
1836
  children: [
1626
- /* @__PURE__ */ jsx11("span", {
1837
+ /* @__PURE__ */ jsx13("span", {
1627
1838
  children: beforeLabel
1628
1839
  }),
1629
- /* @__PURE__ */ jsx11("span", {
1840
+ /* @__PURE__ */ jsx13("span", {
1630
1841
  children: afterLabel
1631
1842
  })
1632
1843
  ]
1633
1844
  }),
1634
- children: /* @__PURE__ */ jsxs7(ImageViewport, {
1845
+ children: /* @__PURE__ */ jsxs9(ImageViewport, {
1635
1846
  label: `${beforeLabel} and ${afterLabel}`,
1636
1847
  zoom,
1637
1848
  naturalSize: afterImage.size,
@@ -1642,7 +1853,7 @@ ${after.src}`,
1642
1853
  renderAfterImage(),
1643
1854
  renderBeforeImage(undefined, { clipPath: `inset(0 ${100 - position}% 0 0)` }),
1644
1855
  overlay,
1645
- /* @__PURE__ */ jsx11(ImageSwipeDivider, {
1856
+ /* @__PURE__ */ jsx13(ImageSwipeDivider, {
1646
1857
  value: position,
1647
1858
  onValueChange: setPosition,
1648
1859
  beforeLabel,
@@ -1653,8 +1864,8 @@ ${after.src}`,
1653
1864
  });
1654
1865
  } else {
1655
1866
  const showingLabel = isShowingBefore ? beforeLabel : afterLabel;
1656
- content = /* @__PURE__ */ jsx11(ComparisonPane, {
1657
- header: /* @__PURE__ */ jsxs7("span", {
1867
+ content = /* @__PURE__ */ jsx13(ComparisonPane, {
1868
+ header: /* @__PURE__ */ jsxs9("span", {
1658
1869
  "data-slot": "image-comparison-showing",
1659
1870
  "aria-live": "polite",
1660
1871
  children: [
@@ -1662,13 +1873,15 @@ ${after.src}`,
1662
1873
  showingLabel
1663
1874
  ]
1664
1875
  }),
1665
- children: /* @__PURE__ */ jsxs7(ImageViewport, {
1876
+ children: /* @__PURE__ */ jsxs9(ImageViewport, {
1666
1877
  label: showingLabel,
1667
1878
  zoom,
1668
1879
  naturalSize: afterImage.size,
1669
1880
  center,
1670
1881
  onZoomChange: setZoom,
1671
1882
  fallback,
1883
+ onStageKeyDown: handleToggleStageKey,
1884
+ stageKeyShortcuts: "B A",
1672
1885
  children: [
1673
1886
  renderAfterImage(isShowingBefore ? "invisible" : undefined),
1674
1887
  renderBeforeImage(isShowingBefore ? undefined : "invisible"),
@@ -1677,7 +1890,7 @@ ${after.src}`,
1677
1890
  })
1678
1891
  });
1679
1892
  }
1680
- return /* @__PURE__ */ jsx11("div", {
1893
+ return /* @__PURE__ */ jsx13("div", {
1681
1894
  role: "group",
1682
1895
  "aria-label": label,
1683
1896
  "data-slot": "image-comparison",
@@ -1688,18 +1901,20 @@ ${after.src}`,
1688
1901
  "data-zoom": zoom,
1689
1902
  "data-showing": isShowingBefore ? "before" : "after",
1690
1903
  className: "@container flex size-full min-h-0 min-w-0 flex-1",
1691
- children: /* @__PURE__ */ jsxs7("div", {
1904
+ children: /* @__PURE__ */ jsxs9("div", {
1692
1905
  className: "flex min-h-0 min-w-0 flex-1 flex-col @3xl:flex-row",
1693
1906
  children: [
1694
- /* @__PURE__ */ jsx11("div", {
1907
+ /* @__PURE__ */ jsx13("div", {
1695
1908
  "data-slot": "image-comparison-stage",
1696
1909
  "data-scroll": "none",
1697
1910
  className: "flex min-h-0 min-w-0 flex-1",
1698
1911
  children: content
1699
1912
  }),
1700
- showToolbar && /* @__PURE__ */ jsx11(ImageComparisonToolbar, {
1913
+ showToolbar && /* @__PURE__ */ jsx13(ImageComparisonToolbar, {
1701
1914
  mode,
1702
1915
  onModeChange: setMode,
1916
+ side,
1917
+ onSideChange: setSide,
1703
1918
  orientation,
1704
1919
  onOrientationChange: setOrientation,
1705
1920
  zoom,
@@ -1723,6 +1938,7 @@ export {
1723
1938
  IMAGE_REGION_STEP,
1724
1939
  IMAGE_ZOOM_STEPS,
1725
1940
  ImageComparison,
1941
+ ImageGallery,
1726
1942
  ImageRegionFields,
1727
1943
  ImageRegionMarker,
1728
1944
  ImageRegionMarkerBadge,
@@ -1732,6 +1948,7 @@ export {
1732
1948
  ImageZoomToggle,
1733
1949
  MAX_IMAGE_ZOOM,
1734
1950
  MIN_IMAGE_REGION_SIZE,
1951
+ MediaShell,
1735
1952
  applyImageRegionKey,
1736
1953
  clampImageRegion,
1737
1954
  computeImageDiff,
@@ -14,6 +14,8 @@ export interface IImageZoomScales {
14
14
  }
15
15
  /** How ImageComparison presents the before and after images. */
16
16
  export type ImageComparisonMode = "toggle" | "swipe" | "side-by-side";
17
+ /** The image a comparison shows in `toggle` mode. */
18
+ export type ImageComparisonSide = "before" | "after";
17
19
  /** Side-by-side pane arrangement: `horizontal` places panes left and right, `vertical` top and bottom. */
18
20
  export type ImageComparisonOrientation = StackDirection;
19
21
  export interface IImageSize {
@@ -26,7 +26,7 @@ import {
26
26
  PaginationPrevious2,
27
27
  PaginationNext2,
28
28
  PaginationEllipsis2
29
- } from "../../chunk-v1semj30.js";
29
+ } from "../../chunk-avp2phea.js";
30
30
  import {
31
31
  MenuPopup,
32
32
  MenuItem2,
package/dist/index.js CHANGED
@@ -188,7 +188,7 @@ import {
188
188
  DashboardLayout2,
189
189
  BillingUsage2,
190
190
  SelectionAction2
191
- } from "./chunk-v1semj30.js";
191
+ } from "./chunk-avp2phea.js";
192
192
  import {
193
193
  statusDotVariants2,
194
194
  StatusDot2
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.148",
2054
+ version: "0.0.151",
2055
2055
  description: "Sharp, monospace React components with compact, comfortable, and touch densities.",
2056
2056
  license: "MIT",
2057
2057
  repository: {
@@ -1,6 +1,6 @@
1
1
  # ImageComparison
2
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 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.
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 one image, chosen by the "Shown image" control or B and A on the focused stage (`side`, default `after`), and the "Hold to show before" (or "after") button shows the other image while a pointer, Space, or Enter is held; the header announces the shown image. `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`, `side`, `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
4
 
5
5
  Story: @alexgorbatchev/shadcn/components/data-display/ImageComparison
6
6
  Source: src/components/stories/data-display/ImageComparison.stories.tsx
@@ -46,6 +46,7 @@ ImageComparison
46
46
  before: { src: fixture_beforeScreenshot, alt: BEFORE_ALT },
47
47
  after: { src: fixture_afterScreenshot, alt: AFTER_ALT },
48
48
  onModeChange: fn(),
49
+ onSideChange: fn(),
49
50
  onOrientationChange: fn(),
50
51
  onZoomChange: fn(),
51
52
  onShowDifferencesChange: fn(),
@@ -70,6 +71,14 @@ Storybook CSF excerpts. Default args and render apply unless overridden. Local h
70
71
  {}
71
72
  ```
72
73
 
74
+ ### ShownSide
75
+
76
+ ```tsx
77
+ {
78
+ args: { defaultSide: "before" }
79
+ }
80
+ ```
81
+
73
82
  ### Swipe
74
83
 
75
84
  ```tsx
@@ -0,0 +1,62 @@
1
+ # ImageGallery
2
+
3
+ Import `ImageGallery` and `MediaShell` from `@alexgorbatchev/shadcn/image-viewer`. `MediaShell` is the full-screen shell every image, comparison, gallery and diagram opens in: `title` (one line, truncated) and an optional `description` in the header, an always visible Close, and `children` filling the stage; `onOpenChange` receives Base UI's change details, so Escape can close an inner layer first with `details.cancel()`. `ImageGallery` steps through `items` (`{ key, src, alt, label }`) in one `ImageViewer` at the controlled `index`, keeping the zoom and viewed position between items so the same area of each can be compared. Its toolbar holds the zoom bar, Previous, "n of m" and Next (named by `previousLabel` and `nextLabel`, disabled with a reason at either end) and then `toolbar`, such as a Choose action; Left and Right step on the focused stage only at Fit, where arrows do not pan, and each step is announced politely as "<label> · n of m". `overlay`, `imageRef`, `stageRef`, `onStageKeyDown` and `stageKeyShortcuts` pass to the viewer. Name the shell after the shown item.
4
+
5
+ Story: @alexgorbatchev/shadcn/components/data-display/ImageGallery
6
+ Source: src/components/stories/data-display/ImageGallery.stories.tsx
7
+
8
+ [Full source and local helpers](https://github.com/alexgorbatchev/shadcn/blob/main/src/components/stories/data-display/ImageGallery.stories.tsx)
9
+
10
+ ## Public imports
11
+
12
+ ```tsx
13
+ import { ImageGallery, MediaShell, type IImageGalleryItem, type IImageGalleryProps } from "@alexgorbatchev/shadcn/image-viewer";
14
+ import { Button } 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
+ ImageGallery
27
+ ```
28
+
29
+ ## Default args
30
+
31
+ ```tsx
32
+ { items: ITEMS, index: 0, onIndexChange: fn() }
33
+ ```
34
+
35
+ ## Default render
36
+
37
+ ```tsx
38
+ (args) => <GalleryInShell items={args.items} onIndexChange={args.onIndexChange}/>
39
+ ```
40
+
41
+ ## Examples
42
+
43
+ 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.
44
+
45
+ ### StepAndChoose
46
+
47
+ ```tsx
48
+ {
49
+ render: (args) => <GalleryInShell items={args.items} onIndexChange={args.onIndexChange} onChoose={chooseSpy}/>
50
+ }
51
+ ```
52
+
53
+ ### Empty
54
+
55
+ ```tsx
56
+ {
57
+ args: { items: [] },
58
+ render: (args) => (<div className="h-64">
59
+ <ImageGallery items={args.items} index={0} onIndexChange={args.onIndexChange}/>
60
+ </div>)
61
+ }
62
+ ```
@@ -199,6 +199,28 @@ Storybook CSF excerpts. Default args and render apply unless overridden. Local h
199
199
  }
200
200
  ```
201
201
 
202
+ ### RowLayout
203
+
204
+ ```tsx
205
+ {
206
+ render: (args) => (<div className="flex flex-col gap-6">
207
+ <div className="w-[56rem]" data-testid="wide">
208
+ <OptionCardGroup aria-label="Hero direction" layout="row" {...args}>
209
+ <HeroOption value="quiet" label="Quiet"/>
210
+ <HeroOption value="bold" label="Bold"/>
211
+ <HeroOption value="playful" label="Playful"/>
212
+ </OptionCardGroup>
213
+ </div>
214
+ <div className="w-72" data-testid="narrow">
215
+ <OptionCheckboxGroup aria-label="Hero directions" layout="row">
216
+ <OptionCheckboxCard value="quiet" label="Quiet narrow"/>
217
+ <OptionCheckboxCard value="bold" label="Bold narrow"/>
218
+ </OptionCheckboxGroup>
219
+ </div>
220
+ </div>)
221
+ }
222
+ ```
223
+
202
224
  ### FoldedDescription
203
225
 
204
226
  ```tsx
package/llms.txt CHANGED
@@ -345,7 +345,8 @@ Generated from the public package exports and Storybook sources.
345
345
  - [DescriptionList](./llms/components/data-display/DescriptionList.md)
346
346
  - [FramedImage](./llms/components/data-display/FramedImage.md): Import from `@alexgorbatchev/shadcn/image-viewer`. FramedImage shows a screenshot or other supplied image as evidence: a 1px edge in the `media-edge` token, which keeps at least 3:1 against the page in both themes, so a white image in the light theme and a black one in the dark theme still show where they end. `size="intrinsic"` (the default) keeps the image's own size within its column and at most 70% of the viewport height, scaled and never cropped; `size="fill"` fills its container's width, as in a row of thumbnails. It takes every `<img>` attribute.
347
347
  - [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, and the display sizes 2xl and 3xl for a page's own title) sets the visual size independently. Sizes default by level: 1 xl, 2 lg, 3 base, 4–6 sm. `truncate` keeps one line.
348
- - [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
+ - [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 one image, chosen by the "Shown image" control or B and A on the focused stage (`side`, default `after`), and the "Hold to show before" (or "after") button shows the other image while a pointer, Space, or Enter is held; the header announces the shown image. `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`, `side`, `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.
349
+ - [ImageGallery](./llms/components/data-display/ImageGallery.md): Import `ImageGallery` and `MediaShell` from `@alexgorbatchev/shadcn/image-viewer`. `MediaShell` is the full-screen shell every image, comparison, gallery and diagram opens in: `title` (one line, truncated) and an optional `description` in the header, an always visible Close, and `children` filling the stage; `onOpenChange` receives Base UI's change details, so Escape can close an inner layer first with `details.cancel()`. `ImageGallery` steps through `items` (`{ key, src, alt, label }`) in one `ImageViewer` at the controlled `index`, keeping the zoom and viewed position between items so the same area of each can be compared. Its toolbar holds the zoom bar, Previous, "n of m" and Next (named by `previousLabel` and `nextLabel`, disabled with a reason at either end) and then `toolbar`, such as a Choose action; Left and Right step on the focused stage only at Fit, where arrows do not pan, and each step is announced politely as "<label> · n of m". `overlay`, `imageRef`, `stageRef`, `onStageKeyDown` and `stageKeyShortcuts` pass to the viewer. Name the shell after the shown item.
349
350
  - [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.
350
351
  - [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.
351
352
  - [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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexgorbatchev/shadcn",
3
- "version": "0.0.148",
3
+ "version": "0.0.151",
4
4
  "description": "Sharp, monospace React components with compact, comfortable, and touch densities.",
5
5
  "license": "MIT",
6
6
  "repository": {