@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/dist/react.d.cts CHANGED
@@ -133,6 +133,13 @@ interface CanvasKind<TData extends CanvasJson = CanvasJson> {
133
133
  readonly HeaderLeading?: ComponentType<CanvasKindProps<TData>>;
134
134
  /** The kind's own button, rendered left of the pane's "…" menu. */
135
135
  readonly HeaderAction?: ComponentType<CanvasKindProps<TData>>;
136
+ /**
137
+ * A toolbar ROW between the pane header and the body, for the active item
138
+ * only (a browser's back / forward / reload / address / screenshot). Always
139
+ * DOM, never covered by a native view: a `body: "native"` frame is measured
140
+ * BELOW it.
141
+ */
142
+ readonly Toolbar?: ComponentType<CanvasKindProps<TData>>;
136
143
  /** Kind-specific entries for the pane's "…" menu. */
137
144
  readonly menuItems?: (props: CanvasKindProps<TData>) => readonly CanvasMenuItem[];
138
145
  }
package/dist/react.d.ts CHANGED
@@ -133,6 +133,13 @@ interface CanvasKind<TData extends CanvasJson = CanvasJson> {
133
133
  readonly HeaderLeading?: ComponentType<CanvasKindProps<TData>>;
134
134
  /** The kind's own button, rendered left of the pane's "…" menu. */
135
135
  readonly HeaderAction?: ComponentType<CanvasKindProps<TData>>;
136
+ /**
137
+ * A toolbar ROW between the pane header and the body, for the active item
138
+ * only (a browser's back / forward / reload / address / screenshot). Always
139
+ * DOM, never covered by a native view: a `body: "native"` frame is measured
140
+ * BELOW it.
141
+ */
142
+ readonly Toolbar?: ComponentType<CanvasKindProps<TData>>;
136
143
  /** Kind-specific entries for the pane's "…" menu. */
137
144
  readonly menuItems?: (props: CanvasKindProps<TData>) => readonly CanvasMenuItem[];
138
145
  }
package/dist/react.js CHANGED
@@ -2008,6 +2008,7 @@ function CanvasPaneView({ paneId }) {
2008
2008
  const kindProps = active && kind ? { item: active, data: active.data, paneId, isFocused: focused, canvas, windowId } : null;
2009
2009
  const Leading = kind?.HeaderLeading;
2010
2010
  const Action = kind?.HeaderAction;
2011
+ const Toolbar = kind?.Toolbar;
2011
2012
  const single = tabStrip === "auto" && pane.itemIds.length === 1 && active;
2012
2013
  const hideDrop = () => {
2013
2014
  drop.current?.();
@@ -2034,7 +2035,7 @@ function CanvasPaneView({ paneId }) {
2034
2035
  canvas.moveItem(itemId, paneId);
2035
2036
  };
2036
2037
  const closeLabel = role === "pop-out" && paneCount === 1 ? "Close window" : paneCount > 1 ? "Close pane" : "Close canvas";
2037
- return /* @__PURE__ */ jsx5(
2038
+ return /* @__PURE__ */ jsxs4(
2038
2039
  CanvasPanel,
2039
2040
  {
2040
2041
  ref: sectionRef,
@@ -2059,15 +2060,30 @@ function CanvasPaneView({ paneId }) {
2059
2060
  onDragOver,
2060
2061
  onDragLeave,
2061
2062
  onDrop,
2062
- children: pane.itemIds.length === 0 ? /* @__PURE__ */ jsx5(Launcher, { paneId }) : pane.itemIds.map((itemId) => {
2063
- const item = items[itemId];
2064
- if (!item) return null;
2065
- const isActive = itemId === pane.activeItemId;
2066
- return /* @__PURE__ */ jsx5(ItemBody, { item, paneId, windowId, isActive, isFocused: focused && isActive, hasNativePort: !!ports.onNativeBodyFrame }, itemId);
2067
- })
2063
+ children: [
2064
+ Toolbar && kindProps ? /* @__PURE__ */ jsx5("div", { className: "mxc-item-toolbar", "data-kind": active?.kind, children: /* @__PURE__ */ jsx5(ToolbarBoundary, { kindId: kind?.id ?? "", children: /* @__PURE__ */ jsx5(Toolbar, { ...kindProps }) }) }) : null,
2065
+ pane.itemIds.length === 0 ? /* @__PURE__ */ jsx5(Launcher, { paneId }) : pane.itemIds.map((itemId) => {
2066
+ const item = items[itemId];
2067
+ if (!item) return null;
2068
+ const isActive = itemId === pane.activeItemId;
2069
+ return /* @__PURE__ */ jsx5(ItemBody, { item, paneId, windowId, isActive, isFocused: focused && isActive, hasNativePort: !!ports.onNativeBodyFrame }, itemId);
2070
+ })
2071
+ ]
2068
2072
  }
2069
2073
  );
2070
2074
  }
2075
+ var ToolbarBoundary = class extends Component {
2076
+ state = { failed: false };
2077
+ static getDerivedStateFromError() {
2078
+ return { failed: true };
2079
+ }
2080
+ componentDidCatch(error) {
2081
+ console.error(`[@ai-matrx/canvas] "${this.props.kindId}" Toolbar threw`, error);
2082
+ }
2083
+ render() {
2084
+ return this.state.failed ? null : this.props.children;
2085
+ }
2086
+ };
2071
2087
  function SingleTitle({ item, kind }) {
2072
2088
  const title = itemTitle(item, kind);
2073
2089
  const drag = useTabDrag(item.id, title);