@ai-matrx/canvas 0.8.1 → 0.8.3

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.cjs CHANGED
@@ -3324,24 +3324,49 @@ function TabStrip({
3324
3324
  "data-overflow": overflow ? "" : void 0,
3325
3325
  style: { ["--mxc-tab-min"]: `${CANVAS_TAB_MIN_WIDTH}px` },
3326
3326
  children: [
3327
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { ref: list, className: "mxc-tabs", role: "tablist", "aria-label": "Canvas tabs", "aria-multiselectable": joined ? true : void 0, children: entries.map(
3328
- (entry) => entry.type === "tab" ? tabView(entry.tab) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3329
- "div",
3330
- {
3331
- className: "mxc-tab-group",
3332
- "data-split": "",
3333
- role: "presentation",
3334
- style: { ["--mxc-group-n"]: entry.tabs.length },
3335
- children: entry.tabs.map(tabView)
3336
- },
3337
- `split:${entry.tabs.map((tab) => tab.itemId).join("|")}`
3338
- )
3339
- ) }),
3327
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3328
+ "div",
3329
+ {
3330
+ ref: list,
3331
+ className: "mxc-tabs",
3332
+ role: "tablist",
3333
+ "aria-label": "Canvas tabs",
3334
+ "aria-multiselectable": joined ? true : void 0,
3335
+ onKeyDown: moveTabFocus,
3336
+ children: entries.map(
3337
+ (entry) => entry.type === "tab" ? tabView(entry.tab) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3338
+ "div",
3339
+ {
3340
+ className: "mxc-tab-group",
3341
+ "data-split": "",
3342
+ role: "presentation",
3343
+ style: { ["--mxc-group-n"]: entry.tabs.length },
3344
+ children: entry.tabs.map(tabView)
3345
+ },
3346
+ `split:${entry.tabs.map((tab) => tab.itemId).join("|")}`
3347
+ )
3348
+ )
3349
+ }
3350
+ ),
3340
3351
  overflow ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TabListMenu, { tabs, activeItemId }) : null
3341
3352
  ]
3342
3353
  }
3343
3354
  );
3344
3355
  }
3356
+ function moveTabFocus(event) {
3357
+ const keys = ["ArrowLeft", "ArrowRight", "Home", "End"];
3358
+ if (!keys.includes(event.key) || event.altKey || event.ctrlKey || event.metaKey) return;
3359
+ const tabs = [...event.currentTarget.querySelectorAll('[role="tab"]')];
3360
+ const at = tabs.findIndex((tab) => tab === event.target || tab.contains(event.target));
3361
+ if (at < 0 || tabs.length < 2) return;
3362
+ event.preventDefault();
3363
+ const rtl = getComputedStyle(event.currentTarget).direction === "rtl";
3364
+ const step = event.key === "ArrowRight" !== rtl ? 1 : -1;
3365
+ const next = event.key === "Home" ? 0 : event.key === "End" ? tabs.length - 1 : (at + step + tabs.length) % tabs.length;
3366
+ const target = tabs[next];
3367
+ target?.focus();
3368
+ target?.click();
3369
+ }
3345
3370
  function TabListMenu({ tabs, activeItemId }) {
3346
3371
  const canvas = useCanvas();
3347
3372
  const { ports, layer } = useCanvasInternals();