@alexgorbatchev/shadcn 0.0.161 → 0.0.162
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.
- package/dist/{chunk-1j2hz3w9.js → chunk-3kb1gkke.js} +5 -7
- package/dist/{chunk-fnfaa0zx.js → chunk-46p9pkw1.js} +1 -1
- package/dist/{chunk-g2amqz9q.js → chunk-crvagbjs.js} +1 -1
- package/dist/chunk-dpedhp0c.js +5 -0
- package/dist/{chunk-dv0rz8r9.js → chunk-hev911n9.js} +1 -1
- package/dist/{chunk-ajnmzqsv.js → chunk-jkjq1jkd.js} +1 -1
- package/dist/{chunk-wvap51y9.js → chunk-vvt6y9j4.js} +1 -1
- package/dist/{chunk-j0sw6cn8.js → chunk-y7jv23qt.js} +1 -1
- package/dist/{chunk-zh1vby37.js → chunk-zyt63zrh.js} +1 -1
- package/dist/components/assistant-ui/elements/ElicitationForm.js +2 -2
- package/dist/components/assistant-ui/elements/ScheduleCard.js +2 -2
- package/dist/components/assistant-ui/elements/SettingsPanel.js +2 -2
- package/dist/components/assistant-ui/elements/VoiceOrb.js +3 -2
- package/dist/components/assistant-ui/index.js +7 -6
- package/dist/components/assistant-ui/native/VoiceOrb.js +4 -3
- package/dist/components/assistant-ui/native/index.js +4 -3
- package/dist/components/image-viewer/DiagramSurface.d.ts +22 -0
- package/dist/components/image-viewer/DiagramViewer.d.ts +42 -0
- package/dist/components/image-viewer/hooks/useMermaidTheme.d.ts +11 -0
- package/dist/components/image-viewer/index.d.ts +10 -0
- package/dist/components/image-viewer/index.js +692 -189
- package/dist/components/image-viewer/mermaidTheme.d.ts +58 -0
- package/dist/components/image-viewer/prepareDiagramSvg.d.ts +21 -0
- package/dist/components/json-render/index.js +4 -3
- package/dist/components/sonner/index.js +2 -1
- package/dist/index.js +4 -3
- package/dist/prototype.js +1 -1
- package/llms/components/data-display/DiagramViewer.md +66 -0
- package/llms.txt +1 -0
- package/package.json +1 -1
|
@@ -17,6 +17,9 @@ import {
|
|
|
17
17
|
ToggleGroup2,
|
|
18
18
|
ToggleGroupItem2
|
|
19
19
|
} from "../../chunk-pbyj8rja.js";
|
|
20
|
+
import {
|
|
21
|
+
ThemeContext
|
|
22
|
+
} from "../../chunk-dpedhp0c.js";
|
|
20
23
|
import"../../chunk-4m2x9jfb.js";
|
|
21
24
|
import {
|
|
22
25
|
Separator2
|
|
@@ -45,7 +48,7 @@ import {
|
|
|
45
48
|
} from "../../chunk-d22t4qx6.js";
|
|
46
49
|
import {
|
|
47
50
|
Switch2
|
|
48
|
-
} from "../../chunk-
|
|
51
|
+
} from "../../chunk-hev911n9.js";
|
|
49
52
|
import"../../chunk-5mydsjp3.js";
|
|
50
53
|
|
|
51
54
|
// src/components/image-viewer/ImageViewer.tsx
|
|
@@ -406,25 +409,25 @@ function ImageViewport({
|
|
|
406
409
|
"data-slot": "image-viewport-scroll-hint",
|
|
407
410
|
"data-edge": "left",
|
|
408
411
|
"aria-hidden": "true",
|
|
409
|
-
className: "pointer-events-none absolute inset-y-0 left-0 w-5
|
|
412
|
+
className: "pointer-events-none absolute inset-y-0 left-0 w-5 bg-gradient-to-r from-black/45 via-black/15 to-transparent dark:from-black/65 dark:via-black/25"
|
|
410
413
|
}),
|
|
411
414
|
scrollHints.right && /* @__PURE__ */ jsx("div", {
|
|
412
415
|
"data-slot": "image-viewport-scroll-hint",
|
|
413
416
|
"data-edge": "right",
|
|
414
417
|
"aria-hidden": "true",
|
|
415
|
-
className: "pointer-events-none absolute inset-y-0 right-0 w-5
|
|
418
|
+
className: "pointer-events-none absolute inset-y-0 right-0 w-5 bg-gradient-to-l from-black/45 via-black/15 to-transparent dark:from-black/65 dark:via-black/25"
|
|
416
419
|
}),
|
|
417
420
|
scrollHints.top && /* @__PURE__ */ jsx("div", {
|
|
418
421
|
"data-slot": "image-viewport-scroll-hint",
|
|
419
422
|
"data-edge": "top",
|
|
420
423
|
"aria-hidden": "true",
|
|
421
|
-
className: "pointer-events-none absolute inset-x-0 top-0 h-5
|
|
424
|
+
className: "pointer-events-none absolute inset-x-0 top-0 h-5 bg-gradient-to-b from-black/45 via-black/15 to-transparent dark:from-black/65 dark:via-black/25"
|
|
422
425
|
}),
|
|
423
426
|
scrollHints.bottom && /* @__PURE__ */ jsx("div", {
|
|
424
427
|
"data-slot": "image-viewport-scroll-hint",
|
|
425
428
|
"data-edge": "bottom",
|
|
426
429
|
"aria-hidden": "true",
|
|
427
|
-
className: "pointer-events-none absolute inset-x-0 bottom-0 h-5
|
|
430
|
+
className: "pointer-events-none absolute inset-x-0 bottom-0 h-5 bg-gradient-to-t from-black/45 via-black/15 to-transparent dark:from-black/65 dark:via-black/25"
|
|
428
431
|
})
|
|
429
432
|
]
|
|
430
433
|
});
|
|
@@ -633,8 +636,499 @@ function ImageViewer({
|
|
|
633
636
|
]
|
|
634
637
|
});
|
|
635
638
|
}
|
|
636
|
-
// src/components/image-viewer/
|
|
639
|
+
// src/components/image-viewer/DiagramSurface.tsx
|
|
640
|
+
import { useIsoLayoutEffect as useIsoLayoutEffect3 } from "@base-ui/utils/useIsoLayoutEffect";
|
|
641
|
+
import { useId, useRef as useRef3 } from "react";
|
|
642
|
+
|
|
643
|
+
// src/components/image-viewer/prepareDiagramSvg.ts
|
|
644
|
+
function parseLength(value) {
|
|
645
|
+
if (!value)
|
|
646
|
+
return;
|
|
647
|
+
const trimmed = value.trim();
|
|
648
|
+
if (trimmed.endsWith("%"))
|
|
649
|
+
return;
|
|
650
|
+
const parsed = Number.parseFloat(trimmed);
|
|
651
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;
|
|
652
|
+
}
|
|
653
|
+
function parseViewBox(value) {
|
|
654
|
+
if (!value)
|
|
655
|
+
return;
|
|
656
|
+
const parts = value.trim().split(/[\s,]+/).map(Number);
|
|
657
|
+
if (parts.length !== 4)
|
|
658
|
+
return;
|
|
659
|
+
const width = parts[2];
|
|
660
|
+
const height = parts[3];
|
|
661
|
+
if (width === undefined || height === undefined || !Number.isFinite(width) || !Number.isFinite(height)) {
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
return width > 0 && height > 0 ? { width, height } : undefined;
|
|
665
|
+
}
|
|
666
|
+
function getDiagramSvgSize(svg) {
|
|
667
|
+
if (typeof DOMParser === "undefined")
|
|
668
|
+
return;
|
|
669
|
+
const parsed = new DOMParser().parseFromString(svg, "image/svg+xml");
|
|
670
|
+
const root = parsed.documentElement;
|
|
671
|
+
if (root.localName !== "svg")
|
|
672
|
+
return;
|
|
673
|
+
const fromViewBox = parseViewBox(root.getAttribute("viewBox"));
|
|
674
|
+
if (fromViewBox)
|
|
675
|
+
return fromViewBox;
|
|
676
|
+
const width = parseLength(root.getAttribute("width"));
|
|
677
|
+
const height = parseLength(root.getAttribute("height"));
|
|
678
|
+
return width && height ? { width, height } : undefined;
|
|
679
|
+
}
|
|
680
|
+
function escapeRegExp(value) {
|
|
681
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
682
|
+
}
|
|
683
|
+
function stripImportRules(root, ownerDocument) {
|
|
684
|
+
const detached = ownerDocument.implementation.createHTMLDocument();
|
|
685
|
+
for (const source of root.querySelectorAll("style")) {
|
|
686
|
+
const style = detached.createElement("style");
|
|
687
|
+
style.textContent = source.textContent;
|
|
688
|
+
detached.head.append(style);
|
|
689
|
+
const sheet = style.sheet;
|
|
690
|
+
if (sheet) {
|
|
691
|
+
for (let index = sheet.cssRules.length - 1;index >= 0; index--) {
|
|
692
|
+
const rule = sheet.cssRules[index];
|
|
693
|
+
if (rule && rule.cssText.trimStart().startsWith("@import"))
|
|
694
|
+
sheet.deleteRule(index);
|
|
695
|
+
}
|
|
696
|
+
source.textContent = Array.from(sheet.cssRules, (rule) => rule.cssText).join(`
|
|
697
|
+
`);
|
|
698
|
+
} else {
|
|
699
|
+
source.textContent = (source.textContent ?? "").replace(/@import\s+[^;]+;/gi, "");
|
|
700
|
+
}
|
|
701
|
+
style.remove();
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
function prefixSvgIds(root, prefix) {
|
|
705
|
+
const idMap = new Map;
|
|
706
|
+
const elements = [root, ...Array.from(root.querySelectorAll("[id]"))];
|
|
707
|
+
for (const element of elements) {
|
|
708
|
+
const oldId = element.getAttribute("id");
|
|
709
|
+
if (!oldId || idMap.has(oldId))
|
|
710
|
+
continue;
|
|
711
|
+
const nextId = `${prefix}-${oldId}`;
|
|
712
|
+
idMap.set(oldId, nextId);
|
|
713
|
+
element.setAttribute("id", nextId);
|
|
714
|
+
}
|
|
715
|
+
if (idMap.size === 0)
|
|
716
|
+
return;
|
|
717
|
+
const sortedIds = [...idMap.keys()].sort((a, b) => b.length - a.length);
|
|
718
|
+
const selectorPattern = new RegExp(`#(${sortedIds.map(escapeRegExp).join("|")})(?![A-Za-z0-9_-])`, "g");
|
|
719
|
+
const urlPattern = new RegExp(`url\\(\\s*["']?#(${sortedIds.map(escapeRegExp).join("|")})["']?\\s*\\)`, "g");
|
|
720
|
+
for (const style of root.querySelectorAll("style")) {
|
|
721
|
+
if (!style.textContent)
|
|
722
|
+
continue;
|
|
723
|
+
style.textContent = style.textContent.replace(urlPattern, (_match, id) => `url(#${idMap.get(id) ?? id})`).replace(selectorPattern, (_match, id) => `#${idMap.get(id) ?? id}`);
|
|
724
|
+
}
|
|
725
|
+
for (const element of [root, ...Array.from(root.querySelectorAll("*"))]) {
|
|
726
|
+
for (const attr of Array.from(element.attributes)) {
|
|
727
|
+
if (attr.name === "id")
|
|
728
|
+
continue;
|
|
729
|
+
if (attr.name === "href" || attr.name === "xlink:href") {
|
|
730
|
+
if (attr.value.startsWith("#")) {
|
|
731
|
+
const target = attr.value.slice(1);
|
|
732
|
+
const mapped = idMap.get(target);
|
|
733
|
+
if (mapped)
|
|
734
|
+
element.setAttribute(attr.name, `#${mapped}`);
|
|
735
|
+
}
|
|
736
|
+
continue;
|
|
737
|
+
}
|
|
738
|
+
if (attr.name === "aria-labelledby" || attr.name === "aria-describedby") {
|
|
739
|
+
const replaced = attr.value.split(/\s+/).map((token) => idMap.get(token) ?? token).join(" ");
|
|
740
|
+
if (replaced !== attr.value)
|
|
741
|
+
element.setAttribute(attr.name, replaced);
|
|
742
|
+
continue;
|
|
743
|
+
}
|
|
744
|
+
if (attr.value.includes("url(")) {
|
|
745
|
+
const replaced = attr.value.replace(urlPattern, (_match, id) => `url(#${idMap.get(id) ?? id})`);
|
|
746
|
+
if (replaced !== attr.value)
|
|
747
|
+
element.setAttribute(attr.name, replaced);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
function prepareDiagramSvg(svg, ownerDocument, options) {
|
|
753
|
+
const parsed = new DOMParser().parseFromString(svg, "image/svg+xml");
|
|
754
|
+
const root = parsed.documentElement;
|
|
755
|
+
if (root.localName !== "svg")
|
|
756
|
+
throw new Error("Diagram returned an invalid SVG document.");
|
|
757
|
+
stripImportRules(root, ownerDocument);
|
|
758
|
+
prefixSvgIds(root, options.idPrefix);
|
|
759
|
+
const imported = ownerDocument.importNode(root, true);
|
|
760
|
+
if (!(imported instanceof SVGSVGElement))
|
|
761
|
+
throw new Error("Diagram SVG could not be imported.");
|
|
762
|
+
imported.setAttribute("role", "img");
|
|
763
|
+
imported.removeAttribute("aria-roledescription");
|
|
764
|
+
if (options.labelledBy) {
|
|
765
|
+
imported.setAttribute("aria-labelledby", options.labelledBy);
|
|
766
|
+
imported.removeAttribute("aria-label");
|
|
767
|
+
} else if (options.label) {
|
|
768
|
+
imported.setAttribute("aria-label", options.label);
|
|
769
|
+
imported.removeAttribute("aria-labelledby");
|
|
770
|
+
}
|
|
771
|
+
if (options.describedBy)
|
|
772
|
+
imported.setAttribute("aria-describedby", options.describedBy);
|
|
773
|
+
else
|
|
774
|
+
imported.removeAttribute("aria-describedby");
|
|
775
|
+
const size = parseViewBox(imported.getAttribute("viewBox")) ?? {
|
|
776
|
+
width: parseLength(imported.getAttribute("width")) ?? 0,
|
|
777
|
+
height: parseLength(imported.getAttribute("height")) ?? 0
|
|
778
|
+
};
|
|
779
|
+
if (!imported.getAttribute("viewBox") && size.width > 0 && size.height > 0) {
|
|
780
|
+
imported.setAttribute("viewBox", `0 0 ${size.width} ${size.height}`);
|
|
781
|
+
}
|
|
782
|
+
imported.style.display = "block";
|
|
783
|
+
if (options.fit === "fill") {
|
|
784
|
+
imported.setAttribute("width", "100%");
|
|
785
|
+
imported.setAttribute("height", "100%");
|
|
786
|
+
imported.style.maxWidth = "none";
|
|
787
|
+
imported.style.width = "100%";
|
|
788
|
+
imported.style.height = "100%";
|
|
789
|
+
} else {
|
|
790
|
+
imported.removeAttribute("height");
|
|
791
|
+
imported.style.maxWidth = "100%";
|
|
792
|
+
imported.style.height = "auto";
|
|
793
|
+
imported.style.marginInline = "auto";
|
|
794
|
+
}
|
|
795
|
+
return imported;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
// src/components/image-viewer/DiagramSurface.tsx
|
|
637
799
|
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
800
|
+
function assignRef(ref, value) {
|
|
801
|
+
if (!ref)
|
|
802
|
+
return;
|
|
803
|
+
if (typeof ref === "function")
|
|
804
|
+
ref(value);
|
|
805
|
+
else
|
|
806
|
+
ref.current = value;
|
|
807
|
+
}
|
|
808
|
+
function DiagramSurface({
|
|
809
|
+
svg,
|
|
810
|
+
label,
|
|
811
|
+
labelledBy,
|
|
812
|
+
describedBy,
|
|
813
|
+
description,
|
|
814
|
+
fit = "inline",
|
|
815
|
+
svgRef
|
|
816
|
+
}) {
|
|
817
|
+
const hostRef = useRef3(null);
|
|
818
|
+
const rawId = useId().replace(/[^a-zA-Z0-9_-]/g, "");
|
|
819
|
+
const descriptionId = `diagram-desc-${rawId}`;
|
|
820
|
+
const effectiveDescribedBy = describedBy ?? (description?.trim() ? descriptionId : undefined);
|
|
821
|
+
useIsoLayoutEffect3(() => {
|
|
822
|
+
const host = hostRef.current;
|
|
823
|
+
if (!host)
|
|
824
|
+
return;
|
|
825
|
+
const element = prepareDiagramSvg(svg, host.ownerDocument, {
|
|
826
|
+
idPrefix: `diagram-${rawId}`,
|
|
827
|
+
label,
|
|
828
|
+
labelledBy,
|
|
829
|
+
describedBy: effectiveDescribedBy,
|
|
830
|
+
fit
|
|
831
|
+
});
|
|
832
|
+
host.replaceChildren(element);
|
|
833
|
+
assignRef(svgRef, element);
|
|
834
|
+
return () => {
|
|
835
|
+
assignRef(svgRef, null);
|
|
836
|
+
host.replaceChildren();
|
|
837
|
+
};
|
|
838
|
+
}, [svg, rawId, label, labelledBy, effectiveDescribedBy, fit, svgRef]);
|
|
839
|
+
return /* @__PURE__ */ jsxs4("div", {
|
|
840
|
+
"data-slot": "diagram-surface",
|
|
841
|
+
"data-fit": fit,
|
|
842
|
+
className: cn2("bg-card text-card-foreground", fit === "fill" ? "size-full" : "overflow-x-auto p-panel-sm"),
|
|
843
|
+
children: [
|
|
844
|
+
/* @__PURE__ */ jsx4("div", {
|
|
845
|
+
ref: hostRef,
|
|
846
|
+
className: fit === "fill" ? "size-full" : undefined
|
|
847
|
+
}),
|
|
848
|
+
!describedBy && description?.trim() ? /* @__PURE__ */ jsx4("span", {
|
|
849
|
+
id: descriptionId,
|
|
850
|
+
className: "sr-only",
|
|
851
|
+
children: description.trim()
|
|
852
|
+
}) : null
|
|
853
|
+
]
|
|
854
|
+
});
|
|
855
|
+
}
|
|
856
|
+
// src/components/image-viewer/DiagramViewer.tsx
|
|
857
|
+
import { useControlled as useControlled2 } from "@base-ui/utils/useControlled";
|
|
858
|
+
import { useIsoLayoutEffect as useIsoLayoutEffect4 } from "@base-ui/utils/useIsoLayoutEffect";
|
|
859
|
+
import { useMergedRefs as useMergedRefs3 } from "@base-ui/utils/useMergedRefs";
|
|
860
|
+
import { useMemo, useRef as useRef4, useState as useState4 } from "react";
|
|
861
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
862
|
+
function DiagramViewer({
|
|
863
|
+
svg,
|
|
864
|
+
label,
|
|
865
|
+
description,
|
|
866
|
+
naturalSize: naturalSizeProp,
|
|
867
|
+
zoom: zoomProp,
|
|
868
|
+
defaultZoom,
|
|
869
|
+
onZoomChange,
|
|
870
|
+
openingWidth,
|
|
871
|
+
showZoomControl = false,
|
|
872
|
+
toolbar,
|
|
873
|
+
stageRef,
|
|
874
|
+
onStageKeyDown,
|
|
875
|
+
stageKeyShortcuts,
|
|
876
|
+
density
|
|
877
|
+
}) {
|
|
878
|
+
const [zoom, setZoomState] = useControlled2({
|
|
879
|
+
controlled: zoomProp,
|
|
880
|
+
default: defaultZoom,
|
|
881
|
+
name: "DiagramViewer",
|
|
882
|
+
state: "zoom"
|
|
883
|
+
});
|
|
884
|
+
const center = useRef4({ x: 0.5, y: 0.5 });
|
|
885
|
+
const viewportRef = useRef4(null);
|
|
886
|
+
const mergedStageRef = useMergedRefs3(viewportRef, stageRef);
|
|
887
|
+
const viewportSize = useElementSize(viewportRef);
|
|
888
|
+
const parsedSize = useMemo(() => getDiagramSvgSize(svg), [svg]);
|
|
889
|
+
const naturalSize = naturalSizeProp ?? parsedSize;
|
|
890
|
+
const [openingZoom, setOpeningZoom] = useState4();
|
|
891
|
+
const scales = naturalSize && viewportSize ? getImageZoomScales(naturalSize, viewportSize) : undefined;
|
|
892
|
+
useIsoLayoutEffect4(() => {
|
|
893
|
+
if (zoom !== undefined || openingZoom !== undefined || !naturalSize || !viewportSize)
|
|
894
|
+
return;
|
|
895
|
+
const opening = getOpeningImageZoom(naturalSize, viewportSize, openingWidth);
|
|
896
|
+
const stageHeight = naturalSize.height * resolveImageZoomScale(opening, getImageZoomScales(naturalSize, viewportSize));
|
|
897
|
+
if (stageHeight > viewportSize.height)
|
|
898
|
+
center.current = { x: 0.5, y: viewportSize.height / 2 / stageHeight };
|
|
899
|
+
setOpeningZoom(opening);
|
|
900
|
+
}, [naturalSize, openingWidth, openingZoom, viewportSize, zoom]);
|
|
901
|
+
const shownZoom = zoom ?? openingZoom ?? "fit";
|
|
902
|
+
const scale = scales ? resolveImageZoomScale(shownZoom, scales) : undefined;
|
|
903
|
+
function setZoom(next) {
|
|
904
|
+
setZoomState(next);
|
|
905
|
+
setOpeningZoom(next);
|
|
906
|
+
onZoomChange?.(next);
|
|
907
|
+
}
|
|
908
|
+
return /* @__PURE__ */ jsxs5("div", {
|
|
909
|
+
"data-slot": "diagram-viewer",
|
|
910
|
+
"data-scroll": "none",
|
|
911
|
+
"data-density": density,
|
|
912
|
+
"data-zoom": shownZoom,
|
|
913
|
+
className: "flex size-full min-h-0 min-w-0 flex-1 flex-col gap-2",
|
|
914
|
+
children: [
|
|
915
|
+
(showZoomControl || toolbar !== undefined) && /* @__PURE__ */ jsxs5("div", {
|
|
916
|
+
"data-slot": "diagram-viewer-toolbar",
|
|
917
|
+
className: "flex shrink-0 flex-wrap items-center gap-control-gap *:shrink-0",
|
|
918
|
+
children: [
|
|
919
|
+
showZoomControl && /* @__PURE__ */ jsx5(ImageZoomControl, {
|
|
920
|
+
zoom: shownZoom,
|
|
921
|
+
scale,
|
|
922
|
+
scales,
|
|
923
|
+
onZoomChange: setZoom,
|
|
924
|
+
density
|
|
925
|
+
}),
|
|
926
|
+
toolbar
|
|
927
|
+
]
|
|
928
|
+
}),
|
|
929
|
+
/* @__PURE__ */ jsx5(ImageViewport, {
|
|
930
|
+
label,
|
|
931
|
+
zoom: shownZoom,
|
|
932
|
+
naturalSize,
|
|
933
|
+
center,
|
|
934
|
+
viewportRef: mergedStageRef,
|
|
935
|
+
onZoomChange: setZoom,
|
|
936
|
+
onStageKeyDown,
|
|
937
|
+
stageKeyShortcuts,
|
|
938
|
+
children: /* @__PURE__ */ jsx5("div", {
|
|
939
|
+
"data-slot": "diagram-viewer-frame",
|
|
940
|
+
className: "size-full bg-card outline-1 -outline-offset-1 outline-media-edge",
|
|
941
|
+
children: /* @__PURE__ */ jsx5(DiagramSurface, {
|
|
942
|
+
svg,
|
|
943
|
+
label,
|
|
944
|
+
description,
|
|
945
|
+
fit: "fill"
|
|
946
|
+
})
|
|
947
|
+
})
|
|
948
|
+
})
|
|
949
|
+
]
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
// src/components/image-viewer/mermaidTheme.ts
|
|
953
|
+
var DARK_FALLBACK = {
|
|
954
|
+
card: "#121417",
|
|
955
|
+
foreground: "#eceff3",
|
|
956
|
+
secondary: "#1c1f24",
|
|
957
|
+
muted: "#282c33",
|
|
958
|
+
mutedForeground: "#a3abb6",
|
|
959
|
+
border: "#353b44",
|
|
960
|
+
input: "#6f7783",
|
|
961
|
+
primaryForeground: "#1a0014",
|
|
962
|
+
fontFamily: '"JetBrains Mono Variable", "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace'
|
|
963
|
+
};
|
|
964
|
+
var LIGHT_FALLBACK = {
|
|
965
|
+
card: "#fcfcfd",
|
|
966
|
+
foreground: "#0c0e11",
|
|
967
|
+
secondary: "#eef0f3",
|
|
968
|
+
muted: "#e0e4ea",
|
|
969
|
+
mutedForeground: "#4b535e",
|
|
970
|
+
border: "#c7ccd4",
|
|
971
|
+
input: "#747c88",
|
|
972
|
+
primaryForeground: "#ffffff",
|
|
973
|
+
fontFamily: '"JetBrains Mono Variable", "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace'
|
|
974
|
+
};
|
|
975
|
+
function toHexByte(channel) {
|
|
976
|
+
return Math.max(0, Math.min(255, Math.round(channel))).toString(16).padStart(2, "0");
|
|
977
|
+
}
|
|
978
|
+
function normalizeHex(raw) {
|
|
979
|
+
const trimmed = raw.trim();
|
|
980
|
+
if (/^#[0-9a-f]{6}$/i.test(trimmed))
|
|
981
|
+
return trimmed.toLowerCase();
|
|
982
|
+
const short = /^#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(trimmed);
|
|
983
|
+
if (short) {
|
|
984
|
+
const [, r, g, b] = short;
|
|
985
|
+
return `#${r}${r}${g}${g}${b}${b}`.toLowerCase();
|
|
986
|
+
}
|
|
987
|
+
const rgb = /^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i.exec(trimmed);
|
|
988
|
+
if (rgb)
|
|
989
|
+
return `#${toHexByte(Number(rgb[1]))}${toHexByte(Number(rgb[2]))}${toHexByte(Number(rgb[3]))}`;
|
|
990
|
+
return;
|
|
991
|
+
}
|
|
992
|
+
function resolveCssColorToHex(raw, fallback) {
|
|
993
|
+
const direct = normalizeHex(raw);
|
|
994
|
+
if (direct)
|
|
995
|
+
return direct;
|
|
996
|
+
const trimmed = raw.trim();
|
|
997
|
+
if (!trimmed || typeof document === "undefined")
|
|
998
|
+
return fallback;
|
|
999
|
+
const canvas = document.createElement("canvas");
|
|
1000
|
+
canvas.width = 1;
|
|
1001
|
+
canvas.height = 1;
|
|
1002
|
+
const context = canvas.getContext("2d", { willReadFrequently: true });
|
|
1003
|
+
if (!context)
|
|
1004
|
+
return fallback;
|
|
1005
|
+
context.fillStyle = fallback;
|
|
1006
|
+
context.fillRect(0, 0, 1, 1);
|
|
1007
|
+
context.fillStyle = trimmed;
|
|
1008
|
+
context.fillRect(0, 0, 1, 1);
|
|
1009
|
+
const pixel = context.getImageData(0, 0, 1, 1).data;
|
|
1010
|
+
if (pixel[3] === 0)
|
|
1011
|
+
return fallback;
|
|
1012
|
+
return `#${toHexByte(pixel[0] ?? 0)}${toHexByte(pixel[1] ?? 0)}${toHexByte(pixel[2] ?? 0)}`;
|
|
1013
|
+
}
|
|
1014
|
+
function detectDarkMode(element) {
|
|
1015
|
+
const themed = element?.closest("[data-theme]") ?? (typeof document !== "undefined" ? document.documentElement : null);
|
|
1016
|
+
const attr = themed?.getAttribute("data-theme");
|
|
1017
|
+
if (attr === "light")
|
|
1018
|
+
return false;
|
|
1019
|
+
if (attr === "dark")
|
|
1020
|
+
return true;
|
|
1021
|
+
if (typeof window !== "undefined" && typeof window.matchMedia === "function") {
|
|
1022
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
1023
|
+
}
|
|
1024
|
+
return true;
|
|
1025
|
+
}
|
|
1026
|
+
function getMermaidThemeConfig(element) {
|
|
1027
|
+
const darkMode = detectDarkMode(element);
|
|
1028
|
+
const fallback = darkMode ? DARK_FALLBACK : LIGHT_FALLBACK;
|
|
1029
|
+
const target = element ?? (typeof document !== "undefined" ? document.documentElement : undefined);
|
|
1030
|
+
const style = target && typeof getComputedStyle === "function" ? getComputedStyle(target) : undefined;
|
|
1031
|
+
const color = (token, defaultHex) => resolveCssColorToHex(style?.getPropertyValue(token) ?? "", defaultHex);
|
|
1032
|
+
const card = color("--card", fallback.card);
|
|
1033
|
+
const foreground = color("--foreground", fallback.foreground);
|
|
1034
|
+
const secondary = color("--secondary", fallback.secondary);
|
|
1035
|
+
const muted = color("--muted", fallback.muted);
|
|
1036
|
+
const mutedForeground = color("--muted-foreground", fallback.mutedForeground);
|
|
1037
|
+
const border = color("--border", fallback.border);
|
|
1038
|
+
const input = color("--input", fallback.input);
|
|
1039
|
+
const primaryForeground = color("--primary-foreground", fallback.primaryForeground);
|
|
1040
|
+
const fontFamily = style?.getPropertyValue("--ag-font").trim() || style?.fontFamily.trim() || fallback.fontFamily;
|
|
1041
|
+
return {
|
|
1042
|
+
theme: "base",
|
|
1043
|
+
darkMode,
|
|
1044
|
+
fontFamily,
|
|
1045
|
+
themeVariables: {
|
|
1046
|
+
darkMode,
|
|
1047
|
+
fontFamily,
|
|
1048
|
+
background: card,
|
|
1049
|
+
primaryColor: secondary,
|
|
1050
|
+
primaryTextColor: foreground,
|
|
1051
|
+
primaryBorderColor: input,
|
|
1052
|
+
secondaryColor: muted,
|
|
1053
|
+
secondaryTextColor: foreground,
|
|
1054
|
+
secondaryBorderColor: input,
|
|
1055
|
+
tertiaryColor: card,
|
|
1056
|
+
tertiaryTextColor: foreground,
|
|
1057
|
+
tertiaryBorderColor: border,
|
|
1058
|
+
mainBkg: secondary,
|
|
1059
|
+
nodeBorder: input,
|
|
1060
|
+
nodeTextColor: foreground,
|
|
1061
|
+
textColor: foreground,
|
|
1062
|
+
titleColor: foreground,
|
|
1063
|
+
lineColor: mutedForeground,
|
|
1064
|
+
defaultLinkColor: mutedForeground,
|
|
1065
|
+
edgeLabelBackground: card,
|
|
1066
|
+
clusterBkg: card,
|
|
1067
|
+
clusterBorder: input,
|
|
1068
|
+
actorBkg: secondary,
|
|
1069
|
+
actorBorder: input,
|
|
1070
|
+
actorTextColor: foreground,
|
|
1071
|
+
actorLineColor: input,
|
|
1072
|
+
signalColor: mutedForeground,
|
|
1073
|
+
signalTextColor: foreground,
|
|
1074
|
+
labelBoxBkgColor: secondary,
|
|
1075
|
+
labelBoxBorderColor: input,
|
|
1076
|
+
labelTextColor: foreground,
|
|
1077
|
+
loopTextColor: foreground,
|
|
1078
|
+
noteBkgColor: muted,
|
|
1079
|
+
noteBorderColor: input,
|
|
1080
|
+
noteTextColor: foreground,
|
|
1081
|
+
activationBkgColor: muted,
|
|
1082
|
+
activationBorderColor: mutedForeground,
|
|
1083
|
+
sequenceNumberColor: primaryForeground,
|
|
1084
|
+
errorBkgColor: muted,
|
|
1085
|
+
errorTextColor: foreground
|
|
1086
|
+
}
|
|
1087
|
+
};
|
|
1088
|
+
}
|
|
1089
|
+
// src/components/image-viewer/hooks/useMermaidTheme.ts
|
|
1090
|
+
import { useContext, useEffect as useEffect2, useState as useState5 } from "react";
|
|
1091
|
+
function readThemeState(element) {
|
|
1092
|
+
const config = getMermaidThemeConfig(element);
|
|
1093
|
+
return { themeKey: JSON.stringify(config), config };
|
|
1094
|
+
}
|
|
1095
|
+
function useMermaidTheme(element) {
|
|
1096
|
+
const theme = useContext(ThemeContext);
|
|
1097
|
+
const resolvedTheme = theme?.resolvedTheme;
|
|
1098
|
+
const preset = theme?.preset;
|
|
1099
|
+
const [state, setState] = useState5(() => readThemeState(element ?? undefined));
|
|
1100
|
+
useEffect2(() => {
|
|
1101
|
+
const target = element ?? undefined;
|
|
1102
|
+
const sync = () => {
|
|
1103
|
+
const next = readThemeState(target);
|
|
1104
|
+
setState((current) => current.themeKey === next.themeKey ? current : next);
|
|
1105
|
+
};
|
|
1106
|
+
sync();
|
|
1107
|
+
const observer = typeof MutationObserver !== "undefined" && typeof document !== "undefined" ? new MutationObserver(sync) : undefined;
|
|
1108
|
+
if (observer && typeof document !== "undefined") {
|
|
1109
|
+
observer.observe(document.documentElement, {
|
|
1110
|
+
attributes: true,
|
|
1111
|
+
attributeFilter: ["data-theme", "data-theme-preset", "class", "style"]
|
|
1112
|
+
});
|
|
1113
|
+
const scoped = target?.closest("[data-theme]");
|
|
1114
|
+
if (scoped && scoped !== document.documentElement) {
|
|
1115
|
+
observer.observe(scoped, {
|
|
1116
|
+
attributes: true,
|
|
1117
|
+
attributeFilter: ["data-theme", "data-theme-preset", "class", "style"]
|
|
1118
|
+
});
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
const media = typeof window !== "undefined" && typeof window.matchMedia === "function" ? window.matchMedia("(prefers-color-scheme: dark)") : undefined;
|
|
1122
|
+
media?.addEventListener("change", sync);
|
|
1123
|
+
return () => {
|
|
1124
|
+
observer?.disconnect();
|
|
1125
|
+
media?.removeEventListener("change", sync);
|
|
1126
|
+
};
|
|
1127
|
+
}, [element, resolvedTheme, preset]);
|
|
1128
|
+
return state;
|
|
1129
|
+
}
|
|
1130
|
+
// src/components/image-viewer/ImageZoomToggle.tsx
|
|
1131
|
+
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
638
1132
|
function ImageZoomToggle({
|
|
639
1133
|
zoom,
|
|
640
1134
|
onZoomChange,
|
|
@@ -645,7 +1139,7 @@ function ImageZoomToggle({
|
|
|
645
1139
|
disabled = false,
|
|
646
1140
|
density
|
|
647
1141
|
}) {
|
|
648
|
-
return /* @__PURE__ */
|
|
1142
|
+
return /* @__PURE__ */ jsxs6(ToggleGroup2, {
|
|
649
1143
|
"aria-label": label,
|
|
650
1144
|
value: zoom === "fit" ? ["fit"] : zoom === 1 ? ["original"] : [],
|
|
651
1145
|
onValueChange: (value) => {
|
|
@@ -660,11 +1154,11 @@ function ImageZoomToggle({
|
|
|
660
1154
|
disabled,
|
|
661
1155
|
density,
|
|
662
1156
|
children: [
|
|
663
|
-
/* @__PURE__ */
|
|
1157
|
+
/* @__PURE__ */ jsx6(ToggleGroupItem2, {
|
|
664
1158
|
value: "fit",
|
|
665
1159
|
children: "Fit to screen"
|
|
666
1160
|
}),
|
|
667
|
-
/* @__PURE__ */
|
|
1161
|
+
/* @__PURE__ */ jsx6(ToggleGroupItem2, {
|
|
668
1162
|
value: "original",
|
|
669
1163
|
children: "Original size"
|
|
670
1164
|
})
|
|
@@ -672,7 +1166,7 @@ function ImageZoomToggle({
|
|
|
672
1166
|
});
|
|
673
1167
|
}
|
|
674
1168
|
// src/components/image-viewer/ImageRegionSelect.tsx
|
|
675
|
-
import { useRef as
|
|
1169
|
+
import { useRef as useRef5, useState as useState6 } from "react";
|
|
676
1170
|
|
|
677
1171
|
// src/components/image-viewer/getNormalizedImagePoint.ts
|
|
678
1172
|
function clampUnit2(value) {
|
|
@@ -739,13 +1233,13 @@ function formatImageRegion(region) {
|
|
|
739
1233
|
|
|
740
1234
|
// src/components/image-viewer/ImageRegionMarker.tsx
|
|
741
1235
|
import { cva } from "class-variance-authority";
|
|
742
|
-
import { jsx as
|
|
1236
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
743
1237
|
var imageRegionMarkerVariants = cva("pointer-events-none absolute rounded-xs shadow-[0_0_0_4px_var(--background)] ring-1 ring-background outline-2 outline-offset-1 forced-colors:outline-[Highlight]", {
|
|
744
1238
|
variants: {
|
|
745
1239
|
variant: {
|
|
746
1240
|
comment: "bg-primary/10 outline-primary",
|
|
747
1241
|
draft: "bg-primary/10 outline-dashed outline-primary",
|
|
748
|
-
difference: "bg-warning/5 outline-dashed outline-
|
|
1242
|
+
difference: "bg-warning/5 outline-dashed outline-warning/80"
|
|
749
1243
|
}
|
|
750
1244
|
},
|
|
751
1245
|
defaultVariants: { variant: "comment" }
|
|
@@ -758,11 +1252,11 @@ function ImageRegionMarker({
|
|
|
758
1252
|
style,
|
|
759
1253
|
...props
|
|
760
1254
|
}) {
|
|
761
|
-
return /* @__PURE__ */
|
|
1255
|
+
return /* @__PURE__ */ jsx7("div", {
|
|
762
1256
|
"data-slot": "image-region-marker",
|
|
763
1257
|
"data-variant": variant ?? "comment",
|
|
764
1258
|
"data-active": active ? "" : undefined,
|
|
765
|
-
className: cn2(imageRegionMarkerVariants({ variant }), active && "z-10 outline-[3px]", active && variant === "difference" && "bg-warning/
|
|
1259
|
+
className: cn2(imageRegionMarkerVariants({ variant }), active && "z-10 outline-[3px]", active && variant === "difference" && "bg-warning/20 shadow-[0_0_0_5px_var(--background)] outline-solid outline-warning", className),
|
|
766
1260
|
style: region ? { ...style, ...region } : style,
|
|
767
1261
|
...props
|
|
768
1262
|
});
|
|
@@ -774,7 +1268,7 @@ function ImageRegionMarkerBadge({
|
|
|
774
1268
|
style,
|
|
775
1269
|
...props
|
|
776
1270
|
}) {
|
|
777
|
-
return /* @__PURE__ */
|
|
1271
|
+
return /* @__PURE__ */ jsx7("div", {
|
|
778
1272
|
"data-slot": "image-region-marker-badge",
|
|
779
1273
|
"data-interactive": interactive,
|
|
780
1274
|
className: cn2("absolute z-10 rounded-sm shadow-[0_0_0_4px_var(--background)] outline-2 outline-primary forced-colors:outline-[Highlight]", interactive ? "pointer-events-auto" : "pointer-events-none", className),
|
|
@@ -784,7 +1278,7 @@ function ImageRegionMarkerBadge({
|
|
|
784
1278
|
}
|
|
785
1279
|
|
|
786
1280
|
// src/components/image-viewer/ImageRegionSelect.tsx
|
|
787
|
-
import { jsx as
|
|
1281
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
788
1282
|
var MINIMUM_DRAG = 4;
|
|
789
1283
|
function toRegion(start, end) {
|
|
790
1284
|
return {
|
|
@@ -803,9 +1297,9 @@ function toBox(region) {
|
|
|
803
1297
|
};
|
|
804
1298
|
}
|
|
805
1299
|
function ImageRegionSelect({ region, onRegionChange, onStart }) {
|
|
806
|
-
const drag =
|
|
807
|
-
const pendingClick =
|
|
808
|
-
const [draft, setDraft] =
|
|
1300
|
+
const drag = useRef5(null);
|
|
1301
|
+
const pendingClick = useRef5(null);
|
|
1302
|
+
const [draft, setDraft] = useState6();
|
|
809
1303
|
const point = (event) => getNormalizedImagePoint(event, event.currentTarget.getBoundingClientRect());
|
|
810
1304
|
function cancel() {
|
|
811
1305
|
drag.current = null;
|
|
@@ -823,7 +1317,7 @@ function ImageRegionSelect({ region, onRegionChange, onStart }) {
|
|
|
823
1317
|
onRegionChange(placed);
|
|
824
1318
|
}
|
|
825
1319
|
const shown = draft ?? region;
|
|
826
|
-
return /* @__PURE__ */
|
|
1320
|
+
return /* @__PURE__ */ jsx8("div", {
|
|
827
1321
|
"data-slot": "image-region-select",
|
|
828
1322
|
className: "absolute inset-0 cursor-crosshair touch-none",
|
|
829
1323
|
onPointerDown: (event) => {
|
|
@@ -865,7 +1359,7 @@ function ImageRegionSelect({ region, onRegionChange, onStart }) {
|
|
|
865
1359
|
onRegionChange(dragged);
|
|
866
1360
|
},
|
|
867
1361
|
onPointerCancel: cancel,
|
|
868
|
-
children: shown && /* @__PURE__ */
|
|
1362
|
+
children: shown && /* @__PURE__ */ jsx8(ImageRegionMarker, {
|
|
869
1363
|
variant: "draft",
|
|
870
1364
|
role: draft ? undefined : "img",
|
|
871
1365
|
"aria-hidden": draft ? "true" : undefined,
|
|
@@ -876,8 +1370,8 @@ function ImageRegionSelect({ region, onRegionChange, onStart }) {
|
|
|
876
1370
|
});
|
|
877
1371
|
}
|
|
878
1372
|
// src/components/image-viewer/ImageRegionFields.tsx
|
|
879
|
-
import { useId } from "react";
|
|
880
|
-
import { jsx as
|
|
1373
|
+
import { useId as useId2 } from "react";
|
|
1374
|
+
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
881
1375
|
var FIELDS = [
|
|
882
1376
|
["x", "Left"],
|
|
883
1377
|
["y", "Top"],
|
|
@@ -894,22 +1388,22 @@ function ImageRegionFields({
|
|
|
894
1388
|
className,
|
|
895
1389
|
density
|
|
896
1390
|
}) {
|
|
897
|
-
const id =
|
|
898
|
-
return /* @__PURE__ */
|
|
1391
|
+
const id = useId2();
|
|
1392
|
+
return /* @__PURE__ */ jsxs7("div", {
|
|
899
1393
|
role: "group",
|
|
900
1394
|
"aria-label": label,
|
|
901
1395
|
"data-slot": "image-region-fields",
|
|
902
1396
|
"data-density": density,
|
|
903
1397
|
className: cn2("flex flex-wrap items-end gap-control-gap", className),
|
|
904
1398
|
children: [
|
|
905
|
-
FIELDS.map(([key, name]) => /* @__PURE__ */
|
|
1399
|
+
FIELDS.map(([key, name]) => /* @__PURE__ */ jsxs7(Field2, {
|
|
906
1400
|
className: "w-20",
|
|
907
1401
|
children: [
|
|
908
|
-
/* @__PURE__ */
|
|
1402
|
+
/* @__PURE__ */ jsx9(FieldLabel2, {
|
|
909
1403
|
htmlFor: `${id}-${key}`,
|
|
910
1404
|
children: name
|
|
911
1405
|
}),
|
|
912
|
-
/* @__PURE__ */
|
|
1406
|
+
/* @__PURE__ */ jsx9(NumberField2, {
|
|
913
1407
|
id: `${id}-${key}`,
|
|
914
1408
|
density,
|
|
915
1409
|
value: toPercent(region[key]),
|
|
@@ -923,15 +1417,15 @@ function ImageRegionFields({
|
|
|
923
1417
|
return;
|
|
924
1418
|
onRegionChange(clampImageRegion({ ...region, [key]: value / 100 }));
|
|
925
1419
|
},
|
|
926
|
-
children: /* @__PURE__ */
|
|
927
|
-
children: /* @__PURE__ */
|
|
1420
|
+
children: /* @__PURE__ */ jsx9(NumberFieldGroup2, {
|
|
1421
|
+
children: /* @__PURE__ */ jsx9(NumberFieldInput2, {
|
|
928
1422
|
"aria-describedby": `${id}-unit`
|
|
929
1423
|
})
|
|
930
1424
|
})
|
|
931
1425
|
})
|
|
932
1426
|
]
|
|
933
1427
|
}, key)),
|
|
934
|
-
/* @__PURE__ */
|
|
1428
|
+
/* @__PURE__ */ jsx9("span", {
|
|
935
1429
|
id: `${id}-unit`,
|
|
936
1430
|
className: "sr-only",
|
|
937
1431
|
children: "percent of the image"
|
|
@@ -940,13 +1434,13 @@ function ImageRegionFields({
|
|
|
940
1434
|
});
|
|
941
1435
|
}
|
|
942
1436
|
// src/components/image-viewer/ImageGallery.tsx
|
|
943
|
-
import { useControlled as
|
|
1437
|
+
import { useControlled as useControlled3 } from "@base-ui/utils/useControlled";
|
|
944
1438
|
import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
|
|
945
1439
|
import {
|
|
946
|
-
useRef as
|
|
947
|
-
useState as
|
|
1440
|
+
useRef as useRef6,
|
|
1441
|
+
useState as useState7
|
|
948
1442
|
} from "react";
|
|
949
|
-
import { jsx as
|
|
1443
|
+
import { jsx as jsx10, jsxs as jsxs8, Fragment } from "react/jsx-runtime";
|
|
950
1444
|
function CompareAllPane({
|
|
951
1445
|
item,
|
|
952
1446
|
zoom,
|
|
@@ -957,29 +1451,29 @@ function CompareAllPane({
|
|
|
957
1451
|
footer
|
|
958
1452
|
}) {
|
|
959
1453
|
const [image, imageHandlers] = useImageLoad(item.src);
|
|
960
|
-
return /* @__PURE__ */
|
|
1454
|
+
return /* @__PURE__ */ jsxs8("section", {
|
|
961
1455
|
"aria-label": item.label,
|
|
962
1456
|
"data-slot": "image-gallery-compare-pane",
|
|
963
1457
|
"data-selected": item.selected ? "" : undefined,
|
|
964
1458
|
className: cn2("flex min-w-0 flex-col overflow-hidden rounded-md border bg-background", item.selected ? "border-primary ring-1 ring-primary" : "border-border"),
|
|
965
1459
|
children: [
|
|
966
|
-
/* @__PURE__ */
|
|
1460
|
+
/* @__PURE__ */ jsxs8("div", {
|
|
967
1461
|
"data-slot": "image-gallery-compare-header",
|
|
968
1462
|
className: "flex h-control shrink-0 items-center justify-between gap-2 border-b border-border px-control-x text-xs font-medium text-foreground",
|
|
969
1463
|
children: [
|
|
970
|
-
/* @__PURE__ */
|
|
1464
|
+
/* @__PURE__ */ jsx10("span", {
|
|
971
1465
|
className: "truncate",
|
|
972
1466
|
children: item.label
|
|
973
1467
|
}),
|
|
974
|
-
item.selected && /* @__PURE__ */
|
|
1468
|
+
item.selected && /* @__PURE__ */ jsx10(Badge2, {
|
|
975
1469
|
variant: "default",
|
|
976
1470
|
children: "Chosen"
|
|
977
1471
|
})
|
|
978
1472
|
]
|
|
979
1473
|
}),
|
|
980
|
-
/* @__PURE__ */
|
|
1474
|
+
/* @__PURE__ */ jsx10("div", {
|
|
981
1475
|
className: cn2("flex w-full shrink-0 p-2", zoom === "fit" ? "aspect-[16/10]" : "h-[min(60dvh,32rem)]"),
|
|
982
|
-
children: /* @__PURE__ */
|
|
1476
|
+
children: /* @__PURE__ */ jsx10(ImageViewport, {
|
|
983
1477
|
label: item.label,
|
|
984
1478
|
zoom,
|
|
985
1479
|
naturalSize: image.size,
|
|
@@ -988,11 +1482,11 @@ function CompareAllPane({
|
|
|
988
1482
|
viewportRef,
|
|
989
1483
|
onViewportScroll,
|
|
990
1484
|
allowVerticalScroll: true,
|
|
991
|
-
fallback: image.status === "error" ? /* @__PURE__ */
|
|
1485
|
+
fallback: image.status === "error" ? /* @__PURE__ */ jsx10("p", {
|
|
992
1486
|
className: "m-auto p-panel text-center text-sm text-muted-foreground",
|
|
993
1487
|
children: "Image could not be loaded."
|
|
994
1488
|
}) : undefined,
|
|
995
|
-
children: /* @__PURE__ */
|
|
1489
|
+
children: /* @__PURE__ */ jsx10("img", {
|
|
996
1490
|
src: item.src,
|
|
997
1491
|
alt: item.alt,
|
|
998
1492
|
draggable: false,
|
|
@@ -1003,15 +1497,15 @@ function CompareAllPane({
|
|
|
1003
1497
|
})
|
|
1004
1498
|
})
|
|
1005
1499
|
}),
|
|
1006
|
-
(item.description || footer !== undefined && footer !== null) && /* @__PURE__ */
|
|
1500
|
+
(item.description || footer !== undefined && footer !== null) && /* @__PURE__ */ jsxs8("div", {
|
|
1007
1501
|
"data-slot": "image-gallery-compare-footer",
|
|
1008
1502
|
className: "flex flex-1 shrink-0 flex-col justify-between gap-2 border-t border-border p-panel-sm",
|
|
1009
1503
|
children: [
|
|
1010
|
-
item.description && /* @__PURE__ */
|
|
1504
|
+
item.description && /* @__PURE__ */ jsx10("p", {
|
|
1011
1505
|
className: "text-xs text-muted-foreground",
|
|
1012
1506
|
children: item.description
|
|
1013
1507
|
}),
|
|
1014
|
-
footer !== undefined && footer !== null && /* @__PURE__ */
|
|
1508
|
+
footer !== undefined && footer !== null && /* @__PURE__ */ jsx10("div", {
|
|
1015
1509
|
className: "flex items-center justify-between gap-2",
|
|
1016
1510
|
children: footer
|
|
1017
1511
|
})
|
|
@@ -1045,17 +1539,17 @@ function ImageGallery({
|
|
|
1045
1539
|
renderItemFooter,
|
|
1046
1540
|
density
|
|
1047
1541
|
}) {
|
|
1048
|
-
const [announcement, setAnnouncement] =
|
|
1049
|
-
const [compareZoom, setCompareZoom] =
|
|
1050
|
-
const [isComparingAll, setCompareAllState] =
|
|
1542
|
+
const [announcement, setAnnouncement] = useState7("");
|
|
1543
|
+
const [compareZoom, setCompareZoom] = useState7("fit");
|
|
1544
|
+
const [isComparingAll, setCompareAllState] = useControlled3({
|
|
1051
1545
|
controlled: compareAllProp,
|
|
1052
1546
|
default: defaultCompareAll,
|
|
1053
1547
|
name: "ImageGallery",
|
|
1054
1548
|
state: "compareAll"
|
|
1055
1549
|
});
|
|
1056
|
-
const compareCenter =
|
|
1057
|
-
const compareViewports =
|
|
1058
|
-
const expectedScrollRef =
|
|
1550
|
+
const compareCenter = useRef6({ x: 0.5, y: 0.5 });
|
|
1551
|
+
const compareViewports = useRef6(new Map);
|
|
1552
|
+
const expectedScrollRef = useRef6(new WeakMap);
|
|
1059
1553
|
const item = items[index];
|
|
1060
1554
|
const count = items.length;
|
|
1061
1555
|
const canCompareAll = count > 1 && (allowCompareAll ?? (compareAllProp !== undefined || onCompareAllChange !== undefined || renderItemFooter !== undefined));
|
|
@@ -1098,28 +1592,28 @@ function ImageGallery({
|
|
|
1098
1592
|
}
|
|
1099
1593
|
}
|
|
1100
1594
|
if (!item)
|
|
1101
|
-
return /* @__PURE__ */
|
|
1595
|
+
return /* @__PURE__ */ jsx10("div", {
|
|
1102
1596
|
"data-slot": "image-gallery",
|
|
1103
1597
|
"data-density": density
|
|
1104
1598
|
});
|
|
1105
1599
|
if (canCompareAll && isComparingAll) {
|
|
1106
|
-
return /* @__PURE__ */
|
|
1600
|
+
return /* @__PURE__ */ jsxs8("div", {
|
|
1107
1601
|
"data-slot": "image-gallery",
|
|
1108
1602
|
"data-mode": "compare-all",
|
|
1109
1603
|
"data-scroll": "none",
|
|
1110
1604
|
"data-density": density,
|
|
1111
1605
|
className: "@container flex size-full min-h-0 min-w-0 flex-1 flex-col gap-2",
|
|
1112
1606
|
children: [
|
|
1113
|
-
/* @__PURE__ */
|
|
1607
|
+
/* @__PURE__ */ jsxs8("div", {
|
|
1114
1608
|
"data-slot": "image-gallery-toolbar",
|
|
1115
1609
|
className: "flex shrink-0 flex-wrap items-center gap-control-gap border-b border-border pb-2 *:shrink-0",
|
|
1116
1610
|
children: [
|
|
1117
|
-
/* @__PURE__ */
|
|
1611
|
+
/* @__PURE__ */ jsx10(ImageZoomToggle, {
|
|
1118
1612
|
zoom: compareZoom,
|
|
1119
1613
|
onZoomChange: setCompareZoom,
|
|
1120
1614
|
density
|
|
1121
1615
|
}),
|
|
1122
|
-
/* @__PURE__ */
|
|
1616
|
+
/* @__PURE__ */ jsx10(Toggle2, {
|
|
1123
1617
|
variant: "outline",
|
|
1124
1618
|
size: "sm",
|
|
1125
1619
|
density,
|
|
@@ -1129,10 +1623,10 @@ function ImageGallery({
|
|
|
1129
1623
|
})
|
|
1130
1624
|
]
|
|
1131
1625
|
}),
|
|
1132
|
-
/* @__PURE__ */
|
|
1626
|
+
/* @__PURE__ */ jsx10("div", {
|
|
1133
1627
|
"data-slot": "image-gallery-compare-grid",
|
|
1134
1628
|
className: cn2("grid min-h-0 min-w-0 flex-1 auto-rows-max content-start grid-cols-1 gap-3 overflow-y-auto px-0.5 pt-1 pb-2", count === 2 ? "@2xl:grid-cols-2" : "@xl:grid-cols-2 @3xl:grid-cols-3"),
|
|
1135
|
-
children: items.map((entry, entryIndex) => /* @__PURE__ */
|
|
1629
|
+
children: items.map((entry, entryIndex) => /* @__PURE__ */ jsx10(CompareAllPane, {
|
|
1136
1630
|
item: entry,
|
|
1137
1631
|
zoom: compareZoom,
|
|
1138
1632
|
center: compareCenter,
|
|
@@ -1147,7 +1641,7 @@ function ImageGallery({
|
|
|
1147
1641
|
footer: renderItemFooter?.(entry, entryIndex)
|
|
1148
1642
|
}, entry.key))
|
|
1149
1643
|
}),
|
|
1150
|
-
/* @__PURE__ */
|
|
1644
|
+
/* @__PURE__ */ jsx10("p", {
|
|
1151
1645
|
role: "status",
|
|
1152
1646
|
"data-slot": "image-gallery-status",
|
|
1153
1647
|
className: "sr-only",
|
|
@@ -1156,14 +1650,14 @@ function ImageGallery({
|
|
|
1156
1650
|
]
|
|
1157
1651
|
});
|
|
1158
1652
|
}
|
|
1159
|
-
return /* @__PURE__ */
|
|
1653
|
+
return /* @__PURE__ */ jsxs8("div", {
|
|
1160
1654
|
"data-slot": "image-gallery",
|
|
1161
1655
|
"data-mode": "single",
|
|
1162
1656
|
"data-scroll": "none",
|
|
1163
1657
|
"data-density": density,
|
|
1164
1658
|
className: "flex size-full min-h-0 min-w-0 flex-1 flex-col",
|
|
1165
1659
|
children: [
|
|
1166
|
-
/* @__PURE__ */
|
|
1660
|
+
/* @__PURE__ */ jsx10(ImageViewer, {
|
|
1167
1661
|
src: item.src,
|
|
1168
1662
|
alt: item.alt,
|
|
1169
1663
|
label: label ?? item.label,
|
|
@@ -1175,24 +1669,24 @@ function ImageGallery({
|
|
|
1175
1669
|
onStageKeyDown: handleStageKey,
|
|
1176
1670
|
stageKeyShortcuts,
|
|
1177
1671
|
density,
|
|
1178
|
-
toolbar: /* @__PURE__ */
|
|
1672
|
+
toolbar: /* @__PURE__ */ jsxs8(Fragment, {
|
|
1179
1673
|
children: [
|
|
1180
|
-
/* @__PURE__ */
|
|
1674
|
+
/* @__PURE__ */ jsxs8("div", {
|
|
1181
1675
|
role: "group",
|
|
1182
1676
|
"aria-label": "Images",
|
|
1183
1677
|
"data-slot": "image-gallery-stepper",
|
|
1184
1678
|
className: "flex items-center gap-control-gap",
|
|
1185
1679
|
children: [
|
|
1186
|
-
/* @__PURE__ */
|
|
1680
|
+
/* @__PURE__ */ jsx10(Button2, {
|
|
1187
1681
|
variant: "outline",
|
|
1188
1682
|
size: "icon-sm",
|
|
1189
1683
|
density,
|
|
1190
1684
|
"aria-label": previousLabel,
|
|
1191
1685
|
disabledReason: index === 0 ? "This is the first image" : undefined,
|
|
1192
1686
|
onClick: () => step(index - 1),
|
|
1193
|
-
children: /* @__PURE__ */
|
|
1687
|
+
children: /* @__PURE__ */ jsx10(ChevronLeftIcon, {})
|
|
1194
1688
|
}),
|
|
1195
|
-
/* @__PURE__ */
|
|
1689
|
+
/* @__PURE__ */ jsxs8("span", {
|
|
1196
1690
|
"data-slot": "image-gallery-position",
|
|
1197
1691
|
className: "text-xs text-muted-foreground tabular-nums",
|
|
1198
1692
|
children: [
|
|
@@ -1201,18 +1695,18 @@ function ImageGallery({
|
|
|
1201
1695
|
count
|
|
1202
1696
|
]
|
|
1203
1697
|
}),
|
|
1204
|
-
/* @__PURE__ */
|
|
1698
|
+
/* @__PURE__ */ jsx10(Button2, {
|
|
1205
1699
|
variant: "outline",
|
|
1206
1700
|
size: "icon-sm",
|
|
1207
1701
|
density,
|
|
1208
1702
|
"aria-label": nextLabel,
|
|
1209
1703
|
disabledReason: index === count - 1 ? "This is the last image" : undefined,
|
|
1210
1704
|
onClick: () => step(index + 1),
|
|
1211
|
-
children: /* @__PURE__ */
|
|
1705
|
+
children: /* @__PURE__ */ jsx10(ChevronRightIcon, {})
|
|
1212
1706
|
})
|
|
1213
1707
|
]
|
|
1214
1708
|
}),
|
|
1215
|
-
canCompareAll && /* @__PURE__ */
|
|
1709
|
+
canCompareAll && /* @__PURE__ */ jsx10(Toggle2, {
|
|
1216
1710
|
variant: "outline",
|
|
1217
1711
|
size: "sm",
|
|
1218
1712
|
density,
|
|
@@ -1224,7 +1718,7 @@ function ImageGallery({
|
|
|
1224
1718
|
]
|
|
1225
1719
|
})
|
|
1226
1720
|
}),
|
|
1227
|
-
/* @__PURE__ */
|
|
1721
|
+
/* @__PURE__ */ jsx10("p", {
|
|
1228
1722
|
role: "status",
|
|
1229
1723
|
"data-slot": "image-gallery-status",
|
|
1230
1724
|
className: "sr-only",
|
|
@@ -1234,7 +1728,7 @@ function ImageGallery({
|
|
|
1234
1728
|
});
|
|
1235
1729
|
}
|
|
1236
1730
|
// src/components/image-viewer/MediaShell.tsx
|
|
1237
|
-
import { jsx as
|
|
1731
|
+
import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1238
1732
|
function MediaShell({
|
|
1239
1733
|
open,
|
|
1240
1734
|
onOpenChange,
|
|
@@ -1243,26 +1737,28 @@ function MediaShell({
|
|
|
1243
1737
|
children,
|
|
1244
1738
|
density
|
|
1245
1739
|
}) {
|
|
1246
|
-
return /* @__PURE__ */
|
|
1740
|
+
return /* @__PURE__ */ jsx11(Dialog2, {
|
|
1247
1741
|
open,
|
|
1248
1742
|
onOpenChange,
|
|
1249
|
-
children: /* @__PURE__ */
|
|
1743
|
+
children: /* @__PURE__ */ jsxs9(DialogContent2, {
|
|
1250
1744
|
size: "fullscreen",
|
|
1251
1745
|
density,
|
|
1252
1746
|
"data-slot": "media-shell",
|
|
1747
|
+
className: "[@media(max-height:280px)]:gap-1.5 [@media(max-height:280px)]:p-2",
|
|
1253
1748
|
children: [
|
|
1254
|
-
/* @__PURE__ */
|
|
1749
|
+
/* @__PURE__ */ jsxs9(DialogHeader2, {
|
|
1255
1750
|
children: [
|
|
1256
|
-
/* @__PURE__ */
|
|
1751
|
+
/* @__PURE__ */ jsx11(DialogTitle2, {
|
|
1257
1752
|
className: "truncate",
|
|
1258
1753
|
children: title
|
|
1259
1754
|
}),
|
|
1260
|
-
description !== undefined && /* @__PURE__ */
|
|
1755
|
+
description !== undefined && /* @__PURE__ */ jsx11(DialogDescription2, {
|
|
1756
|
+
className: "[@media(max-height:280px)]:sr-only",
|
|
1261
1757
|
children: description
|
|
1262
1758
|
})
|
|
1263
1759
|
]
|
|
1264
1760
|
}),
|
|
1265
|
-
/* @__PURE__ */
|
|
1761
|
+
/* @__PURE__ */ jsx11("div", {
|
|
1266
1762
|
"data-slot": "media-shell-stage",
|
|
1267
1763
|
"data-scroll": "none",
|
|
1268
1764
|
className: "flex min-h-0 min-w-0 flex-1 flex-col",
|
|
@@ -1273,19 +1769,19 @@ function MediaShell({
|
|
|
1273
1769
|
});
|
|
1274
1770
|
}
|
|
1275
1771
|
// src/components/image-viewer/ImageComparison.tsx
|
|
1276
|
-
import { useControlled as
|
|
1277
|
-
import { useRef as
|
|
1772
|
+
import { useControlled as useControlled4 } from "@base-ui/utils/useControlled";
|
|
1773
|
+
import { useRef as useRef8, useState as useState9 } from "react";
|
|
1278
1774
|
|
|
1279
1775
|
// src/components/image-viewer/ImageComparisonToolbar.tsx
|
|
1280
1776
|
import { ChevronLeftIcon as ChevronLeftIcon2, ChevronRightIcon as ChevronRightIcon2, Columns2Icon, Rows2Icon } from "lucide-react";
|
|
1281
|
-
import { useId as
|
|
1282
|
-
import { jsx as
|
|
1777
|
+
import { useId as useId3 } from "react";
|
|
1778
|
+
import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1283
1779
|
function ToolbarSection({ title, titleId, children }) {
|
|
1284
|
-
return /* @__PURE__ */
|
|
1780
|
+
return /* @__PURE__ */ jsxs10("div", {
|
|
1285
1781
|
"data-slot": "image-comparison-toolbar-section",
|
|
1286
1782
|
className: "flex shrink-0 items-center",
|
|
1287
1783
|
children: [
|
|
1288
|
-
/* @__PURE__ */
|
|
1784
|
+
/* @__PURE__ */ jsx12("span", {
|
|
1289
1785
|
id: titleId,
|
|
1290
1786
|
className: "sr-only",
|
|
1291
1787
|
children: title
|
|
@@ -1338,24 +1834,24 @@ function ImageComparisonToolbar({
|
|
|
1338
1834
|
toolbar,
|
|
1339
1835
|
density
|
|
1340
1836
|
}) {
|
|
1341
|
-
const id =
|
|
1837
|
+
const id = useId3();
|
|
1342
1838
|
const isUnavailable = differences.status === "unavailable";
|
|
1343
1839
|
const regionCount = showDifferences && differences.status === "ready" ? differences.diff.regions.length : 0;
|
|
1344
1840
|
const hasStepper = regionCount > 0;
|
|
1345
1841
|
const releasePeek = () => onPeekChange(false);
|
|
1346
1842
|
const statusText = describeDifferences(differences, showDifferences);
|
|
1347
1843
|
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;
|
|
1348
|
-
return /* @__PURE__ */
|
|
1844
|
+
return /* @__PURE__ */ jsxs10("div", {
|
|
1349
1845
|
role: "group",
|
|
1350
1846
|
"aria-label": "Comparison controls",
|
|
1351
1847
|
"data-slot": "image-comparison-toolbar",
|
|
1352
1848
|
"data-density": density,
|
|
1353
1849
|
className: "flex shrink-0 flex-wrap items-center gap-x-2 gap-y-2 border-b border-border py-2",
|
|
1354
1850
|
children: [
|
|
1355
|
-
/* @__PURE__ */
|
|
1851
|
+
/* @__PURE__ */ jsx12(ToolbarSection, {
|
|
1356
1852
|
title: "Mode",
|
|
1357
1853
|
titleId: `${id}-mode`,
|
|
1358
|
-
children: /* @__PURE__ */
|
|
1854
|
+
children: /* @__PURE__ */ jsxs10(ToggleGroup2, {
|
|
1359
1855
|
"aria-labelledby": `${id}-mode`,
|
|
1360
1856
|
required: true,
|
|
1361
1857
|
value: [mode],
|
|
@@ -1365,25 +1861,25 @@ function ImageComparisonToolbar({
|
|
|
1365
1861
|
spacing: 0,
|
|
1366
1862
|
density,
|
|
1367
1863
|
children: [
|
|
1368
|
-
/* @__PURE__ */
|
|
1864
|
+
/* @__PURE__ */ jsx12(ToggleGroupItem2, {
|
|
1369
1865
|
value: "toggle",
|
|
1370
1866
|
children: "Toggle"
|
|
1371
1867
|
}),
|
|
1372
|
-
/* @__PURE__ */
|
|
1868
|
+
/* @__PURE__ */ jsx12(ToggleGroupItem2, {
|
|
1373
1869
|
value: "swipe",
|
|
1374
1870
|
children: "Swipe"
|
|
1375
1871
|
}),
|
|
1376
|
-
/* @__PURE__ */
|
|
1872
|
+
/* @__PURE__ */ jsx12(ToggleGroupItem2, {
|
|
1377
1873
|
value: "side-by-side",
|
|
1378
1874
|
children: "Side by side"
|
|
1379
1875
|
})
|
|
1380
1876
|
]
|
|
1381
1877
|
})
|
|
1382
1878
|
}),
|
|
1383
|
-
mode === "toggle" && /* @__PURE__ */
|
|
1879
|
+
mode === "toggle" && /* @__PURE__ */ jsx12(ToolbarSection, {
|
|
1384
1880
|
title: "Shown image",
|
|
1385
1881
|
titleId: `${id}-side`,
|
|
1386
|
-
children: /* @__PURE__ */
|
|
1882
|
+
children: /* @__PURE__ */ jsxs10(ToggleGroup2, {
|
|
1387
1883
|
"aria-labelledby": `${id}-side`,
|
|
1388
1884
|
"aria-keyshortcuts": "B A",
|
|
1389
1885
|
required: true,
|
|
@@ -1394,21 +1890,21 @@ function ImageComparisonToolbar({
|
|
|
1394
1890
|
spacing: 0,
|
|
1395
1891
|
density,
|
|
1396
1892
|
children: [
|
|
1397
|
-
/* @__PURE__ */
|
|
1893
|
+
/* @__PURE__ */ jsx12(ToggleGroupItem2, {
|
|
1398
1894
|
value: "before",
|
|
1399
1895
|
children: beforeLabel
|
|
1400
1896
|
}),
|
|
1401
|
-
/* @__PURE__ */
|
|
1897
|
+
/* @__PURE__ */ jsx12(ToggleGroupItem2, {
|
|
1402
1898
|
value: "after",
|
|
1403
1899
|
children: afterLabel
|
|
1404
1900
|
})
|
|
1405
1901
|
]
|
|
1406
1902
|
})
|
|
1407
1903
|
}),
|
|
1408
|
-
mode === "side-by-side" && /* @__PURE__ */
|
|
1904
|
+
mode === "side-by-side" && /* @__PURE__ */ jsx12(ToolbarSection, {
|
|
1409
1905
|
title: "Orientation",
|
|
1410
1906
|
titleId: `${id}-orientation`,
|
|
1411
|
-
children: /* @__PURE__ */
|
|
1907
|
+
children: /* @__PURE__ */ jsxs10(ToggleGroup2, {
|
|
1412
1908
|
"aria-labelledby": `${id}-orientation`,
|
|
1413
1909
|
required: true,
|
|
1414
1910
|
value: [orientation],
|
|
@@ -1418,19 +1914,19 @@ function ImageComparisonToolbar({
|
|
|
1418
1914
|
spacing: 0,
|
|
1419
1915
|
density,
|
|
1420
1916
|
children: [
|
|
1421
|
-
/* @__PURE__ */
|
|
1917
|
+
/* @__PURE__ */ jsxs10(ToggleGroupItem2, {
|
|
1422
1918
|
value: "horizontal",
|
|
1423
1919
|
children: [
|
|
1424
|
-
/* @__PURE__ */
|
|
1920
|
+
/* @__PURE__ */ jsx12(Columns2Icon, {
|
|
1425
1921
|
"data-icon": "inline-start"
|
|
1426
1922
|
}),
|
|
1427
1923
|
"Horizontal"
|
|
1428
1924
|
]
|
|
1429
1925
|
}),
|
|
1430
|
-
/* @__PURE__ */
|
|
1926
|
+
/* @__PURE__ */ jsxs10(ToggleGroupItem2, {
|
|
1431
1927
|
value: "vertical",
|
|
1432
1928
|
children: [
|
|
1433
|
-
/* @__PURE__ */
|
|
1929
|
+
/* @__PURE__ */ jsx12(Rows2Icon, {
|
|
1434
1930
|
"data-icon": "inline-start"
|
|
1435
1931
|
}),
|
|
1436
1932
|
"Vertical"
|
|
@@ -1439,16 +1935,16 @@ function ImageComparisonToolbar({
|
|
|
1439
1935
|
]
|
|
1440
1936
|
})
|
|
1441
1937
|
}),
|
|
1442
|
-
/* @__PURE__ */
|
|
1938
|
+
/* @__PURE__ */ jsx12(ToolbarSection, {
|
|
1443
1939
|
title: "Zoom",
|
|
1444
1940
|
titleId: `${id}-zoom`,
|
|
1445
|
-
children: /* @__PURE__ */
|
|
1941
|
+
children: /* @__PURE__ */ jsx12(ImageZoomToggle, {
|
|
1446
1942
|
zoom,
|
|
1447
1943
|
onZoomChange,
|
|
1448
1944
|
density
|
|
1449
1945
|
})
|
|
1450
1946
|
}),
|
|
1451
|
-
mode === "toggle" && /* @__PURE__ */
|
|
1947
|
+
mode === "toggle" && /* @__PURE__ */ jsx12(Button2, {
|
|
1452
1948
|
variant: "outline",
|
|
1453
1949
|
size: "sm",
|
|
1454
1950
|
density,
|
|
@@ -1472,49 +1968,49 @@ function ImageComparisonToolbar({
|
|
|
1472
1968
|
onContextMenu: (event) => event.preventDefault(),
|
|
1473
1969
|
children: `Hold to show ${side === "before" ? "after" : "before"}`
|
|
1474
1970
|
}),
|
|
1475
|
-
/* @__PURE__ */
|
|
1971
|
+
/* @__PURE__ */ jsxs10("div", {
|
|
1476
1972
|
className: "flex min-w-0 flex-wrap items-center gap-2",
|
|
1477
1973
|
children: [
|
|
1478
|
-
/* @__PURE__ */
|
|
1974
|
+
/* @__PURE__ */ jsxs10("div", {
|
|
1479
1975
|
className: "flex items-center gap-1.5",
|
|
1480
1976
|
children: [
|
|
1481
|
-
/* @__PURE__ */
|
|
1977
|
+
/* @__PURE__ */ jsx12(Switch2, {
|
|
1482
1978
|
id: `${id}-differences`,
|
|
1483
1979
|
"aria-describedby": `${id}-differences-status`,
|
|
1484
1980
|
checked: showDifferences && !isUnavailable,
|
|
1485
1981
|
disabled: isUnavailable,
|
|
1486
1982
|
onCheckedChange: onShowDifferencesChange
|
|
1487
1983
|
}),
|
|
1488
|
-
/* @__PURE__ */
|
|
1984
|
+
/* @__PURE__ */ jsx12("label", {
|
|
1489
1985
|
htmlFor: `${id}-differences`,
|
|
1490
1986
|
className: "cursor-pointer text-sm leading-none font-medium whitespace-nowrap select-none",
|
|
1491
1987
|
children: "Highlight differences"
|
|
1492
1988
|
})
|
|
1493
1989
|
]
|
|
1494
1990
|
}),
|
|
1495
|
-
showDifferences && differences.status === "ready" && /* @__PURE__ */
|
|
1991
|
+
showDifferences && differences.status === "ready" && /* @__PURE__ */ jsxs10("span", {
|
|
1496
1992
|
"data-slot": "image-comparison-legend",
|
|
1497
1993
|
className: "flex items-center gap-1.5 text-xs whitespace-nowrap text-muted-foreground",
|
|
1498
1994
|
children: [
|
|
1499
|
-
/* @__PURE__ */
|
|
1995
|
+
/* @__PURE__ */ jsx12("span", {
|
|
1500
1996
|
"aria-hidden": "true",
|
|
1501
1997
|
className: "mx-[3px] size-2.5 shrink-0 rounded-xs bg-warning/10 ring-1 ring-background outline-2 outline-offset-1 outline-warning"
|
|
1502
1998
|
}),
|
|
1503
1999
|
"Changed region"
|
|
1504
2000
|
]
|
|
1505
2001
|
}),
|
|
1506
|
-
hasStepper && /* @__PURE__ */
|
|
2002
|
+
hasStepper && /* @__PURE__ */ jsxs10("div", {
|
|
1507
2003
|
role: "group",
|
|
1508
2004
|
"aria-label": "Changed regions",
|
|
1509
2005
|
"data-slot": "image-comparison-stepper",
|
|
1510
2006
|
className: "flex flex-wrap items-center gap-1.5",
|
|
1511
2007
|
children: [
|
|
1512
|
-
/* @__PURE__ */
|
|
2008
|
+
/* @__PURE__ */ jsx12("span", {
|
|
1513
2009
|
"aria-hidden": "true",
|
|
1514
2010
|
className: "text-muted-foreground",
|
|
1515
2011
|
children: "·"
|
|
1516
2012
|
}),
|
|
1517
|
-
/* @__PURE__ */
|
|
2013
|
+
/* @__PURE__ */ jsxs10("span", {
|
|
1518
2014
|
"data-slot": "image-comparison-change-count",
|
|
1519
2015
|
className: "text-xs whitespace-nowrap text-muted-foreground tabular-nums",
|
|
1520
2016
|
children: [
|
|
@@ -1524,25 +2020,25 @@ function ImageComparisonToolbar({
|
|
|
1524
2020
|
regionCount
|
|
1525
2021
|
]
|
|
1526
2022
|
}),
|
|
1527
|
-
/* @__PURE__ */
|
|
2023
|
+
/* @__PURE__ */ jsx12(Button2, {
|
|
1528
2024
|
variant: "outline",
|
|
1529
2025
|
size: "icon-sm",
|
|
1530
2026
|
density,
|
|
1531
2027
|
"aria-label": "Previous change",
|
|
1532
2028
|
"aria-keyshortcuts": "Shift+N",
|
|
1533
2029
|
onClick: () => onStepChange(-1),
|
|
1534
|
-
children: /* @__PURE__ */
|
|
2030
|
+
children: /* @__PURE__ */ jsx12(ChevronLeftIcon2, {})
|
|
1535
2031
|
}),
|
|
1536
|
-
/* @__PURE__ */
|
|
2032
|
+
/* @__PURE__ */ jsx12(Button2, {
|
|
1537
2033
|
variant: "outline",
|
|
1538
2034
|
size: "icon-sm",
|
|
1539
2035
|
density,
|
|
1540
2036
|
"aria-label": "Next change",
|
|
1541
2037
|
"aria-keyshortcuts": "N",
|
|
1542
2038
|
onClick: () => onStepChange(1),
|
|
1543
|
-
children: /* @__PURE__ */
|
|
2039
|
+
children: /* @__PURE__ */ jsx12(ChevronRightIcon2, {})
|
|
1544
2040
|
}),
|
|
1545
|
-
onCommentActiveDifference && /* @__PURE__ */
|
|
2041
|
+
onCommentActiveDifference && /* @__PURE__ */ jsx12(Button2, {
|
|
1546
2042
|
variant: "outline",
|
|
1547
2043
|
size: "sm",
|
|
1548
2044
|
density,
|
|
@@ -1552,7 +2048,7 @@ function ImageComparisonToolbar({
|
|
|
1552
2048
|
})
|
|
1553
2049
|
]
|
|
1554
2050
|
}),
|
|
1555
|
-
/* @__PURE__ */
|
|
2051
|
+
/* @__PURE__ */ jsx12("p", {
|
|
1556
2052
|
id: `${id}-differences-status`,
|
|
1557
2053
|
role: "status",
|
|
1558
2054
|
className: hasStepper || !statusText ? "sr-only" : "text-xs text-muted-foreground",
|
|
@@ -1560,12 +2056,12 @@ function ImageComparisonToolbar({
|
|
|
1560
2056
|
})
|
|
1561
2057
|
]
|
|
1562
2058
|
}),
|
|
1563
|
-
toolbar && /* @__PURE__ */
|
|
2059
|
+
toolbar && /* @__PURE__ */ jsx12("div", {
|
|
1564
2060
|
"data-slot": "image-comparison-toolbar-extra",
|
|
1565
2061
|
className: "flex min-w-0 flex-wrap items-center gap-2 @2xl:border-s @2xl:border-border @2xl:ps-2",
|
|
1566
2062
|
children: toolbar
|
|
1567
2063
|
}),
|
|
1568
|
-
sizeMismatch && /* @__PURE__ */
|
|
2064
|
+
sizeMismatch && /* @__PURE__ */ jsx12("p", {
|
|
1569
2065
|
"data-slot": "image-comparison-size-mismatch",
|
|
1570
2066
|
className: "w-full text-xs text-muted-foreground",
|
|
1571
2067
|
children: sizeMismatch
|
|
@@ -1575,16 +2071,16 @@ function ImageComparisonToolbar({
|
|
|
1575
2071
|
}
|
|
1576
2072
|
|
|
1577
2073
|
// src/components/image-viewer/ImageDifferenceOverlay.tsx
|
|
1578
|
-
import { jsx as
|
|
2074
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
1579
2075
|
function toPercent2(value, total) {
|
|
1580
2076
|
return `${value / total * 100}%`;
|
|
1581
2077
|
}
|
|
1582
2078
|
function ImageDifferenceOverlay({ diff, activeIndex }) {
|
|
1583
|
-
return /* @__PURE__ */
|
|
2079
|
+
return /* @__PURE__ */ jsx13("div", {
|
|
1584
2080
|
"data-slot": "image-difference-overlay",
|
|
1585
2081
|
"aria-hidden": "true",
|
|
1586
2082
|
className: "pointer-events-none absolute inset-0",
|
|
1587
|
-
children: diff.regions.map((region, index) => /* @__PURE__ */
|
|
2083
|
+
children: diff.regions.map((region, index) => /* @__PURE__ */ jsx13(ImageRegionMarker, {
|
|
1588
2084
|
"data-slot": "image-difference-region",
|
|
1589
2085
|
variant: "difference",
|
|
1590
2086
|
active: index === activeIndex,
|
|
@@ -1602,16 +2098,16 @@ function ImageDifferenceOverlay({ diff, activeIndex }) {
|
|
|
1602
2098
|
import { DirectionProvider } from "@base-ui/react/direction-provider";
|
|
1603
2099
|
import { Slider as SliderPrimitive } from "@base-ui/react/slider";
|
|
1604
2100
|
import { ChevronsLeftRightIcon } from "lucide-react";
|
|
1605
|
-
import { jsx as
|
|
2101
|
+
import { jsx as jsx14, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1606
2102
|
function ImageSwipeDivider({
|
|
1607
2103
|
value,
|
|
1608
2104
|
onValueChange,
|
|
1609
2105
|
beforeLabel,
|
|
1610
2106
|
afterLabel
|
|
1611
2107
|
}) {
|
|
1612
|
-
return /* @__PURE__ */
|
|
2108
|
+
return /* @__PURE__ */ jsx14(DirectionProvider, {
|
|
1613
2109
|
direction: "ltr",
|
|
1614
|
-
children: /* @__PURE__ */
|
|
2110
|
+
children: /* @__PURE__ */ jsx14(SliderPrimitive.Root, {
|
|
1615
2111
|
dir: "ltr",
|
|
1616
2112
|
"data-slot": "image-swipe-divider",
|
|
1617
2113
|
value,
|
|
@@ -1621,22 +2117,22 @@ function ImageSwipeDivider({
|
|
|
1621
2117
|
step: 1,
|
|
1622
2118
|
largeStep: 10,
|
|
1623
2119
|
className: "pointer-events-none absolute inset-0",
|
|
1624
|
-
children: /* @__PURE__ */
|
|
2120
|
+
children: /* @__PURE__ */ jsx14(SliderPrimitive.Control, {
|
|
1625
2121
|
className: "pointer-events-none absolute inset-0",
|
|
1626
|
-
children: /* @__PURE__ */
|
|
2122
|
+
children: /* @__PURE__ */ jsxs11(SliderPrimitive.Thumb, {
|
|
1627
2123
|
"data-slot": "image-swipe-divider-handle",
|
|
1628
2124
|
getAriaLabel: () => "Swipe divider",
|
|
1629
2125
|
getAriaValueText: (_formatted, current) => `${beforeLabel} ${current}%, ${afterLabel} ${100 - current}%`,
|
|
1630
2126
|
className: "group/divider pointer-events-auto flex h-full w-6 cursor-ew-resize touch-none flex-col items-center justify-center select-none",
|
|
1631
2127
|
children: [
|
|
1632
|
-
/* @__PURE__ */
|
|
2128
|
+
/* @__PURE__ */ jsx14("span", {
|
|
1633
2129
|
"aria-hidden": "true",
|
|
1634
2130
|
className: "absolute inset-y-0 start-1/2 w-0.5 -translate-x-1/2 bg-foreground ring-1 ring-background"
|
|
1635
2131
|
}),
|
|
1636
|
-
/* @__PURE__ */
|
|
2132
|
+
/* @__PURE__ */ jsx14("span", {
|
|
1637
2133
|
"aria-hidden": "true",
|
|
1638
2134
|
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",
|
|
1639
|
-
children: /* @__PURE__ */
|
|
2135
|
+
children: /* @__PURE__ */ jsx14(ChevronsLeftRightIcon, {
|
|
1640
2136
|
className: "size-3.5"
|
|
1641
2137
|
})
|
|
1642
2138
|
})
|
|
@@ -1648,7 +2144,7 @@ function ImageSwipeDivider({
|
|
|
1648
2144
|
}
|
|
1649
2145
|
|
|
1650
2146
|
// src/components/image-viewer/hooks/useImageDifferences.ts
|
|
1651
|
-
import { useEffect as
|
|
2147
|
+
import { useEffect as useEffect3, useRef as useRef7, useState as useState8 } from "react";
|
|
1652
2148
|
|
|
1653
2149
|
// src/components/image-viewer/computeImageDiff.ts
|
|
1654
2150
|
var DEFAULT_THRESHOLD = 32;
|
|
@@ -1861,11 +2357,11 @@ function useImageDifferences({
|
|
|
1861
2357
|
beforeRef,
|
|
1862
2358
|
afterRef
|
|
1863
2359
|
}) {
|
|
1864
|
-
const [entries, setEntries] =
|
|
1865
|
-
const startedRef =
|
|
1866
|
-
const controllerRef =
|
|
1867
|
-
|
|
1868
|
-
|
|
2360
|
+
const [entries, setEntries] = useState8(() => new Map);
|
|
2361
|
+
const startedRef = useRef7(new Set);
|
|
2362
|
+
const controllerRef = useRef7(undefined);
|
|
2363
|
+
useEffect3(() => () => controllerRef.current?.abort(), [pairKey]);
|
|
2364
|
+
useEffect3(() => {
|
|
1869
2365
|
const before = beforeRef.current;
|
|
1870
2366
|
const after = afterRef.current;
|
|
1871
2367
|
if (!loaded || !before || !after)
|
|
@@ -1880,7 +2376,7 @@ function useImageDifferences({
|
|
|
1880
2376
|
isCurrent = false;
|
|
1881
2377
|
};
|
|
1882
2378
|
}, [afterRef, beforeRef, loaded, pairKey]);
|
|
1883
|
-
|
|
2379
|
+
useEffect3(() => {
|
|
1884
2380
|
const before = beforeRef.current;
|
|
1885
2381
|
const after = afterRef.current;
|
|
1886
2382
|
if (!enabled || !loaded || !before || !after || startedRef.current.has(pairKey))
|
|
@@ -1902,16 +2398,16 @@ function useImageDifferences({
|
|
|
1902
2398
|
}
|
|
1903
2399
|
|
|
1904
2400
|
// src/components/image-viewer/ImageComparison.tsx
|
|
1905
|
-
import { jsx as
|
|
2401
|
+
import { jsx as jsx15, jsxs as jsxs12, Fragment as Fragment2 } from "react/jsx-runtime";
|
|
1906
2402
|
function ComparisonPane({ header, children }) {
|
|
1907
|
-
return /* @__PURE__ */
|
|
2403
|
+
return /* @__PURE__ */ jsxs12("div", {
|
|
1908
2404
|
"data-slot": "image-comparison-pane",
|
|
1909
2405
|
"data-scroll": "none",
|
|
1910
2406
|
className: "flex min-h-0 min-w-0 flex-1 flex-col",
|
|
1911
2407
|
children: [
|
|
1912
|
-
/* @__PURE__ */
|
|
2408
|
+
/* @__PURE__ */ jsx15("div", {
|
|
1913
2409
|
"data-slot": "image-comparison-pane-header",
|
|
1914
|
-
className: "flex h-control shrink-0 items-center justify-between gap-2
|
|
2410
|
+
className: "flex h-control shrink-0 items-center justify-between gap-2 text-xs font-medium text-muted-foreground",
|
|
1915
2411
|
children: header
|
|
1916
2412
|
}),
|
|
1917
2413
|
children
|
|
@@ -1956,31 +2452,31 @@ function ImageComparison({
|
|
|
1956
2452
|
label = "Image comparison",
|
|
1957
2453
|
density
|
|
1958
2454
|
}) {
|
|
1959
|
-
const [mode, setModeState] =
|
|
2455
|
+
const [mode, setModeState] = useControlled4({
|
|
1960
2456
|
controlled: modeProp,
|
|
1961
2457
|
default: defaultMode,
|
|
1962
2458
|
name: "ImageComparison",
|
|
1963
2459
|
state: "mode"
|
|
1964
2460
|
});
|
|
1965
|
-
const [side, setSideState] =
|
|
2461
|
+
const [side, setSideState] = useControlled4({
|
|
1966
2462
|
controlled: sideProp,
|
|
1967
2463
|
default: defaultSide,
|
|
1968
2464
|
name: "ImageComparison",
|
|
1969
2465
|
state: "side"
|
|
1970
2466
|
});
|
|
1971
|
-
const [chosenOrientation, setOrientationState] =
|
|
2467
|
+
const [chosenOrientation, setOrientationState] = useControlled4({
|
|
1972
2468
|
controlled: orientationProp,
|
|
1973
2469
|
default: defaultOrientation,
|
|
1974
2470
|
name: "ImageComparison",
|
|
1975
2471
|
state: "orientation"
|
|
1976
2472
|
});
|
|
1977
|
-
const [zoom, setZoomState] =
|
|
2473
|
+
const [zoom, setZoomState] = useControlled4({
|
|
1978
2474
|
controlled: zoomProp,
|
|
1979
2475
|
default: defaultZoom,
|
|
1980
2476
|
name: "ImageComparison",
|
|
1981
2477
|
state: "zoom"
|
|
1982
2478
|
});
|
|
1983
|
-
const [showDifferences, setShowDifferencesState] =
|
|
2479
|
+
const [showDifferences, setShowDifferencesState] = useControlled4({
|
|
1984
2480
|
controlled: showDifferencesProp,
|
|
1985
2481
|
default: defaultShowDifferences,
|
|
1986
2482
|
name: "ImageComparison",
|
|
@@ -1988,12 +2484,12 @@ function ImageComparison({
|
|
|
1988
2484
|
});
|
|
1989
2485
|
const pairKey = `${before.src}
|
|
1990
2486
|
${after.src}`;
|
|
1991
|
-
const [isPeeking, setIsPeeking] =
|
|
1992
|
-
const [position, setPosition] =
|
|
1993
|
-
const [activeRegionIndex, setActiveRegionIndex] =
|
|
1994
|
-
const [changeAnnouncement, setChangeAnnouncement] =
|
|
1995
|
-
const [lastPairKey, setLastPairKey] =
|
|
1996
|
-
const [lastShowDifferences, setLastShowDifferences] =
|
|
2487
|
+
const [isPeeking, setIsPeeking] = useState9(false);
|
|
2488
|
+
const [position, setPosition] = useState9(50);
|
|
2489
|
+
const [activeRegionIndex, setActiveRegionIndex] = useState9(0);
|
|
2490
|
+
const [changeAnnouncement, setChangeAnnouncement] = useState9("");
|
|
2491
|
+
const [lastPairKey, setLastPairKey] = useState9(pairKey);
|
|
2492
|
+
const [lastShowDifferences, setLastShowDifferences] = useState9(showDifferences);
|
|
1997
2493
|
if (lastPairKey !== pairKey || lastShowDifferences !== showDifferences) {
|
|
1998
2494
|
setLastPairKey(pairKey);
|
|
1999
2495
|
setLastShowDifferences(showDifferences);
|
|
@@ -2002,14 +2498,14 @@ ${after.src}`;
|
|
|
2002
2498
|
}
|
|
2003
2499
|
const [beforeImage, beforeHandlers] = useImageLoad(before.src);
|
|
2004
2500
|
const [afterImage, afterHandlers] = useImageLoad(after.src);
|
|
2005
|
-
const beforeRef =
|
|
2006
|
-
const afterRef =
|
|
2007
|
-
const stageRef =
|
|
2008
|
-
const singleViewportRef =
|
|
2009
|
-
const beforeViewportRef =
|
|
2010
|
-
const afterViewportRef =
|
|
2011
|
-
const expectedScrollRef =
|
|
2012
|
-
const center =
|
|
2501
|
+
const beforeRef = useRef8(null);
|
|
2502
|
+
const afterRef = useRef8(null);
|
|
2503
|
+
const stageRef = useRef8(null);
|
|
2504
|
+
const singleViewportRef = useRef8(null);
|
|
2505
|
+
const beforeViewportRef = useRef8(null);
|
|
2506
|
+
const afterViewportRef = useRef8(null);
|
|
2507
|
+
const expectedScrollRef = useRef8(new WeakMap);
|
|
2508
|
+
const center = useRef8({ x: 0.5, y: 0.5 });
|
|
2013
2509
|
const stageSize = useElementSize(stageRef);
|
|
2014
2510
|
const autoOrientation = stageSize && stageSize.height > stageSize.width ? "vertical" : "horizontal";
|
|
2015
2511
|
const orientation = chosenOrientation ?? autoOrientation;
|
|
@@ -2026,13 +2522,13 @@ ${after.src}`;
|
|
|
2026
2522
|
const clampedActiveIndex = regions.length > 0 ? Math.min(activeRegionIndex, regions.length - 1) : 0;
|
|
2027
2523
|
const shownSide = mode !== "toggle" ? "after" : isPeeking ? side === "before" ? "after" : "before" : side;
|
|
2028
2524
|
const isShowingBefore = shownSide === "before";
|
|
2029
|
-
const diffOverlay = showDifferences && differences.status === "ready" ? /* @__PURE__ */
|
|
2525
|
+
const diffOverlay = showDifferences && differences.status === "ready" ? /* @__PURE__ */ jsx15(ImageDifferenceOverlay, {
|
|
2030
2526
|
diff: differences.diff,
|
|
2031
2527
|
activeIndex: clampedActiveIndex
|
|
2032
2528
|
}) : null;
|
|
2033
2529
|
const activeRegion = regions[clampedActiveIndex];
|
|
2034
2530
|
const handleCommentActiveDifference = onCommentDifference && showDifferences && differences.status === "ready" && activeRegion ? () => onCommentDifference(activeRegion, clampedActiveIndex, differences.diff) : undefined;
|
|
2035
|
-
const fallback = failedLabel ? /* @__PURE__ */
|
|
2531
|
+
const fallback = failedLabel ? /* @__PURE__ */ jsxs12("p", {
|
|
2036
2532
|
"data-slot": "image-comparison-error",
|
|
2037
2533
|
className: "m-auto p-panel text-center text-sm text-muted-foreground",
|
|
2038
2534
|
children: [
|
|
@@ -2135,7 +2631,7 @@ ${after.src}`;
|
|
|
2135
2631
|
}
|
|
2136
2632
|
}
|
|
2137
2633
|
function renderAfterImage(className) {
|
|
2138
|
-
return /* @__PURE__ */
|
|
2634
|
+
return /* @__PURE__ */ jsx15("img", {
|
|
2139
2635
|
ref: afterRef,
|
|
2140
2636
|
src: after.src,
|
|
2141
2637
|
alt: after.alt,
|
|
@@ -2148,7 +2644,7 @@ ${after.src}`;
|
|
|
2148
2644
|
});
|
|
2149
2645
|
}
|
|
2150
2646
|
function renderBeforeImage(className, style) {
|
|
2151
|
-
return /* @__PURE__ */
|
|
2647
|
+
return /* @__PURE__ */ jsx15("img", {
|
|
2152
2648
|
ref: beforeRef,
|
|
2153
2649
|
src: before.src,
|
|
2154
2650
|
alt: before.alt,
|
|
@@ -2165,15 +2661,15 @@ ${after.src}`;
|
|
|
2165
2661
|
const toggleStageKeys = ["B A", sharedStageKeys].filter(Boolean).join(" ");
|
|
2166
2662
|
let content;
|
|
2167
2663
|
if (mode === "side-by-side") {
|
|
2168
|
-
content = /* @__PURE__ */
|
|
2664
|
+
content = /* @__PURE__ */ jsxs12("div", {
|
|
2169
2665
|
"data-slot": "image-comparison-panes",
|
|
2170
|
-
className: cn2("flex min-h-0 min-w-0 flex-1", orientation === "vertical" ? "flex-col" : "flex-row"),
|
|
2666
|
+
className: cn2("flex min-h-0 min-w-0 flex-1", orientation === "vertical" ? "flex-col gap-2" : "flex-row gap-3"),
|
|
2171
2667
|
children: [
|
|
2172
|
-
/* @__PURE__ */
|
|
2173
|
-
header: /* @__PURE__ */
|
|
2668
|
+
/* @__PURE__ */ jsx15(ComparisonPane, {
|
|
2669
|
+
header: /* @__PURE__ */ jsx15("span", {
|
|
2174
2670
|
children: beforeLabel
|
|
2175
2671
|
}),
|
|
2176
|
-
children: /* @__PURE__ */
|
|
2672
|
+
children: /* @__PURE__ */ jsxs12(ImageViewport, {
|
|
2177
2673
|
label: beforeLabel,
|
|
2178
2674
|
zoom,
|
|
2179
2675
|
naturalSize: afterImage.size,
|
|
@@ -2191,14 +2687,14 @@ ${after.src}`;
|
|
|
2191
2687
|
]
|
|
2192
2688
|
})
|
|
2193
2689
|
}),
|
|
2194
|
-
/* @__PURE__ */
|
|
2690
|
+
/* @__PURE__ */ jsx15(Separator2, {
|
|
2195
2691
|
orientation: orientation === "vertical" ? "horizontal" : "vertical"
|
|
2196
2692
|
}),
|
|
2197
|
-
/* @__PURE__ */
|
|
2198
|
-
header: /* @__PURE__ */
|
|
2693
|
+
/* @__PURE__ */ jsx15(ComparisonPane, {
|
|
2694
|
+
header: /* @__PURE__ */ jsx15("span", {
|
|
2199
2695
|
children: afterLabel
|
|
2200
2696
|
}),
|
|
2201
|
-
children: /* @__PURE__ */
|
|
2697
|
+
children: /* @__PURE__ */ jsxs12(ImageViewport, {
|
|
2202
2698
|
label: afterLabel,
|
|
2203
2699
|
zoom,
|
|
2204
2700
|
naturalSize: afterImage.size,
|
|
@@ -2219,18 +2715,18 @@ ${after.src}`;
|
|
|
2219
2715
|
]
|
|
2220
2716
|
});
|
|
2221
2717
|
} else if (mode === "swipe") {
|
|
2222
|
-
content = /* @__PURE__ */
|
|
2223
|
-
header: /* @__PURE__ */
|
|
2718
|
+
content = /* @__PURE__ */ jsx15(ComparisonPane, {
|
|
2719
|
+
header: /* @__PURE__ */ jsxs12(Fragment2, {
|
|
2224
2720
|
children: [
|
|
2225
|
-
/* @__PURE__ */
|
|
2721
|
+
/* @__PURE__ */ jsx15("span", {
|
|
2226
2722
|
children: beforeLabel
|
|
2227
2723
|
}),
|
|
2228
|
-
/* @__PURE__ */
|
|
2724
|
+
/* @__PURE__ */ jsx15("span", {
|
|
2229
2725
|
children: afterLabel
|
|
2230
2726
|
})
|
|
2231
2727
|
]
|
|
2232
2728
|
}),
|
|
2233
|
-
children: /* @__PURE__ */
|
|
2729
|
+
children: /* @__PURE__ */ jsxs12(ImageViewport, {
|
|
2234
2730
|
label: `${beforeLabel} and ${afterLabel}`,
|
|
2235
2731
|
zoom,
|
|
2236
2732
|
naturalSize: afterImage.size,
|
|
@@ -2246,7 +2742,7 @@ ${after.src}`;
|
|
|
2246
2742
|
beforeOverlay,
|
|
2247
2743
|
afterOverlay,
|
|
2248
2744
|
diffOverlay,
|
|
2249
|
-
/* @__PURE__ */
|
|
2745
|
+
/* @__PURE__ */ jsx15(ImageSwipeDivider, {
|
|
2250
2746
|
value: position,
|
|
2251
2747
|
onValueChange: handlePositionChange,
|
|
2252
2748
|
beforeLabel,
|
|
@@ -2258,8 +2754,8 @@ ${after.src}`;
|
|
|
2258
2754
|
});
|
|
2259
2755
|
} else {
|
|
2260
2756
|
const showingLabel = isShowingBefore ? beforeLabel : afterLabel;
|
|
2261
|
-
content = /* @__PURE__ */
|
|
2262
|
-
header: /* @__PURE__ */
|
|
2757
|
+
content = /* @__PURE__ */ jsx15(ComparisonPane, {
|
|
2758
|
+
header: /* @__PURE__ */ jsxs12("span", {
|
|
2263
2759
|
"data-slot": "image-comparison-showing",
|
|
2264
2760
|
"aria-live": "polite",
|
|
2265
2761
|
children: [
|
|
@@ -2267,7 +2763,7 @@ ${after.src}`;
|
|
|
2267
2763
|
showingLabel
|
|
2268
2764
|
]
|
|
2269
2765
|
}),
|
|
2270
|
-
children: /* @__PURE__ */
|
|
2766
|
+
children: /* @__PURE__ */ jsxs12(ImageViewport, {
|
|
2271
2767
|
label: showingLabel,
|
|
2272
2768
|
zoom,
|
|
2273
2769
|
naturalSize: afterImage.size,
|
|
@@ -2288,7 +2784,7 @@ ${after.src}`;
|
|
|
2288
2784
|
})
|
|
2289
2785
|
});
|
|
2290
2786
|
}
|
|
2291
|
-
return /* @__PURE__ */
|
|
2787
|
+
return /* @__PURE__ */ jsxs12("div", {
|
|
2292
2788
|
role: "group",
|
|
2293
2789
|
"aria-label": label,
|
|
2294
2790
|
"data-slot": "image-comparison",
|
|
@@ -2300,7 +2796,7 @@ ${after.src}`;
|
|
|
2300
2796
|
"data-showing": isShowingBefore ? "before" : "after",
|
|
2301
2797
|
className: "@container flex size-full min-h-0 min-w-0 flex-1 flex-col",
|
|
2302
2798
|
children: [
|
|
2303
|
-
showToolbar && /* @__PURE__ */
|
|
2799
|
+
showToolbar && /* @__PURE__ */ jsx15(ImageComparisonToolbar, {
|
|
2304
2800
|
mode,
|
|
2305
2801
|
onModeChange: setMode,
|
|
2306
2802
|
side,
|
|
@@ -2323,14 +2819,14 @@ ${after.src}`;
|
|
|
2323
2819
|
toolbar,
|
|
2324
2820
|
density
|
|
2325
2821
|
}),
|
|
2326
|
-
/* @__PURE__ */
|
|
2822
|
+
/* @__PURE__ */ jsx15("div", {
|
|
2327
2823
|
ref: stageRef,
|
|
2328
2824
|
"data-slot": "image-comparison-stage",
|
|
2329
2825
|
"data-scroll": "none",
|
|
2330
2826
|
className: "flex min-h-0 min-w-0 flex-1",
|
|
2331
2827
|
children: content
|
|
2332
2828
|
}),
|
|
2333
|
-
/* @__PURE__ */
|
|
2829
|
+
/* @__PURE__ */ jsx15("p", {
|
|
2334
2830
|
role: "status",
|
|
2335
2831
|
"data-slot": "image-comparison-change-announcement",
|
|
2336
2832
|
className: "sr-only",
|
|
@@ -2340,6 +2836,8 @@ ${after.src}`;
|
|
|
2340
2836
|
});
|
|
2341
2837
|
}
|
|
2342
2838
|
export {
|
|
2839
|
+
DiagramSurface,
|
|
2840
|
+
DiagramViewer,
|
|
2343
2841
|
FramedImage2 as FramedImage,
|
|
2344
2842
|
IMAGE_REGION_STEP,
|
|
2345
2843
|
IMAGE_ZOOM_STEPS,
|
|
@@ -2360,12 +2858,17 @@ export {
|
|
|
2360
2858
|
computeImageDiff,
|
|
2361
2859
|
formatImageRegion,
|
|
2362
2860
|
formatImageZoom,
|
|
2861
|
+
getDiagramSvgSize,
|
|
2363
2862
|
getImageRegionFromCorners,
|
|
2364
2863
|
getImageZoomScales,
|
|
2864
|
+
getMermaidThemeConfig,
|
|
2365
2865
|
getNextImageZoom,
|
|
2366
2866
|
getNormalizedImagePoint,
|
|
2367
2867
|
getOpeningImageZoom,
|
|
2368
2868
|
getPreviousImageZoom,
|
|
2369
2869
|
placeImageRegion,
|
|
2370
|
-
|
|
2870
|
+
prepareDiagramSvg,
|
|
2871
|
+
resolveCssColorToHex,
|
|
2872
|
+
resolveImageZoomScale,
|
|
2873
|
+
useMermaidTheme
|
|
2371
2874
|
};
|