@smwb/ui-react 2.8.0 → 2.9.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/AI_LESS_OVERRIDES.md +84 -21
- package/AI_THEMING.md +72 -28
- package/README.md +654 -0
- package/dist/assets/styles/less/components/appBar/appBar.entry.css +1 -1
- package/dist/assets/styles/less/components/button/button.entry.css +1 -1
- package/dist/assets/styles/less/components/checkbox/checkbox.entry.css +1 -1
- package/dist/assets/styles/less/components/chip/chip.entry.css +1 -1
- package/dist/assets/styles/less/components/commandPalette/commandPalette.entry.css +1 -0
- package/dist/assets/styles/less/components/composer/composer.entry.css +1 -0
- package/dist/assets/styles/less/components/dagView/dagView.entry.css +1 -0
- package/dist/assets/styles/less/components/diffStat/diffStat.entry.css +1 -0
- package/dist/assets/styles/less/components/kbd/kbd.entry.css +1 -0
- package/dist/assets/styles/less/components/list/list.entry.css +1 -1
- package/dist/assets/styles/less/components/qrCode/qrCode.entry.css +1 -0
- package/dist/assets/styles/less/components/radioButton/radioButton.entry.css +1 -1
- package/dist/assets/styles/less/components/selectField/selectField.entry.css +1 -1
- package/dist/assets/styles/less/components/sidebar/sidebar.entry.css +1 -1
- package/dist/assets/styles/less/components/statusDot/statusDot.entry.css +1 -0
- package/dist/assets/styles/less/components/swimlanes/swimlanes.entry.css +1 -0
- package/dist/assets/styles/less/components/tabGroups/tabGroups.entry.css +1 -0
- package/dist/assets/styles/less/components/tabs/tab/tab.entry.css +1 -1
- package/dist/assets/styles/less/components/tabs/tabPanel/tabPanel.entry.css +1 -0
- package/dist/assets/styles/less/components/tabs/tabs.entry.css +1 -1
- package/dist/assets/styles/less/components/textField/textField.entry.css +1 -1
- package/dist/assets/styles/less/components/toggle/toggle.entry.css +1 -1
- package/dist/assets/styles/less/components/treeView/treeView.entry.css +1 -1
- package/dist/assets/styles/less/tokens.entry.css +1 -1
- package/dist/components/dataDisplay/chat/chat.d.ts +43 -1
- package/dist/components/dataDisplay/chat/chat.js +179 -150
- package/dist/components/dataDisplay/chat/chat.js.map +1 -1
- package/dist/components/dataDisplay/chat/chatComposer.d.ts +17 -0
- package/dist/components/dataDisplay/chat/chatComposer.js +31 -29
- package/dist/components/dataDisplay/chat/chatComposer.js.map +1 -1
- package/dist/components/dataDisplay/chat/index.d.ts +1 -1
- package/dist/components/dataDisplay/chat/utils.d.ts +14 -0
- package/dist/components/dataDisplay/chat/utils.js.map +1 -1
- package/dist/components/dataDisplay/dagView/dagLayout.d.ts +74 -0
- package/dist/components/dataDisplay/dagView/dagLayout.js +289 -0
- package/dist/components/dataDisplay/dagView/dagLayout.js.map +1 -0
- package/dist/components/dataDisplay/dagView/dagView.d.ts +157 -0
- package/dist/components/dataDisplay/dagView/dagView.js +543 -0
- package/dist/components/dataDisplay/dagView/dagView.js.map +1 -0
- package/dist/components/dataDisplay/dagView/index.d.ts +4 -0
- package/dist/components/dataDisplay/dagView/panZoom.d.ts +75 -0
- package/dist/components/dataDisplay/dagView/panZoom.js +171 -0
- package/dist/components/dataDisplay/dagView/panZoom.js.map +1 -0
- package/dist/components/dataDisplay/diffStat/diffStat.d.ts +54 -0
- package/dist/components/dataDisplay/diffStat/diffStat.js +63 -0
- package/dist/components/dataDisplay/diffStat/diffStat.js.map +1 -0
- package/dist/components/dataDisplay/diffStat/index.d.ts +2 -0
- package/dist/components/dataDisplay/kbd/index.d.ts +4 -0
- package/dist/components/dataDisplay/kbd/kbd.d.ts +40 -0
- package/dist/components/dataDisplay/kbd/kbd.js +27 -0
- package/dist/components/dataDisplay/kbd/kbd.js.map +1 -0
- package/dist/components/dataDisplay/kbd/kbdKeys.d.ts +18 -0
- package/dist/components/dataDisplay/kbd/kbdKeys.js +72 -0
- package/dist/components/dataDisplay/kbd/kbdKeys.js.map +1 -0
- package/dist/components/dataDisplay/list/listItem.d.ts +34 -0
- package/dist/components/dataDisplay/list/listItem.js +47 -24
- package/dist/components/dataDisplay/list/listItem.js.map +1 -1
- package/dist/components/dataDisplay/qrCode/index.d.ts +2 -0
- package/dist/components/dataDisplay/qrCode/qrCode.d.ts +28 -0
- package/dist/components/dataDisplay/qrCode/qrCode.js +78 -0
- package/dist/components/dataDisplay/qrCode/qrCode.js.map +1 -0
- package/dist/components/dataDisplay/qrCode/qrCodePath.d.ts +7 -0
- package/dist/components/dataDisplay/qrCode/qrCodePath.js +20 -0
- package/dist/components/dataDisplay/qrCode/qrCodePath.js.map +1 -0
- package/dist/components/dataDisplay/statusDot/index.d.ts +2 -0
- package/dist/components/dataDisplay/statusDot/statusDot.d.ts +35 -0
- package/dist/components/dataDisplay/statusDot/statusDot.js +30 -0
- package/dist/components/dataDisplay/statusDot/statusDot.js.map +1 -0
- package/dist/components/dataDisplay/swimlanes/index.d.ts +2 -0
- package/dist/components/dataDisplay/swimlanes/swimlanes.d.ts +53 -0
- package/dist/components/dataDisplay/swimlanes/swimlanes.js +357 -0
- package/dist/components/dataDisplay/swimlanes/swimlanes.js.map +1 -0
- package/dist/components/dataDisplay/treeView/treeView.d.ts +17 -1
- package/dist/components/dataDisplay/treeView/treeView.js +113 -92
- package/dist/components/dataDisplay/treeView/treeView.js.map +1 -1
- package/dist/components/feedBack/modal/modal.js +84 -63
- package/dist/components/feedBack/modal/modal.js.map +1 -1
- package/dist/components/inputs/button/button.d.ts +13 -1
- package/dist/components/inputs/button/button.js +57 -51
- package/dist/components/inputs/button/button.js.map +1 -1
- package/dist/components/inputs/composer/composer.d.ts +149 -0
- package/dist/components/inputs/composer/composer.js +219 -0
- package/dist/components/inputs/composer/composer.js.map +1 -0
- package/dist/components/inputs/composer/composerFiles.d.ts +26 -0
- package/dist/components/inputs/composer/composerFiles.js +19 -0
- package/dist/components/inputs/composer/composerFiles.js.map +1 -0
- package/dist/components/inputs/composer/composerKeys.d.ts +29 -0
- package/dist/components/inputs/composer/composerKeys.js +7 -0
- package/dist/components/inputs/composer/composerKeys.js.map +1 -0
- package/dist/components/inputs/composer/index.d.ts +3 -0
- package/dist/components/layout/sheet/sheet.d.ts +12 -0
- package/dist/components/layout/sheet/sheet.js +152 -137
- package/dist/components/layout/sheet/sheet.js.map +1 -1
- package/dist/components/layout/tabGroups/index.d.ts +4 -0
- package/dist/components/layout/tabGroups/tabGroups.d.ts +94 -0
- package/dist/components/layout/tabGroups/tabGroups.js +783 -0
- package/dist/components/layout/tabGroups/tabGroups.js.map +1 -0
- package/dist/components/layout/tabGroups/tabGroupsFocus.d.ts +55 -0
- package/dist/components/layout/tabGroups/tabGroupsFocus.js +199 -0
- package/dist/components/layout/tabGroups/tabGroupsFocus.js.map +1 -0
- package/dist/components/layout/tabGroups/tabGroupsLayout.d.ts +250 -0
- package/dist/components/layout/tabGroups/tabGroupsLayout.js +497 -0
- package/dist/components/layout/tabGroups/tabGroupsLayout.js.map +1 -0
- package/dist/components/navigation/appBar/appBar.d.ts +22 -0
- package/dist/components/navigation/appBar/appBar.js +31 -26
- package/dist/components/navigation/appBar/appBar.js.map +1 -1
- package/dist/components/navigation/commandPalette/commandPalette.d.ts +111 -0
- package/dist/components/navigation/commandPalette/commandPalette.js +337 -0
- package/dist/components/navigation/commandPalette/commandPalette.js.map +1 -0
- package/dist/components/navigation/commandPalette/commandPaletteFilter.d.ts +11 -0
- package/dist/components/navigation/commandPalette/commandPaletteFilter.js +16 -0
- package/dist/components/navigation/commandPalette/commandPaletteFilter.js.map +1 -0
- package/dist/components/navigation/commandPalette/commandPaletteNavigation.d.ts +13 -0
- package/dist/components/navigation/commandPalette/commandPaletteNavigation.js +38 -0
- package/dist/components/navigation/commandPalette/commandPaletteNavigation.js.map +1 -0
- package/dist/components/navigation/commandPalette/commandPaletteTypes.d.ts +39 -0
- package/dist/components/navigation/commandPalette/index.d.ts +4 -0
- package/dist/components/navigation/sidebar/sidebar.d.ts +10 -0
- package/dist/components/navigation/sidebar/sidebar.js +61 -59
- package/dist/components/navigation/sidebar/sidebar.js.map +1 -1
- package/dist/components/navigation/tabs/index.d.ts +3 -1
- package/dist/components/navigation/tabs/tab/tab.d.ts +88 -1
- package/dist/components/navigation/tabs/tab/tab.js +121 -42
- package/dist/components/navigation/tabs/tab/tab.js.map +1 -1
- package/dist/components/navigation/tabs/tabPanel/tabPanel.d.ts +19 -0
- package/dist/components/navigation/tabs/tabPanel/tabPanel.js +27 -0
- package/dist/components/navigation/tabs/tabPanel/tabPanel.js.map +1 -0
- package/dist/components/navigation/tabs/tabs.d.ts +75 -5
- package/dist/components/navigation/tabs/tabs.js +369 -145
- package/dist/components/navigation/tabs/tabs.js.map +1 -1
- package/dist/components/navigation/tabs/tabs.utils.d.ts +20 -0
- package/dist/components/navigation/tabs/tabs.utils.js +11 -0
- package/dist/components/navigation/tabs/tabs.utils.js.map +1 -0
- package/dist/components/navigation/tabs/tabsContext.d.ts +11 -0
- package/dist/components/navigation/tabs/tabsContext.js +6 -0
- package/dist/components/navigation/tabs/tabsContext.js.map +1 -0
- package/dist/headless/components/dataDisplay/chat/chat.js +179 -150
- package/dist/headless/components/dataDisplay/chat/chat.js.map +1 -1
- package/dist/headless/components/dataDisplay/chat/chatComposer.js +31 -29
- package/dist/headless/components/dataDisplay/chat/chatComposer.js.map +1 -1
- package/dist/headless/components/dataDisplay/chat/utils.js.map +1 -1
- package/dist/headless/components/dataDisplay/dagView/dagLayout.js +289 -0
- package/dist/headless/components/dataDisplay/dagView/dagLayout.js.map +1 -0
- package/dist/headless/components/dataDisplay/dagView/dagView.js +541 -0
- package/dist/headless/components/dataDisplay/dagView/dagView.js.map +1 -0
- package/dist/headless/components/dataDisplay/dagView/panZoom.js +171 -0
- package/dist/headless/components/dataDisplay/dagView/panZoom.js.map +1 -0
- package/dist/headless/components/dataDisplay/diffStat/diffStat.js +61 -0
- package/dist/headless/components/dataDisplay/diffStat/diffStat.js.map +1 -0
- package/dist/headless/components/dataDisplay/kbd/kbd.js +25 -0
- package/dist/headless/components/dataDisplay/kbd/kbd.js.map +1 -0
- package/dist/headless/components/dataDisplay/kbd/kbdKeys.js +72 -0
- package/dist/headless/components/dataDisplay/kbd/kbdKeys.js.map +1 -0
- package/dist/headless/components/dataDisplay/list/listItem.js +47 -24
- package/dist/headless/components/dataDisplay/list/listItem.js.map +1 -1
- package/dist/headless/components/dataDisplay/qrCode/qrCode.js +76 -0
- package/dist/headless/components/dataDisplay/qrCode/qrCode.js.map +1 -0
- package/dist/headless/components/dataDisplay/qrCode/qrCodePath.js +20 -0
- package/dist/headless/components/dataDisplay/qrCode/qrCodePath.js.map +1 -0
- package/dist/headless/components/dataDisplay/statusDot/statusDot.js +28 -0
- package/dist/headless/components/dataDisplay/statusDot/statusDot.js.map +1 -0
- package/dist/headless/components/dataDisplay/swimlanes/swimlanes.js +355 -0
- package/dist/headless/components/dataDisplay/swimlanes/swimlanes.js.map +1 -0
- package/dist/headless/components/dataDisplay/treeView/treeView.js +113 -92
- package/dist/headless/components/dataDisplay/treeView/treeView.js.map +1 -1
- package/dist/headless/components/feedBack/modal/modal.js +85 -64
- package/dist/headless/components/feedBack/modal/modal.js.map +1 -1
- package/dist/headless/components/inputs/button/button.js +56 -50
- package/dist/headless/components/inputs/button/button.js.map +1 -1
- package/dist/headless/components/inputs/composer/composer.js +217 -0
- package/dist/headless/components/inputs/composer/composer.js.map +1 -0
- package/dist/headless/components/inputs/composer/composerFiles.js +19 -0
- package/dist/headless/components/inputs/composer/composerFiles.js.map +1 -0
- package/dist/headless/components/inputs/composer/composerKeys.js +7 -0
- package/dist/headless/components/inputs/composer/composerKeys.js.map +1 -0
- package/dist/headless/components/layout/sheet/sheet.js +160 -145
- package/dist/headless/components/layout/sheet/sheet.js.map +1 -1
- package/dist/headless/components/layout/tabGroups/tabGroups.js +781 -0
- package/dist/headless/components/layout/tabGroups/tabGroups.js.map +1 -0
- package/dist/headless/components/layout/tabGroups/tabGroupsFocus.js +199 -0
- package/dist/headless/components/layout/tabGroups/tabGroupsFocus.js.map +1 -0
- package/dist/headless/components/layout/tabGroups/tabGroupsLayout.js +497 -0
- package/dist/headless/components/layout/tabGroups/tabGroupsLayout.js.map +1 -0
- package/dist/headless/components/navigation/appBar/appBar.js +35 -30
- package/dist/headless/components/navigation/appBar/appBar.js.map +1 -1
- package/dist/headless/components/navigation/commandPalette/commandPalette.js +335 -0
- package/dist/headless/components/navigation/commandPalette/commandPalette.js.map +1 -0
- package/dist/headless/components/navigation/commandPalette/commandPaletteFilter.js +16 -0
- package/dist/headless/components/navigation/commandPalette/commandPaletteFilter.js.map +1 -0
- package/dist/headless/components/navigation/commandPalette/commandPaletteNavigation.js +38 -0
- package/dist/headless/components/navigation/commandPalette/commandPaletteNavigation.js.map +1 -0
- package/dist/headless/components/navigation/sidebar/sidebar.js +56 -54
- package/dist/headless/components/navigation/sidebar/sidebar.js.map +1 -1
- package/dist/headless/components/navigation/tabs/tab/tab.js +121 -42
- package/dist/headless/components/navigation/tabs/tab/tab.js.map +1 -1
- package/dist/headless/components/navigation/tabs/tabPanel/tabPanel.js +25 -0
- package/dist/headless/components/navigation/tabs/tabPanel/tabPanel.js.map +1 -0
- package/dist/headless/components/navigation/tabs/tabs.js +369 -145
- package/dist/headless/components/navigation/tabs/tabs.js.map +1 -1
- package/dist/headless/components/navigation/tabs/tabs.utils.js +11 -0
- package/dist/headless/components/navigation/tabs/tabs.utils.js.map +1 -0
- package/dist/headless/components/navigation/tabs/tabsContext.js +6 -0
- package/dist/headless/components/navigation/tabs/tabsContext.js.map +1 -0
- package/dist/headless/hooks/useFocusTrap.js +24 -21
- package/dist/headless/hooks/useFocusTrap.js.map +1 -1
- package/dist/headless/hooks/useKeyboardShortcut.js +19 -0
- package/dist/headless/hooks/useKeyboardShortcut.js.map +1 -0
- package/dist/headless/index.js +360 -316
- package/dist/headless/index.js.map +1 -1
- package/dist/headless/utils/keyboardShortcut.js +49 -0
- package/dist/headless/utils/keyboardShortcut.js.map +1 -0
- package/dist/headless/utils/linkAttrs.js +13 -0
- package/dist/headless/utils/linkAttrs.js.map +1 -0
- package/dist/headless/utils/restoreFocus.js +10 -0
- package/dist/headless/utils/restoreFocus.js.map +1 -0
- package/dist/hooks/useFocusTrap.d.ts +6 -1
- package/dist/hooks/useFocusTrap.js +24 -21
- package/dist/hooks/useFocusTrap.js.map +1 -1
- package/dist/hooks/useKeyboardShortcut.d.ts +30 -0
- package/dist/hooks/useKeyboardShortcut.js +19 -0
- package/dist/hooks/useKeyboardShortcut.js.map +1 -0
- package/dist/index.cjs +3 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +24 -3
- package/dist/index.js +360 -316
- package/dist/index.js.map +1 -1
- package/dist/utils/keyboardShortcut.d.ts +12 -0
- package/dist/utils/keyboardShortcut.js +49 -0
- package/dist/utils/keyboardShortcut.js.map +1 -0
- package/dist/utils/linkAttrs.d.ts +13 -0
- package/dist/utils/linkAttrs.js +13 -0
- package/dist/utils/linkAttrs.js.map +1 -0
- package/dist/utils/restoreFocus.d.ts +8 -0
- package/dist/utils/restoreFocus.js +10 -0
- package/dist/utils/restoreFocus.js.map +1 -0
- package/package.json +5 -3
|
@@ -0,0 +1,781 @@
|
|
|
1
|
+
import { jsxs as B, jsx as g, Fragment as ie } from "react/jsx-runtime";
|
|
2
|
+
import u from "react";
|
|
3
|
+
import J from "clsx";
|
|
4
|
+
import { Icon as sr } from "../../base/icon/icon.js";
|
|
5
|
+
import { useControllableState as ir } from "../../../hooks/useControllableState.js";
|
|
6
|
+
import { useEventCallback as _ } from "../../../hooks/useEventCallback.js";
|
|
7
|
+
import { useForkRef as ur } from "../../../hooks/useForkRef.js";
|
|
8
|
+
import { useId as ar } from "../../../hooks/useId.js";
|
|
9
|
+
import { useSafeLayoutEffect as vt } from "../../../hooks/useSafeLayoutEffect.js";
|
|
10
|
+
import { matchesKeyboardShortcut as L } from "../../../utils/keyboardShortcut.js";
|
|
11
|
+
import { throttle as cr } from "../../../utils/throttle.js";
|
|
12
|
+
import { TAB_GROUPS_LABELS as lr, getGroups as Et, computeTabGroupsGrid as dr, groupHeaderArea as fr, groupBodyArea as pr, gridTemplateRows as mr, gridTemplateColumns as gr, findGroupOfTab as $, resizeSplit as br, setActiveGroup as hr, describeTabGroupsChange as wr, moveTab as ue, moveTabInDirection as yr, selectTab as Rr, removeTab as vr, adjacentGroup as Ar, dropZoneAt as Sr, separatorArea as Er, createTabGroupsLayout as Tr } from "./tabGroupsLayout.js";
|
|
13
|
+
import { ownerRootOf as ae, deepActiveElement as tt, containsDeep as ce, tabMove as Dr, frameExitTarget as _r, ownGroupIdOf as le, lastStopOf as Mr, focusFromEnd as kr } from "./tabGroupsFocus.js";
|
|
14
|
+
import { Tabs as xr } from "../../navigation/tabs/tabs.js";
|
|
15
|
+
import { Menu as Cr } from "../../navigation/menu/menu.js";
|
|
16
|
+
import { MenuItem as $r } from "../../navigation/menu/menuItem.js";
|
|
17
|
+
import { Tab as Pr } from "../../navigation/tabs/tab/tab.js";
|
|
18
|
+
const Or = '[role^="menuitem"]:not([aria-disabled="true"])', Fr = Tr(), Gr = [
|
|
19
|
+
"Alt+Shift+ArrowLeft",
|
|
20
|
+
"Alt+Shift+ArrowRight",
|
|
21
|
+
"Alt+Shift+ArrowUp",
|
|
22
|
+
"Alt+Shift+ArrowDown",
|
|
23
|
+
"Control+Shift+ArrowLeft",
|
|
24
|
+
"Meta+Shift+ArrowLeft",
|
|
25
|
+
"Control+Shift+ArrowRight",
|
|
26
|
+
"Meta+Shift+ArrowRight"
|
|
27
|
+
].join(" ");
|
|
28
|
+
function At(c) {
|
|
29
|
+
let a = c != null ? c : null;
|
|
30
|
+
for (; a; ) {
|
|
31
|
+
const f = a.getAttribute("data-group-id");
|
|
32
|
+
if (f !== null) return f;
|
|
33
|
+
a = a.parentElement;
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
function de(c) {
|
|
38
|
+
var a;
|
|
39
|
+
return (a = c.closest(".smwb-tab-item")) != null ? a : c;
|
|
40
|
+
}
|
|
41
|
+
function fe(c) {
|
|
42
|
+
var f;
|
|
43
|
+
const a = c.closest(".smwb-tab-item");
|
|
44
|
+
return (f = a == null ? void 0 : a.querySelector('[role="tab"][data-tab-id]')) != null ? f : c.closest('[role="tab"][data-tab-id]');
|
|
45
|
+
}
|
|
46
|
+
function me(c, a) {
|
|
47
|
+
if (c.type !== "group") {
|
|
48
|
+
if (c.id === a) return c;
|
|
49
|
+
for (const f of c.children) {
|
|
50
|
+
const p = me(f, a);
|
|
51
|
+
if (p) return p;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function ge(c) {
|
|
56
|
+
return c.type === "group" ? [c.id] : c.children.flatMap(ge);
|
|
57
|
+
}
|
|
58
|
+
function pe(c) {
|
|
59
|
+
const a = [0];
|
|
60
|
+
return c.forEach((f, p) => {
|
|
61
|
+
var m;
|
|
62
|
+
a[p + 1] = ((m = a[p]) != null ? m : 0) + f;
|
|
63
|
+
}), a;
|
|
64
|
+
}
|
|
65
|
+
function Lr(c, a) {
|
|
66
|
+
var m, b;
|
|
67
|
+
const f = (m = c.sizes[a]) != null ? m : 0, p = f + ((b = c.sizes[a + 1]) != null ? b : 0);
|
|
68
|
+
return p > 0 ? Math.round(f / p * 100) : 0;
|
|
69
|
+
}
|
|
70
|
+
function et(c, a) {
|
|
71
|
+
return Et(c).some((f) => f.id === a);
|
|
72
|
+
}
|
|
73
|
+
function zr(c) {
|
|
74
|
+
const a = [], f = (p) => {
|
|
75
|
+
if (p.type === "group") {
|
|
76
|
+
a.push(`h:${p.id}`, `p:${p.id}`);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
p.children.forEach((m, b) => {
|
|
80
|
+
f(m), b < p.children.length - 1 && a.push(`s:${p.id}:${b}`);
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
return f(c), a;
|
|
84
|
+
}
|
|
85
|
+
function St(c, a, f, p) {
|
|
86
|
+
const m = $(c, f), b = $(a, f);
|
|
87
|
+
if (!m || !b) return null;
|
|
88
|
+
const z = !et(a, m.id);
|
|
89
|
+
return p !== void 0 && !et(c, b.id) ? { type: "split", tab: f, from: m.id, to: b.id, edge: p, sourceClosed: z } : { type: "move", tab: f, from: m.id, to: b.id, index: b.tabs.indexOf(f), sourceClosed: z };
|
|
90
|
+
}
|
|
91
|
+
const rn = u.forwardRef(function(a, f) {
|
|
92
|
+
var ne, oe, se;
|
|
93
|
+
const {
|
|
94
|
+
layout: p,
|
|
95
|
+
defaultLayout: m,
|
|
96
|
+
onLayoutChange: b,
|
|
97
|
+
getTab: z,
|
|
98
|
+
renderPanel: be,
|
|
99
|
+
onTabClose: rt,
|
|
100
|
+
empty: he,
|
|
101
|
+
minGroupSize: Tt = 120,
|
|
102
|
+
keyboardStep: Dt = 5,
|
|
103
|
+
groupActions: we = !0,
|
|
104
|
+
dense: ye = !1,
|
|
105
|
+
labels: _t,
|
|
106
|
+
id: Re,
|
|
107
|
+
className: ve,
|
|
108
|
+
style: Ae,
|
|
109
|
+
"data-testid": Se = "tab-groups",
|
|
110
|
+
// Wrapped so that the caller's handler still runs, first.
|
|
111
|
+
onFocus: nt,
|
|
112
|
+
onKeyDown: ot,
|
|
113
|
+
onDragStart: st,
|
|
114
|
+
onDragOver: it,
|
|
115
|
+
onDrop: ut,
|
|
116
|
+
onDragEnd: at,
|
|
117
|
+
...Ee
|
|
118
|
+
} = a, A = ar(Re), Mt = (t) => `${A}-header-${encodeURIComponent(t)}`, kt = (t) => `${A}-panel-${encodeURIComponent(t)}`, xt = (t, e) => `${A}-separator-${encodeURIComponent(t)}-${e}`, y = u.useRef(null), Te = ur(f, y), [R, De] = ir({
|
|
119
|
+
value: p,
|
|
120
|
+
defaultValue: m != null ? m : Fr
|
|
121
|
+
}), h = u.useRef(R);
|
|
122
|
+
h.current = R;
|
|
123
|
+
const P = u.useRef(R);
|
|
124
|
+
P.current = R;
|
|
125
|
+
const ct = u.useRef(p !== void 0);
|
|
126
|
+
ct.current = p !== void 0;
|
|
127
|
+
const lt = u.useRef(!1), S = u.useMemo(() => ({ ...lr, ..._t }), [_t]), [_e, Me] = u.useState(""), q = u.useRef(null), dt = u.useRef(/* @__PURE__ */ new WeakMap()), Ct = u.useRef(0), H = u.useRef(!1), W = u.useRef(null), N = u.useRef(null), ft = u.useRef(!1), M = u.useRef(null), D = u.useRef(null), Y = u.useRef(null), [ke, $t] = u.useState(!1), [j, K] = u.useState(null), U = u.useRef(null), [O, Pt] = u.useState(null), [Ot, V] = u.useState(null), [pt, xe] = u.useState(null), [Ft, Ce] = u.useState(0), w = u.useMemo(() => Et(R), [R]), E = u.useMemo(() => dr(R), [R]), mt = u.useMemo(() => new Map(w.map((t) => [t.id, t])), [w]), F = u.useMemo(() => new Map(E.groups.map((t) => [t.id, t])), [E]), $e = u.useMemo(
|
|
128
|
+
() => new Map(E.separators.map((t) => [`${t.split}:${t.index}`, t])),
|
|
129
|
+
[E]
|
|
130
|
+
), Gt = u.useMemo(() => pe(E.columns), [E]), Lt = u.useMemo(() => pe(E.rows), [E]), zt = u.useRef(null), G = (ne = zt.current) != null ? ne : /* @__PURE__ */ new Set(), gt = /* @__PURE__ */ new Set();
|
|
131
|
+
w.forEach((t) => t.tabs.forEach((e) => gt.add(e))), Array.from(G).forEach((t) => {
|
|
132
|
+
gt.has(t) || G.delete(t);
|
|
133
|
+
}), w.forEach((t) => {
|
|
134
|
+
t.active !== null && G.add(t.active);
|
|
135
|
+
}), zt.current = G;
|
|
136
|
+
const Nt = u.useRef([]), X = Nt.current.filter((t) => gt.has(t)), Kt = new Set(X);
|
|
137
|
+
w.forEach(
|
|
138
|
+
(t) => t.tabs.forEach((e) => {
|
|
139
|
+
Kt.has(e) || (Kt.add(e), X.push(e));
|
|
140
|
+
})
|
|
141
|
+
), Nt.current = X;
|
|
142
|
+
const Ut = /* @__PURE__ */ new Map();
|
|
143
|
+
w.forEach((t) => t.tabs.forEach((e) => Ut.set(e, t)));
|
|
144
|
+
const Pe = _((t) => {
|
|
145
|
+
const e = z(t);
|
|
146
|
+
return e ? e.title !== void 0 ? e.title : typeof e.label == "string" ? e.label : t : t;
|
|
147
|
+
}), k = _((t, e) => {
|
|
148
|
+
if (t === h.current) return !1;
|
|
149
|
+
h.current = t, Ct.current += 1, dt.current.set(t, Ct.current), De(t), b == null || b(t, e);
|
|
150
|
+
const r = wr(e, t, Pe, S);
|
|
151
|
+
return r && Me((n) => n === r ? `${r} ` : r), ct.current && !lt.current && (lt.current = !0, queueMicrotask(Oe)), !0;
|
|
152
|
+
}), Oe = _(() => {
|
|
153
|
+
lt.current = !1, !(!ct.current || h.current === P.current) && (h.current = P.current);
|
|
154
|
+
}), Q = (t, e, r) => {
|
|
155
|
+
var s;
|
|
156
|
+
const n = $(e, t);
|
|
157
|
+
if (!n) return;
|
|
158
|
+
const o = (s = y.current) == null ? void 0 : s.ownerDocument;
|
|
159
|
+
q.current = {
|
|
160
|
+
tab: t,
|
|
161
|
+
group: n.id,
|
|
162
|
+
index: n.tabs.indexOf(t),
|
|
163
|
+
...r === void 0 ? {} : { gone: r },
|
|
164
|
+
after: e,
|
|
165
|
+
base: P.current,
|
|
166
|
+
from: o ? tt(o) : null
|
|
167
|
+
};
|
|
168
|
+
}, x = _((t, e, r = !0) => {
|
|
169
|
+
const n = h.current, o = ue(n, t, e), s = St(n, o, t, e.edge);
|
|
170
|
+
!s || !k(o, s) || r && Q(t, o);
|
|
171
|
+
}), Fe = _((t, e) => {
|
|
172
|
+
const r = h.current, n = yr(r, t, e);
|
|
173
|
+
if (n === r) return !1;
|
|
174
|
+
const o = St(r, n, t, e);
|
|
175
|
+
return !o || !k(n, o) ? !1 : (Q(t, n), !0);
|
|
176
|
+
}), Z = _((t, e) => {
|
|
177
|
+
const r = h.current, n = $(r, t);
|
|
178
|
+
if (!n) return !1;
|
|
179
|
+
const o = n.tabs.indexOf(t) + e;
|
|
180
|
+
if (o < 0 || o >= n.tabs.length) return !1;
|
|
181
|
+
const s = ue(r, t, { group: n.id, index: o }), i = St(r, s, t, void 0);
|
|
182
|
+
return !i || !k(s, i) ? !1 : (Q(t, s), !0);
|
|
183
|
+
}), Ge = _((t) => {
|
|
184
|
+
const e = h.current, r = $(e, t);
|
|
185
|
+
r && k(Rr(e, t), { type: "select", tab: t, group: r.id });
|
|
186
|
+
}), bt = _(
|
|
187
|
+
(t, e, r, n, o) => {
|
|
188
|
+
const s = o != null ? o : h.current, i = br(s, t, e, r, n);
|
|
189
|
+
if (i === s) return;
|
|
190
|
+
const l = me(i.root, t);
|
|
191
|
+
k(i, { type: "resize", split: t, sizes: l ? [...l.sizes] : [] });
|
|
192
|
+
}
|
|
193
|
+
), Le = _(
|
|
194
|
+
(t, e, r) => {
|
|
195
|
+
const n = h.current, o = $(n, t);
|
|
196
|
+
if (!o || (rt == null ? void 0 : rt(t, e, r)) === !1) return;
|
|
197
|
+
const s = vr(n, t);
|
|
198
|
+
if (s === n) return;
|
|
199
|
+
const i = !et(s, o.id), l = y.current, d = l ? tt(l.ownerDocument) : null, T = r === "actions" || l !== null && le(l, d) === o.id;
|
|
200
|
+
if (!k(s, { type: "close", tab: t, group: o.id, groupClosed: i }) || !i || !T) return;
|
|
201
|
+
const v = Ar(n, o.id), C = v ? Et(s).find((yt) => yt.id === v) : void 0;
|
|
202
|
+
C != null && C.active && Q(C.active, s, o.id);
|
|
203
|
+
}
|
|
204
|
+
), ze = (t) => {
|
|
205
|
+
nt == null || nt(t);
|
|
206
|
+
const e = y.current;
|
|
207
|
+
if (!e) return;
|
|
208
|
+
const r = t.target, n = N.current;
|
|
209
|
+
if (N.current = ae(r) === e ? r : null, (n == null ? void 0 : n.localName) === "iframe" && n !== r && !ft.current) {
|
|
210
|
+
const s = _r(e, n, r);
|
|
211
|
+
if (s !== null && s === W.current) {
|
|
212
|
+
H.current = !0, s !== r && s.focus({ preventScroll: !0 });
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
if (s !== null) {
|
|
216
|
+
s.focus();
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (r === W.current) {
|
|
221
|
+
Ke();
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const o = le(e, r);
|
|
225
|
+
!o || o === h.current.activeGroup || k(hr(h.current, o), { type: "activate", group: o });
|
|
226
|
+
}, Ne = (t) => {
|
|
227
|
+
if (ot == null || ot(t), t.defaultPrevented || t.key !== "Tab" || t.altKey || t.ctrlKey || t.metaKey || t.nativeEvent.isComposing) return;
|
|
228
|
+
const e = y.current, r = e ? tt(e.ownerDocument) : null;
|
|
229
|
+
if (!e || !r || !ce(e, r)) return;
|
|
230
|
+
const n = Dr(e, r, t.shiftKey ? -1 : 1);
|
|
231
|
+
n && (n.element === W.current && (H.current = !0), N.current = null, n.prevent ? (t.preventDefault(), n.element.focus()) : n.element.focus({ preventScroll: !0 }));
|
|
232
|
+
};
|
|
233
|
+
u.useEffect(() => {
|
|
234
|
+
const t = y.current, e = t == null ? void 0 : t.ownerDocument.defaultView;
|
|
235
|
+
if (!t || !e) return;
|
|
236
|
+
let r;
|
|
237
|
+
const n = () => {
|
|
238
|
+
ft.current = !0, e.clearTimeout(r), r = e.setTimeout(() => {
|
|
239
|
+
ft.current = !1;
|
|
240
|
+
}, 0);
|
|
241
|
+
}, o = (i) => {
|
|
242
|
+
i.relatedTarget instanceof Node && !t.contains(i.relatedTarget) && (N.current = null);
|
|
243
|
+
}, s = () => {
|
|
244
|
+
const i = t.ownerDocument.activeElement;
|
|
245
|
+
i instanceof e.HTMLIFrameElement && ae(i) === t && (N.current = i);
|
|
246
|
+
};
|
|
247
|
+
return t.addEventListener("pointerdown", n, !0), t.addEventListener("focusout", o), e.addEventListener("blur", s), () => {
|
|
248
|
+
e.clearTimeout(r), t.removeEventListener("pointerdown", n, !0), t.removeEventListener("focusout", o), e.removeEventListener("blur", s);
|
|
249
|
+
};
|
|
250
|
+
}, []);
|
|
251
|
+
const Ke = () => {
|
|
252
|
+
const t = y.current;
|
|
253
|
+
if (H.current || !t) return;
|
|
254
|
+
const e = Mr(t);
|
|
255
|
+
e && kr(e);
|
|
256
|
+
}, It = (t, e) => {
|
|
257
|
+
if (e === t.base) return !0;
|
|
258
|
+
const r = dt.current.get(e), n = dt.current.get(t.after);
|
|
259
|
+
return r !== void 0 && n !== void 0 && r < n;
|
|
260
|
+
}, Bt = () => {
|
|
261
|
+
const t = q.current, e = y.current, r = P.current;
|
|
262
|
+
if (!t || !e || It(t, r)) return;
|
|
263
|
+
const n = $(r, t.tab);
|
|
264
|
+
if ((n == null ? void 0 : n.id) !== t.group || n.tabs.indexOf(t.tab) !== t.index || t.gone !== void 0 && et(r, t.gone)) return;
|
|
265
|
+
const o = Array.from(
|
|
266
|
+
e.querySelectorAll(':scope > .smwb-tab-groups__header [role="tab"][data-tab-id]')
|
|
267
|
+
).find((l) => l.getAttribute("data-tab-id") === t.tab);
|
|
268
|
+
if (!o || At(o) !== t.group) return;
|
|
269
|
+
const s = e.ownerDocument, i = tt(s);
|
|
270
|
+
i !== o && (i !== null && i !== s.body && i !== t.from && !ce(e, i) || o.focus());
|
|
271
|
+
};
|
|
272
|
+
vt(() => {
|
|
273
|
+
Bt();
|
|
274
|
+
}), u.useEffect(() => {
|
|
275
|
+
Bt();
|
|
276
|
+
const t = q.current;
|
|
277
|
+
t && !It(t, P.current) && (q.current = null);
|
|
278
|
+
}), vt(() => {
|
|
279
|
+
var e, r, n;
|
|
280
|
+
if (Ft === 0) return;
|
|
281
|
+
const t = pt;
|
|
282
|
+
for (const o of (r = (e = t == null ? void 0 : t.getAttribute("aria-controls")) == null ? void 0 : e.split(/\s+/)) != null ? r : []) {
|
|
283
|
+
const s = o ? (n = t == null ? void 0 : t.ownerDocument.getElementById(o)) == null ? void 0 : n.querySelector(Or) : null;
|
|
284
|
+
if (s) {
|
|
285
|
+
s.focus({ preventScroll: !0 });
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}, [Ft, pt]), vt(() => {
|
|
290
|
+
if (!O) return;
|
|
291
|
+
const t = document.body, e = t.style.cursor;
|
|
292
|
+
return t.style.cursor = O.orientation === "vertical" ? "col-resize" : "row-resize", () => {
|
|
293
|
+
t.style.cursor = e;
|
|
294
|
+
};
|
|
295
|
+
}, [O]);
|
|
296
|
+
const qt = u.useCallback(
|
|
297
|
+
(t, e) => {
|
|
298
|
+
const r = e === "x" ? Gt : Lt;
|
|
299
|
+
let n = 1 / 0, o = -1 / 0;
|
|
300
|
+
return ge(t).forEach((s) => {
|
|
301
|
+
var T, v;
|
|
302
|
+
const i = F.get(s);
|
|
303
|
+
if (!i) return;
|
|
304
|
+
const [l, d] = e === "x" ? i.column : i.row;
|
|
305
|
+
n = Math.min(n, (T = r[l]) != null ? T : 0), o = Math.max(o, (v = r[d]) != null ? v : 100);
|
|
306
|
+
}), Number.isFinite(n) && o > n ? o - n : 100;
|
|
307
|
+
},
|
|
308
|
+
[Gt, Lt, F]
|
|
309
|
+
), Ht = u.useCallback(
|
|
310
|
+
(t, e) => {
|
|
311
|
+
var s, i;
|
|
312
|
+
const r = (s = y.current) == null ? void 0 : s.getBoundingClientRect(), o = ((i = e === "x" ? r == null ? void 0 : r.width : r == null ? void 0 : r.height) != null ? i : 0) * qt(t, e) / 100;
|
|
313
|
+
return { extentPx: o, minPercent: o > 0 ? Tt / o * 100 : 0 };
|
|
314
|
+
},
|
|
315
|
+
[Tt, qt]
|
|
316
|
+
), Ue = u.useCallback(
|
|
317
|
+
(t) => {
|
|
318
|
+
const e = F.get(t);
|
|
319
|
+
return e ? { gridArea: fr(e) } : void 0;
|
|
320
|
+
},
|
|
321
|
+
[F]
|
|
322
|
+
), Wt = u.useCallback(
|
|
323
|
+
(t) => {
|
|
324
|
+
const e = F.get(t);
|
|
325
|
+
return e ? { gridArea: pr(e) } : void 0;
|
|
326
|
+
},
|
|
327
|
+
[F]
|
|
328
|
+
), ht = u.useMemo(
|
|
329
|
+
() => cr((t) => {
|
|
330
|
+
const e = U.current;
|
|
331
|
+
!e || !(e.extentPx > 0) || bt(e.split, e.index, (t - e.start) / e.extentPx * 100, e.minPercent, e.layout);
|
|
332
|
+
}, 1e3 / 60),
|
|
333
|
+
[bt]
|
|
334
|
+
);
|
|
335
|
+
u.useEffect(
|
|
336
|
+
() => () => {
|
|
337
|
+
D.current && D.current.view.cancelAnimationFrame(D.current.id), ht.cancel();
|
|
338
|
+
},
|
|
339
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
340
|
+
[]
|
|
341
|
+
);
|
|
342
|
+
const Ie = (t, e, r, n) => {
|
|
343
|
+
if (t.pointerType === "mouse" && t.button !== 0) return;
|
|
344
|
+
const o = e.direction === "row" ? "vertical" : "horizontal", s = o === "vertical" ? "x" : "y", { extentPx: i, minPercent: l } = Ht(e, s);
|
|
345
|
+
U.current = {
|
|
346
|
+
split: e.id,
|
|
347
|
+
index: r,
|
|
348
|
+
axis: s,
|
|
349
|
+
pointerId: t.pointerId,
|
|
350
|
+
start: s === "x" ? t.clientX : t.clientY,
|
|
351
|
+
extentPx: i,
|
|
352
|
+
minPercent: l,
|
|
353
|
+
layout: h.current
|
|
354
|
+
}, Pt({ key: n, orientation: o });
|
|
355
|
+
const d = t.currentTarget;
|
|
356
|
+
if (typeof d.setPointerCapture == "function")
|
|
357
|
+
try {
|
|
358
|
+
d.setPointerCapture(t.pointerId);
|
|
359
|
+
} catch {
|
|
360
|
+
}
|
|
361
|
+
}, Be = (t) => {
|
|
362
|
+
const e = U.current;
|
|
363
|
+
!e || e.pointerId !== t.pointerId || ht(e.axis === "x" ? t.clientX : t.clientY);
|
|
364
|
+
}, Yt = (t) => {
|
|
365
|
+
var e;
|
|
366
|
+
((e = U.current) == null ? void 0 : e.pointerId) === t.pointerId && (U.current = null, ht.cancel(), Pt(null));
|
|
367
|
+
}, qe = (t, e, r) => {
|
|
368
|
+
if (t.defaultPrevented) return;
|
|
369
|
+
const n = e.direction === "row";
|
|
370
|
+
let o;
|
|
371
|
+
if (t.key === (n ? "ArrowLeft" : "ArrowUp")) o = -Dt;
|
|
372
|
+
else if (t.key === (n ? "ArrowRight" : "ArrowDown")) o = Dt;
|
|
373
|
+
else if (t.key === "Home") o = -1 / 0;
|
|
374
|
+
else if (t.key === "End") o = 1 / 0;
|
|
375
|
+
else return;
|
|
376
|
+
t.preventDefault();
|
|
377
|
+
const { minPercent: s } = Ht(e, n ? "x" : "y");
|
|
378
|
+
bt(e.id, r, o, s);
|
|
379
|
+
}, jt = (t) => {
|
|
380
|
+
var i, l, d;
|
|
381
|
+
const e = y.current, r = t.target;
|
|
382
|
+
if (!e || !r || r.closest(".smwb-tab-groups") !== e) return null;
|
|
383
|
+
const n = r.closest(".smwb-tab-groups__header");
|
|
384
|
+
if (n) {
|
|
385
|
+
const T = n.getAttribute("data-group-id");
|
|
386
|
+
if (!T) return null;
|
|
387
|
+
const v = fe(r), C = (i = v == null ? void 0 : v.getAttribute("data-tab-id")) != null ? i : null, yt = (d = (l = mt.get(T)) == null ? void 0 : l.tabs) != null ? d : [], Rt = C === null ? -1 : yt.indexOf(C);
|
|
388
|
+
return {
|
|
389
|
+
kind: "row",
|
|
390
|
+
group: T,
|
|
391
|
+
index: Rt >= 0 ? Rt : null,
|
|
392
|
+
item: Rt >= 0 && v ? de(v) : null
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
const o = r.closest(".smwb-tab-groups__drop-target");
|
|
396
|
+
if (!o) return null;
|
|
397
|
+
const s = o.getAttribute("data-group-id");
|
|
398
|
+
return s ? { kind: "body", group: s, element: o } : null;
|
|
399
|
+
}, Vt = (t, e) => {
|
|
400
|
+
const r = t.getBoundingClientRect();
|
|
401
|
+
return Sr(e.clientX - r.left, e.clientY - r.top, r.width, r.height);
|
|
402
|
+
}, Xt = (t, e, r) => {
|
|
403
|
+
var n, o;
|
|
404
|
+
return t !== e ? !0 : r === "center" ? !1 : ((o = (n = mt.get(e)) == null ? void 0 : n.tabs.length) != null ? o : 0) >= 2;
|
|
405
|
+
}, I = (t) => {
|
|
406
|
+
var e;
|
|
407
|
+
Y.current !== t && ((e = Y.current) == null || e.classList.remove("smwb-tab-item--drop-target"), Y.current = t, t == null || t.classList.add("smwb-tab-item--drop-target"));
|
|
408
|
+
}, wt = () => {
|
|
409
|
+
var r, n;
|
|
410
|
+
const t = M.current, e = Array.from(
|
|
411
|
+
(n = (r = y.current) == null ? void 0 : r.querySelectorAll(":scope > .smwb-tab-groups__header")) != null ? n : []
|
|
412
|
+
).find((o) => o.getAttribute("data-group-id") === (t == null ? void 0 : t.group));
|
|
413
|
+
e == null || e.querySelectorAll(".smwb-tab-item--drop-target").forEach((o) => {
|
|
414
|
+
o !== Y.current && o.classList.remove("smwb-tab-item--drop-target");
|
|
415
|
+
});
|
|
416
|
+
}, Qt = () => {
|
|
417
|
+
M.current = null, D.current && (D.current.view.cancelAnimationFrame(D.current.id), D.current = null), I(null), $t(!1), K(null);
|
|
418
|
+
}, He = (t) => {
|
|
419
|
+
st == null || st(t);
|
|
420
|
+
const e = y.current, r = t.target;
|
|
421
|
+
if (!e || !r || r.closest(".smwb-tab-groups") !== e) return;
|
|
422
|
+
const n = fe(r), o = n == null ? void 0 : n.getAttribute("data-tab-id");
|
|
423
|
+
if (!n || !o || n.getAttribute("aria-disabled") === "true") return;
|
|
424
|
+
const s = At(n);
|
|
425
|
+
if (!s) return;
|
|
426
|
+
const i = e.ownerDocument, l = i.activeElement;
|
|
427
|
+
M.current = {
|
|
428
|
+
tab: o,
|
|
429
|
+
group: s,
|
|
430
|
+
hadFocus: !!(l && l !== i.body && de(n).contains(l))
|
|
431
|
+
};
|
|
432
|
+
const d = i.defaultView;
|
|
433
|
+
if (!d) return;
|
|
434
|
+
const T = d.requestAnimationFrame(() => {
|
|
435
|
+
D.current = null, $t(!0);
|
|
436
|
+
});
|
|
437
|
+
D.current = { view: d, id: T };
|
|
438
|
+
}, We = (t) => {
|
|
439
|
+
var n;
|
|
440
|
+
if (it == null || it(t), !M.current) return;
|
|
441
|
+
const e = jt(t);
|
|
442
|
+
if (!e) {
|
|
443
|
+
I(null), wt(), K(null);
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
if (e.kind === "row") {
|
|
447
|
+
if (e.group === M.current.group) {
|
|
448
|
+
I(null), (n = e.item) == null || n.classList.add("smwb-tab-item--drop-target");
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
wt(), t.preventDefault(), t.dataTransfer && (t.dataTransfer.dropEffect = "move"), K(null), I(e.item);
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
I(null), wt();
|
|
455
|
+
const r = Vt(e.element, t);
|
|
456
|
+
if (!Xt(M.current.group, e.group, r)) {
|
|
457
|
+
K(null);
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
t.preventDefault(), t.dataTransfer && (t.dataTransfer.dropEffect = "move"), K(
|
|
461
|
+
(o) => o && o.group === e.group && o.zone === r ? o : { group: e.group, zone: r }
|
|
462
|
+
);
|
|
463
|
+
}, Ye = (t) => {
|
|
464
|
+
ut == null || ut(t);
|
|
465
|
+
const e = M.current;
|
|
466
|
+
if (!e) return;
|
|
467
|
+
const r = t.defaultPrevented ? null : jt(t), n = r && r.kind === "body" ? Vt(r.element, t) : null;
|
|
468
|
+
if (Qt(), !!r) {
|
|
469
|
+
if (r.kind === "row") {
|
|
470
|
+
if (r.group === e.group) return;
|
|
471
|
+
x(
|
|
472
|
+
e.tab,
|
|
473
|
+
r.index === null ? { group: r.group } : { group: r.group, index: r.index },
|
|
474
|
+
e.hadFocus
|
|
475
|
+
);
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
!n || !Xt(e.group, r.group, n) || x(e.tab, n === "center" ? { group: r.group } : { group: r.group, edge: n }, e.hadFocus);
|
|
479
|
+
}
|
|
480
|
+
}, je = (t) => {
|
|
481
|
+
at == null || at(t), Qt();
|
|
482
|
+
}, Ve = (t, e, r) => {
|
|
483
|
+
if (e.type === "drop") return;
|
|
484
|
+
const n = t.tabs[r];
|
|
485
|
+
n !== void 0 && Ge(n);
|
|
486
|
+
}, Xe = (t, e, r) => {
|
|
487
|
+
var o, s;
|
|
488
|
+
const n = t.tabs[e];
|
|
489
|
+
n !== void 0 && x(n, { group: t.id, index: r }, (s = (o = M.current) == null ? void 0 : o.hadFocus) != null ? s : !1);
|
|
490
|
+
}, Qe = (t) => (e) => {
|
|
491
|
+
if (e.defaultPrevented || e.repeat || e.nativeEvent.isComposing) return;
|
|
492
|
+
const r = e.target, n = r == null ? void 0 : r.closest('[role="tab"]');
|
|
493
|
+
if (!n || At(n) !== t.id || n.getAttribute("aria-disabled") === "true") return;
|
|
494
|
+
const o = n.getAttribute("data-tab-id");
|
|
495
|
+
if (!o) return;
|
|
496
|
+
const s = L(e, ["Alt", "Shift", "ArrowLeft"]) ? "left" : L(e, ["Alt", "Shift", "ArrowRight"]) ? "right" : L(e, ["Alt", "Shift", "ArrowUp"]) ? "top" : L(e, ["Alt", "Shift", "ArrowDown"]) ? "bottom" : void 0;
|
|
497
|
+
if (s !== void 0) {
|
|
498
|
+
Fe(o, s) && e.preventDefault();
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
if (L(e, ["Mod", "Shift", "ArrowLeft"])) {
|
|
502
|
+
Z(o, -1) && e.preventDefault();
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
L(e, ["Mod", "Shift", "ArrowRight"]) && Z(o, 1) && e.preventDefault();
|
|
506
|
+
}, Zt = (t, e, r) => {
|
|
507
|
+
xe(e), V(t), r && Ce((n) => n + 1);
|
|
508
|
+
}, Ze = (t, e) => {
|
|
509
|
+
if (Ot === t) {
|
|
510
|
+
V(null);
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
Zt(t, e.currentTarget, e.detail === 0);
|
|
514
|
+
}, Je = (t, e) => {
|
|
515
|
+
e.defaultPrevented || e.repeat || e.key !== "ArrowDown" || (e.preventDefault(), Zt(t, e.currentTarget, !0));
|
|
516
|
+
}, tr = (t, e) => {
|
|
517
|
+
const r = t.active, n = t.tabs.length, o = r ? t.tabs.indexOf(r) : -1, s = w[e - 1], i = w[e + 1], l = (d) => () => {
|
|
518
|
+
r && d(r);
|
|
519
|
+
};
|
|
520
|
+
return [
|
|
521
|
+
{
|
|
522
|
+
key: "split-right",
|
|
523
|
+
label: S.splitRight,
|
|
524
|
+
// A split moves the group's selected tab out of it, so it takes two tabs to leave one behind.
|
|
525
|
+
disabled: !r || n < 2,
|
|
526
|
+
run: l((d) => x(d, { group: t.id, edge: "right" }))
|
|
527
|
+
},
|
|
528
|
+
{
|
|
529
|
+
key: "split-down",
|
|
530
|
+
label: S.splitDown,
|
|
531
|
+
disabled: !r || n < 2,
|
|
532
|
+
run: l((d) => x(d, { group: t.id, edge: "bottom" }))
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
key: "previous-group",
|
|
536
|
+
label: S.moveToPreviousGroup,
|
|
537
|
+
disabled: !r || !s,
|
|
538
|
+
run: l((d) => {
|
|
539
|
+
s && x(d, { group: s.id });
|
|
540
|
+
})
|
|
541
|
+
},
|
|
542
|
+
{
|
|
543
|
+
key: "next-group",
|
|
544
|
+
label: S.moveToNextGroup,
|
|
545
|
+
disabled: !r || !i,
|
|
546
|
+
run: l((d) => {
|
|
547
|
+
i && x(d, { group: i.id });
|
|
548
|
+
})
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
key: "move-left",
|
|
552
|
+
label: S.moveLeft,
|
|
553
|
+
disabled: !r || o <= 0,
|
|
554
|
+
run: l((d) => Z(d, -1))
|
|
555
|
+
},
|
|
556
|
+
{
|
|
557
|
+
key: "move-right",
|
|
558
|
+
label: S.moveRight,
|
|
559
|
+
disabled: !r || o < 0 || o >= n - 1,
|
|
560
|
+
run: l((d) => Z(d, 1))
|
|
561
|
+
}
|
|
562
|
+
];
|
|
563
|
+
}, er = (t) => {
|
|
564
|
+
var o, s;
|
|
565
|
+
const e = z(t), r = (e == null ? void 0 : e.disabled) === !0, n = encodeURIComponent(t);
|
|
566
|
+
return /* @__PURE__ */ g(
|
|
567
|
+
Pr,
|
|
568
|
+
{
|
|
569
|
+
id: `${A}-tab-${n}`,
|
|
570
|
+
"aria-controls": `${A}-panel-${n}`,
|
|
571
|
+
"aria-keyshortcuts": r ? void 0 : Gr,
|
|
572
|
+
"data-tab-id": t,
|
|
573
|
+
label: (o = e == null ? void 0 : e.label) != null ? o : t,
|
|
574
|
+
icon: e == null ? void 0 : e.icon,
|
|
575
|
+
closable: (s = e == null ? void 0 : e.closable) != null ? s : !0,
|
|
576
|
+
closeLabel: e == null ? void 0 : e.closeLabel,
|
|
577
|
+
actions: e == null ? void 0 : e.actions,
|
|
578
|
+
disabled: e == null ? void 0 : e.disabled,
|
|
579
|
+
onClose: (i, l) => Le(t, i, l)
|
|
580
|
+
},
|
|
581
|
+
t
|
|
582
|
+
);
|
|
583
|
+
}, rr = (t, e) => {
|
|
584
|
+
const r = `${A}-menu-${encodeURIComponent(t.id)}`, n = Ot === t.id, o = t.active ? Math.max(0, t.tabs.indexOf(t.active)) : 0;
|
|
585
|
+
return /* @__PURE__ */ B(
|
|
586
|
+
"div",
|
|
587
|
+
{
|
|
588
|
+
id: Mt(t.id),
|
|
589
|
+
className: J("smwb-tab-groups__header", {
|
|
590
|
+
"smwb-tab-groups__header--active": R.activeGroup === t.id
|
|
591
|
+
}),
|
|
592
|
+
"data-group-id": t.id,
|
|
593
|
+
style: Ue(t.id),
|
|
594
|
+
onKeyDown: Qe(t),
|
|
595
|
+
children: [
|
|
596
|
+
/* @__PURE__ */ g(
|
|
597
|
+
xr,
|
|
598
|
+
{
|
|
599
|
+
className: "smwb-tab-groups__tabs",
|
|
600
|
+
value: o,
|
|
601
|
+
onChange: (s, i) => Ve(t, s, i),
|
|
602
|
+
onReorder: (s, i) => Xe(t, s, i),
|
|
603
|
+
dense: ye,
|
|
604
|
+
scrollable: !0,
|
|
605
|
+
overflowMenu: !0,
|
|
606
|
+
"aria-label": S.group(e + 1, w.length),
|
|
607
|
+
children: t.tabs.map(er)
|
|
608
|
+
}
|
|
609
|
+
),
|
|
610
|
+
we && /* @__PURE__ */ B(ie, { children: [
|
|
611
|
+
/* @__PURE__ */ g(
|
|
612
|
+
"button",
|
|
613
|
+
{
|
|
614
|
+
type: "button",
|
|
615
|
+
className: "smwb-tab-groups__actions-trigger",
|
|
616
|
+
"aria-label": S.groupActions,
|
|
617
|
+
"aria-haspopup": "menu",
|
|
618
|
+
"aria-expanded": n,
|
|
619
|
+
"aria-controls": n ? r : void 0,
|
|
620
|
+
onClick: (s) => Ze(t.id, s),
|
|
621
|
+
onKeyDown: (s) => Je(t.id, s),
|
|
622
|
+
children: /* @__PURE__ */ g(sr, { name: "more_vert", size: 20 })
|
|
623
|
+
}
|
|
624
|
+
),
|
|
625
|
+
/* @__PURE__ */ g(
|
|
626
|
+
Cr,
|
|
627
|
+
{
|
|
628
|
+
id: r,
|
|
629
|
+
anchorElement: pt,
|
|
630
|
+
isOpen: n,
|
|
631
|
+
onClose: () => V(null),
|
|
632
|
+
placement: "bottom-end",
|
|
633
|
+
children: tr(t, e).map((s) => /* @__PURE__ */ g(
|
|
634
|
+
$r,
|
|
635
|
+
{
|
|
636
|
+
disabled: s.disabled,
|
|
637
|
+
onClick: () => {
|
|
638
|
+
V(null), s.run();
|
|
639
|
+
},
|
|
640
|
+
children: s.label
|
|
641
|
+
},
|
|
642
|
+
s.key
|
|
643
|
+
))
|
|
644
|
+
}
|
|
645
|
+
)
|
|
646
|
+
] })
|
|
647
|
+
]
|
|
648
|
+
},
|
|
649
|
+
`h:${t.id}`
|
|
650
|
+
);
|
|
651
|
+
}, nr = (t) => {
|
|
652
|
+
const e = Ut.get(t);
|
|
653
|
+
if (!e) return null;
|
|
654
|
+
const r = encodeURIComponent(t);
|
|
655
|
+
return /* @__PURE__ */ B(
|
|
656
|
+
"div",
|
|
657
|
+
{
|
|
658
|
+
id: kt(t),
|
|
659
|
+
className: "smwb-tab-panel smwb-tab-groups__panel",
|
|
660
|
+
role: "tabpanel",
|
|
661
|
+
"aria-labelledby": `${A}-tab-${r}`,
|
|
662
|
+
tabIndex: 0,
|
|
663
|
+
hidden: e.active !== t,
|
|
664
|
+
"data-tab-id": t,
|
|
665
|
+
"data-group-id": e.id,
|
|
666
|
+
style: Wt(e.id),
|
|
667
|
+
children: [
|
|
668
|
+
G.has(t) ? be(t) : null,
|
|
669
|
+
G.has(t) ? /* @__PURE__ */ g("span", { className: "smwb-tab-groups__panel-end", tabIndex: -1, "aria-hidden": "true" }) : null
|
|
670
|
+
]
|
|
671
|
+
},
|
|
672
|
+
`p:${t}`
|
|
673
|
+
);
|
|
674
|
+
}, or = (t, e) => {
|
|
675
|
+
var s;
|
|
676
|
+
const r = `s:${t.id}:${e}`, n = $e.get(`${t.id}:${e}`), o = (s = n == null ? void 0 : n.orientation) != null ? s : t.direction === "row" ? "vertical" : "horizontal";
|
|
677
|
+
return /* @__PURE__ */ g(
|
|
678
|
+
"div",
|
|
679
|
+
{
|
|
680
|
+
id: xt(t.id, e),
|
|
681
|
+
className: J("smwb-tab-groups__separator", `smwb-tab-groups__separator--${o}`, {
|
|
682
|
+
"smwb-tab-groups__separator--dragging": (O == null ? void 0 : O.key) === r
|
|
683
|
+
}),
|
|
684
|
+
role: "separator",
|
|
685
|
+
tabIndex: 0,
|
|
686
|
+
"aria-orientation": o,
|
|
687
|
+
"aria-valuenow": Lr(t, e),
|
|
688
|
+
"aria-valuemin": 0,
|
|
689
|
+
"aria-valuemax": 100,
|
|
690
|
+
"aria-label": S.resize,
|
|
691
|
+
"data-split-id": t.id,
|
|
692
|
+
"data-index": e,
|
|
693
|
+
style: n ? { gridArea: Er(n) } : void 0,
|
|
694
|
+
onKeyDown: (i) => qe(i, t, e),
|
|
695
|
+
onPointerDown: (i) => Ie(i, t, e, r),
|
|
696
|
+
onPointerMove: Be,
|
|
697
|
+
onPointerUp: Yt,
|
|
698
|
+
onPointerCancel: Yt
|
|
699
|
+
},
|
|
700
|
+
r
|
|
701
|
+
);
|
|
702
|
+
}, Jt = [], te = (t) => {
|
|
703
|
+
t.type !== "group" && t.children.forEach((e, r) => {
|
|
704
|
+
te(e), r < t.children.length - 1 && Jt.push(or(t, r));
|
|
705
|
+
});
|
|
706
|
+
}, ee = w.length === 1 && ((se = (oe = w[0]) == null ? void 0 : oe.tabs.length) != null ? se : 0) === 0;
|
|
707
|
+
let re;
|
|
708
|
+
return ee || (te(R.root), re = [
|
|
709
|
+
...zr(R.root).flatMap((t) => {
|
|
710
|
+
var r, n;
|
|
711
|
+
if (t.startsWith("h:")) return [Mt(t.slice(2))];
|
|
712
|
+
if (t.startsWith("p:")) return ((n = (r = mt.get(t.slice(2))) == null ? void 0 : r.tabs) != null ? n : []).map(kt);
|
|
713
|
+
const e = t.lastIndexOf(":");
|
|
714
|
+
return [xt(t.slice(2, e), Number(t.slice(e + 1)))];
|
|
715
|
+
}),
|
|
716
|
+
`${A}-status`
|
|
717
|
+
].join(" ")), /* @__PURE__ */ B(
|
|
718
|
+
"div",
|
|
719
|
+
{
|
|
720
|
+
...Ee,
|
|
721
|
+
id: A,
|
|
722
|
+
ref: Te,
|
|
723
|
+
className: J("smwb-tab-groups", { "smwb-tab-groups--split": w.length > 1 }, ve),
|
|
724
|
+
"data-testid": Se,
|
|
725
|
+
style: { ...Ae, gridTemplateColumns: gr(E), gridTemplateRows: mr(E) },
|
|
726
|
+
"aria-owns": re,
|
|
727
|
+
onFocus: ze,
|
|
728
|
+
onKeyDown: Ne,
|
|
729
|
+
onDragStart: He,
|
|
730
|
+
onDragOver: We,
|
|
731
|
+
onDrop: Ye,
|
|
732
|
+
onDragEnd: je,
|
|
733
|
+
children: [
|
|
734
|
+
ee ? /* @__PURE__ */ g("div", { className: "smwb-tab-groups__empty", children: he }) : /* @__PURE__ */ B(ie, { children: [
|
|
735
|
+
/* @__PURE__ */ g(u.Fragment, { children: w.map(rr) }, "headers"),
|
|
736
|
+
/* @__PURE__ */ g(u.Fragment, { children: Jt }, "separators"),
|
|
737
|
+
/* @__PURE__ */ g(u.Fragment, { children: X.map(nr) }, "panels"),
|
|
738
|
+
/* @__PURE__ */ g(u.Fragment, { children: ke && w.map((t) => {
|
|
739
|
+
const e = (j == null ? void 0 : j.group) === t.id ? j.zone : void 0;
|
|
740
|
+
return /* @__PURE__ */ g(
|
|
741
|
+
"div",
|
|
742
|
+
{
|
|
743
|
+
className: J("smwb-tab-groups__drop-target", e && `smwb-tab-groups__drop-target--${e}`),
|
|
744
|
+
"data-group-id": t.id,
|
|
745
|
+
"aria-hidden": "true",
|
|
746
|
+
style: Wt(t.id)
|
|
747
|
+
},
|
|
748
|
+
`d:${t.id}`
|
|
749
|
+
);
|
|
750
|
+
}) }, "drop-targets"),
|
|
751
|
+
/* @__PURE__ */ g(
|
|
752
|
+
"span",
|
|
753
|
+
{
|
|
754
|
+
ref: W,
|
|
755
|
+
className: "smwb-tab-groups__focus-guard",
|
|
756
|
+
tabIndex: 0,
|
|
757
|
+
onBlur: () => {
|
|
758
|
+
H.current = !1;
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
)
|
|
762
|
+
] }),
|
|
763
|
+
/* @__PURE__ */ g(
|
|
764
|
+
"div",
|
|
765
|
+
{
|
|
766
|
+
id: `${A}-status`,
|
|
767
|
+
className: "smwb-tab-groups__status",
|
|
768
|
+
role: "status",
|
|
769
|
+
"aria-atomic": "true",
|
|
770
|
+
"data-testid": "tab-groups-status",
|
|
771
|
+
children: _e
|
|
772
|
+
}
|
|
773
|
+
)
|
|
774
|
+
]
|
|
775
|
+
}
|
|
776
|
+
);
|
|
777
|
+
});
|
|
778
|
+
export {
|
|
779
|
+
rn as TabGroups
|
|
780
|
+
};
|
|
781
|
+
//# sourceMappingURL=tabGroups.js.map
|