@tangle-network/sandbox-ui 0.113.2 → 0.113.3
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.
|
@@ -6,13 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-EI44GEQ5.js";
|
|
7
7
|
|
|
8
8
|
// src/workspace/workspace-layout.tsx
|
|
9
|
-
import {
|
|
10
|
-
useCallback,
|
|
11
|
-
useEffect,
|
|
12
|
-
useMemo,
|
|
13
|
-
useRef,
|
|
14
|
-
useState
|
|
15
|
-
} from "react";
|
|
9
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
16
10
|
import {
|
|
17
11
|
PanelBottomClose,
|
|
18
12
|
PanelBottomOpen,
|
|
@@ -215,6 +209,7 @@ function WorkspaceLayout({
|
|
|
215
209
|
maxLeftWidth = 420,
|
|
216
210
|
minRightWidth = 320,
|
|
217
211
|
maxRightWidth = 720,
|
|
212
|
+
minCenterWidth = 400,
|
|
218
213
|
minBottomHeight = 100,
|
|
219
214
|
maxBottomHeight = 500,
|
|
220
215
|
persistenceKey,
|
|
@@ -332,8 +327,35 @@ function WorkspaceLayout({
|
|
|
332
327
|
window.removeEventListener("pointercancel", handlePointerUp);
|
|
333
328
|
};
|
|
334
329
|
}, [desktop, maxBottomHeight, maxLeftWidth, maxRightWidth, minBottomHeight, minLeftWidth, minRightWidth]);
|
|
335
|
-
const
|
|
336
|
-
const
|
|
330
|
+
const shellRef = useRef(null);
|
|
331
|
+
const [shellWidth, setShellWidth] = useState(null);
|
|
332
|
+
useEffect(() => {
|
|
333
|
+
const shell = shellRef.current;
|
|
334
|
+
if (!shell || typeof ResizeObserver === "undefined") return;
|
|
335
|
+
const observer = new ResizeObserver((entries) => {
|
|
336
|
+
const width = entries[0]?.contentRect.width;
|
|
337
|
+
if (typeof width === "number") setShellWidth(width);
|
|
338
|
+
});
|
|
339
|
+
observer.observe(shell);
|
|
340
|
+
return () => observer.disconnect();
|
|
341
|
+
}, []);
|
|
342
|
+
const { leftPx, rightPx } = useMemo(() => {
|
|
343
|
+
const leftShown = desktop && hasLeft && leftOpen;
|
|
344
|
+
const rightShown = desktop && hasRight && rightOpen;
|
|
345
|
+
let leftPx2 = leftWidth;
|
|
346
|
+
let rightPx2 = rightWidth;
|
|
347
|
+
if (shellWidth === null) return { leftPx: leftPx2, rightPx: rightPx2 };
|
|
348
|
+
const room = () => shellWidth - (leftShown ? leftPx2 : 0) - (rightShown ? rightPx2 : 0);
|
|
349
|
+
if (rightShown && room() < minCenterWidth) {
|
|
350
|
+
rightPx2 = Math.max(minRightWidth, rightPx2 - (minCenterWidth - room()));
|
|
351
|
+
}
|
|
352
|
+
if (leftShown && room() < minCenterWidth) {
|
|
353
|
+
leftPx2 = Math.max(minLeftWidth, leftPx2 - (minCenterWidth - room()));
|
|
354
|
+
}
|
|
355
|
+
return { leftPx: leftPx2, rightPx: rightPx2 };
|
|
356
|
+
}, [desktop, hasLeft, hasRight, leftOpen, leftWidth, minCenterWidth, minLeftWidth, minRightWidth, rightOpen, rightWidth, shellWidth]);
|
|
357
|
+
const leftStyle = useMemo(() => ({ width: `${leftPx}px` }), [leftPx]);
|
|
358
|
+
const rightStyle = useMemo(() => ({ width: `${rightPx}px` }), [rightPx]);
|
|
337
359
|
const startResize = (side, pointerStartX) => {
|
|
338
360
|
dragStateRef.current = {
|
|
339
361
|
side,
|
|
@@ -371,7 +393,7 @@ function WorkspaceLayout({
|
|
|
371
393
|
className
|
|
372
394
|
),
|
|
373
395
|
children: [
|
|
374
|
-
/* @__PURE__ */ jsxs("div", { className: "flex min-h-0 flex-1", children: [
|
|
396
|
+
/* @__PURE__ */ jsxs("div", { ref: shellRef, className: "flex min-h-0 flex-1", children: [
|
|
375
397
|
desktop && left && leftOpen && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
376
398
|
/* @__PURE__ */ jsxs(
|
|
377
399
|
"aside",
|
package/dist/index.js
CHANGED
package/dist/workspace.d.ts
CHANGED
|
@@ -46,6 +46,12 @@ interface WorkspaceLayoutProps {
|
|
|
46
46
|
minRightWidth?: number;
|
|
47
47
|
/** Maximum right panel width in px */
|
|
48
48
|
maxRightWidth?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Width in px the center column keeps on desktop. When the shell is too
|
|
51
|
+
* narrow for the stored pane widths, the right pane yields down to its
|
|
52
|
+
* minimum first, then the left; the stored widths return when room does.
|
|
53
|
+
*/
|
|
54
|
+
minCenterWidth?: number;
|
|
49
55
|
/** Minimum bottom panel height in px */
|
|
50
56
|
minBottomHeight?: number;
|
|
51
57
|
/** Maximum bottom panel height in px */
|
|
@@ -99,7 +105,7 @@ interface WorkspaceLayoutProps {
|
|
|
99
105
|
centerHeaderVisibility?: "always" | "auto";
|
|
100
106
|
className?: string;
|
|
101
107
|
}
|
|
102
|
-
declare function WorkspaceLayout({ left, leftHeader, center, centerHeader, centerFooter, right, rightHeader, bottom, bottomHeader, defaultLeftOpen, defaultRightOpen, defaultBottomOpen, defaultLeftWidth, defaultRightWidth, defaultBottomHeight, minLeftWidth, maxLeftWidth, minRightWidth, maxRightWidth, minBottomHeight, maxBottomHeight, persistenceKey, resizable, theme, density, leftLabel, rightLabel, bottomLabel, leftOpen: leftOpenProp, onLeftOpenChange, rightOpen: rightOpenProp, onRightOpenChange, keyboardShortcuts, leftCollapsedControl, leftContentClassName, rightContentClassName, centerHeaderVisibility, className, }: WorkspaceLayoutProps): React$1.JSX.Element;
|
|
108
|
+
declare function WorkspaceLayout({ left, leftHeader, center, centerHeader, centerFooter, right, rightHeader, bottom, bottomHeader, defaultLeftOpen, defaultRightOpen, defaultBottomOpen, defaultLeftWidth, defaultRightWidth, defaultBottomHeight, minLeftWidth, maxLeftWidth, minRightWidth, maxRightWidth, minCenterWidth, minBottomHeight, maxBottomHeight, persistenceKey, resizable, theme, density, leftLabel, rightLabel, bottomLabel, leftOpen: leftOpenProp, onLeftOpenChange, rightOpen: rightOpenProp, onRightOpenChange, keyboardShortcuts, leftCollapsedControl, leftContentClassName, rightContentClassName, centerHeaderVisibility, className, }: WorkspaceLayoutProps): React$1.JSX.Element;
|
|
103
109
|
|
|
104
110
|
type WorkspacePaneHeaderProps = HTMLAttributes<HTMLDivElement>;
|
|
105
111
|
/**
|
package/dist/workspace.js
CHANGED
package/package.json
CHANGED