react-resizable-panels 0.0.38 → 0.0.40
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/.eslintrc.json +22 -0
- package/CHANGELOG.md +6 -0
- package/README.md +2 -0
- package/dist/react-resizable-panels.d.ts +4 -4
- package/dist/react-resizable-panels.d.ts.map +1 -1
- package/dist/react-resizable-panels.js +104 -75
- package/dist/react-resizable-panels.js.map +1 -1
- package/dist/react-resizable-panels.module.js +104 -75
- package/dist/react-resizable-panels.module.js.map +1 -1
- package/package.json +6 -2
- package/src/Panel.ts +2 -2
- package/src/PanelContexts.ts +1 -1
- package/src/PanelGroup.ts +10 -10
- package/src/PanelResizeHandle.ts +5 -5
- package/src/hooks/useIsomorphicEffect.ts +1 -1
- package/src/hooks/useUniqueId.ts +4 -8
- package/src/hooks/useWindowSplitterBehavior.ts +16 -6
- package/src/types.ts +2 -2
- package/src/utils/assert.ts +10 -0
- package/src/utils/coordinates.ts +2 -2
- package/src/utils/debounce.ts +3 -1
- package/src/utils/group.ts +15 -3
- package/src/vendor/react.ts +61 -0
|
@@ -1,28 +1,36 @@
|
|
|
1
1
|
import * as $jhddX$react from "react";
|
|
2
2
|
|
|
3
|
+
// This module exists to work around Webpack issue https://github.com/webpack/webpack/issues/14814
|
|
4
|
+
// and limitations with ParcelJS parsing of the useId workaround (used below).
|
|
5
|
+
// For the time being, all react-resizable-panels must import "react" with the "* as React" syntax.
|
|
6
|
+
// To avoid mistakes, we use the ESLint "no-restricted-imports" to prevent "react" imports except in this file.
|
|
7
|
+
// See https://github.com/bvaughn/react-resizable-panels/issues/118
|
|
8
|
+
// eslint-disable-next-line no-restricted-imports
|
|
9
|
+
|
|
10
|
+
const { createElement: $ef07efbe5fa7d87e$export$c8a8987d4410bf2d , createContext: $ef07efbe5fa7d87e$export$fd42f52fd3ae1109 , forwardRef: $ef07efbe5fa7d87e$export$257a8862b851cb5b , useCallback: $ef07efbe5fa7d87e$export$35808ee640e87ca7 , useContext: $ef07efbe5fa7d87e$export$fae74005e78b1a27 , useEffect: $ef07efbe5fa7d87e$export$6d9c69b0de29b591 , useImperativeHandle: $ef07efbe5fa7d87e$export$d5a552a76deda3c2 , useLayoutEffect: $ef07efbe5fa7d87e$export$e5c5a5f917a5871c , useMemo: $ef07efbe5fa7d87e$export$1538c33de8887b59 , useRef: $ef07efbe5fa7d87e$export$b8f5890fc79d6aca , useState: $ef07efbe5fa7d87e$export$60241385465d0a34 } = $jhddX$react;
|
|
11
|
+
// `toString()` prevents bundlers from trying to `import { useId } from 'react'`
|
|
12
|
+
const $ef07efbe5fa7d87e$export$f680877a34711e37 = $jhddX$react["useId".toString()];
|
|
13
|
+
|
|
3
14
|
|
|
4
15
|
|
|
5
16
|
const $3f95d3e171760903$var$canUseEffectHooks = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
|
|
6
|
-
const $3f95d3e171760903$var$useIsomorphicLayoutEffect = $3f95d3e171760903$var$canUseEffectHooks ? (0, $
|
|
17
|
+
const $3f95d3e171760903$var$useIsomorphicLayoutEffect = $3f95d3e171760903$var$canUseEffectHooks ? (0, $ef07efbe5fa7d87e$export$e5c5a5f917a5871c) : ()=>{};
|
|
7
18
|
var $3f95d3e171760903$export$2e2bcd8739ae039 = $3f95d3e171760903$var$useIsomorphicLayoutEffect;
|
|
8
19
|
|
|
9
20
|
|
|
10
21
|
|
|
11
|
-
|
|
12
|
-
// Support React versions older than 18.0
|
|
13
|
-
// Workaround for https://github.com/webpack/webpack/issues/14814
|
|
14
|
-
const $e504a2438473eda9$var$useId = $jhddX$react["useId".toString()];
|
|
22
|
+
const $e504a2438473eda9$var$wrappedUseId = typeof (0, $ef07efbe5fa7d87e$export$f680877a34711e37) === "function" ? (0, $ef07efbe5fa7d87e$export$f680877a34711e37) : ()=>null;
|
|
15
23
|
let $e504a2438473eda9$var$counter = 0;
|
|
16
24
|
function $e504a2438473eda9$export$2e2bcd8739ae039(idFromParams = null) {
|
|
17
|
-
const idFromUseId =
|
|
18
|
-
const idRef = (0, $
|
|
25
|
+
const idFromUseId = $e504a2438473eda9$var$wrappedUseId();
|
|
26
|
+
const idRef = (0, $ef07efbe5fa7d87e$export$b8f5890fc79d6aca)(idFromParams || idFromUseId || null);
|
|
19
27
|
if (idRef.current === null) idRef.current = "" + $e504a2438473eda9$var$counter++;
|
|
20
28
|
return idRef.current;
|
|
21
29
|
}
|
|
22
30
|
|
|
23
31
|
|
|
24
32
|
|
|
25
|
-
const $af466b485b9d515d$export$7d8c6d083caec74a = (0, $
|
|
33
|
+
const $af466b485b9d515d$export$7d8c6d083caec74a = (0, $ef07efbe5fa7d87e$export$fd42f52fd3ae1109)(null);
|
|
26
34
|
// Workaround for Parcel scope hoisting (which renames objects/functions).
|
|
27
35
|
// Casting to :any is required to avoid corrupting the generated TypeScript types.
|
|
28
36
|
// See github.com/parcel-bundler/parcel/issues/8724
|
|
@@ -30,16 +38,16 @@ $af466b485b9d515d$export$7d8c6d083caec74a.displayName = "PanelGroupContext";
|
|
|
30
38
|
|
|
31
39
|
|
|
32
40
|
function $c33df6d7c39fd3ee$var$PanelWithForwardedRef({ children: children = null , className: classNameFromProps = "" , collapsible: collapsible = false , defaultSize: defaultSize = null , forwardedRef: forwardedRef , id: idFromProps = null , maxSize: maxSize = 100 , minSize: minSize = 10 , onCollapse: onCollapse = null , onResize: onResize = null , order: order = null , style: styleFromProps = {} , tagName: Type = "div" }) {
|
|
33
|
-
const context = (0, $
|
|
41
|
+
const context = (0, $ef07efbe5fa7d87e$export$fae74005e78b1a27)((0, $af466b485b9d515d$export$7d8c6d083caec74a));
|
|
34
42
|
if (context === null) throw Error(`Panel components must be rendered within a PanelGroup container`);
|
|
35
43
|
const panelId = (0, $e504a2438473eda9$export$2e2bcd8739ae039)(idFromProps);
|
|
36
44
|
const { collapsePanel: collapsePanel , expandPanel: expandPanel , getPanelStyle: getPanelStyle , registerPanel: registerPanel , resizePanel: resizePanel , unregisterPanel: unregisterPanel } = context;
|
|
37
45
|
// Use a ref to guard against users passing inline props
|
|
38
|
-
const callbacksRef = (0, $
|
|
46
|
+
const callbacksRef = (0, $ef07efbe5fa7d87e$export$b8f5890fc79d6aca)({
|
|
39
47
|
onCollapse: onCollapse,
|
|
40
48
|
onResize: onResize
|
|
41
49
|
});
|
|
42
|
-
(0, $
|
|
50
|
+
(0, $ef07efbe5fa7d87e$export$6d9c69b0de29b591)(()=>{
|
|
43
51
|
callbacksRef.current.onCollapse = onCollapse;
|
|
44
52
|
callbacksRef.current.onResize = onResize;
|
|
45
53
|
});
|
|
@@ -78,13 +86,13 @@ function $c33df6d7c39fd3ee$var$PanelWithForwardedRef({ children: children = null
|
|
|
78
86
|
unregisterPanel
|
|
79
87
|
]);
|
|
80
88
|
const style = getPanelStyle(panelId);
|
|
81
|
-
const committedValuesRef = (0, $
|
|
89
|
+
const committedValuesRef = (0, $ef07efbe5fa7d87e$export$b8f5890fc79d6aca)({
|
|
82
90
|
size: $c33df6d7c39fd3ee$var$parseSizeFromStyle(style)
|
|
83
91
|
});
|
|
84
92
|
(0, $3f95d3e171760903$export$2e2bcd8739ae039)(()=>{
|
|
85
93
|
committedValuesRef.current.size = $c33df6d7c39fd3ee$var$parseSizeFromStyle(style);
|
|
86
94
|
});
|
|
87
|
-
(0, $
|
|
95
|
+
(0, $ef07efbe5fa7d87e$export$d5a552a76deda3c2)(forwardedRef, ()=>({
|
|
88
96
|
collapse: ()=>collapsePanel(panelId),
|
|
89
97
|
expand: ()=>expandPanel(panelId),
|
|
90
98
|
getCollapsed () {
|
|
@@ -100,7 +108,7 @@ function $c33df6d7c39fd3ee$var$PanelWithForwardedRef({ children: children = null
|
|
|
100
108
|
panelId,
|
|
101
109
|
resizePanel
|
|
102
110
|
]);
|
|
103
|
-
return (0, $
|
|
111
|
+
return (0, $ef07efbe5fa7d87e$export$c8a8987d4410bf2d)(Type, {
|
|
104
112
|
children: children,
|
|
105
113
|
className: classNameFromProps,
|
|
106
114
|
"data-panel": "",
|
|
@@ -114,7 +122,7 @@ function $c33df6d7c39fd3ee$var$PanelWithForwardedRef({ children: children = null
|
|
|
114
122
|
}
|
|
115
123
|
});
|
|
116
124
|
}
|
|
117
|
-
const $c33df6d7c39fd3ee$export$2ddb90ad54e5f587 = (0, $
|
|
125
|
+
const $c33df6d7c39fd3ee$export$2ddb90ad54e5f587 = (0, $ef07efbe5fa7d87e$export$257a8862b851cb5b)((props, ref)=>(0, $ef07efbe5fa7d87e$export$c8a8987d4410bf2d)($c33df6d7c39fd3ee$var$PanelWithForwardedRef, {
|
|
118
126
|
...props,
|
|
119
127
|
forwardedRef: ref
|
|
120
128
|
}));
|
|
@@ -208,34 +216,34 @@ function $d6f7e4c3aa9e02d7$export$f50bae335f53943c(event, panels, idBefore, idAf
|
|
|
208
216
|
delta = delta < 0 ? baseSize - nextSize : nextSize - baseSize;
|
|
209
217
|
}
|
|
210
218
|
}
|
|
211
|
-
let
|
|
212
|
-
let
|
|
219
|
+
let pivotId = delta < 0 ? idBefore : idAfter;
|
|
220
|
+
let index = panelsArray.findIndex((panel)=>panel.id === pivotId);
|
|
213
221
|
while(true){
|
|
214
|
-
const
|
|
215
|
-
const
|
|
222
|
+
const panel = panelsArray[index];
|
|
223
|
+
const baseSize = baseSizes[index];
|
|
216
224
|
const deltaRemaining = Math.abs(delta) - Math.abs(deltaApplied);
|
|
217
|
-
const
|
|
218
|
-
if (
|
|
219
|
-
if (
|
|
220
|
-
deltaApplied +=
|
|
221
|
-
nextSizes[
|
|
225
|
+
const nextSize = $d6f7e4c3aa9e02d7$var$safeResizePanel(panel, 0 - deltaRemaining, baseSize, event);
|
|
226
|
+
if (baseSize !== nextSize) {
|
|
227
|
+
if (nextSize === 0 && baseSize > 0) panelSizeBeforeCollapse.set(panel.id, baseSize);
|
|
228
|
+
deltaApplied += baseSize - nextSize;
|
|
229
|
+
nextSizes[index] = nextSize;
|
|
222
230
|
if (deltaApplied.toPrecision((0, $a8e83be196252871$export$d6d3992f3becc879)).localeCompare(Math.abs(delta).toPrecision((0, $a8e83be196252871$export$d6d3992f3becc879)), undefined, {
|
|
223
231
|
numeric: true
|
|
224
232
|
}) >= 0) break;
|
|
225
233
|
}
|
|
226
234
|
if (delta < 0) {
|
|
227
|
-
if (--
|
|
235
|
+
if (--index < 0) break;
|
|
228
236
|
} else {
|
|
229
|
-
if (++
|
|
237
|
+
if (++index >= panelsArray.length) break;
|
|
230
238
|
}
|
|
231
239
|
}
|
|
232
240
|
// If we were unable to resize any of the panels panels, return the previous state.
|
|
233
241
|
// This will essentially bailout and ignore the "mousemove" event.
|
|
234
242
|
if (deltaApplied === 0) return baseSizes;
|
|
235
243
|
// Adjust the pivot panel before, but only by the amount that surrounding panels were able to shrink/contract.
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
nextSizes[
|
|
244
|
+
pivotId = delta < 0 ? idAfter : idBefore;
|
|
245
|
+
index = panelsArray.findIndex((panel)=>panel.id === pivotId);
|
|
246
|
+
nextSizes[index] = baseSizes[index] + deltaApplied;
|
|
239
247
|
return nextSizes;
|
|
240
248
|
}
|
|
241
249
|
function $d6f7e4c3aa9e02d7$export$b8e48269e4faa934(panelsArray, prevSizes, nextSizes) {
|
|
@@ -310,7 +318,7 @@ function $d6f7e4c3aa9e02d7$export$68d3a33c21dfbe27(groupId, handleId, panelsArra
|
|
|
310
318
|
var _panelsArray_index, _panelsArray_;
|
|
311
319
|
const handle = $d6f7e4c3aa9e02d7$export$2e27d3a347680388(handleId);
|
|
312
320
|
const handles = $d6f7e4c3aa9e02d7$export$ae14931f0a0256a3(groupId);
|
|
313
|
-
const index = handles.indexOf(handle);
|
|
321
|
+
const index = handle ? handles.indexOf(handle) : -1;
|
|
314
322
|
var _panelsArray_index_id;
|
|
315
323
|
const idBefore = (_panelsArray_index_id = (_panelsArray_index = panelsArray[index]) === null || _panelsArray_index === void 0 ? void 0 : _panelsArray_index.id) !== null && _panelsArray_index_id !== void 0 ? _panelsArray_index_id : null;
|
|
316
324
|
var _panelsArray__id;
|
|
@@ -321,7 +329,14 @@ function $d6f7e4c3aa9e02d7$export$68d3a33c21dfbe27(groupId, handleId, panelsArra
|
|
|
321
329
|
];
|
|
322
330
|
}
|
|
323
331
|
function $d6f7e4c3aa9e02d7$export$a861c0ad45885494(panels) {
|
|
324
|
-
return Array.from(panels.values()).sort((
|
|
332
|
+
return Array.from(panels.values()).sort((panelA, panelB)=>{
|
|
333
|
+
const orderA = panelA.order;
|
|
334
|
+
const orderB = panelB.order;
|
|
335
|
+
if (orderA == null && orderB == null) return 0;
|
|
336
|
+
else if (orderA == null) return -1;
|
|
337
|
+
else if (orderB == null) return 1;
|
|
338
|
+
else return orderA - orderB;
|
|
339
|
+
});
|
|
325
340
|
}
|
|
326
341
|
function $d6f7e4c3aa9e02d7$var$safeResizePanel(panel, delta, prevSize, event) {
|
|
327
342
|
const nextSizeUnsafe = prevSize + delta;
|
|
@@ -422,8 +437,16 @@ function $8f51c2d77bf1da88$export$c4dfce035d43d1e0(event) {
|
|
|
422
437
|
|
|
423
438
|
|
|
424
439
|
|
|
440
|
+
function $5f33910cd46e8ae7$export$a7a9523472993e97(expectedCondition, message = "Assertion failed!") {
|
|
441
|
+
if (!expectedCondition) {
|
|
442
|
+
console.error(message);
|
|
443
|
+
throw Error(message);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
|
|
425
448
|
function $4a90471e7083b52f$export$d9fcbe062527d159({ committedValuesRef: committedValuesRef , groupId: groupId , panels: panels , setSizes: setSizes , sizes: sizes , panelSizeBeforeCollapse: panelSizeBeforeCollapse }) {
|
|
426
|
-
(0, $
|
|
449
|
+
(0, $ef07efbe5fa7d87e$export$6d9c69b0de29b591)(()=>{
|
|
427
450
|
const { direction: direction , panels: panels } = committedValuesRef.current;
|
|
428
451
|
const groupElement = (0, $d6f7e4c3aa9e02d7$export$5e67632cf3550a9c)(groupId);
|
|
429
452
|
const { height: height , width: width } = groupElement.getBoundingClientRect();
|
|
@@ -490,13 +513,16 @@ function $4a90471e7083b52f$export$d9fcbe062527d159({ committedValuesRef: committ
|
|
|
490
513
|
cleanupFunctions.forEach((cleanupFunction)=>cleanupFunction());
|
|
491
514
|
};
|
|
492
515
|
}, [
|
|
516
|
+
committedValuesRef,
|
|
493
517
|
groupId,
|
|
494
518
|
panels,
|
|
519
|
+
panelSizeBeforeCollapse,
|
|
520
|
+
setSizes,
|
|
495
521
|
sizes
|
|
496
522
|
]);
|
|
497
523
|
}
|
|
498
524
|
function $4a90471e7083b52f$export$33b0bea6ac3ffb03({ disabled: disabled , handleId: handleId , resizeHandler: resizeHandler }) {
|
|
499
|
-
(0, $
|
|
525
|
+
(0, $ef07efbe5fa7d87e$export$6d9c69b0de29b591)(()=>{
|
|
500
526
|
if (disabled || resizeHandler == null) return;
|
|
501
527
|
const handleElement = (0, $d6f7e4c3aa9e02d7$export$2e27d3a347680388)(handleId);
|
|
502
528
|
if (handleElement == null) return;
|
|
@@ -517,6 +543,7 @@ function $4a90471e7083b52f$export$33b0bea6ac3ffb03({ disabled: disabled , handle
|
|
|
517
543
|
event.preventDefault();
|
|
518
544
|
const handles = (0, $d6f7e4c3aa9e02d7$export$8d0cd3c32ddc045e)();
|
|
519
545
|
const index = (0, $d6f7e4c3aa9e02d7$export$96a40be80fb6c3c8)(handleId);
|
|
546
|
+
(0, $5f33910cd46e8ae7$export$a7a9523472993e97)(index !== null);
|
|
520
547
|
const nextIndex = event.shiftKey ? index > 0 ? index - 1 : handles.length - 1 : index + 1 < handles.length ? index + 1 : 0;
|
|
521
548
|
const nextHandle = handles[nextIndex];
|
|
522
549
|
nextHandle.focus();
|
|
@@ -576,7 +603,7 @@ function $8d9d88bebf1a8ace$export$d395b5dfd066a659(state) {
|
|
|
576
603
|
function $f7d932e9304c1581$export$2e2bcd8739ae039(callback, durationMs = 10) {
|
|
577
604
|
let timeoutId = null;
|
|
578
605
|
let callable = (...args)=>{
|
|
579
|
-
clearTimeout(timeoutId);
|
|
606
|
+
if (timeoutId !== null) clearTimeout(timeoutId);
|
|
580
607
|
timeoutId = setTimeout(()=>{
|
|
581
608
|
callback(...args);
|
|
582
609
|
}, durationMs);
|
|
@@ -603,28 +630,28 @@ const $3daa5d4c086ea816$var$defaultStorage = {
|
|
|
603
630
|
getItem: typeof localStorage !== "undefined" ? (name)=>localStorage.getItem(name) : $3daa5d4c086ea816$var$throwServerError,
|
|
604
631
|
setItem: typeof localStorage !== "undefined" ? (name, value)=>localStorage.setItem(name, value) : $3daa5d4c086ea816$var$throwServerError
|
|
605
632
|
};
|
|
606
|
-
function $3daa5d4c086ea816$export$1d05749f6f573bb({ autoSaveId: autoSaveId , children: children = null , className: classNameFromProps = "" , direction: direction , disablePointerEventsDuringResize: disablePointerEventsDuringResize = false , id: idFromProps = null , onLayout: onLayout
|
|
633
|
+
function $3daa5d4c086ea816$export$1d05749f6f573bb({ autoSaveId: autoSaveId , children: children = null , className: classNameFromProps = "" , direction: direction , disablePointerEventsDuringResize: disablePointerEventsDuringResize = false , id: idFromProps = null , onLayout: onLayout , storage: storage = $3daa5d4c086ea816$var$defaultStorage , style: styleFromProps = {} , tagName: Type = "div" }) {
|
|
607
634
|
const groupId = (0, $e504a2438473eda9$export$2e2bcd8739ae039)(idFromProps);
|
|
608
|
-
const [activeHandleId, setActiveHandleId] = (0, $
|
|
609
|
-
const [panels, setPanels] = (0, $
|
|
635
|
+
const [activeHandleId, setActiveHandleId] = (0, $ef07efbe5fa7d87e$export$60241385465d0a34)(null);
|
|
636
|
+
const [panels, setPanels] = (0, $ef07efbe5fa7d87e$export$60241385465d0a34)(new Map());
|
|
610
637
|
// When resizing is done via mouse/touch event–
|
|
611
638
|
// We store the initial Panel sizes in this ref, and apply move deltas to them instead of to the current sizes.
|
|
612
639
|
// This has the benefit of causing force-collapsed panels to spring back open if drag is reversed.
|
|
613
|
-
const initialDragStateRef = (0, $
|
|
640
|
+
const initialDragStateRef = (0, $ef07efbe5fa7d87e$export$b8f5890fc79d6aca)(null);
|
|
614
641
|
// Use a ref to guard against users passing inline props
|
|
615
|
-
const callbacksRef = (0, $
|
|
642
|
+
const callbacksRef = (0, $ef07efbe5fa7d87e$export$b8f5890fc79d6aca)({
|
|
616
643
|
onLayout: onLayout
|
|
617
644
|
});
|
|
618
|
-
(0, $
|
|
645
|
+
(0, $ef07efbe5fa7d87e$export$6d9c69b0de29b591)(()=>{
|
|
619
646
|
callbacksRef.current.onLayout = onLayout;
|
|
620
647
|
});
|
|
621
648
|
// 0-1 values representing the relative size of each panel.
|
|
622
|
-
const [sizes, setSizes] = (0, $
|
|
649
|
+
const [sizes, setSizes] = (0, $ef07efbe5fa7d87e$export$60241385465d0a34)([]);
|
|
623
650
|
// Used to support imperative collapse/expand API.
|
|
624
|
-
const panelSizeBeforeCollapse = (0, $
|
|
625
|
-
const prevDeltaRef = (0, $
|
|
651
|
+
const panelSizeBeforeCollapse = (0, $ef07efbe5fa7d87e$export$b8f5890fc79d6aca)(new Map());
|
|
652
|
+
const prevDeltaRef = (0, $ef07efbe5fa7d87e$export$b8f5890fc79d6aca)(0);
|
|
626
653
|
// Store committed values to avoid unnecessarily re-running memoization/effects functions.
|
|
627
|
-
const committedValuesRef = (0, $
|
|
654
|
+
const committedValuesRef = (0, $ef07efbe5fa7d87e$export$b8f5890fc79d6aca)({
|
|
628
655
|
direction: direction,
|
|
629
656
|
panels: panels,
|
|
630
657
|
sizes: sizes
|
|
@@ -643,7 +670,7 @@ function $3daa5d4c086ea816$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
643
670
|
panelSizeBeforeCollapse: panelSizeBeforeCollapse
|
|
644
671
|
});
|
|
645
672
|
// Notify external code when sizes have changed.
|
|
646
|
-
(0, $
|
|
673
|
+
(0, $ef07efbe5fa7d87e$export$6d9c69b0de29b591)(()=>{
|
|
647
674
|
const { onLayout: onLayout } = callbacksRef.current;
|
|
648
675
|
if (onLayout) {
|
|
649
676
|
const { sizes: sizes } = committedValuesRef.current;
|
|
@@ -655,7 +682,7 @@ function $3daa5d4c086ea816$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
655
682
|
]);
|
|
656
683
|
// Notify Panel listeners about their initial sizes and collapsed state after mount.
|
|
657
684
|
// Subsequent changes will be called by the resizeHandler.
|
|
658
|
-
const didNotifyCallbacksAfterMountRef = (0, $
|
|
685
|
+
const didNotifyCallbacksAfterMountRef = (0, $ef07efbe5fa7d87e$export$b8f5890fc79d6aca)(false);
|
|
659
686
|
(0, $3f95d3e171760903$export$2e2bcd8739ae039)(()=>{
|
|
660
687
|
if (didNotifyCallbacksAfterMountRef.current) return;
|
|
661
688
|
const { panels: panels , sizes: sizes } = committedValuesRef.current;
|
|
@@ -676,14 +703,14 @@ function $3daa5d4c086ea816$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
676
703
|
return;
|
|
677
704
|
// If this panel has been configured to persist sizing information,
|
|
678
705
|
// default size should be restored from local storage if possible.
|
|
679
|
-
let defaultSizes =
|
|
706
|
+
let defaultSizes = null;
|
|
680
707
|
if (autoSaveId) {
|
|
681
708
|
const panelsArray = (0, $d6f7e4c3aa9e02d7$export$a861c0ad45885494)(panels);
|
|
682
709
|
defaultSizes = (0, $6889c3a3ed41cfd1$export$9c80c6617f0386da)(autoSaveId, panelsArray, storage);
|
|
683
710
|
}
|
|
684
711
|
if (defaultSizes != null) setSizes(defaultSizes);
|
|
685
712
|
else {
|
|
686
|
-
const
|
|
713
|
+
const panelsArray = (0, $d6f7e4c3aa9e02d7$export$a861c0ad45885494)(panels);
|
|
687
714
|
let panelsWithNullDefaultSize = 0;
|
|
688
715
|
let totalDefaultSize = 0;
|
|
689
716
|
let totalMinSize = 0;
|
|
@@ -691,23 +718,24 @@ function $3daa5d4c086ea816$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
691
718
|
// Implicit default size calculations below do not account for inferred min/max size values.
|
|
692
719
|
// e.g. if Panel A has a maxSize of 40 then Panels A and B can't both have an implicit default size of 50.
|
|
693
720
|
// For now, these logic edge cases are left to the user to handle via props.
|
|
694
|
-
|
|
721
|
+
panelsArray.forEach((panel)=>{
|
|
695
722
|
totalMinSize += panel.minSize;
|
|
696
723
|
if (panel.defaultSize === null) panelsWithNullDefaultSize++;
|
|
697
724
|
else totalDefaultSize += panel.defaultSize;
|
|
698
725
|
});
|
|
699
726
|
if (totalDefaultSize > 100) throw new Error(`The sum of the defaultSize of all panels in a group cannot exceed 100.`);
|
|
700
727
|
else if (totalMinSize > 100) throw new Error(`The sum of the minSize of all panels in a group cannot exceed 100.`);
|
|
701
|
-
setSizes(
|
|
728
|
+
setSizes(panelsArray.map((panel)=>{
|
|
702
729
|
if (panel.defaultSize === null) return (100 - totalDefaultSize) / panelsWithNullDefaultSize;
|
|
703
730
|
return panel.defaultSize;
|
|
704
731
|
}));
|
|
705
732
|
}
|
|
706
733
|
}, [
|
|
707
734
|
autoSaveId,
|
|
708
|
-
panels
|
|
735
|
+
panels,
|
|
736
|
+
storage
|
|
709
737
|
]);
|
|
710
|
-
(0, $
|
|
738
|
+
(0, $ef07efbe5fa7d87e$export$6d9c69b0de29b591)(()=>{
|
|
711
739
|
// If this panel has been configured to persist sizing information, save sizes to local storage.
|
|
712
740
|
if (autoSaveId) {
|
|
713
741
|
if (sizes.length === 0 || sizes.length !== panels.size) return;
|
|
@@ -717,9 +745,10 @@ function $3daa5d4c086ea816$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
717
745
|
}, [
|
|
718
746
|
autoSaveId,
|
|
719
747
|
panels,
|
|
720
|
-
sizes
|
|
748
|
+
sizes,
|
|
749
|
+
storage
|
|
721
750
|
]);
|
|
722
|
-
const getPanelStyle = (0, $
|
|
751
|
+
const getPanelStyle = (0, $ef07efbe5fa7d87e$export$35808ee640e87ca7)((id)=>{
|
|
723
752
|
const { panels: panels } = committedValuesRef.current;
|
|
724
753
|
// Before mounting, Panels will not yet have registered themselves.
|
|
725
754
|
// This includes server rendering.
|
|
@@ -744,10 +773,10 @@ function $3daa5d4c086ea816$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
744
773
|
};
|
|
745
774
|
}, [
|
|
746
775
|
activeHandleId,
|
|
747
|
-
|
|
776
|
+
disablePointerEventsDuringResize,
|
|
748
777
|
sizes
|
|
749
778
|
]);
|
|
750
|
-
const registerPanel = (0, $
|
|
779
|
+
const registerPanel = (0, $ef07efbe5fa7d87e$export$35808ee640e87ca7)((id, panel)=>{
|
|
751
780
|
setPanels((prevPanels)=>{
|
|
752
781
|
if (prevPanels.has(id)) return prevPanels;
|
|
753
782
|
const nextPanels = new Map(prevPanels);
|
|
@@ -755,7 +784,7 @@ function $3daa5d4c086ea816$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
755
784
|
return nextPanels;
|
|
756
785
|
});
|
|
757
786
|
}, []);
|
|
758
|
-
const registerResizeHandle = (0, $
|
|
787
|
+
const registerResizeHandle = (0, $ef07efbe5fa7d87e$export$35808ee640e87ca7)((handleId)=>{
|
|
759
788
|
const resizeHandler = (event)=>{
|
|
760
789
|
event.preventDefault();
|
|
761
790
|
const { direction: direction , panels: panels , sizes: prevSizes } = committedValuesRef.current;
|
|
@@ -798,7 +827,7 @@ function $3daa5d4c086ea816$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
798
827
|
}, [
|
|
799
828
|
groupId
|
|
800
829
|
]);
|
|
801
|
-
const unregisterPanel = (0, $
|
|
830
|
+
const unregisterPanel = (0, $ef07efbe5fa7d87e$export$35808ee640e87ca7)((id)=>{
|
|
802
831
|
setPanels((prevPanels)=>{
|
|
803
832
|
if (!prevPanels.has(id)) return prevPanels;
|
|
804
833
|
const nextPanels = new Map(prevPanels);
|
|
@@ -806,7 +835,7 @@ function $3daa5d4c086ea816$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
806
835
|
return nextPanels;
|
|
807
836
|
});
|
|
808
837
|
}, []);
|
|
809
|
-
const collapsePanel = (0, $
|
|
838
|
+
const collapsePanel = (0, $ef07efbe5fa7d87e$export$35808ee640e87ca7)((id)=>{
|
|
810
839
|
const { panels: panels , sizes: prevSizes } = committedValuesRef.current;
|
|
811
840
|
const panel = panels.get(id);
|
|
812
841
|
if (panel == null || !panel.collapsible) return;
|
|
@@ -828,7 +857,7 @@ function $3daa5d4c086ea816$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
828
857
|
setSizes(nextSizes);
|
|
829
858
|
}
|
|
830
859
|
}, []);
|
|
831
|
-
const expandPanel = (0, $
|
|
860
|
+
const expandPanel = (0, $ef07efbe5fa7d87e$export$35808ee640e87ca7)((id)=>{
|
|
832
861
|
const { panels: panels , sizes: prevSizes } = committedValuesRef.current;
|
|
833
862
|
const panel = panels.get(id);
|
|
834
863
|
if (panel == null) return;
|
|
@@ -851,7 +880,7 @@ function $3daa5d4c086ea816$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
851
880
|
setSizes(nextSizes);
|
|
852
881
|
}
|
|
853
882
|
}, []);
|
|
854
|
-
const resizePanel = (0, $
|
|
883
|
+
const resizePanel = (0, $ef07efbe5fa7d87e$export$35808ee640e87ca7)((id, nextSize)=>{
|
|
855
884
|
const { panels: panels , sizes: prevSizes } = committedValuesRef.current;
|
|
856
885
|
const panel = panels.get(id);
|
|
857
886
|
if (panel == null) return;
|
|
@@ -873,7 +902,7 @@ function $3daa5d4c086ea816$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
873
902
|
setSizes(nextSizes);
|
|
874
903
|
}
|
|
875
904
|
}, []);
|
|
876
|
-
const context = (0, $
|
|
905
|
+
const context = (0, $ef07efbe5fa7d87e$export$1538c33de8887b59)(()=>({
|
|
877
906
|
activeHandleId: activeHandleId,
|
|
878
907
|
collapsePanel: collapsePanel,
|
|
879
908
|
direction: direction,
|
|
@@ -919,8 +948,8 @@ function $3daa5d4c086ea816$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
919
948
|
overflow: "hidden",
|
|
920
949
|
width: "100%"
|
|
921
950
|
};
|
|
922
|
-
return (0, $
|
|
923
|
-
children: (0, $
|
|
951
|
+
return (0, $ef07efbe5fa7d87e$export$c8a8987d4410bf2d)((0, $af466b485b9d515d$export$7d8c6d083caec74a).Provider, {
|
|
952
|
+
children: (0, $ef07efbe5fa7d87e$export$c8a8987d4410bf2d)(Type, {
|
|
924
953
|
children: children,
|
|
925
954
|
className: classNameFromProps,
|
|
926
955
|
"data-panel-group": "",
|
|
@@ -945,23 +974,23 @@ $3daa5d4c086ea816$export$1d05749f6f573bb.displayName = "PanelGroup";
|
|
|
945
974
|
|
|
946
975
|
|
|
947
976
|
|
|
948
|
-
function $971f2c37f9d2b98e$export$8829ecf6b6b15484({ children: children = null , className: classNameFromProps = "" , disabled: disabled = false , id: idFromProps = null , onDragging: onDragging
|
|
949
|
-
const divElementRef = (0, $
|
|
977
|
+
function $971f2c37f9d2b98e$export$8829ecf6b6b15484({ children: children = null , className: classNameFromProps = "" , disabled: disabled = false , id: idFromProps = null , onDragging: onDragging , style: styleFromProps = {} , tagName: Type = "div" }) {
|
|
978
|
+
const divElementRef = (0, $ef07efbe5fa7d87e$export$b8f5890fc79d6aca)(null);
|
|
950
979
|
// Use a ref to guard against users passing inline props
|
|
951
|
-
const callbacksRef = (0, $
|
|
980
|
+
const callbacksRef = (0, $ef07efbe5fa7d87e$export$b8f5890fc79d6aca)({
|
|
952
981
|
onDragging: onDragging
|
|
953
982
|
});
|
|
954
|
-
(0, $
|
|
983
|
+
(0, $ef07efbe5fa7d87e$export$6d9c69b0de29b591)(()=>{
|
|
955
984
|
callbacksRef.current.onDragging = onDragging;
|
|
956
985
|
});
|
|
957
|
-
const panelGroupContext = (0, $
|
|
986
|
+
const panelGroupContext = (0, $ef07efbe5fa7d87e$export$fae74005e78b1a27)((0, $af466b485b9d515d$export$7d8c6d083caec74a));
|
|
958
987
|
if (panelGroupContext === null) throw Error(`PanelResizeHandle components must be rendered within a PanelGroup container`);
|
|
959
988
|
const { activeHandleId: activeHandleId , direction: direction , groupId: groupId , registerResizeHandle: registerResizeHandle , startDragging: startDragging , stopDragging: stopDragging } = panelGroupContext;
|
|
960
989
|
const resizeHandleId = (0, $e504a2438473eda9$export$2e2bcd8739ae039)(idFromProps);
|
|
961
990
|
const isDragging = activeHandleId === resizeHandleId;
|
|
962
|
-
const [isFocused, setIsFocused] = (0, $
|
|
963
|
-
const [resizeHandler, setResizeHandler] = (0, $
|
|
964
|
-
const stopDraggingAndBlur = (0, $
|
|
991
|
+
const [isFocused, setIsFocused] = (0, $ef07efbe5fa7d87e$export$60241385465d0a34)(false);
|
|
992
|
+
const [resizeHandler, setResizeHandler] = (0, $ef07efbe5fa7d87e$export$60241385465d0a34)(null);
|
|
993
|
+
const stopDraggingAndBlur = (0, $ef07efbe5fa7d87e$export$35808ee640e87ca7)(()=>{
|
|
965
994
|
// Clicking on the drag handle shouldn't leave it focused;
|
|
966
995
|
// That would cause the PanelGroup to think it was still active.
|
|
967
996
|
const div = divElementRef.current;
|
|
@@ -972,7 +1001,7 @@ function $971f2c37f9d2b98e$export$8829ecf6b6b15484({ children: children = null ,
|
|
|
972
1001
|
}, [
|
|
973
1002
|
stopDragging
|
|
974
1003
|
]);
|
|
975
|
-
(0, $
|
|
1004
|
+
(0, $ef07efbe5fa7d87e$export$6d9c69b0de29b591)(()=>{
|
|
976
1005
|
if (disabled) setResizeHandler(null);
|
|
977
1006
|
else {
|
|
978
1007
|
const resizeHandler = registerResizeHandle(resizeHandleId);
|
|
@@ -983,7 +1012,7 @@ function $971f2c37f9d2b98e$export$8829ecf6b6b15484({ children: children = null ,
|
|
|
983
1012
|
resizeHandleId,
|
|
984
1013
|
registerResizeHandle
|
|
985
1014
|
]);
|
|
986
|
-
(0, $
|
|
1015
|
+
(0, $ef07efbe5fa7d87e$export$6d9c69b0de29b591)(()=>{
|
|
987
1016
|
if (disabled || resizeHandler == null || !isDragging) return;
|
|
988
1017
|
const onMove = (event)=>{
|
|
989
1018
|
resizeHandler(event);
|
|
@@ -1024,7 +1053,7 @@ function $971f2c37f9d2b98e$export$8829ecf6b6b15484({ children: children = null ,
|
|
|
1024
1053
|
touchAction: "none",
|
|
1025
1054
|
userSelect: "none"
|
|
1026
1055
|
};
|
|
1027
|
-
return (0, $
|
|
1056
|
+
return (0, $ef07efbe5fa7d87e$export$c8a8987d4410bf2d)(Type, {
|
|
1028
1057
|
children: children,
|
|
1029
1058
|
className: classNameFromProps,
|
|
1030
1059
|
"data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
|