@alexgorbatchev/shadcn 0.0.80 → 0.0.81
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.
|
@@ -92,13 +92,26 @@ function SplitView({
|
|
|
92
92
|
const isHydrated = useSyncExternalStore(subscribeToHydration, () => true, () => false);
|
|
93
93
|
const [slots] = useState(createSlots);
|
|
94
94
|
const portalSlots = isHydrated ? slots : null;
|
|
95
|
+
const storedSize = layout.defaultLayout?.sidebar;
|
|
96
|
+
const openSize = useRef(storedSize !== undefined && storedSize > 0 ? `${storedSize}%` : defaultSidebarSize);
|
|
97
|
+
const wasShownOpen = useRef(false);
|
|
98
|
+
const pendingOpenSize = useRef(null);
|
|
95
99
|
useEffect(() => {
|
|
96
|
-
|
|
100
|
+
const panel = sidebarRef.current;
|
|
101
|
+
if (!isWide || !panel)
|
|
102
|
+
return;
|
|
103
|
+
if (sidebarOpen) {
|
|
104
|
+
if (panel.isCollapsed()) {
|
|
105
|
+
pendingOpenSize.current = openSize.current;
|
|
106
|
+
panel.expand();
|
|
107
|
+
}
|
|
108
|
+
wasShownOpen.current = true;
|
|
97
109
|
return;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
110
|
+
}
|
|
111
|
+
if (wasShownOpen.current && !panel.isCollapsed())
|
|
112
|
+
openSize.current = `${panel.getSize().asPercentage}%`;
|
|
113
|
+
wasShownOpen.current = false;
|
|
114
|
+
panel.collapse();
|
|
102
115
|
}, [isWide, sidebarOpen, sidebarRef]);
|
|
103
116
|
const unexpandedSize = useRef(null);
|
|
104
117
|
useEffect(() => {
|
|
@@ -134,8 +147,18 @@ function SplitView({
|
|
|
134
147
|
const sidebarPanel = /* @__PURE__ */ jsx(ResizablePanel2, {
|
|
135
148
|
id: "sidebar",
|
|
136
149
|
panelRef: sidebarRef,
|
|
137
|
-
collapsible:
|
|
150
|
+
collapsible: true,
|
|
138
151
|
collapsedSize: 0,
|
|
152
|
+
onResize: (size) => {
|
|
153
|
+
if (!sidebarOpen)
|
|
154
|
+
return;
|
|
155
|
+
const pending = pendingOpenSize.current;
|
|
156
|
+
if (pending !== null && size.inPixels > 0) {
|
|
157
|
+
pendingOpenSize.current = null;
|
|
158
|
+
sidebarRef.current?.resize(pending);
|
|
159
|
+
} else if (pending === null && size.inPixels === 0)
|
|
160
|
+
sidebarRef.current?.resize(minSidebarSize);
|
|
161
|
+
},
|
|
139
162
|
defaultSize: defaultSidebarSize,
|
|
140
163
|
minSize: minSidebarSize,
|
|
141
164
|
maxSize: maxSidebarSize,
|
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.81",
|
|
2055
2055
|
description: "Sharp, monospace React components with compact and comfortable densities.",
|
|
2056
2056
|
license: "MIT",
|
|
2057
2057
|
repository: {
|
|
@@ -197,3 +197,26 @@ Storybook CSF excerpts. Default args and render apply unless overridden. Local h
|
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
```
|
|
200
|
+
|
|
201
|
+
### DockOpensAtDefaultWidth
|
|
202
|
+
|
|
203
|
+
```tsx
|
|
204
|
+
{
|
|
205
|
+
render: function Example(args) {
|
|
206
|
+
const key = useId();
|
|
207
|
+
const [open, setOpen] = useState(false);
|
|
208
|
+
const [isWideFrame, setWideFrame] = useState(false);
|
|
209
|
+
return (<div className="flex flex-col gap-2">
|
|
210
|
+
<div className="flex gap-2">
|
|
211
|
+
<Button onClick={() => setWideFrame(true)}>Widen workspace</Button>
|
|
212
|
+
<Button onClick={() => setOpen(!open)}>{open ? "Close dock" : "Open dock"}</Button>
|
|
213
|
+
</div>
|
|
214
|
+
<div className={isWideFrame ? "h-80 w-[1000px]" : "h-80 w-[300px]"}>
|
|
215
|
+
<SplitView {...args} storageKey={key} sidebarLabel="Dock" resizeLabel="Resize dock" sidebarPosition="end" sidebarOpen={open} defaultSidebarSize={400} minSidebarSize={320} maxSidebarSize="60%" layout="fill" sidebar={<h2>Review</h2>}>
|
|
216
|
+
<p>Workspace</p>
|
|
217
|
+
</SplitView>
|
|
218
|
+
</div>
|
|
219
|
+
</div>);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
```
|