react-resizable-panels 2.1.7 → 2.1.9
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/LICENSE +21 -0
- package/README.md +4 -0
- package/dist/declarations/src/Panel.d.ts +1 -1
- package/dist/declarations/src/PanelGroup.d.ts +1 -1
- package/dist/declarations/src/PanelResizeHandle.d.ts +6 -3
- package/dist/declarations/src/constants.d.ts +15 -0
- package/dist/declarations/src/index.d.ts +3 -2
- package/dist/react-resizable-panels.browser.cjs.js +202 -176
- package/dist/react-resizable-panels.browser.cjs.mjs +1 -0
- package/dist/react-resizable-panels.browser.development.cjs.js +202 -176
- package/dist/react-resizable-panels.browser.development.cjs.mjs +1 -0
- package/dist/react-resizable-panels.browser.development.esm.js +150 -124
- package/dist/react-resizable-panels.browser.esm.js +150 -124
- package/dist/react-resizable-panels.cjs.js +202 -176
- package/dist/react-resizable-panels.cjs.mjs +1 -0
- package/dist/react-resizable-panels.development.cjs.js +202 -176
- package/dist/react-resizable-panels.development.cjs.mjs +1 -0
- package/dist/react-resizable-panels.development.esm.js +150 -124
- package/dist/react-resizable-panels.development.node.cjs.js +201 -174
- package/dist/react-resizable-panels.development.node.cjs.mjs +1 -0
- package/dist/react-resizable-panels.development.node.esm.js +149 -122
- package/dist/react-resizable-panels.esm.js +150 -124
- package/dist/react-resizable-panels.node.cjs.js +201 -174
- package/dist/react-resizable-panels.node.cjs.mjs +1 -0
- package/dist/react-resizable-panels.node.esm.js +149 -122
- package/package.json +12 -13
- package/dist/declarations/src/vendor/react.d.ts +0 -7
|
@@ -24,41 +24,35 @@ function _interopNamespace(e) {
|
|
|
24
24
|
|
|
25
25
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
26
26
|
|
|
27
|
-
// This module exists to work around Webpack issue https://github.com/webpack/webpack/issues/14814
|
|
28
|
-
|
|
29
|
-
// eslint-disable-next-line no-restricted-imports
|
|
30
|
-
|
|
31
|
-
const {
|
|
32
|
-
createElement,
|
|
33
|
-
createContext,
|
|
34
|
-
createRef,
|
|
35
|
-
forwardRef,
|
|
36
|
-
useCallback,
|
|
37
|
-
useContext,
|
|
38
|
-
useEffect,
|
|
39
|
-
useImperativeHandle,
|
|
40
|
-
useLayoutEffect,
|
|
41
|
-
useMemo,
|
|
42
|
-
useRef,
|
|
43
|
-
useState
|
|
44
|
-
} = React__namespace;
|
|
45
|
-
|
|
46
|
-
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
|
|
47
|
-
const useId = React__namespace[`useId${Math.random()}`.slice(0, 5)];
|
|
48
|
-
const useLayoutEffect_do_not_use_directly = useLayoutEffect;
|
|
49
|
-
|
|
50
27
|
// The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
|
|
51
28
|
|
|
52
|
-
const PanelGroupContext = createContext(null);
|
|
29
|
+
const PanelGroupContext = React.createContext(null);
|
|
53
30
|
PanelGroupContext.displayName = "PanelGroupContext";
|
|
54
31
|
|
|
55
|
-
const
|
|
32
|
+
const DATA_ATTRIBUTES = {
|
|
33
|
+
group: "data-panel-group",
|
|
34
|
+
groupDirection: "data-panel-group-direction",
|
|
35
|
+
groupId: "data-panel-group-id",
|
|
36
|
+
panel: "data-panel",
|
|
37
|
+
panelCollapsible: "data-panel-collapsible",
|
|
38
|
+
panelId: "data-panel-id",
|
|
39
|
+
panelSize: "data-panel-size",
|
|
40
|
+
resizeHandle: "data-resize-handle",
|
|
41
|
+
resizeHandleActive: "data-resize-handle-active",
|
|
42
|
+
resizeHandleEnabled: "data-panel-resize-handle-enabled",
|
|
43
|
+
resizeHandleId: "data-panel-resize-handle-id",
|
|
44
|
+
resizeHandleState: "data-resize-handle-state"
|
|
45
|
+
};
|
|
46
|
+
const PRECISION = 10;
|
|
47
|
+
|
|
48
|
+
const useIsomorphicLayoutEffect = React.useLayoutEffect ;
|
|
56
49
|
|
|
50
|
+
const useId = React__namespace["useId".toString()];
|
|
57
51
|
const wrappedUseId = typeof useId === "function" ? useId : () => null;
|
|
58
52
|
let counter = 0;
|
|
59
53
|
function useUniqueId(idFromParams = null) {
|
|
60
54
|
const idFromUseId = wrappedUseId();
|
|
61
|
-
const idRef = useRef(idFromParams || idFromUseId || null);
|
|
55
|
+
const idRef = React.useRef(idFromParams || idFromUseId || null);
|
|
62
56
|
if (idRef.current === null) {
|
|
63
57
|
idRef.current = "" + counter++;
|
|
64
58
|
}
|
|
@@ -83,7 +77,7 @@ function PanelWithForwardedRef({
|
|
|
83
77
|
tagName: Type = "div",
|
|
84
78
|
...rest
|
|
85
79
|
}) {
|
|
86
|
-
const context = useContext(PanelGroupContext);
|
|
80
|
+
const context = React.useContext(PanelGroupContext);
|
|
87
81
|
if (context === null) {
|
|
88
82
|
throw Error(`Panel components must be rendered within a PanelGroup container`);
|
|
89
83
|
}
|
|
@@ -100,7 +94,7 @@ function PanelWithForwardedRef({
|
|
|
100
94
|
unregisterPanel
|
|
101
95
|
} = context;
|
|
102
96
|
const panelId = useUniqueId(idFromProps);
|
|
103
|
-
const panelDataRef = useRef({
|
|
97
|
+
const panelDataRef = React.useRef({
|
|
104
98
|
callbacks: {
|
|
105
99
|
onCollapse,
|
|
106
100
|
onExpand,
|
|
@@ -117,7 +111,7 @@ function PanelWithForwardedRef({
|
|
|
117
111
|
idIsFromProps: idFromProps !== undefined,
|
|
118
112
|
order
|
|
119
113
|
});
|
|
120
|
-
const devWarningsRef = useRef({
|
|
114
|
+
const devWarningsRef = React.useRef({
|
|
121
115
|
didLogMissingDefaultSizeWarning: false
|
|
122
116
|
});
|
|
123
117
|
|
|
@@ -159,7 +153,7 @@ function PanelWithForwardedRef({
|
|
|
159
153
|
unregisterPanel(panelData);
|
|
160
154
|
};
|
|
161
155
|
}, [order, panelId, registerPanel, unregisterPanel]);
|
|
162
|
-
useImperativeHandle(forwardedRef, () => ({
|
|
156
|
+
React.useImperativeHandle(forwardedRef, () => ({
|
|
163
157
|
collapse: () => {
|
|
164
158
|
collapsePanel(panelDataRef.current);
|
|
165
159
|
},
|
|
@@ -183,24 +177,24 @@ function PanelWithForwardedRef({
|
|
|
183
177
|
}
|
|
184
178
|
}), [collapsePanel, expandPanel, getPanelSize, isPanelCollapsed, panelId, resizePanel]);
|
|
185
179
|
const style = getPanelStyle(panelDataRef.current, defaultSize);
|
|
186
|
-
return createElement(Type, {
|
|
180
|
+
return React.createElement(Type, {
|
|
187
181
|
...rest,
|
|
188
182
|
children,
|
|
189
183
|
className: classNameFromProps,
|
|
190
|
-
id:
|
|
184
|
+
id: panelId,
|
|
191
185
|
style: {
|
|
192
186
|
...style,
|
|
193
187
|
...styleFromProps
|
|
194
188
|
},
|
|
195
189
|
// CSS selectors
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
190
|
+
[DATA_ATTRIBUTES.groupId]: groupId,
|
|
191
|
+
[DATA_ATTRIBUTES.panel]: "",
|
|
192
|
+
[DATA_ATTRIBUTES.panelCollapsible]: collapsible || undefined,
|
|
193
|
+
[DATA_ATTRIBUTES.panelId]: panelId,
|
|
194
|
+
[DATA_ATTRIBUTES.panelSize]: parseFloat("" + style.flexGrow).toFixed(1)
|
|
201
195
|
});
|
|
202
196
|
}
|
|
203
|
-
const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
|
|
197
|
+
const Panel = React.forwardRef((props, ref) => React.createElement(PanelWithForwardedRef, {
|
|
204
198
|
...props,
|
|
205
199
|
forwardedRef: ref
|
|
206
200
|
}));
|
|
@@ -217,6 +211,7 @@ function setNonce(value) {
|
|
|
217
211
|
|
|
218
212
|
let currentCursorStyle = null;
|
|
219
213
|
let enabled = true;
|
|
214
|
+
let prevRuleIndex = -1;
|
|
220
215
|
let styleElement = null;
|
|
221
216
|
function disableGlobalCursorStyles() {
|
|
222
217
|
enabled = false;
|
|
@@ -266,9 +261,11 @@ function resetGlobalCursorStyle() {
|
|
|
266
261
|
document.head.removeChild(styleElement);
|
|
267
262
|
currentCursorStyle = null;
|
|
268
263
|
styleElement = null;
|
|
264
|
+
prevRuleIndex = -1;
|
|
269
265
|
}
|
|
270
266
|
}
|
|
271
267
|
function setGlobalCursorStyle(state, constraintFlags) {
|
|
268
|
+
var _styleElement$sheet$i, _styleElement$sheet2;
|
|
272
269
|
if (!enabled) {
|
|
273
270
|
return;
|
|
274
271
|
}
|
|
@@ -285,7 +282,11 @@ function setGlobalCursorStyle(state, constraintFlags) {
|
|
|
285
282
|
}
|
|
286
283
|
document.head.appendChild(styleElement);
|
|
287
284
|
}
|
|
288
|
-
|
|
285
|
+
if (prevRuleIndex >= 0) {
|
|
286
|
+
var _styleElement$sheet;
|
|
287
|
+
(_styleElement$sheet = styleElement.sheet) === null || _styleElement$sheet === void 0 ? void 0 : _styleElement$sheet.removeRule(prevRuleIndex);
|
|
288
|
+
}
|
|
289
|
+
prevRuleIndex = (_styleElement$sheet$i = (_styleElement$sheet2 = styleElement.sheet) === null || _styleElement$sheet2 === void 0 ? void 0 : _styleElement$sheet2.insertRule(`*{cursor: ${style} !important;}`)) !== null && _styleElement$sheet$i !== void 0 ? _styleElement$sheet$i : -1;
|
|
289
290
|
}
|
|
290
291
|
|
|
291
292
|
function isKeyDown(event) {
|
|
@@ -516,7 +517,9 @@ function handlePointerDown(event) {
|
|
|
516
517
|
if (intersectingHandles.length > 0) {
|
|
517
518
|
updateResizeHandlerStates("down", event);
|
|
518
519
|
event.preventDefault();
|
|
519
|
-
|
|
520
|
+
if (!isWithinResizeHandle(target)) {
|
|
521
|
+
event.stopImmediatePropagation();
|
|
522
|
+
}
|
|
520
523
|
}
|
|
521
524
|
}
|
|
522
525
|
function handlePointerMove(event) {
|
|
@@ -565,6 +568,9 @@ function handlePointerUp(event) {
|
|
|
565
568
|
isPointerDown = false;
|
|
566
569
|
if (intersectingHandles.length > 0) {
|
|
567
570
|
event.preventDefault();
|
|
571
|
+
if (!isWithinResizeHandle(target)) {
|
|
572
|
+
event.stopImmediatePropagation();
|
|
573
|
+
}
|
|
568
574
|
}
|
|
569
575
|
updateResizeHandlerStates("up", event);
|
|
570
576
|
recalculateIntersectingHandles({
|
|
@@ -575,6 +581,16 @@ function handlePointerUp(event) {
|
|
|
575
581
|
updateCursor();
|
|
576
582
|
updateListeners();
|
|
577
583
|
}
|
|
584
|
+
function isWithinResizeHandle(element) {
|
|
585
|
+
let currentElement = element;
|
|
586
|
+
while (currentElement) {
|
|
587
|
+
if (currentElement.hasAttribute(DATA_ATTRIBUTES.resizeHandle)) {
|
|
588
|
+
return true;
|
|
589
|
+
}
|
|
590
|
+
currentElement = currentElement.parentElement;
|
|
591
|
+
}
|
|
592
|
+
return false;
|
|
593
|
+
}
|
|
578
594
|
function recalculateIntersectingHandles({
|
|
579
595
|
target,
|
|
580
596
|
x,
|
|
@@ -666,47 +682,42 @@ function updateCursor() {
|
|
|
666
682
|
resetGlobalCursorStyle();
|
|
667
683
|
}
|
|
668
684
|
}
|
|
685
|
+
let listenersAbortController = new AbortController();
|
|
669
686
|
function updateListeners() {
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
if (registeredResizeHandlers.size > 0) {
|
|
682
|
-
if (isPointerDown) {
|
|
683
|
-
if (intersectingHandles.length > 0) {
|
|
684
|
-
ownerDocumentCounts.forEach((count, ownerDocument) => {
|
|
685
|
-
const {
|
|
686
|
-
body
|
|
687
|
-
} = ownerDocument;
|
|
688
|
-
if (count > 0) {
|
|
689
|
-
body.addEventListener("contextmenu", handlePointerUp);
|
|
690
|
-
body.addEventListener("pointerleave", handlePointerMove);
|
|
691
|
-
body.addEventListener("pointermove", handlePointerMove);
|
|
692
|
-
}
|
|
693
|
-
});
|
|
694
|
-
}
|
|
695
|
-
window.addEventListener("pointerup", handlePointerUp);
|
|
696
|
-
window.addEventListener("pointercancel", handlePointerUp);
|
|
697
|
-
} else {
|
|
687
|
+
listenersAbortController.abort();
|
|
688
|
+
listenersAbortController = new AbortController();
|
|
689
|
+
const options = {
|
|
690
|
+
capture: true,
|
|
691
|
+
signal: listenersAbortController.signal
|
|
692
|
+
};
|
|
693
|
+
if (!registeredResizeHandlers.size) {
|
|
694
|
+
return;
|
|
695
|
+
}
|
|
696
|
+
if (isPointerDown) {
|
|
697
|
+
if (intersectingHandles.length > 0) {
|
|
698
698
|
ownerDocumentCounts.forEach((count, ownerDocument) => {
|
|
699
699
|
const {
|
|
700
700
|
body
|
|
701
701
|
} = ownerDocument;
|
|
702
702
|
if (count > 0) {
|
|
703
|
-
body.addEventListener("
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
body.addEventListener("pointermove", handlePointerMove);
|
|
703
|
+
body.addEventListener("contextmenu", handlePointerUp, options);
|
|
704
|
+
body.addEventListener("pointerleave", handlePointerMove, options);
|
|
705
|
+
body.addEventListener("pointermove", handlePointerMove, options);
|
|
707
706
|
}
|
|
708
707
|
});
|
|
709
708
|
}
|
|
709
|
+
window.addEventListener("pointerup", handlePointerUp, options);
|
|
710
|
+
window.addEventListener("pointercancel", handlePointerUp, options);
|
|
711
|
+
} else {
|
|
712
|
+
ownerDocumentCounts.forEach((count, ownerDocument) => {
|
|
713
|
+
const {
|
|
714
|
+
body
|
|
715
|
+
} = ownerDocument;
|
|
716
|
+
if (count > 0) {
|
|
717
|
+
body.addEventListener("pointerdown", handlePointerDown, options);
|
|
718
|
+
body.addEventListener("pointermove", handlePointerMove, options);
|
|
719
|
+
}
|
|
720
|
+
});
|
|
710
721
|
}
|
|
711
722
|
}
|
|
712
723
|
function updateResizeHandlerStates(action, event) {
|
|
@@ -720,8 +731,8 @@ function updateResizeHandlerStates(action, event) {
|
|
|
720
731
|
}
|
|
721
732
|
|
|
722
733
|
function useForceUpdate() {
|
|
723
|
-
const [_, setCount] = useState(0);
|
|
724
|
-
return useCallback(() => setCount(prevCount => prevCount + 1), []);
|
|
734
|
+
const [_, setCount] = React.useState(0);
|
|
735
|
+
return React.useCallback(() => setCount(prevCount => prevCount + 1), []);
|
|
725
736
|
}
|
|
726
737
|
|
|
727
738
|
function assert(expectedCondition, message) {
|
|
@@ -731,8 +742,6 @@ function assert(expectedCondition, message) {
|
|
|
731
742
|
}
|
|
732
743
|
}
|
|
733
744
|
|
|
734
|
-
const PRECISION = 10;
|
|
735
|
-
|
|
736
745
|
function fuzzyCompareNumbers(actual, expected, fractionDigits = PRECISION) {
|
|
737
746
|
if (actual.toFixed(fractionDigits) === expected.toFixed(fractionDigits)) {
|
|
738
747
|
return 0;
|
|
@@ -1076,12 +1085,12 @@ function calculateAriaValues({
|
|
|
1076
1085
|
}
|
|
1077
1086
|
|
|
1078
1087
|
function getResizeHandleElementsForGroup(groupId, scope = document) {
|
|
1079
|
-
return Array.from(scope.querySelectorAll(`[
|
|
1088
|
+
return Array.from(scope.querySelectorAll(`[${DATA_ATTRIBUTES.resizeHandleId}][data-panel-group-id="${groupId}"]`));
|
|
1080
1089
|
}
|
|
1081
1090
|
|
|
1082
1091
|
function getResizeHandleElementIndex(groupId, id, scope = document) {
|
|
1083
1092
|
const handles = getResizeHandleElementsForGroup(groupId, scope);
|
|
1084
|
-
const index = handles.findIndex(handle => handle.getAttribute(
|
|
1093
|
+
const index = handles.findIndex(handle => handle.getAttribute(DATA_ATTRIBUTES.resizeHandleId) === id);
|
|
1085
1094
|
return index !== null && index !== void 0 ? index : null;
|
|
1086
1095
|
}
|
|
1087
1096
|
|
|
@@ -1106,7 +1115,7 @@ function getPanelGroupElement(id, rootElement = document) {
|
|
|
1106
1115
|
}
|
|
1107
1116
|
|
|
1108
1117
|
function getResizeHandleElement(id, scope = document) {
|
|
1109
|
-
const element = scope.querySelector(`[
|
|
1118
|
+
const element = scope.querySelector(`[${DATA_ATTRIBUTES.resizeHandleId}="${id}"]`);
|
|
1110
1119
|
if (element) {
|
|
1111
1120
|
return element;
|
|
1112
1121
|
}
|
|
@@ -1134,7 +1143,7 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
1134
1143
|
panelGroupElement,
|
|
1135
1144
|
setLayout
|
|
1136
1145
|
}) {
|
|
1137
|
-
const devWarningsRef = useRef({
|
|
1146
|
+
const devWarningsRef = React.useRef({
|
|
1138
1147
|
didWarnAboutMissingResizeHandle: false
|
|
1139
1148
|
});
|
|
1140
1149
|
useIsomorphicLayoutEffect(() => {
|
|
@@ -1181,7 +1190,7 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
1181
1190
|
});
|
|
1182
1191
|
};
|
|
1183
1192
|
}, [groupId, layout, panelDataArray, panelGroupElement]);
|
|
1184
|
-
useEffect(() => {
|
|
1193
|
+
React.useEffect(() => {
|
|
1185
1194
|
if (!panelGroupElement) {
|
|
1186
1195
|
return;
|
|
1187
1196
|
}
|
|
@@ -1195,7 +1204,7 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
1195
1204
|
const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
1196
1205
|
assert(handles, `No resize handles found for group id "${groupId}"`);
|
|
1197
1206
|
const cleanupFunctions = handles.map(handle => {
|
|
1198
|
-
const handleId = handle.getAttribute(
|
|
1207
|
+
const handleId = handle.getAttribute(DATA_ATTRIBUTES.resizeHandleId);
|
|
1199
1208
|
assert(handleId, `Resize handle element has no handle id attribute`);
|
|
1200
1209
|
const [idBefore, idAfter] = getResizeHandlePanelIds(groupId, handleId, panelDataArray, panelGroupElement);
|
|
1201
1210
|
if (idBefore == null || idAfter == null) {
|
|
@@ -1273,7 +1282,7 @@ function calculateDragOffsetPercentage(event, dragHandleId, direction, initialDr
|
|
|
1273
1282
|
const isHorizontal = direction === "horizontal";
|
|
1274
1283
|
const handleElement = getResizeHandleElement(dragHandleId, panelGroupElement);
|
|
1275
1284
|
assert(handleElement, `No resize handle element found for id "${dragHandleId}"`);
|
|
1276
|
-
const groupId = handleElement.getAttribute(
|
|
1285
|
+
const groupId = handleElement.getAttribute(DATA_ATTRIBUTES.groupId);
|
|
1277
1286
|
assert(groupId, `Resize handle element has no group id attribute`);
|
|
1278
1287
|
let {
|
|
1279
1288
|
initialCursorPosition
|
|
@@ -1688,14 +1697,14 @@ function PanelGroupWithForwardedRef({
|
|
|
1688
1697
|
...rest
|
|
1689
1698
|
}) {
|
|
1690
1699
|
const groupId = useUniqueId(idFromProps);
|
|
1691
|
-
const panelGroupElementRef = useRef(null);
|
|
1692
|
-
const [dragState, setDragState] = useState(null);
|
|
1693
|
-
const [layout, setLayout] = useState([]);
|
|
1700
|
+
const panelGroupElementRef = React.useRef(null);
|
|
1701
|
+
const [dragState, setDragState] = React.useState(null);
|
|
1702
|
+
const [layout, setLayout] = React.useState([]);
|
|
1694
1703
|
const forceUpdate = useForceUpdate();
|
|
1695
|
-
const panelIdToLastNotifiedSizeMapRef = useRef({});
|
|
1696
|
-
const panelSizeBeforeCollapseRef = useRef(new Map());
|
|
1697
|
-
const prevDeltaRef = useRef(0);
|
|
1698
|
-
const committedValuesRef = useRef({
|
|
1704
|
+
const panelIdToLastNotifiedSizeMapRef = React.useRef({});
|
|
1705
|
+
const panelSizeBeforeCollapseRef = React.useRef(new Map());
|
|
1706
|
+
const prevDeltaRef = React.useRef(0);
|
|
1707
|
+
const committedValuesRef = React.useRef({
|
|
1699
1708
|
autoSaveId,
|
|
1700
1709
|
direction,
|
|
1701
1710
|
dragState,
|
|
@@ -1704,17 +1713,17 @@ function PanelGroupWithForwardedRef({
|
|
|
1704
1713
|
onLayout,
|
|
1705
1714
|
storage
|
|
1706
1715
|
});
|
|
1707
|
-
const eagerValuesRef = useRef({
|
|
1716
|
+
const eagerValuesRef = React.useRef({
|
|
1708
1717
|
layout,
|
|
1709
1718
|
panelDataArray: [],
|
|
1710
1719
|
panelDataArrayChanged: false
|
|
1711
1720
|
});
|
|
1712
|
-
const devWarningsRef = useRef({
|
|
1721
|
+
const devWarningsRef = React.useRef({
|
|
1713
1722
|
didLogIdAndOrderWarning: false,
|
|
1714
1723
|
didLogPanelConstraintsWarning: false,
|
|
1715
1724
|
prevPanelIds: []
|
|
1716
1725
|
});
|
|
1717
|
-
useImperativeHandle(forwardedRef, () => ({
|
|
1726
|
+
React.useImperativeHandle(forwardedRef, () => ({
|
|
1718
1727
|
getId: () => committedValuesRef.current.id,
|
|
1719
1728
|
getLayout: () => {
|
|
1720
1729
|
const {
|
|
@@ -1761,7 +1770,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1761
1770
|
setLayout,
|
|
1762
1771
|
panelGroupElement: panelGroupElementRef.current
|
|
1763
1772
|
});
|
|
1764
|
-
useEffect(() => {
|
|
1773
|
+
React.useEffect(() => {
|
|
1765
1774
|
const {
|
|
1766
1775
|
panelDataArray
|
|
1767
1776
|
} = eagerValuesRef.current;
|
|
@@ -1788,7 +1797,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1788
1797
|
}, [autoSaveId, layout, storage]);
|
|
1789
1798
|
|
|
1790
1799
|
// DEV warnings
|
|
1791
|
-
useEffect(() => {
|
|
1800
|
+
React.useEffect(() => {
|
|
1792
1801
|
{
|
|
1793
1802
|
const {
|
|
1794
1803
|
panelDataArray
|
|
@@ -1834,7 +1843,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1834
1843
|
});
|
|
1835
1844
|
|
|
1836
1845
|
// External APIs are safe to memoize via committed values ref
|
|
1837
|
-
const collapsePanel = useCallback(panelData => {
|
|
1846
|
+
const collapsePanel = React.useCallback(panelData => {
|
|
1838
1847
|
const {
|
|
1839
1848
|
onLayout
|
|
1840
1849
|
} = committedValuesRef.current;
|
|
@@ -1877,7 +1886,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1877
1886
|
}, []);
|
|
1878
1887
|
|
|
1879
1888
|
// External APIs are safe to memoize via committed values ref
|
|
1880
|
-
const expandPanel = useCallback((panelData, minSizeOverride) => {
|
|
1889
|
+
const expandPanel = React.useCallback((panelData, minSizeOverride) => {
|
|
1881
1890
|
const {
|
|
1882
1891
|
onLayout
|
|
1883
1892
|
} = committedValuesRef.current;
|
|
@@ -1921,7 +1930,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1921
1930
|
}, []);
|
|
1922
1931
|
|
|
1923
1932
|
// External APIs are safe to memoize via committed values ref
|
|
1924
|
-
const getPanelSize = useCallback(panelData => {
|
|
1933
|
+
const getPanelSize = React.useCallback(panelData => {
|
|
1925
1934
|
const {
|
|
1926
1935
|
layout,
|
|
1927
1936
|
panelDataArray
|
|
@@ -1934,7 +1943,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1934
1943
|
}, []);
|
|
1935
1944
|
|
|
1936
1945
|
// This API should never read from committedValuesRef
|
|
1937
|
-
const getPanelStyle = useCallback((panelData, defaultSize) => {
|
|
1946
|
+
const getPanelStyle = React.useCallback((panelData, defaultSize) => {
|
|
1938
1947
|
const {
|
|
1939
1948
|
panelDataArray
|
|
1940
1949
|
} = eagerValuesRef.current;
|
|
@@ -1949,7 +1958,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1949
1958
|
}, [dragState, layout]);
|
|
1950
1959
|
|
|
1951
1960
|
// External APIs are safe to memoize via committed values ref
|
|
1952
|
-
const isPanelCollapsed = useCallback(panelData => {
|
|
1961
|
+
const isPanelCollapsed = React.useCallback(panelData => {
|
|
1953
1962
|
const {
|
|
1954
1963
|
layout,
|
|
1955
1964
|
panelDataArray
|
|
@@ -1964,7 +1973,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1964
1973
|
}, []);
|
|
1965
1974
|
|
|
1966
1975
|
// External APIs are safe to memoize via committed values ref
|
|
1967
|
-
const isPanelExpanded = useCallback(panelData => {
|
|
1976
|
+
const isPanelExpanded = React.useCallback(panelData => {
|
|
1968
1977
|
const {
|
|
1969
1978
|
layout,
|
|
1970
1979
|
panelDataArray
|
|
@@ -1977,7 +1986,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1977
1986
|
assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
|
|
1978
1987
|
return !collapsible || fuzzyCompareNumbers(panelSize, collapsedSize) > 0;
|
|
1979
1988
|
}, []);
|
|
1980
|
-
const registerPanel = useCallback(panelData => {
|
|
1989
|
+
const registerPanel = React.useCallback(panelData => {
|
|
1981
1990
|
const {
|
|
1982
1991
|
panelDataArray
|
|
1983
1992
|
} = eagerValuesRef.current;
|
|
@@ -2054,7 +2063,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2054
2063
|
eagerValues.layout = [];
|
|
2055
2064
|
};
|
|
2056
2065
|
}, []);
|
|
2057
|
-
const registerResizeHandle = useCallback(dragHandleId => {
|
|
2066
|
+
const registerResizeHandle = React.useCallback(dragHandleId => {
|
|
2058
2067
|
let isRTL = false;
|
|
2059
2068
|
const panelGroupElement = panelGroupElementRef.current;
|
|
2060
2069
|
if (panelGroupElement) {
|
|
@@ -2133,7 +2142,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2133
2142
|
}, []);
|
|
2134
2143
|
|
|
2135
2144
|
// External APIs are safe to memoize via committed values ref
|
|
2136
|
-
const resizePanel = useCallback((panelData, unsafePanelSize) => {
|
|
2145
|
+
const resizePanel = React.useCallback((panelData, unsafePanelSize) => {
|
|
2137
2146
|
const {
|
|
2138
2147
|
onLayout
|
|
2139
2148
|
} = committedValuesRef.current;
|
|
@@ -2166,7 +2175,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2166
2175
|
callPanelCallbacks(panelDataArray, nextLayout, panelIdToLastNotifiedSizeMapRef.current);
|
|
2167
2176
|
}
|
|
2168
2177
|
}, []);
|
|
2169
|
-
const reevaluatePanelConstraints = useCallback((panelData, prevConstraints) => {
|
|
2178
|
+
const reevaluatePanelConstraints = React.useCallback((panelData, prevConstraints) => {
|
|
2170
2179
|
const {
|
|
2171
2180
|
layout,
|
|
2172
2181
|
panelDataArray
|
|
@@ -2200,7 +2209,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2200
2209
|
}, [resizePanel]);
|
|
2201
2210
|
|
|
2202
2211
|
// TODO Multiple drag handles can be active at the same time so this API is a bit awkward now
|
|
2203
|
-
const startDragging = useCallback((dragHandleId, event) => {
|
|
2212
|
+
const startDragging = React.useCallback((dragHandleId, event) => {
|
|
2204
2213
|
const {
|
|
2205
2214
|
direction
|
|
2206
2215
|
} = committedValuesRef.current;
|
|
@@ -2220,10 +2229,10 @@ function PanelGroupWithForwardedRef({
|
|
|
2220
2229
|
initialLayout: layout
|
|
2221
2230
|
});
|
|
2222
2231
|
}, []);
|
|
2223
|
-
const stopDragging = useCallback(() => {
|
|
2232
|
+
const stopDragging = React.useCallback(() => {
|
|
2224
2233
|
setDragState(null);
|
|
2225
2234
|
}, []);
|
|
2226
|
-
const unregisterPanel = useCallback(panelData => {
|
|
2235
|
+
const unregisterPanel = React.useCallback(panelData => {
|
|
2227
2236
|
const {
|
|
2228
2237
|
panelDataArray
|
|
2229
2238
|
} = eagerValuesRef.current;
|
|
@@ -2240,7 +2249,7 @@ function PanelGroupWithForwardedRef({
|
|
|
2240
2249
|
forceUpdate();
|
|
2241
2250
|
}
|
|
2242
2251
|
}, [forceUpdate]);
|
|
2243
|
-
const context = useMemo(() => ({
|
|
2252
|
+
const context = React.useMemo(() => ({
|
|
2244
2253
|
collapsePanel,
|
|
2245
2254
|
direction,
|
|
2246
2255
|
dragState,
|
|
@@ -2266,9 +2275,9 @@ function PanelGroupWithForwardedRef({
|
|
|
2266
2275
|
overflow: "hidden",
|
|
2267
2276
|
width: "100%"
|
|
2268
2277
|
};
|
|
2269
|
-
return createElement(PanelGroupContext.Provider, {
|
|
2278
|
+
return React.createElement(PanelGroupContext.Provider, {
|
|
2270
2279
|
value: context
|
|
2271
|
-
}, createElement(Type, {
|
|
2280
|
+
}, React.createElement(Type, {
|
|
2272
2281
|
...rest,
|
|
2273
2282
|
children,
|
|
2274
2283
|
className: classNameFromProps,
|
|
@@ -2279,12 +2288,12 @@ function PanelGroupWithForwardedRef({
|
|
|
2279
2288
|
...styleFromProps
|
|
2280
2289
|
},
|
|
2281
2290
|
// CSS selectors
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2291
|
+
[DATA_ATTRIBUTES.group]: "",
|
|
2292
|
+
[DATA_ATTRIBUTES.groupDirection]: direction,
|
|
2293
|
+
[DATA_ATTRIBUTES.groupId]: groupId
|
|
2285
2294
|
}));
|
|
2286
2295
|
}
|
|
2287
|
-
const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwardedRef, {
|
|
2296
|
+
const PanelGroup = React.forwardRef((props, ref) => React.createElement(PanelGroupWithForwardedRef, {
|
|
2288
2297
|
...props,
|
|
2289
2298
|
forwardedRef: ref
|
|
2290
2299
|
}));
|
|
@@ -2313,7 +2322,7 @@ function useWindowSplitterResizeHandlerBehavior({
|
|
|
2313
2322
|
resizeHandler,
|
|
2314
2323
|
panelGroupElement
|
|
2315
2324
|
}) {
|
|
2316
|
-
useEffect(() => {
|
|
2325
|
+
React.useEffect(() => {
|
|
2317
2326
|
if (disabled || resizeHandler == null || panelGroupElement == null) {
|
|
2318
2327
|
return;
|
|
2319
2328
|
}
|
|
@@ -2340,7 +2349,7 @@ function useWindowSplitterResizeHandlerBehavior({
|
|
|
2340
2349
|
case "F6":
|
|
2341
2350
|
{
|
|
2342
2351
|
event.preventDefault();
|
|
2343
|
-
const groupId = handleElement.getAttribute(
|
|
2352
|
+
const groupId = handleElement.getAttribute(DATA_ATTRIBUTES.groupId);
|
|
2344
2353
|
assert(groupId, `No group element found for id "${groupId}"`);
|
|
2345
2354
|
const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
2346
2355
|
const index = getResizeHandleElementIndex(groupId, handleId, panelGroupElement);
|
|
@@ -2366,24 +2375,33 @@ function PanelResizeHandle({
|
|
|
2366
2375
|
hitAreaMargins,
|
|
2367
2376
|
id: idFromProps,
|
|
2368
2377
|
onBlur,
|
|
2378
|
+
onClick,
|
|
2369
2379
|
onDragging,
|
|
2370
2380
|
onFocus,
|
|
2381
|
+
onPointerDown,
|
|
2382
|
+
onPointerUp,
|
|
2371
2383
|
style: styleFromProps = {},
|
|
2372
2384
|
tabIndex = 0,
|
|
2373
2385
|
tagName: Type = "div",
|
|
2374
2386
|
...rest
|
|
2375
2387
|
}) {
|
|
2376
2388
|
var _hitAreaMargins$coars, _hitAreaMargins$fine;
|
|
2377
|
-
const elementRef = useRef(null);
|
|
2389
|
+
const elementRef = React.useRef(null);
|
|
2378
2390
|
|
|
2379
2391
|
// Use a ref to guard against users passing inline props
|
|
2380
|
-
const callbacksRef = useRef({
|
|
2381
|
-
|
|
2392
|
+
const callbacksRef = React.useRef({
|
|
2393
|
+
onClick,
|
|
2394
|
+
onDragging,
|
|
2395
|
+
onPointerDown,
|
|
2396
|
+
onPointerUp
|
|
2382
2397
|
});
|
|
2383
|
-
useEffect(() => {
|
|
2398
|
+
React.useEffect(() => {
|
|
2399
|
+
callbacksRef.current.onClick = onClick;
|
|
2384
2400
|
callbacksRef.current.onDragging = onDragging;
|
|
2401
|
+
callbacksRef.current.onPointerDown = onPointerDown;
|
|
2402
|
+
callbacksRef.current.onPointerUp = onPointerUp;
|
|
2385
2403
|
});
|
|
2386
|
-
const panelGroupContext = useContext(PanelGroupContext);
|
|
2404
|
+
const panelGroupContext = React.useContext(PanelGroupContext);
|
|
2387
2405
|
if (panelGroupContext === null) {
|
|
2388
2406
|
throw Error(`PanelResizeHandle components must be rendered within a PanelGroup container`);
|
|
2389
2407
|
}
|
|
@@ -2396,16 +2414,16 @@ function PanelResizeHandle({
|
|
|
2396
2414
|
panelGroupElement
|
|
2397
2415
|
} = panelGroupContext;
|
|
2398
2416
|
const resizeHandleId = useUniqueId(idFromProps);
|
|
2399
|
-
const [state, setState] = useState("inactive");
|
|
2400
|
-
const [isFocused, setIsFocused] = useState(false);
|
|
2401
|
-
const [resizeHandler, setResizeHandler] = useState(null);
|
|
2402
|
-
const committedValuesRef = useRef({
|
|
2417
|
+
const [state, setState] = React.useState("inactive");
|
|
2418
|
+
const [isFocused, setIsFocused] = React.useState(false);
|
|
2419
|
+
const [resizeHandler, setResizeHandler] = React.useState(null);
|
|
2420
|
+
const committedValuesRef = React.useRef({
|
|
2403
2421
|
state
|
|
2404
2422
|
});
|
|
2405
2423
|
useIsomorphicLayoutEffect(() => {
|
|
2406
2424
|
committedValuesRef.current.state = state;
|
|
2407
2425
|
});
|
|
2408
|
-
useEffect(() => {
|
|
2426
|
+
React.useEffect(() => {
|
|
2409
2427
|
if (disabled) {
|
|
2410
2428
|
setResizeHandler(null);
|
|
2411
2429
|
} else {
|
|
@@ -2418,55 +2436,62 @@ function PanelResizeHandle({
|
|
|
2418
2436
|
// so that inline object values won't trigger re-renders
|
|
2419
2437
|
const coarseHitAreaMargins = (_hitAreaMargins$coars = hitAreaMargins === null || hitAreaMargins === void 0 ? void 0 : hitAreaMargins.coarse) !== null && _hitAreaMargins$coars !== void 0 ? _hitAreaMargins$coars : 15;
|
|
2420
2438
|
const fineHitAreaMargins = (_hitAreaMargins$fine = hitAreaMargins === null || hitAreaMargins === void 0 ? void 0 : hitAreaMargins.fine) !== null && _hitAreaMargins$fine !== void 0 ? _hitAreaMargins$fine : 5;
|
|
2421
|
-
useEffect(() => {
|
|
2439
|
+
React.useEffect(() => {
|
|
2422
2440
|
if (disabled || resizeHandler == null) {
|
|
2423
2441
|
return;
|
|
2424
2442
|
}
|
|
2425
2443
|
const element = elementRef.current;
|
|
2426
2444
|
assert(element, "Element ref not attached");
|
|
2445
|
+
let didMove = false;
|
|
2427
2446
|
const setResizeHandlerState = (action, isActive, event) => {
|
|
2428
|
-
if (isActive) {
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
}
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
}
|
|
2455
|
-
case "up":
|
|
2456
|
-
{
|
|
2447
|
+
if (!isActive) {
|
|
2448
|
+
setState("inactive");
|
|
2449
|
+
return;
|
|
2450
|
+
}
|
|
2451
|
+
switch (action) {
|
|
2452
|
+
case "down":
|
|
2453
|
+
{
|
|
2454
|
+
setState("drag");
|
|
2455
|
+
didMove = false;
|
|
2456
|
+
assert(event, 'Expected event to be defined for "down" action');
|
|
2457
|
+
startDragging(resizeHandleId, event);
|
|
2458
|
+
const {
|
|
2459
|
+
onDragging,
|
|
2460
|
+
onPointerDown
|
|
2461
|
+
} = callbacksRef.current;
|
|
2462
|
+
onDragging === null || onDragging === void 0 ? void 0 : onDragging(true);
|
|
2463
|
+
onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown();
|
|
2464
|
+
break;
|
|
2465
|
+
}
|
|
2466
|
+
case "move":
|
|
2467
|
+
{
|
|
2468
|
+
const {
|
|
2469
|
+
state
|
|
2470
|
+
} = committedValuesRef.current;
|
|
2471
|
+
didMove = true;
|
|
2472
|
+
if (state !== "drag") {
|
|
2457
2473
|
setState("hover");
|
|
2458
|
-
stopDragging();
|
|
2459
|
-
const {
|
|
2460
|
-
onDragging
|
|
2461
|
-
} = callbacksRef.current;
|
|
2462
|
-
if (onDragging) {
|
|
2463
|
-
onDragging(false);
|
|
2464
|
-
}
|
|
2465
|
-
break;
|
|
2466
2474
|
}
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2475
|
+
assert(event, 'Expected event to be defined for "move" action');
|
|
2476
|
+
resizeHandler(event);
|
|
2477
|
+
break;
|
|
2478
|
+
}
|
|
2479
|
+
case "up":
|
|
2480
|
+
{
|
|
2481
|
+
setState("hover");
|
|
2482
|
+
stopDragging();
|
|
2483
|
+
const {
|
|
2484
|
+
onClick,
|
|
2485
|
+
onDragging,
|
|
2486
|
+
onPointerUp
|
|
2487
|
+
} = callbacksRef.current;
|
|
2488
|
+
onDragging === null || onDragging === void 0 ? void 0 : onDragging(false);
|
|
2489
|
+
onPointerUp === null || onPointerUp === void 0 ? void 0 : onPointerUp();
|
|
2490
|
+
if (!didMove) {
|
|
2491
|
+
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
2492
|
+
}
|
|
2493
|
+
break;
|
|
2494
|
+
}
|
|
2470
2495
|
}
|
|
2471
2496
|
};
|
|
2472
2497
|
return registerResizeHandle(resizeHandleId, element, direction, {
|
|
@@ -2484,7 +2509,7 @@ function PanelResizeHandle({
|
|
|
2484
2509
|
touchAction: "none",
|
|
2485
2510
|
userSelect: "none"
|
|
2486
2511
|
};
|
|
2487
|
-
return createElement(Type, {
|
|
2512
|
+
return React.createElement(Type, {
|
|
2488
2513
|
...rest,
|
|
2489
2514
|
children,
|
|
2490
2515
|
className: classNameFromProps,
|
|
@@ -2505,13 +2530,13 @@ function PanelResizeHandle({
|
|
|
2505
2530
|
},
|
|
2506
2531
|
tabIndex,
|
|
2507
2532
|
// CSS selectors
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2533
|
+
[DATA_ATTRIBUTES.groupDirection]: direction,
|
|
2534
|
+
[DATA_ATTRIBUTES.groupId]: groupId,
|
|
2535
|
+
[DATA_ATTRIBUTES.resizeHandle]: "",
|
|
2536
|
+
[DATA_ATTRIBUTES.resizeHandleActive]: state === "drag" ? "pointer" : isFocused ? "keyboard" : undefined,
|
|
2537
|
+
[DATA_ATTRIBUTES.resizeHandleEnabled]: !disabled,
|
|
2538
|
+
[DATA_ATTRIBUTES.resizeHandleId]: resizeHandleId,
|
|
2539
|
+
[DATA_ATTRIBUTES.resizeHandleState]: state
|
|
2515
2540
|
});
|
|
2516
2541
|
}
|
|
2517
2542
|
PanelResizeHandle.displayName = "PanelResizeHandle";
|
|
@@ -2545,6 +2570,7 @@ function getIntersectingRectangle(rectOne, rectTwo, strict) {
|
|
|
2545
2570
|
};
|
|
2546
2571
|
}
|
|
2547
2572
|
|
|
2573
|
+
exports.DATA_ATTRIBUTES = DATA_ATTRIBUTES;
|
|
2548
2574
|
exports.Panel = Panel;
|
|
2549
2575
|
exports.PanelGroup = PanelGroup;
|
|
2550
2576
|
exports.PanelResizeHandle = PanelResizeHandle;
|