@alexgorbatchev/shadcn 0.0.93 → 0.0.95
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-cc35g6sr.js +187 -0
- package/dist/{chunk-kr38ww4n.js → chunk-fg1h007n.js} +373 -530
- package/dist/components/image-viewer/ImageRegionMarker.d.ts +33 -8
- package/dist/components/image-viewer/index.d.ts +1 -1
- package/dist/components/image-viewer/index.js +19 -4
- package/dist/components/json-render/index.js +9 -8
- package/dist/components/resizable/SplitView.d.ts +19 -4
- package/dist/components/resizable/index.js +101 -17
- package/dist/index.js +14 -13
- package/dist/prototype.js +1 -1
- package/llms/components/data-display/ImageRegionMarker.md +19 -3
- package/llms/components/layout/SplitView.md +45 -1
- package/llms/components/overlays/Drawer.md +20 -0
- package/llms/components/overlays/Sheet.md +20 -0
- package/llms.txt +1 -1
- package/package.json +1 -1
- package/dist/chunk-k99h6evz.js +0 -11
|
@@ -4,21 +4,46 @@ declare const imageRegionMarkerVariants: (props?: ({
|
|
|
4
4
|
variant?: "difference" | "draft" | "comment" | null | undefined;
|
|
5
5
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
6
|
export type ImageRegionMarkerVariant = NonNullable<VariantProps<typeof imageRegionMarkerVariants>["variant"]>;
|
|
7
|
+
/** A length in CSS pixels, or any CSS length such as a percentage of the positioned image box. */
|
|
8
|
+
export type ImageRegionLength = number | string;
|
|
9
|
+
/** Where a region sits inside its positioned image box. */
|
|
10
|
+
export interface IImageRegionBox {
|
|
11
|
+
left: ImageRegionLength;
|
|
12
|
+
top: ImageRegionLength;
|
|
13
|
+
width: ImageRegionLength;
|
|
14
|
+
height: ImageRegionLength;
|
|
15
|
+
}
|
|
16
|
+
/** Where a badge sits relative to its marker's box. */
|
|
17
|
+
export interface IImageRegionBadgePosition {
|
|
18
|
+
left: ImageRegionLength;
|
|
19
|
+
top: ImageRegionLength;
|
|
20
|
+
}
|
|
7
21
|
export interface IImageRegionMarkerProps extends ComponentProps<"div"> {
|
|
8
22
|
/** Which kind of region the marker outlines. Defaults to `comment`. */
|
|
9
23
|
variant?: ImageRegionMarkerVariant;
|
|
24
|
+
/** The region's box inside the positioned image box. Lets consumers place the marker without passing `style`. */
|
|
25
|
+
region?: IImageRegionBox;
|
|
10
26
|
}
|
|
11
27
|
/**
|
|
12
|
-
* Outlines a region drawn over an image. Position it with `
|
|
13
|
-
* percentages of the positioned image box). Children render inside the marker's box, such as
|
|
14
|
-
* `ImageRegionMarkerBadge` pinned to one of its corners.
|
|
28
|
+
* Outlines a region drawn over an image. Position it with `region` (`left`, `top`, `width`, `height`, in pixels or
|
|
29
|
+
* any CSS length, such as percentages of the positioned image box). Children render inside the marker's box, such as
|
|
30
|
+
* an `ImageRegionMarkerBadge` pinned to one of its corners.
|
|
15
31
|
*/
|
|
16
|
-
export declare function ImageRegionMarker({ variant, className, ...props }: IImageRegionMarkerProps): ReactElement;
|
|
17
|
-
export
|
|
32
|
+
export declare function ImageRegionMarker({ variant, region, className, style, ...props }: IImageRegionMarkerProps): ReactElement;
|
|
33
|
+
export interface IImageRegionMarkerBadgeProps extends ComponentProps<"div"> {
|
|
34
|
+
/** Where the badge sits relative to its marker's box. */
|
|
35
|
+
position?: IImageRegionBadgePosition;
|
|
36
|
+
/**
|
|
37
|
+
* Whether the badge takes pointer input. Defaults to `true`; pass `false` while another gesture, such as drawing a
|
|
38
|
+
* new region, owns the pointer so the badge does not intercept it.
|
|
39
|
+
*/
|
|
40
|
+
interactive?: boolean;
|
|
41
|
+
}
|
|
18
42
|
/**
|
|
19
43
|
* Holds an interactive control, such as a comment-count button, beside an `ImageRegionMarker`. It carries the
|
|
20
|
-
* marker's outline and halo, so its edge stays visible on light and dark screenshots. Position it with `
|
|
21
|
-
* relative to the marker's box; it receives pointer events although the marker does not
|
|
44
|
+
* marker's outline and halo, so its edge stays visible on light and dark screenshots. Position it with `position`
|
|
45
|
+
* relative to the marker's box; it receives pointer events although the marker does not, unless `interactive` is
|
|
46
|
+
* `false`.
|
|
22
47
|
*/
|
|
23
|
-
export declare function ImageRegionMarkerBadge({ className, ...props }: IImageRegionMarkerBadgeProps): ReactElement;
|
|
48
|
+
export declare function ImageRegionMarkerBadge({ position, interactive, className, style, ...props }: IImageRegionMarkerBadgeProps): ReactElement;
|
|
24
49
|
export {};
|
|
@@ -8,4 +8,4 @@ export { computeImageDiff } from "./computeImageDiff.js";
|
|
|
8
8
|
export { getNormalizedImagePoint } from "./getNormalizedImagePoint.js";
|
|
9
9
|
export type { IImageComparisonSource, IImageDiff, IImageDiffOptions, IImageDiffRegion, IImagePixels, IImageRect, IImageSize, INormalizedImagePoint, ImageComparisonMode, ImageComparisonOrientation, ImageZoom, } from "./types.js";
|
|
10
10
|
export { ImageRegionMarker, ImageRegionMarkerBadge } from "./ImageRegionMarker.js";
|
|
11
|
-
export type { IImageRegionMarkerBadgeProps, IImageRegionMarkerProps, ImageRegionMarkerVariant, } from "./ImageRegionMarker.js";
|
|
11
|
+
export type { IImageRegionBadgePosition, IImageRegionBox, IImageRegionMarkerBadgeProps, IImageRegionMarkerProps, ImageRegionLength, ImageRegionMarkerVariant, } from "./ImageRegionMarker.js";
|
|
@@ -488,18 +488,33 @@ var imageRegionMarkerVariants = cva("pointer-events-none absolute rounded-xs sha
|
|
|
488
488
|
},
|
|
489
489
|
defaultVariants: { variant: "comment" }
|
|
490
490
|
});
|
|
491
|
-
function ImageRegionMarker({
|
|
491
|
+
function ImageRegionMarker({
|
|
492
|
+
variant,
|
|
493
|
+
region,
|
|
494
|
+
className,
|
|
495
|
+
style,
|
|
496
|
+
...props
|
|
497
|
+
}) {
|
|
492
498
|
return /* @__PURE__ */ jsx5("div", {
|
|
493
499
|
"data-slot": "image-region-marker",
|
|
494
500
|
"data-variant": variant ?? "comment",
|
|
495
501
|
className: cn2(imageRegionMarkerVariants({ variant }), className),
|
|
502
|
+
style: region ? { ...style, ...region } : style,
|
|
496
503
|
...props
|
|
497
504
|
});
|
|
498
505
|
}
|
|
499
|
-
function ImageRegionMarkerBadge({
|
|
506
|
+
function ImageRegionMarkerBadge({
|
|
507
|
+
position,
|
|
508
|
+
interactive = true,
|
|
509
|
+
className,
|
|
510
|
+
style,
|
|
511
|
+
...props
|
|
512
|
+
}) {
|
|
500
513
|
return /* @__PURE__ */ jsx5("div", {
|
|
501
514
|
"data-slot": "image-region-marker-badge",
|
|
502
|
-
|
|
515
|
+
"data-interactive": interactive,
|
|
516
|
+
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),
|
|
517
|
+
style: position ? { ...style, ...position } : style,
|
|
503
518
|
...props
|
|
504
519
|
});
|
|
505
520
|
}
|
|
@@ -517,7 +532,7 @@ function ImageDifferenceOverlay({ diff }) {
|
|
|
517
532
|
children: diff.regions.map((region) => /* @__PURE__ */ jsx6(ImageRegionMarker, {
|
|
518
533
|
"data-slot": "image-difference-region",
|
|
519
534
|
variant: "difference",
|
|
520
|
-
|
|
535
|
+
region: {
|
|
521
536
|
left: toPercent(region.x, diff.width),
|
|
522
537
|
top: toPercent(region.y, diff.height),
|
|
523
538
|
width: toPercent(region.width, diff.width),
|
|
@@ -25,13 +25,8 @@ import {
|
|
|
25
25
|
PaginationLink2,
|
|
26
26
|
PaginationPrevious2,
|
|
27
27
|
PaginationNext2,
|
|
28
|
-
PaginationEllipsis2
|
|
29
|
-
|
|
30
|
-
DrawerContent2,
|
|
31
|
-
DrawerHeader2,
|
|
32
|
-
DrawerTitle2,
|
|
33
|
-
DrawerDescription2
|
|
34
|
-
} from "../../chunk-kr38ww4n.js";
|
|
28
|
+
PaginationEllipsis2
|
|
29
|
+
} from "../../chunk-fg1h007n.js";
|
|
35
30
|
import {
|
|
36
31
|
MenuPopup,
|
|
37
32
|
MenuItem2,
|
|
@@ -116,7 +111,13 @@ import {
|
|
|
116
111
|
SelectItem2
|
|
117
112
|
} from "../../chunk-p6z2m3zp.js";
|
|
118
113
|
import"../../chunk-1j2hz3w9.js";
|
|
119
|
-
import
|
|
114
|
+
import {
|
|
115
|
+
Drawer2,
|
|
116
|
+
DrawerContent2,
|
|
117
|
+
DrawerHeader2,
|
|
118
|
+
DrawerTitle2,
|
|
119
|
+
DrawerDescription2
|
|
120
|
+
} from "../../chunk-cc35g6sr.js";
|
|
120
121
|
import {
|
|
121
122
|
Toggle2,
|
|
122
123
|
ToggleGroup2,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ReactElement, type ReactNode } from "react";
|
|
2
|
+
import type { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
|
|
2
3
|
import { type LayoutStorage } from "react-resizable-panels";
|
|
3
4
|
interface ISplitViewProps {
|
|
4
5
|
sidebar: ReactNode;
|
|
@@ -26,16 +27,30 @@ interface ISplitViewProps {
|
|
|
26
27
|
* Below `wideQuery`: "stack" places the panes one above the other; "takeover" shows an open sidebar in the content's
|
|
27
28
|
* place, with the content hidden but still mounted, as a narrow window's inspector or review does; "strip" places an
|
|
28
29
|
* open sidebar above the content as a strip whose height the divider resizes, so both stay in view and usable, as a
|
|
29
|
-
* persistent tool panel under a player does.
|
|
30
|
+
* persistent tool panel under a player does. "sheet" opens the sidebar as a modal, full-height panel from its own
|
|
31
|
+
* edge, titled `sidebarLabel` with a Close button, as a phone's navigation does; "drawer" opens it as a modal bottom
|
|
32
|
+
* drawer at 85% of the viewport height, full height while `sidebarExpanded`, as a phone's comments do. Both close on
|
|
33
|
+
* Escape, an outside press or a swipe toward their edge, report it through `onSidebarOpenChange`, and leave the
|
|
34
|
+
* content in the document's flow so the page scrolls as one document.
|
|
35
|
+
*/
|
|
36
|
+
narrowLayout?: "stack" | "takeover" | "strip" | "sheet" | "drawer";
|
|
37
|
+
/**
|
|
38
|
+
* Widens the sidebar to `maxSidebarSize`; turning it off restores the width it had before. With the "drawer" narrow
|
|
39
|
+
* layout it raises the drawer to the full viewport height.
|
|
30
40
|
*/
|
|
31
|
-
narrowLayout?: "stack" | "takeover" | "strip";
|
|
32
|
-
/** Widens the sidebar to `maxSidebarSize`; turning it off restores the width it had before. */
|
|
33
41
|
sidebarExpanded?: boolean;
|
|
42
|
+
/** Called when a "sheet" or "drawer" narrow layout asks to open or close the sidebar, such as on Escape or a swipe. */
|
|
43
|
+
onSidebarOpenChange?: (open: boolean) => void;
|
|
44
|
+
/**
|
|
45
|
+
* Where focus goes when a "sheet" or "drawer" narrow layout closes, as Base UI's `finalFocus`: by default the element
|
|
46
|
+
* that had focus before it opened; return `false` from a function to leave focus where the consumer put it.
|
|
47
|
+
*/
|
|
48
|
+
sidebarFinalFocus?: DialogPrimitive.Popup.Props["finalFocus"];
|
|
34
49
|
}
|
|
35
50
|
/**
|
|
36
51
|
* Pairs a resizable sidebar with its content above `wideQuery` (1024px by default) and stacks them below it, or lets an
|
|
37
52
|
* open sidebar take over the content's place. The sidebar and content render into slots that move between the
|
|
38
53
|
* layouts, so their state survives resizing across the breakpoint and opening or closing the sidebar.
|
|
39
54
|
*/
|
|
40
|
-
export declare function SplitView({ sidebar, children, storageKey, sidebarPosition, sidebarOpen, storage, sidebarLabel, contentLabel, resizeLabel, defaultSidebarSize, sidebarPadding, contentPadding, layout: layoutMode, minSidebarSize, maxSidebarSize, wideQuery, narrowLayout, sidebarExpanded, }: ISplitViewProps): ReactElement;
|
|
55
|
+
export declare function SplitView({ sidebar, children, storageKey, sidebarPosition, sidebarOpen, storage, sidebarLabel, contentLabel, resizeLabel, defaultSidebarSize, sidebarPadding, contentPadding, layout: layoutMode, minSidebarSize, maxSidebarSize, wideQuery, narrowLayout, sidebarExpanded, onSidebarOpenChange, sidebarFinalFocus, }: ISplitViewProps): ReactElement;
|
|
41
56
|
export {};
|
|
@@ -12,8 +12,20 @@ import {
|
|
|
12
12
|
Separator2
|
|
13
13
|
} from "../../chunk-52aadmkc.js";
|
|
14
14
|
import {
|
|
15
|
-
useMediaQuery
|
|
16
|
-
|
|
15
|
+
useMediaQuery,
|
|
16
|
+
Drawer2,
|
|
17
|
+
DrawerClose2,
|
|
18
|
+
DrawerContent2,
|
|
19
|
+
DrawerTitle2
|
|
20
|
+
} from "../../chunk-cc35g6sr.js";
|
|
21
|
+
import"../../chunk-e6hk39ev.js";
|
|
22
|
+
import"../../chunk-x90xmrba.js";
|
|
23
|
+
import {
|
|
24
|
+
useDirection2
|
|
25
|
+
} from "../../chunk-jpvw9xqy.js";
|
|
26
|
+
import {
|
|
27
|
+
Button2
|
|
28
|
+
} from "../../chunk-32t5kc0y.js";
|
|
17
29
|
import"../../chunk-5mydsjp3.js";
|
|
18
30
|
// src/components/resizable/SplitView.tsx
|
|
19
31
|
import {
|
|
@@ -24,6 +36,7 @@ import {
|
|
|
24
36
|
useSyncExternalStore
|
|
25
37
|
} from "react";
|
|
26
38
|
import { createPortal } from "react-dom";
|
|
39
|
+
import { XIcon } from "lucide-react";
|
|
27
40
|
import { useDefaultLayout, usePanelRef } from "react-resizable-panels";
|
|
28
41
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
29
42
|
var layoutStorage = {
|
|
@@ -33,6 +46,8 @@ var layoutStorage = {
|
|
|
33
46
|
if (!raw)
|
|
34
47
|
return null;
|
|
35
48
|
const value = JSON.parse(raw);
|
|
49
|
+
if (typeof value === "number")
|
|
50
|
+
return Number.isFinite(value) && value > 0 ? raw : null;
|
|
36
51
|
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
37
52
|
return null;
|
|
38
53
|
return Object.values(value).every((size) => typeof size === "number" && Number.isFinite(size) && size >= 0 && size <= 100) ? raw : null;
|
|
@@ -46,6 +61,23 @@ var layoutStorage = {
|
|
|
46
61
|
} catch {}
|
|
47
62
|
}
|
|
48
63
|
};
|
|
64
|
+
function getSidebarWidthKey(storageKey) {
|
|
65
|
+
return `split-view:${storageKey}:sidebar-px`;
|
|
66
|
+
}
|
|
67
|
+
function readSidebarWidth(storage, storageKey) {
|
|
68
|
+
try {
|
|
69
|
+
const raw = storage.getItem(getSidebarWidthKey(storageKey));
|
|
70
|
+
const value = raw === null ? null : JSON.parse(raw);
|
|
71
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : null;
|
|
72
|
+
} catch {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function writeSidebarWidth(storage, storageKey, width) {
|
|
77
|
+
try {
|
|
78
|
+
storage.setItem(getSidebarWidthKey(storageKey), JSON.stringify(width));
|
|
79
|
+
} catch {}
|
|
80
|
+
}
|
|
49
81
|
function createSlot() {
|
|
50
82
|
const slot = document.createElement("div");
|
|
51
83
|
slot.className = "contents";
|
|
@@ -82,22 +114,25 @@ function SplitView({
|
|
|
82
114
|
maxSidebarSize = "50%",
|
|
83
115
|
wideQuery = "(min-width: 1024px)",
|
|
84
116
|
narrowLayout = "stack",
|
|
85
|
-
sidebarExpanded = false
|
|
117
|
+
sidebarExpanded = false,
|
|
118
|
+
onSidebarOpenChange,
|
|
119
|
+
sidebarFinalFocus
|
|
86
120
|
}) {
|
|
87
121
|
const isFill = layoutMode === "fill";
|
|
88
122
|
const isWide = useMediaQuery(wideQuery);
|
|
123
|
+
const direction = useDirection2();
|
|
89
124
|
const isTakeover = !isWide && narrowLayout === "takeover" && sidebarOpen;
|
|
90
125
|
const isStrip = !isWide && narrowLayout === "strip" && sidebarOpen;
|
|
91
|
-
const
|
|
126
|
+
const isOverlay = !isWide && (narrowLayout === "sheet" || narrowLayout === "drawer");
|
|
92
127
|
const stripLayout = useDefaultLayout({ id: `${storageKey}:strip`, storage, onlySaveAfterUserInteractions: true });
|
|
93
128
|
const sidebarRef = usePanelRef();
|
|
94
129
|
const isHydrated = useSyncExternalStore(subscribeToHydration, () => true, () => false);
|
|
95
130
|
const [slots] = useState(createSlots);
|
|
96
131
|
const portalSlots = isHydrated ? slots : null;
|
|
97
|
-
const
|
|
98
|
-
const openSize = useRef(
|
|
99
|
-
const wasShownOpen = useRef(false);
|
|
132
|
+
const [storedWidth] = useState(() => readSidebarWidth(storage, storageKey));
|
|
133
|
+
const openSize = useRef(storedWidth ?? defaultSidebarSize);
|
|
100
134
|
const pendingOpenSize = useRef(null);
|
|
135
|
+
const groupRef = useRef(null);
|
|
101
136
|
useEffect(() => {
|
|
102
137
|
const panel = sidebarRef.current;
|
|
103
138
|
if (!isWide || !panel)
|
|
@@ -107,12 +142,8 @@ function SplitView({
|
|
|
107
142
|
pendingOpenSize.current = openSize.current;
|
|
108
143
|
panel.expand();
|
|
109
144
|
}
|
|
110
|
-
wasShownOpen.current = true;
|
|
111
145
|
return;
|
|
112
146
|
}
|
|
113
|
-
if (wasShownOpen.current && !panel.isCollapsed())
|
|
114
|
-
openSize.current = `${panel.getSize().asPercentage}%`;
|
|
115
|
-
wasShownOpen.current = false;
|
|
116
147
|
panel.collapse();
|
|
117
148
|
}, [isWide, sidebarOpen, sidebarRef]);
|
|
118
149
|
const unexpandedSize = useRef(null);
|
|
@@ -129,15 +160,15 @@ function SplitView({
|
|
|
129
160
|
}
|
|
130
161
|
}, [isWide, sidebarOpen, sidebarExpanded, maxSidebarSize, sidebarRef]);
|
|
131
162
|
const sidebarContent = /* @__PURE__ */ jsx("aside", {
|
|
132
|
-
hidden: !sidebarOpen,
|
|
163
|
+
hidden: !sidebarOpen && !isOverlay,
|
|
133
164
|
"aria-label": sidebarLabel,
|
|
134
|
-
className: cn2("min-w-0 bg-card", isWide && "h-full", sidebarPadding === "panel" && "p-4", isFill && "min-h-0 overflow-y-auto", !isWide && isFill && !isTakeover && !isStrip && "max-h-[35%] shrink-0", isStrip && "h-full", isTakeover && isFill && "flex-1"),
|
|
165
|
+
className: cn2("min-w-0 bg-card", isWide && "h-full", sidebarPadding === "panel" && "p-4", (isFill || isOverlay) && "min-h-0 overflow-y-auto", isOverlay && "flex-1", !isWide && isFill && !isTakeover && !isStrip && !isOverlay && "max-h-[35%] shrink-0", isStrip && "h-full", isTakeover && isFill && "flex-1"),
|
|
135
166
|
children: sidebar
|
|
136
167
|
});
|
|
137
168
|
const content = /* @__PURE__ */ jsx("section", {
|
|
138
169
|
"aria-label": contentLabel,
|
|
139
170
|
hidden: isTakeover,
|
|
140
|
-
className: cn2("min-w-0 bg-card", isWide && "h-full", contentPadding === "panel" && "p-4", isFill && "flex min-h-0 flex-1 flex-col overflow-hidden"),
|
|
171
|
+
className: cn2("min-w-0 bg-card", isWide && "h-full", contentPadding === "panel" && "p-4", isFill && (isOverlay ? "flex flex-1 flex-col" : "flex min-h-0 flex-1 flex-col overflow-hidden")),
|
|
141
172
|
children
|
|
142
173
|
});
|
|
143
174
|
const sidebarSlot = portalSlots ? /* @__PURE__ */ jsx(SlotHost, {
|
|
@@ -160,8 +191,11 @@ function SplitView({
|
|
|
160
191
|
sidebarRef.current?.resize(pending);
|
|
161
192
|
} else if (pending === null && size.inPixels === 0)
|
|
162
193
|
sidebarRef.current?.resize(minSidebarSize);
|
|
194
|
+
else if (pending === null)
|
|
195
|
+
openSize.current = size.inPixels;
|
|
163
196
|
},
|
|
164
|
-
defaultSize:
|
|
197
|
+
defaultSize: openSize.current,
|
|
198
|
+
groupResizeBehavior: "preserve-pixel-size",
|
|
165
199
|
minSize: minSidebarSize,
|
|
166
200
|
maxSize: maxSidebarSize,
|
|
167
201
|
children: sidebarSlot
|
|
@@ -173,8 +207,17 @@ function SplitView({
|
|
|
173
207
|
});
|
|
174
208
|
const frame = isWide ? /* @__PURE__ */ jsxs(Resizable2, {
|
|
175
209
|
orientation: "horizontal",
|
|
176
|
-
|
|
177
|
-
onLayoutChanged: layout
|
|
210
|
+
elementRef: groupRef,
|
|
211
|
+
onLayoutChanged: (layout, meta) => {
|
|
212
|
+
const share = layout.sidebar;
|
|
213
|
+
const group = groupRef.current;
|
|
214
|
+
if (!meta.isUserInteraction || !sidebarOpen || share === undefined || share <= 0 || !group)
|
|
215
|
+
return;
|
|
216
|
+
const dividers = Array.from(group.querySelectorAll(":scope > [role='separator']"));
|
|
217
|
+
const width = dividers.reduce((total, divider) => total - divider.getBoundingClientRect().width, group.getBoundingClientRect().width);
|
|
218
|
+
openSize.current = width * share / 100;
|
|
219
|
+
writeSidebarWidth(storage, storageKey, openSize.current);
|
|
220
|
+
},
|
|
178
221
|
children: [
|
|
179
222
|
sidebarPosition === "start" ? sidebarPanel : contentPanel,
|
|
180
223
|
/* @__PURE__ */ jsx(ResizableHandle2, {
|
|
@@ -208,6 +251,47 @@ function SplitView({
|
|
|
208
251
|
children: contentSlot
|
|
209
252
|
})
|
|
210
253
|
]
|
|
254
|
+
}) : isOverlay ? /* @__PURE__ */ jsxs(Fragment, {
|
|
255
|
+
children: [
|
|
256
|
+
/* @__PURE__ */ jsx("div", {
|
|
257
|
+
className: cn2("flex min-w-0 flex-col bg-card", isFill && "flex-1"),
|
|
258
|
+
children: contentSlot
|
|
259
|
+
}),
|
|
260
|
+
/* @__PURE__ */ jsx(Drawer2, {
|
|
261
|
+
open: sidebarOpen,
|
|
262
|
+
onOpenChange: (open) => onSidebarOpenChange?.(open),
|
|
263
|
+
showSwipeHandle: true,
|
|
264
|
+
swipeDirection: narrowLayout === "drawer" ? "down" : sidebarPosition === "start" === (direction === "rtl") ? "right" : "left",
|
|
265
|
+
children: /* @__PURE__ */ jsxs(DrawerContent2, {
|
|
266
|
+
"aria-label": sidebarLabel,
|
|
267
|
+
finalFocus: sidebarFinalFocus,
|
|
268
|
+
className: cn2(narrowLayout === "drawer" && "data-[swipe-axis=y]:[--drawer-content-max-height:100dvh] data-[swipe-axis=y]:rounded-t-none", narrowLayout === "drawer" && (sidebarExpanded ? "h-dvh" : "h-[85dvh]")),
|
|
269
|
+
children: [
|
|
270
|
+
narrowLayout === "sheet" && /* @__PURE__ */ jsxs("div", {
|
|
271
|
+
className: "flex shrink-0 items-center justify-between gap-2 p-panel pb-0",
|
|
272
|
+
children: [
|
|
273
|
+
/* @__PURE__ */ jsx(DrawerTitle2, {
|
|
274
|
+
children: sidebarLabel
|
|
275
|
+
}),
|
|
276
|
+
/* @__PURE__ */ jsxs(DrawerClose2, {
|
|
277
|
+
render: /* @__PURE__ */ jsx(Button2, {
|
|
278
|
+
variant: "ghost",
|
|
279
|
+
size: "sm"
|
|
280
|
+
}),
|
|
281
|
+
children: [
|
|
282
|
+
/* @__PURE__ */ jsx(XIcon, {
|
|
283
|
+
"aria-hidden": "true"
|
|
284
|
+
}),
|
|
285
|
+
"Close"
|
|
286
|
+
]
|
|
287
|
+
})
|
|
288
|
+
]
|
|
289
|
+
}),
|
|
290
|
+
sidebarSlot
|
|
291
|
+
]
|
|
292
|
+
})
|
|
293
|
+
})
|
|
294
|
+
]
|
|
211
295
|
}) : /* @__PURE__ */ jsxs("div", {
|
|
212
296
|
className: cn2("flex min-w-0 flex-col bg-card", isFill && "h-full min-h-0 overflow-hidden"),
|
|
213
297
|
children: [
|
package/dist/index.js
CHANGED
|
@@ -66,17 +66,6 @@ import {
|
|
|
66
66
|
PaginationPrevious2,
|
|
67
67
|
PaginationNext2,
|
|
68
68
|
PaginationEllipsis2,
|
|
69
|
-
Drawer2,
|
|
70
|
-
DrawerTrigger2,
|
|
71
|
-
DrawerPortal2,
|
|
72
|
-
DrawerClose2,
|
|
73
|
-
DrawerOverlay2,
|
|
74
|
-
DrawerSwipeHandle2,
|
|
75
|
-
DrawerContent2,
|
|
76
|
-
DrawerHeader2,
|
|
77
|
-
DrawerFooter2,
|
|
78
|
-
DrawerTitle2,
|
|
79
|
-
DrawerDescription2,
|
|
80
69
|
Menubar2,
|
|
81
70
|
MenubarMenu2,
|
|
82
71
|
MenubarGroup2,
|
|
@@ -176,7 +165,7 @@ import {
|
|
|
176
165
|
StatusTracker2,
|
|
177
166
|
DashboardLayout2,
|
|
178
167
|
BillingUsage2
|
|
179
|
-
} from "./chunk-
|
|
168
|
+
} from "./chunk-fg1h007n.js";
|
|
180
169
|
import {
|
|
181
170
|
Combobox2,
|
|
182
171
|
ComboboxValue2,
|
|
@@ -443,7 +432,19 @@ import {
|
|
|
443
432
|
Input2
|
|
444
433
|
} from "./chunk-7vg045gd.js";
|
|
445
434
|
import"./chunk-7jpsybag.js";
|
|
446
|
-
import
|
|
435
|
+
import {
|
|
436
|
+
Drawer2,
|
|
437
|
+
DrawerTrigger2,
|
|
438
|
+
DrawerPortal2,
|
|
439
|
+
DrawerClose2,
|
|
440
|
+
DrawerOverlay2,
|
|
441
|
+
DrawerSwipeHandle2,
|
|
442
|
+
DrawerContent2,
|
|
443
|
+
DrawerHeader2,
|
|
444
|
+
DrawerFooter2,
|
|
445
|
+
DrawerTitle2,
|
|
446
|
+
DrawerDescription2
|
|
447
|
+
} from "./chunk-cc35g6sr.js";
|
|
447
448
|
import {
|
|
448
449
|
Separator2
|
|
449
450
|
} from "./chunk-52aadmkc.js";
|
package/dist/prototype.js
CHANGED
|
@@ -2051,7 +2051,7 @@ var program = new Command;
|
|
|
2051
2051
|
// package.json
|
|
2052
2052
|
var package_default = {
|
|
2053
2053
|
name: "@alexgorbatchev/shadcn",
|
|
2054
|
-
version: "0.0.
|
|
2054
|
+
version: "0.0.95",
|
|
2055
2055
|
description: "Sharp, monospace React components with compact and comfortable densities.",
|
|
2056
2056
|
license: "MIT",
|
|
2057
2057
|
repository: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# ImageRegionMarker
|
|
2
2
|
|
|
3
|
-
Import from `@alexgorbatchev/shadcn/image-viewer`. Outlines a region over an image: a 2px outline 1px outside the region over a 4px halo in the page background, so the outline keeps 3:1 against any screenshot in both themes; forced colours draw it in Highlight. Variants: `comment` (a saved comment's region), `draft` (dashed, a region being drawn) and `difference` (changed pixels, used by ImageComparison's Highlight differences). Position it with `
|
|
3
|
+
Import from `@alexgorbatchev/shadcn/image-viewer`. Outlines a region over an image: a 2px outline 1px outside the region over a 4px halo in the page background, so the outline keeps 3:1 against any screenshot in both themes; forced colours draw it in Highlight. Variants: `comment` (a saved comment's region), `draft` (dashed, a region being drawn) and `difference` (changed pixels, used by ImageComparison's Highlight differences). Position it with `region` (left, top, width, height in pixels or any CSS length) over a positioned image box. `ImageRegionMarkerBadge` pins an interactive control, such as a comment count, beside the marker with the same outline and halo; place it with `position`, and pass `interactive={false}` while another gesture owns the pointer. The theme's `target-emphasis` utility is the matching two-tone mark for a jump target on the page.
|
|
4
4
|
|
|
5
5
|
Story: @alexgorbatchev/shadcn/components/data-display/ImageRegionMarker
|
|
6
6
|
Source: src/components/stories/data-display/ImageRegionMarker.stories.tsx
|
|
@@ -38,8 +38,8 @@ ImageRegionMarker
|
|
|
38
38
|
(args) => (<div className="flex flex-wrap gap-6">
|
|
39
39
|
{screenshots.map((screenshot) => (<figure key={screenshot.label} className="flex flex-col gap-2">
|
|
40
40
|
<div role="img" aria-label={screenshot.label} className="relative h-40 w-72" style={{ background: screenshot.background }}>
|
|
41
|
-
<ImageRegionMarker {...args}
|
|
42
|
-
<ImageRegionMarkerBadge
|
|
41
|
+
<ImageRegionMarker {...args} region={{ left: "20%", top: "35%", width: "45%", height: "30%" }}>
|
|
42
|
+
<ImageRegionMarkerBadge position={{ left: "calc(100% + 8px)", top: -32 }}>
|
|
43
43
|
<Button size="sm" variant="secondary" aria-label={`Open comments on ${screenshot.label}`}>
|
|
44
44
|
3
|
|
45
45
|
</Button>
|
|
@@ -77,6 +77,22 @@ Storybook CSF excerpts. Default args and render apply unless overridden. Local h
|
|
|
77
77
|
}
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
+
### InertBadge
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
{
|
|
84
|
+
render: () => (<div role="img" aria-label="Screenshot being drawn on" className="relative h-40 w-72 bg-muted">
|
|
85
|
+
<ImageRegionMarker region={{ left: 40, top: 50, width: 120, height: 60 }}>
|
|
86
|
+
<ImageRegionMarkerBadge position={{ left: 128, top: -32 }} interactive={false}>
|
|
87
|
+
<Button size="sm" variant="secondary" aria-label="Open comments">
|
|
88
|
+
1
|
|
89
|
+
</Button>
|
|
90
|
+
</ImageRegionMarkerBadge>
|
|
91
|
+
</ImageRegionMarker>
|
|
92
|
+
</div>)
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
80
96
|
### TargetEmphasis
|
|
81
97
|
|
|
82
98
|
```tsx
|
|
@@ -82,7 +82,7 @@ Storybook CSF excerpts. Default args and render apply unless overridden. Local h
|
|
|
82
82
|
{isVisible && (<SplitView {...args} storageKey="external-layout" storage={storage} sidebar={<h2>Navigation</h2>}>
|
|
83
83
|
<h2>Content</h2>
|
|
84
84
|
</SplitView>)}
|
|
85
|
-
<Button onClick={() => setVisible(values.has("
|
|
85
|
+
<Button onClick={() => setVisible(values.has("split-view:external-layout:sidebar-px"))}>
|
|
86
86
|
Restore saved panels
|
|
87
87
|
</Button>
|
|
88
88
|
<p role="status">{isSaved ? "Layout saved" : "No saved layout"}</p>
|
|
@@ -236,3 +236,47 @@ Storybook CSF excerpts. Default args and render apply unless overridden. Local h
|
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
238
|
```
|
|
239
|
+
|
|
240
|
+
### NarrowSheet
|
|
241
|
+
|
|
242
|
+
```tsx
|
|
243
|
+
{
|
|
244
|
+
render: function Example(args) {
|
|
245
|
+
const [open, setOpen] = useState(false);
|
|
246
|
+
return (<div className="flex w-[600px] flex-col gap-2">
|
|
247
|
+
<Button onClick={() => setOpen(true)}>Pages</Button>
|
|
248
|
+
<SplitView {...args} sidebarLabel="Pages" sidebarOpen={open} onSidebarOpenChange={setOpen} wideQuery="(min-width: 100000px)" narrowLayout="sheet" layout="fill" sidebar={<nav aria-label="Projects and pages">
|
|
249
|
+
<button type="button" onClick={() => setOpen(false)}>
|
|
250
|
+
Brand questionnaire
|
|
251
|
+
</button>
|
|
252
|
+
</nav>}>
|
|
253
|
+
<h2>Incident review</h2>
|
|
254
|
+
</SplitView>
|
|
255
|
+
</div>);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### NarrowDrawer
|
|
261
|
+
|
|
262
|
+
```tsx
|
|
263
|
+
{
|
|
264
|
+
render: function Example(args) {
|
|
265
|
+
const [open, setOpen] = useState(false);
|
|
266
|
+
const [expanded, setExpanded] = useState(false);
|
|
267
|
+
return (<div className="flex w-[600px] flex-col gap-2">
|
|
268
|
+
<Button onClick={() => setOpen(true)}>Comments</Button>
|
|
269
|
+
<SplitView {...args} sidebarLabel="Comments" sidebarPosition="end" sidebarOpen={open} sidebarExpanded={expanded} onSidebarOpenChange={setOpen} wideQuery="(min-width: 100000px)" narrowLayout="drawer" layout="fill" sidebar={<div className="flex gap-2 p-panel">
|
|
270
|
+
<Button variant="outline" onClick={() => setExpanded(!expanded)}>
|
|
271
|
+
{expanded ? "Collapse" : "Full height"}
|
|
272
|
+
</Button>
|
|
273
|
+
<Button variant="outline" onClick={() => setOpen(false)}>
|
|
274
|
+
Close comments
|
|
275
|
+
</Button>
|
|
276
|
+
</div>}>
|
|
277
|
+
<h2>Incident review</h2>
|
|
278
|
+
</SplitView>
|
|
279
|
+
</div>);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
```
|
|
@@ -595,3 +595,23 @@ Storybook CSF excerpts. Default args and render apply unless overridden. Local h
|
|
|
595
595
|
</Drawer>)
|
|
596
596
|
}
|
|
597
597
|
```
|
|
598
|
+
|
|
599
|
+
### MotionPreference
|
|
600
|
+
|
|
601
|
+
```tsx
|
|
602
|
+
{
|
|
603
|
+
render: (args) => (<Drawer {...args}>
|
|
604
|
+
<DrawerTrigger render={<Button variant="outline"/>}>Open details</DrawerTrigger>
|
|
605
|
+
<DrawerContent>
|
|
606
|
+
<DrawerHeader>
|
|
607
|
+
<DrawerTitle>Project details</DrawerTitle>
|
|
608
|
+
<DrawerDescription>Review the project before continuing.</DrawerDescription>
|
|
609
|
+
</DrawerHeader>
|
|
610
|
+
<div className="p-panel">Three tasks are ready.</div>
|
|
611
|
+
<DrawerFooter>
|
|
612
|
+
<DrawerClose render={<Button />}>Done</DrawerClose>
|
|
613
|
+
</DrawerFooter>
|
|
614
|
+
</DrawerContent>
|
|
615
|
+
</Drawer>)
|
|
616
|
+
}
|
|
617
|
+
```
|
|
@@ -431,3 +431,23 @@ Storybook CSF excerpts. Default args and render apply unless overridden. Local h
|
|
|
431
431
|
</Sheet>)
|
|
432
432
|
}
|
|
433
433
|
```
|
|
434
|
+
|
|
435
|
+
### MotionPreference
|
|
436
|
+
|
|
437
|
+
```tsx
|
|
438
|
+
{
|
|
439
|
+
render: (args) => (<Sheet>
|
|
440
|
+
<SheetTrigger render={<Button variant="outline"/>}>Open preferences</SheetTrigger>
|
|
441
|
+
<SheetContent {...args}>
|
|
442
|
+
<SheetHeader>
|
|
443
|
+
<SheetTitle>Preferences</SheetTitle>
|
|
444
|
+
<SheetDescription>Adjust your workspace preferences.</SheetDescription>
|
|
445
|
+
</SheetHeader>
|
|
446
|
+
<SheetFooter>
|
|
447
|
+
<SheetClose render={<Button />}>Done</SheetClose>
|
|
448
|
+
</SheetFooter>
|
|
449
|
+
</SheetContent>
|
|
450
|
+
</Sheet>),
|
|
451
|
+
args: { side: "left" }
|
|
452
|
+
}
|
|
453
|
+
```
|
package/llms.txt
CHANGED
|
@@ -343,7 +343,7 @@ Generated from the public package exports and Storybook sources.
|
|
|
343
343
|
- [DataViewer](./llms/components/data-display/DataViewer.md)
|
|
344
344
|
- [Heading](./llms/components/data-display/Heading.md): Heading renders `h1`–`h6` from the required `level` so the document outline stays correct, while `size` (sm, base, lg, xl) sets the visual size independently. Sizes default by level: 1 xl, 2 lg, 3 base, 4–6 sm. `truncate` keeps one line.
|
|
345
345
|
- [ImageComparison](./llms/components/data-display/ImageComparison.md): Import from `@alexgorbatchev/shadcn/image-viewer`. ImageComparison fills its container and compares `before` and `after` images (`{ src, alt, crossOrigin? }`) labelled by `beforeLabel` and `afterLabel` (default "Before" and "After"). `toggle` (the default) shows the after image and the "Hold to show before" button shows the before image while a pointer, Space, or Enter is held. `swipe` stacks both images; the divider is a slider (0–100, arrows ±1, Page Up/Page Down ±10, Home/End) whose handle drags with pointer capture. `side-by-side` shows labelled panes left and right (`horizontal`) or top and bottom (`vertical`) that scroll in sync at original size. Every mode starts fitted and offers original size. A differently sized before image is drawn inside the after image box, and the toolbar reports the mismatch. "Highlight differences" compares pixels on first use, caches the result per image pair, outlines changed regions, and summarizes them; it is disabled with a reason when pixels cannot be read. `mode`, `orientation`, `zoom`, and `showDifferences` are controllable with matching `default*` and `on*Change` props; `showToolbar={false}` hides the controls, which sit beside wide comparisons and below narrow ones.
|
|
346
|
-
- [ImageRegionMarker](./llms/components/data-display/ImageRegionMarker.md): Import from `@alexgorbatchev/shadcn/image-viewer`. Outlines a region over an image: a 2px outline 1px outside the region over a 4px halo in the page background, so the outline keeps 3:1 against any screenshot in both themes; forced colours draw it in Highlight. Variants: `comment` (a saved comment's region), `draft` (dashed, a region being drawn) and `difference` (changed pixels, used by ImageComparison's Highlight differences). Position it with `
|
|
346
|
+
- [ImageRegionMarker](./llms/components/data-display/ImageRegionMarker.md): Import from `@alexgorbatchev/shadcn/image-viewer`. Outlines a region over an image: a 2px outline 1px outside the region over a 4px halo in the page background, so the outline keeps 3:1 against any screenshot in both themes; forced colours draw it in Highlight. Variants: `comment` (a saved comment's region), `draft` (dashed, a region being drawn) and `difference` (changed pixels, used by ImageComparison's Highlight differences). Position it with `region` (left, top, width, height in pixels or any CSS length) over a positioned image box. `ImageRegionMarkerBadge` pins an interactive control, such as a comment count, beside the marker with the same outline and halo; place it with `position`, and pass `interactive={false}` while another gesture owns the pointer. The theme's `target-emphasis` utility is the matching two-tone mark for a jump target on the page.
|
|
347
347
|
- [ImageViewer](./llms/components/data-display/ImageViewer.md): Import from `@alexgorbatchev/shadcn/image-viewer`. ImageViewer fills the container it is given, such as a `DialogContent size="fullscreen"` body, and shows one image in a native scroll viewport. `fit` (the default) scales the image down proportionally to fit both dimensions, centered and without scrollbars, and never upscales it; `original` shows natural size in CSS pixels, centered on axes where it is smaller and scrolling where it is larger. Switching zoom keeps the viewed center. Control zoom with `zoom` and `onZoomChange`, or leave it uncontrolled with `defaultZoom`; place `ImageZoomToggle` in a header or toolbar, or set `showZoomControl` for the built-in toggle. `overlay` renders content sized and positioned exactly over the rendered image at every zoom, `imageRef` and `overlayRef` expose the rendered image box, and `getNormalizedImagePoint(event, box)` maps pointer coordinates to 0–1 image coordinates.
|
|
348
348
|
- [ImageZoomToggle](./llms/components/data-display/ImageZoomToggle.md): Import from `@alexgorbatchev/shadcn/image-viewer`. A two-option toggle for ImageViewer and ImageComparison zoom that consumers place in a header or toolbar. "Fit to screen" and "Original size" are pressed-state toggles with constant names, so assistive technology announces the active zoom through `aria-pressed`. One option always stays pressed. `label` names the group (default "Zoom"); `size`, `orientation`, `layout`, `disabled`, and `density` follow ToggleGroup.
|
|
349
349
|
- [Item](./llms/components/data-display/Item.md)
|
package/package.json
CHANGED
package/dist/chunk-k99h6evz.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// src/hooks/useMediaQuery.ts
|
|
2
|
-
import { useMemo, useSyncExternalStore } from "react";
|
|
3
|
-
function useMediaQuery(query) {
|
|
4
|
-
const media = useMemo(() => typeof window === "undefined" ? undefined : window.matchMedia(query), [query]);
|
|
5
|
-
return useSyncExternalStore((listener) => {
|
|
6
|
-
media?.addEventListener("change", listener);
|
|
7
|
-
return () => media?.removeEventListener("change", listener);
|
|
8
|
-
}, () => media?.matches ?? false, () => false);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export { useMediaQuery };
|