@alexgorbatchev/shadcn 0.0.79 → 0.0.80
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.
|
@@ -16,10 +16,24 @@ interface ISplitViewProps {
|
|
|
16
16
|
contentPadding?: "none" | "panel";
|
|
17
17
|
/** Fill a bounded parent; mobile navigation scrolls within at most 35% of its height. */
|
|
18
18
|
layout?: "content" | "fill";
|
|
19
|
+
/** The sidebar's smallest width beside the content: pixels as a number, or a percentage such as "20%". */
|
|
20
|
+
minSidebarSize?: number | string;
|
|
21
|
+
/** The sidebar's largest width beside the content: pixels as a number, or a percentage such as "60%". */
|
|
22
|
+
maxSidebarSize?: number | string;
|
|
23
|
+
/** The media query above which the panes sit side by side. */
|
|
24
|
+
wideQuery?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Below `wideQuery`: "stack" places the panes one above the other; "takeover" shows an open sidebar in the content's
|
|
27
|
+
* place, with the content hidden but still mounted, as a narrow window's inspector or review does.
|
|
28
|
+
*/
|
|
29
|
+
narrowLayout?: "stack" | "takeover";
|
|
30
|
+
/** Widens the sidebar to `maxSidebarSize`; turning it off restores the width it had before. */
|
|
31
|
+
sidebarExpanded?: boolean;
|
|
19
32
|
}
|
|
20
33
|
/**
|
|
21
|
-
* Pairs a resizable sidebar with its content above 1024px and stacks them below it
|
|
22
|
-
*
|
|
34
|
+
* Pairs a resizable sidebar with its content above `wideQuery` (1024px by default) and stacks them below it, or lets an
|
|
35
|
+
* open sidebar take over the content's place. The sidebar and content render into slots that move between the
|
|
36
|
+
* layouts, so their state survives resizing across the breakpoint and opening or closing the sidebar.
|
|
23
37
|
*/
|
|
24
|
-
export declare function SplitView({ sidebar, children, storageKey, sidebarPosition, sidebarOpen, storage, sidebarLabel, contentLabel, resizeLabel, defaultSidebarSize, sidebarPadding, contentPadding, layout: layoutMode, }: ISplitViewProps): ReactElement;
|
|
38
|
+
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;
|
|
25
39
|
export {};
|
|
@@ -16,7 +16,13 @@ import {
|
|
|
16
16
|
} from "../../chunk-k99h6evz.js";
|
|
17
17
|
import"../../chunk-5mydsjp3.js";
|
|
18
18
|
// src/components/resizable/SplitView.tsx
|
|
19
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
useCallback,
|
|
21
|
+
useEffect,
|
|
22
|
+
useRef,
|
|
23
|
+
useState,
|
|
24
|
+
useSyncExternalStore
|
|
25
|
+
} from "react";
|
|
20
26
|
import { createPortal } from "react-dom";
|
|
21
27
|
import { useDefaultLayout, usePanelRef } from "react-resizable-panels";
|
|
22
28
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
@@ -71,10 +77,16 @@ function SplitView({
|
|
|
71
77
|
defaultSidebarSize = 325,
|
|
72
78
|
sidebarPadding = "panel",
|
|
73
79
|
contentPadding = "panel",
|
|
74
|
-
layout: layoutMode = "content"
|
|
80
|
+
layout: layoutMode = "content",
|
|
81
|
+
minSidebarSize = 200,
|
|
82
|
+
maxSidebarSize = "50%",
|
|
83
|
+
wideQuery = "(min-width: 1024px)",
|
|
84
|
+
narrowLayout = "stack",
|
|
85
|
+
sidebarExpanded = false
|
|
75
86
|
}) {
|
|
76
87
|
const isFill = layoutMode === "fill";
|
|
77
|
-
const isWide = useMediaQuery(
|
|
88
|
+
const isWide = useMediaQuery(wideQuery);
|
|
89
|
+
const isTakeover = !isWide && narrowLayout === "takeover" && sidebarOpen;
|
|
78
90
|
const layout = useDefaultLayout({ id: storageKey, storage, onlySaveAfterUserInteractions: true });
|
|
79
91
|
const sidebarRef = usePanelRef();
|
|
80
92
|
const isHydrated = useSyncExternalStore(subscribeToHydration, () => true, () => false);
|
|
@@ -88,14 +100,28 @@ function SplitView({
|
|
|
88
100
|
else
|
|
89
101
|
sidebarRef.current?.collapse();
|
|
90
102
|
}, [isWide, sidebarOpen, sidebarRef]);
|
|
103
|
+
const unexpandedSize = useRef(null);
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
const panel = sidebarRef.current;
|
|
106
|
+
if (!isWide || !sidebarOpen || !panel)
|
|
107
|
+
return;
|
|
108
|
+
if (sidebarExpanded) {
|
|
109
|
+
unexpandedSize.current ??= panel.getSize().inPixels;
|
|
110
|
+
panel.resize(maxSidebarSize);
|
|
111
|
+
} else if (unexpandedSize.current !== null) {
|
|
112
|
+
panel.resize(unexpandedSize.current);
|
|
113
|
+
unexpandedSize.current = null;
|
|
114
|
+
}
|
|
115
|
+
}, [isWide, sidebarOpen, sidebarExpanded, maxSidebarSize, sidebarRef]);
|
|
91
116
|
const sidebarContent = /* @__PURE__ */ jsx("aside", {
|
|
92
117
|
hidden: !sidebarOpen,
|
|
93
118
|
"aria-label": sidebarLabel,
|
|
94
|
-
className: cn2("min-w-0 bg-card", isWide && "h-full", sidebarPadding === "panel" && "p-4", isFill && "min-h-0 overflow-y-auto", !isWide && isFill && "max-h-[35%] shrink-0"),
|
|
119
|
+
className: cn2("min-w-0 bg-card", isWide && "h-full", sidebarPadding === "panel" && "p-4", isFill && "min-h-0 overflow-y-auto", !isWide && isFill && !isTakeover && "max-h-[35%] shrink-0", isTakeover && isFill && "flex-1"),
|
|
95
120
|
children: sidebar
|
|
96
121
|
});
|
|
97
122
|
const content = /* @__PURE__ */ jsx("section", {
|
|
98
123
|
"aria-label": contentLabel,
|
|
124
|
+
hidden: isTakeover,
|
|
99
125
|
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"),
|
|
100
126
|
children
|
|
101
127
|
});
|
|
@@ -108,11 +134,11 @@ function SplitView({
|
|
|
108
134
|
const sidebarPanel = /* @__PURE__ */ jsx(ResizablePanel2, {
|
|
109
135
|
id: "sidebar",
|
|
110
136
|
panelRef: sidebarRef,
|
|
111
|
-
collapsible:
|
|
137
|
+
collapsible: !sidebarOpen,
|
|
112
138
|
collapsedSize: 0,
|
|
113
139
|
defaultSize: defaultSidebarSize,
|
|
114
|
-
minSize:
|
|
115
|
-
maxSize:
|
|
140
|
+
minSize: minSidebarSize,
|
|
141
|
+
maxSize: maxSidebarSize,
|
|
116
142
|
children: sidebarSlot
|
|
117
143
|
});
|
|
118
144
|
const contentPanel = /* @__PURE__ */ jsx(ResizablePanel2, {
|
|
@@ -129,7 +155,8 @@ function SplitView({
|
|
|
129
155
|
/* @__PURE__ */ jsx(ResizableHandle2, {
|
|
130
156
|
thickness: "strong",
|
|
131
157
|
disabled: !sidebarOpen,
|
|
132
|
-
"aria-label": resizeLabel
|
|
158
|
+
"aria-label": resizeLabel,
|
|
159
|
+
className: cn2(!sidebarOpen && "invisible w-0")
|
|
133
160
|
}),
|
|
134
161
|
sidebarPosition === "start" ? contentPanel : sidebarPanel
|
|
135
162
|
]
|
|
@@ -139,7 +166,7 @@ function SplitView({
|
|
|
139
166
|
sidebarPosition === "start" ? sidebarSlot : contentSlot,
|
|
140
167
|
/* @__PURE__ */ jsx(Separator2, {
|
|
141
168
|
thickness: "strong",
|
|
142
|
-
hidden: !sidebarOpen
|
|
169
|
+
hidden: !sidebarOpen || isTakeover
|
|
143
170
|
}),
|
|
144
171
|
sidebarPosition === "start" ? contentSlot : sidebarSlot
|
|
145
172
|
]
|
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.80",
|
|
2055
2055
|
description: "Sharp, monospace React components with compact and comfortable densities.",
|
|
2056
2056
|
license: "MIT",
|
|
2057
2057
|
repository: {
|
|
@@ -3110,13 +3110,13 @@ var package_default = {
|
|
|
3110
3110
|
registry: "https://registry.npmjs.org/"
|
|
3111
3111
|
},
|
|
3112
3112
|
devDependencies: {
|
|
3113
|
-
"@assistant-ui/ai-sdk": "0.0.
|
|
3114
|
-
"@assistant-ui/generative-ui": "0.0.
|
|
3115
|
-
"@assistant-ui/react": "0.15.
|
|
3116
|
-
"@assistant-ui/react-markdown": "0.14.
|
|
3117
|
-
"@assistant-ui/react-mcp": "0.1.
|
|
3113
|
+
"@assistant-ui/ai-sdk": "0.0.19",
|
|
3114
|
+
"@assistant-ui/generative-ui": "0.0.12",
|
|
3115
|
+
"@assistant-ui/react": "0.15.37",
|
|
3116
|
+
"@assistant-ui/react-markdown": "0.14.26",
|
|
3117
|
+
"@assistant-ui/react-mcp": "0.1.29",
|
|
3118
3118
|
"@assistant-ui/react-syntax-highlighter": "0.14.7",
|
|
3119
|
-
"@assistant-ui/store": "0.3.
|
|
3119
|
+
"@assistant-ui/store": "0.3.24",
|
|
3120
3120
|
"@base-ui/react": "^1.9.0",
|
|
3121
3121
|
"@base-ui/utils": "0.5.0",
|
|
3122
3122
|
"@date-fns/tz": "1.5.0",
|
|
@@ -3211,13 +3211,13 @@ var package_default = {
|
|
|
3211
3211
|
zustand: "5.0.15"
|
|
3212
3212
|
},
|
|
3213
3213
|
peerDependencies: {
|
|
3214
|
-
"@assistant-ui/ai-sdk": "0.0.
|
|
3215
|
-
"@assistant-ui/generative-ui": "0.0.
|
|
3216
|
-
"@assistant-ui/react": "0.15.
|
|
3217
|
-
"@assistant-ui/react-markdown": "0.14.
|
|
3218
|
-
"@assistant-ui/react-mcp": "0.1.
|
|
3214
|
+
"@assistant-ui/ai-sdk": "0.0.19",
|
|
3215
|
+
"@assistant-ui/generative-ui": "0.0.12",
|
|
3216
|
+
"@assistant-ui/react": "0.15.37",
|
|
3217
|
+
"@assistant-ui/react-markdown": "0.14.26",
|
|
3218
|
+
"@assistant-ui/react-mcp": "0.1.29",
|
|
3219
3219
|
"@assistant-ui/react-syntax-highlighter": "0.14.7",
|
|
3220
|
-
"@assistant-ui/store": "0.3.
|
|
3220
|
+
"@assistant-ui/store": "0.3.24",
|
|
3221
3221
|
"@base-ui/react": "^1.9.0",
|
|
3222
3222
|
"@base-ui/utils": "0.5.0",
|
|
3223
3223
|
"@date-fns/tz": "^1.5.0",
|
|
@@ -160,3 +160,40 @@ Storybook CSF excerpts. Default args and render apply unless overridden. Local h
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
```
|
|
163
|
+
|
|
164
|
+
### Dock
|
|
165
|
+
|
|
166
|
+
```tsx
|
|
167
|
+
{
|
|
168
|
+
render: function Example(args) {
|
|
169
|
+
const key = useId();
|
|
170
|
+
const [open, setOpen] = useState(false);
|
|
171
|
+
const [expanded, setExpanded] = useState(false);
|
|
172
|
+
return (<div className="flex h-96 w-[1000px] flex-col gap-2">
|
|
173
|
+
<div className="flex gap-2">
|
|
174
|
+
<Button onClick={() => setOpen(!open)}>{open ? "Close dock" : "Open dock"}</Button>
|
|
175
|
+
<Button onClick={() => setExpanded(!expanded)}>{expanded ? "Restore width" : "Expand"}</Button>
|
|
176
|
+
</div>
|
|
177
|
+
<SplitView {...args} storageKey={key} sidebarLabel="Dock" resizeLabel="Resize dock" sidebarPosition="end" sidebarOpen={open} sidebarExpanded={expanded} defaultSidebarSize={400} minSidebarSize={320} maxSidebarSize="60%" layout="fill" sidebar={<h2>Review</h2>}>
|
|
178
|
+
<input aria-label="Draft answer" defaultValue=""/>
|
|
179
|
+
</SplitView>
|
|
180
|
+
</div>);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### NarrowTakeover
|
|
186
|
+
|
|
187
|
+
```tsx
|
|
188
|
+
{
|
|
189
|
+
render: function Example(args) {
|
|
190
|
+
const [open, setOpen] = useState(false);
|
|
191
|
+
return (<div className="flex h-96 w-[600px] flex-col gap-2">
|
|
192
|
+
<Button onClick={() => setOpen(!open)}>{open ? "Back to content" : "Open dock"}</Button>
|
|
193
|
+
<SplitView {...args} sidebarLabel="Dock" resizeLabel="Resize dock" sidebarPosition="end" sidebarOpen={open} wideQuery="(min-width: 100000px)" narrowLayout="takeover" layout="fill" sidebar={<h2>Review</h2>}>
|
|
194
|
+
<input aria-label="Draft answer" defaultValue=""/>
|
|
195
|
+
</SplitView>
|
|
196
|
+
</div>);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alexgorbatchev/shadcn",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.80",
|
|
4
4
|
"description": "Sharp, monospace React components with compact and comfortable densities.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -1059,13 +1059,13 @@
|
|
|
1059
1059
|
"registry": "https://registry.npmjs.org/"
|
|
1060
1060
|
},
|
|
1061
1061
|
"devDependencies": {
|
|
1062
|
-
"@assistant-ui/ai-sdk": "0.0.
|
|
1063
|
-
"@assistant-ui/generative-ui": "0.0.
|
|
1064
|
-
"@assistant-ui/react": "0.15.
|
|
1065
|
-
"@assistant-ui/react-markdown": "0.14.
|
|
1066
|
-
"@assistant-ui/react-mcp": "0.1.
|
|
1062
|
+
"@assistant-ui/ai-sdk": "0.0.19",
|
|
1063
|
+
"@assistant-ui/generative-ui": "0.0.12",
|
|
1064
|
+
"@assistant-ui/react": "0.15.37",
|
|
1065
|
+
"@assistant-ui/react-markdown": "0.14.26",
|
|
1066
|
+
"@assistant-ui/react-mcp": "0.1.29",
|
|
1067
1067
|
"@assistant-ui/react-syntax-highlighter": "0.14.7",
|
|
1068
|
-
"@assistant-ui/store": "0.3.
|
|
1068
|
+
"@assistant-ui/store": "0.3.24",
|
|
1069
1069
|
"@base-ui/react": "^1.9.0",
|
|
1070
1070
|
"@base-ui/utils": "0.5.0",
|
|
1071
1071
|
"@date-fns/tz": "1.5.0",
|
|
@@ -1160,13 +1160,13 @@
|
|
|
1160
1160
|
"zustand": "5.0.15"
|
|
1161
1161
|
},
|
|
1162
1162
|
"peerDependencies": {
|
|
1163
|
-
"@assistant-ui/ai-sdk": "0.0.
|
|
1164
|
-
"@assistant-ui/generative-ui": "0.0.
|
|
1165
|
-
"@assistant-ui/react": "0.15.
|
|
1166
|
-
"@assistant-ui/react-markdown": "0.14.
|
|
1167
|
-
"@assistant-ui/react-mcp": "0.1.
|
|
1163
|
+
"@assistant-ui/ai-sdk": "0.0.19",
|
|
1164
|
+
"@assistant-ui/generative-ui": "0.0.12",
|
|
1165
|
+
"@assistant-ui/react": "0.15.37",
|
|
1166
|
+
"@assistant-ui/react-markdown": "0.14.26",
|
|
1167
|
+
"@assistant-ui/react-mcp": "0.1.29",
|
|
1168
1168
|
"@assistant-ui/react-syntax-highlighter": "0.14.7",
|
|
1169
|
-
"@assistant-ui/store": "0.3.
|
|
1169
|
+
"@assistant-ui/store": "0.3.24",
|
|
1170
1170
|
"@base-ui/react": "^1.9.0",
|
|
1171
1171
|
"@base-ui/utils": "0.5.0",
|
|
1172
1172
|
"@date-fns/tz": "^1.5.0",
|