@bayonai/mui-design 1.8.0 → 1.9.0
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.9.0 — 2026-11-23
|
|
4
|
+
|
|
5
|
+
- Add host-owned width preferences to `WorkspaceSidePane`. Responsive fit and modal presentation preserve the saved preference, and pointer and keyboard resize report user changes.
|
|
6
|
+
|
|
3
7
|
## 1.8.0 — 2026-11-21 (candidate)
|
|
4
8
|
|
|
5
9
|
- Add `WorkspaceSidePane` to the drawers entry for a docked, resizable workspace pane that becomes a modal on narrow layouts.
|
package/README.md
CHANGED
|
@@ -95,6 +95,14 @@ docked when the workspace can retain 640px of usable content and otherwise
|
|
|
95
95
|
opens as a modal overlay. Resize by dragging the docked edge or by focusing
|
|
96
96
|
its separator and pressing Left, Right, Home, End, or Enter.
|
|
97
97
|
|
|
98
|
+
Pass `preferredWidth` and `onPreferredWidthChange` to store the docked width.
|
|
99
|
+
The component constrains finite preferences to 320–480 CSS pixels, and a
|
|
100
|
+
workspace that can fit the default width may temporarily render a smaller
|
|
101
|
+
pane without changing its preference. Modal presentation uses the default
|
|
102
|
+
geometry. The callback reports explicit pointer and keyboard resize changes.
|
|
103
|
+
Without a finite host preference, the component tracks its own width.
|
|
104
|
+
Hosts choose where to store the preference and feed the new value back.
|
|
105
|
+
|
|
98
106
|
Pass a heading ID and ref for naming the pane and directing focus. Render
|
|
99
107
|
rail buttons with `renderActions`, connecting `aria-controls` to `paneId` and
|
|
100
108
|
`aria-expanded` to `visible`. Call `openFrom(event)` from the opener and
|
|
@@ -17,9 +17,13 @@ export interface WorkspaceSidePaneProps {
|
|
|
17
17
|
actionsLabel: string;
|
|
18
18
|
resizeLabel?: string;
|
|
19
19
|
keepPaneMounted?: boolean;
|
|
20
|
+
/** Preferred docked width in CSS pixels. The available canvas can constrain the displayed width. */
|
|
21
|
+
preferredWidth?: number;
|
|
22
|
+
/** Reports an explicit resize through the pointer or keyboard control. */
|
|
23
|
+
onPreferredWidthChange?: (width: number) => void;
|
|
20
24
|
getOverlaySiblings?: (root: HTMLDivElement) => readonly HTMLElement[];
|
|
21
25
|
renderActions: (actions: WorkspaceSidePaneActions) => ReactNode;
|
|
22
26
|
renderPane: (visible: boolean) => ReactNode;
|
|
23
27
|
}
|
|
24
28
|
/** Keeps the workspace in one slot across docked, modal and closed presentation. */
|
|
25
|
-
export declare function WorkspaceSidePane({ children, enabled, className, style, paneId, headingId, headingRef, workspaceRef, actionsLabel, resizeLabel, keepPaneMounted, getOverlaySiblings, renderActions, renderPane, }: WorkspaceSidePaneProps): import("react").JSX.Element;
|
|
29
|
+
export declare function WorkspaceSidePane({ children, enabled, className, style, paneId, headingId, headingRef, workspaceRef, actionsLabel, resizeLabel, keepPaneMounted, preferredWidth, onPreferredWidthChange, getOverlaySiblings, renderActions, renderPane, }: WorkspaceSidePaneProps): import("react").JSX.Element;
|
|
@@ -14,7 +14,7 @@ const WorkspaceSidePaneRoot_js_1 = require("./WorkspaceSidePaneRoot.js");
|
|
|
14
14
|
const workspaceSidePaneGeometry_js_1 = require("./workspaceSidePaneGeometry.js");
|
|
15
15
|
const motion = { timeout: { enter: 220, exit: 170 }, easing: "cubic-bezier(0.25, 1, 0.5, 1)" };
|
|
16
16
|
/** Keeps the workspace in one slot across docked, modal and closed presentation. */
|
|
17
|
-
function WorkspaceSidePane({ children, enabled = true, className, style, paneId, headingId, headingRef, workspaceRef, actionsLabel, resizeLabel = "Resize side pane", keepPaneMounted = false, getOverlaySiblings, renderActions, renderPane, }) {
|
|
17
|
+
function WorkspaceSidePane({ children, enabled = true, className, style, paneId, headingId, headingRef, workspaceRef, actionsLabel, resizeLabel = "Resize side pane", keepPaneMounted = false, preferredWidth, onPreferredWidthChange, getOverlaySiblings, renderActions, renderPane, }) {
|
|
18
18
|
const generatedId = (0, react_1.useId)();
|
|
19
19
|
const panelId = paneId !== null && paneId !== void 0 ? paneId : generatedId;
|
|
20
20
|
const rootRef = (0, react_1.useRef)(null);
|
|
@@ -27,10 +27,23 @@ function WorkspaceSidePane({ children, enabled = true, className, style, paneId,
|
|
|
27
27
|
const [directResize, setDirectResize] = (0, react_1.useState)(false);
|
|
28
28
|
const reducedMotion = (0, useMediaQuery_1.default)("(prefers-reduced-motion: reduce)", { noSsr: true });
|
|
29
29
|
const duration = reducedMotion ? 0 : motion.timeout;
|
|
30
|
-
const [
|
|
30
|
+
const [internalWidth, setWidth] = (0, react_1.useState)(workspaceSidePaneGeometry_js_1.workspaceSidePaneMetrics.initialPane);
|
|
31
31
|
const [bounds, setBounds] = (0, react_1.useState)({ width: workspaceSidePaneGeometry_js_1.workspaceSidePaneMetrics.minCanvas + workspaceSidePaneGeometry_js_1.workspaceSidePaneMetrics.rail + workspaceSidePaneGeometry_js_1.workspaceSidePaneMetrics.initialPane, top: 0, workspaceInset: 0 });
|
|
32
32
|
const drag = (0, react_1.useRef)(null);
|
|
33
|
+
const dockedMaximum = Math.max(workspaceSidePaneGeometry_js_1.workspaceSidePaneMetrics.minPane, Math.min(workspaceSidePaneGeometry_js_1.workspaceSidePaneMetrics.maxPane, bounds.width - bounds.workspaceInset - workspaceSidePaneGeometry_js_1.workspaceSidePaneMetrics.rail - workspaceSidePaneGeometry_js_1.workspaceSidePaneMetrics.minCanvas));
|
|
34
|
+
const hasPreferredWidth = typeof preferredWidth === "number" && Number.isFinite(preferredWidth);
|
|
35
|
+
const requestedWidth = hasPreferredWidth
|
|
36
|
+
? Math.min(workspaceSidePaneGeometry_js_1.workspaceSidePaneMetrics.maxPane, Math.max(workspaceSidePaneGeometry_js_1.workspaceSidePaneMetrics.minPane, preferredWidth))
|
|
37
|
+
: internalWidth;
|
|
38
|
+
// A host preference can yield to the canvas without changing the preferred
|
|
39
|
+
// width or turning a workspace that fits the default into a modal.
|
|
40
|
+
const width = hasPreferredWidth && dockedMaximum >= workspaceSidePaneGeometry_js_1.workspaceSidePaneMetrics.initialPane
|
|
41
|
+
? Math.min(requestedWidth, dockedMaximum)
|
|
42
|
+
: requestedWidth;
|
|
33
43
|
const geometry = (0, workspaceSidePaneGeometry_js_1.workspaceSidePaneGeometry)(bounds.width, width, bounds.workspaceInset);
|
|
44
|
+
const presentedWidth = geometry.overlay && hasPreferredWidth
|
|
45
|
+
? (0, workspaceSidePaneGeometry_js_1.workspaceSidePaneGeometry)(bounds.width, workspaceSidePaneGeometry_js_1.workspaceSidePaneMetrics.initialPane, bounds.workspaceInset).paneWidth
|
|
46
|
+
: geometry.paneWidth;
|
|
34
47
|
const visible = enabled && open;
|
|
35
48
|
const overlay = visible && geometry.overlay;
|
|
36
49
|
const visibleRef = (0, react_1.useRef)(visible);
|
|
@@ -130,10 +143,13 @@ function WorkspaceSidePane({ children, enabled = true, className, style, paneId,
|
|
|
130
143
|
};
|
|
131
144
|
// Deliberate docked resizing preserves the useful canvas and its focusable
|
|
132
145
|
// control. Only an external viewport/container change may require an overlay.
|
|
133
|
-
const
|
|
134
|
-
|
|
146
|
+
const clampWidth = (next, reset = false) => {
|
|
147
|
+
const nextWidth = Math.max(workspaceSidePaneGeometry_js_1.workspaceSidePaneMetrics.minPane, Math.min(dockedMaximum, Math.round(next)));
|
|
148
|
+
if (nextWidth === width && (!reset || nextWidth === requestedWidth))
|
|
149
|
+
return;
|
|
135
150
|
setDirectResize(true);
|
|
136
|
-
setWidth(
|
|
151
|
+
setWidth(nextWidth);
|
|
152
|
+
onPreferredWidthChange === null || onPreferredWidthChange === void 0 ? void 0 : onPreferredWidthChange(nextWidth);
|
|
137
153
|
};
|
|
138
154
|
const keyboard = (event) => {
|
|
139
155
|
var _a, _b, _c, _d, _e;
|
|
@@ -174,7 +190,7 @@ function WorkspaceSidePane({ children, enabled = true, className, style, paneId,
|
|
|
174
190
|
(_a = focusTarget.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
175
191
|
});
|
|
176
192
|
};
|
|
177
|
-
return ((0, jsx_runtime_1.jsxs)(WorkspaceSidePaneRoot_js_1.WorkspaceSidePaneRoot, { ref: rootRef, className: `workspace-side-pane${className ? ` ${className}` : ""}${enabled ? " workspace-side-pane-enabled" : ""}${visible ? " workspace-side-pane-open" : ""}${overlayPresentation ? " workspace-side-pane-overlay" : ""}${directResize && visible ? " workspace-side-pane-direct-resize" : ""}${reducedMotion ? " workspace-side-pane-reduced-motion" : ""}`, style: { ...style, "--workspace-side-pane-width": `${
|
|
193
|
+
return ((0, jsx_runtime_1.jsxs)(WorkspaceSidePaneRoot_js_1.WorkspaceSidePaneRoot, { ref: rootRef, className: `workspace-side-pane${className ? ` ${className}` : ""}${enabled ? " workspace-side-pane-enabled" : ""}${visible ? " workspace-side-pane-open" : ""}${overlayPresentation ? " workspace-side-pane-overlay" : ""}${directResize && visible ? " workspace-side-pane-direct-resize" : ""}${reducedMotion ? " workspace-side-pane-reduced-motion" : ""}`, style: { ...style, "--workspace-side-pane-width": `${presentedWidth}px`, "--workspace-side-pane-top": `${bounds.top}px` }, children: [(0, jsx_runtime_1.jsx)("div", { ref: contentRef, className: "workspace-side-pane-workspace", children: children }), enabled && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Fade_1.default, { in: overlay, timeout: duration, easing: motion.easing, mountOnEnter: true, unmountOnExit: true, children: (0, jsx_runtime_1.jsx)("div", { className: "workspace-side-pane-backdrop", "data-active": overlay, style: { pointerEvents: overlay ? "auto" : "none" }, onClick: () => close(), "aria-hidden": "true" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "workspace-side-pane-group", ref: groupRef, role: overlay ? "dialog" : undefined, "aria-modal": overlay ? true : undefined, "aria-labelledby": overlay ? headingId : undefined, onKeyDown: keyboard, children: [(0, jsx_runtime_1.jsxs)("nav", { className: "workspace-side-pane-rail", "aria-label": actionsLabel, children: [renderActions({ visible, paneId: panelId, openFrom, close }), visible && !overlay && ((0, jsx_runtime_1.jsx)("div", { role: "separator", tabIndex: 0, className: "workspace-side-pane-resize", "aria-label": resizeLabel, "aria-orientation": "vertical", "aria-valuemin": workspaceSidePaneGeometry_js_1.workspaceSidePaneMetrics.minPane, "aria-valuemax": dockedMaximum, "aria-valuenow": width, "aria-valuetext": `${Math.round(geometry.paneWidth)} pixels`, title: "Drag to resize; Left/Right adjusts width; Enter resets", onKeyDown: (event) => {
|
|
178
194
|
const next = event.key === "ArrowLeft"
|
|
179
195
|
? width + 16
|
|
180
196
|
: event.key === "ArrowRight"
|
|
@@ -189,7 +205,7 @@ function WorkspaceSidePane({ children, enabled = true, className, style, paneId,
|
|
|
189
205
|
if (next !== null) {
|
|
190
206
|
event.preventDefault();
|
|
191
207
|
event.stopPropagation();
|
|
192
|
-
clampWidth(next);
|
|
208
|
+
clampWidth(next, event.key === "Enter");
|
|
193
209
|
}
|
|
194
210
|
}, onPointerDown: (event) => {
|
|
195
211
|
var _a, _b;
|
|
@@ -8,7 +8,7 @@ import { WorkspaceSidePaneRoot } from "./WorkspaceSidePaneRoot.js";
|
|
|
8
8
|
import { workspaceSidePaneGeometry, workspaceSidePaneMetrics } from "./workspaceSidePaneGeometry.js";
|
|
9
9
|
const motion = { timeout: { enter: 220, exit: 170 }, easing: "cubic-bezier(0.25, 1, 0.5, 1)" };
|
|
10
10
|
/** Keeps the workspace in one slot across docked, modal and closed presentation. */
|
|
11
|
-
export function WorkspaceSidePane({ children, enabled = true, className, style, paneId, headingId, headingRef, workspaceRef, actionsLabel, resizeLabel = "Resize side pane", keepPaneMounted = false, getOverlaySiblings, renderActions, renderPane, }) {
|
|
11
|
+
export function WorkspaceSidePane({ children, enabled = true, className, style, paneId, headingId, headingRef, workspaceRef, actionsLabel, resizeLabel = "Resize side pane", keepPaneMounted = false, preferredWidth, onPreferredWidthChange, getOverlaySiblings, renderActions, renderPane, }) {
|
|
12
12
|
const generatedId = useId();
|
|
13
13
|
const panelId = paneId !== null && paneId !== void 0 ? paneId : generatedId;
|
|
14
14
|
const rootRef = useRef(null);
|
|
@@ -21,10 +21,23 @@ export function WorkspaceSidePane({ children, enabled = true, className, style,
|
|
|
21
21
|
const [directResize, setDirectResize] = useState(false);
|
|
22
22
|
const reducedMotion = useMediaQuery("(prefers-reduced-motion: reduce)", { noSsr: true });
|
|
23
23
|
const duration = reducedMotion ? 0 : motion.timeout;
|
|
24
|
-
const [
|
|
24
|
+
const [internalWidth, setWidth] = useState(workspaceSidePaneMetrics.initialPane);
|
|
25
25
|
const [bounds, setBounds] = useState({ width: workspaceSidePaneMetrics.minCanvas + workspaceSidePaneMetrics.rail + workspaceSidePaneMetrics.initialPane, top: 0, workspaceInset: 0 });
|
|
26
26
|
const drag = useRef(null);
|
|
27
|
+
const dockedMaximum = Math.max(workspaceSidePaneMetrics.minPane, Math.min(workspaceSidePaneMetrics.maxPane, bounds.width - bounds.workspaceInset - workspaceSidePaneMetrics.rail - workspaceSidePaneMetrics.minCanvas));
|
|
28
|
+
const hasPreferredWidth = typeof preferredWidth === "number" && Number.isFinite(preferredWidth);
|
|
29
|
+
const requestedWidth = hasPreferredWidth
|
|
30
|
+
? Math.min(workspaceSidePaneMetrics.maxPane, Math.max(workspaceSidePaneMetrics.minPane, preferredWidth))
|
|
31
|
+
: internalWidth;
|
|
32
|
+
// A host preference can yield to the canvas without changing the preferred
|
|
33
|
+
// width or turning a workspace that fits the default into a modal.
|
|
34
|
+
const width = hasPreferredWidth && dockedMaximum >= workspaceSidePaneMetrics.initialPane
|
|
35
|
+
? Math.min(requestedWidth, dockedMaximum)
|
|
36
|
+
: requestedWidth;
|
|
27
37
|
const geometry = workspaceSidePaneGeometry(bounds.width, width, bounds.workspaceInset);
|
|
38
|
+
const presentedWidth = geometry.overlay && hasPreferredWidth
|
|
39
|
+
? workspaceSidePaneGeometry(bounds.width, workspaceSidePaneMetrics.initialPane, bounds.workspaceInset).paneWidth
|
|
40
|
+
: geometry.paneWidth;
|
|
28
41
|
const visible = enabled && open;
|
|
29
42
|
const overlay = visible && geometry.overlay;
|
|
30
43
|
const visibleRef = useRef(visible);
|
|
@@ -124,10 +137,13 @@ export function WorkspaceSidePane({ children, enabled = true, className, style,
|
|
|
124
137
|
};
|
|
125
138
|
// Deliberate docked resizing preserves the useful canvas and its focusable
|
|
126
139
|
// control. Only an external viewport/container change may require an overlay.
|
|
127
|
-
const
|
|
128
|
-
|
|
140
|
+
const clampWidth = (next, reset = false) => {
|
|
141
|
+
const nextWidth = Math.max(workspaceSidePaneMetrics.minPane, Math.min(dockedMaximum, Math.round(next)));
|
|
142
|
+
if (nextWidth === width && (!reset || nextWidth === requestedWidth))
|
|
143
|
+
return;
|
|
129
144
|
setDirectResize(true);
|
|
130
|
-
setWidth(
|
|
145
|
+
setWidth(nextWidth);
|
|
146
|
+
onPreferredWidthChange === null || onPreferredWidthChange === void 0 ? void 0 : onPreferredWidthChange(nextWidth);
|
|
131
147
|
};
|
|
132
148
|
const keyboard = (event) => {
|
|
133
149
|
var _a, _b, _c, _d, _e;
|
|
@@ -168,7 +184,7 @@ export function WorkspaceSidePane({ children, enabled = true, className, style,
|
|
|
168
184
|
(_a = focusTarget.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
169
185
|
});
|
|
170
186
|
};
|
|
171
|
-
return (_jsxs(WorkspaceSidePaneRoot, { ref: rootRef, className: `workspace-side-pane${className ? ` ${className}` : ""}${enabled ? " workspace-side-pane-enabled" : ""}${visible ? " workspace-side-pane-open" : ""}${overlayPresentation ? " workspace-side-pane-overlay" : ""}${directResize && visible ? " workspace-side-pane-direct-resize" : ""}${reducedMotion ? " workspace-side-pane-reduced-motion" : ""}`, style: { ...style, "--workspace-side-pane-width": `${
|
|
187
|
+
return (_jsxs(WorkspaceSidePaneRoot, { ref: rootRef, className: `workspace-side-pane${className ? ` ${className}` : ""}${enabled ? " workspace-side-pane-enabled" : ""}${visible ? " workspace-side-pane-open" : ""}${overlayPresentation ? " workspace-side-pane-overlay" : ""}${directResize && visible ? " workspace-side-pane-direct-resize" : ""}${reducedMotion ? " workspace-side-pane-reduced-motion" : ""}`, style: { ...style, "--workspace-side-pane-width": `${presentedWidth}px`, "--workspace-side-pane-top": `${bounds.top}px` }, children: [_jsx("div", { ref: contentRef, className: "workspace-side-pane-workspace", children: children }), enabled && (_jsxs(_Fragment, { children: [_jsx(Fade, { in: overlay, timeout: duration, easing: motion.easing, mountOnEnter: true, unmountOnExit: true, children: _jsx("div", { className: "workspace-side-pane-backdrop", "data-active": overlay, style: { pointerEvents: overlay ? "auto" : "none" }, onClick: () => close(), "aria-hidden": "true" }) }), _jsxs("div", { className: "workspace-side-pane-group", ref: groupRef, role: overlay ? "dialog" : undefined, "aria-modal": overlay ? true : undefined, "aria-labelledby": overlay ? headingId : undefined, onKeyDown: keyboard, children: [_jsxs("nav", { className: "workspace-side-pane-rail", "aria-label": actionsLabel, children: [renderActions({ visible, paneId: panelId, openFrom, close }), visible && !overlay && (_jsx("div", { role: "separator", tabIndex: 0, className: "workspace-side-pane-resize", "aria-label": resizeLabel, "aria-orientation": "vertical", "aria-valuemin": workspaceSidePaneMetrics.minPane, "aria-valuemax": dockedMaximum, "aria-valuenow": width, "aria-valuetext": `${Math.round(geometry.paneWidth)} pixels`, title: "Drag to resize; Left/Right adjusts width; Enter resets", onKeyDown: (event) => {
|
|
172
188
|
const next = event.key === "ArrowLeft"
|
|
173
189
|
? width + 16
|
|
174
190
|
: event.key === "ArrowRight"
|
|
@@ -183,7 +199,7 @@ export function WorkspaceSidePane({ children, enabled = true, className, style,
|
|
|
183
199
|
if (next !== null) {
|
|
184
200
|
event.preventDefault();
|
|
185
201
|
event.stopPropagation();
|
|
186
|
-
clampWidth(next);
|
|
202
|
+
clampWidth(next, event.key === "Enter");
|
|
187
203
|
}
|
|
188
204
|
}, onPointerDown: (event) => {
|
|
189
205
|
var _a, _b;
|
|
@@ -17,9 +17,13 @@ export interface WorkspaceSidePaneProps {
|
|
|
17
17
|
actionsLabel: string;
|
|
18
18
|
resizeLabel?: string;
|
|
19
19
|
keepPaneMounted?: boolean;
|
|
20
|
+
/** Preferred docked width in CSS pixels. The available canvas can constrain the displayed width. */
|
|
21
|
+
preferredWidth?: number;
|
|
22
|
+
/** Reports an explicit resize through the pointer or keyboard control. */
|
|
23
|
+
onPreferredWidthChange?: (width: number) => void;
|
|
20
24
|
getOverlaySiblings?: (root: HTMLDivElement) => readonly HTMLElement[];
|
|
21
25
|
renderActions: (actions: WorkspaceSidePaneActions) => ReactNode;
|
|
22
26
|
renderPane: (visible: boolean) => ReactNode;
|
|
23
27
|
}
|
|
24
28
|
/** Keeps the workspace in one slot across docked, modal and closed presentation. */
|
|
25
|
-
export declare function WorkspaceSidePane({ children, enabled, className, style, paneId, headingId, headingRef, workspaceRef, actionsLabel, resizeLabel, keepPaneMounted, getOverlaySiblings, renderActions, renderPane, }: WorkspaceSidePaneProps): import("react").JSX.Element;
|
|
29
|
+
export declare function WorkspaceSidePane({ children, enabled, className, style, paneId, headingId, headingRef, workspaceRef, actionsLabel, resizeLabel, keepPaneMounted, preferredWidth, onPreferredWidthChange, getOverlaySiblings, renderActions, renderPane, }: WorkspaceSidePaneProps): import("react").JSX.Element;
|