@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
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useDensity
|
|
3
|
+
} from "./chunk-e6hk39ev.js";
|
|
4
|
+
import {
|
|
5
|
+
usePortalContainer2,
|
|
6
|
+
usePortalNode,
|
|
7
|
+
PortalProvider2
|
|
8
|
+
} from "./chunk-x90xmrba.js";
|
|
9
|
+
import {
|
|
10
|
+
useDirection2
|
|
11
|
+
} from "./chunk-jpvw9xqy.js";
|
|
12
|
+
import {
|
|
13
|
+
cn2
|
|
14
|
+
} from "./chunk-en44w1pn.js";
|
|
15
|
+
import {
|
|
16
|
+
useAnalyticsCallback
|
|
17
|
+
} from "./chunk-5mydsjp3.js";
|
|
18
|
+
|
|
19
|
+
// src/components/Drawer.tsx
|
|
20
|
+
import { useMemo } from "react";
|
|
21
|
+
|
|
22
|
+
// src/drawer/DrawerContext.ts
|
|
23
|
+
import { createContext } from "react";
|
|
24
|
+
var DrawerContext = createContext(null);
|
|
25
|
+
|
|
26
|
+
// src/hooks/useDrawer.ts
|
|
27
|
+
import { useContext } from "react";
|
|
28
|
+
function useDrawer() {
|
|
29
|
+
const context = useContext(DrawerContext);
|
|
30
|
+
if (!context) {
|
|
31
|
+
throw new Error("useDrawer must be used within a Drawer.");
|
|
32
|
+
}
|
|
33
|
+
return context;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/components/Drawer.tsx
|
|
37
|
+
import { Drawer as DrawerPrimitive } from "@base-ui/react/drawer";
|
|
38
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
39
|
+
function Drawer2({
|
|
40
|
+
analytics,
|
|
41
|
+
modal = true,
|
|
42
|
+
showSwipeHandle = false,
|
|
43
|
+
snapPoints,
|
|
44
|
+
swipeDirection = "down",
|
|
45
|
+
...props
|
|
46
|
+
}) {
|
|
47
|
+
const trackedOnOpenChange = useAnalyticsCallback("Drawer", analytics, (open, _details) => ({ name: "ui.open-request", open }), props.onOpenChange);
|
|
48
|
+
const hasSnapPoints = snapPoints != null && snapPoints.length > 0;
|
|
49
|
+
const contextValue = useMemo(() => ({ hasSnapPoints, modal, showSwipeHandle, swipeDirection }), [hasSnapPoints, modal, showSwipeHandle, swipeDirection]);
|
|
50
|
+
return /* @__PURE__ */ jsx(DrawerContext.Provider, {
|
|
51
|
+
value: contextValue,
|
|
52
|
+
children: /* @__PURE__ */ jsx(DrawerPrimitive.Root, {
|
|
53
|
+
"data-slot": "drawer",
|
|
54
|
+
modal,
|
|
55
|
+
snapPoints,
|
|
56
|
+
swipeDirection,
|
|
57
|
+
...props,
|
|
58
|
+
onOpenChange: trackedOnOpenChange
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function DrawerTrigger2({ ...props }) {
|
|
63
|
+
return /* @__PURE__ */ jsx(DrawerPrimitive.Trigger, {
|
|
64
|
+
"data-slot": "drawer-trigger",
|
|
65
|
+
...props
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function DrawerPortal2({ container, ref, children, ...props }) {
|
|
69
|
+
const resolvedContainer = usePortalContainer2(container);
|
|
70
|
+
const portal = usePortalNode(ref);
|
|
71
|
+
return /* @__PURE__ */ jsx(DrawerPrimitive.Portal, {
|
|
72
|
+
"data-slot": "drawer-portal",
|
|
73
|
+
container: resolvedContainer,
|
|
74
|
+
ref: portal.ref,
|
|
75
|
+
...props,
|
|
76
|
+
children: /* @__PURE__ */ jsx(PortalProvider2, {
|
|
77
|
+
container: portal.node,
|
|
78
|
+
children
|
|
79
|
+
})
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function DrawerClose2({ ...props }) {
|
|
83
|
+
return /* @__PURE__ */ jsx(DrawerPrimitive.Close, {
|
|
84
|
+
"data-slot": "drawer-close",
|
|
85
|
+
...props
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function DrawerOverlay2({ density, className, ...props }) {
|
|
89
|
+
const resolvedDensity = useDensity(density);
|
|
90
|
+
return /* @__PURE__ */ jsx(DrawerPrimitive.Backdrop, {
|
|
91
|
+
"data-density": resolvedDensity,
|
|
92
|
+
"data-slot": "drawer-overlay",
|
|
93
|
+
className: (state) => cn2("fixed inset-0 min-h-dvh bg-backdrop opacity-[max(var(--drawer-overlay-min-opacity,0),calc(1-var(--drawer-swipe-progress)))] transition-opacity duration-450 ease-[cubic-bezier(0.32,0.72,0,1)] select-none data-ending-style:pointer-events-none data-ending-style:opacity-0 data-ending-style:duration-[calc(var(--drawer-swipe-strength)*400ms)] data-snap-points:[--drawer-overlay-min-opacity:0.5] data-starting-style:opacity-0 data-swiping:duration-0 supports-[-webkit-touch-callout:none]:absolute", typeof className === "function" ? className(state) : className),
|
|
94
|
+
...props
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function DrawerSwipeHandle2({ density, className, ...props }) {
|
|
98
|
+
return /* @__PURE__ */ jsx("div", {
|
|
99
|
+
"data-density": density,
|
|
100
|
+
"data-slot": "drawer-swipe-handle",
|
|
101
|
+
"aria-hidden": "true",
|
|
102
|
+
className: cn2("relative flex shrink-0 cursor-grab transition-opacity duration-200 group-data-nested-drawer-open/drawer-popup:opacity-0 group-data-nested-drawer-swiping/drawer-popup:opacity-100 group-data-[swipe-axis=x]/drawer-popup:h-full group-data-[swipe-axis=x]/drawer-popup:w-3 group-data-[swipe-axis=x]/drawer-popup:items-center group-data-[swipe-axis=y]/drawer-popup:h-3 group-data-[swipe-axis=y]/drawer-popup:w-full group-data-[swipe-axis=y]/drawer-popup:justify-center group-data-[swipe-direction=down]/drawer-popup:items-end group-data-[swipe-direction=left]/drawer-popup:order-last group-data-[swipe-direction=left]/drawer-popup:justify-start group-data-[swipe-direction=right]/drawer-popup:justify-end group-data-[swipe-direction=up]/drawer-popup:order-last group-data-[swipe-direction=up]/drawer-popup:items-start after:block after:shrink-0 after:rounded-full after:bg-muted group-data-[swipe-axis=x]/drawer-popup:after:h-24 group-data-[swipe-axis=x]/drawer-popup:after:w-1 group-data-[swipe-axis=y]/drawer-popup:after:h-1 group-data-[swipe-axis=y]/drawer-popup:after:w-24 active:cursor-grabbing", className),
|
|
103
|
+
...props
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
function DrawerContent2({ density, className, children, ...props }) {
|
|
107
|
+
const resolvedDensity = useDensity(density);
|
|
108
|
+
const direction = useDirection2();
|
|
109
|
+
const { hasSnapPoints, modal, showSwipeHandle, swipeDirection } = useDrawer();
|
|
110
|
+
const swipeAxis = swipeDirection === "down" || swipeDirection === "up" ? "y" : "x";
|
|
111
|
+
return /* @__PURE__ */ jsxs(DrawerPortal2, {
|
|
112
|
+
"data-slot": "drawer-portal",
|
|
113
|
+
children: [
|
|
114
|
+
modal === true && /* @__PURE__ */ jsx(DrawerOverlay2, {
|
|
115
|
+
"data-snap-points": hasSnapPoints ? "" : undefined
|
|
116
|
+
}),
|
|
117
|
+
/* @__PURE__ */ jsx(DrawerPrimitive.Viewport, {
|
|
118
|
+
dir: direction,
|
|
119
|
+
"data-slot": "drawer-viewport",
|
|
120
|
+
"data-modal": modal,
|
|
121
|
+
className: "pointer-events-none fixed inset-0 select-none data-[modal=true]:pointer-events-auto",
|
|
122
|
+
children: /* @__PURE__ */ jsxs(DrawerPrimitive.Popup, {
|
|
123
|
+
"data-density": resolvedDensity,
|
|
124
|
+
"data-slot": "drawer-popup",
|
|
125
|
+
"data-scroll": "none",
|
|
126
|
+
"data-swipe-axis": swipeAxis,
|
|
127
|
+
"data-snap-points": hasSnapPoints ? "" : undefined,
|
|
128
|
+
className: (state) => cn2("group/drawer-popup pointer-events-auto fixed m-(--drawer-inset,0px) flex h-(--drawer-content-height) max-h-(--drawer-content-max-height,none) min-h-0 w-(--drawer-content-width,auto) transform-[translate3d(var(--translate-x,0px),var(--translate-y,0px),0)] flex-col border border-frame-edge shadow-frame bg-popover text-sm text-popover-foreground transition-[transform,height,opacity,filter] duration-450 ease-[cubic-bezier(0.22,1,0.36,1)] will-change-transform outline-none select-none [interpolate-size:allow-keywords] data-[swipe-direction=down]:rounded-t-md data-[swipe-direction=down]:border-t data-[swipe-direction=left]:rounded-r-md data-[swipe-direction=left]:border-r data-[swipe-direction=right]:rounded-l-md data-[swipe-direction=right]:border-l data-[swipe-direction=up]:rounded-b-md data-[swipe-direction=up]:border-b", "data-nested-drawer-open:overflow-hidden data-nested-drawer-open:brightness-95", "after:pointer-events-none after:absolute after:bg-(--drawer-bleed-background,var(--color-popover)) data-[swipe-axis=x]:after:inset-y-0 data-[swipe-axis=x]:after:w-(--bleed) data-[swipe-axis=y]:after:inset-x-0 data-[swipe-axis=y]:after:h-(--bleed) data-[swipe-direction=down]:after:top-full data-[swipe-direction=left]:after:right-full data-[swipe-direction=right]:after:left-full data-[swipe-direction=up]:after:bottom-full", "[--drawer-content-height:var(--drawer-height,auto)] data-[swipe-axis=x]:[--drawer-content-width:75%] data-[swipe-axis=y]:[--drawer-content-max-height:calc(100dvh-6rem)] data-[swipe-axis=y]:data-snap-points:[--drawer-content-height:100dvh] data-[swipe-axis=x]:sm:[--drawer-content-width:24rem]", "[--bleed:3rem] [--peek:1rem] [--stack-height:var(--drawer-frontmost-height,var(--drawer-height,0px))] [--stack-peek-offset:max(0px,calc((var(--nested-drawers)-var(--stack-progress))*var(--peek)))] [--stack-progress:clamp(0,var(--drawer-swipe-progress),1)] [--stack-shrink:0]", "data-ending-style:transform-(--closed-transform) data-ending-style:opacity-[0.9999] data-ending-style:duration-[calc(var(--drawer-swipe-strength)*400ms)] data-nested-drawer-swiping:duration-0 data-ending-style:data-nested-drawer-swiping:duration-[calc(var(--drawer-swipe-strength)*400ms)] data-starting-style:transform-(--closed-transform) data-swiping:duration-0 data-ending-style:data-swiping:duration-[calc(var(--drawer-swipe-strength)*400ms)]", "data-[swipe-axis=y]:inset-x-0 data-[swipe-axis=y]:data-nested-drawer-open:h-(--stack-height)", "data-[swipe-axis=x]:inset-y-0 data-[swipe-axis=x]:flex-row", "data-[swipe-direction=down]:bottom-0 data-[swipe-direction=down]:origin-bottom data-[swipe-direction=down]:[--closed-transform:translate3d(0,calc(100%+var(--drawer-inset,0px)+2px),0)] data-[swipe-direction=down]:[--translate-y:calc(var(--drawer-snap-point-offset,0px)+var(--drawer-swipe-movement-y)-var(--stack-peek-offset)-(var(--stack-shrink)*var(--stack-height)))]", "data-[swipe-direction=up]:top-0 data-[swipe-direction=up]:origin-top data-[swipe-direction=up]:[--closed-transform:translate3d(0,calc(-100%-var(--drawer-inset,0px)-2px),0)] data-[swipe-direction=up]:[--translate-y:calc(var(--drawer-snap-point-offset,0px)+var(--drawer-swipe-movement-y)+var(--stack-peek-offset)+(var(--stack-shrink)*var(--stack-height)))]", "data-[swipe-direction=left]:left-0 data-[swipe-direction=left]:origin-left data-[swipe-direction=left]:[--closed-transform:translate3d(calc(-100%-var(--drawer-inset,0px)-2px),0,0)] data-[swipe-direction=left]:[--translate-x:calc(var(--drawer-swipe-movement-x)+var(--stack-peek-offset)+(var(--stack-shrink)*100%))]", "data-[swipe-direction=right]:right-0 data-[swipe-direction=right]:origin-right data-[swipe-direction=right]:[--closed-transform:translate3d(calc(100%+var(--drawer-inset,0px)+2px),0,0)] data-[swipe-direction=right]:[--translate-x:calc(var(--drawer-swipe-movement-x)-var(--stack-peek-offset)-(var(--stack-shrink)*100%))]", typeof className === "function" ? className(state) : className),
|
|
129
|
+
...props,
|
|
130
|
+
children: [
|
|
131
|
+
showSwipeHandle && /* @__PURE__ */ jsx(DrawerSwipeHandle2, {}),
|
|
132
|
+
/* @__PURE__ */ jsx(DrawerPrimitive.Content, {
|
|
133
|
+
"data-slot": "drawer-content",
|
|
134
|
+
"data-scroll": "none",
|
|
135
|
+
className: "flex min-h-0 flex-1 flex-col overflow-hidden overscroll-contain rounded-[inherit] transition-opacity duration-300 ease-out select-text group-data-nested-drawer-open/drawer-popup:opacity-0 group-data-nested-drawer-swiping/drawer-popup:opacity-100 group-data-swiping/drawer-popup:select-none",
|
|
136
|
+
children
|
|
137
|
+
})
|
|
138
|
+
]
|
|
139
|
+
})
|
|
140
|
+
})
|
|
141
|
+
]
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
function DrawerHeader2({ density, className, ...props }) {
|
|
145
|
+
return /* @__PURE__ */ jsx("div", {
|
|
146
|
+
"data-density": density,
|
|
147
|
+
"data-slot": "drawer-header",
|
|
148
|
+
className: cn2("flex shrink-0 flex-col gap-0.5 p-panel pb-0 group-data-[swipe-axis=y]/drawer-popup:text-center md:gap-0.5 md:text-start md:group-data-[swipe-axis=y]/drawer-popup:text-start", className),
|
|
149
|
+
...props
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
function DrawerFooter2({ density, className, ...props }) {
|
|
153
|
+
return /* @__PURE__ */ jsx("div", {
|
|
154
|
+
"data-density": density,
|
|
155
|
+
"data-slot": "drawer-footer",
|
|
156
|
+
className: cn2("mt-auto flex shrink-0 flex-col gap-2 p-panel pt-0", className),
|
|
157
|
+
...props
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
function DrawerTitle2({ density, className, ...props }) {
|
|
161
|
+
return /* @__PURE__ */ jsx(DrawerPrimitive.Title, {
|
|
162
|
+
"data-density": density,
|
|
163
|
+
"data-slot": "drawer-title",
|
|
164
|
+
className: (state) => cn2(" text-base font-medium text-foreground", typeof className === "function" ? className(state) : className),
|
|
165
|
+
...props
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
function DrawerDescription2({ density, className, ...props }) {
|
|
169
|
+
return /* @__PURE__ */ jsx(DrawerPrimitive.Description, {
|
|
170
|
+
"data-density": density,
|
|
171
|
+
"data-slot": "drawer-description",
|
|
172
|
+
className: (state) => cn2("text-sm text-balance text-muted-foreground", typeof className === "function" ? className(state) : className),
|
|
173
|
+
...props
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// src/hooks/useMediaQuery.ts
|
|
178
|
+
import { useMemo as useMemo2, useSyncExternalStore } from "react";
|
|
179
|
+
function useMediaQuery(query) {
|
|
180
|
+
const media = useMemo2(() => typeof window === "undefined" ? undefined : window.matchMedia(query), [query]);
|
|
181
|
+
return useSyncExternalStore((listener) => {
|
|
182
|
+
media?.addEventListener("change", listener);
|
|
183
|
+
return () => media?.removeEventListener("change", listener);
|
|
184
|
+
}, () => media?.matches ?? false, () => false);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export { useMediaQuery, Drawer2, DrawerTrigger2, DrawerPortal2, DrawerClose2, DrawerOverlay2, DrawerSwipeHandle2, DrawerContent2, DrawerHeader2, DrawerFooter2, DrawerTitle2, DrawerDescription2 };
|