@ai-matrx/canvas 0.3.0 → 0.4.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 +8 -0
- package/README.md +5 -0
- package/dist/react.cjs +23 -7
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +7 -0
- package/dist/react.d.ts +7 -0
- package/dist/react.js +23 -7
- package/dist/react.js.map +1 -1
- package/dist/styles.css +17 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
- **`CanvasKind.Toolbar`** — a toolbar ROW between the pane header and the body, rendered for the active item only (a browser's back / forward / reload / address / screenshot / open in browser / new tab), so the header keeps just the tab strip and pane controls. Always DOM and never covered by a native view: a `body: "native"` frame is measured below it. A toolbar that throws renders nothing instead of taking the pane down. Requested by the desktop session.
|
|
6
|
+
|
|
7
|
+
### Consumer action
|
|
8
|
+
|
|
9
|
+
- Kinds that crammed a toolbar into `HeaderLeading` (the desktop browser) move it to `Toolbar`.
|
|
10
|
+
|
|
3
11
|
## 0.3.0
|
|
4
12
|
|
|
5
13
|
- **Toggle or focus a kind** — what a toolbar icon or a quick-tool launcher does. `toggleKind(controller, { kind, key?, data?, title?, whenVisible? })`: absent → open and reveal; behind another tab or canvas put away → bring it forward; in front → close it (default) or put the canvas away (`whenVisible: "hide"`). `data` seeds only a new item. `selectCanvasKindVisibility(state, kind, key?)` returns `"absent" | "background" | "visible"` (a primitive — safe in useSyncExternalStore / useSelector), and the React hook `useCanvasKindToggle(input)` gives `{ visibility, isOpen, isVisible, toggle }` for an icon button's active state. Key defaults to `CANVAS_DEFAULT_KEY` ("default").
|
package/README.md
CHANGED
|
@@ -38,6 +38,11 @@ defineCanvasKind<{ sessionKey: string }>({
|
|
|
38
38
|
|
|
39
39
|
`body: "native"` makes the body a placeholder whose frame the host receives (below).
|
|
40
40
|
|
|
41
|
+
## A toolbar row under the header
|
|
42
|
+
|
|
43
|
+
A kind's `Toolbar` renders between the pane header and its body for the active
|
|
44
|
+
item (a browser bar). It is DOM, and a native body's frame is measured below it.
|
|
45
|
+
|
|
41
46
|
## Toolbar icons: toggle or focus a kind
|
|
42
47
|
|
|
43
48
|
```tsx
|
package/dist/react.cjs
CHANGED
|
@@ -2049,6 +2049,7 @@ function CanvasPaneView({ paneId }) {
|
|
|
2049
2049
|
const kindProps = active && kind ? { item: active, data: active.data, paneId, isFocused: focused, canvas, windowId } : null;
|
|
2050
2050
|
const Leading = kind?.HeaderLeading;
|
|
2051
2051
|
const Action = kind?.HeaderAction;
|
|
2052
|
+
const Toolbar = kind?.Toolbar;
|
|
2052
2053
|
const single = tabStrip === "auto" && pane.itemIds.length === 1 && active;
|
|
2053
2054
|
const hideDrop = () => {
|
|
2054
2055
|
drop.current?.();
|
|
@@ -2075,7 +2076,7 @@ function CanvasPaneView({ paneId }) {
|
|
|
2075
2076
|
canvas.moveItem(itemId, paneId);
|
|
2076
2077
|
};
|
|
2077
2078
|
const closeLabel = role === "pop-out" && paneCount === 1 ? "Close window" : paneCount > 1 ? "Close pane" : "Close canvas";
|
|
2078
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.
|
|
2079
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
2079
2080
|
CanvasPanel,
|
|
2080
2081
|
{
|
|
2081
2082
|
ref: sectionRef,
|
|
@@ -2100,15 +2101,30 @@ function CanvasPaneView({ paneId }) {
|
|
|
2100
2101
|
onDragOver,
|
|
2101
2102
|
onDragLeave,
|
|
2102
2103
|
onDrop,
|
|
2103
|
-
children:
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2104
|
+
children: [
|
|
2105
|
+
Toolbar && kindProps ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mxc-item-toolbar", "data-kind": active?.kind, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ToolbarBoundary, { kindId: kind?.id ?? "", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Toolbar, { ...kindProps }) }) }) : null,
|
|
2106
|
+
pane.itemIds.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Launcher, { paneId }) : pane.itemIds.map((itemId) => {
|
|
2107
|
+
const item = items[itemId];
|
|
2108
|
+
if (!item) return null;
|
|
2109
|
+
const isActive = itemId === pane.activeItemId;
|
|
2110
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ItemBody, { item, paneId, windowId, isActive, isFocused: focused && isActive, hasNativePort: !!ports.onNativeBodyFrame }, itemId);
|
|
2111
|
+
})
|
|
2112
|
+
]
|
|
2109
2113
|
}
|
|
2110
2114
|
);
|
|
2111
2115
|
}
|
|
2116
|
+
var ToolbarBoundary = class extends import_react4.Component {
|
|
2117
|
+
state = { failed: false };
|
|
2118
|
+
static getDerivedStateFromError() {
|
|
2119
|
+
return { failed: true };
|
|
2120
|
+
}
|
|
2121
|
+
componentDidCatch(error) {
|
|
2122
|
+
console.error(`[@ai-matrx/canvas] "${this.props.kindId}" Toolbar threw`, error);
|
|
2123
|
+
}
|
|
2124
|
+
render() {
|
|
2125
|
+
return this.state.failed ? null : this.props.children;
|
|
2126
|
+
}
|
|
2127
|
+
};
|
|
2112
2128
|
function SingleTitle({ item, kind }) {
|
|
2113
2129
|
const title = itemTitle(item, kind);
|
|
2114
2130
|
const drag = useTabDrag(item.id, title);
|