@ai-matrx/canvas 0.7.0 → 0.7.2

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
@@ -384,10 +384,10 @@ declare function itemTitle(item: CanvasItem, kind: AnyCanvasKind | undefined): s
384
384
  declare function CanvasPaneView({ paneId }: {
385
385
  paneId: CanvasPaneId;
386
386
  }): react.JSX.Element | null;
387
- /** A background tab's floor (px): icon + ~6 letters + "…". Mirrored to CSS as --mxc-tab-min. */
388
- declare const CANVAS_TAB_MIN_WIDTH = 78;
389
- /** The active tab's floor (px): icon + ~7 letters + "…" + its close. Mirrored to CSS as --mxc-tab-active-min. */
390
- declare const CANVAS_ACTIVE_TAB_MIN_WIDTH = 100;
387
+ /** A background tab's floor (px): icon + ~7 letters + "…" ("Messag…"). Mirrored to CSS as --mxc-tab-min. */
388
+ declare const CANVAS_TAB_MIN_WIDTH = 88;
389
+ /** The active tab's floor (px): icon + ~8 letters + "…" + its close. Mirrored to CSS as --mxc-tab-active-min. */
390
+ declare const CANVAS_ACTIVE_TAB_MIN_WIDTH = 112;
391
391
  /**
392
392
  * Which tabs the strip shows at this width: all of them when every tab fits
393
393
  * at its floor, else as many as fit — always the active one — and the rest
package/dist/react.d.ts CHANGED
@@ -384,10 +384,10 @@ declare function itemTitle(item: CanvasItem, kind: AnyCanvasKind | undefined): s
384
384
  declare function CanvasPaneView({ paneId }: {
385
385
  paneId: CanvasPaneId;
386
386
  }): react.JSX.Element | null;
387
- /** A background tab's floor (px): icon + ~6 letters + "…". Mirrored to CSS as --mxc-tab-min. */
388
- declare const CANVAS_TAB_MIN_WIDTH = 78;
389
- /** The active tab's floor (px): icon + ~7 letters + "…" + its close. Mirrored to CSS as --mxc-tab-active-min. */
390
- declare const CANVAS_ACTIVE_TAB_MIN_WIDTH = 100;
387
+ /** A background tab's floor (px): icon + ~7 letters + "…" ("Messag…"). Mirrored to CSS as --mxc-tab-min. */
388
+ declare const CANVAS_TAB_MIN_WIDTH = 88;
389
+ /** The active tab's floor (px): icon + ~8 letters + "…" + its close. Mirrored to CSS as --mxc-tab-active-min. */
390
+ declare const CANVAS_ACTIVE_TAB_MIN_WIDTH = 112;
391
391
  /**
392
392
  * Which tabs the strip shows at this width: all of them when every tab fits
393
393
  * at its floor, else as many as fit — always the active one — and the rest
package/dist/react.js CHANGED
@@ -3135,9 +3135,9 @@ function SingleTitle({ item, kind }) {
3135
3135
  /* @__PURE__ */ jsx7("button", { type: "button", className: "mxc-tab-close", "data-slot": "browser-tab-close", "aria-label": `Close ${title}`, onClick: () => canvas.close(item.id), children: /* @__PURE__ */ jsx7(CloseIcon, {}) })
3136
3136
  ] });
3137
3137
  }
3138
- var CANVAS_TAB_MIN_WIDTH = 78;
3139
- var CANVAS_ACTIVE_TAB_MIN_WIDTH = 100;
3140
- var TAB_LIST_BUTTON_ROOM = 30;
3138
+ var CANVAS_TAB_MIN_WIDTH = 88;
3139
+ var CANVAS_ACTIVE_TAB_MIN_WIDTH = 112;
3140
+ var TAB_LIST_BUTTON_ROOM = 36;
3141
3141
  var TAB_GAP = 2;
3142
3142
  function fitCanvasTabs(count, activeIndex, width) {
3143
3143
  if (count <= 0) return { start: 0, end: 0, overflow: false, compact: false };
@@ -3154,15 +3154,30 @@ function TabStrip({ tabs, activeItemId }) {
3154
3154
  const canvas = useCanvas();
3155
3155
  const strip = useRef7(null);
3156
3156
  const [width, setWidth] = useState5(0);
3157
+ const read = useRef7(() => {
3158
+ });
3157
3159
  useIsoLayoutEffect4(() => {
3158
3160
  const el = strip.current;
3159
3161
  if (!el) return void 0;
3160
- const read = () => setWidth(Math.floor(el.getBoundingClientRect().width));
3161
- read();
3162
- const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(read);
3162
+ let live = true;
3163
+ const measure = () => {
3164
+ if (live) setWidth(Math.floor(el.getBoundingClientRect().width));
3165
+ };
3166
+ read.current = measure;
3167
+ measure();
3168
+ const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(measure);
3163
3169
  observer?.observe(el);
3164
- return () => observer?.disconnect();
3170
+ void document.fonts?.ready?.then(measure);
3171
+ const frame2 = typeof requestAnimationFrame === "undefined" ? 0 : requestAnimationFrame(() => requestAnimationFrame(measure));
3172
+ return () => {
3173
+ live = false;
3174
+ observer?.disconnect();
3175
+ if (frame2 && typeof cancelAnimationFrame !== "undefined") cancelAnimationFrame(frame2);
3176
+ };
3165
3177
  }, []);
3178
+ useIsoLayoutEffect4(() => {
3179
+ read.current();
3180
+ }, [tabs.length]);
3166
3181
  const activeIndex = Math.max(0, tabs.findIndex((tab) => tab.itemId === activeItemId));
3167
3182
  const fit = fitCanvasTabs(tabs.length, activeIndex, width);
3168
3183
  const shown = tabs.slice(fit.start, fit.end);