@ai-matrx/canvas 0.8.0 → 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/CHANGELOG.md +16 -1
- package/dist/react.cjs +40 -14
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +40 -14
- package/dist/react.js.map +1 -1
- package/dist/styles.css +6 -2
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -3249,8 +3249,9 @@ function TabStrip({
|
|
|
3249
3249
|
if (!el || !activeItemId) return;
|
|
3250
3250
|
const tab = [...el.querySelectorAll("[data-mxc-tab]")].find((node) => node.dataset.mxcTab === activeItemId);
|
|
3251
3251
|
if (!tab) return;
|
|
3252
|
+
const target = tab.closest(".mxc-tab-group") ?? tab;
|
|
3252
3253
|
const box = el.getBoundingClientRect();
|
|
3253
|
-
const rect =
|
|
3254
|
+
const rect = target.getBoundingClientRect();
|
|
3254
3255
|
if (rect.left < box.left) el.scrollLeft -= box.left - rect.left;
|
|
3255
3256
|
else if (rect.right > box.right) el.scrollLeft += rect.right - box.right;
|
|
3256
3257
|
}, [activeItemId, width, tabs.length]);
|
|
@@ -3277,24 +3278,49 @@ function TabStrip({
|
|
|
3277
3278
|
"data-overflow": overflow ? "" : void 0,
|
|
3278
3279
|
style: { ["--mxc-tab-min"]: `${CANVAS_TAB_MIN_WIDTH}px` },
|
|
3279
3280
|
children: [
|
|
3280
|
-
/* @__PURE__ */ jsx7(
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
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
|
+
),
|
|
3293
3305
|
overflow ? /* @__PURE__ */ jsx7(TabListMenu, { tabs, activeItemId }) : null
|
|
3294
3306
|
]
|
|
3295
3307
|
}
|
|
3296
3308
|
);
|
|
3297
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
|
+
}
|
|
3298
3324
|
function TabListMenu({ tabs, activeItemId }) {
|
|
3299
3325
|
const canvas = useCanvas();
|
|
3300
3326
|
const { ports, layer } = useCanvasInternals();
|