@bayonai/mui-design 1.7.0 → 1.8.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 +10 -0
- package/README.md +29 -0
- package/dist/cjs/drawers/WorkspaceSidePane.d.ts +25 -0
- package/dist/cjs/drawers/WorkspaceSidePane.js +206 -0
- package/dist/cjs/drawers/WorkspaceSidePaneRoot.d.ts +1 -0
- package/dist/cjs/drawers/WorkspaceSidePaneRoot.js +93 -0
- package/dist/cjs/drawers/index.d.ts +1 -0
- package/dist/cjs/drawers/index.js +3 -1
- package/dist/cjs/drawers/workspaceSidePaneGeometry.d.ts +11 -0
- package/dist/cjs/drawers/workspaceSidePaneGeometry.js +15 -0
- package/dist/esm/drawers/WorkspaceSidePane.js +200 -0
- package/dist/esm/drawers/WorkspaceSidePaneRoot.js +90 -0
- package/dist/esm/drawers/index.js +1 -0
- package/dist/esm/drawers/workspaceSidePaneGeometry.js +11 -0
- package/dist/types/drawers/WorkspaceSidePane.d.ts +25 -0
- package/dist/types/drawers/WorkspaceSidePaneRoot.d.ts +1 -0
- package/dist/types/drawers/index.d.ts +1 -0
- package/dist/types/drawers/workspaceSidePaneGeometry.d.ts +11 -0
- package/drawers.js +4 -0
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.8.0 — 2026-11-21 (candidate)
|
|
4
|
+
|
|
5
|
+
- Add `WorkspaceSidePane` to the drawers entry for a docked, resizable workspace pane that becomes a modal on narrow layouts.
|
|
6
|
+
|
|
3
7
|
## 1.7.0 — 2026-11-20
|
|
4
8
|
|
|
5
9
|
- Add a controlled image quality dialog with a local preview and quality tiles.
|
|
@@ -20,6 +24,12 @@ All notable changes to `@bayonai/mui-design` will be documented in this file.
|
|
|
20
24
|
- Give plan sections accessible names with an optional host override.
|
|
21
25
|
- Use the published file-uploads package for local upload component development.
|
|
22
26
|
|
|
27
|
+
## 1.5.0 - 2026-11-19
|
|
28
|
+
|
|
29
|
+
- Add the optional dark comparison appearance for pricing tables.
|
|
30
|
+
- Give plan sections accessible names with an optional host override.
|
|
31
|
+
- Use the published file-uploads package for local upload component development.
|
|
32
|
+
|
|
23
33
|
## 1.4.0 - 2026-11-12
|
|
24
34
|
|
|
25
35
|
- Add reusable metadata value-row/group spacing, neutral template badge, and explicit venue-search presentation.
|
package/README.md
CHANGED
|
@@ -86,6 +86,35 @@ The main website consumes this package through the local npm workspace while the
|
|
|
86
86
|
npm publish --workspace @bayonai/mui-design
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
+
## Workspace side pane
|
|
90
|
+
|
|
91
|
+
`WorkspaceSidePane` is available from `@bayonai/mui-design/drawers`.
|
|
92
|
+
Place it in the right-aligned workspace and provide the working content as
|
|
93
|
+
children. The rail sits between the workspace and the pane. The pane opens
|
|
94
|
+
docked when the workspace can retain 640px of usable content and otherwise
|
|
95
|
+
opens as a modal overlay. Resize by dragging the docked edge or by focusing
|
|
96
|
+
its separator and pressing Left, Right, Home, End, or Enter.
|
|
97
|
+
|
|
98
|
+
Pass a heading ID and ref for naming the pane and directing focus. Render
|
|
99
|
+
rail buttons with `renderActions`, connecting `aria-controls` to `paneId` and
|
|
100
|
+
`aria-expanded` to `visible`. Call `openFrom(event)` from the opener and
|
|
101
|
+
`close(event.currentTarget)` when the active button closes the pane. If a
|
|
102
|
+
button switches to a different heading, pass its ref to `openFrom`.
|
|
103
|
+
`renderPane(visible)` receives `false` as soon as dismissal starts. Use it to
|
|
104
|
+
stop protected reads or clear interactive content immediately.
|
|
105
|
+
`keepPaneMounted` can retain a pane draft across close and reopen.
|
|
106
|
+
|
|
107
|
+
Hosts provide rail actions, view selection, data access, and workspace
|
|
108
|
+
padding. `getOverlaySiblings` can identify additional background elements,
|
|
109
|
+
such as sibling navigation, to make inert during the modal. `workspaceRef`
|
|
110
|
+
optionally exposes the working slot. The layout respects reduced motion and
|
|
111
|
+
restores focus to the opener on close. The package includes a physical drawers
|
|
112
|
+
entry for bundlers that resolve subpaths without reading the export map. CSS custom properties
|
|
113
|
+
`--workspace-side-pane-background`, `--workspace-side-pane-rail-background`,
|
|
114
|
+
`--workspace-side-pane-border`, `--workspace-side-pane-text`,
|
|
115
|
+
`--workspace-side-pane-focus`, and `--workspace-side-pane-z-index` let the
|
|
116
|
+
host match its theme and stacking order.
|
|
117
|
+
|
|
89
118
|
## Preserved application primitives (1.1.0 candidate)
|
|
90
119
|
|
|
91
120
|
TL-M249 makes this package the owner of the existing MUI presentation previously
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type CSSProperties, type MouseEvent, type ReactNode, type RefObject } from "react";
|
|
2
|
+
export interface WorkspaceSidePaneActions {
|
|
3
|
+
visible: boolean;
|
|
4
|
+
paneId: string;
|
|
5
|
+
openFrom: (event: MouseEvent<HTMLButtonElement>, focusTarget?: RefObject<HTMLElement | null>) => void;
|
|
6
|
+
close: (opener?: HTMLButtonElement) => void;
|
|
7
|
+
}
|
|
8
|
+
export interface WorkspaceSidePaneProps {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
enabled?: boolean;
|
|
11
|
+
className?: string;
|
|
12
|
+
style?: CSSProperties;
|
|
13
|
+
paneId?: string;
|
|
14
|
+
headingId: string;
|
|
15
|
+
headingRef: RefObject<HTMLElement | null>;
|
|
16
|
+
workspaceRef?: RefObject<HTMLDivElement | null>;
|
|
17
|
+
actionsLabel: string;
|
|
18
|
+
resizeLabel?: string;
|
|
19
|
+
keepPaneMounted?: boolean;
|
|
20
|
+
getOverlaySiblings?: (root: HTMLDivElement) => readonly HTMLElement[];
|
|
21
|
+
renderActions: (actions: WorkspaceSidePaneActions) => ReactNode;
|
|
22
|
+
renderPane: (visible: boolean) => ReactNode;
|
|
23
|
+
}
|
|
24
|
+
/** 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;
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.WorkspaceSidePane = WorkspaceSidePane;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const Collapse_1 = __importDefault(require("@mui/material/Collapse"));
|
|
11
|
+
const Fade_1 = __importDefault(require("@mui/material/Fade"));
|
|
12
|
+
const useMediaQuery_1 = __importDefault(require("@mui/material/useMediaQuery"));
|
|
13
|
+
const WorkspaceSidePaneRoot_js_1 = require("./WorkspaceSidePaneRoot.js");
|
|
14
|
+
const workspaceSidePaneGeometry_js_1 = require("./workspaceSidePaneGeometry.js");
|
|
15
|
+
const motion = { timeout: { enter: 220, exit: 170 }, easing: "cubic-bezier(0.25, 1, 0.5, 1)" };
|
|
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, }) {
|
|
18
|
+
const generatedId = (0, react_1.useId)();
|
|
19
|
+
const panelId = paneId !== null && paneId !== void 0 ? paneId : generatedId;
|
|
20
|
+
const rootRef = (0, react_1.useRef)(null);
|
|
21
|
+
const internalWorkspaceRef = (0, react_1.useRef)(null);
|
|
22
|
+
const contentRef = workspaceRef !== null && workspaceRef !== void 0 ? workspaceRef : internalWorkspaceRef;
|
|
23
|
+
const groupRef = (0, react_1.useRef)(null);
|
|
24
|
+
const openerRef = (0, react_1.useRef)(null);
|
|
25
|
+
const [open, setOpen] = (0, react_1.useState)(false);
|
|
26
|
+
const [present, setPresent] = (0, react_1.useState)(false);
|
|
27
|
+
const [directResize, setDirectResize] = (0, react_1.useState)(false);
|
|
28
|
+
const reducedMotion = (0, useMediaQuery_1.default)("(prefers-reduced-motion: reduce)", { noSsr: true });
|
|
29
|
+
const duration = reducedMotion ? 0 : motion.timeout;
|
|
30
|
+
const [width, setWidth] = (0, react_1.useState)(workspaceSidePaneGeometry_js_1.workspaceSidePaneMetrics.initialPane);
|
|
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
|
+
const drag = (0, react_1.useRef)(null);
|
|
33
|
+
const geometry = (0, workspaceSidePaneGeometry_js_1.workspaceSidePaneGeometry)(bounds.width, width, bounds.workspaceInset);
|
|
34
|
+
const visible = enabled && open;
|
|
35
|
+
const overlay = visible && geometry.overlay;
|
|
36
|
+
const visibleRef = (0, react_1.useRef)(visible);
|
|
37
|
+
visibleRef.current = visible;
|
|
38
|
+
// Release modal focus and report closed to the host before visual exit.
|
|
39
|
+
const overlayPresentation = geometry.overlay && (visible || (present && !reducedMotion));
|
|
40
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
41
|
+
if (!enabled) {
|
|
42
|
+
setPresent(false);
|
|
43
|
+
setDirectResize(false);
|
|
44
|
+
drag.current = null;
|
|
45
|
+
}
|
|
46
|
+
else if (visible) {
|
|
47
|
+
setPresent(true);
|
|
48
|
+
}
|
|
49
|
+
}, [enabled, visible]);
|
|
50
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
51
|
+
const element = rootRef.current;
|
|
52
|
+
if (!element)
|
|
53
|
+
return;
|
|
54
|
+
const measure = () => {
|
|
55
|
+
const rect = element.getBoundingClientRect();
|
|
56
|
+
const workspaceStyle = contentRef.current ? getComputedStyle(contentRef.current) : null;
|
|
57
|
+
// Useful canvas excludes its retained page padding; chrome still uses
|
|
58
|
+
// the full root width, including in narrow overlays.
|
|
59
|
+
const workspaceInset = workspaceStyle
|
|
60
|
+
? (parseFloat(workspaceStyle.paddingLeft) || 0) + (parseFloat(workspaceStyle.paddingRight) || 0)
|
|
61
|
+
: 0;
|
|
62
|
+
const next = { width: rect.width || window.innerWidth, top: Math.max(0, rect.top), workspaceInset };
|
|
63
|
+
// Content ResizeObserver notifications also arrive during pane motion;
|
|
64
|
+
// unchanged shell geometry must not rerender pane content per frame.
|
|
65
|
+
setBounds((previous) => previous.width === next.width && previous.top === next.top && previous.workspaceInset === next.workspaceInset ? previous : next);
|
|
66
|
+
};
|
|
67
|
+
measure();
|
|
68
|
+
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(measure);
|
|
69
|
+
observer === null || observer === void 0 ? void 0 : observer.observe(element);
|
|
70
|
+
if (contentRef.current)
|
|
71
|
+
observer === null || observer === void 0 ? void 0 : observer.observe(contentRef.current);
|
|
72
|
+
window.addEventListener("resize", measure);
|
|
73
|
+
return () => {
|
|
74
|
+
observer === null || observer === void 0 ? void 0 : observer.disconnect();
|
|
75
|
+
window.removeEventListener("resize", measure);
|
|
76
|
+
};
|
|
77
|
+
}, [enabled, contentRef]);
|
|
78
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
79
|
+
var _a, _b, _c;
|
|
80
|
+
if (!overlay)
|
|
81
|
+
return;
|
|
82
|
+
const content = contentRef.current;
|
|
83
|
+
const root = rootRef.current;
|
|
84
|
+
const siblings = root ? (_a = getOverlaySiblings === null || getOverlaySiblings === void 0 ? void 0 : getOverlaySiblings(root)) !== null && _a !== void 0 ? _a : [] : [];
|
|
85
|
+
const covered = [...new Set([...(content ? [content] : []), ...siblings])];
|
|
86
|
+
const priorInert = covered.map((element) => ({ element, value: element.getAttribute("inert") }));
|
|
87
|
+
// Restore the pre-existing inert state when this overlay releases focus.
|
|
88
|
+
covered.forEach((element) => element.setAttribute("inert", ""));
|
|
89
|
+
const ownerDocument = (_c = (_b = rootRef.current) === null || _b === void 0 ? void 0 : _b.ownerDocument) !== null && _c !== void 0 ? _c : document;
|
|
90
|
+
const focusInside = () => { var _a; return (_a = headingRef.current) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
91
|
+
const containsTarget = (target) => { var _a; return Boolean(target && ((_a = groupRef.current) === null || _a === void 0 ? void 0 : _a.contains(target))); };
|
|
92
|
+
const containFocus = (event) => {
|
|
93
|
+
if (!containsTarget(event.target))
|
|
94
|
+
focusInside();
|
|
95
|
+
};
|
|
96
|
+
const containOutsideTab = (event) => {
|
|
97
|
+
if (event.key !== "Tab" || containsTarget(event.target))
|
|
98
|
+
return;
|
|
99
|
+
event.preventDefault();
|
|
100
|
+
event.stopPropagation();
|
|
101
|
+
focusInside();
|
|
102
|
+
};
|
|
103
|
+
// inert blocks normal background interaction; focusin additionally contains
|
|
104
|
+
// programmatic focus and browsers/environments with incomplete inert support.
|
|
105
|
+
ownerDocument.addEventListener("focusin", containFocus, true);
|
|
106
|
+
ownerDocument.addEventListener("keydown", containOutsideTab, true);
|
|
107
|
+
focusInside();
|
|
108
|
+
return () => {
|
|
109
|
+
ownerDocument.removeEventListener("focusin", containFocus, true);
|
|
110
|
+
ownerDocument.removeEventListener("keydown", containOutsideTab, true);
|
|
111
|
+
priorInert.forEach(({ element, value }) => {
|
|
112
|
+
if (value === null)
|
|
113
|
+
element.removeAttribute("inert");
|
|
114
|
+
else
|
|
115
|
+
element.setAttribute("inert", value);
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
}, [overlay, headingId, headingRef, contentRef, getOverlaySiblings]);
|
|
119
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
120
|
+
var _a;
|
|
121
|
+
if (!visible && present)
|
|
122
|
+
(_a = openerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
123
|
+
}, [visible, present]);
|
|
124
|
+
const close = (opener) => {
|
|
125
|
+
if (opener)
|
|
126
|
+
openerRef.current = opener;
|
|
127
|
+
setOpen(false);
|
|
128
|
+
setDirectResize(false);
|
|
129
|
+
drag.current = null;
|
|
130
|
+
};
|
|
131
|
+
// Deliberate docked resizing preserves the useful canvas and its focusable
|
|
132
|
+
// control. Only an external viewport/container change may require an overlay.
|
|
133
|
+
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));
|
|
134
|
+
const clampWidth = (next) => {
|
|
135
|
+
setDirectResize(true);
|
|
136
|
+
setWidth(Math.max(workspaceSidePaneGeometry_js_1.workspaceSidePaneMetrics.minPane, Math.min(dockedMaximum, next)));
|
|
137
|
+
};
|
|
138
|
+
const keyboard = (event) => {
|
|
139
|
+
var _a, _b, _c, _d, _e;
|
|
140
|
+
// Nested native dialogs own their own Escape handling.
|
|
141
|
+
if ((_b = (_a = event.target).closest) === null || _b === void 0 ? void 0 : _b.call(_a, "dialog[open]"))
|
|
142
|
+
return;
|
|
143
|
+
if (event.key === "Escape" && !event.defaultPrevented) {
|
|
144
|
+
event.preventDefault();
|
|
145
|
+
event.stopPropagation();
|
|
146
|
+
close();
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
if (!overlay || event.key !== "Tab")
|
|
150
|
+
return;
|
|
151
|
+
const controls = [...((_d = (_c = groupRef.current) === null || _c === void 0 ? void 0 : _c.querySelectorAll('button, a[href], input, textarea, select, summary, [tabindex]')) !== null && _d !== void 0 ? _d : [])]
|
|
152
|
+
.filter((element) => element.tabIndex >= 0 && !element.matches(":disabled")
|
|
153
|
+
&& !element.closest('[hidden], [inert], dialog:not([open])')
|
|
154
|
+
&& element.getClientRects().length > 0 && getComputedStyle(element).visibility !== "hidden");
|
|
155
|
+
const first = controls[0], last = controls[controls.length - 1];
|
|
156
|
+
const focused = (_e = groupRef.current) === null || _e === void 0 ? void 0 : _e.ownerDocument.activeElement;
|
|
157
|
+
if (event.shiftKey && (focused === first || focused === headingRef.current)) {
|
|
158
|
+
event.preventDefault();
|
|
159
|
+
last === null || last === void 0 ? void 0 : last.focus();
|
|
160
|
+
}
|
|
161
|
+
else if (!event.shiftKey && focused === last) {
|
|
162
|
+
event.preventDefault();
|
|
163
|
+
first === null || first === void 0 ? void 0 : first.focus();
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
const openFrom = (event, focusTarget = headingRef) => {
|
|
167
|
+
openerRef.current = event.currentTarget;
|
|
168
|
+
setPresent(true);
|
|
169
|
+
setOpen(true);
|
|
170
|
+
if (event.detail === 0)
|
|
171
|
+
requestAnimationFrame(() => {
|
|
172
|
+
var _a;
|
|
173
|
+
if (visibleRef.current)
|
|
174
|
+
(_a = focusTarget.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
175
|
+
});
|
|
176
|
+
};
|
|
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": `${geometry.paneWidth}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
|
+
const next = event.key === "ArrowLeft"
|
|
179
|
+
? width + 16
|
|
180
|
+
: event.key === "ArrowRight"
|
|
181
|
+
? width - 16
|
|
182
|
+
: event.key === "Home"
|
|
183
|
+
? workspaceSidePaneGeometry_js_1.workspaceSidePaneMetrics.minPane
|
|
184
|
+
: event.key === "End"
|
|
185
|
+
? workspaceSidePaneGeometry_js_1.workspaceSidePaneMetrics.maxPane
|
|
186
|
+
: event.key === "Enter"
|
|
187
|
+
? workspaceSidePaneGeometry_js_1.workspaceSidePaneMetrics.initialPane
|
|
188
|
+
: null;
|
|
189
|
+
if (next !== null) {
|
|
190
|
+
event.preventDefault();
|
|
191
|
+
event.stopPropagation();
|
|
192
|
+
clampWidth(next);
|
|
193
|
+
}
|
|
194
|
+
}, onPointerDown: (event) => {
|
|
195
|
+
var _a, _b;
|
|
196
|
+
drag.current = { x: event.clientX, width };
|
|
197
|
+
(_b = (_a = event.currentTarget).setPointerCapture) === null || _b === void 0 ? void 0 : _b.call(_a, event.pointerId);
|
|
198
|
+
}, onPointerMove: (event) => {
|
|
199
|
+
if (drag.current)
|
|
200
|
+
clampWidth(drag.current.width + drag.current.x - event.clientX);
|
|
201
|
+
}, onPointerUp: () => {
|
|
202
|
+
drag.current = null;
|
|
203
|
+
}, onPointerCancel: () => {
|
|
204
|
+
drag.current = null;
|
|
205
|
+
} }))] }), (0, jsx_runtime_1.jsx)(Collapse_1.default, { in: visible, orientation: "horizontal", className: "workspace-side-pane-presence", timeout: duration, easing: motion.easing, mountOnEnter: true, unmountOnExit: !keepPaneMounted, onExited: () => setPresent(false), children: (0, jsx_runtime_1.jsx)("aside", { id: panelId, className: "workspace-side-pane-panel", "aria-labelledby": headingId, "aria-hidden": !visible || undefined, inert: !visible, children: renderPane(visible) }) })] })] }))] }));
|
|
206
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const WorkspaceSidePaneRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.WorkspaceSidePaneRoot = void 0;
|
|
5
|
+
const styles_1 = require("@mui/material/styles");
|
|
6
|
+
const workspaceSidePaneGeometry_js_1 = require("./workspaceSidePaneGeometry.js");
|
|
7
|
+
const width = "var(--workspace-side-pane-width)";
|
|
8
|
+
const top = "var(--workspace-side-pane-top)";
|
|
9
|
+
const layer = "var(--workspace-side-pane-z-index, 1250)";
|
|
10
|
+
exports.WorkspaceSidePaneRoot = (0, styles_1.styled)("div")(({ theme }) => ({
|
|
11
|
+
minWidth: 0,
|
|
12
|
+
minHeight: "100%",
|
|
13
|
+
"&.workspace-side-pane-enabled": {
|
|
14
|
+
display: "flex",
|
|
15
|
+
alignItems: "flex-start",
|
|
16
|
+
gap: 0,
|
|
17
|
+
position: "relative",
|
|
18
|
+
},
|
|
19
|
+
"& .workspace-side-pane-workspace": { minWidth: 0, flex: "1 1 auto" },
|
|
20
|
+
"& .workspace-side-pane-group": {
|
|
21
|
+
display: "flex",
|
|
22
|
+
flex: "0 0 auto",
|
|
23
|
+
position: "sticky",
|
|
24
|
+
top: 0,
|
|
25
|
+
alignSelf: "flex-start",
|
|
26
|
+
color: "var(--workspace-side-pane-text, " + theme.palette.text.primary + ")",
|
|
27
|
+
},
|
|
28
|
+
"& .workspace-side-pane-rail": {
|
|
29
|
+
boxSizing: "border-box",
|
|
30
|
+
width: workspaceSidePaneGeometry_js_1.workspaceSidePaneMetrics.rail,
|
|
31
|
+
flex: `0 0 ${workspaceSidePaneGeometry_js_1.workspaceSidePaneMetrics.rail}px`,
|
|
32
|
+
display: "flex",
|
|
33
|
+
alignItems: "center",
|
|
34
|
+
flexDirection: "column",
|
|
35
|
+
gap: 8,
|
|
36
|
+
padding: "8px 0",
|
|
37
|
+
background: "var(--workspace-side-pane-rail-background, " + theme.palette.background.default + ")",
|
|
38
|
+
borderInline: "1px solid var(--workspace-side-pane-border, " + theme.palette.divider + ")",
|
|
39
|
+
minHeight: "100dvh",
|
|
40
|
+
},
|
|
41
|
+
"& .workspace-side-pane-group :is(button, [tabindex], summary):focus-visible": {
|
|
42
|
+
outline: "2px solid var(--workspace-side-pane-focus, " + theme.palette.primary.main + ")",
|
|
43
|
+
outlineOffset: -2,
|
|
44
|
+
},
|
|
45
|
+
"& .workspace-side-pane-resize": {
|
|
46
|
+
position: "absolute", left: -5, top: 0, bottom: 0, width: 10, zIndex: 2,
|
|
47
|
+
cursor: "ew-resize", touchAction: "none",
|
|
48
|
+
},
|
|
49
|
+
"& .workspace-side-pane-panel": {
|
|
50
|
+
boxSizing: "border-box",
|
|
51
|
+
width,
|
|
52
|
+
height: "100dvh",
|
|
53
|
+
maxHeight: `calc(100dvh - ${top})`,
|
|
54
|
+
background: "var(--workspace-side-pane-background, " + theme.palette.background.paper + ")",
|
|
55
|
+
display: "flex",
|
|
56
|
+
flexDirection: "column",
|
|
57
|
+
minWidth: 0,
|
|
58
|
+
minHeight: 0,
|
|
59
|
+
overflow: "hidden",
|
|
60
|
+
borderRight: "1px solid var(--workspace-side-pane-border, " + theme.palette.divider + ")",
|
|
61
|
+
},
|
|
62
|
+
"& .workspace-side-pane-backdrop": {
|
|
63
|
+
position: "fixed", inset: `${top} 0 0`, background: "rgba(0, 0, 0, 0.45)", zIndex: layer,
|
|
64
|
+
},
|
|
65
|
+
"&.workspace-side-pane-overlay .workspace-side-pane-group": {
|
|
66
|
+
position: "fixed", top, right: 0, bottom: 0, width: "max-content", maxWidth: "100%",
|
|
67
|
+
height: `calc(100dvh - ${top})`, minHeight: 0, zIndex: layer,
|
|
68
|
+
},
|
|
69
|
+
"&.workspace-side-pane-overlay :is(.workspace-side-pane-panel, .workspace-side-pane-rail)": {
|
|
70
|
+
height: "100%", maxHeight: "100%", minHeight: 0,
|
|
71
|
+
},
|
|
72
|
+
// Open/close animates the allocation. Explicit resizing responds immediately.
|
|
73
|
+
"& .workspace-side-pane-presence": { flex: "0 0 auto" },
|
|
74
|
+
"&.workspace-side-pane-direct-resize .workspace-side-pane-presence": {
|
|
75
|
+
transition: "none !important", width: `${width} !important`,
|
|
76
|
+
},
|
|
77
|
+
// A live motion preference change snaps the layout during an existing transition.
|
|
78
|
+
"&.workspace-side-pane-reduced-motion .workspace-side-pane-presence": {
|
|
79
|
+
transition: "none !important", width: "0 !important", overflow: "hidden !important",
|
|
80
|
+
},
|
|
81
|
+
"&.workspace-side-pane-reduced-motion.workspace-side-pane-open .workspace-side-pane-presence": {
|
|
82
|
+
width: `${width} !important`,
|
|
83
|
+
},
|
|
84
|
+
"&.workspace-side-pane-reduced-motion .workspace-side-pane-backdrop": {
|
|
85
|
+
transition: "none !important", opacity: "0 !important",
|
|
86
|
+
},
|
|
87
|
+
"&.workspace-side-pane-reduced-motion .workspace-side-pane-backdrop[data-active='true']": {
|
|
88
|
+
opacity: "1 !important",
|
|
89
|
+
},
|
|
90
|
+
"@media (max-width: 480px)": {
|
|
91
|
+
"& .workspace-side-pane-panel": { paddingBottom: "env(safe-area-inset-bottom)" },
|
|
92
|
+
},
|
|
93
|
+
}));
|
|
@@ -4,3 +4,4 @@ export { BottomDrawer } from "./BottomDrawer.js";
|
|
|
4
4
|
export { ResponsiveDrawer } from "./ResponsiveDrawer.js";
|
|
5
5
|
export { useVisualViewportBottomInset, getVisualViewportBottomInset, } from "./useVisualViewportBottomInset.js";
|
|
6
6
|
export type { DrawerAppearance } from "./drawerAppearance.js";
|
|
7
|
+
export { WorkspaceSidePane, type WorkspaceSidePaneActions, type WorkspaceSidePaneProps, } from "./WorkspaceSidePane.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
"use client";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.getVisualViewportBottomInset = exports.useVisualViewportBottomInset = exports.ResponsiveDrawer = exports.BottomDrawer = exports.MobileBottomDrawerHeader = exports.mobileBottomDrawerDismissDuration = exports.MobileBottomDrawer = void 0;
|
|
4
|
+
exports.WorkspaceSidePane = exports.getVisualViewportBottomInset = exports.useVisualViewportBottomInset = exports.ResponsiveDrawer = exports.BottomDrawer = exports.MobileBottomDrawerHeader = exports.mobileBottomDrawerDismissDuration = exports.MobileBottomDrawer = void 0;
|
|
5
5
|
// TL-M249: preserve the established MUI presentation under its owning package.
|
|
6
6
|
var MobileBottomDrawer_js_1 = require("./MobileBottomDrawer.js");
|
|
7
7
|
Object.defineProperty(exports, "MobileBottomDrawer", { enumerable: true, get: function () { return MobileBottomDrawer_js_1.MobileBottomDrawer; } });
|
|
@@ -15,3 +15,5 @@ Object.defineProperty(exports, "ResponsiveDrawer", { enumerable: true, get: func
|
|
|
15
15
|
var useVisualViewportBottomInset_js_1 = require("./useVisualViewportBottomInset.js");
|
|
16
16
|
Object.defineProperty(exports, "useVisualViewportBottomInset", { enumerable: true, get: function () { return useVisualViewportBottomInset_js_1.useVisualViewportBottomInset; } });
|
|
17
17
|
Object.defineProperty(exports, "getVisualViewportBottomInset", { enumerable: true, get: function () { return useVisualViewportBottomInset_js_1.getVisualViewportBottomInset; } });
|
|
18
|
+
var WorkspaceSidePane_js_1 = require("./WorkspaceSidePane.js");
|
|
19
|
+
Object.defineProperty(exports, "WorkspaceSidePane", { enumerable: true, get: function () { return WorkspaceSidePane_js_1.WorkspaceSidePane; } });
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const workspaceSidePaneMetrics: {
|
|
2
|
+
readonly rail: 56;
|
|
3
|
+
readonly initialPane: 384;
|
|
4
|
+
readonly minPane: 320;
|
|
5
|
+
readonly maxPane: 480;
|
|
6
|
+
readonly minCanvas: 640;
|
|
7
|
+
};
|
|
8
|
+
export declare function workspaceSidePaneGeometry(available: number, requested: number, workspaceInset?: number): {
|
|
9
|
+
overlay: boolean;
|
|
10
|
+
paneWidth: number;
|
|
11
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.workspaceSidePaneMetrics = void 0;
|
|
4
|
+
exports.workspaceSidePaneGeometry = workspaceSidePaneGeometry;
|
|
5
|
+
exports.workspaceSidePaneMetrics = { rail: 56, initialPane: 384, minPane: 320, maxPane: 480, minCanvas: 640 };
|
|
6
|
+
function workspaceSidePaneGeometry(available, requested, workspaceInset = 0) {
|
|
7
|
+
const preferred = Math.min(exports.workspaceSidePaneMetrics.maxPane, Math.max(exports.workspaceSidePaneMetrics.minPane, requested));
|
|
8
|
+
const overlay = available < exports.workspaceSidePaneMetrics.minCanvas + workspaceInset + exports.workspaceSidePaneMetrics.rail + preferred;
|
|
9
|
+
return {
|
|
10
|
+
overlay,
|
|
11
|
+
paneWidth: Math.max(0, available < exports.workspaceSidePaneMetrics.minCanvas + workspaceInset + exports.workspaceSidePaneMetrics.rail
|
|
12
|
+
? available - exports.workspaceSidePaneMetrics.rail
|
|
13
|
+
: Math.min(preferred, available - exports.workspaceSidePaneMetrics.rail)),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useId, useLayoutEffect, useRef, useState } from "react";
|
|
4
|
+
import Collapse from "@mui/material/Collapse";
|
|
5
|
+
import Fade from "@mui/material/Fade";
|
|
6
|
+
import useMediaQuery from "@mui/material/useMediaQuery";
|
|
7
|
+
import { WorkspaceSidePaneRoot } from "./WorkspaceSidePaneRoot.js";
|
|
8
|
+
import { workspaceSidePaneGeometry, workspaceSidePaneMetrics } from "./workspaceSidePaneGeometry.js";
|
|
9
|
+
const motion = { timeout: { enter: 220, exit: 170 }, easing: "cubic-bezier(0.25, 1, 0.5, 1)" };
|
|
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, }) {
|
|
12
|
+
const generatedId = useId();
|
|
13
|
+
const panelId = paneId !== null && paneId !== void 0 ? paneId : generatedId;
|
|
14
|
+
const rootRef = useRef(null);
|
|
15
|
+
const internalWorkspaceRef = useRef(null);
|
|
16
|
+
const contentRef = workspaceRef !== null && workspaceRef !== void 0 ? workspaceRef : internalWorkspaceRef;
|
|
17
|
+
const groupRef = useRef(null);
|
|
18
|
+
const openerRef = useRef(null);
|
|
19
|
+
const [open, setOpen] = useState(false);
|
|
20
|
+
const [present, setPresent] = useState(false);
|
|
21
|
+
const [directResize, setDirectResize] = useState(false);
|
|
22
|
+
const reducedMotion = useMediaQuery("(prefers-reduced-motion: reduce)", { noSsr: true });
|
|
23
|
+
const duration = reducedMotion ? 0 : motion.timeout;
|
|
24
|
+
const [width, setWidth] = useState(workspaceSidePaneMetrics.initialPane);
|
|
25
|
+
const [bounds, setBounds] = useState({ width: workspaceSidePaneMetrics.minCanvas + workspaceSidePaneMetrics.rail + workspaceSidePaneMetrics.initialPane, top: 0, workspaceInset: 0 });
|
|
26
|
+
const drag = useRef(null);
|
|
27
|
+
const geometry = workspaceSidePaneGeometry(bounds.width, width, bounds.workspaceInset);
|
|
28
|
+
const visible = enabled && open;
|
|
29
|
+
const overlay = visible && geometry.overlay;
|
|
30
|
+
const visibleRef = useRef(visible);
|
|
31
|
+
visibleRef.current = visible;
|
|
32
|
+
// Release modal focus and report closed to the host before visual exit.
|
|
33
|
+
const overlayPresentation = geometry.overlay && (visible || (present && !reducedMotion));
|
|
34
|
+
useLayoutEffect(() => {
|
|
35
|
+
if (!enabled) {
|
|
36
|
+
setPresent(false);
|
|
37
|
+
setDirectResize(false);
|
|
38
|
+
drag.current = null;
|
|
39
|
+
}
|
|
40
|
+
else if (visible) {
|
|
41
|
+
setPresent(true);
|
|
42
|
+
}
|
|
43
|
+
}, [enabled, visible]);
|
|
44
|
+
useLayoutEffect(() => {
|
|
45
|
+
const element = rootRef.current;
|
|
46
|
+
if (!element)
|
|
47
|
+
return;
|
|
48
|
+
const measure = () => {
|
|
49
|
+
const rect = element.getBoundingClientRect();
|
|
50
|
+
const workspaceStyle = contentRef.current ? getComputedStyle(contentRef.current) : null;
|
|
51
|
+
// Useful canvas excludes its retained page padding; chrome still uses
|
|
52
|
+
// the full root width, including in narrow overlays.
|
|
53
|
+
const workspaceInset = workspaceStyle
|
|
54
|
+
? (parseFloat(workspaceStyle.paddingLeft) || 0) + (parseFloat(workspaceStyle.paddingRight) || 0)
|
|
55
|
+
: 0;
|
|
56
|
+
const next = { width: rect.width || window.innerWidth, top: Math.max(0, rect.top), workspaceInset };
|
|
57
|
+
// Content ResizeObserver notifications also arrive during pane motion;
|
|
58
|
+
// unchanged shell geometry must not rerender pane content per frame.
|
|
59
|
+
setBounds((previous) => previous.width === next.width && previous.top === next.top && previous.workspaceInset === next.workspaceInset ? previous : next);
|
|
60
|
+
};
|
|
61
|
+
measure();
|
|
62
|
+
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(measure);
|
|
63
|
+
observer === null || observer === void 0 ? void 0 : observer.observe(element);
|
|
64
|
+
if (contentRef.current)
|
|
65
|
+
observer === null || observer === void 0 ? void 0 : observer.observe(contentRef.current);
|
|
66
|
+
window.addEventListener("resize", measure);
|
|
67
|
+
return () => {
|
|
68
|
+
observer === null || observer === void 0 ? void 0 : observer.disconnect();
|
|
69
|
+
window.removeEventListener("resize", measure);
|
|
70
|
+
};
|
|
71
|
+
}, [enabled, contentRef]);
|
|
72
|
+
useLayoutEffect(() => {
|
|
73
|
+
var _a, _b, _c;
|
|
74
|
+
if (!overlay)
|
|
75
|
+
return;
|
|
76
|
+
const content = contentRef.current;
|
|
77
|
+
const root = rootRef.current;
|
|
78
|
+
const siblings = root ? (_a = getOverlaySiblings === null || getOverlaySiblings === void 0 ? void 0 : getOverlaySiblings(root)) !== null && _a !== void 0 ? _a : [] : [];
|
|
79
|
+
const covered = [...new Set([...(content ? [content] : []), ...siblings])];
|
|
80
|
+
const priorInert = covered.map((element) => ({ element, value: element.getAttribute("inert") }));
|
|
81
|
+
// Restore the pre-existing inert state when this overlay releases focus.
|
|
82
|
+
covered.forEach((element) => element.setAttribute("inert", ""));
|
|
83
|
+
const ownerDocument = (_c = (_b = rootRef.current) === null || _b === void 0 ? void 0 : _b.ownerDocument) !== null && _c !== void 0 ? _c : document;
|
|
84
|
+
const focusInside = () => { var _a; return (_a = headingRef.current) === null || _a === void 0 ? void 0 : _a.focus(); };
|
|
85
|
+
const containsTarget = (target) => { var _a; return Boolean(target && ((_a = groupRef.current) === null || _a === void 0 ? void 0 : _a.contains(target))); };
|
|
86
|
+
const containFocus = (event) => {
|
|
87
|
+
if (!containsTarget(event.target))
|
|
88
|
+
focusInside();
|
|
89
|
+
};
|
|
90
|
+
const containOutsideTab = (event) => {
|
|
91
|
+
if (event.key !== "Tab" || containsTarget(event.target))
|
|
92
|
+
return;
|
|
93
|
+
event.preventDefault();
|
|
94
|
+
event.stopPropagation();
|
|
95
|
+
focusInside();
|
|
96
|
+
};
|
|
97
|
+
// inert blocks normal background interaction; focusin additionally contains
|
|
98
|
+
// programmatic focus and browsers/environments with incomplete inert support.
|
|
99
|
+
ownerDocument.addEventListener("focusin", containFocus, true);
|
|
100
|
+
ownerDocument.addEventListener("keydown", containOutsideTab, true);
|
|
101
|
+
focusInside();
|
|
102
|
+
return () => {
|
|
103
|
+
ownerDocument.removeEventListener("focusin", containFocus, true);
|
|
104
|
+
ownerDocument.removeEventListener("keydown", containOutsideTab, true);
|
|
105
|
+
priorInert.forEach(({ element, value }) => {
|
|
106
|
+
if (value === null)
|
|
107
|
+
element.removeAttribute("inert");
|
|
108
|
+
else
|
|
109
|
+
element.setAttribute("inert", value);
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
}, [overlay, headingId, headingRef, contentRef, getOverlaySiblings]);
|
|
113
|
+
useLayoutEffect(() => {
|
|
114
|
+
var _a;
|
|
115
|
+
if (!visible && present)
|
|
116
|
+
(_a = openerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
117
|
+
}, [visible, present]);
|
|
118
|
+
const close = (opener) => {
|
|
119
|
+
if (opener)
|
|
120
|
+
openerRef.current = opener;
|
|
121
|
+
setOpen(false);
|
|
122
|
+
setDirectResize(false);
|
|
123
|
+
drag.current = null;
|
|
124
|
+
};
|
|
125
|
+
// Deliberate docked resizing preserves the useful canvas and its focusable
|
|
126
|
+
// control. Only an external viewport/container change may require an overlay.
|
|
127
|
+
const dockedMaximum = Math.max(workspaceSidePaneMetrics.minPane, Math.min(workspaceSidePaneMetrics.maxPane, bounds.width - bounds.workspaceInset - workspaceSidePaneMetrics.rail - workspaceSidePaneMetrics.minCanvas));
|
|
128
|
+
const clampWidth = (next) => {
|
|
129
|
+
setDirectResize(true);
|
|
130
|
+
setWidth(Math.max(workspaceSidePaneMetrics.minPane, Math.min(dockedMaximum, next)));
|
|
131
|
+
};
|
|
132
|
+
const keyboard = (event) => {
|
|
133
|
+
var _a, _b, _c, _d, _e;
|
|
134
|
+
// Nested native dialogs own their own Escape handling.
|
|
135
|
+
if ((_b = (_a = event.target).closest) === null || _b === void 0 ? void 0 : _b.call(_a, "dialog[open]"))
|
|
136
|
+
return;
|
|
137
|
+
if (event.key === "Escape" && !event.defaultPrevented) {
|
|
138
|
+
event.preventDefault();
|
|
139
|
+
event.stopPropagation();
|
|
140
|
+
close();
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (!overlay || event.key !== "Tab")
|
|
144
|
+
return;
|
|
145
|
+
const controls = [...((_d = (_c = groupRef.current) === null || _c === void 0 ? void 0 : _c.querySelectorAll('button, a[href], input, textarea, select, summary, [tabindex]')) !== null && _d !== void 0 ? _d : [])]
|
|
146
|
+
.filter((element) => element.tabIndex >= 0 && !element.matches(":disabled")
|
|
147
|
+
&& !element.closest('[hidden], [inert], dialog:not([open])')
|
|
148
|
+
&& element.getClientRects().length > 0 && getComputedStyle(element).visibility !== "hidden");
|
|
149
|
+
const first = controls[0], last = controls[controls.length - 1];
|
|
150
|
+
const focused = (_e = groupRef.current) === null || _e === void 0 ? void 0 : _e.ownerDocument.activeElement;
|
|
151
|
+
if (event.shiftKey && (focused === first || focused === headingRef.current)) {
|
|
152
|
+
event.preventDefault();
|
|
153
|
+
last === null || last === void 0 ? void 0 : last.focus();
|
|
154
|
+
}
|
|
155
|
+
else if (!event.shiftKey && focused === last) {
|
|
156
|
+
event.preventDefault();
|
|
157
|
+
first === null || first === void 0 ? void 0 : first.focus();
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
const openFrom = (event, focusTarget = headingRef) => {
|
|
161
|
+
openerRef.current = event.currentTarget;
|
|
162
|
+
setPresent(true);
|
|
163
|
+
setOpen(true);
|
|
164
|
+
if (event.detail === 0)
|
|
165
|
+
requestAnimationFrame(() => {
|
|
166
|
+
var _a;
|
|
167
|
+
if (visibleRef.current)
|
|
168
|
+
(_a = focusTarget.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
169
|
+
});
|
|
170
|
+
};
|
|
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": `${geometry.paneWidth}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
|
+
const next = event.key === "ArrowLeft"
|
|
173
|
+
? width + 16
|
|
174
|
+
: event.key === "ArrowRight"
|
|
175
|
+
? width - 16
|
|
176
|
+
: event.key === "Home"
|
|
177
|
+
? workspaceSidePaneMetrics.minPane
|
|
178
|
+
: event.key === "End"
|
|
179
|
+
? workspaceSidePaneMetrics.maxPane
|
|
180
|
+
: event.key === "Enter"
|
|
181
|
+
? workspaceSidePaneMetrics.initialPane
|
|
182
|
+
: null;
|
|
183
|
+
if (next !== null) {
|
|
184
|
+
event.preventDefault();
|
|
185
|
+
event.stopPropagation();
|
|
186
|
+
clampWidth(next);
|
|
187
|
+
}
|
|
188
|
+
}, onPointerDown: (event) => {
|
|
189
|
+
var _a, _b;
|
|
190
|
+
drag.current = { x: event.clientX, width };
|
|
191
|
+
(_b = (_a = event.currentTarget).setPointerCapture) === null || _b === void 0 ? void 0 : _b.call(_a, event.pointerId);
|
|
192
|
+
}, onPointerMove: (event) => {
|
|
193
|
+
if (drag.current)
|
|
194
|
+
clampWidth(drag.current.width + drag.current.x - event.clientX);
|
|
195
|
+
}, onPointerUp: () => {
|
|
196
|
+
drag.current = null;
|
|
197
|
+
}, onPointerCancel: () => {
|
|
198
|
+
drag.current = null;
|
|
199
|
+
} }))] }), _jsx(Collapse, { in: visible, orientation: "horizontal", className: "workspace-side-pane-presence", timeout: duration, easing: motion.easing, mountOnEnter: true, unmountOnExit: !keepPaneMounted, onExited: () => setPresent(false), children: _jsx("aside", { id: panelId, className: "workspace-side-pane-panel", "aria-labelledby": headingId, "aria-hidden": !visible || undefined, inert: !visible, children: renderPane(visible) }) })] })] }))] }));
|
|
200
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { styled } from "@mui/material/styles";
|
|
3
|
+
import { workspaceSidePaneMetrics } from "./workspaceSidePaneGeometry.js";
|
|
4
|
+
const width = "var(--workspace-side-pane-width)";
|
|
5
|
+
const top = "var(--workspace-side-pane-top)";
|
|
6
|
+
const layer = "var(--workspace-side-pane-z-index, 1250)";
|
|
7
|
+
export const WorkspaceSidePaneRoot = styled("div")(({ theme }) => ({
|
|
8
|
+
minWidth: 0,
|
|
9
|
+
minHeight: "100%",
|
|
10
|
+
"&.workspace-side-pane-enabled": {
|
|
11
|
+
display: "flex",
|
|
12
|
+
alignItems: "flex-start",
|
|
13
|
+
gap: 0,
|
|
14
|
+
position: "relative",
|
|
15
|
+
},
|
|
16
|
+
"& .workspace-side-pane-workspace": { minWidth: 0, flex: "1 1 auto" },
|
|
17
|
+
"& .workspace-side-pane-group": {
|
|
18
|
+
display: "flex",
|
|
19
|
+
flex: "0 0 auto",
|
|
20
|
+
position: "sticky",
|
|
21
|
+
top: 0,
|
|
22
|
+
alignSelf: "flex-start",
|
|
23
|
+
color: "var(--workspace-side-pane-text, " + theme.palette.text.primary + ")",
|
|
24
|
+
},
|
|
25
|
+
"& .workspace-side-pane-rail": {
|
|
26
|
+
boxSizing: "border-box",
|
|
27
|
+
width: workspaceSidePaneMetrics.rail,
|
|
28
|
+
flex: `0 0 ${workspaceSidePaneMetrics.rail}px`,
|
|
29
|
+
display: "flex",
|
|
30
|
+
alignItems: "center",
|
|
31
|
+
flexDirection: "column",
|
|
32
|
+
gap: 8,
|
|
33
|
+
padding: "8px 0",
|
|
34
|
+
background: "var(--workspace-side-pane-rail-background, " + theme.palette.background.default + ")",
|
|
35
|
+
borderInline: "1px solid var(--workspace-side-pane-border, " + theme.palette.divider + ")",
|
|
36
|
+
minHeight: "100dvh",
|
|
37
|
+
},
|
|
38
|
+
"& .workspace-side-pane-group :is(button, [tabindex], summary):focus-visible": {
|
|
39
|
+
outline: "2px solid var(--workspace-side-pane-focus, " + theme.palette.primary.main + ")",
|
|
40
|
+
outlineOffset: -2,
|
|
41
|
+
},
|
|
42
|
+
"& .workspace-side-pane-resize": {
|
|
43
|
+
position: "absolute", left: -5, top: 0, bottom: 0, width: 10, zIndex: 2,
|
|
44
|
+
cursor: "ew-resize", touchAction: "none",
|
|
45
|
+
},
|
|
46
|
+
"& .workspace-side-pane-panel": {
|
|
47
|
+
boxSizing: "border-box",
|
|
48
|
+
width,
|
|
49
|
+
height: "100dvh",
|
|
50
|
+
maxHeight: `calc(100dvh - ${top})`,
|
|
51
|
+
background: "var(--workspace-side-pane-background, " + theme.palette.background.paper + ")",
|
|
52
|
+
display: "flex",
|
|
53
|
+
flexDirection: "column",
|
|
54
|
+
minWidth: 0,
|
|
55
|
+
minHeight: 0,
|
|
56
|
+
overflow: "hidden",
|
|
57
|
+
borderRight: "1px solid var(--workspace-side-pane-border, " + theme.palette.divider + ")",
|
|
58
|
+
},
|
|
59
|
+
"& .workspace-side-pane-backdrop": {
|
|
60
|
+
position: "fixed", inset: `${top} 0 0`, background: "rgba(0, 0, 0, 0.45)", zIndex: layer,
|
|
61
|
+
},
|
|
62
|
+
"&.workspace-side-pane-overlay .workspace-side-pane-group": {
|
|
63
|
+
position: "fixed", top, right: 0, bottom: 0, width: "max-content", maxWidth: "100%",
|
|
64
|
+
height: `calc(100dvh - ${top})`, minHeight: 0, zIndex: layer,
|
|
65
|
+
},
|
|
66
|
+
"&.workspace-side-pane-overlay :is(.workspace-side-pane-panel, .workspace-side-pane-rail)": {
|
|
67
|
+
height: "100%", maxHeight: "100%", minHeight: 0,
|
|
68
|
+
},
|
|
69
|
+
// Open/close animates the allocation. Explicit resizing responds immediately.
|
|
70
|
+
"& .workspace-side-pane-presence": { flex: "0 0 auto" },
|
|
71
|
+
"&.workspace-side-pane-direct-resize .workspace-side-pane-presence": {
|
|
72
|
+
transition: "none !important", width: `${width} !important`,
|
|
73
|
+
},
|
|
74
|
+
// A live motion preference change snaps the layout during an existing transition.
|
|
75
|
+
"&.workspace-side-pane-reduced-motion .workspace-side-pane-presence": {
|
|
76
|
+
transition: "none !important", width: "0 !important", overflow: "hidden !important",
|
|
77
|
+
},
|
|
78
|
+
"&.workspace-side-pane-reduced-motion.workspace-side-pane-open .workspace-side-pane-presence": {
|
|
79
|
+
width: `${width} !important`,
|
|
80
|
+
},
|
|
81
|
+
"&.workspace-side-pane-reduced-motion .workspace-side-pane-backdrop": {
|
|
82
|
+
transition: "none !important", opacity: "0 !important",
|
|
83
|
+
},
|
|
84
|
+
"&.workspace-side-pane-reduced-motion .workspace-side-pane-backdrop[data-active='true']": {
|
|
85
|
+
opacity: "1 !important",
|
|
86
|
+
},
|
|
87
|
+
"@media (max-width: 480px)": {
|
|
88
|
+
"& .workspace-side-pane-panel": { paddingBottom: "env(safe-area-inset-bottom)" },
|
|
89
|
+
},
|
|
90
|
+
}));
|
|
@@ -5,3 +5,4 @@ export { MobileBottomDrawerHeader } from "./MobileBottomDrawerHeader.js";
|
|
|
5
5
|
export { BottomDrawer } from "./BottomDrawer.js";
|
|
6
6
|
export { ResponsiveDrawer } from "./ResponsiveDrawer.js";
|
|
7
7
|
export { useVisualViewportBottomInset, getVisualViewportBottomInset, } from "./useVisualViewportBottomInset.js";
|
|
8
|
+
export { WorkspaceSidePane, } from "./WorkspaceSidePane.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const workspaceSidePaneMetrics = { rail: 56, initialPane: 384, minPane: 320, maxPane: 480, minCanvas: 640 };
|
|
2
|
+
export function workspaceSidePaneGeometry(available, requested, workspaceInset = 0) {
|
|
3
|
+
const preferred = Math.min(workspaceSidePaneMetrics.maxPane, Math.max(workspaceSidePaneMetrics.minPane, requested));
|
|
4
|
+
const overlay = available < workspaceSidePaneMetrics.minCanvas + workspaceInset + workspaceSidePaneMetrics.rail + preferred;
|
|
5
|
+
return {
|
|
6
|
+
overlay,
|
|
7
|
+
paneWidth: Math.max(0, available < workspaceSidePaneMetrics.minCanvas + workspaceInset + workspaceSidePaneMetrics.rail
|
|
8
|
+
? available - workspaceSidePaneMetrics.rail
|
|
9
|
+
: Math.min(preferred, available - workspaceSidePaneMetrics.rail)),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type CSSProperties, type MouseEvent, type ReactNode, type RefObject } from "react";
|
|
2
|
+
export interface WorkspaceSidePaneActions {
|
|
3
|
+
visible: boolean;
|
|
4
|
+
paneId: string;
|
|
5
|
+
openFrom: (event: MouseEvent<HTMLButtonElement>, focusTarget?: RefObject<HTMLElement | null>) => void;
|
|
6
|
+
close: (opener?: HTMLButtonElement) => void;
|
|
7
|
+
}
|
|
8
|
+
export interface WorkspaceSidePaneProps {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
enabled?: boolean;
|
|
11
|
+
className?: string;
|
|
12
|
+
style?: CSSProperties;
|
|
13
|
+
paneId?: string;
|
|
14
|
+
headingId: string;
|
|
15
|
+
headingRef: RefObject<HTMLElement | null>;
|
|
16
|
+
workspaceRef?: RefObject<HTMLDivElement | null>;
|
|
17
|
+
actionsLabel: string;
|
|
18
|
+
resizeLabel?: string;
|
|
19
|
+
keepPaneMounted?: boolean;
|
|
20
|
+
getOverlaySiblings?: (root: HTMLDivElement) => readonly HTMLElement[];
|
|
21
|
+
renderActions: (actions: WorkspaceSidePaneActions) => ReactNode;
|
|
22
|
+
renderPane: (visible: boolean) => ReactNode;
|
|
23
|
+
}
|
|
24
|
+
/** 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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const WorkspaceSidePaneRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -4,3 +4,4 @@ export { BottomDrawer } from "./BottomDrawer.js";
|
|
|
4
4
|
export { ResponsiveDrawer } from "./ResponsiveDrawer.js";
|
|
5
5
|
export { useVisualViewportBottomInset, getVisualViewportBottomInset, } from "./useVisualViewportBottomInset.js";
|
|
6
6
|
export type { DrawerAppearance } from "./drawerAppearance.js";
|
|
7
|
+
export { WorkspaceSidePane, type WorkspaceSidePaneActions, type WorkspaceSidePaneProps, } from "./WorkspaceSidePane.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const workspaceSidePaneMetrics: {
|
|
2
|
+
readonly rail: 56;
|
|
3
|
+
readonly initialPane: 384;
|
|
4
|
+
readonly minPane: 320;
|
|
5
|
+
readonly maxPane: 480;
|
|
6
|
+
readonly minCanvas: 640;
|
|
7
|
+
};
|
|
8
|
+
export declare function workspaceSidePaneGeometry(available: number, requested: number, workspaceInset?: number): {
|
|
9
|
+
overlay: boolean;
|
|
10
|
+
paneWidth: number;
|
|
11
|
+
};
|
package/drawers.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bayonai/mui-design",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "Shared Bayon AI Material UI theme, style recipes, and reusable design components.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -154,6 +154,7 @@
|
|
|
154
154
|
},
|
|
155
155
|
"files": [
|
|
156
156
|
"dist",
|
|
157
|
+
"drawers.js",
|
|
157
158
|
"README.md",
|
|
158
159
|
"CHANGELOG.md",
|
|
159
160
|
"docs",
|