@forgeax/app-shell 0.6.1 → 0.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/README.md +17 -0
- package/dist/panel.css +41 -0
- package/dist/react.d.ts +26 -3
- package/dist/react.js +67 -12
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -67,6 +67,23 @@ const [width, setWidth] = useLocalSize('product.sidebar.width', 280, 180, 640);
|
|
|
67
67
|
</aside>
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
+
Generic panel sections keep product renderers and action policies outside App
|
|
71
|
+
Shell while providing stable shell/content metadata:
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
import '@forgeax/app-shell/panel.css';
|
|
75
|
+
import { PanelSurface } from '@forgeax/app-shell/react';
|
|
76
|
+
|
|
77
|
+
<PanelSurface
|
|
78
|
+
id="project-tree"
|
|
79
|
+
registered
|
|
80
|
+
header={<ProductPanelActions />}
|
|
81
|
+
content={{ padding: 'sm', scroll: 'auto', tone: 'tool' }}
|
|
82
|
+
>
|
|
83
|
+
<ProjectTree />
|
|
84
|
+
</PanelSurface>
|
|
85
|
+
```
|
|
86
|
+
|
|
70
87
|
## Ownership boundary
|
|
71
88
|
|
|
72
89
|
| Package | Owns |
|
package/dist/panel.css
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
.fx-panel {
|
|
2
|
+
height: 100%;
|
|
3
|
+
width: 100%;
|
|
4
|
+
min-width: 0;
|
|
5
|
+
min-height: 0;
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
background: var(--color-background-base, #191919);
|
|
9
|
+
color: var(--color-text-primary, #e8eaed);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.fx-panel-content {
|
|
13
|
+
flex: 1 1 auto;
|
|
14
|
+
min-width: 0;
|
|
15
|
+
min-height: 0;
|
|
16
|
+
overflow: auto;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.fx-panel-content[data-scroll="none"] {
|
|
20
|
+
overflow: hidden;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.fx-panel-content[data-padding="none"] {
|
|
24
|
+
padding: 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.fx-panel-content[data-padding="sm"] {
|
|
28
|
+
padding: 8px;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.fx-panel-content[data-padding="md"] {
|
|
32
|
+
padding: 12px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.fx-panel-content[data-tone="surface"] {
|
|
36
|
+
background: var(--color-background-elevated, #161619);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.fx-panel-content[data-tone="tool"] {
|
|
40
|
+
background: var(--color-background-base, #191919);
|
|
41
|
+
}
|
package/dist/react.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ReactElement, HTMLAttributes } from 'react';
|
|
2
|
+
import { ReactElement, HTMLAttributes, ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
/** Stable FNV-1a color bucket for a shell slot name. */
|
|
5
5
|
declare function hashSlotHue(name: string): number;
|
|
@@ -12,9 +12,32 @@ declare function useLocalSize(key: string, initial: number, min: number, max: nu
|
|
|
12
12
|
interface ResizeHandleProps {
|
|
13
13
|
orientation: 'col' | 'row';
|
|
14
14
|
onDrag: (delta: number) => void;
|
|
15
|
+
onDragStart?: () => void;
|
|
16
|
+
onDragEnd?: () => void;
|
|
17
|
+
className?: string;
|
|
18
|
+
ariaLabel?: string;
|
|
15
19
|
title?: string;
|
|
16
20
|
}
|
|
17
|
-
declare function ResizeHandle({ orientation, onDrag, title }: ResizeHandleProps): react.JSX.Element;
|
|
21
|
+
declare function ResizeHandle({ orientation, onDrag, onDragStart, onDragEnd, className, ariaLabel, title, }: ResizeHandleProps): react.JSX.Element;
|
|
22
|
+
|
|
23
|
+
type PanelContentPadding = 'none' | 'sm' | 'md';
|
|
24
|
+
type PanelContentScroll = 'none' | 'auto';
|
|
25
|
+
type PanelContentTone = 'default' | 'surface' | 'tool';
|
|
26
|
+
interface PanelContentPolicy {
|
|
27
|
+
readonly padding?: PanelContentPadding;
|
|
28
|
+
readonly scroll?: PanelContentScroll;
|
|
29
|
+
readonly tone?: PanelContentTone;
|
|
30
|
+
}
|
|
31
|
+
interface PanelSurfaceProps extends Omit<HTMLAttributes<HTMLElement>, 'children' | 'content' | 'id'> {
|
|
32
|
+
readonly id: string;
|
|
33
|
+
readonly registered?: boolean;
|
|
34
|
+
readonly singleTab?: 'default' | 'full' | 'hideTitle';
|
|
35
|
+
readonly header?: ReactNode;
|
|
36
|
+
readonly content?: PanelContentPolicy;
|
|
37
|
+
readonly children?: ReactNode;
|
|
38
|
+
}
|
|
39
|
+
/** Product-neutral panel section and content presentation. */
|
|
40
|
+
declare function PanelSurface({ id, registered, singleTab, header, content, children, className, ...props }: PanelSurfaceProps): ReactElement;
|
|
18
41
|
|
|
19
42
|
type ShellSlotElement = 'aside' | 'div' | 'main' | 'section';
|
|
20
43
|
interface ShellSlotProps extends HTMLAttributes<HTMLElement> {
|
|
@@ -24,4 +47,4 @@ interface ShellSlotProps extends HTMLAttributes<HTMLElement> {
|
|
|
24
47
|
/** Structural shell marker that preserves the caller's semantic element. */
|
|
25
48
|
declare function ShellSlot({ as, name, ...props }: ShellSlotProps): ReactElement;
|
|
26
49
|
|
|
27
|
-
export { ResizeHandle, type ResizeHandleProps, ShellSlot, type ShellSlotElement, type ShellSlotProps, SlotDebugOverlay, hashSlotHue, isSlotDebugEnabled, useLocalSize };
|
|
50
|
+
export { type PanelContentPadding, type PanelContentPolicy, type PanelContentScroll, type PanelContentTone, PanelSurface, type PanelSurfaceProps, ResizeHandle, type ResizeHandleProps, ShellSlot, type ShellSlotElement, type ShellSlotProps, SlotDebugOverlay, hashSlotHue, isSlotDebugEnabled, useLocalSize };
|
package/dist/react.js
CHANGED
|
@@ -192,49 +192,103 @@ function useLocalSize(key, initial, min, max) {
|
|
|
192
192
|
};
|
|
193
193
|
return [value, setValue];
|
|
194
194
|
}
|
|
195
|
-
function ResizeHandle({
|
|
195
|
+
function ResizeHandle({
|
|
196
|
+
orientation,
|
|
197
|
+
onDrag,
|
|
198
|
+
onDragStart,
|
|
199
|
+
onDragEnd,
|
|
200
|
+
className,
|
|
201
|
+
ariaLabel,
|
|
202
|
+
title
|
|
203
|
+
}) {
|
|
196
204
|
const startRef = useRef(null);
|
|
205
|
+
const onDragEndRef = useRef(onDragEnd);
|
|
206
|
+
onDragEndRef.current = onDragEnd;
|
|
197
207
|
const resetGlobalDragStyles = () => {
|
|
198
208
|
document.body.style.cursor = "";
|
|
199
209
|
document.body.style.userSelect = "";
|
|
200
210
|
};
|
|
201
|
-
|
|
202
|
-
if (startRef.current)
|
|
203
|
-
|
|
211
|
+
const finishDrag = () => {
|
|
212
|
+
if (!startRef.current) return;
|
|
213
|
+
startRef.current = null;
|
|
214
|
+
resetGlobalDragStyles();
|
|
215
|
+
onDragEndRef.current?.();
|
|
216
|
+
};
|
|
217
|
+
useEffect2(() => finishDrag, []);
|
|
204
218
|
const onPointerDown = (event) => {
|
|
219
|
+
if (startRef.current) return;
|
|
205
220
|
event.preventDefault();
|
|
206
221
|
event.currentTarget.setPointerCapture(event.pointerId);
|
|
207
|
-
startRef.current = { x: event.clientX, y: event.clientY };
|
|
222
|
+
startRef.current = { pointerId: event.pointerId, x: event.clientX, y: event.clientY };
|
|
208
223
|
document.body.style.cursor = orientation === "col" ? "col-resize" : "row-resize";
|
|
209
224
|
document.body.style.userSelect = "none";
|
|
225
|
+
onDragStart?.();
|
|
210
226
|
};
|
|
211
227
|
const onPointerMove = (event) => {
|
|
212
|
-
if (!startRef.current) return;
|
|
228
|
+
if (!startRef.current || startRef.current.pointerId !== event.pointerId) return;
|
|
213
229
|
const deltaX = event.clientX - startRef.current.x;
|
|
214
230
|
const deltaY = event.clientY - startRef.current.y;
|
|
215
|
-
startRef.current = { x: event.clientX, y: event.clientY };
|
|
231
|
+
startRef.current = { pointerId: event.pointerId, x: event.clientX, y: event.clientY };
|
|
216
232
|
onDrag(orientation === "col" ? deltaX : deltaY);
|
|
217
233
|
};
|
|
218
234
|
const finish = (event) => {
|
|
219
|
-
if (!startRef.current) return;
|
|
220
|
-
startRef.current = null;
|
|
235
|
+
if (!startRef.current || startRef.current.pointerId !== event.pointerId) return;
|
|
221
236
|
try {
|
|
222
237
|
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
223
238
|
} catch {
|
|
224
239
|
}
|
|
225
|
-
|
|
240
|
+
finishDrag();
|
|
226
241
|
};
|
|
227
242
|
return /* @__PURE__ */ jsx2(
|
|
228
243
|
"div",
|
|
229
244
|
{
|
|
230
|
-
className: `resize-handle resize-handle-${orientation}`,
|
|
245
|
+
className: `resize-handle resize-handle-${orientation}${className ? ` ${className}` : ""}`,
|
|
231
246
|
onPointerDown,
|
|
232
247
|
onPointerMove,
|
|
233
248
|
onPointerUp: finish,
|
|
234
249
|
onPointerCancel: finish,
|
|
235
250
|
title,
|
|
236
251
|
role: "separator",
|
|
237
|
-
"aria-orientation": orientation === "col" ? "vertical" : "horizontal"
|
|
252
|
+
"aria-orientation": orientation === "col" ? "vertical" : "horizontal",
|
|
253
|
+
"aria-label": ariaLabel
|
|
254
|
+
}
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// src/panel.tsx
|
|
259
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
260
|
+
function PanelSurface({
|
|
261
|
+
id,
|
|
262
|
+
registered = false,
|
|
263
|
+
singleTab,
|
|
264
|
+
header,
|
|
265
|
+
content,
|
|
266
|
+
children,
|
|
267
|
+
className,
|
|
268
|
+
...props
|
|
269
|
+
}) {
|
|
270
|
+
return /* @__PURE__ */ jsxs(
|
|
271
|
+
"section",
|
|
272
|
+
{
|
|
273
|
+
...props,
|
|
274
|
+
className: className ? `fx-panel ${className}` : "fx-panel",
|
|
275
|
+
"data-fx-panel-id": id,
|
|
276
|
+
"data-panel-registered": registered ? "true" : "false",
|
|
277
|
+
"data-dock-single-tab": singleTab,
|
|
278
|
+
"data-fx-slot": `DockPanel:${id}`,
|
|
279
|
+
children: [
|
|
280
|
+
header,
|
|
281
|
+
/* @__PURE__ */ jsx3(
|
|
282
|
+
"div",
|
|
283
|
+
{
|
|
284
|
+
className: "fx-panel-content",
|
|
285
|
+
"data-padding": content?.padding ?? "none",
|
|
286
|
+
"data-scroll": content?.scroll ?? "auto",
|
|
287
|
+
"data-tone": content?.tone ?? "default",
|
|
288
|
+
children
|
|
289
|
+
}
|
|
290
|
+
)
|
|
291
|
+
]
|
|
238
292
|
}
|
|
239
293
|
);
|
|
240
294
|
}
|
|
@@ -248,6 +302,7 @@ function ShellSlot({
|
|
|
248
302
|
return createElement(as, { ...props, "data-fx-slot": name });
|
|
249
303
|
}
|
|
250
304
|
export {
|
|
305
|
+
PanelSurface,
|
|
251
306
|
ResizeHandle,
|
|
252
307
|
ShellSlot,
|
|
253
308
|
SlotDebugOverlay,
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forgeax/app-shell",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Generic Dock, Panel, Window, and Slot composition primitives",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"sideEffects": ["./dist/resize.css"],
|
|
7
|
+
"sideEffects": ["./dist/resize.css", "./dist/panel.css"],
|
|
8
8
|
"files": ["dist"],
|
|
9
9
|
"main": "./dist/index.js",
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
@@ -21,12 +21,13 @@
|
|
|
21
21
|
"types": "./dist/react.d.ts",
|
|
22
22
|
"import": "./dist/react.js"
|
|
23
23
|
},
|
|
24
|
-
"./resize.css": "./dist/resize.css"
|
|
24
|
+
"./resize.css": "./dist/resize.css",
|
|
25
|
+
"./panel.css": "./dist/panel.css"
|
|
25
26
|
},
|
|
26
27
|
"scripts": {
|
|
27
28
|
"typecheck": "tsc --noEmit",
|
|
28
29
|
"test": "bun test test",
|
|
29
|
-
"build": "tsup src/index.ts src/dock.ts src/react.tsx --format esm --dts --outDir dist && bun run scripts/copy-resize-css.ts",
|
|
30
|
+
"build": "tsup src/index.ts src/dock.ts src/react.tsx --format esm --dts --outDir dist && bun run scripts/copy-resize-css.ts && bun run scripts/copy-panel-css.ts",
|
|
30
31
|
"check": "bun run typecheck && bun run test && bun run build",
|
|
31
32
|
"release:preflight": "bun run scripts/release-preflight.ts"
|
|
32
33
|
},
|