@industry-theme/xterm-terminal-panel 0.5.5 → 0.5.6
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/index.js
CHANGED
|
@@ -1782,18 +1782,2720 @@ var TerminalPanel = ({
|
|
|
1782
1782
|
};
|
|
1783
1783
|
// src/panels/TabbedTerminalPanel.tsx
|
|
1784
1784
|
import { useTheme as useTheme6 } from "@principal-ade/industry-theme";
|
|
1785
|
+
|
|
1786
|
+
// node_modules/@principal-ade/panels/dist/index.esm.js
|
|
1787
|
+
import { jsx as e, jsxs as t, Fragment as n } from "react/jsx-runtime";
|
|
1788
|
+
import r, { useState as o, useRef as i, useCallback as a, useEffect as l, createContext as s, useContext as c, forwardRef as d, useImperativeHandle as u, useMemo as p, useLayoutEffect as h, memo as m, useReducer as f } from "react";
|
|
1789
|
+
|
|
1790
|
+
// node_modules/react-resizable-panels/dist/react-resizable-panels.browser.js
|
|
1791
|
+
import * as React2 from "react";
|
|
1792
|
+
import { createContext, useLayoutEffect, useRef as useRef3, forwardRef as forwardRef3, createElement, useContext, useImperativeHandle as useImperativeHandle2, useState as useState4, useCallback as useCallback3, useEffect as useEffect4, useMemo as useMemo2 } from "react";
|
|
1793
|
+
var PanelGroupContext = createContext(null);
|
|
1794
|
+
PanelGroupContext.displayName = "PanelGroupContext";
|
|
1795
|
+
var DATA_ATTRIBUTES = {
|
|
1796
|
+
group: "data-panel-group",
|
|
1797
|
+
groupDirection: "data-panel-group-direction",
|
|
1798
|
+
groupId: "data-panel-group-id",
|
|
1799
|
+
panel: "data-panel",
|
|
1800
|
+
panelCollapsible: "data-panel-collapsible",
|
|
1801
|
+
panelId: "data-panel-id",
|
|
1802
|
+
panelSize: "data-panel-size",
|
|
1803
|
+
resizeHandle: "data-resize-handle",
|
|
1804
|
+
resizeHandleActive: "data-resize-handle-active",
|
|
1805
|
+
resizeHandleEnabled: "data-panel-resize-handle-enabled",
|
|
1806
|
+
resizeHandleId: "data-panel-resize-handle-id",
|
|
1807
|
+
resizeHandleState: "data-resize-handle-state"
|
|
1808
|
+
};
|
|
1809
|
+
var PRECISION = 10;
|
|
1810
|
+
var useIsomorphicLayoutEffect = useLayoutEffect;
|
|
1811
|
+
var useId = React2["useId".toString()];
|
|
1812
|
+
var wrappedUseId = typeof useId === "function" ? useId : () => null;
|
|
1813
|
+
var counter = 0;
|
|
1814
|
+
function useUniqueId(idFromParams = null) {
|
|
1815
|
+
const idFromUseId = wrappedUseId();
|
|
1816
|
+
const idRef = useRef3(idFromParams || idFromUseId || null);
|
|
1817
|
+
if (idRef.current === null) {
|
|
1818
|
+
idRef.current = "" + counter++;
|
|
1819
|
+
}
|
|
1820
|
+
return idFromParams !== null && idFromParams !== undefined ? idFromParams : idRef.current;
|
|
1821
|
+
}
|
|
1822
|
+
function PanelWithForwardedRef({
|
|
1823
|
+
children,
|
|
1824
|
+
className: classNameFromProps = "",
|
|
1825
|
+
collapsedSize,
|
|
1826
|
+
collapsible,
|
|
1827
|
+
defaultSize,
|
|
1828
|
+
forwardedRef,
|
|
1829
|
+
id: idFromProps,
|
|
1830
|
+
maxSize,
|
|
1831
|
+
minSize,
|
|
1832
|
+
onCollapse,
|
|
1833
|
+
onExpand,
|
|
1834
|
+
onResize,
|
|
1835
|
+
order,
|
|
1836
|
+
style: styleFromProps,
|
|
1837
|
+
tagName: Type = "div",
|
|
1838
|
+
...rest
|
|
1839
|
+
}) {
|
|
1840
|
+
const context2 = useContext(PanelGroupContext);
|
|
1841
|
+
if (context2 === null) {
|
|
1842
|
+
throw Error(`Panel components must be rendered within a PanelGroup container`);
|
|
1843
|
+
}
|
|
1844
|
+
const {
|
|
1845
|
+
collapsePanel,
|
|
1846
|
+
expandPanel,
|
|
1847
|
+
getPanelSize,
|
|
1848
|
+
getPanelStyle,
|
|
1849
|
+
groupId,
|
|
1850
|
+
isPanelCollapsed,
|
|
1851
|
+
reevaluatePanelConstraints,
|
|
1852
|
+
registerPanel,
|
|
1853
|
+
resizePanel,
|
|
1854
|
+
unregisterPanel
|
|
1855
|
+
} = context2;
|
|
1856
|
+
const panelId = useUniqueId(idFromProps);
|
|
1857
|
+
const panelDataRef = useRef3({
|
|
1858
|
+
callbacks: {
|
|
1859
|
+
onCollapse,
|
|
1860
|
+
onExpand,
|
|
1861
|
+
onResize
|
|
1862
|
+
},
|
|
1863
|
+
constraints: {
|
|
1864
|
+
collapsedSize,
|
|
1865
|
+
collapsible,
|
|
1866
|
+
defaultSize,
|
|
1867
|
+
maxSize,
|
|
1868
|
+
minSize
|
|
1869
|
+
},
|
|
1870
|
+
id: panelId,
|
|
1871
|
+
idIsFromProps: idFromProps !== undefined,
|
|
1872
|
+
order
|
|
1873
|
+
});
|
|
1874
|
+
useRef3({
|
|
1875
|
+
didLogMissingDefaultSizeWarning: false
|
|
1876
|
+
});
|
|
1877
|
+
useIsomorphicLayoutEffect(() => {
|
|
1878
|
+
const {
|
|
1879
|
+
callbacks,
|
|
1880
|
+
constraints
|
|
1881
|
+
} = panelDataRef.current;
|
|
1882
|
+
const prevConstraints = {
|
|
1883
|
+
...constraints
|
|
1884
|
+
};
|
|
1885
|
+
panelDataRef.current.id = panelId;
|
|
1886
|
+
panelDataRef.current.idIsFromProps = idFromProps !== undefined;
|
|
1887
|
+
panelDataRef.current.order = order;
|
|
1888
|
+
callbacks.onCollapse = onCollapse;
|
|
1889
|
+
callbacks.onExpand = onExpand;
|
|
1890
|
+
callbacks.onResize = onResize;
|
|
1891
|
+
constraints.collapsedSize = collapsedSize;
|
|
1892
|
+
constraints.collapsible = collapsible;
|
|
1893
|
+
constraints.defaultSize = defaultSize;
|
|
1894
|
+
constraints.maxSize = maxSize;
|
|
1895
|
+
constraints.minSize = minSize;
|
|
1896
|
+
if (prevConstraints.collapsedSize !== constraints.collapsedSize || prevConstraints.collapsible !== constraints.collapsible || prevConstraints.maxSize !== constraints.maxSize || prevConstraints.minSize !== constraints.minSize) {
|
|
1897
|
+
reevaluatePanelConstraints(panelDataRef.current, prevConstraints);
|
|
1898
|
+
}
|
|
1899
|
+
});
|
|
1900
|
+
useIsomorphicLayoutEffect(() => {
|
|
1901
|
+
const panelData = panelDataRef.current;
|
|
1902
|
+
registerPanel(panelData);
|
|
1903
|
+
return () => {
|
|
1904
|
+
unregisterPanel(panelData);
|
|
1905
|
+
};
|
|
1906
|
+
}, [order, panelId, registerPanel, unregisterPanel]);
|
|
1907
|
+
useImperativeHandle2(forwardedRef, () => ({
|
|
1908
|
+
collapse: () => {
|
|
1909
|
+
collapsePanel(panelDataRef.current);
|
|
1910
|
+
},
|
|
1911
|
+
expand: (minSize2) => {
|
|
1912
|
+
expandPanel(panelDataRef.current, minSize2);
|
|
1913
|
+
},
|
|
1914
|
+
getId() {
|
|
1915
|
+
return panelId;
|
|
1916
|
+
},
|
|
1917
|
+
getSize() {
|
|
1918
|
+
return getPanelSize(panelDataRef.current);
|
|
1919
|
+
},
|
|
1920
|
+
isCollapsed() {
|
|
1921
|
+
return isPanelCollapsed(panelDataRef.current);
|
|
1922
|
+
},
|
|
1923
|
+
isExpanded() {
|
|
1924
|
+
return !isPanelCollapsed(panelDataRef.current);
|
|
1925
|
+
},
|
|
1926
|
+
resize: (size) => {
|
|
1927
|
+
resizePanel(panelDataRef.current, size);
|
|
1928
|
+
}
|
|
1929
|
+
}), [collapsePanel, expandPanel, getPanelSize, isPanelCollapsed, panelId, resizePanel]);
|
|
1930
|
+
const style = getPanelStyle(panelDataRef.current, defaultSize);
|
|
1931
|
+
return createElement(Type, {
|
|
1932
|
+
...rest,
|
|
1933
|
+
children,
|
|
1934
|
+
className: classNameFromProps,
|
|
1935
|
+
id: panelId,
|
|
1936
|
+
style: {
|
|
1937
|
+
...style,
|
|
1938
|
+
...styleFromProps
|
|
1939
|
+
},
|
|
1940
|
+
[DATA_ATTRIBUTES.groupId]: groupId,
|
|
1941
|
+
[DATA_ATTRIBUTES.panel]: "",
|
|
1942
|
+
[DATA_ATTRIBUTES.panelCollapsible]: collapsible || undefined,
|
|
1943
|
+
[DATA_ATTRIBUTES.panelId]: panelId,
|
|
1944
|
+
[DATA_ATTRIBUTES.panelSize]: parseFloat("" + style.flexGrow).toFixed(1)
|
|
1945
|
+
});
|
|
1946
|
+
}
|
|
1947
|
+
var Panel = forwardRef3((props, ref) => createElement(PanelWithForwardedRef, {
|
|
1948
|
+
...props,
|
|
1949
|
+
forwardedRef: ref
|
|
1950
|
+
}));
|
|
1951
|
+
PanelWithForwardedRef.displayName = "Panel";
|
|
1952
|
+
Panel.displayName = "forwardRef(Panel)";
|
|
1953
|
+
var nonce;
|
|
1954
|
+
function getNonce() {
|
|
1955
|
+
return nonce;
|
|
1956
|
+
}
|
|
1957
|
+
var currentCursorStyle = null;
|
|
1958
|
+
var enabled = true;
|
|
1959
|
+
var getCustomCursorStyleFunction = null;
|
|
1960
|
+
var prevRuleIndex = -1;
|
|
1961
|
+
var styleElement = null;
|
|
1962
|
+
function getCursorStyle(state, constraintFlags, isPointerDown) {
|
|
1963
|
+
const horizontalMin = (constraintFlags & EXCEEDED_HORIZONTAL_MIN) !== 0;
|
|
1964
|
+
const horizontalMax = (constraintFlags & EXCEEDED_HORIZONTAL_MAX) !== 0;
|
|
1965
|
+
const verticalMin = (constraintFlags & EXCEEDED_VERTICAL_MIN) !== 0;
|
|
1966
|
+
const verticalMax = (constraintFlags & EXCEEDED_VERTICAL_MAX) !== 0;
|
|
1967
|
+
if (getCustomCursorStyleFunction) {
|
|
1968
|
+
return getCustomCursorStyleFunction({
|
|
1969
|
+
exceedsHorizontalMaximum: horizontalMax,
|
|
1970
|
+
exceedsHorizontalMinimum: horizontalMin,
|
|
1971
|
+
exceedsVerticalMaximum: verticalMax,
|
|
1972
|
+
exceedsVerticalMinimum: verticalMin,
|
|
1973
|
+
intersectsHorizontalDragHandle: state === "horizontal" || state === "intersection",
|
|
1974
|
+
intersectsVerticalDragHandle: state === "vertical" || state === "intersection",
|
|
1975
|
+
isPointerDown
|
|
1976
|
+
});
|
|
1977
|
+
}
|
|
1978
|
+
if (constraintFlags) {
|
|
1979
|
+
if (horizontalMin) {
|
|
1980
|
+
if (verticalMin) {
|
|
1981
|
+
return "se-resize";
|
|
1982
|
+
} else if (verticalMax) {
|
|
1983
|
+
return "ne-resize";
|
|
1984
|
+
} else {
|
|
1985
|
+
return "e-resize";
|
|
1986
|
+
}
|
|
1987
|
+
} else if (horizontalMax) {
|
|
1988
|
+
if (verticalMin) {
|
|
1989
|
+
return "sw-resize";
|
|
1990
|
+
} else if (verticalMax) {
|
|
1991
|
+
return "nw-resize";
|
|
1992
|
+
} else {
|
|
1993
|
+
return "w-resize";
|
|
1994
|
+
}
|
|
1995
|
+
} else if (verticalMin) {
|
|
1996
|
+
return "s-resize";
|
|
1997
|
+
} else if (verticalMax) {
|
|
1998
|
+
return "n-resize";
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
switch (state) {
|
|
2002
|
+
case "horizontal":
|
|
2003
|
+
return "ew-resize";
|
|
2004
|
+
case "intersection":
|
|
2005
|
+
return "move";
|
|
2006
|
+
case "vertical":
|
|
2007
|
+
return "ns-resize";
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
function resetGlobalCursorStyle() {
|
|
2011
|
+
if (styleElement !== null) {
|
|
2012
|
+
document.head.removeChild(styleElement);
|
|
2013
|
+
currentCursorStyle = null;
|
|
2014
|
+
styleElement = null;
|
|
2015
|
+
prevRuleIndex = -1;
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
function setGlobalCursorStyle(state, constraintFlags, isPointerDown) {
|
|
2019
|
+
var _styleElement$sheet$i, _styleElement$sheet2;
|
|
2020
|
+
if (!enabled) {
|
|
2021
|
+
return;
|
|
2022
|
+
}
|
|
2023
|
+
const style = getCursorStyle(state, constraintFlags, isPointerDown);
|
|
2024
|
+
if (currentCursorStyle === style) {
|
|
2025
|
+
return;
|
|
2026
|
+
}
|
|
2027
|
+
currentCursorStyle = style;
|
|
2028
|
+
if (styleElement === null) {
|
|
2029
|
+
styleElement = document.createElement("style");
|
|
2030
|
+
const nonce2 = getNonce();
|
|
2031
|
+
if (nonce2) {
|
|
2032
|
+
styleElement.setAttribute("nonce", nonce2);
|
|
2033
|
+
}
|
|
2034
|
+
document.head.appendChild(styleElement);
|
|
2035
|
+
}
|
|
2036
|
+
if (prevRuleIndex >= 0) {
|
|
2037
|
+
var _styleElement$sheet;
|
|
2038
|
+
(_styleElement$sheet = styleElement.sheet) === null || _styleElement$sheet === undefined || _styleElement$sheet.removeRule(prevRuleIndex);
|
|
2039
|
+
}
|
|
2040
|
+
prevRuleIndex = (_styleElement$sheet$i = (_styleElement$sheet2 = styleElement.sheet) === null || _styleElement$sheet2 === undefined ? undefined : _styleElement$sheet2.insertRule(`*{cursor: ${style} !important;}`)) !== null && _styleElement$sheet$i !== undefined ? _styleElement$sheet$i : -1;
|
|
2041
|
+
}
|
|
2042
|
+
function isKeyDown(event) {
|
|
2043
|
+
return event.type === "keydown";
|
|
2044
|
+
}
|
|
2045
|
+
function isPointerEvent(event) {
|
|
2046
|
+
return event.type.startsWith("pointer");
|
|
2047
|
+
}
|
|
2048
|
+
function isMouseEvent(event) {
|
|
2049
|
+
return event.type.startsWith("mouse");
|
|
2050
|
+
}
|
|
2051
|
+
function getResizeEventCoordinates(event) {
|
|
2052
|
+
if (isPointerEvent(event)) {
|
|
2053
|
+
if (event.isPrimary) {
|
|
2054
|
+
return {
|
|
2055
|
+
x: event.clientX,
|
|
2056
|
+
y: event.clientY
|
|
2057
|
+
};
|
|
2058
|
+
}
|
|
2059
|
+
} else if (isMouseEvent(event)) {
|
|
2060
|
+
return {
|
|
2061
|
+
x: event.clientX,
|
|
2062
|
+
y: event.clientY
|
|
2063
|
+
};
|
|
2064
|
+
}
|
|
2065
|
+
return {
|
|
2066
|
+
x: Infinity,
|
|
2067
|
+
y: Infinity
|
|
2068
|
+
};
|
|
2069
|
+
}
|
|
2070
|
+
function getInputType() {
|
|
2071
|
+
if (typeof matchMedia === "function") {
|
|
2072
|
+
return matchMedia("(pointer:coarse)").matches ? "coarse" : "fine";
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
function intersects(rectOne, rectTwo, strict) {
|
|
2076
|
+
if (strict) {
|
|
2077
|
+
return rectOne.x < rectTwo.x + rectTwo.width && rectOne.x + rectOne.width > rectTwo.x && rectOne.y < rectTwo.y + rectTwo.height && rectOne.y + rectOne.height > rectTwo.y;
|
|
2078
|
+
} else {
|
|
2079
|
+
return rectOne.x <= rectTwo.x + rectTwo.width && rectOne.x + rectOne.width >= rectTwo.x && rectOne.y <= rectTwo.y + rectTwo.height && rectOne.y + rectOne.height >= rectTwo.y;
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
function compare(a, b) {
|
|
2083
|
+
if (a === b)
|
|
2084
|
+
throw new Error("Cannot compare node with itself");
|
|
2085
|
+
const ancestors = {
|
|
2086
|
+
a: get_ancestors(a),
|
|
2087
|
+
b: get_ancestors(b)
|
|
2088
|
+
};
|
|
2089
|
+
let common_ancestor;
|
|
2090
|
+
while (ancestors.a.at(-1) === ancestors.b.at(-1)) {
|
|
2091
|
+
a = ancestors.a.pop();
|
|
2092
|
+
b = ancestors.b.pop();
|
|
2093
|
+
common_ancestor = a;
|
|
2094
|
+
}
|
|
2095
|
+
assert(common_ancestor, "Stacking order can only be calculated for elements with a common ancestor");
|
|
2096
|
+
const z_indexes = {
|
|
2097
|
+
a: get_z_index(find_stacking_context(ancestors.a)),
|
|
2098
|
+
b: get_z_index(find_stacking_context(ancestors.b))
|
|
2099
|
+
};
|
|
2100
|
+
if (z_indexes.a === z_indexes.b) {
|
|
2101
|
+
const children = common_ancestor.childNodes;
|
|
2102
|
+
const furthest_ancestors = {
|
|
2103
|
+
a: ancestors.a.at(-1),
|
|
2104
|
+
b: ancestors.b.at(-1)
|
|
2105
|
+
};
|
|
2106
|
+
let i = children.length;
|
|
2107
|
+
while (i--) {
|
|
2108
|
+
const child = children[i];
|
|
2109
|
+
if (child === furthest_ancestors.a)
|
|
2110
|
+
return 1;
|
|
2111
|
+
if (child === furthest_ancestors.b)
|
|
2112
|
+
return -1;
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2115
|
+
return Math.sign(z_indexes.a - z_indexes.b);
|
|
2116
|
+
}
|
|
2117
|
+
var props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;
|
|
2118
|
+
function is_flex_item(node) {
|
|
2119
|
+
var _get_parent;
|
|
2120
|
+
const display = getComputedStyle((_get_parent = get_parent(node)) !== null && _get_parent !== undefined ? _get_parent : node).display;
|
|
2121
|
+
return display === "flex" || display === "inline-flex";
|
|
2122
|
+
}
|
|
2123
|
+
function creates_stacking_context(node) {
|
|
2124
|
+
const style = getComputedStyle(node);
|
|
2125
|
+
if (style.position === "fixed")
|
|
2126
|
+
return true;
|
|
2127
|
+
if (style.zIndex !== "auto" && (style.position !== "static" || is_flex_item(node)))
|
|
2128
|
+
return true;
|
|
2129
|
+
if (+style.opacity < 1)
|
|
2130
|
+
return true;
|
|
2131
|
+
if ("transform" in style && style.transform !== "none")
|
|
2132
|
+
return true;
|
|
2133
|
+
if ("webkitTransform" in style && style.webkitTransform !== "none")
|
|
2134
|
+
return true;
|
|
2135
|
+
if ("mixBlendMode" in style && style.mixBlendMode !== "normal")
|
|
2136
|
+
return true;
|
|
2137
|
+
if ("filter" in style && style.filter !== "none")
|
|
2138
|
+
return true;
|
|
2139
|
+
if ("webkitFilter" in style && style.webkitFilter !== "none")
|
|
2140
|
+
return true;
|
|
2141
|
+
if ("isolation" in style && style.isolation === "isolate")
|
|
2142
|
+
return true;
|
|
2143
|
+
if (props.test(style.willChange))
|
|
2144
|
+
return true;
|
|
2145
|
+
if (style.webkitOverflowScrolling === "touch")
|
|
2146
|
+
return true;
|
|
2147
|
+
return false;
|
|
2148
|
+
}
|
|
2149
|
+
function find_stacking_context(nodes) {
|
|
2150
|
+
let i = nodes.length;
|
|
2151
|
+
while (i--) {
|
|
2152
|
+
const node = nodes[i];
|
|
2153
|
+
assert(node, "Missing node");
|
|
2154
|
+
if (creates_stacking_context(node))
|
|
2155
|
+
return node;
|
|
2156
|
+
}
|
|
2157
|
+
return null;
|
|
2158
|
+
}
|
|
2159
|
+
function get_z_index(node) {
|
|
2160
|
+
return node && Number(getComputedStyle(node).zIndex) || 0;
|
|
2161
|
+
}
|
|
2162
|
+
function get_ancestors(node) {
|
|
2163
|
+
const ancestors = [];
|
|
2164
|
+
while (node) {
|
|
2165
|
+
ancestors.push(node);
|
|
2166
|
+
node = get_parent(node);
|
|
2167
|
+
}
|
|
2168
|
+
return ancestors;
|
|
2169
|
+
}
|
|
2170
|
+
function get_parent(node) {
|
|
2171
|
+
const {
|
|
2172
|
+
parentNode
|
|
2173
|
+
} = node;
|
|
2174
|
+
if (parentNode && parentNode instanceof ShadowRoot) {
|
|
2175
|
+
return parentNode.host;
|
|
2176
|
+
}
|
|
2177
|
+
return parentNode;
|
|
2178
|
+
}
|
|
2179
|
+
var EXCEEDED_HORIZONTAL_MIN = 1;
|
|
2180
|
+
var EXCEEDED_HORIZONTAL_MAX = 2;
|
|
2181
|
+
var EXCEEDED_VERTICAL_MIN = 4;
|
|
2182
|
+
var EXCEEDED_VERTICAL_MAX = 8;
|
|
2183
|
+
var isCoarsePointer = getInputType() === "coarse";
|
|
2184
|
+
var intersectingHandles = [];
|
|
2185
|
+
var isPointerDown = false;
|
|
2186
|
+
var ownerDocumentCounts = new Map;
|
|
2187
|
+
var panelConstraintFlags = new Map;
|
|
2188
|
+
var registeredResizeHandlers = new Set;
|
|
2189
|
+
function registerResizeHandle(resizeHandleId, element, direction, hitAreaMargins, setResizeHandlerState) {
|
|
2190
|
+
var _ownerDocumentCounts$;
|
|
2191
|
+
const {
|
|
2192
|
+
ownerDocument
|
|
2193
|
+
} = element;
|
|
2194
|
+
const data = {
|
|
2195
|
+
direction,
|
|
2196
|
+
element,
|
|
2197
|
+
hitAreaMargins,
|
|
2198
|
+
setResizeHandlerState
|
|
2199
|
+
};
|
|
2200
|
+
const count = (_ownerDocumentCounts$ = ownerDocumentCounts.get(ownerDocument)) !== null && _ownerDocumentCounts$ !== undefined ? _ownerDocumentCounts$ : 0;
|
|
2201
|
+
ownerDocumentCounts.set(ownerDocument, count + 1);
|
|
2202
|
+
registeredResizeHandlers.add(data);
|
|
2203
|
+
updateListeners();
|
|
2204
|
+
return function unregisterResizeHandle() {
|
|
2205
|
+
var _ownerDocumentCounts$2;
|
|
2206
|
+
panelConstraintFlags.delete(resizeHandleId);
|
|
2207
|
+
registeredResizeHandlers.delete(data);
|
|
2208
|
+
const count2 = (_ownerDocumentCounts$2 = ownerDocumentCounts.get(ownerDocument)) !== null && _ownerDocumentCounts$2 !== undefined ? _ownerDocumentCounts$2 : 1;
|
|
2209
|
+
ownerDocumentCounts.set(ownerDocument, count2 - 1);
|
|
2210
|
+
updateListeners();
|
|
2211
|
+
if (count2 === 1) {
|
|
2212
|
+
ownerDocumentCounts.delete(ownerDocument);
|
|
2213
|
+
}
|
|
2214
|
+
if (intersectingHandles.includes(data)) {
|
|
2215
|
+
const index = intersectingHandles.indexOf(data);
|
|
2216
|
+
if (index >= 0) {
|
|
2217
|
+
intersectingHandles.splice(index, 1);
|
|
2218
|
+
}
|
|
2219
|
+
updateCursor();
|
|
2220
|
+
setResizeHandlerState("up", true, null);
|
|
2221
|
+
}
|
|
2222
|
+
};
|
|
2223
|
+
}
|
|
2224
|
+
function handlePointerDown(event) {
|
|
2225
|
+
const {
|
|
2226
|
+
target
|
|
2227
|
+
} = event;
|
|
2228
|
+
const {
|
|
2229
|
+
x,
|
|
2230
|
+
y
|
|
2231
|
+
} = getResizeEventCoordinates(event);
|
|
2232
|
+
isPointerDown = true;
|
|
2233
|
+
recalculateIntersectingHandles({
|
|
2234
|
+
target,
|
|
2235
|
+
x,
|
|
2236
|
+
y
|
|
2237
|
+
});
|
|
2238
|
+
updateListeners();
|
|
2239
|
+
if (intersectingHandles.length > 0) {
|
|
2240
|
+
updateResizeHandlerStates("down", event);
|
|
2241
|
+
updateCursor();
|
|
2242
|
+
event.preventDefault();
|
|
2243
|
+
if (!isWithinResizeHandle(target)) {
|
|
2244
|
+
event.stopImmediatePropagation();
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2248
|
+
function handlePointerMove(event) {
|
|
2249
|
+
const {
|
|
2250
|
+
x,
|
|
2251
|
+
y
|
|
2252
|
+
} = getResizeEventCoordinates(event);
|
|
2253
|
+
if (isPointerDown && event.type !== "pointerleave" && event.buttons === 0) {
|
|
2254
|
+
isPointerDown = false;
|
|
2255
|
+
updateResizeHandlerStates("up", event);
|
|
2256
|
+
}
|
|
2257
|
+
if (!isPointerDown) {
|
|
2258
|
+
const {
|
|
2259
|
+
target
|
|
2260
|
+
} = event;
|
|
2261
|
+
recalculateIntersectingHandles({
|
|
2262
|
+
target,
|
|
2263
|
+
x,
|
|
2264
|
+
y
|
|
2265
|
+
});
|
|
2266
|
+
}
|
|
2267
|
+
updateResizeHandlerStates("move", event);
|
|
2268
|
+
updateCursor();
|
|
2269
|
+
if (intersectingHandles.length > 0) {
|
|
2270
|
+
event.preventDefault();
|
|
2271
|
+
}
|
|
2272
|
+
}
|
|
2273
|
+
function handlePointerUp(event) {
|
|
2274
|
+
const {
|
|
2275
|
+
target
|
|
2276
|
+
} = event;
|
|
2277
|
+
const {
|
|
2278
|
+
x,
|
|
2279
|
+
y
|
|
2280
|
+
} = getResizeEventCoordinates(event);
|
|
2281
|
+
panelConstraintFlags.clear();
|
|
2282
|
+
isPointerDown = false;
|
|
2283
|
+
if (intersectingHandles.length > 0) {
|
|
2284
|
+
event.preventDefault();
|
|
2285
|
+
if (!isWithinResizeHandle(target)) {
|
|
2286
|
+
event.stopImmediatePropagation();
|
|
2287
|
+
}
|
|
2288
|
+
}
|
|
2289
|
+
updateResizeHandlerStates("up", event);
|
|
2290
|
+
recalculateIntersectingHandles({
|
|
2291
|
+
target,
|
|
2292
|
+
x,
|
|
2293
|
+
y
|
|
2294
|
+
});
|
|
2295
|
+
updateCursor();
|
|
2296
|
+
updateListeners();
|
|
2297
|
+
}
|
|
2298
|
+
function isWithinResizeHandle(element) {
|
|
2299
|
+
let currentElement = element;
|
|
2300
|
+
while (currentElement) {
|
|
2301
|
+
if (currentElement.hasAttribute(DATA_ATTRIBUTES.resizeHandle)) {
|
|
2302
|
+
return true;
|
|
2303
|
+
}
|
|
2304
|
+
currentElement = currentElement.parentElement;
|
|
2305
|
+
}
|
|
2306
|
+
return false;
|
|
2307
|
+
}
|
|
2308
|
+
function recalculateIntersectingHandles({
|
|
2309
|
+
target,
|
|
2310
|
+
x,
|
|
2311
|
+
y
|
|
2312
|
+
}) {
|
|
2313
|
+
intersectingHandles.splice(0);
|
|
2314
|
+
let targetElement = null;
|
|
2315
|
+
if (target instanceof HTMLElement || target instanceof SVGElement) {
|
|
2316
|
+
targetElement = target;
|
|
2317
|
+
}
|
|
2318
|
+
registeredResizeHandlers.forEach((data) => {
|
|
2319
|
+
const {
|
|
2320
|
+
element: dragHandleElement,
|
|
2321
|
+
hitAreaMargins
|
|
2322
|
+
} = data;
|
|
2323
|
+
const dragHandleRect = dragHandleElement.getBoundingClientRect();
|
|
2324
|
+
const {
|
|
2325
|
+
bottom,
|
|
2326
|
+
left,
|
|
2327
|
+
right,
|
|
2328
|
+
top
|
|
2329
|
+
} = dragHandleRect;
|
|
2330
|
+
const margin = isCoarsePointer ? hitAreaMargins.coarse : hitAreaMargins.fine;
|
|
2331
|
+
const eventIntersects = x >= left - margin && x <= right + margin && y >= top - margin && y <= bottom + margin;
|
|
2332
|
+
if (eventIntersects) {
|
|
2333
|
+
if (targetElement !== null && document.contains(targetElement) && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) && compare(targetElement, dragHandleElement) > 0) {
|
|
2334
|
+
let currentElement = targetElement;
|
|
2335
|
+
let didIntersect = false;
|
|
2336
|
+
while (currentElement) {
|
|
2337
|
+
if (currentElement.contains(dragHandleElement)) {
|
|
2338
|
+
break;
|
|
2339
|
+
} else if (intersects(currentElement.getBoundingClientRect(), dragHandleRect, true)) {
|
|
2340
|
+
didIntersect = true;
|
|
2341
|
+
break;
|
|
2342
|
+
}
|
|
2343
|
+
currentElement = currentElement.parentElement;
|
|
2344
|
+
}
|
|
2345
|
+
if (didIntersect) {
|
|
2346
|
+
return;
|
|
2347
|
+
}
|
|
2348
|
+
}
|
|
2349
|
+
intersectingHandles.push(data);
|
|
2350
|
+
}
|
|
2351
|
+
});
|
|
2352
|
+
}
|
|
2353
|
+
function reportConstraintsViolation(resizeHandleId, flag) {
|
|
2354
|
+
panelConstraintFlags.set(resizeHandleId, flag);
|
|
2355
|
+
}
|
|
2356
|
+
function updateCursor() {
|
|
2357
|
+
let intersectsHorizontal = false;
|
|
2358
|
+
let intersectsVertical = false;
|
|
2359
|
+
intersectingHandles.forEach((data) => {
|
|
2360
|
+
const {
|
|
2361
|
+
direction
|
|
2362
|
+
} = data;
|
|
2363
|
+
if (direction === "horizontal") {
|
|
2364
|
+
intersectsHorizontal = true;
|
|
2365
|
+
} else {
|
|
2366
|
+
intersectsVertical = true;
|
|
2367
|
+
}
|
|
2368
|
+
});
|
|
2369
|
+
let constraintFlags = 0;
|
|
2370
|
+
panelConstraintFlags.forEach((flag) => {
|
|
2371
|
+
constraintFlags |= flag;
|
|
2372
|
+
});
|
|
2373
|
+
if (intersectsHorizontal && intersectsVertical) {
|
|
2374
|
+
setGlobalCursorStyle("intersection", constraintFlags, isPointerDown);
|
|
2375
|
+
} else if (intersectsHorizontal) {
|
|
2376
|
+
setGlobalCursorStyle("horizontal", constraintFlags, isPointerDown);
|
|
2377
|
+
} else if (intersectsVertical) {
|
|
2378
|
+
setGlobalCursorStyle("vertical", constraintFlags, isPointerDown);
|
|
2379
|
+
} else {
|
|
2380
|
+
resetGlobalCursorStyle();
|
|
2381
|
+
}
|
|
2382
|
+
}
|
|
2383
|
+
var listenersAbortController;
|
|
2384
|
+
function updateListeners() {
|
|
2385
|
+
var _listenersAbortContro;
|
|
2386
|
+
(_listenersAbortContro = listenersAbortController) === null || _listenersAbortContro === undefined || _listenersAbortContro.abort();
|
|
2387
|
+
listenersAbortController = new AbortController;
|
|
2388
|
+
const options = {
|
|
2389
|
+
capture: true,
|
|
2390
|
+
signal: listenersAbortController.signal
|
|
2391
|
+
};
|
|
2392
|
+
if (!registeredResizeHandlers.size) {
|
|
2393
|
+
return;
|
|
2394
|
+
}
|
|
2395
|
+
if (isPointerDown) {
|
|
2396
|
+
if (intersectingHandles.length > 0) {
|
|
2397
|
+
ownerDocumentCounts.forEach((count, ownerDocument) => {
|
|
2398
|
+
const {
|
|
2399
|
+
body
|
|
2400
|
+
} = ownerDocument;
|
|
2401
|
+
if (count > 0) {
|
|
2402
|
+
body.addEventListener("contextmenu", handlePointerUp, options);
|
|
2403
|
+
body.addEventListener("pointerleave", handlePointerMove, options);
|
|
2404
|
+
body.addEventListener("pointermove", handlePointerMove, options);
|
|
2405
|
+
}
|
|
2406
|
+
});
|
|
2407
|
+
}
|
|
2408
|
+
ownerDocumentCounts.forEach((_, ownerDocument) => {
|
|
2409
|
+
const {
|
|
2410
|
+
body
|
|
2411
|
+
} = ownerDocument;
|
|
2412
|
+
body.addEventListener("pointerup", handlePointerUp, options);
|
|
2413
|
+
body.addEventListener("pointercancel", handlePointerUp, options);
|
|
2414
|
+
});
|
|
2415
|
+
} else {
|
|
2416
|
+
ownerDocumentCounts.forEach((count, ownerDocument) => {
|
|
2417
|
+
const {
|
|
2418
|
+
body
|
|
2419
|
+
} = ownerDocument;
|
|
2420
|
+
if (count > 0) {
|
|
2421
|
+
body.addEventListener("pointerdown", handlePointerDown, options);
|
|
2422
|
+
body.addEventListener("pointermove", handlePointerMove, options);
|
|
2423
|
+
}
|
|
2424
|
+
});
|
|
2425
|
+
}
|
|
2426
|
+
}
|
|
2427
|
+
function updateResizeHandlerStates(action, event) {
|
|
2428
|
+
registeredResizeHandlers.forEach((data) => {
|
|
2429
|
+
const {
|
|
2430
|
+
setResizeHandlerState
|
|
2431
|
+
} = data;
|
|
2432
|
+
const isActive = intersectingHandles.includes(data);
|
|
2433
|
+
setResizeHandlerState(action, isActive, event);
|
|
2434
|
+
});
|
|
2435
|
+
}
|
|
2436
|
+
function useForceUpdate() {
|
|
2437
|
+
const [_, setCount] = useState4(0);
|
|
2438
|
+
return useCallback3(() => setCount((prevCount) => prevCount + 1), []);
|
|
2439
|
+
}
|
|
2440
|
+
function assert(expectedCondition, message) {
|
|
2441
|
+
if (!expectedCondition) {
|
|
2442
|
+
console.error(message);
|
|
2443
|
+
throw Error(message);
|
|
2444
|
+
}
|
|
2445
|
+
}
|
|
2446
|
+
function fuzzyCompareNumbers(actual, expected, fractionDigits = PRECISION) {
|
|
2447
|
+
if (actual.toFixed(fractionDigits) === expected.toFixed(fractionDigits)) {
|
|
2448
|
+
return 0;
|
|
2449
|
+
} else {
|
|
2450
|
+
return actual > expected ? 1 : -1;
|
|
2451
|
+
}
|
|
2452
|
+
}
|
|
2453
|
+
function fuzzyNumbersEqual$1(actual, expected, fractionDigits = PRECISION) {
|
|
2454
|
+
return fuzzyCompareNumbers(actual, expected, fractionDigits) === 0;
|
|
2455
|
+
}
|
|
2456
|
+
function fuzzyNumbersEqual(actual, expected, fractionDigits) {
|
|
2457
|
+
return fuzzyCompareNumbers(actual, expected, fractionDigits) === 0;
|
|
2458
|
+
}
|
|
2459
|
+
function fuzzyLayoutsEqual(actual, expected, fractionDigits) {
|
|
2460
|
+
if (actual.length !== expected.length) {
|
|
2461
|
+
return false;
|
|
2462
|
+
}
|
|
2463
|
+
for (let index = 0;index < actual.length; index++) {
|
|
2464
|
+
const actualSize = actual[index];
|
|
2465
|
+
const expectedSize = expected[index];
|
|
2466
|
+
if (!fuzzyNumbersEqual(actualSize, expectedSize, fractionDigits)) {
|
|
2467
|
+
return false;
|
|
2468
|
+
}
|
|
2469
|
+
}
|
|
2470
|
+
return true;
|
|
2471
|
+
}
|
|
2472
|
+
function resizePanel({
|
|
2473
|
+
panelConstraints: panelConstraintsArray,
|
|
2474
|
+
panelIndex,
|
|
2475
|
+
size
|
|
2476
|
+
}) {
|
|
2477
|
+
const panelConstraints = panelConstraintsArray[panelIndex];
|
|
2478
|
+
assert(panelConstraints != null, `Panel constraints not found for index ${panelIndex}`);
|
|
2479
|
+
let {
|
|
2480
|
+
collapsedSize = 0,
|
|
2481
|
+
collapsible,
|
|
2482
|
+
maxSize = 100,
|
|
2483
|
+
minSize = 0
|
|
2484
|
+
} = panelConstraints;
|
|
2485
|
+
if (fuzzyCompareNumbers(size, minSize) < 0) {
|
|
2486
|
+
if (collapsible) {
|
|
2487
|
+
const halfwayPoint = (collapsedSize + minSize) / 2;
|
|
2488
|
+
if (fuzzyCompareNumbers(size, halfwayPoint) < 0) {
|
|
2489
|
+
size = collapsedSize;
|
|
2490
|
+
} else {
|
|
2491
|
+
size = minSize;
|
|
2492
|
+
}
|
|
2493
|
+
} else {
|
|
2494
|
+
size = minSize;
|
|
2495
|
+
}
|
|
2496
|
+
}
|
|
2497
|
+
size = Math.min(maxSize, size);
|
|
2498
|
+
size = parseFloat(size.toFixed(PRECISION));
|
|
2499
|
+
return size;
|
|
2500
|
+
}
|
|
2501
|
+
function adjustLayoutByDelta({
|
|
2502
|
+
delta,
|
|
2503
|
+
initialLayout,
|
|
2504
|
+
panelConstraints: panelConstraintsArray,
|
|
2505
|
+
pivotIndices,
|
|
2506
|
+
prevLayout,
|
|
2507
|
+
trigger
|
|
2508
|
+
}) {
|
|
2509
|
+
if (fuzzyNumbersEqual(delta, 0)) {
|
|
2510
|
+
return initialLayout;
|
|
2511
|
+
}
|
|
2512
|
+
const nextLayout = [...initialLayout];
|
|
2513
|
+
const [firstPivotIndex, secondPivotIndex] = pivotIndices;
|
|
2514
|
+
assert(firstPivotIndex != null, "Invalid first pivot index");
|
|
2515
|
+
assert(secondPivotIndex != null, "Invalid second pivot index");
|
|
2516
|
+
let deltaApplied = 0;
|
|
2517
|
+
{
|
|
2518
|
+
if (trigger === "keyboard") {
|
|
2519
|
+
{
|
|
2520
|
+
const index = delta < 0 ? secondPivotIndex : firstPivotIndex;
|
|
2521
|
+
const panelConstraints = panelConstraintsArray[index];
|
|
2522
|
+
assert(panelConstraints, `Panel constraints not found for index ${index}`);
|
|
2523
|
+
const {
|
|
2524
|
+
collapsedSize = 0,
|
|
2525
|
+
collapsible,
|
|
2526
|
+
minSize = 0
|
|
2527
|
+
} = panelConstraints;
|
|
2528
|
+
if (collapsible) {
|
|
2529
|
+
const prevSize = initialLayout[index];
|
|
2530
|
+
assert(prevSize != null, `Previous layout not found for panel index ${index}`);
|
|
2531
|
+
if (fuzzyNumbersEqual(prevSize, collapsedSize)) {
|
|
2532
|
+
const localDelta = minSize - prevSize;
|
|
2533
|
+
if (fuzzyCompareNumbers(localDelta, Math.abs(delta)) > 0) {
|
|
2534
|
+
delta = delta < 0 ? 0 - localDelta : localDelta;
|
|
2535
|
+
}
|
|
2536
|
+
}
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
{
|
|
2540
|
+
const index = delta < 0 ? firstPivotIndex : secondPivotIndex;
|
|
2541
|
+
const panelConstraints = panelConstraintsArray[index];
|
|
2542
|
+
assert(panelConstraints, `No panel constraints found for index ${index}`);
|
|
2543
|
+
const {
|
|
2544
|
+
collapsedSize = 0,
|
|
2545
|
+
collapsible,
|
|
2546
|
+
minSize = 0
|
|
2547
|
+
} = panelConstraints;
|
|
2548
|
+
if (collapsible) {
|
|
2549
|
+
const prevSize = initialLayout[index];
|
|
2550
|
+
assert(prevSize != null, `Previous layout not found for panel index ${index}`);
|
|
2551
|
+
if (fuzzyNumbersEqual(prevSize, minSize)) {
|
|
2552
|
+
const localDelta = prevSize - collapsedSize;
|
|
2553
|
+
if (fuzzyCompareNumbers(localDelta, Math.abs(delta)) > 0) {
|
|
2554
|
+
delta = delta < 0 ? 0 - localDelta : localDelta;
|
|
2555
|
+
}
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
}
|
|
2559
|
+
}
|
|
2560
|
+
}
|
|
2561
|
+
{
|
|
2562
|
+
const increment = delta < 0 ? 1 : -1;
|
|
2563
|
+
let index = delta < 0 ? secondPivotIndex : firstPivotIndex;
|
|
2564
|
+
let maxAvailableDelta = 0;
|
|
2565
|
+
while (true) {
|
|
2566
|
+
const prevSize = initialLayout[index];
|
|
2567
|
+
assert(prevSize != null, `Previous layout not found for panel index ${index}`);
|
|
2568
|
+
const maxSafeSize = resizePanel({
|
|
2569
|
+
panelConstraints: panelConstraintsArray,
|
|
2570
|
+
panelIndex: index,
|
|
2571
|
+
size: 100
|
|
2572
|
+
});
|
|
2573
|
+
const delta2 = maxSafeSize - prevSize;
|
|
2574
|
+
maxAvailableDelta += delta2;
|
|
2575
|
+
index += increment;
|
|
2576
|
+
if (index < 0 || index >= panelConstraintsArray.length) {
|
|
2577
|
+
break;
|
|
2578
|
+
}
|
|
2579
|
+
}
|
|
2580
|
+
const minAbsDelta = Math.min(Math.abs(delta), Math.abs(maxAvailableDelta));
|
|
2581
|
+
delta = delta < 0 ? 0 - minAbsDelta : minAbsDelta;
|
|
2582
|
+
}
|
|
2583
|
+
{
|
|
2584
|
+
const pivotIndex = delta < 0 ? firstPivotIndex : secondPivotIndex;
|
|
2585
|
+
let index = pivotIndex;
|
|
2586
|
+
while (index >= 0 && index < panelConstraintsArray.length) {
|
|
2587
|
+
const deltaRemaining = Math.abs(delta) - Math.abs(deltaApplied);
|
|
2588
|
+
const prevSize = initialLayout[index];
|
|
2589
|
+
assert(prevSize != null, `Previous layout not found for panel index ${index}`);
|
|
2590
|
+
const unsafeSize = prevSize - deltaRemaining;
|
|
2591
|
+
const safeSize = resizePanel({
|
|
2592
|
+
panelConstraints: panelConstraintsArray,
|
|
2593
|
+
panelIndex: index,
|
|
2594
|
+
size: unsafeSize
|
|
2595
|
+
});
|
|
2596
|
+
if (!fuzzyNumbersEqual(prevSize, safeSize)) {
|
|
2597
|
+
deltaApplied += prevSize - safeSize;
|
|
2598
|
+
nextLayout[index] = safeSize;
|
|
2599
|
+
if (deltaApplied.toFixed(3).localeCompare(Math.abs(delta).toFixed(3), undefined, {
|
|
2600
|
+
numeric: true
|
|
2601
|
+
}) >= 0) {
|
|
2602
|
+
break;
|
|
2603
|
+
}
|
|
2604
|
+
}
|
|
2605
|
+
if (delta < 0) {
|
|
2606
|
+
index--;
|
|
2607
|
+
} else {
|
|
2608
|
+
index++;
|
|
2609
|
+
}
|
|
2610
|
+
}
|
|
2611
|
+
}
|
|
2612
|
+
if (fuzzyLayoutsEqual(prevLayout, nextLayout)) {
|
|
2613
|
+
return prevLayout;
|
|
2614
|
+
}
|
|
2615
|
+
{
|
|
2616
|
+
const pivotIndex = delta < 0 ? secondPivotIndex : firstPivotIndex;
|
|
2617
|
+
const prevSize = initialLayout[pivotIndex];
|
|
2618
|
+
assert(prevSize != null, `Previous layout not found for panel index ${pivotIndex}`);
|
|
2619
|
+
const unsafeSize = prevSize + deltaApplied;
|
|
2620
|
+
const safeSize = resizePanel({
|
|
2621
|
+
panelConstraints: panelConstraintsArray,
|
|
2622
|
+
panelIndex: pivotIndex,
|
|
2623
|
+
size: unsafeSize
|
|
2624
|
+
});
|
|
2625
|
+
nextLayout[pivotIndex] = safeSize;
|
|
2626
|
+
if (!fuzzyNumbersEqual(safeSize, unsafeSize)) {
|
|
2627
|
+
let deltaRemaining = unsafeSize - safeSize;
|
|
2628
|
+
const pivotIndex2 = delta < 0 ? secondPivotIndex : firstPivotIndex;
|
|
2629
|
+
let index = pivotIndex2;
|
|
2630
|
+
while (index >= 0 && index < panelConstraintsArray.length) {
|
|
2631
|
+
const prevSize2 = nextLayout[index];
|
|
2632
|
+
assert(prevSize2 != null, `Previous layout not found for panel index ${index}`);
|
|
2633
|
+
const unsafeSize2 = prevSize2 + deltaRemaining;
|
|
2634
|
+
const safeSize2 = resizePanel({
|
|
2635
|
+
panelConstraints: panelConstraintsArray,
|
|
2636
|
+
panelIndex: index,
|
|
2637
|
+
size: unsafeSize2
|
|
2638
|
+
});
|
|
2639
|
+
if (!fuzzyNumbersEqual(prevSize2, safeSize2)) {
|
|
2640
|
+
deltaRemaining -= safeSize2 - prevSize2;
|
|
2641
|
+
nextLayout[index] = safeSize2;
|
|
2642
|
+
}
|
|
2643
|
+
if (fuzzyNumbersEqual(deltaRemaining, 0)) {
|
|
2644
|
+
break;
|
|
2645
|
+
}
|
|
2646
|
+
if (delta > 0) {
|
|
2647
|
+
index--;
|
|
2648
|
+
} else {
|
|
2649
|
+
index++;
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
}
|
|
2653
|
+
}
|
|
2654
|
+
const totalSize = nextLayout.reduce((total, size) => size + total, 0);
|
|
2655
|
+
if (!fuzzyNumbersEqual(totalSize, 100)) {
|
|
2656
|
+
return prevLayout;
|
|
2657
|
+
}
|
|
2658
|
+
return nextLayout;
|
|
2659
|
+
}
|
|
2660
|
+
function calculateAriaValues({
|
|
2661
|
+
layout,
|
|
2662
|
+
panelsArray,
|
|
2663
|
+
pivotIndices
|
|
2664
|
+
}) {
|
|
2665
|
+
let currentMinSize = 0;
|
|
2666
|
+
let currentMaxSize = 100;
|
|
2667
|
+
let totalMinSize = 0;
|
|
2668
|
+
let totalMaxSize = 0;
|
|
2669
|
+
const firstIndex = pivotIndices[0];
|
|
2670
|
+
assert(firstIndex != null, "No pivot index found");
|
|
2671
|
+
panelsArray.forEach((panelData, index) => {
|
|
2672
|
+
const {
|
|
2673
|
+
constraints
|
|
2674
|
+
} = panelData;
|
|
2675
|
+
const {
|
|
2676
|
+
maxSize = 100,
|
|
2677
|
+
minSize = 0
|
|
2678
|
+
} = constraints;
|
|
2679
|
+
if (index === firstIndex) {
|
|
2680
|
+
currentMinSize = minSize;
|
|
2681
|
+
currentMaxSize = maxSize;
|
|
2682
|
+
} else {
|
|
2683
|
+
totalMinSize += minSize;
|
|
2684
|
+
totalMaxSize += maxSize;
|
|
2685
|
+
}
|
|
2686
|
+
});
|
|
2687
|
+
const valueMax = Math.min(currentMaxSize, 100 - totalMinSize);
|
|
2688
|
+
const valueMin = Math.max(currentMinSize, 100 - totalMaxSize);
|
|
2689
|
+
const valueNow = layout[firstIndex];
|
|
2690
|
+
return {
|
|
2691
|
+
valueMax,
|
|
2692
|
+
valueMin,
|
|
2693
|
+
valueNow
|
|
2694
|
+
};
|
|
2695
|
+
}
|
|
2696
|
+
function getResizeHandleElementsForGroup(groupId, scope = document) {
|
|
2697
|
+
return Array.from(scope.querySelectorAll(`[${DATA_ATTRIBUTES.resizeHandleId}][data-panel-group-id="${groupId}"]`));
|
|
2698
|
+
}
|
|
2699
|
+
function getResizeHandleElementIndex(groupId, id, scope = document) {
|
|
2700
|
+
const handles = getResizeHandleElementsForGroup(groupId, scope);
|
|
2701
|
+
const index = handles.findIndex((handle) => handle.getAttribute(DATA_ATTRIBUTES.resizeHandleId) === id);
|
|
2702
|
+
return index !== null && index !== undefined ? index : null;
|
|
2703
|
+
}
|
|
2704
|
+
function determinePivotIndices(groupId, dragHandleId, panelGroupElement) {
|
|
2705
|
+
const index = getResizeHandleElementIndex(groupId, dragHandleId, panelGroupElement);
|
|
2706
|
+
return index != null ? [index, index + 1] : [-1, -1];
|
|
2707
|
+
}
|
|
2708
|
+
function isHTMLElement(target) {
|
|
2709
|
+
if (target instanceof HTMLElement) {
|
|
2710
|
+
return true;
|
|
2711
|
+
}
|
|
2712
|
+
return typeof target === "object" && target !== null && "tagName" in target && "getAttribute" in target;
|
|
2713
|
+
}
|
|
2714
|
+
function getPanelGroupElement(id, rootElement = document) {
|
|
2715
|
+
if (isHTMLElement(rootElement) && rootElement.dataset.panelGroupId == id) {
|
|
2716
|
+
return rootElement;
|
|
2717
|
+
}
|
|
2718
|
+
const element = rootElement.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
|
|
2719
|
+
if (element) {
|
|
2720
|
+
return element;
|
|
2721
|
+
}
|
|
2722
|
+
return null;
|
|
2723
|
+
}
|
|
2724
|
+
function getResizeHandleElement(id, scope = document) {
|
|
2725
|
+
const element = scope.querySelector(`[${DATA_ATTRIBUTES.resizeHandleId}="${id}"]`);
|
|
2726
|
+
if (element) {
|
|
2727
|
+
return element;
|
|
2728
|
+
}
|
|
2729
|
+
return null;
|
|
2730
|
+
}
|
|
2731
|
+
function getResizeHandlePanelIds(groupId, handleId, panelsArray, scope = document) {
|
|
2732
|
+
var _panelsArray$index$id, _panelsArray$index, _panelsArray$id, _panelsArray;
|
|
2733
|
+
const handle = getResizeHandleElement(handleId, scope);
|
|
2734
|
+
const handles = getResizeHandleElementsForGroup(groupId, scope);
|
|
2735
|
+
const index = handle ? handles.indexOf(handle) : -1;
|
|
2736
|
+
const idBefore = (_panelsArray$index$id = (_panelsArray$index = panelsArray[index]) === null || _panelsArray$index === undefined ? undefined : _panelsArray$index.id) !== null && _panelsArray$index$id !== undefined ? _panelsArray$index$id : null;
|
|
2737
|
+
const idAfter = (_panelsArray$id = (_panelsArray = panelsArray[index + 1]) === null || _panelsArray === undefined ? undefined : _panelsArray.id) !== null && _panelsArray$id !== undefined ? _panelsArray$id : null;
|
|
2738
|
+
return [idBefore, idAfter];
|
|
2739
|
+
}
|
|
2740
|
+
function useWindowSplitterPanelGroupBehavior({
|
|
2741
|
+
committedValuesRef,
|
|
2742
|
+
eagerValuesRef,
|
|
2743
|
+
groupId,
|
|
2744
|
+
layout,
|
|
2745
|
+
panelDataArray,
|
|
2746
|
+
panelGroupElement,
|
|
2747
|
+
setLayout
|
|
2748
|
+
}) {
|
|
2749
|
+
useRef3({
|
|
2750
|
+
didWarnAboutMissingResizeHandle: false
|
|
2751
|
+
});
|
|
2752
|
+
useIsomorphicLayoutEffect(() => {
|
|
2753
|
+
if (!panelGroupElement) {
|
|
2754
|
+
return;
|
|
2755
|
+
}
|
|
2756
|
+
const resizeHandleElements = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
2757
|
+
for (let index = 0;index < panelDataArray.length - 1; index++) {
|
|
2758
|
+
const {
|
|
2759
|
+
valueMax,
|
|
2760
|
+
valueMin,
|
|
2761
|
+
valueNow
|
|
2762
|
+
} = calculateAriaValues({
|
|
2763
|
+
layout,
|
|
2764
|
+
panelsArray: panelDataArray,
|
|
2765
|
+
pivotIndices: [index, index + 1]
|
|
2766
|
+
});
|
|
2767
|
+
const resizeHandleElement = resizeHandleElements[index];
|
|
2768
|
+
if (resizeHandleElement == null)
|
|
2769
|
+
;
|
|
2770
|
+
else {
|
|
2771
|
+
const panelData = panelDataArray[index];
|
|
2772
|
+
assert(panelData, `No panel data found for index "${index}"`);
|
|
2773
|
+
resizeHandleElement.setAttribute("aria-controls", panelData.id);
|
|
2774
|
+
resizeHandleElement.setAttribute("aria-valuemax", "" + Math.round(valueMax));
|
|
2775
|
+
resizeHandleElement.setAttribute("aria-valuemin", "" + Math.round(valueMin));
|
|
2776
|
+
resizeHandleElement.setAttribute("aria-valuenow", valueNow != null ? "" + Math.round(valueNow) : "");
|
|
2777
|
+
}
|
|
2778
|
+
}
|
|
2779
|
+
return () => {
|
|
2780
|
+
resizeHandleElements.forEach((resizeHandleElement, index) => {
|
|
2781
|
+
resizeHandleElement.removeAttribute("aria-controls");
|
|
2782
|
+
resizeHandleElement.removeAttribute("aria-valuemax");
|
|
2783
|
+
resizeHandleElement.removeAttribute("aria-valuemin");
|
|
2784
|
+
resizeHandleElement.removeAttribute("aria-valuenow");
|
|
2785
|
+
});
|
|
2786
|
+
};
|
|
2787
|
+
}, [groupId, layout, panelDataArray, panelGroupElement]);
|
|
2788
|
+
useEffect4(() => {
|
|
2789
|
+
if (!panelGroupElement) {
|
|
2790
|
+
return;
|
|
2791
|
+
}
|
|
2792
|
+
const eagerValues = eagerValuesRef.current;
|
|
2793
|
+
assert(eagerValues, `Eager values not found`);
|
|
2794
|
+
const {
|
|
2795
|
+
panelDataArray: panelDataArray2
|
|
2796
|
+
} = eagerValues;
|
|
2797
|
+
const groupElement = getPanelGroupElement(groupId, panelGroupElement);
|
|
2798
|
+
assert(groupElement != null, `No group found for id "${groupId}"`);
|
|
2799
|
+
const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
2800
|
+
assert(handles, `No resize handles found for group id "${groupId}"`);
|
|
2801
|
+
const cleanupFunctions = handles.map((handle) => {
|
|
2802
|
+
const handleId = handle.getAttribute(DATA_ATTRIBUTES.resizeHandleId);
|
|
2803
|
+
assert(handleId, `Resize handle element has no handle id attribute`);
|
|
2804
|
+
const [idBefore, idAfter] = getResizeHandlePanelIds(groupId, handleId, panelDataArray2, panelGroupElement);
|
|
2805
|
+
if (idBefore == null || idAfter == null) {
|
|
2806
|
+
return () => {};
|
|
2807
|
+
}
|
|
2808
|
+
const onKeyDown = (event) => {
|
|
2809
|
+
if (event.defaultPrevented) {
|
|
2810
|
+
return;
|
|
2811
|
+
}
|
|
2812
|
+
switch (event.key) {
|
|
2813
|
+
case "Enter": {
|
|
2814
|
+
event.preventDefault();
|
|
2815
|
+
const index = panelDataArray2.findIndex((panelData) => panelData.id === idBefore);
|
|
2816
|
+
if (index >= 0) {
|
|
2817
|
+
const panelData = panelDataArray2[index];
|
|
2818
|
+
assert(panelData, `No panel data found for index ${index}`);
|
|
2819
|
+
const size = layout[index];
|
|
2820
|
+
const {
|
|
2821
|
+
collapsedSize = 0,
|
|
2822
|
+
collapsible,
|
|
2823
|
+
minSize = 0
|
|
2824
|
+
} = panelData.constraints;
|
|
2825
|
+
if (size != null && collapsible) {
|
|
2826
|
+
const nextLayout = adjustLayoutByDelta({
|
|
2827
|
+
delta: fuzzyNumbersEqual(size, collapsedSize) ? minSize - collapsedSize : collapsedSize - size,
|
|
2828
|
+
initialLayout: layout,
|
|
2829
|
+
panelConstraints: panelDataArray2.map((panelData2) => panelData2.constraints),
|
|
2830
|
+
pivotIndices: determinePivotIndices(groupId, handleId, panelGroupElement),
|
|
2831
|
+
prevLayout: layout,
|
|
2832
|
+
trigger: "keyboard"
|
|
2833
|
+
});
|
|
2834
|
+
if (layout !== nextLayout) {
|
|
2835
|
+
setLayout(nextLayout);
|
|
2836
|
+
}
|
|
2837
|
+
}
|
|
2838
|
+
}
|
|
2839
|
+
break;
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2842
|
+
};
|
|
2843
|
+
handle.addEventListener("keydown", onKeyDown);
|
|
2844
|
+
return () => {
|
|
2845
|
+
handle.removeEventListener("keydown", onKeyDown);
|
|
2846
|
+
};
|
|
2847
|
+
});
|
|
2848
|
+
return () => {
|
|
2849
|
+
cleanupFunctions.forEach((cleanupFunction) => cleanupFunction());
|
|
2850
|
+
};
|
|
2851
|
+
}, [panelGroupElement, committedValuesRef, eagerValuesRef, groupId, layout, panelDataArray, setLayout]);
|
|
2852
|
+
}
|
|
2853
|
+
function areEqual(arrayA, arrayB) {
|
|
2854
|
+
if (arrayA.length !== arrayB.length) {
|
|
2855
|
+
return false;
|
|
2856
|
+
}
|
|
2857
|
+
for (let index = 0;index < arrayA.length; index++) {
|
|
2858
|
+
if (arrayA[index] !== arrayB[index]) {
|
|
2859
|
+
return false;
|
|
2860
|
+
}
|
|
2861
|
+
}
|
|
2862
|
+
return true;
|
|
2863
|
+
}
|
|
2864
|
+
function getResizeEventCursorPosition(direction, event) {
|
|
2865
|
+
const isHorizontal = direction === "horizontal";
|
|
2866
|
+
const {
|
|
2867
|
+
x,
|
|
2868
|
+
y
|
|
2869
|
+
} = getResizeEventCoordinates(event);
|
|
2870
|
+
return isHorizontal ? x : y;
|
|
2871
|
+
}
|
|
2872
|
+
function calculateDragOffsetPercentage(event, dragHandleId, direction, initialDragState, panelGroupElement) {
|
|
2873
|
+
const isHorizontal = direction === "horizontal";
|
|
2874
|
+
const handleElement = getResizeHandleElement(dragHandleId, panelGroupElement);
|
|
2875
|
+
assert(handleElement, `No resize handle element found for id "${dragHandleId}"`);
|
|
2876
|
+
const groupId = handleElement.getAttribute(DATA_ATTRIBUTES.groupId);
|
|
2877
|
+
assert(groupId, `Resize handle element has no group id attribute`);
|
|
2878
|
+
let {
|
|
2879
|
+
initialCursorPosition
|
|
2880
|
+
} = initialDragState;
|
|
2881
|
+
const cursorPosition = getResizeEventCursorPosition(direction, event);
|
|
2882
|
+
const groupElement = getPanelGroupElement(groupId, panelGroupElement);
|
|
2883
|
+
assert(groupElement, `No group element found for id "${groupId}"`);
|
|
2884
|
+
const groupRect = groupElement.getBoundingClientRect();
|
|
2885
|
+
const groupSizeInPixels = isHorizontal ? groupRect.width : groupRect.height;
|
|
2886
|
+
const offsetPixels = cursorPosition - initialCursorPosition;
|
|
2887
|
+
const offsetPercentage = offsetPixels / groupSizeInPixels * 100;
|
|
2888
|
+
return offsetPercentage;
|
|
2889
|
+
}
|
|
2890
|
+
function calculateDeltaPercentage(event, dragHandleId, direction, initialDragState, keyboardResizeBy, panelGroupElement) {
|
|
2891
|
+
if (isKeyDown(event)) {
|
|
2892
|
+
const isHorizontal = direction === "horizontal";
|
|
2893
|
+
let delta = 0;
|
|
2894
|
+
if (event.shiftKey) {
|
|
2895
|
+
delta = 100;
|
|
2896
|
+
} else if (keyboardResizeBy != null) {
|
|
2897
|
+
delta = keyboardResizeBy;
|
|
2898
|
+
} else {
|
|
2899
|
+
delta = 10;
|
|
2900
|
+
}
|
|
2901
|
+
let movement = 0;
|
|
2902
|
+
switch (event.key) {
|
|
2903
|
+
case "ArrowDown":
|
|
2904
|
+
movement = isHorizontal ? 0 : delta;
|
|
2905
|
+
break;
|
|
2906
|
+
case "ArrowLeft":
|
|
2907
|
+
movement = isHorizontal ? -delta : 0;
|
|
2908
|
+
break;
|
|
2909
|
+
case "ArrowRight":
|
|
2910
|
+
movement = isHorizontal ? delta : 0;
|
|
2911
|
+
break;
|
|
2912
|
+
case "ArrowUp":
|
|
2913
|
+
movement = isHorizontal ? 0 : -delta;
|
|
2914
|
+
break;
|
|
2915
|
+
case "End":
|
|
2916
|
+
movement = 100;
|
|
2917
|
+
break;
|
|
2918
|
+
case "Home":
|
|
2919
|
+
movement = -100;
|
|
2920
|
+
break;
|
|
2921
|
+
}
|
|
2922
|
+
return movement;
|
|
2923
|
+
} else {
|
|
2924
|
+
if (initialDragState == null) {
|
|
2925
|
+
return 0;
|
|
2926
|
+
}
|
|
2927
|
+
return calculateDragOffsetPercentage(event, dragHandleId, direction, initialDragState, panelGroupElement);
|
|
2928
|
+
}
|
|
2929
|
+
}
|
|
2930
|
+
function calculateUnsafeDefaultLayout({
|
|
2931
|
+
panelDataArray
|
|
2932
|
+
}) {
|
|
2933
|
+
const layout = Array(panelDataArray.length);
|
|
2934
|
+
const panelConstraintsArray = panelDataArray.map((panelData) => panelData.constraints);
|
|
2935
|
+
let numPanelsWithSizes = 0;
|
|
2936
|
+
let remainingSize = 100;
|
|
2937
|
+
for (let index = 0;index < panelDataArray.length; index++) {
|
|
2938
|
+
const panelConstraints = panelConstraintsArray[index];
|
|
2939
|
+
assert(panelConstraints, `Panel constraints not found for index ${index}`);
|
|
2940
|
+
const {
|
|
2941
|
+
defaultSize
|
|
2942
|
+
} = panelConstraints;
|
|
2943
|
+
if (defaultSize != null) {
|
|
2944
|
+
numPanelsWithSizes++;
|
|
2945
|
+
layout[index] = defaultSize;
|
|
2946
|
+
remainingSize -= defaultSize;
|
|
2947
|
+
}
|
|
2948
|
+
}
|
|
2949
|
+
for (let index = 0;index < panelDataArray.length; index++) {
|
|
2950
|
+
const panelConstraints = panelConstraintsArray[index];
|
|
2951
|
+
assert(panelConstraints, `Panel constraints not found for index ${index}`);
|
|
2952
|
+
const {
|
|
2953
|
+
defaultSize
|
|
2954
|
+
} = panelConstraints;
|
|
2955
|
+
if (defaultSize != null) {
|
|
2956
|
+
continue;
|
|
2957
|
+
}
|
|
2958
|
+
const numRemainingPanels = panelDataArray.length - numPanelsWithSizes;
|
|
2959
|
+
const size = remainingSize / numRemainingPanels;
|
|
2960
|
+
numPanelsWithSizes++;
|
|
2961
|
+
layout[index] = size;
|
|
2962
|
+
remainingSize -= size;
|
|
2963
|
+
}
|
|
2964
|
+
return layout;
|
|
2965
|
+
}
|
|
2966
|
+
function callPanelCallbacks(panelsArray, layout, panelIdToLastNotifiedSizeMap) {
|
|
2967
|
+
layout.forEach((size, index) => {
|
|
2968
|
+
const panelData = panelsArray[index];
|
|
2969
|
+
assert(panelData, `Panel data not found for index ${index}`);
|
|
2970
|
+
const {
|
|
2971
|
+
callbacks,
|
|
2972
|
+
constraints,
|
|
2973
|
+
id: panelId
|
|
2974
|
+
} = panelData;
|
|
2975
|
+
const {
|
|
2976
|
+
collapsedSize = 0,
|
|
2977
|
+
collapsible
|
|
2978
|
+
} = constraints;
|
|
2979
|
+
const lastNotifiedSize = panelIdToLastNotifiedSizeMap[panelId];
|
|
2980
|
+
if (lastNotifiedSize == null || size !== lastNotifiedSize) {
|
|
2981
|
+
panelIdToLastNotifiedSizeMap[panelId] = size;
|
|
2982
|
+
const {
|
|
2983
|
+
onCollapse,
|
|
2984
|
+
onExpand,
|
|
2985
|
+
onResize
|
|
2986
|
+
} = callbacks;
|
|
2987
|
+
if (onResize) {
|
|
2988
|
+
onResize(size, lastNotifiedSize);
|
|
2989
|
+
}
|
|
2990
|
+
if (collapsible && (onCollapse || onExpand)) {
|
|
2991
|
+
if (onExpand && (lastNotifiedSize == null || fuzzyNumbersEqual$1(lastNotifiedSize, collapsedSize)) && !fuzzyNumbersEqual$1(size, collapsedSize)) {
|
|
2992
|
+
onExpand();
|
|
2993
|
+
}
|
|
2994
|
+
if (onCollapse && (lastNotifiedSize == null || !fuzzyNumbersEqual$1(lastNotifiedSize, collapsedSize)) && fuzzyNumbersEqual$1(size, collapsedSize)) {
|
|
2995
|
+
onCollapse();
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2998
|
+
}
|
|
2999
|
+
});
|
|
3000
|
+
}
|
|
3001
|
+
function compareLayouts(a, b) {
|
|
3002
|
+
if (a.length !== b.length) {
|
|
3003
|
+
return false;
|
|
3004
|
+
} else {
|
|
3005
|
+
for (let index = 0;index < a.length; index++) {
|
|
3006
|
+
if (a[index] != b[index]) {
|
|
3007
|
+
return false;
|
|
3008
|
+
}
|
|
3009
|
+
}
|
|
3010
|
+
}
|
|
3011
|
+
return true;
|
|
3012
|
+
}
|
|
3013
|
+
function computePanelFlexBoxStyle({
|
|
3014
|
+
defaultSize,
|
|
3015
|
+
dragState,
|
|
3016
|
+
layout,
|
|
3017
|
+
panelData,
|
|
3018
|
+
panelIndex,
|
|
3019
|
+
precision = 3
|
|
3020
|
+
}) {
|
|
3021
|
+
const size = layout[panelIndex];
|
|
3022
|
+
let flexGrow;
|
|
3023
|
+
if (size == null) {
|
|
3024
|
+
flexGrow = defaultSize != null ? defaultSize.toFixed(precision) : "1";
|
|
3025
|
+
} else if (panelData.length === 1) {
|
|
3026
|
+
flexGrow = "1";
|
|
3027
|
+
} else {
|
|
3028
|
+
flexGrow = size.toFixed(precision);
|
|
3029
|
+
}
|
|
3030
|
+
return {
|
|
3031
|
+
flexBasis: 0,
|
|
3032
|
+
flexGrow,
|
|
3033
|
+
flexShrink: 1,
|
|
3034
|
+
overflow: "hidden",
|
|
3035
|
+
pointerEvents: dragState !== null ? "none" : undefined
|
|
3036
|
+
};
|
|
3037
|
+
}
|
|
3038
|
+
function debounce(callback, durationMs = 10) {
|
|
3039
|
+
let timeoutId = null;
|
|
3040
|
+
let callable = (...args) => {
|
|
3041
|
+
if (timeoutId !== null) {
|
|
3042
|
+
clearTimeout(timeoutId);
|
|
3043
|
+
}
|
|
3044
|
+
timeoutId = setTimeout(() => {
|
|
3045
|
+
callback(...args);
|
|
3046
|
+
}, durationMs);
|
|
3047
|
+
};
|
|
3048
|
+
return callable;
|
|
3049
|
+
}
|
|
3050
|
+
function initializeDefaultStorage(storageObject) {
|
|
3051
|
+
try {
|
|
3052
|
+
if (typeof localStorage !== "undefined") {
|
|
3053
|
+
storageObject.getItem = (name) => {
|
|
3054
|
+
return localStorage.getItem(name);
|
|
3055
|
+
};
|
|
3056
|
+
storageObject.setItem = (name, value) => {
|
|
3057
|
+
localStorage.setItem(name, value);
|
|
3058
|
+
};
|
|
3059
|
+
} else {
|
|
3060
|
+
throw new Error("localStorage not supported in this environment");
|
|
3061
|
+
}
|
|
3062
|
+
} catch (error) {
|
|
3063
|
+
console.error(error);
|
|
3064
|
+
storageObject.getItem = () => null;
|
|
3065
|
+
storageObject.setItem = () => {};
|
|
3066
|
+
}
|
|
3067
|
+
}
|
|
3068
|
+
function getPanelGroupKey(autoSaveId) {
|
|
3069
|
+
return `react-resizable-panels:${autoSaveId}`;
|
|
3070
|
+
}
|
|
3071
|
+
function getPanelKey(panels) {
|
|
3072
|
+
return panels.map((panel) => {
|
|
3073
|
+
const {
|
|
3074
|
+
constraints,
|
|
3075
|
+
id,
|
|
3076
|
+
idIsFromProps,
|
|
3077
|
+
order
|
|
3078
|
+
} = panel;
|
|
3079
|
+
if (idIsFromProps) {
|
|
3080
|
+
return id;
|
|
3081
|
+
} else {
|
|
3082
|
+
return order ? `${order}:${JSON.stringify(constraints)}` : JSON.stringify(constraints);
|
|
3083
|
+
}
|
|
3084
|
+
}).sort((a, b) => a.localeCompare(b)).join(",");
|
|
3085
|
+
}
|
|
3086
|
+
function loadSerializedPanelGroupState(autoSaveId, storage) {
|
|
3087
|
+
try {
|
|
3088
|
+
const panelGroupKey = getPanelGroupKey(autoSaveId);
|
|
3089
|
+
const serialized = storage.getItem(panelGroupKey);
|
|
3090
|
+
if (serialized) {
|
|
3091
|
+
const parsed = JSON.parse(serialized);
|
|
3092
|
+
if (typeof parsed === "object" && parsed != null) {
|
|
3093
|
+
return parsed;
|
|
3094
|
+
}
|
|
3095
|
+
}
|
|
3096
|
+
} catch (error) {}
|
|
3097
|
+
return null;
|
|
3098
|
+
}
|
|
3099
|
+
function loadPanelGroupState(autoSaveId, panels, storage) {
|
|
3100
|
+
var _loadSerializedPanelG, _state$panelKey;
|
|
3101
|
+
const state = (_loadSerializedPanelG = loadSerializedPanelGroupState(autoSaveId, storage)) !== null && _loadSerializedPanelG !== undefined ? _loadSerializedPanelG : {};
|
|
3102
|
+
const panelKey = getPanelKey(panels);
|
|
3103
|
+
return (_state$panelKey = state[panelKey]) !== null && _state$panelKey !== undefined ? _state$panelKey : null;
|
|
3104
|
+
}
|
|
3105
|
+
function savePanelGroupState(autoSaveId, panels, panelSizesBeforeCollapse, sizes, storage) {
|
|
3106
|
+
var _loadSerializedPanelG2;
|
|
3107
|
+
const panelGroupKey = getPanelGroupKey(autoSaveId);
|
|
3108
|
+
const panelKey = getPanelKey(panels);
|
|
3109
|
+
const state = (_loadSerializedPanelG2 = loadSerializedPanelGroupState(autoSaveId, storage)) !== null && _loadSerializedPanelG2 !== undefined ? _loadSerializedPanelG2 : {};
|
|
3110
|
+
state[panelKey] = {
|
|
3111
|
+
expandToSizes: Object.fromEntries(panelSizesBeforeCollapse.entries()),
|
|
3112
|
+
layout: sizes
|
|
3113
|
+
};
|
|
3114
|
+
try {
|
|
3115
|
+
storage.setItem(panelGroupKey, JSON.stringify(state));
|
|
3116
|
+
} catch (error) {
|
|
3117
|
+
console.error(error);
|
|
3118
|
+
}
|
|
3119
|
+
}
|
|
3120
|
+
function validatePanelGroupLayout({
|
|
3121
|
+
layout: prevLayout,
|
|
3122
|
+
panelConstraints
|
|
3123
|
+
}) {
|
|
3124
|
+
const nextLayout = [...prevLayout];
|
|
3125
|
+
const nextLayoutTotalSize = nextLayout.reduce((accumulated, current) => accumulated + current, 0);
|
|
3126
|
+
if (nextLayout.length !== panelConstraints.length) {
|
|
3127
|
+
throw Error(`Invalid ${panelConstraints.length} panel layout: ${nextLayout.map((size) => `${size}%`).join(", ")}`);
|
|
3128
|
+
} else if (!fuzzyNumbersEqual(nextLayoutTotalSize, 100) && nextLayout.length > 0) {
|
|
3129
|
+
for (let index = 0;index < panelConstraints.length; index++) {
|
|
3130
|
+
const unsafeSize = nextLayout[index];
|
|
3131
|
+
assert(unsafeSize != null, `No layout data found for index ${index}`);
|
|
3132
|
+
const safeSize = 100 / nextLayoutTotalSize * unsafeSize;
|
|
3133
|
+
nextLayout[index] = safeSize;
|
|
3134
|
+
}
|
|
3135
|
+
}
|
|
3136
|
+
let remainingSize = 0;
|
|
3137
|
+
for (let index = 0;index < panelConstraints.length; index++) {
|
|
3138
|
+
const unsafeSize = nextLayout[index];
|
|
3139
|
+
assert(unsafeSize != null, `No layout data found for index ${index}`);
|
|
3140
|
+
const safeSize = resizePanel({
|
|
3141
|
+
panelConstraints,
|
|
3142
|
+
panelIndex: index,
|
|
3143
|
+
size: unsafeSize
|
|
3144
|
+
});
|
|
3145
|
+
if (unsafeSize != safeSize) {
|
|
3146
|
+
remainingSize += unsafeSize - safeSize;
|
|
3147
|
+
nextLayout[index] = safeSize;
|
|
3148
|
+
}
|
|
3149
|
+
}
|
|
3150
|
+
if (!fuzzyNumbersEqual(remainingSize, 0)) {
|
|
3151
|
+
for (let index = 0;index < panelConstraints.length; index++) {
|
|
3152
|
+
const prevSize = nextLayout[index];
|
|
3153
|
+
assert(prevSize != null, `No layout data found for index ${index}`);
|
|
3154
|
+
const unsafeSize = prevSize + remainingSize;
|
|
3155
|
+
const safeSize = resizePanel({
|
|
3156
|
+
panelConstraints,
|
|
3157
|
+
panelIndex: index,
|
|
3158
|
+
size: unsafeSize
|
|
3159
|
+
});
|
|
3160
|
+
if (prevSize !== safeSize) {
|
|
3161
|
+
remainingSize -= safeSize - prevSize;
|
|
3162
|
+
nextLayout[index] = safeSize;
|
|
3163
|
+
if (fuzzyNumbersEqual(remainingSize, 0)) {
|
|
3164
|
+
break;
|
|
3165
|
+
}
|
|
3166
|
+
}
|
|
3167
|
+
}
|
|
3168
|
+
}
|
|
3169
|
+
return nextLayout;
|
|
3170
|
+
}
|
|
3171
|
+
var LOCAL_STORAGE_DEBOUNCE_INTERVAL = 100;
|
|
3172
|
+
var defaultStorage = {
|
|
3173
|
+
getItem: (name) => {
|
|
3174
|
+
initializeDefaultStorage(defaultStorage);
|
|
3175
|
+
return defaultStorage.getItem(name);
|
|
3176
|
+
},
|
|
3177
|
+
setItem: (name, value) => {
|
|
3178
|
+
initializeDefaultStorage(defaultStorage);
|
|
3179
|
+
defaultStorage.setItem(name, value);
|
|
3180
|
+
}
|
|
3181
|
+
};
|
|
3182
|
+
var debounceMap = {};
|
|
3183
|
+
function PanelGroupWithForwardedRef({
|
|
3184
|
+
autoSaveId = null,
|
|
3185
|
+
children,
|
|
3186
|
+
className: classNameFromProps = "",
|
|
3187
|
+
direction,
|
|
3188
|
+
forwardedRef,
|
|
3189
|
+
id: idFromProps = null,
|
|
3190
|
+
onLayout = null,
|
|
3191
|
+
keyboardResizeBy = null,
|
|
3192
|
+
storage = defaultStorage,
|
|
3193
|
+
style: styleFromProps,
|
|
3194
|
+
tagName: Type = "div",
|
|
3195
|
+
...rest
|
|
3196
|
+
}) {
|
|
3197
|
+
const groupId = useUniqueId(idFromProps);
|
|
3198
|
+
const panelGroupElementRef = useRef3(null);
|
|
3199
|
+
const [dragState, setDragState] = useState4(null);
|
|
3200
|
+
const [layout, setLayout] = useState4([]);
|
|
3201
|
+
const forceUpdate = useForceUpdate();
|
|
3202
|
+
const panelIdToLastNotifiedSizeMapRef = useRef3({});
|
|
3203
|
+
const panelSizeBeforeCollapseRef = useRef3(new Map);
|
|
3204
|
+
const prevDeltaRef = useRef3(0);
|
|
3205
|
+
const committedValuesRef = useRef3({
|
|
3206
|
+
autoSaveId,
|
|
3207
|
+
direction,
|
|
3208
|
+
dragState,
|
|
3209
|
+
id: groupId,
|
|
3210
|
+
keyboardResizeBy,
|
|
3211
|
+
onLayout,
|
|
3212
|
+
storage
|
|
3213
|
+
});
|
|
3214
|
+
const eagerValuesRef = useRef3({
|
|
3215
|
+
layout,
|
|
3216
|
+
panelDataArray: [],
|
|
3217
|
+
panelDataArrayChanged: false
|
|
3218
|
+
});
|
|
3219
|
+
useRef3({
|
|
3220
|
+
didLogIdAndOrderWarning: false,
|
|
3221
|
+
didLogPanelConstraintsWarning: false,
|
|
3222
|
+
prevPanelIds: []
|
|
3223
|
+
});
|
|
3224
|
+
useImperativeHandle2(forwardedRef, () => ({
|
|
3225
|
+
getId: () => committedValuesRef.current.id,
|
|
3226
|
+
getLayout: () => {
|
|
3227
|
+
const {
|
|
3228
|
+
layout: layout2
|
|
3229
|
+
} = eagerValuesRef.current;
|
|
3230
|
+
return layout2;
|
|
3231
|
+
},
|
|
3232
|
+
setLayout: (unsafeLayout) => {
|
|
3233
|
+
const {
|
|
3234
|
+
onLayout: onLayout2
|
|
3235
|
+
} = committedValuesRef.current;
|
|
3236
|
+
const {
|
|
3237
|
+
layout: prevLayout,
|
|
3238
|
+
panelDataArray
|
|
3239
|
+
} = eagerValuesRef.current;
|
|
3240
|
+
const safeLayout = validatePanelGroupLayout({
|
|
3241
|
+
layout: unsafeLayout,
|
|
3242
|
+
panelConstraints: panelDataArray.map((panelData) => panelData.constraints)
|
|
3243
|
+
});
|
|
3244
|
+
if (!areEqual(prevLayout, safeLayout)) {
|
|
3245
|
+
setLayout(safeLayout);
|
|
3246
|
+
eagerValuesRef.current.layout = safeLayout;
|
|
3247
|
+
if (onLayout2) {
|
|
3248
|
+
onLayout2(safeLayout);
|
|
3249
|
+
}
|
|
3250
|
+
callPanelCallbacks(panelDataArray, safeLayout, panelIdToLastNotifiedSizeMapRef.current);
|
|
3251
|
+
}
|
|
3252
|
+
}
|
|
3253
|
+
}), []);
|
|
3254
|
+
useIsomorphicLayoutEffect(() => {
|
|
3255
|
+
committedValuesRef.current.autoSaveId = autoSaveId;
|
|
3256
|
+
committedValuesRef.current.direction = direction;
|
|
3257
|
+
committedValuesRef.current.dragState = dragState;
|
|
3258
|
+
committedValuesRef.current.id = groupId;
|
|
3259
|
+
committedValuesRef.current.onLayout = onLayout;
|
|
3260
|
+
committedValuesRef.current.storage = storage;
|
|
3261
|
+
});
|
|
3262
|
+
useWindowSplitterPanelGroupBehavior({
|
|
3263
|
+
committedValuesRef,
|
|
3264
|
+
eagerValuesRef,
|
|
3265
|
+
groupId,
|
|
3266
|
+
layout,
|
|
3267
|
+
panelDataArray: eagerValuesRef.current.panelDataArray,
|
|
3268
|
+
setLayout,
|
|
3269
|
+
panelGroupElement: panelGroupElementRef.current
|
|
3270
|
+
});
|
|
3271
|
+
useEffect4(() => {
|
|
3272
|
+
const {
|
|
3273
|
+
panelDataArray
|
|
3274
|
+
} = eagerValuesRef.current;
|
|
3275
|
+
if (autoSaveId) {
|
|
3276
|
+
if (layout.length === 0 || layout.length !== panelDataArray.length) {
|
|
3277
|
+
return;
|
|
3278
|
+
}
|
|
3279
|
+
let debouncedSave = debounceMap[autoSaveId];
|
|
3280
|
+
if (debouncedSave == null) {
|
|
3281
|
+
debouncedSave = debounce(savePanelGroupState, LOCAL_STORAGE_DEBOUNCE_INTERVAL);
|
|
3282
|
+
debounceMap[autoSaveId] = debouncedSave;
|
|
3283
|
+
}
|
|
3284
|
+
const clonedPanelDataArray = [...panelDataArray];
|
|
3285
|
+
const clonedPanelSizesBeforeCollapse = new Map(panelSizeBeforeCollapseRef.current);
|
|
3286
|
+
debouncedSave(autoSaveId, clonedPanelDataArray, clonedPanelSizesBeforeCollapse, layout, storage);
|
|
3287
|
+
}
|
|
3288
|
+
}, [autoSaveId, layout, storage]);
|
|
3289
|
+
useEffect4(() => {});
|
|
3290
|
+
const collapsePanel = useCallback3((panelData) => {
|
|
3291
|
+
const {
|
|
3292
|
+
onLayout: onLayout2
|
|
3293
|
+
} = committedValuesRef.current;
|
|
3294
|
+
const {
|
|
3295
|
+
layout: prevLayout,
|
|
3296
|
+
panelDataArray
|
|
3297
|
+
} = eagerValuesRef.current;
|
|
3298
|
+
if (panelData.constraints.collapsible) {
|
|
3299
|
+
const panelConstraintsArray = panelDataArray.map((panelData2) => panelData2.constraints);
|
|
3300
|
+
const {
|
|
3301
|
+
collapsedSize = 0,
|
|
3302
|
+
panelSize,
|
|
3303
|
+
pivotIndices
|
|
3304
|
+
} = panelDataHelper(panelDataArray, panelData, prevLayout);
|
|
3305
|
+
assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
|
|
3306
|
+
if (!fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
|
|
3307
|
+
panelSizeBeforeCollapseRef.current.set(panelData.id, panelSize);
|
|
3308
|
+
const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
|
|
3309
|
+
const delta = isLastPanel ? panelSize - collapsedSize : collapsedSize - panelSize;
|
|
3310
|
+
const nextLayout = adjustLayoutByDelta({
|
|
3311
|
+
delta,
|
|
3312
|
+
initialLayout: prevLayout,
|
|
3313
|
+
panelConstraints: panelConstraintsArray,
|
|
3314
|
+
pivotIndices,
|
|
3315
|
+
prevLayout,
|
|
3316
|
+
trigger: "imperative-api"
|
|
3317
|
+
});
|
|
3318
|
+
if (!compareLayouts(prevLayout, nextLayout)) {
|
|
3319
|
+
setLayout(nextLayout);
|
|
3320
|
+
eagerValuesRef.current.layout = nextLayout;
|
|
3321
|
+
if (onLayout2) {
|
|
3322
|
+
onLayout2(nextLayout);
|
|
3323
|
+
}
|
|
3324
|
+
callPanelCallbacks(panelDataArray, nextLayout, panelIdToLastNotifiedSizeMapRef.current);
|
|
3325
|
+
}
|
|
3326
|
+
}
|
|
3327
|
+
}
|
|
3328
|
+
}, []);
|
|
3329
|
+
const expandPanel = useCallback3((panelData, minSizeOverride) => {
|
|
3330
|
+
const {
|
|
3331
|
+
onLayout: onLayout2
|
|
3332
|
+
} = committedValuesRef.current;
|
|
3333
|
+
const {
|
|
3334
|
+
layout: prevLayout,
|
|
3335
|
+
panelDataArray
|
|
3336
|
+
} = eagerValuesRef.current;
|
|
3337
|
+
if (panelData.constraints.collapsible) {
|
|
3338
|
+
const panelConstraintsArray = panelDataArray.map((panelData2) => panelData2.constraints);
|
|
3339
|
+
const {
|
|
3340
|
+
collapsedSize = 0,
|
|
3341
|
+
panelSize = 0,
|
|
3342
|
+
minSize: minSizeFromProps = 0,
|
|
3343
|
+
pivotIndices
|
|
3344
|
+
} = panelDataHelper(panelDataArray, panelData, prevLayout);
|
|
3345
|
+
const minSize = minSizeOverride !== null && minSizeOverride !== undefined ? minSizeOverride : minSizeFromProps;
|
|
3346
|
+
if (fuzzyNumbersEqual$1(panelSize, collapsedSize)) {
|
|
3347
|
+
const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
|
|
3348
|
+
const baseSize = prevPanelSize != null && prevPanelSize >= minSize ? prevPanelSize : minSize;
|
|
3349
|
+
const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
|
|
3350
|
+
const delta = isLastPanel ? panelSize - baseSize : baseSize - panelSize;
|
|
3351
|
+
const nextLayout = adjustLayoutByDelta({
|
|
3352
|
+
delta,
|
|
3353
|
+
initialLayout: prevLayout,
|
|
3354
|
+
panelConstraints: panelConstraintsArray,
|
|
3355
|
+
pivotIndices,
|
|
3356
|
+
prevLayout,
|
|
3357
|
+
trigger: "imperative-api"
|
|
3358
|
+
});
|
|
3359
|
+
if (!compareLayouts(prevLayout, nextLayout)) {
|
|
3360
|
+
setLayout(nextLayout);
|
|
3361
|
+
eagerValuesRef.current.layout = nextLayout;
|
|
3362
|
+
if (onLayout2) {
|
|
3363
|
+
onLayout2(nextLayout);
|
|
3364
|
+
}
|
|
3365
|
+
callPanelCallbacks(panelDataArray, nextLayout, panelIdToLastNotifiedSizeMapRef.current);
|
|
3366
|
+
}
|
|
3367
|
+
}
|
|
3368
|
+
}
|
|
3369
|
+
}, []);
|
|
3370
|
+
const getPanelSize = useCallback3((panelData) => {
|
|
3371
|
+
const {
|
|
3372
|
+
layout: layout2,
|
|
3373
|
+
panelDataArray
|
|
3374
|
+
} = eagerValuesRef.current;
|
|
3375
|
+
const {
|
|
3376
|
+
panelSize
|
|
3377
|
+
} = panelDataHelper(panelDataArray, panelData, layout2);
|
|
3378
|
+
assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
|
|
3379
|
+
return panelSize;
|
|
3380
|
+
}, []);
|
|
3381
|
+
const getPanelStyle = useCallback3((panelData, defaultSize) => {
|
|
3382
|
+
const {
|
|
3383
|
+
panelDataArray
|
|
3384
|
+
} = eagerValuesRef.current;
|
|
3385
|
+
const panelIndex = findPanelDataIndex(panelDataArray, panelData);
|
|
3386
|
+
return computePanelFlexBoxStyle({
|
|
3387
|
+
defaultSize,
|
|
3388
|
+
dragState,
|
|
3389
|
+
layout,
|
|
3390
|
+
panelData: panelDataArray,
|
|
3391
|
+
panelIndex
|
|
3392
|
+
});
|
|
3393
|
+
}, [dragState, layout]);
|
|
3394
|
+
const isPanelCollapsed = useCallback3((panelData) => {
|
|
3395
|
+
const {
|
|
3396
|
+
layout: layout2,
|
|
3397
|
+
panelDataArray
|
|
3398
|
+
} = eagerValuesRef.current;
|
|
3399
|
+
const {
|
|
3400
|
+
collapsedSize = 0,
|
|
3401
|
+
collapsible,
|
|
3402
|
+
panelSize
|
|
3403
|
+
} = panelDataHelper(panelDataArray, panelData, layout2);
|
|
3404
|
+
assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
|
|
3405
|
+
return collapsible === true && fuzzyNumbersEqual$1(panelSize, collapsedSize);
|
|
3406
|
+
}, []);
|
|
3407
|
+
const isPanelExpanded = useCallback3((panelData) => {
|
|
3408
|
+
const {
|
|
3409
|
+
layout: layout2,
|
|
3410
|
+
panelDataArray
|
|
3411
|
+
} = eagerValuesRef.current;
|
|
3412
|
+
const {
|
|
3413
|
+
collapsedSize = 0,
|
|
3414
|
+
collapsible,
|
|
3415
|
+
panelSize
|
|
3416
|
+
} = panelDataHelper(panelDataArray, panelData, layout2);
|
|
3417
|
+
assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
|
|
3418
|
+
return !collapsible || fuzzyCompareNumbers(panelSize, collapsedSize) > 0;
|
|
3419
|
+
}, []);
|
|
3420
|
+
const registerPanel = useCallback3((panelData) => {
|
|
3421
|
+
const {
|
|
3422
|
+
panelDataArray
|
|
3423
|
+
} = eagerValuesRef.current;
|
|
3424
|
+
panelDataArray.push(panelData);
|
|
3425
|
+
panelDataArray.sort((panelA, panelB) => {
|
|
3426
|
+
const orderA = panelA.order;
|
|
3427
|
+
const orderB = panelB.order;
|
|
3428
|
+
if (orderA == null && orderB == null) {
|
|
3429
|
+
return 0;
|
|
3430
|
+
} else if (orderA == null) {
|
|
3431
|
+
return -1;
|
|
3432
|
+
} else if (orderB == null) {
|
|
3433
|
+
return 1;
|
|
3434
|
+
} else {
|
|
3435
|
+
return orderA - orderB;
|
|
3436
|
+
}
|
|
3437
|
+
});
|
|
3438
|
+
eagerValuesRef.current.panelDataArrayChanged = true;
|
|
3439
|
+
forceUpdate();
|
|
3440
|
+
}, [forceUpdate]);
|
|
3441
|
+
useIsomorphicLayoutEffect(() => {
|
|
3442
|
+
if (eagerValuesRef.current.panelDataArrayChanged) {
|
|
3443
|
+
eagerValuesRef.current.panelDataArrayChanged = false;
|
|
3444
|
+
const {
|
|
3445
|
+
autoSaveId: autoSaveId2,
|
|
3446
|
+
onLayout: onLayout2,
|
|
3447
|
+
storage: storage2
|
|
3448
|
+
} = committedValuesRef.current;
|
|
3449
|
+
const {
|
|
3450
|
+
layout: prevLayout,
|
|
3451
|
+
panelDataArray
|
|
3452
|
+
} = eagerValuesRef.current;
|
|
3453
|
+
let unsafeLayout = null;
|
|
3454
|
+
if (autoSaveId2) {
|
|
3455
|
+
const state = loadPanelGroupState(autoSaveId2, panelDataArray, storage2);
|
|
3456
|
+
if (state) {
|
|
3457
|
+
panelSizeBeforeCollapseRef.current = new Map(Object.entries(state.expandToSizes));
|
|
3458
|
+
unsafeLayout = state.layout;
|
|
3459
|
+
}
|
|
3460
|
+
}
|
|
3461
|
+
if (unsafeLayout == null) {
|
|
3462
|
+
unsafeLayout = calculateUnsafeDefaultLayout({
|
|
3463
|
+
panelDataArray
|
|
3464
|
+
});
|
|
3465
|
+
}
|
|
3466
|
+
const nextLayout = validatePanelGroupLayout({
|
|
3467
|
+
layout: unsafeLayout,
|
|
3468
|
+
panelConstraints: panelDataArray.map((panelData) => panelData.constraints)
|
|
3469
|
+
});
|
|
3470
|
+
if (!areEqual(prevLayout, nextLayout)) {
|
|
3471
|
+
setLayout(nextLayout);
|
|
3472
|
+
eagerValuesRef.current.layout = nextLayout;
|
|
3473
|
+
if (onLayout2) {
|
|
3474
|
+
onLayout2(nextLayout);
|
|
3475
|
+
}
|
|
3476
|
+
callPanelCallbacks(panelDataArray, nextLayout, panelIdToLastNotifiedSizeMapRef.current);
|
|
3477
|
+
}
|
|
3478
|
+
}
|
|
3479
|
+
});
|
|
3480
|
+
useIsomorphicLayoutEffect(() => {
|
|
3481
|
+
const eagerValues = eagerValuesRef.current;
|
|
3482
|
+
return () => {
|
|
3483
|
+
eagerValues.layout = [];
|
|
3484
|
+
};
|
|
3485
|
+
}, []);
|
|
3486
|
+
const registerResizeHandle2 = useCallback3((dragHandleId) => {
|
|
3487
|
+
let isRTL = false;
|
|
3488
|
+
const panelGroupElement = panelGroupElementRef.current;
|
|
3489
|
+
if (panelGroupElement) {
|
|
3490
|
+
const style2 = window.getComputedStyle(panelGroupElement, null);
|
|
3491
|
+
if (style2.getPropertyValue("direction") === "rtl") {
|
|
3492
|
+
isRTL = true;
|
|
3493
|
+
}
|
|
3494
|
+
}
|
|
3495
|
+
return function resizeHandler(event) {
|
|
3496
|
+
event.preventDefault();
|
|
3497
|
+
const panelGroupElement2 = panelGroupElementRef.current;
|
|
3498
|
+
if (!panelGroupElement2) {
|
|
3499
|
+
return () => null;
|
|
3500
|
+
}
|
|
3501
|
+
const {
|
|
3502
|
+
direction: direction2,
|
|
3503
|
+
dragState: dragState2,
|
|
3504
|
+
id: groupId2,
|
|
3505
|
+
keyboardResizeBy: keyboardResizeBy2,
|
|
3506
|
+
onLayout: onLayout2
|
|
3507
|
+
} = committedValuesRef.current;
|
|
3508
|
+
const {
|
|
3509
|
+
layout: prevLayout,
|
|
3510
|
+
panelDataArray
|
|
3511
|
+
} = eagerValuesRef.current;
|
|
3512
|
+
const {
|
|
3513
|
+
initialLayout
|
|
3514
|
+
} = dragState2 !== null && dragState2 !== undefined ? dragState2 : {};
|
|
3515
|
+
const pivotIndices = determinePivotIndices(groupId2, dragHandleId, panelGroupElement2);
|
|
3516
|
+
let delta = calculateDeltaPercentage(event, dragHandleId, direction2, dragState2, keyboardResizeBy2, panelGroupElement2);
|
|
3517
|
+
const isHorizontal = direction2 === "horizontal";
|
|
3518
|
+
if (isHorizontal && isRTL) {
|
|
3519
|
+
delta = -delta;
|
|
3520
|
+
}
|
|
3521
|
+
const panelConstraints = panelDataArray.map((panelData) => panelData.constraints);
|
|
3522
|
+
const nextLayout = adjustLayoutByDelta({
|
|
3523
|
+
delta,
|
|
3524
|
+
initialLayout: initialLayout !== null && initialLayout !== undefined ? initialLayout : prevLayout,
|
|
3525
|
+
panelConstraints,
|
|
3526
|
+
pivotIndices,
|
|
3527
|
+
prevLayout,
|
|
3528
|
+
trigger: isKeyDown(event) ? "keyboard" : "mouse-or-touch"
|
|
3529
|
+
});
|
|
3530
|
+
const layoutChanged = !compareLayouts(prevLayout, nextLayout);
|
|
3531
|
+
if (isPointerEvent(event) || isMouseEvent(event)) {
|
|
3532
|
+
if (prevDeltaRef.current != delta) {
|
|
3533
|
+
prevDeltaRef.current = delta;
|
|
3534
|
+
if (!layoutChanged && delta !== 0) {
|
|
3535
|
+
if (isHorizontal) {
|
|
3536
|
+
reportConstraintsViolation(dragHandleId, delta < 0 ? EXCEEDED_HORIZONTAL_MIN : EXCEEDED_HORIZONTAL_MAX);
|
|
3537
|
+
} else {
|
|
3538
|
+
reportConstraintsViolation(dragHandleId, delta < 0 ? EXCEEDED_VERTICAL_MIN : EXCEEDED_VERTICAL_MAX);
|
|
3539
|
+
}
|
|
3540
|
+
} else {
|
|
3541
|
+
reportConstraintsViolation(dragHandleId, 0);
|
|
3542
|
+
}
|
|
3543
|
+
}
|
|
3544
|
+
}
|
|
3545
|
+
if (layoutChanged) {
|
|
3546
|
+
setLayout(nextLayout);
|
|
3547
|
+
eagerValuesRef.current.layout = nextLayout;
|
|
3548
|
+
if (onLayout2) {
|
|
3549
|
+
onLayout2(nextLayout);
|
|
3550
|
+
}
|
|
3551
|
+
callPanelCallbacks(panelDataArray, nextLayout, panelIdToLastNotifiedSizeMapRef.current);
|
|
3552
|
+
}
|
|
3553
|
+
};
|
|
3554
|
+
}, []);
|
|
3555
|
+
const resizePanel2 = useCallback3((panelData, unsafePanelSize) => {
|
|
3556
|
+
const {
|
|
3557
|
+
onLayout: onLayout2
|
|
3558
|
+
} = committedValuesRef.current;
|
|
3559
|
+
const {
|
|
3560
|
+
layout: prevLayout,
|
|
3561
|
+
panelDataArray
|
|
3562
|
+
} = eagerValuesRef.current;
|
|
3563
|
+
const panelConstraintsArray = panelDataArray.map((panelData2) => panelData2.constraints);
|
|
3564
|
+
const {
|
|
3565
|
+
panelSize,
|
|
3566
|
+
pivotIndices
|
|
3567
|
+
} = panelDataHelper(panelDataArray, panelData, prevLayout);
|
|
3568
|
+
assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
|
|
3569
|
+
const isLastPanel = findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
|
|
3570
|
+
const delta = isLastPanel ? panelSize - unsafePanelSize : unsafePanelSize - panelSize;
|
|
3571
|
+
const nextLayout = adjustLayoutByDelta({
|
|
3572
|
+
delta,
|
|
3573
|
+
initialLayout: prevLayout,
|
|
3574
|
+
panelConstraints: panelConstraintsArray,
|
|
3575
|
+
pivotIndices,
|
|
3576
|
+
prevLayout,
|
|
3577
|
+
trigger: "imperative-api"
|
|
3578
|
+
});
|
|
3579
|
+
if (!compareLayouts(prevLayout, nextLayout)) {
|
|
3580
|
+
setLayout(nextLayout);
|
|
3581
|
+
eagerValuesRef.current.layout = nextLayout;
|
|
3582
|
+
if (onLayout2) {
|
|
3583
|
+
onLayout2(nextLayout);
|
|
3584
|
+
}
|
|
3585
|
+
callPanelCallbacks(panelDataArray, nextLayout, panelIdToLastNotifiedSizeMapRef.current);
|
|
3586
|
+
}
|
|
3587
|
+
}, []);
|
|
3588
|
+
const reevaluatePanelConstraints = useCallback3((panelData, prevConstraints) => {
|
|
3589
|
+
const {
|
|
3590
|
+
layout: layout2,
|
|
3591
|
+
panelDataArray
|
|
3592
|
+
} = eagerValuesRef.current;
|
|
3593
|
+
const {
|
|
3594
|
+
collapsedSize: prevCollapsedSize = 0,
|
|
3595
|
+
collapsible: prevCollapsible
|
|
3596
|
+
} = prevConstraints;
|
|
3597
|
+
const {
|
|
3598
|
+
collapsedSize: nextCollapsedSize = 0,
|
|
3599
|
+
collapsible: nextCollapsible,
|
|
3600
|
+
maxSize: nextMaxSize = 100,
|
|
3601
|
+
minSize: nextMinSize = 0
|
|
3602
|
+
} = panelData.constraints;
|
|
3603
|
+
const {
|
|
3604
|
+
panelSize: prevPanelSize
|
|
3605
|
+
} = panelDataHelper(panelDataArray, panelData, layout2);
|
|
3606
|
+
if (prevPanelSize == null) {
|
|
3607
|
+
return;
|
|
3608
|
+
}
|
|
3609
|
+
if (prevCollapsible && nextCollapsible && fuzzyNumbersEqual$1(prevPanelSize, prevCollapsedSize)) {
|
|
3610
|
+
if (!fuzzyNumbersEqual$1(prevCollapsedSize, nextCollapsedSize)) {
|
|
3611
|
+
resizePanel2(panelData, nextCollapsedSize);
|
|
3612
|
+
}
|
|
3613
|
+
} else if (prevPanelSize < nextMinSize) {
|
|
3614
|
+
resizePanel2(panelData, nextMinSize);
|
|
3615
|
+
} else if (prevPanelSize > nextMaxSize) {
|
|
3616
|
+
resizePanel2(panelData, nextMaxSize);
|
|
3617
|
+
}
|
|
3618
|
+
}, [resizePanel2]);
|
|
3619
|
+
const startDragging = useCallback3((dragHandleId, event) => {
|
|
3620
|
+
const {
|
|
3621
|
+
direction: direction2
|
|
3622
|
+
} = committedValuesRef.current;
|
|
3623
|
+
const {
|
|
3624
|
+
layout: layout2
|
|
3625
|
+
} = eagerValuesRef.current;
|
|
3626
|
+
if (!panelGroupElementRef.current) {
|
|
3627
|
+
return;
|
|
3628
|
+
}
|
|
3629
|
+
const handleElement = getResizeHandleElement(dragHandleId, panelGroupElementRef.current);
|
|
3630
|
+
assert(handleElement, `Drag handle element not found for id "${dragHandleId}"`);
|
|
3631
|
+
const initialCursorPosition = getResizeEventCursorPosition(direction2, event);
|
|
3632
|
+
setDragState({
|
|
3633
|
+
dragHandleId,
|
|
3634
|
+
dragHandleRect: handleElement.getBoundingClientRect(),
|
|
3635
|
+
initialCursorPosition,
|
|
3636
|
+
initialLayout: layout2
|
|
3637
|
+
});
|
|
3638
|
+
}, []);
|
|
3639
|
+
const stopDragging = useCallback3(() => {
|
|
3640
|
+
setDragState(null);
|
|
3641
|
+
}, []);
|
|
3642
|
+
const unregisterPanel = useCallback3((panelData) => {
|
|
3643
|
+
const {
|
|
3644
|
+
panelDataArray
|
|
3645
|
+
} = eagerValuesRef.current;
|
|
3646
|
+
const index = findPanelDataIndex(panelDataArray, panelData);
|
|
3647
|
+
if (index >= 0) {
|
|
3648
|
+
panelDataArray.splice(index, 1);
|
|
3649
|
+
delete panelIdToLastNotifiedSizeMapRef.current[panelData.id];
|
|
3650
|
+
eagerValuesRef.current.panelDataArrayChanged = true;
|
|
3651
|
+
forceUpdate();
|
|
3652
|
+
}
|
|
3653
|
+
}, [forceUpdate]);
|
|
3654
|
+
const context2 = useMemo2(() => ({
|
|
3655
|
+
collapsePanel,
|
|
3656
|
+
direction,
|
|
3657
|
+
dragState,
|
|
3658
|
+
expandPanel,
|
|
3659
|
+
getPanelSize,
|
|
3660
|
+
getPanelStyle,
|
|
3661
|
+
groupId,
|
|
3662
|
+
isPanelCollapsed,
|
|
3663
|
+
isPanelExpanded,
|
|
3664
|
+
reevaluatePanelConstraints,
|
|
3665
|
+
registerPanel,
|
|
3666
|
+
registerResizeHandle: registerResizeHandle2,
|
|
3667
|
+
resizePanel: resizePanel2,
|
|
3668
|
+
startDragging,
|
|
3669
|
+
stopDragging,
|
|
3670
|
+
unregisterPanel,
|
|
3671
|
+
panelGroupElement: panelGroupElementRef.current
|
|
3672
|
+
}), [collapsePanel, dragState, direction, expandPanel, getPanelSize, getPanelStyle, groupId, isPanelCollapsed, isPanelExpanded, reevaluatePanelConstraints, registerPanel, registerResizeHandle2, resizePanel2, startDragging, stopDragging, unregisterPanel]);
|
|
3673
|
+
const style = {
|
|
3674
|
+
display: "flex",
|
|
3675
|
+
flexDirection: direction === "horizontal" ? "row" : "column",
|
|
3676
|
+
height: "100%",
|
|
3677
|
+
overflow: "hidden",
|
|
3678
|
+
width: "100%"
|
|
3679
|
+
};
|
|
3680
|
+
return createElement(PanelGroupContext.Provider, {
|
|
3681
|
+
value: context2
|
|
3682
|
+
}, createElement(Type, {
|
|
3683
|
+
...rest,
|
|
3684
|
+
children,
|
|
3685
|
+
className: classNameFromProps,
|
|
3686
|
+
id: idFromProps,
|
|
3687
|
+
ref: panelGroupElementRef,
|
|
3688
|
+
style: {
|
|
3689
|
+
...style,
|
|
3690
|
+
...styleFromProps
|
|
3691
|
+
},
|
|
3692
|
+
[DATA_ATTRIBUTES.group]: "",
|
|
3693
|
+
[DATA_ATTRIBUTES.groupDirection]: direction,
|
|
3694
|
+
[DATA_ATTRIBUTES.groupId]: groupId
|
|
3695
|
+
}));
|
|
3696
|
+
}
|
|
3697
|
+
var PanelGroup = forwardRef3((props2, ref) => createElement(PanelGroupWithForwardedRef, {
|
|
3698
|
+
...props2,
|
|
3699
|
+
forwardedRef: ref
|
|
3700
|
+
}));
|
|
3701
|
+
PanelGroupWithForwardedRef.displayName = "PanelGroup";
|
|
3702
|
+
PanelGroup.displayName = "forwardRef(PanelGroup)";
|
|
3703
|
+
function findPanelDataIndex(panelDataArray, panelData) {
|
|
3704
|
+
return panelDataArray.findIndex((prevPanelData) => prevPanelData === panelData || prevPanelData.id === panelData.id);
|
|
3705
|
+
}
|
|
3706
|
+
function panelDataHelper(panelDataArray, panelData, layout) {
|
|
3707
|
+
const panelIndex = findPanelDataIndex(panelDataArray, panelData);
|
|
3708
|
+
const isLastPanel = panelIndex === panelDataArray.length - 1;
|
|
3709
|
+
const pivotIndices = isLastPanel ? [panelIndex - 1, panelIndex] : [panelIndex, panelIndex + 1];
|
|
3710
|
+
const panelSize = layout[panelIndex];
|
|
3711
|
+
return {
|
|
3712
|
+
...panelData.constraints,
|
|
3713
|
+
panelSize,
|
|
3714
|
+
pivotIndices
|
|
3715
|
+
};
|
|
3716
|
+
}
|
|
3717
|
+
function useWindowSplitterResizeHandlerBehavior({
|
|
3718
|
+
disabled,
|
|
3719
|
+
handleId,
|
|
3720
|
+
resizeHandler,
|
|
3721
|
+
panelGroupElement
|
|
3722
|
+
}) {
|
|
3723
|
+
useEffect4(() => {
|
|
3724
|
+
if (disabled || resizeHandler == null || panelGroupElement == null) {
|
|
3725
|
+
return;
|
|
3726
|
+
}
|
|
3727
|
+
const handleElement = getResizeHandleElement(handleId, panelGroupElement);
|
|
3728
|
+
if (handleElement == null) {
|
|
3729
|
+
return;
|
|
3730
|
+
}
|
|
3731
|
+
const onKeyDown = (event) => {
|
|
3732
|
+
if (event.defaultPrevented) {
|
|
3733
|
+
return;
|
|
3734
|
+
}
|
|
3735
|
+
switch (event.key) {
|
|
3736
|
+
case "ArrowDown":
|
|
3737
|
+
case "ArrowLeft":
|
|
3738
|
+
case "ArrowRight":
|
|
3739
|
+
case "ArrowUp":
|
|
3740
|
+
case "End":
|
|
3741
|
+
case "Home": {
|
|
3742
|
+
event.preventDefault();
|
|
3743
|
+
resizeHandler(event);
|
|
3744
|
+
break;
|
|
3745
|
+
}
|
|
3746
|
+
case "F6": {
|
|
3747
|
+
event.preventDefault();
|
|
3748
|
+
const groupId = handleElement.getAttribute(DATA_ATTRIBUTES.groupId);
|
|
3749
|
+
assert(groupId, `No group element found for id "${groupId}"`);
|
|
3750
|
+
const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
3751
|
+
const index = getResizeHandleElementIndex(groupId, handleId, panelGroupElement);
|
|
3752
|
+
assert(index !== null, `No resize element found for id "${handleId}"`);
|
|
3753
|
+
const nextIndex = event.shiftKey ? index > 0 ? index - 1 : handles.length - 1 : index + 1 < handles.length ? index + 1 : 0;
|
|
3754
|
+
const nextHandle = handles[nextIndex];
|
|
3755
|
+
nextHandle.focus();
|
|
3756
|
+
break;
|
|
3757
|
+
}
|
|
3758
|
+
}
|
|
3759
|
+
};
|
|
3760
|
+
handleElement.addEventListener("keydown", onKeyDown);
|
|
3761
|
+
return () => {
|
|
3762
|
+
handleElement.removeEventListener("keydown", onKeyDown);
|
|
3763
|
+
};
|
|
3764
|
+
}, [panelGroupElement, disabled, handleId, resizeHandler]);
|
|
3765
|
+
}
|
|
3766
|
+
function PanelResizeHandle({
|
|
3767
|
+
children = null,
|
|
3768
|
+
className: classNameFromProps = "",
|
|
3769
|
+
disabled = false,
|
|
3770
|
+
hitAreaMargins,
|
|
3771
|
+
id: idFromProps,
|
|
3772
|
+
onBlur,
|
|
3773
|
+
onClick,
|
|
3774
|
+
onDragging,
|
|
3775
|
+
onFocus,
|
|
3776
|
+
onPointerDown,
|
|
3777
|
+
onPointerUp,
|
|
3778
|
+
style: styleFromProps = {},
|
|
3779
|
+
tabIndex = 0,
|
|
3780
|
+
tagName: Type = "div",
|
|
3781
|
+
...rest
|
|
3782
|
+
}) {
|
|
3783
|
+
var _hitAreaMargins$coars, _hitAreaMargins$fine;
|
|
3784
|
+
const elementRef = useRef3(null);
|
|
3785
|
+
const callbacksRef = useRef3({
|
|
3786
|
+
onClick,
|
|
3787
|
+
onDragging,
|
|
3788
|
+
onPointerDown,
|
|
3789
|
+
onPointerUp
|
|
3790
|
+
});
|
|
3791
|
+
useEffect4(() => {
|
|
3792
|
+
callbacksRef.current.onClick = onClick;
|
|
3793
|
+
callbacksRef.current.onDragging = onDragging;
|
|
3794
|
+
callbacksRef.current.onPointerDown = onPointerDown;
|
|
3795
|
+
callbacksRef.current.onPointerUp = onPointerUp;
|
|
3796
|
+
});
|
|
3797
|
+
const panelGroupContext = useContext(PanelGroupContext);
|
|
3798
|
+
if (panelGroupContext === null) {
|
|
3799
|
+
throw Error(`PanelResizeHandle components must be rendered within a PanelGroup container`);
|
|
3800
|
+
}
|
|
3801
|
+
const {
|
|
3802
|
+
direction,
|
|
3803
|
+
groupId,
|
|
3804
|
+
registerResizeHandle: registerResizeHandleWithParentGroup,
|
|
3805
|
+
startDragging,
|
|
3806
|
+
stopDragging,
|
|
3807
|
+
panelGroupElement
|
|
3808
|
+
} = panelGroupContext;
|
|
3809
|
+
const resizeHandleId = useUniqueId(idFromProps);
|
|
3810
|
+
const [state, setState] = useState4("inactive");
|
|
3811
|
+
const [isFocused, setIsFocused] = useState4(false);
|
|
3812
|
+
const [resizeHandler, setResizeHandler] = useState4(null);
|
|
3813
|
+
const committedValuesRef = useRef3({
|
|
3814
|
+
state
|
|
3815
|
+
});
|
|
3816
|
+
useIsomorphicLayoutEffect(() => {
|
|
3817
|
+
committedValuesRef.current.state = state;
|
|
3818
|
+
});
|
|
3819
|
+
useEffect4(() => {
|
|
3820
|
+
if (disabled) {
|
|
3821
|
+
setResizeHandler(null);
|
|
3822
|
+
} else {
|
|
3823
|
+
const resizeHandler2 = registerResizeHandleWithParentGroup(resizeHandleId);
|
|
3824
|
+
setResizeHandler(() => resizeHandler2);
|
|
3825
|
+
}
|
|
3826
|
+
}, [disabled, resizeHandleId, registerResizeHandleWithParentGroup]);
|
|
3827
|
+
const coarseHitAreaMargins = (_hitAreaMargins$coars = hitAreaMargins === null || hitAreaMargins === undefined ? undefined : hitAreaMargins.coarse) !== null && _hitAreaMargins$coars !== undefined ? _hitAreaMargins$coars : 15;
|
|
3828
|
+
const fineHitAreaMargins = (_hitAreaMargins$fine = hitAreaMargins === null || hitAreaMargins === undefined ? undefined : hitAreaMargins.fine) !== null && _hitAreaMargins$fine !== undefined ? _hitAreaMargins$fine : 5;
|
|
3829
|
+
useEffect4(() => {
|
|
3830
|
+
if (disabled || resizeHandler == null) {
|
|
3831
|
+
return;
|
|
3832
|
+
}
|
|
3833
|
+
const element = elementRef.current;
|
|
3834
|
+
assert(element, "Element ref not attached");
|
|
3835
|
+
let didMove = false;
|
|
3836
|
+
const setResizeHandlerState = (action, isActive, event) => {
|
|
3837
|
+
if (!isActive) {
|
|
3838
|
+
setState("inactive");
|
|
3839
|
+
return;
|
|
3840
|
+
}
|
|
3841
|
+
switch (action) {
|
|
3842
|
+
case "down": {
|
|
3843
|
+
setState("drag");
|
|
3844
|
+
didMove = false;
|
|
3845
|
+
assert(event, 'Expected event to be defined for "down" action');
|
|
3846
|
+
startDragging(resizeHandleId, event);
|
|
3847
|
+
const {
|
|
3848
|
+
onDragging: onDragging2,
|
|
3849
|
+
onPointerDown: onPointerDown2
|
|
3850
|
+
} = callbacksRef.current;
|
|
3851
|
+
onDragging2 === null || onDragging2 === undefined || onDragging2(true);
|
|
3852
|
+
onPointerDown2 === null || onPointerDown2 === undefined || onPointerDown2();
|
|
3853
|
+
break;
|
|
3854
|
+
}
|
|
3855
|
+
case "move": {
|
|
3856
|
+
const {
|
|
3857
|
+
state: state2
|
|
3858
|
+
} = committedValuesRef.current;
|
|
3859
|
+
didMove = true;
|
|
3860
|
+
if (state2 !== "drag") {
|
|
3861
|
+
setState("hover");
|
|
3862
|
+
}
|
|
3863
|
+
assert(event, 'Expected event to be defined for "move" action');
|
|
3864
|
+
resizeHandler(event);
|
|
3865
|
+
break;
|
|
3866
|
+
}
|
|
3867
|
+
case "up": {
|
|
3868
|
+
setState("hover");
|
|
3869
|
+
stopDragging();
|
|
3870
|
+
const {
|
|
3871
|
+
onClick: onClick2,
|
|
3872
|
+
onDragging: onDragging2,
|
|
3873
|
+
onPointerUp: onPointerUp2
|
|
3874
|
+
} = callbacksRef.current;
|
|
3875
|
+
onDragging2 === null || onDragging2 === undefined || onDragging2(false);
|
|
3876
|
+
onPointerUp2 === null || onPointerUp2 === undefined || onPointerUp2();
|
|
3877
|
+
if (!didMove) {
|
|
3878
|
+
onClick2 === null || onClick2 === undefined || onClick2();
|
|
3879
|
+
}
|
|
3880
|
+
break;
|
|
3881
|
+
}
|
|
3882
|
+
}
|
|
3883
|
+
};
|
|
3884
|
+
return registerResizeHandle(resizeHandleId, element, direction, {
|
|
3885
|
+
coarse: coarseHitAreaMargins,
|
|
3886
|
+
fine: fineHitAreaMargins
|
|
3887
|
+
}, setResizeHandlerState);
|
|
3888
|
+
}, [coarseHitAreaMargins, direction, disabled, fineHitAreaMargins, registerResizeHandleWithParentGroup, resizeHandleId, resizeHandler, startDragging, stopDragging]);
|
|
3889
|
+
useWindowSplitterResizeHandlerBehavior({
|
|
3890
|
+
disabled,
|
|
3891
|
+
handleId: resizeHandleId,
|
|
3892
|
+
resizeHandler,
|
|
3893
|
+
panelGroupElement
|
|
3894
|
+
});
|
|
3895
|
+
const style = {
|
|
3896
|
+
touchAction: "none",
|
|
3897
|
+
userSelect: "none"
|
|
3898
|
+
};
|
|
3899
|
+
return createElement(Type, {
|
|
3900
|
+
...rest,
|
|
3901
|
+
children,
|
|
3902
|
+
className: classNameFromProps,
|
|
3903
|
+
id: idFromProps,
|
|
3904
|
+
onBlur: () => {
|
|
3905
|
+
setIsFocused(false);
|
|
3906
|
+
onBlur === null || onBlur === undefined || onBlur();
|
|
3907
|
+
},
|
|
3908
|
+
onFocus: () => {
|
|
3909
|
+
setIsFocused(true);
|
|
3910
|
+
onFocus === null || onFocus === undefined || onFocus();
|
|
3911
|
+
},
|
|
3912
|
+
ref: elementRef,
|
|
3913
|
+
role: "separator",
|
|
3914
|
+
style: {
|
|
3915
|
+
...style,
|
|
3916
|
+
...styleFromProps
|
|
3917
|
+
},
|
|
3918
|
+
tabIndex,
|
|
3919
|
+
[DATA_ATTRIBUTES.groupDirection]: direction,
|
|
3920
|
+
[DATA_ATTRIBUTES.groupId]: groupId,
|
|
3921
|
+
[DATA_ATTRIBUTES.resizeHandle]: "",
|
|
3922
|
+
[DATA_ATTRIBUTES.resizeHandleActive]: state === "drag" ? "pointer" : isFocused ? "keyboard" : undefined,
|
|
3923
|
+
[DATA_ATTRIBUTES.resizeHandleEnabled]: !disabled,
|
|
3924
|
+
[DATA_ATTRIBUTES.resizeHandleId]: resizeHandleId,
|
|
3925
|
+
[DATA_ATTRIBUTES.resizeHandleState]: state
|
|
3926
|
+
});
|
|
3927
|
+
}
|
|
3928
|
+
PanelResizeHandle.displayName = "PanelResizeHandle";
|
|
3929
|
+
|
|
3930
|
+
// node_modules/@principal-ade/panels/dist/index.esm.js
|
|
3931
|
+
import { flushSync as y, unstable_batchedUpdates as w, createPortal as x } from "react-dom";
|
|
3932
|
+
import { useTheme as C } from "@principal-ade/industry-theme";
|
|
3933
|
+
function S(e2) {
|
|
3934
|
+
return { "--panel-background": e2.colors.background, "--panel-border": e2.colors.border, "--panel-handle": e2.colors.backgroundSecondary, "--panel-handle-hover": e2.colors.backgroundHover, "--panel-handle-active": e2.colors.primary, "--panel-button-bg": e2.colors.surface, "--panel-button-hover": e2.colors.backgroundHover, "--panel-button-border": e2.colors.border, "--panel-button-icon": e2.colors.textSecondary, "--panel-accent-bg": e2.colors.primary + "15" };
|
|
3935
|
+
}
|
|
3936
|
+
var D = ({ primaryContent: t2, secondaryContent: n2, collapsedHeader: r2, collapsed: o2 = true, onCollapsedChange: i2, ratio: a2 = 0.3, onRatioChange: l2, minRatio: s2 = 0.1, maxRatio: c2 = 0.8, collapsedHeight: d2 = 28, theme: u2, className: p2 = "", style: h2, animationDuration: m2 = 200, onCollapseStart: f2, onCollapseComplete: g, onExpandStart: v, onExpandComplete: b }) => {
|
|
3937
|
+
const y2 = S(u2);
|
|
3938
|
+
return n2 ? /* @__PURE__ */ e(z, { primaryContent: t2, secondaryContent: n2, collapsedHeader: r2 ?? { title: "Content" }, collapsed: o2, onCollapsedChange: i2 ?? (() => {}), ratio: a2, onRatioChange: l2 ?? (() => {}), minRatio: s2, maxRatio: c2, collapsedHeight: d2, theme: u2, className: p2, style: h2, animationDuration: m2, onCollapseStart: f2, onCollapseComplete: g, onExpandStart: v, onExpandComplete: b }) : /* @__PURE__ */ e("div", { className: `collapsible-split-pane ${p2}`, style: { ...y2, ...h2 }, children: /* @__PURE__ */ e("div", { className: "csp-primary-content-full", children: t2 }) });
|
|
3939
|
+
};
|
|
3940
|
+
var z = ({ primaryContent: r2, secondaryContent: s2, collapsedHeader: c2, collapsed: d2, onCollapsedChange: u2, ratio: p2, onRatioChange: h2, minRatio: m2 = 0.1, maxRatio: f2 = 0.8, collapsedHeight: y2 = 28, theme: w2, className: x2 = "", style: C2, animationDuration: R = 200, onCollapseStart: N, onCollapseComplete: E, onExpandStart: D2, onExpandComplete: z2 }) => {
|
|
3941
|
+
const [M, T] = o(false), [A, k] = o(false), L = i(null), P = i(undefined), F = i(undefined), $ = i(p2), B = (e2) => 100 * e2;
|
|
3942
|
+
l(() => {
|
|
3943
|
+
!d2 && p2 > 0 && ($.current = p2);
|
|
3944
|
+
}, [d2, p2]);
|
|
3945
|
+
const O = a((e2, t2, n2) => {
|
|
3946
|
+
if (!L.current)
|
|
3947
|
+
return;
|
|
3948
|
+
P.current && cancelAnimationFrame(P.current), F.current = performance.now();
|
|
3949
|
+
const r3 = (o2) => {
|
|
3950
|
+
if (!F.current || !L.current)
|
|
3951
|
+
return;
|
|
3952
|
+
const i2 = o2 - F.current, a2 = Math.min(i2 / R, 1), l2 = a2 < 0.5 ? 4 * a2 * a2 * a2 : 1 - Math.pow(-2 * a2 + 2, 3) / 2, s3 = e2 + (t2 - e2) * l2;
|
|
3953
|
+
L.current.resize(s3), a2 < 1 ? P.current = requestAnimationFrame(r3) : (t2 === 0 ? L.current.collapse() : L.current.resize(t2), T(false), n2 && n2());
|
|
3954
|
+
};
|
|
3955
|
+
P.current = requestAnimationFrame(r3);
|
|
3956
|
+
}, [R]), I = a(() => {
|
|
3957
|
+
if (M || A)
|
|
3958
|
+
return;
|
|
3959
|
+
T(true), N?.();
|
|
3960
|
+
const e2 = B(p2);
|
|
3961
|
+
O(e2, 0, () => {
|
|
3962
|
+
u2(true), E?.();
|
|
3963
|
+
});
|
|
3964
|
+
}, [M, A, p2, O, u2, N, E]), q = a(() => {
|
|
3965
|
+
if (M || A)
|
|
3966
|
+
return;
|
|
3967
|
+
T(true), D2?.();
|
|
3968
|
+
const e2 = $.current || p2 || 0.3, t2 = B(e2);
|
|
3969
|
+
O(0, t2, () => {
|
|
3970
|
+
u2(false), h2(e2), z2?.();
|
|
3971
|
+
});
|
|
3972
|
+
}, [M, A, p2, O, u2, h2, D2, z2]), H = a(() => {
|
|
3973
|
+
d2 ? q() : I();
|
|
3974
|
+
}, [d2, I, q]), W = a((e2) => {
|
|
3975
|
+
if (!M && !d2) {
|
|
3976
|
+
const t2 = e2 / 100;
|
|
3977
|
+
h2(t2);
|
|
3978
|
+
}
|
|
3979
|
+
}, [M, d2, h2]), j = a(() => {
|
|
3980
|
+
k(true);
|
|
3981
|
+
}, []), K = a(() => {
|
|
3982
|
+
k(false);
|
|
3983
|
+
}, []);
|
|
3984
|
+
l(() => {
|
|
3985
|
+
if (d2 && !M && L.current) {
|
|
3986
|
+
L.current.getSize() > 0 && I();
|
|
3987
|
+
} else if (!d2 && !M && L.current) {
|
|
3988
|
+
L.current.getSize() === 0 && q();
|
|
3989
|
+
}
|
|
3990
|
+
}, [d2]), l(() => () => {
|
|
3991
|
+
P.current && cancelAnimationFrame(P.current);
|
|
3992
|
+
}, []);
|
|
3993
|
+
const U = S(w2), X2 = ["csp-secondary-panel", M && !A ? "csp-animating" : "", d2 ? "csp-collapsed" : ""].filter(Boolean).join(" ");
|
|
3994
|
+
return e("div", { className: `collapsible-split-pane ${x2}`, style: { ...U, ...C2 }, children: d2 ? /* @__PURE__ */ t(n, { children: [
|
|
3995
|
+
/* @__PURE__ */ t("div", { className: "csp-collapsed-header", style: { height: y2 }, onClick: H, role: "button", tabIndex: 0, onKeyDown: (e2) => {
|
|
3996
|
+
e2.key !== "Enter" && e2.key !== " " || (e2.preventDefault(), H());
|
|
3997
|
+
}, "aria-expanded": false, "aria-label": `Expand ${c2.title}`, children: [
|
|
3998
|
+
c2.icon && /* @__PURE__ */ e("span", { className: "csp-collapsed-header-icon", children: c2.icon }),
|
|
3999
|
+
/* @__PURE__ */ e("span", { className: "csp-collapsed-header-title", children: c2.title }),
|
|
4000
|
+
/* @__PURE__ */ e("button", { className: "csp-collapsed-header-expand", onClick: (e2) => {
|
|
4001
|
+
e2.stopPropagation(), H();
|
|
4002
|
+
}, "aria-label": `Expand ${c2.title}`, children: /* @__PURE__ */ e("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", children: /* @__PURE__ */ e("path", { d: "M3 5L6 8L9 5" }) }) })
|
|
4003
|
+
] }),
|
|
4004
|
+
/* @__PURE__ */ e("div", { className: "csp-primary-content-full", children: r2 })
|
|
4005
|
+
] }) : /* @__PURE__ */ t(PanelGroup, { direction: "vertical", onLayout: K, children: [
|
|
4006
|
+
/* @__PURE__ */ e(Panel, { ref: L, collapsible: true, defaultSize: B(p2), minSize: B(m2), maxSize: B(f2), collapsedSize: 0, onResize: W, onCollapse: () => u2(true), className: X2, children: /* @__PURE__ */ t("div", { className: "csp-panel-content", children: [
|
|
4007
|
+
/* @__PURE__ */ t("div", { className: "csp-secondary-header", children: [
|
|
4008
|
+
c2.icon && /* @__PURE__ */ e("span", { className: "csp-secondary-header-icon", children: c2.icon }),
|
|
4009
|
+
/* @__PURE__ */ e("span", { className: "csp-secondary-header-title", children: c2.title }),
|
|
4010
|
+
/* @__PURE__ */ e("button", { className: "csp-secondary-header-collapse", onClick: I, "aria-label": `Collapse ${c2.title}`, children: /* @__PURE__ */ e("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", children: /* @__PURE__ */ e("path", { d: "M3 7L6 4L9 7" }) }) })
|
|
4011
|
+
] }),
|
|
4012
|
+
/* @__PURE__ */ e("div", { className: "csp-secondary-body", children: s2 })
|
|
4013
|
+
] }) }),
|
|
4014
|
+
/* @__PURE__ */ e(PanelResizeHandle, { className: "csp-resize-handle", onDragging: j, children: /* @__PURE__ */ e("div", { className: "csp-resize-handle-bar" }) }),
|
|
4015
|
+
/* @__PURE__ */ e(Panel, { className: "csp-primary-panel", minSize: 20, children: /* @__PURE__ */ e("div", { className: "csp-panel-content", children: r2 }) })
|
|
4016
|
+
] }) });
|
|
4017
|
+
};
|
|
4018
|
+
var A = s(null);
|
|
4019
|
+
var $ = d(({ panels: o2, className: a2 = "", style: s2, theme: c2, minPanelWidth: d2 = 350, idealPanelWidth: p2 = 0.333, showSeparator: h2 = false, onPanelChange: m2, preventKeyboardScroll: f2 = true, disableSwipe: g = false }, v) => {
|
|
4020
|
+
const b = i(null), y2 = i(false), w2 = i(null), x2 = S(c2);
|
|
4021
|
+
u(v, () => ({ scrollToPanel: (e2) => {
|
|
4022
|
+
if (!b.current)
|
|
4023
|
+
return;
|
|
4024
|
+
const t2 = b.current, n2 = t2.children[e2];
|
|
4025
|
+
if (n2) {
|
|
4026
|
+
y2.current = true, w2.current && clearTimeout(w2.current);
|
|
4027
|
+
const e3 = n2.offsetLeft;
|
|
4028
|
+
t2.scrollTo({ left: e3, behavior: "smooth" }), w2.current = setTimeout(() => {
|
|
4029
|
+
y2.current = false;
|
|
4030
|
+
}, 500);
|
|
4031
|
+
}
|
|
4032
|
+
}, getCurrentPanel: () => {
|
|
4033
|
+
if (!b.current || b.current.children.length === 0)
|
|
4034
|
+
return 0;
|
|
4035
|
+
const e2 = b.current, t2 = e2.getBoundingClientRect().left;
|
|
4036
|
+
let n2 = 0, r2 = 1 / 0;
|
|
4037
|
+
for (let o3 = 0;o3 < e2.children.length; o3++) {
|
|
4038
|
+
const i2 = e2.children[o3].getBoundingClientRect(), a3 = Math.abs(i2.left - t2);
|
|
4039
|
+
a3 < r2 && (r2 = a3, n2 = o3);
|
|
4040
|
+
}
|
|
4041
|
+
return n2;
|
|
4042
|
+
} }));
|
|
4043
|
+
l(() => {
|
|
4044
|
+
if (!f2 || !b.current)
|
|
4045
|
+
return;
|
|
4046
|
+
const e2 = b.current, t2 = (e3) => {
|
|
4047
|
+
const t3 = e3.target;
|
|
4048
|
+
if (t3.tagName === "INPUT" || t3.tagName === "TEXTAREA" || t3.tagName === "SELECT" || t3.isContentEditable || t3.closest(".xterm") !== null || t3.closest('[contenteditable="true"]') !== null)
|
|
4049
|
+
return;
|
|
4050
|
+
[" ", "Space", "ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "PageUp", "PageDown"].includes(e3.key) && e3.preventDefault();
|
|
4051
|
+
};
|
|
4052
|
+
return e2.addEventListener("keydown", t2), () => {
|
|
4053
|
+
e2.removeEventListener("keydown", t2);
|
|
4054
|
+
};
|
|
4055
|
+
}, [f2]), l(() => () => {
|
|
4056
|
+
w2.current && clearTimeout(w2.current);
|
|
4057
|
+
}, []);
|
|
4058
|
+
const C2 = o2.length, R = 2 * d2;
|
|
4059
|
+
let N;
|
|
4060
|
+
N = C2 === 1 || C2 === 2 ? "100%" : `max(${d2}px, ${100 * p2}%)`;
|
|
4061
|
+
const E = r.useId().replace(/:/g, "_");
|
|
4062
|
+
return t(n, { children: [
|
|
4063
|
+
C2 === 2 && /* @__PURE__ */ e("style", { children: `
|
|
4064
|
+
.snap-carousel-container[data-carousel-id="${E}"][data-panel-count="2"] .snap-carousel-panel {
|
|
4065
|
+
width: 100%;
|
|
4066
|
+
}
|
|
4067
|
+
@container (min-width: ${R}px) {
|
|
4068
|
+
.snap-carousel-container[data-carousel-id="${E}"][data-panel-count="2"] .snap-carousel-panel {
|
|
4069
|
+
width: 50%;
|
|
4070
|
+
}
|
|
4071
|
+
}
|
|
4072
|
+
` }),
|
|
4073
|
+
/* @__PURE__ */ e("div", { ref: b, className: `snap-carousel-container ${g ? "swipe-disabled" : ""} ${a2}`, style: { ...x2, ...s2, "--snap-carousel-min-width": `${d2}px`, "--snap-carousel-ideal-width": 100 * p2 + "%", "--snap-carousel-gap": h2 ? "1px" : "0px", "--snap-carousel-panel-width": N, "--snap-carousel-panel-count": C2, "--snap-carousel-two-panel-threshold": `${R}px` }, onScroll: (e2) => {
|
|
4074
|
+
if (!m2 || !b.current || b.current.children.length === 0)
|
|
4075
|
+
return;
|
|
4076
|
+
if (y2.current)
|
|
4077
|
+
return;
|
|
4078
|
+
const t2 = b.current, n2 = t2.getBoundingClientRect().left;
|
|
4079
|
+
let r2 = 0, o3 = 1 / 0;
|
|
4080
|
+
for (let i2 = 0;i2 < t2.children.length; i2++) {
|
|
4081
|
+
const e3 = t2.children[i2].getBoundingClientRect(), a3 = Math.abs(e3.left - n2);
|
|
4082
|
+
a3 < o3 && (o3 = a3, r2 = i2);
|
|
4083
|
+
}
|
|
4084
|
+
m2(r2);
|
|
4085
|
+
}, "data-panel-count": C2, "data-carousel-id": E, children: o2.map((t2, n2) => /* @__PURE__ */ e("div", { className: "snap-carousel-panel", children: t2 }, n2)) })
|
|
4086
|
+
] });
|
|
4087
|
+
});
|
|
4088
|
+
$.displayName = "SnapCarousel";
|
|
4089
|
+
var I = typeof window != "undefined" && window.document !== undefined && window.document.createElement !== undefined;
|
|
4090
|
+
function q(e2) {
|
|
4091
|
+
const t2 = Object.prototype.toString.call(e2);
|
|
4092
|
+
return t2 === "[object Window]" || t2 === "[object global]";
|
|
4093
|
+
}
|
|
4094
|
+
function H(e2) {
|
|
4095
|
+
return "nodeType" in e2;
|
|
4096
|
+
}
|
|
4097
|
+
function W(e2) {
|
|
4098
|
+
var t2, n2;
|
|
4099
|
+
return e2 ? q(e2) ? e2 : H(e2) && (t2 = (n2 = e2.ownerDocument) == null ? undefined : n2.defaultView) != null ? t2 : window : window;
|
|
4100
|
+
}
|
|
4101
|
+
function j(e2) {
|
|
4102
|
+
const { Document: t2 } = W(e2);
|
|
4103
|
+
return e2 instanceof t2;
|
|
4104
|
+
}
|
|
4105
|
+
function K(e2) {
|
|
4106
|
+
return !q(e2) && e2 instanceof W(e2).HTMLElement;
|
|
4107
|
+
}
|
|
4108
|
+
function U(e2) {
|
|
4109
|
+
return e2 instanceof W(e2).SVGElement;
|
|
4110
|
+
}
|
|
4111
|
+
function X2(e2) {
|
|
4112
|
+
return e2 ? q(e2) ? e2.document : H(e2) ? j(e2) ? e2 : K(e2) || U(e2) ? e2.ownerDocument : document : document : document;
|
|
4113
|
+
}
|
|
4114
|
+
function te(e2) {
|
|
4115
|
+
return function(t2) {
|
|
4116
|
+
for (var n2 = arguments.length, r2 = new Array(n2 > 1 ? n2 - 1 : 0), o2 = 1;o2 < n2; o2++)
|
|
4117
|
+
r2[o2 - 1] = arguments[o2];
|
|
4118
|
+
return r2.reduce((t3, n3) => {
|
|
4119
|
+
const r3 = Object.entries(n3);
|
|
4120
|
+
for (const [o3, i2] of r3) {
|
|
4121
|
+
const n4 = t3[o3];
|
|
4122
|
+
n4 != null && (t3[o3] = n4 + e2 * i2);
|
|
4123
|
+
}
|
|
4124
|
+
return t3;
|
|
4125
|
+
}, { ...t2 });
|
|
4126
|
+
};
|
|
4127
|
+
}
|
|
4128
|
+
var ne = /* @__PURE__ */ te(1);
|
|
4129
|
+
var re = /* @__PURE__ */ te(-1);
|
|
4130
|
+
function oe(e2) {
|
|
4131
|
+
if (!e2)
|
|
4132
|
+
return false;
|
|
4133
|
+
const { KeyboardEvent: t2 } = W(e2.target);
|
|
4134
|
+
return t2 && e2 instanceof t2;
|
|
4135
|
+
}
|
|
4136
|
+
function ie(e2) {
|
|
4137
|
+
if (function(e3) {
|
|
4138
|
+
if (!e3)
|
|
4139
|
+
return false;
|
|
4140
|
+
const { TouchEvent: t2 } = W(e3.target);
|
|
4141
|
+
return t2 && e3 instanceof t2;
|
|
4142
|
+
}(e2)) {
|
|
4143
|
+
if (e2.touches && e2.touches.length) {
|
|
4144
|
+
const { clientX: t2, clientY: n2 } = e2.touches[0];
|
|
4145
|
+
return { x: t2, y: n2 };
|
|
4146
|
+
}
|
|
4147
|
+
if (e2.changedTouches && e2.changedTouches.length) {
|
|
4148
|
+
const { clientX: t2, clientY: n2 } = e2.changedTouches[0];
|
|
4149
|
+
return { x: t2, y: n2 };
|
|
4150
|
+
}
|
|
4151
|
+
}
|
|
4152
|
+
return function(e3) {
|
|
4153
|
+
return "clientX" in e3 && "clientY" in e3;
|
|
4154
|
+
}(e2) ? { x: e2.clientX, y: e2.clientY } : null;
|
|
4155
|
+
}
|
|
4156
|
+
var fe;
|
|
4157
|
+
var ge;
|
|
4158
|
+
(ge = fe || (fe = {})).DragStart = "dragStart", ge.DragMove = "dragMove", ge.DragEnd = "dragEnd", ge.DragCancel = "dragCancel", ge.DragOver = "dragOver", ge.RegisterDroppable = "registerDroppable", ge.SetDroppableDisabled = "setDroppableDisabled", ge.UnregisterDroppable = "unregisterDroppable";
|
|
4159
|
+
var be = /* @__PURE__ */ Object.freeze({ x: 0, y: 0 });
|
|
4160
|
+
var Me = { ignoreTransform: false };
|
|
4161
|
+
function Te(e2, t2) {
|
|
4162
|
+
t2 === undefined && (t2 = Me);
|
|
4163
|
+
let n2 = e2.getBoundingClientRect();
|
|
4164
|
+
if (t2.ignoreTransform) {
|
|
4165
|
+
const { transform: t3, transformOrigin: r3 } = W(e2).getComputedStyle(e2);
|
|
4166
|
+
t3 && (n2 = function(e3, t4, n3) {
|
|
4167
|
+
const r4 = function(e4) {
|
|
4168
|
+
if (e4.startsWith("matrix3d(")) {
|
|
4169
|
+
const t5 = e4.slice(9, -1).split(/, /);
|
|
4170
|
+
return { x: +t5[12], y: +t5[13], scaleX: +t5[0], scaleY: +t5[5] };
|
|
4171
|
+
}
|
|
4172
|
+
if (e4.startsWith("matrix(")) {
|
|
4173
|
+
const t5 = e4.slice(7, -1).split(/, /);
|
|
4174
|
+
return { x: +t5[4], y: +t5[5], scaleX: +t5[0], scaleY: +t5[3] };
|
|
4175
|
+
}
|
|
4176
|
+
return null;
|
|
4177
|
+
}(t4);
|
|
4178
|
+
if (!r4)
|
|
4179
|
+
return e3;
|
|
4180
|
+
const { scaleX: o3, scaleY: i3, x: a3, y: l3 } = r4, s3 = e3.left - a3 - (1 - o3) * parseFloat(n3), c2 = e3.top - l3 - (1 - i3) * parseFloat(n3.slice(n3.indexOf(" ") + 1)), d2 = o3 ? e3.width / o3 : e3.width, u2 = i3 ? e3.height / i3 : e3.height;
|
|
4181
|
+
return { width: d2, height: u2, top: c2, right: s3 + d2, bottom: c2 + u2, left: s3 };
|
|
4182
|
+
}(n2, t3, r3));
|
|
4183
|
+
}
|
|
4184
|
+
const { top: r2, left: o2, width: i2, height: a2, bottom: l2, right: s2 } = n2;
|
|
4185
|
+
return { top: r2, left: o2, width: i2, height: a2, bottom: l2, right: s2 };
|
|
4186
|
+
}
|
|
4187
|
+
function Ae(e2) {
|
|
4188
|
+
return Te(e2, { ignoreTransform: true });
|
|
4189
|
+
}
|
|
4190
|
+
function ke(e2, t2) {
|
|
4191
|
+
const n2 = [];
|
|
4192
|
+
return e2 ? function r(o2) {
|
|
4193
|
+
if (t2 != null && n2.length >= t2)
|
|
4194
|
+
return n2;
|
|
4195
|
+
if (!o2)
|
|
4196
|
+
return n2;
|
|
4197
|
+
if (j(o2) && o2.scrollingElement != null && !n2.includes(o2.scrollingElement))
|
|
4198
|
+
return n2.push(o2.scrollingElement), n2;
|
|
4199
|
+
if (!K(o2) || U(o2))
|
|
4200
|
+
return n2;
|
|
4201
|
+
if (n2.includes(o2))
|
|
4202
|
+
return n2;
|
|
4203
|
+
const i2 = W(e2).getComputedStyle(o2);
|
|
4204
|
+
return o2 !== e2 && function(e3, t3) {
|
|
4205
|
+
t3 === undefined && (t3 = W(e3).getComputedStyle(e3));
|
|
4206
|
+
const n3 = /(auto|scroll|overlay)/;
|
|
4207
|
+
return ["overflow", "overflowX", "overflowY"].some((e4) => {
|
|
4208
|
+
const r2 = t3[e4];
|
|
4209
|
+
return typeof r2 == "string" && n3.test(r2);
|
|
4210
|
+
});
|
|
4211
|
+
}(o2, i2) && n2.push(o2), function(e3, t3) {
|
|
4212
|
+
return t3 === undefined && (t3 = W(e3).getComputedStyle(e3)), t3.position === "fixed";
|
|
4213
|
+
}(o2, i2) ? n2 : r(o2.parentNode);
|
|
4214
|
+
}(e2) : n2;
|
|
4215
|
+
}
|
|
4216
|
+
function Le(e2) {
|
|
4217
|
+
const [t2] = ke(e2, 1);
|
|
4218
|
+
return t2 != null ? t2 : null;
|
|
4219
|
+
}
|
|
4220
|
+
var Oe;
|
|
4221
|
+
var Ie;
|
|
4222
|
+
function qe(e2) {
|
|
4223
|
+
return !(!I || !e2) && e2 === document.scrollingElement;
|
|
4224
|
+
}
|
|
4225
|
+
function He(e2) {
|
|
4226
|
+
const t2 = { x: 0, y: 0 }, n2 = qe(e2) ? { height: window.innerHeight, width: window.innerWidth } : { height: e2.clientHeight, width: e2.clientWidth }, r2 = { x: e2.scrollWidth - n2.width, y: e2.scrollHeight - n2.height };
|
|
4227
|
+
return { isTop: e2.scrollTop <= t2.y, isLeft: e2.scrollLeft <= t2.x, isBottom: e2.scrollTop >= r2.y, isRight: e2.scrollLeft >= r2.x, maxScroll: r2, minScroll: t2 };
|
|
4228
|
+
}
|
|
4229
|
+
(Ie = Oe || (Oe = {}))[Ie.Forward = 1] = "Forward", Ie[Ie.Backward = -1] = "Backward";
|
|
4230
|
+
function Ke(e2) {
|
|
4231
|
+
if (e2 === document.scrollingElement) {
|
|
4232
|
+
const { innerWidth: e3, innerHeight: t3 } = window;
|
|
4233
|
+
return { top: 0, left: 0, right: e3, bottom: t3, width: e3, height: t3 };
|
|
4234
|
+
}
|
|
4235
|
+
const { top: t2, left: n2, right: r2, bottom: o2 } = e2.getBoundingClientRect();
|
|
4236
|
+
return { top: t2, left: n2, right: r2, bottom: o2, width: e2.clientWidth, height: e2.clientHeight };
|
|
4237
|
+
}
|
|
4238
|
+
class Ve {
|
|
4239
|
+
constructor(e2) {
|
|
4240
|
+
this.target = undefined, this.listeners = [], this.removeAll = () => {
|
|
4241
|
+
this.listeners.forEach((e3) => {
|
|
4242
|
+
var t2;
|
|
4243
|
+
return (t2 = this.target) == null ? undefined : t2.removeEventListener(...e3);
|
|
4244
|
+
});
|
|
4245
|
+
}, this.target = e2;
|
|
4246
|
+
}
|
|
4247
|
+
add(e2, t2, n2) {
|
|
4248
|
+
var r2;
|
|
4249
|
+
(r2 = this.target) == null || r2.addEventListener(e2, t2, n2), this.listeners.push([e2, t2, n2]);
|
|
4250
|
+
}
|
|
4251
|
+
}
|
|
4252
|
+
function Je(e2, t2) {
|
|
4253
|
+
const n2 = Math.abs(e2.x), r2 = Math.abs(e2.y);
|
|
4254
|
+
return typeof t2 == "number" ? Math.sqrt(n2 ** 2 + r2 ** 2) > t2 : ("x" in t2) && ("y" in t2) ? n2 > t2.x && r2 > t2.y : ("x" in t2) ? n2 > t2.x : ("y" in t2) && r2 > t2.y;
|
|
4255
|
+
}
|
|
4256
|
+
var Ge;
|
|
4257
|
+
var _e;
|
|
4258
|
+
var Qe;
|
|
4259
|
+
var Ze;
|
|
4260
|
+
function et(e2) {
|
|
4261
|
+
e2.preventDefault();
|
|
4262
|
+
}
|
|
4263
|
+
function tt(e2) {
|
|
4264
|
+
e2.stopPropagation();
|
|
4265
|
+
}
|
|
4266
|
+
(_e = Ge || (Ge = {})).Click = "click", _e.DragStart = "dragstart", _e.Keydown = "keydown", _e.ContextMenu = "contextmenu", _e.Resize = "resize", _e.SelectionChange = "selectionchange", _e.VisibilityChange = "visibilitychange", (Ze = Qe || (Qe = {})).Space = "Space", Ze.Down = "ArrowDown", Ze.Right = "ArrowRight", Ze.Left = "ArrowLeft", Ze.Up = "ArrowUp", Ze.Esc = "Escape", Ze.Enter = "Enter", Ze.Tab = "Tab";
|
|
4267
|
+
var nt = { start: [Qe.Space, Qe.Enter], cancel: [Qe.Esc], end: [Qe.Space, Qe.Enter, Qe.Tab] };
|
|
4268
|
+
var rt = (e2, t2) => {
|
|
4269
|
+
let { currentCoordinates: n2 } = t2;
|
|
4270
|
+
switch (e2.code) {
|
|
4271
|
+
case Qe.Right:
|
|
4272
|
+
return { ...n2, x: n2.x + 25 };
|
|
4273
|
+
case Qe.Left:
|
|
4274
|
+
return { ...n2, x: n2.x - 25 };
|
|
4275
|
+
case Qe.Down:
|
|
4276
|
+
return { ...n2, y: n2.y + 25 };
|
|
4277
|
+
case Qe.Up:
|
|
4278
|
+
return { ...n2, y: n2.y - 25 };
|
|
4279
|
+
}
|
|
4280
|
+
};
|
|
4281
|
+
|
|
4282
|
+
class ot {
|
|
4283
|
+
constructor(e2) {
|
|
4284
|
+
this.props = undefined, this.autoScrollEnabled = false, this.referenceCoordinates = undefined, this.listeners = undefined, this.windowListeners = undefined, this.props = e2;
|
|
4285
|
+
const { event: { target: t2 } } = e2;
|
|
4286
|
+
this.props = e2, this.listeners = new Ve(X2(t2)), this.windowListeners = new Ve(W(t2)), this.handleKeyDown = this.handleKeyDown.bind(this), this.handleCancel = this.handleCancel.bind(this), this.attach();
|
|
4287
|
+
}
|
|
4288
|
+
attach() {
|
|
4289
|
+
this.handleStart(), this.windowListeners.add(Ge.Resize, this.handleCancel), this.windowListeners.add(Ge.VisibilityChange, this.handleCancel), setTimeout(() => this.listeners.add(Ge.Keydown, this.handleKeyDown));
|
|
4290
|
+
}
|
|
4291
|
+
handleStart() {
|
|
4292
|
+
const { activeNode: e2, onStart: t2 } = this.props, n2 = e2.node.current;
|
|
4293
|
+
n2 && function(e3, t3) {
|
|
4294
|
+
if (t3 === undefined && (t3 = Te), !e3)
|
|
4295
|
+
return;
|
|
4296
|
+
const { top: n3, left: r2, bottom: o2, right: i2 } = t3(e3);
|
|
4297
|
+
Le(e3) && (o2 <= 0 || i2 <= 0 || n3 >= window.innerHeight || r2 >= window.innerWidth) && e3.scrollIntoView({ block: "center", inline: "center" });
|
|
4298
|
+
}(n2), t2(be);
|
|
4299
|
+
}
|
|
4300
|
+
handleKeyDown(e2) {
|
|
4301
|
+
if (oe(e2)) {
|
|
4302
|
+
const { active: t2, context: n2, options: r2 } = this.props, { keyboardCodes: o2 = nt, coordinateGetter: i2 = rt, scrollBehavior: a2 = "smooth" } = r2, { code: l2 } = e2;
|
|
4303
|
+
if (o2.end.includes(l2))
|
|
4304
|
+
return void this.handleEnd(e2);
|
|
4305
|
+
if (o2.cancel.includes(l2))
|
|
4306
|
+
return void this.handleCancel(e2);
|
|
4307
|
+
const { collisionRect: s2 } = n2.current, c2 = s2 ? { x: s2.left, y: s2.top } : be;
|
|
4308
|
+
this.referenceCoordinates || (this.referenceCoordinates = c2);
|
|
4309
|
+
const d2 = i2(e2, { active: t2, context: n2.current, currentCoordinates: c2 });
|
|
4310
|
+
if (d2) {
|
|
4311
|
+
const t3 = re(d2, c2), r3 = { x: 0, y: 0 }, { scrollableAncestors: o3 } = n2.current;
|
|
4312
|
+
for (const n3 of o3) {
|
|
4313
|
+
const o4 = e2.code, { isTop: i3, isRight: l3, isLeft: s3, isBottom: c3, maxScroll: u2, minScroll: p2 } = He(n3), h2 = Ke(n3), m2 = { x: Math.min(o4 === Qe.Right ? h2.right - h2.width / 2 : h2.right, Math.max(o4 === Qe.Right ? h2.left : h2.left + h2.width / 2, d2.x)), y: Math.min(o4 === Qe.Down ? h2.bottom - h2.height / 2 : h2.bottom, Math.max(o4 === Qe.Down ? h2.top : h2.top + h2.height / 2, d2.y)) }, f2 = o4 === Qe.Right && !l3 || o4 === Qe.Left && !s3, g = o4 === Qe.Down && !c3 || o4 === Qe.Up && !i3;
|
|
4314
|
+
if (f2 && m2.x !== d2.x) {
|
|
4315
|
+
const e3 = n3.scrollLeft + t3.x, i4 = o4 === Qe.Right && e3 <= u2.x || o4 === Qe.Left && e3 >= p2.x;
|
|
4316
|
+
if (i4 && !t3.y)
|
|
4317
|
+
return void n3.scrollTo({ left: e3, behavior: a2 });
|
|
4318
|
+
r3.x = i4 ? n3.scrollLeft - e3 : o4 === Qe.Right ? n3.scrollLeft - u2.x : n3.scrollLeft - p2.x, r3.x && n3.scrollBy({ left: -r3.x, behavior: a2 });
|
|
4319
|
+
break;
|
|
4320
|
+
}
|
|
4321
|
+
if (g && m2.y !== d2.y) {
|
|
4322
|
+
const e3 = n3.scrollTop + t3.y, i4 = o4 === Qe.Down && e3 <= u2.y || o4 === Qe.Up && e3 >= p2.y;
|
|
4323
|
+
if (i4 && !t3.x)
|
|
4324
|
+
return void n3.scrollTo({ top: e3, behavior: a2 });
|
|
4325
|
+
r3.y = i4 ? n3.scrollTop - e3 : o4 === Qe.Down ? n3.scrollTop - u2.y : n3.scrollTop - p2.y, r3.y && n3.scrollBy({ top: -r3.y, behavior: a2 });
|
|
4326
|
+
break;
|
|
4327
|
+
}
|
|
4328
|
+
}
|
|
4329
|
+
this.handleMove(e2, ne(re(d2, this.referenceCoordinates), r3));
|
|
4330
|
+
}
|
|
4331
|
+
}
|
|
4332
|
+
}
|
|
4333
|
+
handleMove(e2, t2) {
|
|
4334
|
+
const { onMove: n2 } = this.props;
|
|
4335
|
+
e2.preventDefault(), n2(t2);
|
|
4336
|
+
}
|
|
4337
|
+
handleEnd(e2) {
|
|
4338
|
+
const { onEnd: t2 } = this.props;
|
|
4339
|
+
e2.preventDefault(), this.detach(), t2();
|
|
4340
|
+
}
|
|
4341
|
+
handleCancel(e2) {
|
|
4342
|
+
const { onCancel: t2 } = this.props;
|
|
4343
|
+
e2.preventDefault(), this.detach(), t2();
|
|
4344
|
+
}
|
|
4345
|
+
detach() {
|
|
4346
|
+
this.listeners.removeAll(), this.windowListeners.removeAll();
|
|
4347
|
+
}
|
|
4348
|
+
}
|
|
4349
|
+
function it(e2) {
|
|
4350
|
+
return Boolean(e2 && "distance" in e2);
|
|
4351
|
+
}
|
|
4352
|
+
function at(e2) {
|
|
4353
|
+
return Boolean(e2 && "delay" in e2);
|
|
4354
|
+
}
|
|
4355
|
+
ot.activators = [{ eventName: "onKeyDown", handler: (e2, t2, n2) => {
|
|
4356
|
+
let { keyboardCodes: r2 = nt, onActivation: o2 } = t2, { active: i2 } = n2;
|
|
4357
|
+
const { code: a2 } = e2.nativeEvent;
|
|
4358
|
+
if (r2.start.includes(a2)) {
|
|
4359
|
+
const t3 = i2.activatorNode.current;
|
|
4360
|
+
return (!t3 || e2.target === t3) && (e2.preventDefault(), o2 == null || o2({ event: e2.nativeEvent }), true);
|
|
4361
|
+
}
|
|
4362
|
+
return false;
|
|
4363
|
+
} }];
|
|
4364
|
+
|
|
4365
|
+
class lt {
|
|
4366
|
+
constructor(e2, t2, n2) {
|
|
4367
|
+
var r2;
|
|
4368
|
+
n2 === undefined && (n2 = function(e3) {
|
|
4369
|
+
const { EventTarget: t3 } = W(e3);
|
|
4370
|
+
return e3 instanceof t3 ? e3 : X2(e3);
|
|
4371
|
+
}(e2.event.target)), this.props = undefined, this.events = undefined, this.autoScrollEnabled = true, this.document = undefined, this.activated = false, this.initialCoordinates = undefined, this.timeoutId = null, this.listeners = undefined, this.documentListeners = undefined, this.windowListeners = undefined, this.props = e2, this.events = t2;
|
|
4372
|
+
const { event: o2 } = e2, { target: i2 } = o2;
|
|
4373
|
+
this.props = e2, this.events = t2, this.document = X2(i2), this.documentListeners = new Ve(this.document), this.listeners = new Ve(n2), this.windowListeners = new Ve(W(i2)), this.initialCoordinates = (r2 = ie(o2)) != null ? r2 : be, this.handleStart = this.handleStart.bind(this), this.handleMove = this.handleMove.bind(this), this.handleEnd = this.handleEnd.bind(this), this.handleCancel = this.handleCancel.bind(this), this.handleKeydown = this.handleKeydown.bind(this), this.removeTextSelection = this.removeTextSelection.bind(this), this.attach();
|
|
4374
|
+
}
|
|
4375
|
+
attach() {
|
|
4376
|
+
const { events: e2, props: { options: { activationConstraint: t2, bypassActivationConstraint: n2 } } } = this;
|
|
4377
|
+
if (this.listeners.add(e2.move.name, this.handleMove, { passive: false }), this.listeners.add(e2.end.name, this.handleEnd), e2.cancel && this.listeners.add(e2.cancel.name, this.handleCancel), this.windowListeners.add(Ge.Resize, this.handleCancel), this.windowListeners.add(Ge.DragStart, et), this.windowListeners.add(Ge.VisibilityChange, this.handleCancel), this.windowListeners.add(Ge.ContextMenu, et), this.documentListeners.add(Ge.Keydown, this.handleKeydown), t2) {
|
|
4378
|
+
if (n2 != null && n2({ event: this.props.event, activeNode: this.props.activeNode, options: this.props.options }))
|
|
4379
|
+
return this.handleStart();
|
|
4380
|
+
if (at(t2))
|
|
4381
|
+
return this.timeoutId = setTimeout(this.handleStart, t2.delay), void this.handlePending(t2);
|
|
4382
|
+
if (it(t2))
|
|
4383
|
+
return void this.handlePending(t2);
|
|
4384
|
+
}
|
|
4385
|
+
this.handleStart();
|
|
4386
|
+
}
|
|
4387
|
+
detach() {
|
|
4388
|
+
this.listeners.removeAll(), this.windowListeners.removeAll(), setTimeout(this.documentListeners.removeAll, 50), this.timeoutId !== null && (clearTimeout(this.timeoutId), this.timeoutId = null);
|
|
4389
|
+
}
|
|
4390
|
+
handlePending(e2, t2) {
|
|
4391
|
+
const { active: n2, onPending: r2 } = this.props;
|
|
4392
|
+
r2(n2, e2, this.initialCoordinates, t2);
|
|
4393
|
+
}
|
|
4394
|
+
handleStart() {
|
|
4395
|
+
const { initialCoordinates: e2 } = this, { onStart: t2 } = this.props;
|
|
4396
|
+
e2 && (this.activated = true, this.documentListeners.add(Ge.Click, tt, { capture: true }), this.removeTextSelection(), this.documentListeners.add(Ge.SelectionChange, this.removeTextSelection), t2(e2));
|
|
4397
|
+
}
|
|
4398
|
+
handleMove(e2) {
|
|
4399
|
+
var t2;
|
|
4400
|
+
const { activated: n2, initialCoordinates: r2, props: o2 } = this, { onMove: i2, options: { activationConstraint: a2 } } = o2;
|
|
4401
|
+
if (!r2)
|
|
4402
|
+
return;
|
|
4403
|
+
const l2 = (t2 = ie(e2)) != null ? t2 : be, s2 = re(r2, l2);
|
|
4404
|
+
if (!n2 && a2) {
|
|
4405
|
+
if (it(a2)) {
|
|
4406
|
+
if (a2.tolerance != null && Je(s2, a2.tolerance))
|
|
4407
|
+
return this.handleCancel();
|
|
4408
|
+
if (Je(s2, a2.distance))
|
|
4409
|
+
return this.handleStart();
|
|
4410
|
+
}
|
|
4411
|
+
return at(a2) && Je(s2, a2.tolerance) ? this.handleCancel() : void this.handlePending(a2, s2);
|
|
4412
|
+
}
|
|
4413
|
+
e2.cancelable && e2.preventDefault(), i2(l2);
|
|
4414
|
+
}
|
|
4415
|
+
handleEnd() {
|
|
4416
|
+
const { onAbort: e2, onEnd: t2 } = this.props;
|
|
4417
|
+
this.detach(), this.activated || e2(this.props.active), t2();
|
|
4418
|
+
}
|
|
4419
|
+
handleCancel() {
|
|
4420
|
+
const { onAbort: e2, onCancel: t2 } = this.props;
|
|
4421
|
+
this.detach(), this.activated || e2(this.props.active), t2();
|
|
4422
|
+
}
|
|
4423
|
+
handleKeydown(e2) {
|
|
4424
|
+
e2.code === Qe.Esc && this.handleCancel();
|
|
4425
|
+
}
|
|
4426
|
+
removeTextSelection() {
|
|
4427
|
+
var e2;
|
|
4428
|
+
(e2 = this.document.getSelection()) == null || e2.removeAllRanges();
|
|
4429
|
+
}
|
|
4430
|
+
}
|
|
4431
|
+
var st = { cancel: { name: "pointercancel" }, move: { name: "pointermove" }, end: { name: "pointerup" } };
|
|
4432
|
+
|
|
4433
|
+
class ct extends lt {
|
|
4434
|
+
constructor(e2) {
|
|
4435
|
+
const { event: t2 } = e2, n2 = X2(t2.target);
|
|
4436
|
+
super(e2, st, n2);
|
|
4437
|
+
}
|
|
4438
|
+
}
|
|
4439
|
+
ct.activators = [{ eventName: "onPointerDown", handler: (e2, t2) => {
|
|
4440
|
+
let { nativeEvent: n2 } = e2, { onActivation: r2 } = t2;
|
|
4441
|
+
return !(!n2.isPrimary || n2.button !== 0) && (r2 == null || r2({ event: n2 }), true);
|
|
4442
|
+
} }];
|
|
4443
|
+
var dt = { move: { name: "mousemove" }, end: { name: "mouseup" } };
|
|
4444
|
+
var ut;
|
|
4445
|
+
var pt;
|
|
4446
|
+
(pt = ut || (ut = {}))[pt.RightClick = 2] = "RightClick";
|
|
4447
|
+
(class extends lt {
|
|
4448
|
+
constructor(e2) {
|
|
4449
|
+
super(e2, dt, X2(e2.event.target));
|
|
4450
|
+
}
|
|
4451
|
+
}).activators = [{ eventName: "onMouseDown", handler: (e2, t2) => {
|
|
4452
|
+
let { nativeEvent: n2 } = e2, { onActivation: r2 } = t2;
|
|
4453
|
+
return n2.button !== ut.RightClick && (r2 == null || r2({ event: n2 }), true);
|
|
4454
|
+
} }];
|
|
4455
|
+
var ht = { cancel: { name: "touchcancel" }, move: { name: "touchmove" }, end: { name: "touchend" } };
|
|
4456
|
+
var mt;
|
|
4457
|
+
var ft;
|
|
4458
|
+
var gt;
|
|
4459
|
+
var vt;
|
|
4460
|
+
(class extends lt {
|
|
4461
|
+
constructor(e2) {
|
|
4462
|
+
super(e2, ht);
|
|
4463
|
+
}
|
|
4464
|
+
static setup() {
|
|
4465
|
+
return window.addEventListener(ht.move.name, e2, { capture: false, passive: false }), function() {
|
|
4466
|
+
window.removeEventListener(ht.move.name, e2);
|
|
4467
|
+
};
|
|
4468
|
+
function e2() {}
|
|
4469
|
+
}
|
|
4470
|
+
}).activators = [{ eventName: "onTouchStart", handler: (e2, t2) => {
|
|
4471
|
+
let { nativeEvent: n2 } = e2, { onActivation: r2 } = t2;
|
|
4472
|
+
const { touches: o2 } = n2;
|
|
4473
|
+
return !(o2.length > 1) && (r2 == null || r2({ event: n2 }), true);
|
|
4474
|
+
} }], (ft = mt || (mt = {}))[ft.Pointer = 0] = "Pointer", ft[ft.DraggableRect = 1] = "DraggableRect", (vt = gt || (gt = {}))[vt.TreeOrder = 0] = "TreeOrder", vt[vt.ReversedTreeOrder = 1] = "ReversedTreeOrder";
|
|
4475
|
+
var yt = { x: { [Oe.Backward]: false, [Oe.Forward]: false }, y: { [Oe.Backward]: false, [Oe.Forward]: false } };
|
|
4476
|
+
var wt;
|
|
4477
|
+
var xt;
|
|
4478
|
+
var Ct;
|
|
4479
|
+
(xt = wt || (wt = {}))[xt.Always = 0] = "Always", xt[xt.BeforeDragging = 1] = "BeforeDragging", xt[xt.WhileDragging = 2] = "WhileDragging", (Ct || (Ct = {})).Optimized = "optimized";
|
|
4480
|
+
var Ft = { draggable: { measure: Ae }, droppable: { measure: Ae, strategy: wt.WhileDragging, frequency: Ct.Optimized }, dragOverlay: { measure: Te } };
|
|
4481
|
+
var jt = /* @__PURE__ */ s({ ...be, scaleX: 1, scaleY: 1 });
|
|
4482
|
+
var Kt;
|
|
4483
|
+
var Ut;
|
|
4484
|
+
(Ut = Kt || (Kt = {}))[Ut.Uninitialized = 0] = "Uninitialized", Ut[Ut.Initializing = 1] = "Initializing", Ut[Ut.Initialized = 2] = "Initialized";
|
|
4485
|
+
|
|
4486
|
+
// src/panels/TabbedTerminalPanel.tsx
|
|
1785
4487
|
import { Terminal as TerminalIcon2, Lock as Lock2, Unlock as Unlock2, Box, Boxes } from "lucide-react";
|
|
1786
|
-
import
|
|
1787
|
-
useState as
|
|
1788
|
-
useCallback as
|
|
1789
|
-
useEffect as
|
|
1790
|
-
useRef as
|
|
4488
|
+
import React3, {
|
|
4489
|
+
useState as useState5,
|
|
4490
|
+
useCallback as useCallback4,
|
|
4491
|
+
useEffect as useEffect5,
|
|
4492
|
+
useRef as useRef4
|
|
1791
4493
|
} from "react";
|
|
1792
4494
|
import { jsx as jsx7, jsxs as jsxs6, Fragment as Fragment2 } from "react/jsx-runtime";
|
|
1793
4495
|
var ActivityIndicator = ({ color, isAnimating }) => /* @__PURE__ */ jsxs6("div", {
|
|
1794
4496
|
style: { display: "flex", gap: 1, alignItems: "center", height: 12 },
|
|
1795
4497
|
children: [
|
|
1796
|
-
[0, 1, 2, 3, 4].map((
|
|
4498
|
+
[0, 1, 2, 3, 4].map((i2) => /* @__PURE__ */ jsx7("div", {
|
|
1797
4499
|
style: {
|
|
1798
4500
|
width: 2,
|
|
1799
4501
|
height: 10,
|
|
@@ -1801,9 +4503,9 @@ var ActivityIndicator = ({ color, isAnimating }) => /* @__PURE__ */ jsxs6("div",
|
|
|
1801
4503
|
borderRadius: 1,
|
|
1802
4504
|
transformOrigin: "center",
|
|
1803
4505
|
transform: isAnimating ? undefined : "scaleY(0.4)",
|
|
1804
|
-
animation: isAnimating ? `waveSine 1.2s ease-in-out ${
|
|
4506
|
+
animation: isAnimating ? `waveSine 1.2s ease-in-out ${i2 * 0.1}s infinite` : "none"
|
|
1805
4507
|
}
|
|
1806
|
-
},
|
|
4508
|
+
}, i2)),
|
|
1807
4509
|
/* @__PURE__ */ jsx7("style", {
|
|
1808
4510
|
children: `
|
|
1809
4511
|
@keyframes waveSine {
|
|
@@ -1814,23 +4516,23 @@ var ActivityIndicator = ({ color, isAnimating }) => /* @__PURE__ */ jsxs6("div",
|
|
|
1814
4516
|
})
|
|
1815
4517
|
]
|
|
1816
4518
|
});
|
|
1817
|
-
function TerminalTabContentInner(
|
|
1818
|
-
const { tab, sessionId, isActive, isVisible, actions, events, terminalContext, onSessionCreated, onScrollPositionChange, isForeign = false, defaultScrollLocked, activityDetection = true, activityTimeout = 500, autoShowBlinds = false, onActivityStateChange } =
|
|
4519
|
+
function TerminalTabContentInner(props2, ref) {
|
|
4520
|
+
const { tab, sessionId, isActive, isVisible, actions, events, terminalContext, onSessionCreated, onScrollPositionChange, isForeign = false, defaultScrollLocked, activityDetection = true, activityTimeout = 500, autoShowBlinds = false, onActivityStateChange } = props2;
|
|
1819
4521
|
const { theme } = useTheme6();
|
|
1820
4522
|
console.log("[TerminalTabContent] RENDER", { tabId: tab.id, isActive, sessionId });
|
|
1821
|
-
const terminalRef =
|
|
1822
|
-
const [localSessionId, setLocalSessionId] =
|
|
1823
|
-
const [isInitialized, setIsInitialized] =
|
|
1824
|
-
const hasInitializedRef =
|
|
1825
|
-
const [scrollPosition, setScrollPosition] =
|
|
4523
|
+
const terminalRef = useRef4(null);
|
|
4524
|
+
const [localSessionId, setLocalSessionId] = useState5(sessionId);
|
|
4525
|
+
const [isInitialized, setIsInitialized] = useState5(false);
|
|
4526
|
+
const hasInitializedRef = useRef4(false);
|
|
4527
|
+
const [scrollPosition, setScrollPosition] = useState5({
|
|
1826
4528
|
isAtTop: false,
|
|
1827
4529
|
isAtBottom: true,
|
|
1828
4530
|
isScrollLocked: false
|
|
1829
4531
|
});
|
|
1830
|
-
const [shouldRenderTerminal, setShouldRenderTerminal] =
|
|
1831
|
-
const [ownerWindowId, setOwnerWindowId] =
|
|
1832
|
-
const needsRefreshOnResizeRef =
|
|
1833
|
-
const claimAndConnect =
|
|
4532
|
+
const [shouldRenderTerminal, setShouldRenderTerminal] = useState5(true);
|
|
4533
|
+
const [ownerWindowId, setOwnerWindowId] = useState5(null);
|
|
4534
|
+
const needsRefreshOnResizeRef = useRef4(false);
|
|
4535
|
+
const claimAndConnect = useCallback4(async (targetSessionId, force = false) => {
|
|
1834
4536
|
try {
|
|
1835
4537
|
if (actions.claimTerminalOwnership) {
|
|
1836
4538
|
await actions.claimTerminalOwnership(targetSessionId, force);
|
|
@@ -1848,7 +4550,7 @@ function TerminalTabContentInner(props, ref) {
|
|
|
1848
4550
|
throw error;
|
|
1849
4551
|
}
|
|
1850
4552
|
}, [actions]);
|
|
1851
|
-
|
|
4553
|
+
useEffect5(() => {
|
|
1852
4554
|
if (hasInitializedRef.current) {
|
|
1853
4555
|
return;
|
|
1854
4556
|
}
|
|
@@ -1920,7 +4622,7 @@ function TerminalTabContentInner(props, ref) {
|
|
|
1920
4622
|
mounted = false;
|
|
1921
4623
|
};
|
|
1922
4624
|
}, []);
|
|
1923
|
-
|
|
4625
|
+
useEffect5(() => {
|
|
1924
4626
|
if (!localSessionId || !isInitialized || !shouldRenderTerminal) {
|
|
1925
4627
|
return;
|
|
1926
4628
|
}
|
|
@@ -1938,17 +4640,17 @@ function TerminalTabContentInner(props, ref) {
|
|
|
1938
4640
|
unsubscribe();
|
|
1939
4641
|
};
|
|
1940
4642
|
}, [localSessionId, isInitialized, actions, shouldRenderTerminal, tab.id]);
|
|
1941
|
-
const handleData =
|
|
4643
|
+
const handleData = useCallback4((data) => {
|
|
1942
4644
|
if (localSessionId && actions.writeToTerminal) {
|
|
1943
4645
|
actions.writeToTerminal(localSessionId, data);
|
|
1944
4646
|
}
|
|
1945
4647
|
}, [localSessionId, actions]);
|
|
1946
|
-
const handleResize =
|
|
4648
|
+
const handleResize = useCallback4((cols, rows) => {
|
|
1947
4649
|
if (localSessionId && actions.resizeTerminal) {
|
|
1948
4650
|
actions.resizeTerminal(localSessionId, cols, rows);
|
|
1949
4651
|
}
|
|
1950
4652
|
}, [localSessionId, actions]);
|
|
1951
|
-
const handleReady =
|
|
4653
|
+
const handleReady = useCallback4((cols, rows) => {
|
|
1952
4654
|
if (localSessionId && actions.resizeTerminal) {
|
|
1953
4655
|
const shouldForce = needsRefreshOnResizeRef.current;
|
|
1954
4656
|
if (shouldForce) {
|
|
@@ -1957,7 +4659,7 @@ function TerminalTabContentInner(props, ref) {
|
|
|
1957
4659
|
actions.resizeTerminal(localSessionId, cols, rows, shouldForce);
|
|
1958
4660
|
}
|
|
1959
4661
|
}, [localSessionId, actions]);
|
|
1960
|
-
const handleLinkClick =
|
|
4662
|
+
const handleLinkClick = useCallback4((url, modifiers) => {
|
|
1961
4663
|
if (localSessionId) {
|
|
1962
4664
|
events.emit({
|
|
1963
4665
|
type: "terminal:link-click",
|
|
@@ -1974,7 +4676,7 @@ function TerminalTabContentInner(props, ref) {
|
|
|
1974
4676
|
});
|
|
1975
4677
|
}
|
|
1976
4678
|
}, [localSessionId, events]);
|
|
1977
|
-
|
|
4679
|
+
useEffect5(() => {
|
|
1978
4680
|
if (!localSessionId || !actions.onOwnershipLost) {
|
|
1979
4681
|
return;
|
|
1980
4682
|
}
|
|
@@ -1988,17 +4690,17 @@ function TerminalTabContentInner(props, ref) {
|
|
|
1988
4690
|
unsubscribe();
|
|
1989
4691
|
};
|
|
1990
4692
|
}, [localSessionId, actions]);
|
|
1991
|
-
const handleTakeControl =
|
|
4693
|
+
const handleTakeControl = useCallback4(async () => {
|
|
1992
4694
|
if (!localSessionId) {
|
|
1993
4695
|
return;
|
|
1994
4696
|
}
|
|
1995
4697
|
await claimAndConnect(localSessionId, true);
|
|
1996
4698
|
}, [localSessionId, claimAndConnect]);
|
|
1997
|
-
const handleScrollPositionChange =
|
|
4699
|
+
const handleScrollPositionChange = useCallback4((position) => {
|
|
1998
4700
|
setScrollPosition(position);
|
|
1999
4701
|
onScrollPositionChange?.(tab.id, position);
|
|
2000
4702
|
}, [tab.id, onScrollPositionChange]);
|
|
2001
|
-
const handleShortcut =
|
|
4703
|
+
const handleShortcut = useCallback4((shortcutEvent) => {
|
|
2002
4704
|
if (localSessionId) {
|
|
2003
4705
|
events.emit({
|
|
2004
4706
|
type: "terminal:shortcut",
|
|
@@ -2011,7 +4713,7 @@ function TerminalTabContentInner(props, ref) {
|
|
|
2011
4713
|
});
|
|
2012
4714
|
}
|
|
2013
4715
|
}, [localSessionId, events]);
|
|
2014
|
-
const handleActivityChange =
|
|
4716
|
+
const handleActivityChange = useCallback4((state) => {
|
|
2015
4717
|
if (localSessionId) {
|
|
2016
4718
|
onActivityStateChange?.(localSessionId, state.isActive);
|
|
2017
4719
|
events.emit({
|
|
@@ -2026,10 +4728,10 @@ function TerminalTabContentInner(props, ref) {
|
|
|
2026
4728
|
});
|
|
2027
4729
|
}
|
|
2028
4730
|
}, [localSessionId, events, onActivityStateChange]);
|
|
2029
|
-
const handleScrollToBottom =
|
|
4731
|
+
const handleScrollToBottom = useCallback4(() => {
|
|
2030
4732
|
terminalRef.current?.scrollToBottom();
|
|
2031
4733
|
}, []);
|
|
2032
|
-
const handleToggleScrollLock =
|
|
4734
|
+
const handleToggleScrollLock = useCallback4(() => {
|
|
2033
4735
|
if (scrollPosition.isScrollLocked) {
|
|
2034
4736
|
const terminal = terminalRef.current?.getTerminal();
|
|
2035
4737
|
if (terminal) {
|
|
@@ -2039,7 +4741,7 @@ function TerminalTabContentInner(props, ref) {
|
|
|
2039
4741
|
terminalRef.current?.scrollToBottom();
|
|
2040
4742
|
}
|
|
2041
4743
|
}, [scrollPosition.isScrollLocked]);
|
|
2042
|
-
|
|
4744
|
+
React3.useImperativeHandle(ref, () => ({
|
|
2043
4745
|
scrollToBottom: handleScrollToBottom,
|
|
2044
4746
|
toggleScrollLock: handleToggleScrollLock
|
|
2045
4747
|
}), [handleScrollToBottom, handleToggleScrollLock]);
|
|
@@ -2142,8 +4844,8 @@ var areTerminalTabContentPropsEqual = (prevProps, nextProps) => {
|
|
|
2142
4844
|
}
|
|
2143
4845
|
return changes.length === 0;
|
|
2144
4846
|
};
|
|
2145
|
-
var TerminalTabContentForwarded =
|
|
2146
|
-
var TerminalTabContent =
|
|
4847
|
+
var TerminalTabContentForwarded = React3.forwardRef(TerminalTabContentInner);
|
|
4848
|
+
var TerminalTabContent = React3.memo(TerminalTabContentForwarded, areTerminalTabContentPropsEqual);
|
|
2147
4849
|
TerminalTabContent.displayName = "TerminalTabContent";
|
|
2148
4850
|
var TabbedTerminalPanelInner = ({
|
|
2149
4851
|
context: _context,
|
|
@@ -2170,16 +4872,21 @@ var TabbedTerminalPanelInner = ({
|
|
|
2170
4872
|
workingStates,
|
|
2171
4873
|
activityDetection = true,
|
|
2172
4874
|
activityTimeout = 500,
|
|
2173
|
-
autoShowBlinds = false
|
|
4875
|
+
autoShowBlinds = false,
|
|
4876
|
+
associations,
|
|
4877
|
+
onAssociationCollapsedChange,
|
|
4878
|
+
onAssociationRatioChange,
|
|
4879
|
+
renderAssociatedContent,
|
|
4880
|
+
getAssociatedHeader
|
|
2174
4881
|
}) => {
|
|
2175
4882
|
console.log("[TabbedTerminalPanel] RENDER", { terminalContext, directory, width });
|
|
2176
4883
|
const { theme } = useTheme6();
|
|
2177
|
-
const [ownedTabs, setOwnedTabs] =
|
|
2178
|
-
const [foreignTabs, setForeignTabs] =
|
|
2179
|
-
const [internalActiveTabId, setInternalActiveTabId] =
|
|
4884
|
+
const [ownedTabs, setOwnedTabs] = useState5(initialTabs);
|
|
4885
|
+
const [foreignTabs, setForeignTabs] = useState5([]);
|
|
4886
|
+
const [internalActiveTabId, setInternalActiveTabId] = useState5(null);
|
|
2180
4887
|
const isControlled = activeTabIdProp !== undefined;
|
|
2181
4888
|
const activeTabId = isControlled ? activeTabIdProp : internalActiveTabId;
|
|
2182
|
-
const setActiveTabId =
|
|
4889
|
+
const setActiveTabId = React3.useCallback((tabId) => {
|
|
2183
4890
|
if (isControlled) {
|
|
2184
4891
|
onActiveTabChange?.(tabId);
|
|
2185
4892
|
} else {
|
|
@@ -2187,18 +4894,18 @@ var TabbedTerminalPanelInner = ({
|
|
|
2187
4894
|
onActiveTabChange?.(tabId);
|
|
2188
4895
|
}
|
|
2189
4896
|
}, [isControlled, onActiveTabChange]);
|
|
2190
|
-
const [sessionIds, setSessionIds] =
|
|
2191
|
-
const [scrollPositions, setScrollPositions] =
|
|
2192
|
-
const [activityStates, setActivityStates] =
|
|
2193
|
-
const customTabsKey =
|
|
4897
|
+
const [sessionIds, setSessionIds] = useState5(new Map);
|
|
4898
|
+
const [scrollPositions, setScrollPositions] = useState5(new Map);
|
|
4899
|
+
const [activityStates, setActivityStates] = useState5(new Map);
|
|
4900
|
+
const customTabsKey = React3.useMemo(() => {
|
|
2194
4901
|
const customTabs = initialTabs.filter((tab) => tab.contentType !== "terminal");
|
|
2195
4902
|
return JSON.stringify(customTabs);
|
|
2196
4903
|
}, [initialTabs]);
|
|
2197
|
-
|
|
4904
|
+
useEffect5(() => {
|
|
2198
4905
|
const customTabsFromProp = initialTabs.filter((tab) => tab.contentType !== "terminal");
|
|
2199
4906
|
setOwnedTabs((prevTabs) => {
|
|
2200
4907
|
const existingTerminalTabs = prevTabs.filter((tab) => tab.contentType === "terminal");
|
|
2201
|
-
const customTabIds = new Set(customTabsFromProp.map((
|
|
4908
|
+
const customTabIds = new Set(customTabsFromProp.map((t2) => t2.id));
|
|
2202
4909
|
const existingCustomTabs = prevTabs.filter((tab) => tab.contentType !== "terminal" && !customTabIds.has(tab.id));
|
|
2203
4910
|
const mergedTabs = [
|
|
2204
4911
|
...existingTerminalTabs,
|
|
@@ -2207,7 +4914,7 @@ var TabbedTerminalPanelInner = ({
|
|
|
2207
4914
|
];
|
|
2208
4915
|
const prevCustomTabs = prevTabs.filter((tab) => tab.contentType !== "terminal");
|
|
2209
4916
|
const customTabsChanged = prevCustomTabs.length !== customTabsFromProp.length || !customTabsFromProp.every((tab) => {
|
|
2210
|
-
const prev = prevCustomTabs.find((
|
|
4917
|
+
const prev = prevCustomTabs.find((p2) => p2.id === tab.id);
|
|
2211
4918
|
if (!prev)
|
|
2212
4919
|
return false;
|
|
2213
4920
|
return JSON.stringify(tab) === JSON.stringify(prev);
|
|
@@ -2218,7 +4925,7 @@ var TabbedTerminalPanelInner = ({
|
|
|
2218
4925
|
return mergedTabs;
|
|
2219
4926
|
});
|
|
2220
4927
|
}, [customTabsKey]);
|
|
2221
|
-
|
|
4928
|
+
useEffect5(() => {
|
|
2222
4929
|
if (!requestFocusTabId) {
|
|
2223
4930
|
return;
|
|
2224
4931
|
}
|
|
@@ -2233,21 +4940,21 @@ var TabbedTerminalPanelInner = ({
|
|
|
2233
4940
|
onFocusTabHandled?.();
|
|
2234
4941
|
}
|
|
2235
4942
|
}, [requestFocusTabId, ownedTabs, foreignTabs, setActiveTabId, onFocusTabHandled, activeTabId]);
|
|
2236
|
-
const getOwnedTabLabel =
|
|
4943
|
+
const getOwnedTabLabel = useCallback4((index, _directory) => {
|
|
2237
4944
|
if (tabLabelPrefix) {
|
|
2238
4945
|
return `${tabLabelPrefix} ${index + 1}`;
|
|
2239
4946
|
}
|
|
2240
4947
|
return `⌘ ${index + 1}`;
|
|
2241
4948
|
}, [tabLabelPrefix]);
|
|
2242
|
-
const tabs =
|
|
4949
|
+
const tabs = React3.useMemo(() => {
|
|
2243
4950
|
const labeledOwnedTabs = ownedTabs.map((tab, index) => ({
|
|
2244
4951
|
...tab,
|
|
2245
4952
|
label: tab.contentType === "terminal" ? getOwnedTabLabel(index, tab.directory) : tab.label
|
|
2246
4953
|
}));
|
|
2247
|
-
const sortedForeignTabs = [...foreignTabs].sort((
|
|
4954
|
+
const sortedForeignTabs = [...foreignTabs].sort((a2, b) => a2.label.localeCompare(b.label));
|
|
2248
4955
|
return [...labeledOwnedTabs, ...sortedForeignTabs];
|
|
2249
4956
|
}, [ownedTabs, foreignTabs, getOwnedTabLabel]);
|
|
2250
|
-
const genericTabs =
|
|
4957
|
+
const genericTabs = React3.useMemo(() => {
|
|
2251
4958
|
return tabs.map((tab) => ({
|
|
2252
4959
|
id: tab.id,
|
|
2253
4960
|
label: tab.label,
|
|
@@ -2259,9 +4966,9 @@ var TabbedTerminalPanelInner = ({
|
|
|
2259
4966
|
}
|
|
2260
4967
|
}));
|
|
2261
4968
|
}, [tabs]);
|
|
2262
|
-
const tabRefsMap =
|
|
2263
|
-
const refCallbacksMap =
|
|
2264
|
-
const getRefCallback =
|
|
4969
|
+
const tabRefsMap = useRef4(new Map);
|
|
4970
|
+
const refCallbacksMap = useRef4(new Map);
|
|
4971
|
+
const getRefCallback = useCallback4((tabId) => {
|
|
2265
4972
|
let callback = refCallbacksMap.current.get(tabId);
|
|
2266
4973
|
if (!callback) {
|
|
2267
4974
|
callback = (ref) => {
|
|
@@ -2275,10 +4982,10 @@ var TabbedTerminalPanelInner = ({
|
|
|
2275
4982
|
}
|
|
2276
4983
|
return callback;
|
|
2277
4984
|
}, []);
|
|
2278
|
-
const hasInitializedRef =
|
|
2279
|
-
const isCreatingTabRef =
|
|
2280
|
-
const headerRef =
|
|
2281
|
-
const handleTabScrollPositionChange =
|
|
4985
|
+
const hasInitializedRef = useRef4(false);
|
|
4986
|
+
const isCreatingTabRef = useRef4(false);
|
|
4987
|
+
const headerRef = useRef4(null);
|
|
4988
|
+
const handleTabScrollPositionChange = useCallback4((tabId, position) => {
|
|
2282
4989
|
setScrollPositions((prev) => new Map(prev).set(tabId, position));
|
|
2283
4990
|
}, []);
|
|
2284
4991
|
const defaultScrollPosition = {
|
|
@@ -2286,12 +4993,12 @@ var TabbedTerminalPanelInner = ({
|
|
|
2286
4993
|
isAtBottom: true,
|
|
2287
4994
|
isScrollLocked: false
|
|
2288
4995
|
};
|
|
2289
|
-
const handleToggleScrollLock =
|
|
4996
|
+
const handleToggleScrollLock = useCallback4(() => {
|
|
2290
4997
|
if (activeTabId) {
|
|
2291
4998
|
tabRefsMap.current.get(activeTabId)?.toggleScrollLock();
|
|
2292
4999
|
}
|
|
2293
5000
|
}, [activeTabId]);
|
|
2294
|
-
const restoreOwnedSessions =
|
|
5001
|
+
const restoreOwnedSessions = useCallback4(async () => {
|
|
2295
5002
|
try {
|
|
2296
5003
|
let sessions = [];
|
|
2297
5004
|
if (actions.listTerminalSessions) {
|
|
@@ -2326,7 +5033,7 @@ var TabbedTerminalPanelInner = ({
|
|
|
2326
5033
|
console.error("[TabbedTerminalPanel] Failed to restore owned sessions:", err);
|
|
2327
5034
|
}
|
|
2328
5035
|
}, [terminalContext, initialTabs, onTabsChange, actions, directory]);
|
|
2329
|
-
const fetchForeignSessions =
|
|
5036
|
+
const fetchForeignSessions = useCallback4(async () => {
|
|
2330
5037
|
try {
|
|
2331
5038
|
if (!actions.listTerminalSessions) {
|
|
2332
5039
|
return;
|
|
@@ -2358,9 +5065,9 @@ var TabbedTerminalPanelInner = ({
|
|
|
2358
5065
|
console.error("[TabbedTerminalPanel] Failed to fetch foreign sessions:", err);
|
|
2359
5066
|
}
|
|
2360
5067
|
}, [terminalContext, actions]);
|
|
2361
|
-
const clearForeignTabs =
|
|
5068
|
+
const clearForeignTabs = useCallback4(() => {
|
|
2362
5069
|
setForeignTabs((prevForeign) => {
|
|
2363
|
-
const foreignTabIds = new Set(prevForeign.map((
|
|
5070
|
+
const foreignTabIds = new Set(prevForeign.map((t2) => t2.id));
|
|
2364
5071
|
setSessionIds((prev) => {
|
|
2365
5072
|
const updated = new Map(prev);
|
|
2366
5073
|
foreignTabIds.forEach((id) => updated.delete(id));
|
|
@@ -2369,13 +5076,13 @@ var TabbedTerminalPanelInner = ({
|
|
|
2369
5076
|
return [];
|
|
2370
5077
|
});
|
|
2371
5078
|
}, []);
|
|
2372
|
-
|
|
5079
|
+
useEffect5(() => {
|
|
2373
5080
|
if (hasInitializedRef.current)
|
|
2374
5081
|
return;
|
|
2375
5082
|
hasInitializedRef.current = true;
|
|
2376
5083
|
restoreOwnedSessions();
|
|
2377
5084
|
}, []);
|
|
2378
|
-
|
|
5085
|
+
useEffect5(() => {
|
|
2379
5086
|
const handleSessionCreated2 = (event) => {
|
|
2380
5087
|
const customEvent = event;
|
|
2381
5088
|
const { context: context2 } = customEvent.detail || {};
|
|
@@ -2389,17 +5096,17 @@ var TabbedTerminalPanelInner = ({
|
|
|
2389
5096
|
window.removeEventListener("terminal-session-created", handleSessionCreated2);
|
|
2390
5097
|
};
|
|
2391
5098
|
}, [terminalContext, restoreOwnedSessions]);
|
|
2392
|
-
|
|
5099
|
+
useEffect5(() => {
|
|
2393
5100
|
if (showAllTerminals) {
|
|
2394
5101
|
fetchForeignSessions();
|
|
2395
5102
|
} else {
|
|
2396
5103
|
clearForeignTabs();
|
|
2397
5104
|
}
|
|
2398
5105
|
}, [showAllTerminals, fetchForeignSessions, clearForeignTabs]);
|
|
2399
|
-
const switchTab =
|
|
5106
|
+
const switchTab = useCallback4((tabId) => {
|
|
2400
5107
|
setActiveTabId(tabId);
|
|
2401
5108
|
}, [setActiveTabId]);
|
|
2402
|
-
const addNewTab =
|
|
5109
|
+
const addNewTab = useCallback4((label, command, targetDirectory) => {
|
|
2403
5110
|
const targetDir = targetDirectory || directory;
|
|
2404
5111
|
const directoryName = targetDir.split("/").pop() || targetDir;
|
|
2405
5112
|
const newTab = {
|
|
@@ -2417,10 +5124,10 @@ var TabbedTerminalPanelInner = ({
|
|
|
2417
5124
|
});
|
|
2418
5125
|
setActiveTabId(newTab.id);
|
|
2419
5126
|
}, [directory, onTabsChange]);
|
|
2420
|
-
const isForeignTab =
|
|
5127
|
+
const isForeignTab = useCallback4((tabId) => {
|
|
2421
5128
|
return tabId.startsWith("tab-foreign-");
|
|
2422
5129
|
}, []);
|
|
2423
|
-
const closeTab =
|
|
5130
|
+
const closeTab = useCallback4(async (tabId) => {
|
|
2424
5131
|
const sessionId = sessionIds.get(tabId);
|
|
2425
5132
|
const isForeign = isForeignTab(tabId);
|
|
2426
5133
|
if (!isForeign && sessionId && actions.destroyTerminalSession) {
|
|
@@ -2462,7 +5169,7 @@ var TabbedTerminalPanelInner = ({
|
|
|
2462
5169
|
return newMap;
|
|
2463
5170
|
});
|
|
2464
5171
|
const findNextActiveTab = (allTabs) => {
|
|
2465
|
-
const remaining = allTabs.filter((
|
|
5172
|
+
const remaining = allTabs.filter((t2) => t2.id !== tabId);
|
|
2466
5173
|
if (activeTabId === tabId && remaining.length > 0) {
|
|
2467
5174
|
const newActive = remaining[remaining.length - 1];
|
|
2468
5175
|
return newActive.id;
|
|
@@ -2471,7 +5178,7 @@ var TabbedTerminalPanelInner = ({
|
|
|
2471
5178
|
};
|
|
2472
5179
|
if (isForeign) {
|
|
2473
5180
|
setForeignTabs((prevTabs) => {
|
|
2474
|
-
const newTabs = prevTabs.filter((
|
|
5181
|
+
const newTabs = prevTabs.filter((t2) => t2.id !== tabId);
|
|
2475
5182
|
const nextActiveId = findNextActiveTab([...ownedTabs, ...newTabs]);
|
|
2476
5183
|
if (nextActiveId !== activeTabId) {
|
|
2477
5184
|
setActiveTabId(nextActiveId);
|
|
@@ -2480,7 +5187,7 @@ var TabbedTerminalPanelInner = ({
|
|
|
2480
5187
|
});
|
|
2481
5188
|
} else {
|
|
2482
5189
|
setOwnedTabs((prevTabs) => {
|
|
2483
|
-
const newTabs = prevTabs.filter((
|
|
5190
|
+
const newTabs = prevTabs.filter((t2) => t2.id !== tabId);
|
|
2484
5191
|
const nextActiveId = findNextActiveTab([...newTabs, ...foreignTabs]);
|
|
2485
5192
|
if (nextActiveId !== activeTabId) {
|
|
2486
5193
|
setActiveTabId(nextActiveId);
|
|
@@ -2490,10 +5197,10 @@ var TabbedTerminalPanelInner = ({
|
|
|
2490
5197
|
});
|
|
2491
5198
|
}
|
|
2492
5199
|
}, [activeTabId, sessionIds, actions, onTabsChange, isForeignTab, ownedTabs, foreignTabs]);
|
|
2493
|
-
const handleSessionCreated =
|
|
5200
|
+
const handleSessionCreated = useCallback4((tabId, sessionId) => {
|
|
2494
5201
|
setSessionIds((prev) => new Map(prev).set(tabId, sessionId));
|
|
2495
5202
|
}, []);
|
|
2496
|
-
const handleActivityStateChange =
|
|
5203
|
+
const handleActivityStateChange = useCallback4((sessionId, isActive) => {
|
|
2497
5204
|
setActivityStates((prev) => {
|
|
2498
5205
|
const next = new Map(prev);
|
|
2499
5206
|
if (isActive) {
|
|
@@ -2524,7 +5231,7 @@ var TabbedTerminalPanelInner = ({
|
|
|
2524
5231
|
}
|
|
2525
5232
|
}
|
|
2526
5233
|
});
|
|
2527
|
-
const renderTabAccessory =
|
|
5234
|
+
const renderTabAccessory = useCallback4((tab) => {
|
|
2528
5235
|
const tabSessionId = sessionIds.get(tab.id);
|
|
2529
5236
|
const hasExternalWorkingState = tabSessionId ? workingStates?.[tabSessionId]?.isWorking : false;
|
|
2530
5237
|
const hasInternalActivity = tabSessionId ? activityStates.get(tabSessionId) : false;
|
|
@@ -2536,8 +5243,8 @@ var TabbedTerminalPanelInner = ({
|
|
|
2536
5243
|
return /* @__PURE__ */ jsxs6(Fragment2, {
|
|
2537
5244
|
children: [
|
|
2538
5245
|
/* @__PURE__ */ jsx7("button", {
|
|
2539
|
-
onClick: (
|
|
2540
|
-
|
|
5246
|
+
onClick: (e2) => {
|
|
5247
|
+
e2.stopPropagation();
|
|
2541
5248
|
handleToggleScrollLock();
|
|
2542
5249
|
},
|
|
2543
5250
|
style: {
|
|
@@ -2553,11 +5260,11 @@ var TabbedTerminalPanelInner = ({
|
|
|
2553
5260
|
color: scrollPosition.isScrollLocked ? theme.colors.success : theme.colors.warning,
|
|
2554
5261
|
padding: 0
|
|
2555
5262
|
},
|
|
2556
|
-
onMouseEnter: (
|
|
2557
|
-
|
|
5263
|
+
onMouseEnter: (e2) => {
|
|
5264
|
+
e2.currentTarget.style.backgroundColor = theme.colors.backgroundTertiary;
|
|
2558
5265
|
},
|
|
2559
|
-
onMouseLeave: (
|
|
2560
|
-
|
|
5266
|
+
onMouseLeave: (e2) => {
|
|
5267
|
+
e2.currentTarget.style.backgroundColor = "transparent";
|
|
2561
5268
|
},
|
|
2562
5269
|
title: scrollPosition.isScrollLocked ? "Scroll locked" : "Scroll unlocked",
|
|
2563
5270
|
children: scrollPosition.isScrollLocked ? /* @__PURE__ */ jsx7(Lock2, {
|
|
@@ -2585,6 +5292,56 @@ var TabbedTerminalPanelInner = ({
|
|
|
2585
5292
|
]
|
|
2586
5293
|
});
|
|
2587
5294
|
}, [activeTabId, scrollPositions, defaultScrollPosition, handleToggleScrollLock, theme, sessionIds, workingStates, activityStates]);
|
|
5295
|
+
const renderTerminalWithAssociation = useCallback4((tab, isActive, sessionId, association) => {
|
|
5296
|
+
const terminalContent = /* @__PURE__ */ jsx7(TerminalTabContent, {
|
|
5297
|
+
ref: getRefCallback(tab.id),
|
|
5298
|
+
tab,
|
|
5299
|
+
sessionId,
|
|
5300
|
+
isActive,
|
|
5301
|
+
isVisible,
|
|
5302
|
+
actions,
|
|
5303
|
+
events,
|
|
5304
|
+
terminalContext,
|
|
5305
|
+
onSessionCreated: handleSessionCreated,
|
|
5306
|
+
onScrollPositionChange: handleTabScrollPositionChange,
|
|
5307
|
+
isForeign: tab.id.startsWith("tab-foreign-"),
|
|
5308
|
+
defaultScrollLocked,
|
|
5309
|
+
activityDetection,
|
|
5310
|
+
activityTimeout,
|
|
5311
|
+
autoShowBlinds,
|
|
5312
|
+
onActivityStateChange: handleActivityStateChange
|
|
5313
|
+
}, `terminal-${tab.id}`);
|
|
5314
|
+
const secondaryContent = association && renderAssociatedContent ? renderAssociatedContent(association.associatedTabId, isActive) : undefined;
|
|
5315
|
+
const headerConfig = association && getAssociatedHeader ? getAssociatedHeader(association.associatedTabId) : undefined;
|
|
5316
|
+
return /* @__PURE__ */ jsx7(D, {
|
|
5317
|
+
primaryContent: terminalContent,
|
|
5318
|
+
secondaryContent,
|
|
5319
|
+
collapsedHeader: headerConfig,
|
|
5320
|
+
collapsed: association?.collapsed,
|
|
5321
|
+
onCollapsedChange: association ? (collapsed) => onAssociationCollapsedChange?.(tab.id, collapsed) : undefined,
|
|
5322
|
+
ratio: association?.ratio,
|
|
5323
|
+
onRatioChange: association ? (ratio) => onAssociationRatioChange?.(tab.id, ratio) : undefined,
|
|
5324
|
+
theme
|
|
5325
|
+
});
|
|
5326
|
+
}, [
|
|
5327
|
+
getRefCallback,
|
|
5328
|
+
isVisible,
|
|
5329
|
+
actions,
|
|
5330
|
+
events,
|
|
5331
|
+
terminalContext,
|
|
5332
|
+
handleSessionCreated,
|
|
5333
|
+
handleTabScrollPositionChange,
|
|
5334
|
+
defaultScrollLocked,
|
|
5335
|
+
activityDetection,
|
|
5336
|
+
activityTimeout,
|
|
5337
|
+
autoShowBlinds,
|
|
5338
|
+
handleActivityStateChange,
|
|
5339
|
+
renderAssociatedContent,
|
|
5340
|
+
getAssociatedHeader,
|
|
5341
|
+
onAssociationCollapsedChange,
|
|
5342
|
+
onAssociationRatioChange,
|
|
5343
|
+
theme
|
|
5344
|
+
]);
|
|
2588
5345
|
return /* @__PURE__ */ jsxs6("div", {
|
|
2589
5346
|
style: {
|
|
2590
5347
|
display: "flex",
|
|
@@ -2615,14 +5372,14 @@ var TabbedTerminalPanelInner = ({
|
|
|
2615
5372
|
cursor: "pointer",
|
|
2616
5373
|
color: showAllTerminals ? theme.colors.primary : theme.colors.textSecondary
|
|
2617
5374
|
},
|
|
2618
|
-
onMouseEnter: (
|
|
5375
|
+
onMouseEnter: (e2) => {
|
|
2619
5376
|
if (!showAllTerminals) {
|
|
2620
|
-
|
|
5377
|
+
e2.currentTarget.style.backgroundColor = theme.colors.backgroundTertiary;
|
|
2621
5378
|
}
|
|
2622
5379
|
},
|
|
2623
|
-
onMouseLeave: (
|
|
5380
|
+
onMouseLeave: (e2) => {
|
|
2624
5381
|
if (!showAllTerminals) {
|
|
2625
|
-
|
|
5382
|
+
e2.currentTarget.style.backgroundColor = "transparent";
|
|
2626
5383
|
}
|
|
2627
5384
|
},
|
|
2628
5385
|
title: showAllTerminals ? "Showing all terminals (click to filter by context)" : "Show all terminals",
|
|
@@ -2654,23 +5411,15 @@ var TabbedTerminalPanelInner = ({
|
|
|
2654
5411
|
if (renderTabContent) {
|
|
2655
5412
|
const customContent = renderTabContent(tab, isActive, sessionId, width);
|
|
2656
5413
|
if (customContent === null && tab.contentType === "terminal") {
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
onSessionCreated: handleSessionCreated,
|
|
2667
|
-
onScrollPositionChange: handleTabScrollPositionChange,
|
|
2668
|
-
isForeign: tab.id.startsWith("tab-foreign-"),
|
|
2669
|
-
defaultScrollLocked,
|
|
2670
|
-
activityDetection,
|
|
2671
|
-
activityTimeout,
|
|
2672
|
-
autoShowBlinds,
|
|
2673
|
-
onActivityStateChange: handleActivityStateChange
|
|
5414
|
+
const association = associations?.[tab.id];
|
|
5415
|
+
return /* @__PURE__ */ jsx7("div", {
|
|
5416
|
+
style: {
|
|
5417
|
+
display: isActive ? "flex" : "none",
|
|
5418
|
+
flexDirection: "column",
|
|
5419
|
+
height: "100%",
|
|
5420
|
+
width: "100%"
|
|
5421
|
+
},
|
|
5422
|
+
children: renderTerminalWithAssociation(tab, isActive, sessionId, association)
|
|
2674
5423
|
}, tab.id);
|
|
2675
5424
|
}
|
|
2676
5425
|
return /* @__PURE__ */ jsx7("div", {
|
|
@@ -2684,23 +5433,15 @@ var TabbedTerminalPanelInner = ({
|
|
|
2684
5433
|
}, tab.id);
|
|
2685
5434
|
}
|
|
2686
5435
|
if (tab.contentType === "terminal") {
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
onSessionCreated: handleSessionCreated,
|
|
2697
|
-
onScrollPositionChange: handleTabScrollPositionChange,
|
|
2698
|
-
isForeign: tab.id.startsWith("tab-foreign-"),
|
|
2699
|
-
defaultScrollLocked,
|
|
2700
|
-
activityDetection,
|
|
2701
|
-
activityTimeout,
|
|
2702
|
-
autoShowBlinds,
|
|
2703
|
-
onActivityStateChange: handleActivityStateChange
|
|
5436
|
+
const association = associations?.[tab.id];
|
|
5437
|
+
return /* @__PURE__ */ jsx7("div", {
|
|
5438
|
+
style: {
|
|
5439
|
+
display: isActive ? "flex" : "none",
|
|
5440
|
+
flexDirection: "column",
|
|
5441
|
+
height: "100%",
|
|
5442
|
+
width: "100%"
|
|
5443
|
+
},
|
|
5444
|
+
children: renderTerminalWithAssociation(tab, isActive, sessionId, association)
|
|
2704
5445
|
}, tab.id);
|
|
2705
5446
|
}
|
|
2706
5447
|
return /* @__PURE__ */ jsxs6("div", {
|
|
@@ -2739,10 +5480,6 @@ var TabbedTerminalPanelInner = ({
|
|
|
2739
5480
|
size: 32,
|
|
2740
5481
|
style: { opacity: 0.5, marginBottom: "16px" }
|
|
2741
5482
|
}),
|
|
2742
|
-
/* @__PURE__ */ jsx7("p", {
|
|
2743
|
-
style: { fontFamily: theme.fonts.body, fontSize: theme.fontSizes[1] },
|
|
2744
|
-
children: "No terminal sessions"
|
|
2745
|
-
}),
|
|
2746
5483
|
/* @__PURE__ */ jsx7("button", {
|
|
2747
5484
|
onClick: () => addNewTab(),
|
|
2748
5485
|
style: {
|
|
@@ -2766,7 +5503,7 @@ var TabbedTerminalPanelInner = ({
|
|
|
2766
5503
|
});
|
|
2767
5504
|
};
|
|
2768
5505
|
TabbedTerminalPanelInner.displayName = "TabbedTerminalPanelInner";
|
|
2769
|
-
var TabbedTerminalPanelMemoized =
|
|
5506
|
+
var TabbedTerminalPanelMemoized = React3.memo(TabbedTerminalPanelInner, (prevProps, nextProps) => {
|
|
2770
5507
|
const changes = [];
|
|
2771
5508
|
if (prevProps.terminalContext !== nextProps.terminalContext)
|
|
2772
5509
|
changes.push("terminalContext");
|
|
@@ -2808,6 +5545,12 @@ var TabbedTerminalPanelMemoized = React2.memo(TabbedTerminalPanelInner, (prevPro
|
|
|
2808
5545
|
changes.push("activityTimeout");
|
|
2809
5546
|
if (prevProps.autoShowBlinds !== nextProps.autoShowBlinds)
|
|
2810
5547
|
changes.push("autoShowBlinds");
|
|
5548
|
+
if (prevProps.associations !== nextProps.associations)
|
|
5549
|
+
changes.push("associations");
|
|
5550
|
+
if (prevProps.renderAssociatedContent !== nextProps.renderAssociatedContent)
|
|
5551
|
+
changes.push("renderAssociatedContent");
|
|
5552
|
+
if (prevProps.getAssociatedHeader !== nextProps.getAssociatedHeader)
|
|
5553
|
+
changes.push("getAssociatedHeader");
|
|
2811
5554
|
const ignoredChanges = [];
|
|
2812
5555
|
if (prevProps.context !== nextProps.context)
|
|
2813
5556
|
ignoredChanges.push("context");
|