react-resizable-panels 2.1.8 → 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/dist/declarations/src/PanelGroup.d.ts +1 -1
- package/dist/declarations/src/PanelResizeHandle.d.ts +1 -1
- 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 +135 -105
- package/dist/react-resizable-panels.browser.cjs.mjs +1 -0
- package/dist/react-resizable-panels.browser.development.cjs.js +135 -105
- package/dist/react-resizable-panels.browser.development.cjs.mjs +1 -0
- package/dist/react-resizable-panels.browser.development.esm.js +135 -106
- package/dist/react-resizable-panels.browser.esm.js +135 -106
- package/dist/react-resizable-panels.cjs.js +135 -105
- package/dist/react-resizable-panels.cjs.mjs +1 -0
- package/dist/react-resizable-panels.development.cjs.js +135 -105
- package/dist/react-resizable-panels.development.cjs.mjs +1 -0
- package/dist/react-resizable-panels.development.esm.js +135 -106
- package/dist/react-resizable-panels.development.node.cjs.js +135 -105
- package/dist/react-resizable-panels.development.node.cjs.mjs +1 -0
- package/dist/react-resizable-panels.development.node.esm.js +135 -106
- package/dist/react-resizable-panels.esm.js +135 -106
- package/dist/react-resizable-panels.node.cjs.js +135 -105
- package/dist/react-resizable-panels.node.cjs.mjs +1 -0
- package/dist/react-resizable-panels.node.esm.js +135 -106
- package/package.json +12 -12
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Brian Vaughn
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PointerHitAreaMargins } from "./PanelResizeHandleRegistry.js";
|
|
2
1
|
import { CSSProperties, HTMLAttributes, PropsWithChildren, ReactElement } from "react";
|
|
2
|
+
import { PointerHitAreaMargins } from "./PanelResizeHandleRegistry.js";
|
|
3
3
|
export type PanelResizeHandleOnDragging = (isDragging: boolean) => void;
|
|
4
4
|
export type ResizeHandlerState = "drag" | "hover" | "inactive";
|
|
5
5
|
export type PanelResizeHandleProps = Omit<HTMLAttributes<keyof HTMLElementTagNameMap>, "id" | "onBlur" | "onClick" | "onFocus" | "onPointerDown" | "onPointerUp"> & PropsWithChildren<{
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const DATA_ATTRIBUTES: {
|
|
2
|
+
readonly group: "data-panel-group";
|
|
3
|
+
readonly groupDirection: "data-panel-group-direction";
|
|
4
|
+
readonly groupId: "data-panel-group-id";
|
|
5
|
+
readonly panel: "data-panel";
|
|
6
|
+
readonly panelCollapsible: "data-panel-collapsible";
|
|
7
|
+
readonly panelId: "data-panel-id";
|
|
8
|
+
readonly panelSize: "data-panel-size";
|
|
9
|
+
readonly resizeHandle: "data-resize-handle";
|
|
10
|
+
readonly resizeHandleActive: "data-resize-handle-active";
|
|
11
|
+
readonly resizeHandleEnabled: "data-panel-resize-handle-enabled";
|
|
12
|
+
readonly resizeHandleId: "data-panel-resize-handle-id";
|
|
13
|
+
readonly resizeHandleState: "data-resize-handle-state";
|
|
14
|
+
};
|
|
15
|
+
export declare const PRECISION = 10;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Panel } from "./Panel.js";
|
|
2
2
|
import { PanelGroup } from "./PanelGroup.js";
|
|
3
3
|
import { PanelResizeHandle } from "./PanelResizeHandle.js";
|
|
4
|
+
import { DATA_ATTRIBUTES } from "./constants.js";
|
|
4
5
|
import { assert } from "./utils/assert.js";
|
|
5
6
|
import { setNonce } from "./utils/csp.js";
|
|
6
|
-
import {
|
|
7
|
+
import { disableGlobalCursorStyles, enableGlobalCursorStyles } from "./utils/cursor.js";
|
|
7
8
|
import { getPanelElement } from "./utils/dom/getPanelElement.js";
|
|
8
9
|
import { getPanelElementsForGroup } from "./utils/dom/getPanelElementsForGroup.js";
|
|
9
10
|
import { getPanelGroupElement } from "./utils/dom/getPanelGroupElement.js";
|
|
@@ -17,4 +18,4 @@ import type { ImperativePanelHandle, PanelOnCollapse, PanelOnExpand, PanelOnResi
|
|
|
17
18
|
import type { ImperativePanelGroupHandle, PanelGroupOnLayout, PanelGroupProps, PanelGroupStorage } from "./PanelGroup.js";
|
|
18
19
|
import type { PanelResizeHandleOnDragging, PanelResizeHandleProps } from "./PanelResizeHandle.js";
|
|
19
20
|
import type { PointerHitAreaMargins } from "./PanelResizeHandleRegistry.js";
|
|
20
|
-
export { ImperativePanelGroupHandle, ImperativePanelHandle, PanelGroupOnLayout, PanelGroupProps, PanelGroupStorage, PanelOnCollapse, PanelOnExpand, PanelOnResize, PanelProps, PanelResizeHandleOnDragging, PanelResizeHandleProps, PointerHitAreaMargins, Panel, PanelGroup, PanelResizeHandle, assert, getIntersectingRectangle, intersects, getPanelElement, getPanelElementsForGroup, getPanelGroupElement, getResizeHandleElement, getResizeHandleElementIndex, getResizeHandleElementsForGroup, getResizeHandlePanelIds, enableGlobalCursorStyles, disableGlobalCursorStyles, setNonce, };
|
|
21
|
+
export { ImperativePanelGroupHandle, ImperativePanelHandle, PanelGroupOnLayout, PanelGroupProps, PanelGroupStorage, PanelOnCollapse, PanelOnExpand, PanelOnResize, PanelProps, PanelResizeHandleOnDragging, PanelResizeHandleProps, PointerHitAreaMargins, Panel, PanelGroup, PanelResizeHandle, assert, getIntersectingRectangle, intersects, getPanelElement, getPanelElementsForGroup, getPanelGroupElement, getResizeHandleElement, getResizeHandleElementIndex, getResizeHandleElementsForGroup, getResizeHandlePanelIds, enableGlobalCursorStyles, disableGlobalCursorStyles, setNonce, DATA_ATTRIBUTES, };
|
|
@@ -29,6 +29,22 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
|
29
29
|
const PanelGroupContext = React.createContext(null);
|
|
30
30
|
PanelGroupContext.displayName = "PanelGroupContext";
|
|
31
31
|
|
|
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
|
+
|
|
32
48
|
const useIsomorphicLayoutEffect = React.useLayoutEffect ;
|
|
33
49
|
|
|
34
50
|
const useId = React__namespace["useId".toString()];
|
|
@@ -165,11 +181,11 @@ function PanelWithForwardedRef({
|
|
|
165
181
|
...styleFromProps
|
|
166
182
|
},
|
|
167
183
|
// CSS selectors
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
184
|
+
[DATA_ATTRIBUTES.groupId]: groupId,
|
|
185
|
+
[DATA_ATTRIBUTES.panel]: "",
|
|
186
|
+
[DATA_ATTRIBUTES.panelCollapsible]: collapsible || undefined,
|
|
187
|
+
[DATA_ATTRIBUTES.panelId]: panelId,
|
|
188
|
+
[DATA_ATTRIBUTES.panelSize]: parseFloat("" + style.flexGrow).toFixed(1)
|
|
173
189
|
});
|
|
174
190
|
}
|
|
175
191
|
const Panel = React.forwardRef((props, ref) => React.createElement(PanelWithForwardedRef, {
|
|
@@ -189,6 +205,7 @@ function setNonce(value) {
|
|
|
189
205
|
|
|
190
206
|
let currentCursorStyle = null;
|
|
191
207
|
let enabled = true;
|
|
208
|
+
let prevRuleIndex = -1;
|
|
192
209
|
let styleElement = null;
|
|
193
210
|
function disableGlobalCursorStyles() {
|
|
194
211
|
enabled = false;
|
|
@@ -238,9 +255,11 @@ function resetGlobalCursorStyle() {
|
|
|
238
255
|
document.head.removeChild(styleElement);
|
|
239
256
|
currentCursorStyle = null;
|
|
240
257
|
styleElement = null;
|
|
258
|
+
prevRuleIndex = -1;
|
|
241
259
|
}
|
|
242
260
|
}
|
|
243
261
|
function setGlobalCursorStyle(state, constraintFlags) {
|
|
262
|
+
var _styleElement$sheet$i, _styleElement$sheet2;
|
|
244
263
|
if (!enabled) {
|
|
245
264
|
return;
|
|
246
265
|
}
|
|
@@ -257,7 +276,11 @@ function setGlobalCursorStyle(state, constraintFlags) {
|
|
|
257
276
|
}
|
|
258
277
|
document.head.appendChild(styleElement);
|
|
259
278
|
}
|
|
260
|
-
|
|
279
|
+
if (prevRuleIndex >= 0) {
|
|
280
|
+
var _styleElement$sheet;
|
|
281
|
+
(_styleElement$sheet = styleElement.sheet) === null || _styleElement$sheet === void 0 ? void 0 : _styleElement$sheet.removeRule(prevRuleIndex);
|
|
282
|
+
}
|
|
283
|
+
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;
|
|
261
284
|
}
|
|
262
285
|
|
|
263
286
|
function isKeyDown(event) {
|
|
@@ -488,7 +511,9 @@ function handlePointerDown(event) {
|
|
|
488
511
|
if (intersectingHandles.length > 0) {
|
|
489
512
|
updateResizeHandlerStates("down", event);
|
|
490
513
|
event.preventDefault();
|
|
491
|
-
|
|
514
|
+
if (!isWithinResizeHandle(target)) {
|
|
515
|
+
event.stopImmediatePropagation();
|
|
516
|
+
}
|
|
492
517
|
}
|
|
493
518
|
}
|
|
494
519
|
function handlePointerMove(event) {
|
|
@@ -537,6 +562,9 @@ function handlePointerUp(event) {
|
|
|
537
562
|
isPointerDown = false;
|
|
538
563
|
if (intersectingHandles.length > 0) {
|
|
539
564
|
event.preventDefault();
|
|
565
|
+
if (!isWithinResizeHandle(target)) {
|
|
566
|
+
event.stopImmediatePropagation();
|
|
567
|
+
}
|
|
540
568
|
}
|
|
541
569
|
updateResizeHandlerStates("up", event);
|
|
542
570
|
recalculateIntersectingHandles({
|
|
@@ -547,6 +575,16 @@ function handlePointerUp(event) {
|
|
|
547
575
|
updateCursor();
|
|
548
576
|
updateListeners();
|
|
549
577
|
}
|
|
578
|
+
function isWithinResizeHandle(element) {
|
|
579
|
+
let currentElement = element;
|
|
580
|
+
while (currentElement) {
|
|
581
|
+
if (currentElement.hasAttribute(DATA_ATTRIBUTES.resizeHandle)) {
|
|
582
|
+
return true;
|
|
583
|
+
}
|
|
584
|
+
currentElement = currentElement.parentElement;
|
|
585
|
+
}
|
|
586
|
+
return false;
|
|
587
|
+
}
|
|
550
588
|
function recalculateIntersectingHandles({
|
|
551
589
|
target,
|
|
552
590
|
x,
|
|
@@ -638,49 +676,42 @@ function updateCursor() {
|
|
|
638
676
|
resetGlobalCursorStyle();
|
|
639
677
|
}
|
|
640
678
|
}
|
|
679
|
+
let listenersAbortController = new AbortController();
|
|
641
680
|
function updateListeners() {
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
window.removeEventListener("pointerup", handlePointerUp);
|
|
654
|
-
window.removeEventListener("pointercancel", handlePointerUp);
|
|
655
|
-
if (registeredResizeHandlers.size > 0) {
|
|
656
|
-
if (isPointerDown) {
|
|
657
|
-
if (intersectingHandles.length > 0) {
|
|
658
|
-
ownerDocumentCounts.forEach((count, ownerDocument) => {
|
|
659
|
-
const {
|
|
660
|
-
body
|
|
661
|
-
} = ownerDocument;
|
|
662
|
-
if (count > 0) {
|
|
663
|
-
body.addEventListener("contextmenu", handlePointerUp);
|
|
664
|
-
body.addEventListener("pointerleave", handlePointerMove);
|
|
665
|
-
body.addEventListener("pointermove", handlePointerMove);
|
|
666
|
-
}
|
|
667
|
-
});
|
|
668
|
-
}
|
|
669
|
-
window.addEventListener("pointerup", handlePointerUp);
|
|
670
|
-
window.addEventListener("pointercancel", handlePointerUp);
|
|
671
|
-
} else {
|
|
681
|
+
listenersAbortController.abort();
|
|
682
|
+
listenersAbortController = new AbortController();
|
|
683
|
+
const options = {
|
|
684
|
+
capture: true,
|
|
685
|
+
signal: listenersAbortController.signal
|
|
686
|
+
};
|
|
687
|
+
if (!registeredResizeHandlers.size) {
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
if (isPointerDown) {
|
|
691
|
+
if (intersectingHandles.length > 0) {
|
|
672
692
|
ownerDocumentCounts.forEach((count, ownerDocument) => {
|
|
673
693
|
const {
|
|
674
694
|
body
|
|
675
695
|
} = ownerDocument;
|
|
676
696
|
if (count > 0) {
|
|
677
|
-
body.addEventListener("
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
body.addEventListener("pointermove", handlePointerMove);
|
|
697
|
+
body.addEventListener("contextmenu", handlePointerUp, options);
|
|
698
|
+
body.addEventListener("pointerleave", handlePointerMove, options);
|
|
699
|
+
body.addEventListener("pointermove", handlePointerMove, options);
|
|
681
700
|
}
|
|
682
701
|
});
|
|
683
702
|
}
|
|
703
|
+
window.addEventListener("pointerup", handlePointerUp, options);
|
|
704
|
+
window.addEventListener("pointercancel", handlePointerUp, options);
|
|
705
|
+
} else {
|
|
706
|
+
ownerDocumentCounts.forEach((count, ownerDocument) => {
|
|
707
|
+
const {
|
|
708
|
+
body
|
|
709
|
+
} = ownerDocument;
|
|
710
|
+
if (count > 0) {
|
|
711
|
+
body.addEventListener("pointerdown", handlePointerDown, options);
|
|
712
|
+
body.addEventListener("pointermove", handlePointerMove, options);
|
|
713
|
+
}
|
|
714
|
+
});
|
|
684
715
|
}
|
|
685
716
|
}
|
|
686
717
|
function updateResizeHandlerStates(action, event) {
|
|
@@ -705,8 +736,6 @@ function assert(expectedCondition, message) {
|
|
|
705
736
|
}
|
|
706
737
|
}
|
|
707
738
|
|
|
708
|
-
const PRECISION = 10;
|
|
709
|
-
|
|
710
739
|
function fuzzyCompareNumbers(actual, expected, fractionDigits = PRECISION) {
|
|
711
740
|
if (actual.toFixed(fractionDigits) === expected.toFixed(fractionDigits)) {
|
|
712
741
|
return 0;
|
|
@@ -1050,12 +1079,12 @@ function calculateAriaValues({
|
|
|
1050
1079
|
}
|
|
1051
1080
|
|
|
1052
1081
|
function getResizeHandleElementsForGroup(groupId, scope = document) {
|
|
1053
|
-
return Array.from(scope.querySelectorAll(`[
|
|
1082
|
+
return Array.from(scope.querySelectorAll(`[${DATA_ATTRIBUTES.resizeHandleId}][data-panel-group-id="${groupId}"]`));
|
|
1054
1083
|
}
|
|
1055
1084
|
|
|
1056
1085
|
function getResizeHandleElementIndex(groupId, id, scope = document) {
|
|
1057
1086
|
const handles = getResizeHandleElementsForGroup(groupId, scope);
|
|
1058
|
-
const index = handles.findIndex(handle => handle.getAttribute(
|
|
1087
|
+
const index = handles.findIndex(handle => handle.getAttribute(DATA_ATTRIBUTES.resizeHandleId) === id);
|
|
1059
1088
|
return index !== null && index !== void 0 ? index : null;
|
|
1060
1089
|
}
|
|
1061
1090
|
|
|
@@ -1080,7 +1109,7 @@ function getPanelGroupElement(id, rootElement = document) {
|
|
|
1080
1109
|
}
|
|
1081
1110
|
|
|
1082
1111
|
function getResizeHandleElement(id, scope = document) {
|
|
1083
|
-
const element = scope.querySelector(`[
|
|
1112
|
+
const element = scope.querySelector(`[${DATA_ATTRIBUTES.resizeHandleId}="${id}"]`);
|
|
1084
1113
|
if (element) {
|
|
1085
1114
|
return element;
|
|
1086
1115
|
}
|
|
@@ -1159,7 +1188,7 @@ function useWindowSplitterPanelGroupBehavior({
|
|
|
1159
1188
|
const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
1160
1189
|
assert(handles, `No resize handles found for group id "${groupId}"`);
|
|
1161
1190
|
const cleanupFunctions = handles.map(handle => {
|
|
1162
|
-
const handleId = handle.getAttribute(
|
|
1191
|
+
const handleId = handle.getAttribute(DATA_ATTRIBUTES.resizeHandleId);
|
|
1163
1192
|
assert(handleId, `Resize handle element has no handle id attribute`);
|
|
1164
1193
|
const [idBefore, idAfter] = getResizeHandlePanelIds(groupId, handleId, panelDataArray, panelGroupElement);
|
|
1165
1194
|
if (idBefore == null || idAfter == null) {
|
|
@@ -1237,7 +1266,7 @@ function calculateDragOffsetPercentage(event, dragHandleId, direction, initialDr
|
|
|
1237
1266
|
const isHorizontal = direction === "horizontal";
|
|
1238
1267
|
const handleElement = getResizeHandleElement(dragHandleId, panelGroupElement);
|
|
1239
1268
|
assert(handleElement, `No resize handle element found for id "${dragHandleId}"`);
|
|
1240
|
-
const groupId = handleElement.getAttribute(
|
|
1269
|
+
const groupId = handleElement.getAttribute(DATA_ATTRIBUTES.groupId);
|
|
1241
1270
|
assert(groupId, `Resize handle element has no group id attribute`);
|
|
1242
1271
|
let {
|
|
1243
1272
|
initialCursorPosition
|
|
@@ -2153,9 +2182,9 @@ function PanelGroupWithForwardedRef({
|
|
|
2153
2182
|
...styleFromProps
|
|
2154
2183
|
},
|
|
2155
2184
|
// CSS selectors
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2185
|
+
[DATA_ATTRIBUTES.group]: "",
|
|
2186
|
+
[DATA_ATTRIBUTES.groupDirection]: direction,
|
|
2187
|
+
[DATA_ATTRIBUTES.groupId]: groupId
|
|
2159
2188
|
}));
|
|
2160
2189
|
}
|
|
2161
2190
|
const PanelGroup = React.forwardRef((props, ref) => React.createElement(PanelGroupWithForwardedRef, {
|
|
@@ -2214,7 +2243,7 @@ function useWindowSplitterResizeHandlerBehavior({
|
|
|
2214
2243
|
case "F6":
|
|
2215
2244
|
{
|
|
2216
2245
|
event.preventDefault();
|
|
2217
|
-
const groupId = handleElement.getAttribute(
|
|
2246
|
+
const groupId = handleElement.getAttribute(DATA_ATTRIBUTES.groupId);
|
|
2218
2247
|
assert(groupId, `No group element found for id "${groupId}"`);
|
|
2219
2248
|
const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
|
|
2220
2249
|
const index = getResizeHandleElementIndex(groupId, handleId, panelGroupElement);
|
|
@@ -2309,54 +2338,54 @@ function PanelResizeHandle({
|
|
|
2309
2338
|
assert(element, "Element ref not attached");
|
|
2310
2339
|
let didMove = false;
|
|
2311
2340
|
const setResizeHandlerState = (action, isActive, event) => {
|
|
2312
|
-
if (isActive) {
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
onDragging
|
|
2325
|
-
onPointerDown
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
resizeHandler(event);
|
|
2339
|
-
break;
|
|
2340
|
-
}
|
|
2341
|
-
case "up":
|
|
2342
|
-
{
|
|
2341
|
+
if (!isActive) {
|
|
2342
|
+
setState("inactive");
|
|
2343
|
+
return;
|
|
2344
|
+
}
|
|
2345
|
+
switch (action) {
|
|
2346
|
+
case "down":
|
|
2347
|
+
{
|
|
2348
|
+
setState("drag");
|
|
2349
|
+
didMove = false;
|
|
2350
|
+
assert(event, 'Expected event to be defined for "down" action');
|
|
2351
|
+
startDragging(resizeHandleId, event);
|
|
2352
|
+
const {
|
|
2353
|
+
onDragging,
|
|
2354
|
+
onPointerDown
|
|
2355
|
+
} = callbacksRef.current;
|
|
2356
|
+
onDragging === null || onDragging === void 0 ? void 0 : onDragging(true);
|
|
2357
|
+
onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown();
|
|
2358
|
+
break;
|
|
2359
|
+
}
|
|
2360
|
+
case "move":
|
|
2361
|
+
{
|
|
2362
|
+
const {
|
|
2363
|
+
state
|
|
2364
|
+
} = committedValuesRef.current;
|
|
2365
|
+
didMove = true;
|
|
2366
|
+
if (state !== "drag") {
|
|
2343
2367
|
setState("hover");
|
|
2344
|
-
stopDragging();
|
|
2345
|
-
const {
|
|
2346
|
-
onClick,
|
|
2347
|
-
onDragging,
|
|
2348
|
-
onPointerUp
|
|
2349
|
-
} = callbacksRef.current;
|
|
2350
|
-
onDragging === null || onDragging === void 0 ? void 0 : onDragging(false);
|
|
2351
|
-
onPointerUp === null || onPointerUp === void 0 ? void 0 : onPointerUp();
|
|
2352
|
-
if (!didMove) {
|
|
2353
|
-
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
2354
|
-
}
|
|
2355
|
-
break;
|
|
2356
2368
|
}
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2369
|
+
assert(event, 'Expected event to be defined for "move" action');
|
|
2370
|
+
resizeHandler(event);
|
|
2371
|
+
break;
|
|
2372
|
+
}
|
|
2373
|
+
case "up":
|
|
2374
|
+
{
|
|
2375
|
+
setState("hover");
|
|
2376
|
+
stopDragging();
|
|
2377
|
+
const {
|
|
2378
|
+
onClick,
|
|
2379
|
+
onDragging,
|
|
2380
|
+
onPointerUp
|
|
2381
|
+
} = callbacksRef.current;
|
|
2382
|
+
onDragging === null || onDragging === void 0 ? void 0 : onDragging(false);
|
|
2383
|
+
onPointerUp === null || onPointerUp === void 0 ? void 0 : onPointerUp();
|
|
2384
|
+
if (!didMove) {
|
|
2385
|
+
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
2386
|
+
}
|
|
2387
|
+
break;
|
|
2388
|
+
}
|
|
2360
2389
|
}
|
|
2361
2390
|
};
|
|
2362
2391
|
return registerResizeHandle(resizeHandleId, element, direction, {
|
|
@@ -2395,13 +2424,13 @@ function PanelResizeHandle({
|
|
|
2395
2424
|
},
|
|
2396
2425
|
tabIndex,
|
|
2397
2426
|
// CSS selectors
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2427
|
+
[DATA_ATTRIBUTES.groupDirection]: direction,
|
|
2428
|
+
[DATA_ATTRIBUTES.groupId]: groupId,
|
|
2429
|
+
[DATA_ATTRIBUTES.resizeHandle]: "",
|
|
2430
|
+
[DATA_ATTRIBUTES.resizeHandleActive]: state === "drag" ? "pointer" : isFocused ? "keyboard" : undefined,
|
|
2431
|
+
[DATA_ATTRIBUTES.resizeHandleEnabled]: !disabled,
|
|
2432
|
+
[DATA_ATTRIBUTES.resizeHandleId]: resizeHandleId,
|
|
2433
|
+
[DATA_ATTRIBUTES.resizeHandleState]: state
|
|
2405
2434
|
});
|
|
2406
2435
|
}
|
|
2407
2436
|
PanelResizeHandle.displayName = "PanelResizeHandle";
|
|
@@ -2435,6 +2464,7 @@ function getIntersectingRectangle(rectOne, rectTwo, strict) {
|
|
|
2435
2464
|
};
|
|
2436
2465
|
}
|
|
2437
2466
|
|
|
2467
|
+
exports.DATA_ATTRIBUTES = DATA_ATTRIBUTES;
|
|
2438
2468
|
exports.Panel = Panel;
|
|
2439
2469
|
exports.PanelGroup = PanelGroup;
|
|
2440
2470
|
exports.PanelResizeHandle = PanelResizeHandle;
|