@ai-matrx/canvas 0.8.1 → 0.8.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.js CHANGED
@@ -3278,24 +3278,49 @@ function TabStrip({
3278
3278
  "data-overflow": overflow ? "" : void 0,
3279
3279
  style: { ["--mxc-tab-min"]: `${CANVAS_TAB_MIN_WIDTH}px` },
3280
3280
  children: [
3281
- /* @__PURE__ */ jsx7("div", { ref: list, className: "mxc-tabs", role: "tablist", "aria-label": "Canvas tabs", "aria-multiselectable": joined ? true : void 0, children: entries.map(
3282
- (entry) => entry.type === "tab" ? tabView(entry.tab) : /* @__PURE__ */ jsx7(
3283
- "div",
3284
- {
3285
- className: "mxc-tab-group",
3286
- "data-split": "",
3287
- role: "presentation",
3288
- style: { ["--mxc-group-n"]: entry.tabs.length },
3289
- children: entry.tabs.map(tabView)
3290
- },
3291
- `split:${entry.tabs.map((tab) => tab.itemId).join("|")}`
3292
- )
3293
- ) }),
3281
+ /* @__PURE__ */ jsx7(
3282
+ "div",
3283
+ {
3284
+ ref: list,
3285
+ className: "mxc-tabs",
3286
+ role: "tablist",
3287
+ "aria-label": "Canvas tabs",
3288
+ "aria-multiselectable": joined ? true : void 0,
3289
+ onKeyDown: moveTabFocus,
3290
+ children: entries.map(
3291
+ (entry) => entry.type === "tab" ? tabView(entry.tab) : /* @__PURE__ */ jsx7(
3292
+ "div",
3293
+ {
3294
+ className: "mxc-tab-group",
3295
+ "data-split": "",
3296
+ role: "presentation",
3297
+ style: { ["--mxc-group-n"]: entry.tabs.length },
3298
+ children: entry.tabs.map(tabView)
3299
+ },
3300
+ `split:${entry.tabs.map((tab) => tab.itemId).join("|")}`
3301
+ )
3302
+ )
3303
+ }
3304
+ ),
3294
3305
  overflow ? /* @__PURE__ */ jsx7(TabListMenu, { tabs, activeItemId }) : null
3295
3306
  ]
3296
3307
  }
3297
3308
  );
3298
3309
  }
3310
+ function moveTabFocus(event) {
3311
+ const keys = ["ArrowLeft", "ArrowRight", "Home", "End"];
3312
+ if (!keys.includes(event.key) || event.altKey || event.ctrlKey || event.metaKey) return;
3313
+ const tabs = [...event.currentTarget.querySelectorAll('[role="tab"]')];
3314
+ const at = tabs.findIndex((tab) => tab === event.target || tab.contains(event.target));
3315
+ if (at < 0 || tabs.length < 2) return;
3316
+ event.preventDefault();
3317
+ const rtl = getComputedStyle(event.currentTarget).direction === "rtl";
3318
+ const step = event.key === "ArrowRight" !== rtl ? 1 : -1;
3319
+ const next = event.key === "Home" ? 0 : event.key === "End" ? tabs.length - 1 : (at + step + tabs.length) % tabs.length;
3320
+ const target = tabs[next];
3321
+ target?.focus();
3322
+ target?.click();
3323
+ }
3299
3324
  function TabListMenu({ tabs, activeItemId }) {
3300
3325
  const canvas = useCanvas();
3301
3326
  const { ports, layer } = useCanvasInternals();