@alexgorbatchev/shadcn 0.0.104 → 0.0.106
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-38barrma.js +110 -0
- package/dist/{chunk-p8bdmafq.js → chunk-j7fvvgyp.js} +2 -2
- package/dist/{chunk-23ppkypt.js → chunk-me64e034.js} +1 -100
- package/dist/{chunk-e1hkq1mw.js → chunk-rxmcz0j1.js} +617 -481
- package/dist/components/ActionBar.d.ts +31 -0
- package/dist/components/ErrorSummary.d.ts +21 -0
- package/dist/components/Outline.d.ts +20 -0
- package/dist/components/data-grid/index.js +7 -5
- package/dist/components/image-viewer/ImageRegionFields.d.ts +15 -0
- package/dist/components/image-viewer/ImageRegionSelect.d.ts +11 -6
- package/dist/components/image-viewer/imageRegion.d.ts +21 -0
- package/dist/components/image-viewer/index.d.ts +3 -0
- package/dist/components/image-viewer/index.js +247 -92
- package/dist/components/json-render/JsonDropdownMenu.d.ts +4 -0
- package/dist/components/json-render/JsonForm.d.ts +90 -0
- package/dist/components/json-render/catalog.js +1 -1
- package/dist/components/json-render/index.d.ts +2 -0
- package/dist/components/json-render/index.js +487 -228
- package/dist/index.d.ts +5 -0
- package/dist/index.js +26 -10
- package/dist/prototype.js +1 -1
- package/llms/components/data-display/ImageViewer.md +2 -2
- package/llms/components/data-display/JsonRenderForm.md +99 -0
- package/llms/components/feedback/ErrorSummary.md +46 -0
- package/llms/components/layout/ActionBar.md +65 -0
- package/llms/components/navigation/Outline.md +42 -0
- package/llms.txt +5 -1
- package/package.json +1 -1
|
@@ -14,19 +14,24 @@ import {
|
|
|
14
14
|
ToggleGroup2,
|
|
15
15
|
ToggleGroupItem2
|
|
16
16
|
} from "../../chunk-9n617bte.js";
|
|
17
|
-
import
|
|
18
|
-
FramedImage2
|
|
19
|
-
} from "../../chunk-2jsgsjas.js";
|
|
17
|
+
import"../../chunk-m32ptxf3.js";
|
|
20
18
|
import {
|
|
21
19
|
Separator2
|
|
22
20
|
} from "../../chunk-52aadmkc.js";
|
|
23
|
-
import"../../chunk-m32ptxf3.js";
|
|
24
21
|
import {
|
|
25
22
|
Field2,
|
|
26
23
|
FieldContent2,
|
|
27
24
|
FieldLabel2,
|
|
28
25
|
FieldDescription2
|
|
29
26
|
} from "../../chunk-bfv4qesg.js";
|
|
27
|
+
import {
|
|
28
|
+
NumberField2,
|
|
29
|
+
NumberFieldGroup2,
|
|
30
|
+
NumberFieldInput2
|
|
31
|
+
} from "../../chunk-38barrma.js";
|
|
32
|
+
import {
|
|
33
|
+
FramedImage2
|
|
34
|
+
} from "../../chunk-2jsgsjas.js";
|
|
30
35
|
import {
|
|
31
36
|
Switch2
|
|
32
37
|
} from "../../chunk-m98d89xc.js";
|
|
@@ -644,6 +649,58 @@ function getNormalizedImagePoint(point, box) {
|
|
|
644
649
|
};
|
|
645
650
|
}
|
|
646
651
|
|
|
652
|
+
// src/components/image-viewer/imageRegion.ts
|
|
653
|
+
var IMAGE_REGION_STEP = 0.05;
|
|
654
|
+
var MIN_IMAGE_REGION_SIZE = 0.01;
|
|
655
|
+
var DEFAULT_SIZE = 0.5;
|
|
656
|
+
function clamp2(value, min, max) {
|
|
657
|
+
return Math.min(max, Math.max(min, value));
|
|
658
|
+
}
|
|
659
|
+
function round(value) {
|
|
660
|
+
return Math.round(value * 1e4) / 1e4;
|
|
661
|
+
}
|
|
662
|
+
function clampImageRegion(region) {
|
|
663
|
+
const width = clamp2(region.width, MIN_IMAGE_REGION_SIZE, 1);
|
|
664
|
+
const height = clamp2(region.height, MIN_IMAGE_REGION_SIZE, 1);
|
|
665
|
+
return {
|
|
666
|
+
x: round(clamp2(region.x, 0, 1 - width)),
|
|
667
|
+
y: round(clamp2(region.y, 0, 1 - height)),
|
|
668
|
+
width: round(width),
|
|
669
|
+
height: round(height)
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
function placeImageRegion(center = { x: 0.5, y: 0.5 }) {
|
|
673
|
+
return clampImageRegion({
|
|
674
|
+
x: center.x - DEFAULT_SIZE / 2,
|
|
675
|
+
y: center.y - DEFAULT_SIZE / 2,
|
|
676
|
+
width: DEFAULT_SIZE,
|
|
677
|
+
height: DEFAULT_SIZE
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
function getImageRegionFromCorners(first, second) {
|
|
681
|
+
return clampImageRegion({
|
|
682
|
+
x: Math.min(first.x, second.x),
|
|
683
|
+
y: Math.min(first.y, second.y),
|
|
684
|
+
width: Math.abs(second.x - first.x),
|
|
685
|
+
height: Math.abs(second.y - first.y)
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
function applyImageRegionKey(region, key, isResize, step = IMAGE_REGION_STEP) {
|
|
689
|
+
const delta = { ArrowLeft: [-step, 0], ArrowRight: [step, 0], ArrowUp: [0, -step], ArrowDown: [0, step] }[key];
|
|
690
|
+
if (!delta)
|
|
691
|
+
return;
|
|
692
|
+
const [dx = 0, dy = 0] = delta;
|
|
693
|
+
if (isResize)
|
|
694
|
+
return clampImageRegion({ ...region, width: region.width + dx, height: region.height + dy });
|
|
695
|
+
return clampImageRegion({ ...region, x: region.x + dx, y: region.y + dy });
|
|
696
|
+
}
|
|
697
|
+
function percent(value) {
|
|
698
|
+
return `${round(value * 100)}%`;
|
|
699
|
+
}
|
|
700
|
+
function formatImageRegion(region) {
|
|
701
|
+
return `Region ${percent(region.width)} × ${percent(region.height)} at ${percent(region.x)}, ${percent(region.y)}`;
|
|
702
|
+
}
|
|
703
|
+
|
|
647
704
|
// src/components/image-viewer/ImageRegionMarker.tsx
|
|
648
705
|
import { cva } from "class-variance-authority";
|
|
649
706
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
@@ -699,14 +756,35 @@ function toRegion(start, end) {
|
|
|
699
756
|
height: Math.abs(end.y - start.y)
|
|
700
757
|
};
|
|
701
758
|
}
|
|
702
|
-
function
|
|
759
|
+
function toBox(region) {
|
|
760
|
+
return {
|
|
761
|
+
left: `${region.x * 100}%`,
|
|
762
|
+
top: `${region.y * 100}%`,
|
|
763
|
+
width: `${region.width * 100}%`,
|
|
764
|
+
height: `${region.height * 100}%`
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
function ImageRegionSelect({ region, onRegionChange }) {
|
|
703
768
|
const drag = useRef3(null);
|
|
769
|
+
const pendingClick = useRef3(null);
|
|
704
770
|
const [draft, setDraft] = useState4();
|
|
705
771
|
const point = (event) => getNormalizedImagePoint(event, event.currentTarget.getBoundingClientRect());
|
|
706
772
|
function cancel() {
|
|
707
773
|
drag.current = null;
|
|
708
774
|
setDraft(undefined);
|
|
709
775
|
}
|
|
776
|
+
function click(at) {
|
|
777
|
+
const pending = pendingClick.current;
|
|
778
|
+
if (pending && pending.region === region) {
|
|
779
|
+
pendingClick.current = null;
|
|
780
|
+
onRegionChange(getImageRegionFromCorners(pending.point, at));
|
|
781
|
+
return;
|
|
782
|
+
}
|
|
783
|
+
const placed = placeImageRegion(at);
|
|
784
|
+
pendingClick.current = { point: at, region: placed };
|
|
785
|
+
onRegionChange(placed);
|
|
786
|
+
}
|
|
787
|
+
const shown = draft ?? region;
|
|
710
788
|
return /* @__PURE__ */ jsx6("div", {
|
|
711
789
|
"data-slot": "image-region-select",
|
|
712
790
|
className: "absolute inset-0 cursor-crosshair touch-none",
|
|
@@ -721,51 +799,120 @@ function ImageRegionSelect({ onSelect }) {
|
|
|
721
799
|
event.preventDefault();
|
|
722
800
|
event.currentTarget.setPointerCapture(event.pointerId);
|
|
723
801
|
drag.current = { pointerId: event.pointerId, start: point(event) };
|
|
724
|
-
setDraft(undefined);
|
|
725
802
|
},
|
|
726
803
|
onPointerMove: (event) => {
|
|
727
|
-
|
|
728
|
-
|
|
804
|
+
const current = drag.current;
|
|
805
|
+
if (current?.pointerId !== event.pointerId)
|
|
806
|
+
return;
|
|
807
|
+
const moved = toRegion(current.start, point(event));
|
|
808
|
+
const bounds = event.currentTarget.getBoundingClientRect();
|
|
809
|
+
if (moved.width * bounds.width >= MINIMUM_DRAG || moved.height * bounds.height >= MINIMUM_DRAG)
|
|
810
|
+
setDraft(moved);
|
|
729
811
|
},
|
|
730
812
|
onPointerUp: (event) => {
|
|
731
813
|
const current = drag.current;
|
|
732
814
|
if (current?.pointerId !== event.pointerId)
|
|
733
815
|
return;
|
|
734
816
|
cancel();
|
|
735
|
-
const
|
|
817
|
+
const end = point(event);
|
|
818
|
+
const dragged = toRegion(current.start, end);
|
|
736
819
|
const bounds = event.currentTarget.getBoundingClientRect();
|
|
737
|
-
if (
|
|
820
|
+
if (dragged.width * bounds.width < MINIMUM_DRAG && dragged.height * bounds.height < MINIMUM_DRAG) {
|
|
821
|
+
click(end);
|
|
738
822
|
return;
|
|
739
|
-
|
|
823
|
+
}
|
|
824
|
+
pendingClick.current = null;
|
|
825
|
+
onRegionChange(dragged);
|
|
740
826
|
},
|
|
741
827
|
onPointerCancel: cancel,
|
|
742
|
-
children:
|
|
828
|
+
children: shown && /* @__PURE__ */ jsx6(ImageRegionMarker, {
|
|
743
829
|
variant: "draft",
|
|
744
|
-
|
|
830
|
+
role: draft ? undefined : "img",
|
|
831
|
+
"aria-hidden": draft ? "true" : undefined,
|
|
832
|
+
"aria-label": draft ? undefined : formatImageRegion(shown),
|
|
745
833
|
"data-slot": "image-region-select-draft",
|
|
746
|
-
region:
|
|
747
|
-
left: `${draft.x * 100}%`,
|
|
748
|
-
top: `${draft.y * 100}%`,
|
|
749
|
-
width: `${draft.width * 100}%`,
|
|
750
|
-
height: `${draft.height * 100}%`
|
|
751
|
-
}
|
|
834
|
+
region: toBox(shown)
|
|
752
835
|
})
|
|
753
836
|
});
|
|
754
837
|
}
|
|
838
|
+
// src/components/image-viewer/ImageRegionFields.tsx
|
|
839
|
+
import { useId } from "react";
|
|
840
|
+
import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
841
|
+
var FIELDS = [
|
|
842
|
+
["x", "Left"],
|
|
843
|
+
["y", "Top"],
|
|
844
|
+
["width", "Width"],
|
|
845
|
+
["height", "Height"]
|
|
846
|
+
];
|
|
847
|
+
function toPercent(value) {
|
|
848
|
+
return Math.round(value * 1000) / 10;
|
|
849
|
+
}
|
|
850
|
+
function ImageRegionFields({
|
|
851
|
+
region,
|
|
852
|
+
onRegionChange,
|
|
853
|
+
label = "Region",
|
|
854
|
+
className,
|
|
855
|
+
density
|
|
856
|
+
}) {
|
|
857
|
+
const id = useId();
|
|
858
|
+
return /* @__PURE__ */ jsxs4("div", {
|
|
859
|
+
role: "group",
|
|
860
|
+
"aria-label": label,
|
|
861
|
+
"data-slot": "image-region-fields",
|
|
862
|
+
"data-density": density,
|
|
863
|
+
className: cn2("flex flex-wrap items-end gap-control-gap", className),
|
|
864
|
+
children: [
|
|
865
|
+
FIELDS.map(([key, name]) => /* @__PURE__ */ jsxs4(Field2, {
|
|
866
|
+
className: "w-20",
|
|
867
|
+
children: [
|
|
868
|
+
/* @__PURE__ */ jsx7(FieldLabel2, {
|
|
869
|
+
htmlFor: `${id}-${key}`,
|
|
870
|
+
children: name
|
|
871
|
+
}),
|
|
872
|
+
/* @__PURE__ */ jsx7(NumberField2, {
|
|
873
|
+
id: `${id}-${key}`,
|
|
874
|
+
density,
|
|
875
|
+
value: toPercent(region[key]),
|
|
876
|
+
min: 0,
|
|
877
|
+
max: 100,
|
|
878
|
+
step: 1,
|
|
879
|
+
smallStep: 0.1,
|
|
880
|
+
format: { maximumFractionDigits: 1 },
|
|
881
|
+
onValueChange: (value) => {
|
|
882
|
+
if (value === null)
|
|
883
|
+
return;
|
|
884
|
+
onRegionChange(clampImageRegion({ ...region, [key]: value / 100 }));
|
|
885
|
+
},
|
|
886
|
+
children: /* @__PURE__ */ jsx7(NumberFieldGroup2, {
|
|
887
|
+
children: /* @__PURE__ */ jsx7(NumberFieldInput2, {
|
|
888
|
+
"aria-describedby": `${id}-unit`
|
|
889
|
+
})
|
|
890
|
+
})
|
|
891
|
+
})
|
|
892
|
+
]
|
|
893
|
+
}, key)),
|
|
894
|
+
/* @__PURE__ */ jsx7("span", {
|
|
895
|
+
id: `${id}-unit`,
|
|
896
|
+
className: "sr-only",
|
|
897
|
+
children: "percent of the image"
|
|
898
|
+
})
|
|
899
|
+
]
|
|
900
|
+
});
|
|
901
|
+
}
|
|
755
902
|
// src/components/image-viewer/ImageComparison.tsx
|
|
756
903
|
import { useControlled as useControlled2 } from "@base-ui/utils/useControlled";
|
|
757
904
|
import { useRef as useRef5, useState as useState6 } from "react";
|
|
758
905
|
|
|
759
906
|
// src/components/image-viewer/ImageComparisonToolbar.tsx
|
|
760
907
|
import { Columns2Icon, Rows2Icon } from "lucide-react";
|
|
761
|
-
import { useId } from "react";
|
|
762
|
-
import { jsx as
|
|
908
|
+
import { useId as useId2 } from "react";
|
|
909
|
+
import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
763
910
|
function ToolbarSection({ title, titleId, children }) {
|
|
764
|
-
return /* @__PURE__ */
|
|
911
|
+
return /* @__PURE__ */ jsxs5("div", {
|
|
765
912
|
"data-slot": "image-comparison-toolbar-section",
|
|
766
913
|
className: "flex min-w-0 flex-col gap-1.5",
|
|
767
914
|
children: [
|
|
768
|
-
/* @__PURE__ */
|
|
915
|
+
/* @__PURE__ */ jsx8("span", {
|
|
769
916
|
id: titleId,
|
|
770
917
|
className: "sr-only text-xs font-medium text-muted-foreground @3xl:not-sr-only",
|
|
771
918
|
children: title
|
|
@@ -812,21 +959,21 @@ function ImageComparisonToolbar({
|
|
|
812
959
|
afterSize,
|
|
813
960
|
density
|
|
814
961
|
}) {
|
|
815
|
-
const id =
|
|
962
|
+
const id = useId2();
|
|
816
963
|
const isUnavailable = differences.status === "unavailable";
|
|
817
964
|
const releasePeek = () => onPeekChange(false);
|
|
818
965
|
const sizeMismatch = beforeSize && afterSize && (beforeSize.width !== afterSize.width || beforeSize.height !== afterSize.height) ? `Sizes differ: ${beforeLabel} ${formatSize(beforeSize)}, ${afterLabel} ${formatSize(afterSize)}. ` + `${beforeLabel} is fitted inside the ${afterLabel} image box.` : undefined;
|
|
819
|
-
return /* @__PURE__ */
|
|
966
|
+
return /* @__PURE__ */ jsxs5("div", {
|
|
820
967
|
role: "group",
|
|
821
968
|
"aria-label": "Comparison controls",
|
|
822
969
|
"data-slot": "image-comparison-toolbar",
|
|
823
970
|
"data-density": density,
|
|
824
971
|
className: "flex shrink-0 flex-wrap items-end gap-x-panel gap-y-3 border-t border-border p-panel-sm @3xl:w-72 @3xl:flex-col @3xl:flex-nowrap @3xl:items-stretch @3xl:overflow-y-auto @3xl:border-t-0 @3xl:border-s",
|
|
825
972
|
children: [
|
|
826
|
-
/* @__PURE__ */
|
|
973
|
+
/* @__PURE__ */ jsx8(ToolbarSection, {
|
|
827
974
|
title: "Mode",
|
|
828
975
|
titleId: `${id}-mode`,
|
|
829
|
-
children: /* @__PURE__ */
|
|
976
|
+
children: /* @__PURE__ */ jsxs5(ToggleGroup2, {
|
|
830
977
|
"aria-labelledby": `${id}-mode`,
|
|
831
978
|
required: true,
|
|
832
979
|
value: [mode],
|
|
@@ -835,25 +982,25 @@ function ImageComparisonToolbar({
|
|
|
835
982
|
size: "sm",
|
|
836
983
|
spacing: 0,
|
|
837
984
|
children: [
|
|
838
|
-
/* @__PURE__ */
|
|
985
|
+
/* @__PURE__ */ jsx8(ToggleGroupItem2, {
|
|
839
986
|
value: "toggle",
|
|
840
987
|
children: "Toggle"
|
|
841
988
|
}),
|
|
842
|
-
/* @__PURE__ */
|
|
989
|
+
/* @__PURE__ */ jsx8(ToggleGroupItem2, {
|
|
843
990
|
value: "swipe",
|
|
844
991
|
children: "Swipe"
|
|
845
992
|
}),
|
|
846
|
-
/* @__PURE__ */
|
|
993
|
+
/* @__PURE__ */ jsx8(ToggleGroupItem2, {
|
|
847
994
|
value: "side-by-side",
|
|
848
995
|
children: "Side by side"
|
|
849
996
|
})
|
|
850
997
|
]
|
|
851
998
|
})
|
|
852
999
|
}),
|
|
853
|
-
/* @__PURE__ */
|
|
1000
|
+
/* @__PURE__ */ jsx8(ToolbarSection, {
|
|
854
1001
|
title: "Orientation",
|
|
855
1002
|
titleId: `${id}-orientation`,
|
|
856
|
-
children: /* @__PURE__ */
|
|
1003
|
+
children: /* @__PURE__ */ jsxs5(ToggleGroup2, {
|
|
857
1004
|
"aria-labelledby": `${id}-orientation`,
|
|
858
1005
|
required: true,
|
|
859
1006
|
value: [orientation],
|
|
@@ -863,19 +1010,19 @@ function ImageComparisonToolbar({
|
|
|
863
1010
|
spacing: 0,
|
|
864
1011
|
disabled: mode !== "side-by-side",
|
|
865
1012
|
children: [
|
|
866
|
-
/* @__PURE__ */
|
|
1013
|
+
/* @__PURE__ */ jsxs5(ToggleGroupItem2, {
|
|
867
1014
|
value: "horizontal",
|
|
868
1015
|
children: [
|
|
869
|
-
/* @__PURE__ */
|
|
1016
|
+
/* @__PURE__ */ jsx8(Columns2Icon, {
|
|
870
1017
|
"data-icon": "inline-start"
|
|
871
1018
|
}),
|
|
872
1019
|
"Horizontal"
|
|
873
1020
|
]
|
|
874
1021
|
}),
|
|
875
|
-
/* @__PURE__ */
|
|
1022
|
+
/* @__PURE__ */ jsxs5(ToggleGroupItem2, {
|
|
876
1023
|
value: "vertical",
|
|
877
1024
|
children: [
|
|
878
|
-
/* @__PURE__ */
|
|
1025
|
+
/* @__PURE__ */ jsx8(Rows2Icon, {
|
|
879
1026
|
"data-icon": "inline-start"
|
|
880
1027
|
}),
|
|
881
1028
|
"Vertical"
|
|
@@ -884,15 +1031,15 @@ function ImageComparisonToolbar({
|
|
|
884
1031
|
]
|
|
885
1032
|
})
|
|
886
1033
|
}),
|
|
887
|
-
/* @__PURE__ */
|
|
1034
|
+
/* @__PURE__ */ jsx8(ToolbarSection, {
|
|
888
1035
|
title: "Zoom",
|
|
889
1036
|
titleId: `${id}-zoom`,
|
|
890
|
-
children: /* @__PURE__ */
|
|
1037
|
+
children: /* @__PURE__ */ jsx8(ImageZoomToggle, {
|
|
891
1038
|
zoom,
|
|
892
1039
|
onZoomChange
|
|
893
1040
|
})
|
|
894
1041
|
}),
|
|
895
|
-
/* @__PURE__ */
|
|
1042
|
+
/* @__PURE__ */ jsx8(Button2, {
|
|
896
1043
|
variant: "outline",
|
|
897
1044
|
size: "sm",
|
|
898
1045
|
disabled: mode !== "toggle",
|
|
@@ -916,27 +1063,27 @@ function ImageComparisonToolbar({
|
|
|
916
1063
|
onContextMenu: (event) => event.preventDefault(),
|
|
917
1064
|
children: "Hold to show before"
|
|
918
1065
|
}),
|
|
919
|
-
/* @__PURE__ */
|
|
1066
|
+
/* @__PURE__ */ jsxs5(Field2, {
|
|
920
1067
|
orientation: "horizontal",
|
|
921
1068
|
children: [
|
|
922
|
-
/* @__PURE__ */
|
|
1069
|
+
/* @__PURE__ */ jsx8(Switch2, {
|
|
923
1070
|
id: `${id}-differences`,
|
|
924
1071
|
"aria-describedby": `${id}-differences-status`,
|
|
925
1072
|
checked: showDifferences && !isUnavailable,
|
|
926
1073
|
disabled: isUnavailable,
|
|
927
1074
|
onCheckedChange: onShowDifferencesChange
|
|
928
1075
|
}),
|
|
929
|
-
/* @__PURE__ */
|
|
1076
|
+
/* @__PURE__ */ jsxs5(FieldContent2, {
|
|
930
1077
|
children: [
|
|
931
|
-
/* @__PURE__ */
|
|
1078
|
+
/* @__PURE__ */ jsx8(FieldLabel2, {
|
|
932
1079
|
htmlFor: `${id}-differences`,
|
|
933
1080
|
children: "Highlight differences"
|
|
934
1081
|
}),
|
|
935
|
-
showDifferences && differences.status === "ready" && /* @__PURE__ */
|
|
1082
|
+
showDifferences && differences.status === "ready" && /* @__PURE__ */ jsxs5(FieldDescription2, {
|
|
936
1083
|
"data-slot": "image-comparison-legend",
|
|
937
1084
|
className: "flex items-center gap-1.5",
|
|
938
1085
|
children: [
|
|
939
|
-
/* @__PURE__ */
|
|
1086
|
+
/* @__PURE__ */ jsx8("span", {
|
|
940
1087
|
"aria-hidden": "true",
|
|
941
1088
|
className: "mx-[3px] size-2.5 shrink-0 rounded-xs bg-warning/10 ring-1 ring-background outline-2 outline-offset-1 outline-warning"
|
|
942
1089
|
}),
|
|
@@ -947,16 +1094,16 @@ function ImageComparisonToolbar({
|
|
|
947
1094
|
})
|
|
948
1095
|
]
|
|
949
1096
|
}),
|
|
950
|
-
/* @__PURE__ */
|
|
1097
|
+
/* @__PURE__ */ jsxs5("div", {
|
|
951
1098
|
"data-slot": "image-comparison-status",
|
|
952
1099
|
className: "flex min-w-0 flex-col gap-1 text-xs text-muted-foreground",
|
|
953
1100
|
children: [
|
|
954
|
-
/* @__PURE__ */
|
|
1101
|
+
/* @__PURE__ */ jsx8("p", {
|
|
955
1102
|
id: `${id}-differences-status`,
|
|
956
1103
|
role: "status",
|
|
957
1104
|
children: describeDifferences(differences, showDifferences)
|
|
958
1105
|
}),
|
|
959
|
-
sizeMismatch && /* @__PURE__ */
|
|
1106
|
+
sizeMismatch && /* @__PURE__ */ jsx8("p", {
|
|
960
1107
|
"data-slot": "image-comparison-size-mismatch",
|
|
961
1108
|
children: sizeMismatch
|
|
962
1109
|
})
|
|
@@ -967,23 +1114,23 @@ function ImageComparisonToolbar({
|
|
|
967
1114
|
}
|
|
968
1115
|
|
|
969
1116
|
// src/components/image-viewer/ImageDifferenceOverlay.tsx
|
|
970
|
-
import { jsx as
|
|
971
|
-
function
|
|
1117
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
1118
|
+
function toPercent2(value, total) {
|
|
972
1119
|
return `${value / total * 100}%`;
|
|
973
1120
|
}
|
|
974
1121
|
function ImageDifferenceOverlay({ diff }) {
|
|
975
|
-
return /* @__PURE__ */
|
|
1122
|
+
return /* @__PURE__ */ jsx9("div", {
|
|
976
1123
|
"data-slot": "image-difference-overlay",
|
|
977
1124
|
"aria-hidden": "true",
|
|
978
1125
|
className: "pointer-events-none absolute inset-0",
|
|
979
|
-
children: diff.regions.map((region) => /* @__PURE__ */
|
|
1126
|
+
children: diff.regions.map((region) => /* @__PURE__ */ jsx9(ImageRegionMarker, {
|
|
980
1127
|
"data-slot": "image-difference-region",
|
|
981
1128
|
variant: "difference",
|
|
982
1129
|
region: {
|
|
983
|
-
left:
|
|
984
|
-
top:
|
|
985
|
-
width:
|
|
986
|
-
height:
|
|
1130
|
+
left: toPercent2(region.x, diff.width),
|
|
1131
|
+
top: toPercent2(region.y, diff.height),
|
|
1132
|
+
width: toPercent2(region.width, diff.width),
|
|
1133
|
+
height: toPercent2(region.height, diff.height)
|
|
987
1134
|
}
|
|
988
1135
|
}, `${region.x}:${region.y}:${region.width}:${region.height}`))
|
|
989
1136
|
});
|
|
@@ -993,16 +1140,16 @@ function ImageDifferenceOverlay({ diff }) {
|
|
|
993
1140
|
import { DirectionProvider } from "@base-ui/react/direction-provider";
|
|
994
1141
|
import { Slider as SliderPrimitive } from "@base-ui/react/slider";
|
|
995
1142
|
import { ChevronsLeftRightIcon } from "lucide-react";
|
|
996
|
-
import { jsx as
|
|
1143
|
+
import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
997
1144
|
function ImageSwipeDivider({
|
|
998
1145
|
value,
|
|
999
1146
|
onValueChange,
|
|
1000
1147
|
beforeLabel,
|
|
1001
1148
|
afterLabel
|
|
1002
1149
|
}) {
|
|
1003
|
-
return /* @__PURE__ */
|
|
1150
|
+
return /* @__PURE__ */ jsx10(DirectionProvider, {
|
|
1004
1151
|
direction: "ltr",
|
|
1005
|
-
children: /* @__PURE__ */
|
|
1152
|
+
children: /* @__PURE__ */ jsx10(SliderPrimitive.Root, {
|
|
1006
1153
|
dir: "ltr",
|
|
1007
1154
|
"data-slot": "image-swipe-divider",
|
|
1008
1155
|
value,
|
|
@@ -1012,22 +1159,22 @@ function ImageSwipeDivider({
|
|
|
1012
1159
|
step: 1,
|
|
1013
1160
|
largeStep: 10,
|
|
1014
1161
|
className: "pointer-events-none absolute inset-0",
|
|
1015
|
-
children: /* @__PURE__ */
|
|
1162
|
+
children: /* @__PURE__ */ jsx10(SliderPrimitive.Control, {
|
|
1016
1163
|
className: "pointer-events-none absolute inset-0",
|
|
1017
|
-
children: /* @__PURE__ */
|
|
1164
|
+
children: /* @__PURE__ */ jsxs6(SliderPrimitive.Thumb, {
|
|
1018
1165
|
"data-slot": "image-swipe-divider-handle",
|
|
1019
1166
|
getAriaLabel: () => "Swipe divider",
|
|
1020
1167
|
getAriaValueText: (_formatted, current) => `${beforeLabel} ${current}%, ${afterLabel} ${100 - current}%`,
|
|
1021
1168
|
className: "group/divider pointer-events-auto flex h-full w-6 cursor-ew-resize touch-none flex-col items-center justify-center select-none",
|
|
1022
1169
|
children: [
|
|
1023
|
-
/* @__PURE__ */
|
|
1170
|
+
/* @__PURE__ */ jsx10("span", {
|
|
1024
1171
|
"aria-hidden": "true",
|
|
1025
1172
|
className: "absolute inset-y-0 start-1/2 w-0.5 -translate-x-1/2 bg-foreground ring-1 ring-background"
|
|
1026
1173
|
}),
|
|
1027
|
-
/* @__PURE__ */
|
|
1174
|
+
/* @__PURE__ */ jsx10("span", {
|
|
1028
1175
|
"aria-hidden": "true",
|
|
1029
1176
|
className: "relative flex h-8 w-5 items-center justify-center rounded-sm border border-border bg-background text-foreground shadow-frame group-has-[:focus-visible]/divider:border-ring group-has-[:focus-visible]/divider:ring-1 group-has-[:focus-visible]/divider:ring-ring group-data-dragging/divider:border-ring",
|
|
1030
|
-
children: /* @__PURE__ */
|
|
1177
|
+
children: /* @__PURE__ */ jsx10(ChevronsLeftRightIcon, {
|
|
1031
1178
|
className: "size-3.5"
|
|
1032
1179
|
})
|
|
1033
1180
|
})
|
|
@@ -1293,14 +1440,14 @@ function useImageDifferences({
|
|
|
1293
1440
|
}
|
|
1294
1441
|
|
|
1295
1442
|
// src/components/image-viewer/ImageComparison.tsx
|
|
1296
|
-
import { jsx as
|
|
1443
|
+
import { jsx as jsx11, jsxs as jsxs7, Fragment } from "react/jsx-runtime";
|
|
1297
1444
|
function ComparisonPane({ header, children }) {
|
|
1298
|
-
return /* @__PURE__ */
|
|
1445
|
+
return /* @__PURE__ */ jsxs7("div", {
|
|
1299
1446
|
"data-slot": "image-comparison-pane",
|
|
1300
1447
|
"data-scroll": "none",
|
|
1301
1448
|
className: "flex min-h-0 min-w-0 flex-1 flex-col",
|
|
1302
1449
|
children: [
|
|
1303
|
-
/* @__PURE__ */
|
|
1450
|
+
/* @__PURE__ */ jsx11("div", {
|
|
1304
1451
|
"data-slot": "image-comparison-pane-header",
|
|
1305
1452
|
className: "flex h-control shrink-0 items-center justify-between gap-2 px-control-x text-xs font-medium text-muted-foreground",
|
|
1306
1453
|
children: header
|
|
@@ -1375,10 +1522,10 @@ ${after.src}`,
|
|
|
1375
1522
|
afterRef
|
|
1376
1523
|
});
|
|
1377
1524
|
const isShowingBefore = mode === "toggle" && isPeeking;
|
|
1378
|
-
const overlay = showDifferences && differences.status === "ready" ? /* @__PURE__ */
|
|
1525
|
+
const overlay = showDifferences && differences.status === "ready" ? /* @__PURE__ */ jsx11(ImageDifferenceOverlay, {
|
|
1379
1526
|
diff: differences.diff
|
|
1380
1527
|
}) : null;
|
|
1381
|
-
const fallback = failedLabel ? /* @__PURE__ */
|
|
1528
|
+
const fallback = failedLabel ? /* @__PURE__ */ jsxs7("p", {
|
|
1382
1529
|
"data-slot": "image-comparison-error",
|
|
1383
1530
|
className: "m-auto p-panel text-center text-sm text-muted-foreground",
|
|
1384
1531
|
children: [
|
|
@@ -1416,7 +1563,7 @@ ${after.src}`,
|
|
|
1416
1563
|
}
|
|
1417
1564
|
}
|
|
1418
1565
|
function renderAfterImage(className) {
|
|
1419
|
-
return /* @__PURE__ */
|
|
1566
|
+
return /* @__PURE__ */ jsx11("img", {
|
|
1420
1567
|
ref: afterRef,
|
|
1421
1568
|
src: after.src,
|
|
1422
1569
|
alt: after.alt,
|
|
@@ -1429,7 +1576,7 @@ ${after.src}`,
|
|
|
1429
1576
|
});
|
|
1430
1577
|
}
|
|
1431
1578
|
function renderBeforeImage(className, style) {
|
|
1432
|
-
return /* @__PURE__ */
|
|
1579
|
+
return /* @__PURE__ */ jsx11("img", {
|
|
1433
1580
|
ref: beforeRef,
|
|
1434
1581
|
src: before.src,
|
|
1435
1582
|
alt: before.alt,
|
|
@@ -1444,15 +1591,15 @@ ${after.src}`,
|
|
|
1444
1591
|
}
|
|
1445
1592
|
let content;
|
|
1446
1593
|
if (mode === "side-by-side") {
|
|
1447
|
-
content = /* @__PURE__ */
|
|
1594
|
+
content = /* @__PURE__ */ jsxs7("div", {
|
|
1448
1595
|
"data-slot": "image-comparison-panes",
|
|
1449
1596
|
className: cn2("flex min-h-0 min-w-0 flex-1", orientation === "vertical" ? "flex-col" : "flex-row"),
|
|
1450
1597
|
children: [
|
|
1451
|
-
/* @__PURE__ */
|
|
1452
|
-
header: /* @__PURE__ */
|
|
1598
|
+
/* @__PURE__ */ jsx11(ComparisonPane, {
|
|
1599
|
+
header: /* @__PURE__ */ jsx11("span", {
|
|
1453
1600
|
children: beforeLabel
|
|
1454
1601
|
}),
|
|
1455
|
-
children: /* @__PURE__ */
|
|
1602
|
+
children: /* @__PURE__ */ jsxs7(ImageViewport, {
|
|
1456
1603
|
label: beforeLabel,
|
|
1457
1604
|
zoom,
|
|
1458
1605
|
naturalSize: afterImage.size,
|
|
@@ -1467,14 +1614,14 @@ ${after.src}`,
|
|
|
1467
1614
|
]
|
|
1468
1615
|
})
|
|
1469
1616
|
}),
|
|
1470
|
-
/* @__PURE__ */
|
|
1617
|
+
/* @__PURE__ */ jsx11(Separator2, {
|
|
1471
1618
|
orientation: orientation === "vertical" ? "horizontal" : "vertical"
|
|
1472
1619
|
}),
|
|
1473
|
-
/* @__PURE__ */
|
|
1474
|
-
header: /* @__PURE__ */
|
|
1620
|
+
/* @__PURE__ */ jsx11(ComparisonPane, {
|
|
1621
|
+
header: /* @__PURE__ */ jsx11("span", {
|
|
1475
1622
|
children: afterLabel
|
|
1476
1623
|
}),
|
|
1477
|
-
children: /* @__PURE__ */
|
|
1624
|
+
children: /* @__PURE__ */ jsxs7(ImageViewport, {
|
|
1478
1625
|
label: afterLabel,
|
|
1479
1626
|
zoom,
|
|
1480
1627
|
naturalSize: afterImage.size,
|
|
@@ -1492,18 +1639,18 @@ ${after.src}`,
|
|
|
1492
1639
|
]
|
|
1493
1640
|
});
|
|
1494
1641
|
} else if (mode === "swipe") {
|
|
1495
|
-
content = /* @__PURE__ */
|
|
1496
|
-
header: /* @__PURE__ */
|
|
1642
|
+
content = /* @__PURE__ */ jsx11(ComparisonPane, {
|
|
1643
|
+
header: /* @__PURE__ */ jsxs7(Fragment, {
|
|
1497
1644
|
children: [
|
|
1498
|
-
/* @__PURE__ */
|
|
1645
|
+
/* @__PURE__ */ jsx11("span", {
|
|
1499
1646
|
children: beforeLabel
|
|
1500
1647
|
}),
|
|
1501
|
-
/* @__PURE__ */
|
|
1648
|
+
/* @__PURE__ */ jsx11("span", {
|
|
1502
1649
|
children: afterLabel
|
|
1503
1650
|
})
|
|
1504
1651
|
]
|
|
1505
1652
|
}),
|
|
1506
|
-
children: /* @__PURE__ */
|
|
1653
|
+
children: /* @__PURE__ */ jsxs7(ImageViewport, {
|
|
1507
1654
|
label: `${beforeLabel} and ${afterLabel}`,
|
|
1508
1655
|
zoom,
|
|
1509
1656
|
naturalSize: afterImage.size,
|
|
@@ -1514,7 +1661,7 @@ ${after.src}`,
|
|
|
1514
1661
|
renderAfterImage(),
|
|
1515
1662
|
renderBeforeImage(undefined, { clipPath: `inset(0 ${100 - position}% 0 0)` }),
|
|
1516
1663
|
overlay,
|
|
1517
|
-
/* @__PURE__ */
|
|
1664
|
+
/* @__PURE__ */ jsx11(ImageSwipeDivider, {
|
|
1518
1665
|
value: position,
|
|
1519
1666
|
onValueChange: setPosition,
|
|
1520
1667
|
beforeLabel,
|
|
@@ -1525,8 +1672,8 @@ ${after.src}`,
|
|
|
1525
1672
|
});
|
|
1526
1673
|
} else {
|
|
1527
1674
|
const showingLabel = isShowingBefore ? beforeLabel : afterLabel;
|
|
1528
|
-
content = /* @__PURE__ */
|
|
1529
|
-
header: /* @__PURE__ */
|
|
1675
|
+
content = /* @__PURE__ */ jsx11(ComparisonPane, {
|
|
1676
|
+
header: /* @__PURE__ */ jsxs7("span", {
|
|
1530
1677
|
"data-slot": "image-comparison-showing",
|
|
1531
1678
|
"aria-live": "polite",
|
|
1532
1679
|
children: [
|
|
@@ -1534,7 +1681,7 @@ ${after.src}`,
|
|
|
1534
1681
|
showingLabel
|
|
1535
1682
|
]
|
|
1536
1683
|
}),
|
|
1537
|
-
children: /* @__PURE__ */
|
|
1684
|
+
children: /* @__PURE__ */ jsxs7(ImageViewport, {
|
|
1538
1685
|
label: showingLabel,
|
|
1539
1686
|
zoom,
|
|
1540
1687
|
naturalSize: afterImage.size,
|
|
@@ -1549,7 +1696,7 @@ ${after.src}`,
|
|
|
1549
1696
|
})
|
|
1550
1697
|
});
|
|
1551
1698
|
}
|
|
1552
|
-
return /* @__PURE__ */
|
|
1699
|
+
return /* @__PURE__ */ jsx11("div", {
|
|
1553
1700
|
role: "group",
|
|
1554
1701
|
"aria-label": label,
|
|
1555
1702
|
"data-slot": "image-comparison",
|
|
@@ -1560,16 +1707,16 @@ ${after.src}`,
|
|
|
1560
1707
|
"data-zoom": zoom,
|
|
1561
1708
|
"data-showing": isShowingBefore ? "before" : "after",
|
|
1562
1709
|
className: "@container flex size-full min-h-0 min-w-0 flex-1",
|
|
1563
|
-
children: /* @__PURE__ */
|
|
1710
|
+
children: /* @__PURE__ */ jsxs7("div", {
|
|
1564
1711
|
className: "flex min-h-0 min-w-0 flex-1 flex-col @3xl:flex-row",
|
|
1565
1712
|
children: [
|
|
1566
|
-
/* @__PURE__ */
|
|
1713
|
+
/* @__PURE__ */ jsx11("div", {
|
|
1567
1714
|
"data-slot": "image-comparison-stage",
|
|
1568
1715
|
"data-scroll": "none",
|
|
1569
1716
|
className: "flex min-h-0 min-w-0 flex-1",
|
|
1570
1717
|
children: content
|
|
1571
1718
|
}),
|
|
1572
|
-
showToolbar && /* @__PURE__ */
|
|
1719
|
+
showToolbar && /* @__PURE__ */ jsx11(ImageComparisonToolbar, {
|
|
1573
1720
|
mode,
|
|
1574
1721
|
onModeChange: setMode,
|
|
1575
1722
|
orientation,
|
|
@@ -1592,8 +1739,10 @@ ${after.src}`,
|
|
|
1592
1739
|
}
|
|
1593
1740
|
export {
|
|
1594
1741
|
FramedImage2 as FramedImage,
|
|
1742
|
+
IMAGE_REGION_STEP,
|
|
1595
1743
|
IMAGE_ZOOM_STEPS,
|
|
1596
1744
|
ImageComparison,
|
|
1745
|
+
ImageRegionFields,
|
|
1597
1746
|
ImageRegionMarker,
|
|
1598
1747
|
ImageRegionMarkerBadge,
|
|
1599
1748
|
ImageRegionSelect,
|
|
@@ -1601,12 +1750,18 @@ export {
|
|
|
1601
1750
|
ImageZoomControl,
|
|
1602
1751
|
ImageZoomToggle,
|
|
1603
1752
|
MAX_IMAGE_ZOOM,
|
|
1753
|
+
MIN_IMAGE_REGION_SIZE,
|
|
1754
|
+
applyImageRegionKey,
|
|
1755
|
+
clampImageRegion,
|
|
1604
1756
|
computeImageDiff,
|
|
1757
|
+
formatImageRegion,
|
|
1605
1758
|
formatImageZoom,
|
|
1759
|
+
getImageRegionFromCorners,
|
|
1606
1760
|
getImageZoomScales,
|
|
1607
1761
|
getNextImageZoom,
|
|
1608
1762
|
getNormalizedImagePoint,
|
|
1609
1763
|
getOpeningImageZoom,
|
|
1610
1764
|
getPreviousImageZoom,
|
|
1765
|
+
placeImageRegion,
|
|
1611
1766
|
resolveImageZoomScale
|
|
1612
1767
|
};
|