react-resizable-panels 0.0.33 → 0.0.35
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/CHANGELOG.md +8 -0
- package/README.md +8 -1
- package/dist/react-resizable-panels.d.ts +6 -1
- package/dist/react-resizable-panels.d.ts.map +1 -1
- package/dist/react-resizable-panels.js +264 -208
- package/dist/react-resizable-panels.js.map +1 -1
- package/dist/react-resizable-panels.module.js +262 -206
- package/dist/react-resizable-panels.module.js.map +1 -1
- package/package.json +5 -2
- package/src/PanelGroup.ts +112 -29
- package/src/hooks/useWindowSplitterBehavior.ts +2 -1
- package/src/index.ts +2 -0
- package/src/types.ts +5 -0
- package/src/utils/arrays.ts +13 -0
- package/src/utils/coordinates.ts +27 -8
- package/src/utils/group.ts +40 -23
- package/src/utils/serialization.ts +12 -12
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
var $
|
|
1
|
+
var $2IMI0$react = require("react");
|
|
2
2
|
|
|
3
3
|
function $parcel$export(e, n, v, s) {
|
|
4
4
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
$parcel$export(module.exports, "Panel", () => $
|
|
8
|
-
$parcel$export(module.exports, "PanelGroup", () => $
|
|
9
|
-
$parcel$export(module.exports, "PanelResizeHandle", () => $
|
|
7
|
+
$parcel$export(module.exports, "Panel", () => $45da0e827c614f1d$export$2ddb90ad54e5f587);
|
|
8
|
+
$parcel$export(module.exports, "PanelGroup", () => $cec4cafe75f3db78$export$1d05749f6f573bb);
|
|
9
|
+
$parcel$export(module.exports, "PanelResizeHandle", () => $3a26a712c9163348$export$8829ecf6b6b15484);
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
const $
|
|
13
|
-
const $
|
|
14
|
-
var $
|
|
12
|
+
const $129b5b9a317dcc10$var$canUseEffectHooks = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
|
|
13
|
+
const $129b5b9a317dcc10$var$useIsomorphicLayoutEffect = $129b5b9a317dcc10$var$canUseEffectHooks ? (0, $2IMI0$react.useLayoutEffect) : ()=>{};
|
|
14
|
+
var $129b5b9a317dcc10$export$2e2bcd8739ae039 = $129b5b9a317dcc10$var$useIsomorphicLayoutEffect;
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
let $
|
|
19
|
-
function $
|
|
20
|
-
const idFromUseId = typeof (0, $
|
|
21
|
-
const idRef = (0, $
|
|
22
|
-
if (idRef.current === null) idRef.current = "" + $
|
|
18
|
+
let $b1693d8d8f570e9c$var$counter = 0;
|
|
19
|
+
function $b1693d8d8f570e9c$export$2e2bcd8739ae039(idFromParams = null) {
|
|
20
|
+
const idFromUseId = typeof (0, $2IMI0$react.useId) === "function" ? (0, $2IMI0$react.useId)() : null;
|
|
21
|
+
const idRef = (0, $2IMI0$react.useRef)(idFromParams || idFromUseId || null);
|
|
22
|
+
if (idRef.current === null) idRef.current = "" + $b1693d8d8f570e9c$var$counter++;
|
|
23
23
|
return idRef.current;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
const $
|
|
28
|
+
const $b9cf028330e7f243$export$7d8c6d083caec74a = (0, $2IMI0$react.createContext)(null);
|
|
29
29
|
// Workaround for Parcel scope hoisting (which renames objects/functions).
|
|
30
30
|
// Casting to :any is required to avoid corrupting the generated TypeScript types.
|
|
31
31
|
// See github.com/parcel-bundler/parcel/issues/8724
|
|
32
|
-
$
|
|
32
|
+
$b9cf028330e7f243$export$7d8c6d083caec74a.displayName = "PanelGroupContext";
|
|
33
33
|
|
|
34
34
|
|
|
35
|
-
function $
|
|
36
|
-
const context = (0, $
|
|
35
|
+
function $45da0e827c614f1d$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" }) {
|
|
36
|
+
const context = (0, $2IMI0$react.useContext)((0, $b9cf028330e7f243$export$7d8c6d083caec74a));
|
|
37
37
|
if (context === null) throw Error(`Panel components must be rendered within a PanelGroup container`);
|
|
38
|
-
const panelId = (0, $
|
|
38
|
+
const panelId = (0, $b1693d8d8f570e9c$export$2e2bcd8739ae039)(idFromProps);
|
|
39
39
|
const { collapsePanel: collapsePanel , expandPanel: expandPanel , getPanelStyle: getPanelStyle , registerPanel: registerPanel , resizePanel: resizePanel , unregisterPanel: unregisterPanel } = context;
|
|
40
40
|
// Use a ref to guard against users passing inline props
|
|
41
|
-
const callbacksRef = (0, $
|
|
41
|
+
const callbacksRef = (0, $2IMI0$react.useRef)({
|
|
42
42
|
onCollapse: onCollapse,
|
|
43
43
|
onResize: onResize
|
|
44
44
|
});
|
|
45
|
-
(0, $
|
|
45
|
+
(0, $2IMI0$react.useEffect)(()=>{
|
|
46
46
|
callbacksRef.current.onCollapse = onCollapse;
|
|
47
47
|
callbacksRef.current.onResize = onResize;
|
|
48
48
|
});
|
|
@@ -56,7 +56,7 @@ function $4b51bd7b90b9da8b$var$PanelWithForwardedRef({ children: children = null
|
|
|
56
56
|
defaultSize = minSize;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
(0, $
|
|
59
|
+
(0, $129b5b9a317dcc10$export$2e2bcd8739ae039)(()=>{
|
|
60
60
|
const panel = {
|
|
61
61
|
callbacksRef: callbacksRef,
|
|
62
62
|
collapsible: collapsible,
|
|
@@ -81,13 +81,13 @@ function $4b51bd7b90b9da8b$var$PanelWithForwardedRef({ children: children = null
|
|
|
81
81
|
unregisterPanel
|
|
82
82
|
]);
|
|
83
83
|
const style = getPanelStyle(panelId);
|
|
84
|
-
const committedValuesRef = (0, $
|
|
85
|
-
size: $
|
|
84
|
+
const committedValuesRef = (0, $2IMI0$react.useRef)({
|
|
85
|
+
size: $45da0e827c614f1d$var$parseSizeFromStyle(style)
|
|
86
86
|
});
|
|
87
|
-
(0, $
|
|
88
|
-
committedValuesRef.current.size = $
|
|
87
|
+
(0, $129b5b9a317dcc10$export$2e2bcd8739ae039)(()=>{
|
|
88
|
+
committedValuesRef.current.size = $45da0e827c614f1d$var$parseSizeFromStyle(style);
|
|
89
89
|
});
|
|
90
|
-
(0, $
|
|
90
|
+
(0, $2IMI0$react.useImperativeHandle)(forwardedRef, ()=>({
|
|
91
91
|
collapse: ()=>collapsePanel(panelId),
|
|
92
92
|
expand: ()=>expandPanel(panelId),
|
|
93
93
|
getCollapsed () {
|
|
@@ -103,7 +103,7 @@ function $4b51bd7b90b9da8b$var$PanelWithForwardedRef({ children: children = null
|
|
|
103
103
|
panelId,
|
|
104
104
|
resizePanel
|
|
105
105
|
]);
|
|
106
|
-
return (0, $
|
|
106
|
+
return (0, $2IMI0$react.createElement)(Type, {
|
|
107
107
|
children: children,
|
|
108
108
|
className: classNameFromProps,
|
|
109
109
|
"data-panel": "",
|
|
@@ -117,17 +117,17 @@ function $4b51bd7b90b9da8b$var$PanelWithForwardedRef({ children: children = null
|
|
|
117
117
|
}
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
|
-
const $
|
|
120
|
+
const $45da0e827c614f1d$export$2ddb90ad54e5f587 = (0, $2IMI0$react.forwardRef)((props, ref)=>(0, $2IMI0$react.createElement)($45da0e827c614f1d$var$PanelWithForwardedRef, {
|
|
121
121
|
...props,
|
|
122
122
|
forwardedRef: ref
|
|
123
123
|
}));
|
|
124
124
|
// Workaround for Parcel scope hoisting (which renames objects/functions).
|
|
125
125
|
// Casting to :any is required to avoid corrupting the generated TypeScript types.
|
|
126
126
|
// See github.com/parcel-bundler/parcel/issues/8724
|
|
127
|
-
$
|
|
128
|
-
$
|
|
127
|
+
$45da0e827c614f1d$var$PanelWithForwardedRef.displayName = "Panel";
|
|
128
|
+
$45da0e827c614f1d$export$2ddb90ad54e5f587.displayName = "forwardRef(Panel)";
|
|
129
129
|
// HACK
|
|
130
|
-
function $
|
|
130
|
+
function $45da0e827c614f1d$var$parseSizeFromStyle(style) {
|
|
131
131
|
const { flexGrow: flexGrow } = style;
|
|
132
132
|
if (typeof flexGrow === "string") return parseFloat(flexGrow);
|
|
133
133
|
else return flexGrow;
|
|
@@ -140,15 +140,15 @@ function $4b51bd7b90b9da8b$var$parseSizeFromStyle(style) {
|
|
|
140
140
|
// so they should not be used as part of the serialization key.
|
|
141
141
|
// Using an attribute like minSize instead should work well enough.
|
|
142
142
|
// Pre-sorting by minSize allows remembering layouts even if panels are re-ordered/dragged.
|
|
143
|
-
function $
|
|
143
|
+
function $f9cb001fbb908626$var$getSerializationKey(panels) {
|
|
144
144
|
return panels.map((panel)=>{
|
|
145
145
|
const { minSize: minSize , order: order } = panel;
|
|
146
146
|
return order ? `${order}:${minSize}` : `${minSize}`;
|
|
147
147
|
}).sort((a, b)=>a.localeCompare(b)).join(",");
|
|
148
148
|
}
|
|
149
|
-
function $
|
|
149
|
+
function $f9cb001fbb908626$var$loadSerializedPanelGroupState(autoSaveId, storage) {
|
|
150
150
|
try {
|
|
151
|
-
const serialized =
|
|
151
|
+
const serialized = storage.getItem(`PanelGroup:sizes:${autoSaveId}`);
|
|
152
152
|
if (serialized) {
|
|
153
153
|
const parsed = JSON.parse(serialized);
|
|
154
154
|
if (typeof parsed === "object" && parsed != null) return parsed;
|
|
@@ -156,34 +156,39 @@ function $e045b0dd313f33c7$var$loadSerializedPanelGroupState(autoSaveId) {
|
|
|
156
156
|
} catch (error) {}
|
|
157
157
|
return null;
|
|
158
158
|
}
|
|
159
|
-
function $
|
|
160
|
-
const state = $
|
|
159
|
+
function $f9cb001fbb908626$export$9c80c6617f0386da(autoSaveId, panels, storage) {
|
|
160
|
+
const state = $f9cb001fbb908626$var$loadSerializedPanelGroupState(autoSaveId, storage);
|
|
161
161
|
if (state) {
|
|
162
|
-
const key = $
|
|
163
|
-
|
|
162
|
+
const key = $f9cb001fbb908626$var$getSerializationKey(panels);
|
|
163
|
+
var _state_key;
|
|
164
|
+
return (_state_key = state[key]) !== null && _state_key !== void 0 ? _state_key : null;
|
|
164
165
|
}
|
|
165
166
|
return null;
|
|
166
167
|
}
|
|
167
|
-
function $
|
|
168
|
-
const key = $
|
|
169
|
-
const state = $
|
|
168
|
+
function $f9cb001fbb908626$export$af183b313c61be4f(autoSaveId, panels, sizes, storage) {
|
|
169
|
+
const key = $f9cb001fbb908626$var$getSerializationKey(panels);
|
|
170
|
+
const state = $f9cb001fbb908626$var$loadSerializedPanelGroupState(autoSaveId, storage) || {};
|
|
170
171
|
state[key] = sizes;
|
|
171
172
|
try {
|
|
172
|
-
|
|
173
|
+
storage.setItem(`PanelGroup:sizes:${autoSaveId}`, JSON.stringify(state));
|
|
173
174
|
} catch (error) {
|
|
174
175
|
console.error(error);
|
|
175
176
|
}
|
|
176
177
|
}
|
|
177
178
|
|
|
178
179
|
|
|
179
|
-
const $
|
|
180
|
+
const $9abd79656a89cd3a$export$d6d3992f3becc879 = 10;
|
|
180
181
|
|
|
181
182
|
|
|
182
183
|
|
|
183
|
-
function $
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
184
|
+
function $cda3cc4b1114cf23$export$f50bae335f53943c(event, panels, idBefore, idAfter, delta, prevSizes, panelSizeBeforeCollapse, initialDragState) {
|
|
185
|
+
const { sizes: initialSizes } = initialDragState || {};
|
|
186
|
+
// If we're resizing by mouse or touch, use the initial sizes as a base.
|
|
187
|
+
// This has the benefit of causing force-collapsed panels to spring back open if drag is reversed.
|
|
188
|
+
const baseSizes = initialSizes || prevSizes;
|
|
189
|
+
if (delta === 0) return baseSizes;
|
|
190
|
+
const panelsArray = $cda3cc4b1114cf23$export$a861c0ad45885494(panels);
|
|
191
|
+
const nextSizes = baseSizes.concat();
|
|
187
192
|
let deltaApplied = 0;
|
|
188
193
|
// A resizing panel affects the panels before or after it.
|
|
189
194
|
//
|
|
@@ -197,25 +202,29 @@ function $d520236daad9c5d5$export$f50bae335f53943c(event, panels, idBefore, idAf
|
|
|
197
202
|
const pivotId = delta < 0 ? idAfter : idBefore;
|
|
198
203
|
const index = panelsArray.findIndex((panel)=>panel.id === pivotId);
|
|
199
204
|
const panel = panelsArray[index];
|
|
200
|
-
const
|
|
201
|
-
const nextSize = $
|
|
202
|
-
if (
|
|
205
|
+
const baseSize = baseSizes[index];
|
|
206
|
+
const nextSize = $cda3cc4b1114cf23$var$safeResizePanel(panel, Math.abs(delta), baseSize, event);
|
|
207
|
+
if (baseSize === nextSize) // If there's no room for the pivot panel to grow, we can ignore this drag update.
|
|
208
|
+
return baseSizes;
|
|
203
209
|
else {
|
|
204
|
-
if (nextSize === 0 &&
|
|
205
|
-
delta = delta < 0 ?
|
|
210
|
+
if (nextSize === 0 && baseSize > 0) panelSizeBeforeCollapse.set(pivotId, baseSize);
|
|
211
|
+
delta = delta < 0 ? baseSize - nextSize : nextSize - baseSize;
|
|
206
212
|
}
|
|
207
213
|
}
|
|
208
214
|
let pivotId1 = delta < 0 ? idBefore : idAfter;
|
|
209
215
|
let index1 = panelsArray.findIndex((panel)=>panel.id === pivotId1);
|
|
210
216
|
while(true){
|
|
211
217
|
const panel1 = panelsArray[index1];
|
|
212
|
-
const
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
218
|
+
const baseSize1 = baseSizes[index1];
|
|
219
|
+
const deltaRemaining = Math.abs(delta) - Math.abs(deltaApplied);
|
|
220
|
+
const nextSize1 = $cda3cc4b1114cf23$var$safeResizePanel(panel1, 0 - deltaRemaining, baseSize1, event);
|
|
221
|
+
if (baseSize1 !== nextSize1) {
|
|
222
|
+
if (nextSize1 === 0 && baseSize1 > 0) panelSizeBeforeCollapse.set(panel1.id, baseSize1);
|
|
223
|
+
deltaApplied += baseSize1 - nextSize1;
|
|
217
224
|
nextSizes[index1] = nextSize1;
|
|
218
|
-
if (deltaApplied.toPrecision((0, $
|
|
225
|
+
if (deltaApplied.toPrecision((0, $9abd79656a89cd3a$export$d6d3992f3becc879)).localeCompare(Math.abs(delta).toPrecision((0, $9abd79656a89cd3a$export$d6d3992f3becc879)), undefined, {
|
|
226
|
+
numeric: true
|
|
227
|
+
}) >= 0) break;
|
|
219
228
|
}
|
|
220
229
|
if (delta < 0) {
|
|
221
230
|
if (--index1 < 0) break;
|
|
@@ -225,14 +234,14 @@ function $d520236daad9c5d5$export$f50bae335f53943c(event, panels, idBefore, idAf
|
|
|
225
234
|
}
|
|
226
235
|
// If we were unable to resize any of the panels panels, return the previous state.
|
|
227
236
|
// This will essentially bailout and ignore the "mousemove" event.
|
|
228
|
-
if (deltaApplied === 0) return
|
|
237
|
+
if (deltaApplied === 0) return baseSizes;
|
|
229
238
|
// Adjust the pivot panel before, but only by the amount that surrounding panels were able to shrink/contract.
|
|
230
239
|
pivotId1 = delta < 0 ? idAfter : idBefore;
|
|
231
240
|
index1 = panelsArray.findIndex((panel)=>panel.id === pivotId1);
|
|
232
|
-
nextSizes[index1] =
|
|
241
|
+
nextSizes[index1] = baseSizes[index1] + deltaApplied;
|
|
233
242
|
return nextSizes;
|
|
234
243
|
}
|
|
235
|
-
function $
|
|
244
|
+
function $cda3cc4b1114cf23$export$b8e48269e4faa934(panelsArray, prevSizes, nextSizes) {
|
|
236
245
|
nextSizes.forEach((nextSize, index)=>{
|
|
237
246
|
const prevSize = prevSizes[index];
|
|
238
247
|
if (prevSize !== nextSize) {
|
|
@@ -248,7 +257,7 @@ function $d520236daad9c5d5$export$b8e48269e4faa934(panelsArray, prevSizes, nextS
|
|
|
248
257
|
}
|
|
249
258
|
});
|
|
250
259
|
}
|
|
251
|
-
function $
|
|
260
|
+
function $cda3cc4b1114cf23$export$5a5b0c1d38c23c3b(id, panelsArray) {
|
|
252
261
|
if (panelsArray.length < 2) return [
|
|
253
262
|
null,
|
|
254
263
|
null
|
|
@@ -266,61 +275,65 @@ function $d520236daad9c5d5$export$5a5b0c1d38c23c3b(id, panelsArray) {
|
|
|
266
275
|
idAfter
|
|
267
276
|
];
|
|
268
277
|
}
|
|
269
|
-
function $
|
|
278
|
+
function $cda3cc4b1114cf23$export$6f43503e166de6fb(panels, id, sizes) {
|
|
270
279
|
if (panels.size === 1) return "100";
|
|
271
|
-
const panelsArray = $
|
|
280
|
+
const panelsArray = $cda3cc4b1114cf23$export$a861c0ad45885494(panels);
|
|
272
281
|
const index = panelsArray.findIndex((panel)=>panel.id === id);
|
|
273
282
|
const size = sizes[index];
|
|
274
283
|
if (size == null) return "0";
|
|
275
|
-
return size.toPrecision((0, $
|
|
284
|
+
return size.toPrecision((0, $9abd79656a89cd3a$export$d6d3992f3becc879));
|
|
276
285
|
}
|
|
277
|
-
function $
|
|
286
|
+
function $cda3cc4b1114cf23$export$7361ed18ff57179e(id) {
|
|
278
287
|
const element = document.querySelector(`[data-panel-id="${id}"]`);
|
|
279
288
|
if (element) return element;
|
|
280
289
|
return null;
|
|
281
290
|
}
|
|
282
|
-
function $
|
|
291
|
+
function $cda3cc4b1114cf23$export$5e67632cf3550a9c(id) {
|
|
283
292
|
const element = document.querySelector(`[data-panel-group-id="${id}"]`);
|
|
284
293
|
if (element) return element;
|
|
285
294
|
return null;
|
|
286
295
|
}
|
|
287
|
-
function $
|
|
296
|
+
function $cda3cc4b1114cf23$export$2e27d3a347680388(id) {
|
|
288
297
|
const element = document.querySelector(`[data-panel-resize-handle-id="${id}"]`);
|
|
289
298
|
if (element) return element;
|
|
290
299
|
return null;
|
|
291
300
|
}
|
|
292
|
-
function $
|
|
293
|
-
const handles = $
|
|
301
|
+
function $cda3cc4b1114cf23$export$96a40be80fb6c3c8(id) {
|
|
302
|
+
const handles = $cda3cc4b1114cf23$export$8d0cd3c32ddc045e();
|
|
294
303
|
const index = handles.findIndex((handle)=>handle.getAttribute("data-panel-resize-handle-id") === id);
|
|
295
|
-
return index
|
|
304
|
+
return index !== null && index !== void 0 ? index : null;
|
|
296
305
|
}
|
|
297
|
-
function $
|
|
306
|
+
function $cda3cc4b1114cf23$export$8d0cd3c32ddc045e() {
|
|
298
307
|
return Array.from(document.querySelectorAll(`[data-panel-resize-handle-id]`));
|
|
299
308
|
}
|
|
300
|
-
function $
|
|
309
|
+
function $cda3cc4b1114cf23$export$ae14931f0a0256a3(groupId) {
|
|
301
310
|
return Array.from(document.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${groupId}"]`));
|
|
302
311
|
}
|
|
303
|
-
function $
|
|
304
|
-
|
|
305
|
-
const
|
|
312
|
+
function $cda3cc4b1114cf23$export$68d3a33c21dfbe27(groupId, handleId, panelsArray) {
|
|
313
|
+
var _panelsArray_index, _panelsArray_;
|
|
314
|
+
const handle = $cda3cc4b1114cf23$export$2e27d3a347680388(handleId);
|
|
315
|
+
const handles = $cda3cc4b1114cf23$export$ae14931f0a0256a3(groupId);
|
|
306
316
|
const index = handles.indexOf(handle);
|
|
307
|
-
|
|
308
|
-
const
|
|
317
|
+
var _panelsArray_index_id;
|
|
318
|
+
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;
|
|
319
|
+
var _panelsArray__id;
|
|
320
|
+
const idAfter = (_panelsArray__id = (_panelsArray_ = panelsArray[index + 1]) === null || _panelsArray_ === void 0 ? void 0 : _panelsArray_.id) !== null && _panelsArray__id !== void 0 ? _panelsArray__id : null;
|
|
309
321
|
return [
|
|
310
322
|
idBefore,
|
|
311
323
|
idAfter
|
|
312
324
|
];
|
|
313
325
|
}
|
|
314
|
-
function $
|
|
326
|
+
function $cda3cc4b1114cf23$export$a861c0ad45885494(panels) {
|
|
315
327
|
return Array.from(panels.values()).sort((a, b)=>a.order - b.order);
|
|
316
328
|
}
|
|
317
|
-
function $
|
|
329
|
+
function $cda3cc4b1114cf23$var$safeResizePanel(panel, delta, prevSize, event) {
|
|
318
330
|
const nextSizeUnsafe = prevSize + delta;
|
|
319
331
|
if (panel.collapsible) {
|
|
320
332
|
if (prevSize > 0) {
|
|
321
333
|
if (nextSizeUnsafe <= 0) return 0;
|
|
322
334
|
} else {
|
|
323
|
-
|
|
335
|
+
var _event_type;
|
|
336
|
+
const isKeyboardEvent = event === null || event === void 0 ? void 0 : (_event_type = event.type) === null || _event_type === void 0 ? void 0 : _event_type.startsWith("key");
|
|
324
337
|
if (!isKeyboardEvent) {
|
|
325
338
|
// Keyboard events should expand a collapsed panel to the min size,
|
|
326
339
|
// but mouse events should wait until the panel has reached its min size
|
|
@@ -334,23 +347,27 @@ function $d520236daad9c5d5$var$safeResizePanel(panel, delta, prevSize, event) {
|
|
|
334
347
|
}
|
|
335
348
|
|
|
336
349
|
|
|
337
|
-
function $
|
|
350
|
+
function $47eee9224cfec8e8$export$ec391ce65b083ed4(event, handleId, direction, initialOffset = 0, initialHandleElementRect = null) {
|
|
338
351
|
const isHorizontal = direction === "horizontal";
|
|
339
352
|
let pointerOffset = 0;
|
|
340
|
-
if ($
|
|
341
|
-
else if ($
|
|
353
|
+
if ($47eee9224cfec8e8$export$764db16956f554f8(event)) pointerOffset = isHorizontal ? event.clientX : event.clientY;
|
|
354
|
+
else if ($47eee9224cfec8e8$export$c4dfce035d43d1e0(event)) {
|
|
342
355
|
const firstTouch = event.touches[0];
|
|
343
356
|
pointerOffset = isHorizontal ? firstTouch.screenX : firstTouch.screenY;
|
|
344
357
|
} else return 0;
|
|
345
|
-
const handleElement = (0, $
|
|
346
|
-
const rect = handleElement.getBoundingClientRect();
|
|
358
|
+
const handleElement = (0, $cda3cc4b1114cf23$export$2e27d3a347680388)(handleId);
|
|
359
|
+
const rect = initialHandleElementRect || handleElement.getBoundingClientRect();
|
|
347
360
|
const elementOffset = isHorizontal ? rect.left : rect.top;
|
|
348
361
|
return pointerOffset - elementOffset - initialOffset;
|
|
349
362
|
}
|
|
350
|
-
function $
|
|
351
|
-
|
|
363
|
+
function $47eee9224cfec8e8$export$354b17c0684607ed(event, groupId, handleId, panelsArray, direction, prevSizes, initialDragState) {
|
|
364
|
+
const { dragOffset: dragOffset = 0 , dragHandleRect: dragHandleRect , sizes: initialSizes } = initialDragState || {};
|
|
365
|
+
// If we're resizing by mouse or touch, use the initial sizes as a base.
|
|
366
|
+
// This has the benefit of causing force-collapsed panels to spring back open if drag is reversed.
|
|
367
|
+
const baseSizes = initialSizes || prevSizes;
|
|
368
|
+
if ($47eee9224cfec8e8$export$e7bf60a870f429b0(event)) {
|
|
352
369
|
const isHorizontal = direction === "horizontal";
|
|
353
|
-
const groupElement = (0, $
|
|
370
|
+
const groupElement = (0, $cda3cc4b1114cf23$export$5e67632cf3550a9c)(groupId);
|
|
354
371
|
const rect = groupElement.getBoundingClientRect();
|
|
355
372
|
const groupSizeInPixels = isHorizontal ? rect.width : rect.height;
|
|
356
373
|
const denominator = event.shiftKey ? 10 : 100;
|
|
@@ -380,24 +397,24 @@ function $f5af57c8e042a4ad$export$354b17c0684607ed(event, groupId, handleId, pan
|
|
|
380
397
|
// we need to special case resizing around the minSize boundary.
|
|
381
398
|
// If contracting, Panels should shrink to their minSize and then snap to fully collapsed.
|
|
382
399
|
// If expanding from collapsed, they should snap back to their minSize.
|
|
383
|
-
const [idBefore, idAfter] = (0, $
|
|
400
|
+
const [idBefore, idAfter] = (0, $cda3cc4b1114cf23$export$68d3a33c21dfbe27)(groupId, handleId, panelsArray);
|
|
384
401
|
const targetPanelId = movement < 0 ? idBefore : idAfter;
|
|
385
402
|
const targetPanelIndex = panelsArray.findIndex((panel)=>panel.id === targetPanelId);
|
|
386
403
|
const targetPanel = panelsArray[targetPanelIndex];
|
|
387
404
|
if (targetPanel.collapsible) {
|
|
388
|
-
const
|
|
389
|
-
if (
|
|
405
|
+
const baseSize = baseSizes[targetPanelIndex];
|
|
406
|
+
if (baseSize === 0 || baseSize.toPrecision((0, $9abd79656a89cd3a$export$d6d3992f3becc879)) === targetPanel.minSize.toPrecision((0, $9abd79656a89cd3a$export$d6d3992f3becc879))) movement = movement < 0 ? -targetPanel.minSize * groupSizeInPixels : targetPanel.minSize * groupSizeInPixels;
|
|
390
407
|
}
|
|
391
408
|
return movement;
|
|
392
|
-
} else return $
|
|
409
|
+
} else return $47eee9224cfec8e8$export$ec391ce65b083ed4(event, handleId, direction, dragOffset, dragHandleRect);
|
|
393
410
|
}
|
|
394
|
-
function $
|
|
411
|
+
function $47eee9224cfec8e8$export$e7bf60a870f429b0(event) {
|
|
395
412
|
return event.type === "keydown";
|
|
396
413
|
}
|
|
397
|
-
function $
|
|
414
|
+
function $47eee9224cfec8e8$export$764db16956f554f8(event) {
|
|
398
415
|
return event.type.startsWith("mouse");
|
|
399
416
|
}
|
|
400
|
-
function $
|
|
417
|
+
function $47eee9224cfec8e8$export$c4dfce035d43d1e0(event) {
|
|
401
418
|
return event.type.startsWith("touch");
|
|
402
419
|
}
|
|
403
420
|
|
|
@@ -408,16 +425,16 @@ function $f5af57c8e042a4ad$export$c4dfce035d43d1e0(event) {
|
|
|
408
425
|
|
|
409
426
|
|
|
410
427
|
|
|
411
|
-
function $
|
|
412
|
-
(0, $
|
|
428
|
+
function $a695670cc57a5969$export$d9fcbe062527d159({ committedValuesRef: committedValuesRef , groupId: groupId , panels: panels , setSizes: setSizes , sizes: sizes , panelSizeBeforeCollapse: panelSizeBeforeCollapse }) {
|
|
429
|
+
(0, $2IMI0$react.useEffect)(()=>{
|
|
413
430
|
const { direction: direction , panels: panels } = committedValuesRef.current;
|
|
414
|
-
const groupElement = (0, $
|
|
431
|
+
const groupElement = (0, $cda3cc4b1114cf23$export$5e67632cf3550a9c)(groupId);
|
|
415
432
|
const { height: height , width: width } = groupElement.getBoundingClientRect();
|
|
416
|
-
const handles = (0, $
|
|
433
|
+
const handles = (0, $cda3cc4b1114cf23$export$ae14931f0a0256a3)(groupId);
|
|
417
434
|
const cleanupFunctions = handles.map((handle)=>{
|
|
418
435
|
const handleId = handle.getAttribute("data-panel-resize-handle-id");
|
|
419
|
-
const panelsArray = (0, $
|
|
420
|
-
const [idBefore, idAfter] = (0, $
|
|
436
|
+
const panelsArray = (0, $cda3cc4b1114cf23$export$a861c0ad45885494)(panels);
|
|
437
|
+
const [idBefore, idAfter] = (0, $cda3cc4b1114cf23$export$68d3a33c21dfbe27)(groupId, handleId, panelsArray);
|
|
421
438
|
if (idBefore == null || idAfter == null) return ()=>{};
|
|
422
439
|
let minSize = 0;
|
|
423
440
|
let maxSize = 100;
|
|
@@ -435,7 +452,7 @@ function $63be9a96d8675f03$export$d9fcbe062527d159({ committedValuesRef: committ
|
|
|
435
452
|
});
|
|
436
453
|
const ariaValueMax = Math.min(maxSize, 100 - totalMinSize);
|
|
437
454
|
const ariaValueMin = Math.max(minSize, (panelsArray.length - 1) * 100 - totalMaxSize);
|
|
438
|
-
const flexGrow = (0, $
|
|
455
|
+
const flexGrow = (0, $cda3cc4b1114cf23$export$6f43503e166de6fb)(panels, idBefore, sizes);
|
|
439
456
|
handle.setAttribute("aria-valuemax", "" + Math.round(ariaValueMax));
|
|
440
457
|
handle.setAttribute("aria-valuemin", "" + Math.round(ariaValueMin));
|
|
441
458
|
handle.setAttribute("aria-valuenow", "" + Math.round(parseInt(flexGrow)));
|
|
@@ -449,9 +466,9 @@ function $63be9a96d8675f03$export$d9fcbe062527d159({ committedValuesRef: committ
|
|
|
449
466
|
const size = sizes[index];
|
|
450
467
|
if (size != null) {
|
|
451
468
|
let delta = 0;
|
|
452
|
-
if (size.toPrecision((0, $
|
|
469
|
+
if (size.toPrecision((0, $9abd79656a89cd3a$export$d6d3992f3becc879)) <= panelData.minSize.toPrecision((0, $9abd79656a89cd3a$export$d6d3992f3becc879))) delta = direction === "horizontal" ? width : height;
|
|
453
470
|
else delta = -(direction === "horizontal" ? width : height);
|
|
454
|
-
const nextSizes = (0, $
|
|
471
|
+
const nextSizes = (0, $cda3cc4b1114cf23$export$f50bae335f53943c)(event, panels, idBefore, idAfter, delta, sizes, panelSizeBeforeCollapse.current, null);
|
|
455
472
|
if (sizes !== nextSizes) setSizes(nextSizes);
|
|
456
473
|
}
|
|
457
474
|
}
|
|
@@ -460,7 +477,7 @@ function $63be9a96d8675f03$export$d9fcbe062527d159({ committedValuesRef: committ
|
|
|
460
477
|
}
|
|
461
478
|
};
|
|
462
479
|
handle.addEventListener("keydown", onKeyDown);
|
|
463
|
-
const panelBefore = (0, $
|
|
480
|
+
const panelBefore = (0, $cda3cc4b1114cf23$export$7361ed18ff57179e)(idBefore);
|
|
464
481
|
if (panelBefore != null) handle.setAttribute("aria-controls", panelBefore.id);
|
|
465
482
|
return ()=>{
|
|
466
483
|
handle.removeAttribute("aria-valuemax");
|
|
@@ -479,10 +496,10 @@ function $63be9a96d8675f03$export$d9fcbe062527d159({ committedValuesRef: committ
|
|
|
479
496
|
sizes
|
|
480
497
|
]);
|
|
481
498
|
}
|
|
482
|
-
function $
|
|
483
|
-
(0, $
|
|
499
|
+
function $a695670cc57a5969$export$33b0bea6ac3ffb03({ disabled: disabled , handleId: handleId , resizeHandler: resizeHandler }) {
|
|
500
|
+
(0, $2IMI0$react.useEffect)(()=>{
|
|
484
501
|
if (disabled || resizeHandler == null) return;
|
|
485
|
-
const handleElement = (0, $
|
|
502
|
+
const handleElement = (0, $cda3cc4b1114cf23$export$2e27d3a347680388)(handleId);
|
|
486
503
|
if (handleElement == null) return;
|
|
487
504
|
const onKeyDown = (event)=>{
|
|
488
505
|
switch(event.key){
|
|
@@ -496,8 +513,8 @@ function $63be9a96d8675f03$export$33b0bea6ac3ffb03({ disabled: disabled , handle
|
|
|
496
513
|
break;
|
|
497
514
|
case "F6":
|
|
498
515
|
{
|
|
499
|
-
const handles = (0, $
|
|
500
|
-
const index = (0, $
|
|
516
|
+
const handles = (0, $cda3cc4b1114cf23$export$8d0cd3c32ddc045e)();
|
|
517
|
+
const index = (0, $cda3cc4b1114cf23$export$96a40be80fb6c3c8)(handleId);
|
|
501
518
|
const nextIndex = event.shiftKey ? index > 0 ? index - 1 : handles.length - 1 : index + 1 < handles.length ? index + 1 : 0;
|
|
502
519
|
const nextHandle = handles[nextIndex];
|
|
503
520
|
nextHandle.focus();
|
|
@@ -517,9 +534,9 @@ function $63be9a96d8675f03$export$33b0bea6ac3ffb03({ disabled: disabled , handle
|
|
|
517
534
|
}
|
|
518
535
|
|
|
519
536
|
|
|
520
|
-
let $
|
|
521
|
-
let $
|
|
522
|
-
function $
|
|
537
|
+
let $08745f7373322b05$var$currentState = null;
|
|
538
|
+
let $08745f7373322b05$var$element = null;
|
|
539
|
+
function $08745f7373322b05$export$fa35f3322c52262f(state) {
|
|
523
540
|
switch(state){
|
|
524
541
|
case "horizontal":
|
|
525
542
|
return "col-resize";
|
|
@@ -535,26 +552,26 @@ function $102aa6bc0f99b2b3$export$fa35f3322c52262f(state) {
|
|
|
535
552
|
return "s-resize";
|
|
536
553
|
}
|
|
537
554
|
}
|
|
538
|
-
function $
|
|
539
|
-
if ($
|
|
540
|
-
document.head.removeChild($
|
|
541
|
-
$
|
|
542
|
-
$
|
|
555
|
+
function $08745f7373322b05$export$b61932ee18f96e08() {
|
|
556
|
+
if ($08745f7373322b05$var$element !== null) {
|
|
557
|
+
document.head.removeChild($08745f7373322b05$var$element);
|
|
558
|
+
$08745f7373322b05$var$currentState = null;
|
|
559
|
+
$08745f7373322b05$var$element = null;
|
|
543
560
|
}
|
|
544
561
|
}
|
|
545
|
-
function $
|
|
546
|
-
if ($
|
|
547
|
-
$
|
|
548
|
-
const style = $
|
|
549
|
-
if ($
|
|
550
|
-
$
|
|
551
|
-
document.head.appendChild($
|
|
562
|
+
function $08745f7373322b05$export$d395b5dfd066a659(state) {
|
|
563
|
+
if ($08745f7373322b05$var$currentState === state) return;
|
|
564
|
+
$08745f7373322b05$var$currentState = state;
|
|
565
|
+
const style = $08745f7373322b05$export$fa35f3322c52262f(state);
|
|
566
|
+
if ($08745f7373322b05$var$element === null) {
|
|
567
|
+
$08745f7373322b05$var$element = document.createElement("style");
|
|
568
|
+
document.head.appendChild($08745f7373322b05$var$element);
|
|
552
569
|
}
|
|
553
|
-
$
|
|
570
|
+
$08745f7373322b05$var$element.innerHTML = `*{cursor: ${style}!important;}`;
|
|
554
571
|
}
|
|
555
572
|
|
|
556
573
|
|
|
557
|
-
function $
|
|
574
|
+
function $2e8572579e31d898$export$2e2bcd8739ae039(callback, durationMs = 10) {
|
|
558
575
|
let timeoutId = null;
|
|
559
576
|
let callable = (...args)=>{
|
|
560
577
|
clearTimeout(timeoutId);
|
|
@@ -566,38 +583,56 @@ function $0f7a23424493ebd6$export$2e2bcd8739ae039(callback, durationMs = 10) {
|
|
|
566
583
|
}
|
|
567
584
|
|
|
568
585
|
|
|
586
|
+
function $d31ef7445a11a6c5$export$b141efd0b0fb9174(arrayA, arrayB) {
|
|
587
|
+
if (arrayA.length !== arrayB.length) return false;
|
|
588
|
+
for(let index = 0; index < arrayA.length; index++){
|
|
589
|
+
if (arrayA[index] !== arrayB[index]) return false;
|
|
590
|
+
}
|
|
591
|
+
return true;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
|
|
569
595
|
// Limit the frequency of localStorage updates.
|
|
570
|
-
const $
|
|
571
|
-
function $
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
596
|
+
const $cec4cafe75f3db78$var$savePanelGroupLayoutDebounced = (0, $2e8572579e31d898$export$2e2bcd8739ae039)((0, $f9cb001fbb908626$export$af183b313c61be4f), 100);
|
|
597
|
+
function $cec4cafe75f3db78$var$throwServerError() {
|
|
598
|
+
throw new Error('PanelGroup "storage" prop required for server rendering.');
|
|
599
|
+
}
|
|
600
|
+
const $cec4cafe75f3db78$var$defaultStorage = {
|
|
601
|
+
getItem: typeof localStorage !== "undefined" ? (name)=>localStorage.getItem(name) : $cec4cafe75f3db78$var$throwServerError,
|
|
602
|
+
setItem: typeof localStorage !== "undefined" ? (name, value)=>localStorage.setItem(name, value) : $cec4cafe75f3db78$var$throwServerError
|
|
603
|
+
};
|
|
604
|
+
function $cec4cafe75f3db78$export$1d05749f6f573bb({ autoSaveId: autoSaveId , children: children = null , className: classNameFromProps = "" , direction: direction , id: idFromProps = null , onLayout: onLayout = null , storage: storage = $cec4cafe75f3db78$var$defaultStorage , style: styleFromProps = {} , tagName: Type = "div" }) {
|
|
605
|
+
const groupId = (0, $b1693d8d8f570e9c$export$2e2bcd8739ae039)(idFromProps);
|
|
606
|
+
const [activeHandleId, setActiveHandleId] = (0, $2IMI0$react.useState)(null);
|
|
607
|
+
const [panels, setPanels] = (0, $2IMI0$react.useState)(new Map());
|
|
608
|
+
// When resizing is done via mouse/touch event–
|
|
609
|
+
// We store the initial Panel sizes in this ref, and apply move deltas to them instead of to the current sizes.
|
|
610
|
+
// This has the benefit of causing force-collapsed panels to spring back open if drag is reversed.
|
|
611
|
+
const initialDragStateRef = (0, $2IMI0$react.useRef)(null);
|
|
575
612
|
// Use a ref to guard against users passing inline props
|
|
576
|
-
const callbacksRef = (0, $
|
|
613
|
+
const callbacksRef = (0, $2IMI0$react.useRef)({
|
|
577
614
|
onLayout: onLayout
|
|
578
615
|
});
|
|
579
|
-
(0, $
|
|
616
|
+
(0, $2IMI0$react.useEffect)(()=>{
|
|
580
617
|
callbacksRef.current.onLayout = onLayout;
|
|
581
618
|
});
|
|
582
619
|
// 0-1 values representing the relative size of each panel.
|
|
583
|
-
const [sizes, setSizes] = (0, $
|
|
584
|
-
// Resize is calculated by the distance between the current pointer event and the resize handle being "dragged"
|
|
585
|
-
// This value accounts for the initial offset when the touch/click starts, so the handle doesn't appear to "jump"
|
|
586
|
-
const dragOffsetRef = (0, $b2QPe$react.useRef)(0);
|
|
620
|
+
const [sizes, setSizes] = (0, $2IMI0$react.useState)([]);
|
|
587
621
|
// Used to support imperative collapse/expand API.
|
|
588
|
-
const panelSizeBeforeCollapse = (0, $
|
|
622
|
+
const panelSizeBeforeCollapse = (0, $2IMI0$react.useRef)(new Map());
|
|
623
|
+
const prevDeltaRef = (0, $2IMI0$react.useRef)(0);
|
|
589
624
|
// Store committed values to avoid unnecessarily re-running memoization/effects functions.
|
|
590
|
-
const committedValuesRef = (0, $
|
|
625
|
+
const committedValuesRef = (0, $2IMI0$react.useRef)({
|
|
591
626
|
direction: direction,
|
|
592
627
|
panels: panels,
|
|
593
628
|
sizes: sizes
|
|
594
629
|
});
|
|
595
|
-
(0, $
|
|
630
|
+
(0, $129b5b9a317dcc10$export$2e2bcd8739ae039)(()=>{
|
|
596
631
|
committedValuesRef.current.direction = direction;
|
|
597
632
|
committedValuesRef.current.panels = panels;
|
|
598
633
|
committedValuesRef.current.sizes = sizes;
|
|
599
634
|
});
|
|
600
|
-
(0, $
|
|
635
|
+
(0, $a695670cc57a5969$export$d9fcbe062527d159)({
|
|
601
636
|
committedValuesRef: committedValuesRef,
|
|
602
637
|
groupId: groupId,
|
|
603
638
|
panels: panels,
|
|
@@ -606,7 +641,7 @@ function $19bf0050f73d236b$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
606
641
|
panelSizeBeforeCollapse: panelSizeBeforeCollapse
|
|
607
642
|
});
|
|
608
643
|
// Notify external code when sizes have changed.
|
|
609
|
-
(0, $
|
|
644
|
+
(0, $2IMI0$react.useEffect)(()=>{
|
|
610
645
|
const { onLayout: onLayout } = callbacksRef.current;
|
|
611
646
|
if (onLayout) {
|
|
612
647
|
const { sizes: sizes } = committedValuesRef.current;
|
|
@@ -618,14 +653,14 @@ function $19bf0050f73d236b$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
618
653
|
]);
|
|
619
654
|
// Notify Panel listeners about their initial sizes and collapsed state after mount.
|
|
620
655
|
// Subsequent changes will be called by the resizeHandler.
|
|
621
|
-
const didNotifyCallbacksAfterMountRef = (0, $
|
|
622
|
-
(0, $
|
|
656
|
+
const didNotifyCallbacksAfterMountRef = (0, $2IMI0$react.useRef)(false);
|
|
657
|
+
(0, $129b5b9a317dcc10$export$2e2bcd8739ae039)(()=>{
|
|
623
658
|
if (didNotifyCallbacksAfterMountRef.current) return;
|
|
624
659
|
const { panels: panels , sizes: sizes } = committedValuesRef.current;
|
|
625
660
|
if (sizes.length > 0) {
|
|
626
661
|
didNotifyCallbacksAfterMountRef.current = true;
|
|
627
|
-
const panelsArray = (0, $
|
|
628
|
-
(0, $
|
|
662
|
+
const panelsArray = (0, $cda3cc4b1114cf23$export$a861c0ad45885494)(panels);
|
|
663
|
+
(0, $cda3cc4b1114cf23$export$b8e48269e4faa934)(panelsArray, [], sizes);
|
|
629
664
|
}
|
|
630
665
|
}, [
|
|
631
666
|
sizes
|
|
@@ -633,7 +668,7 @@ function $19bf0050f73d236b$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
633
668
|
// Once all panels have registered themselves,
|
|
634
669
|
// Compute the initial sizes based on default weights.
|
|
635
670
|
// This assumes that panels register during initial mount (no conditional rendering)!
|
|
636
|
-
(0, $
|
|
671
|
+
(0, $129b5b9a317dcc10$export$2e2bcd8739ae039)(()=>{
|
|
637
672
|
const sizes = committedValuesRef.current.sizes;
|
|
638
673
|
if (sizes.length === panels.size) // Only compute (or restore) default sizes once per panel configuration.
|
|
639
674
|
return;
|
|
@@ -641,12 +676,12 @@ function $19bf0050f73d236b$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
641
676
|
// default size should be restored from local storage if possible.
|
|
642
677
|
let defaultSizes = undefined;
|
|
643
678
|
if (autoSaveId) {
|
|
644
|
-
const panelsArray = (0, $
|
|
645
|
-
defaultSizes = (0, $
|
|
679
|
+
const panelsArray = (0, $cda3cc4b1114cf23$export$a861c0ad45885494)(panels);
|
|
680
|
+
defaultSizes = (0, $f9cb001fbb908626$export$9c80c6617f0386da)(autoSaveId, panelsArray, storage);
|
|
646
681
|
}
|
|
647
682
|
if (defaultSizes != null) setSizes(defaultSizes);
|
|
648
683
|
else {
|
|
649
|
-
const panelsArray1 = (0, $
|
|
684
|
+
const panelsArray1 = (0, $cda3cc4b1114cf23$export$a861c0ad45885494)(panels);
|
|
650
685
|
let panelsWithNullDefaultSize = 0;
|
|
651
686
|
let totalDefaultSize = 0;
|
|
652
687
|
let totalMinSize = 0;
|
|
@@ -670,19 +705,19 @@ function $19bf0050f73d236b$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
670
705
|
autoSaveId,
|
|
671
706
|
panels
|
|
672
707
|
]);
|
|
673
|
-
(0, $
|
|
708
|
+
(0, $2IMI0$react.useEffect)(()=>{
|
|
674
709
|
// If this panel has been configured to persist sizing information, save sizes to local storage.
|
|
675
710
|
if (autoSaveId) {
|
|
676
711
|
if (sizes.length === 0 || sizes.length !== panels.size) return;
|
|
677
|
-
const panelsArray = (0, $
|
|
678
|
-
$
|
|
712
|
+
const panelsArray = (0, $cda3cc4b1114cf23$export$a861c0ad45885494)(panels);
|
|
713
|
+
$cec4cafe75f3db78$var$savePanelGroupLayoutDebounced(autoSaveId, panelsArray, sizes, storage);
|
|
679
714
|
}
|
|
680
715
|
}, [
|
|
681
716
|
autoSaveId,
|
|
682
717
|
panels,
|
|
683
718
|
sizes
|
|
684
719
|
]);
|
|
685
|
-
const getPanelStyle = (0, $
|
|
720
|
+
const getPanelStyle = (0, $2IMI0$react.useCallback)((id)=>{
|
|
686
721
|
const { panels: panels } = committedValuesRef.current;
|
|
687
722
|
// Before mounting, Panels will not yet have registered themselves.
|
|
688
723
|
// This includes server rendering.
|
|
@@ -694,7 +729,7 @@ function $19bf0050f73d236b$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
694
729
|
// Without this, Panel sizes may be unintentionally overridden by their content.
|
|
695
730
|
overflow: "hidden"
|
|
696
731
|
};
|
|
697
|
-
const flexGrow = (0, $
|
|
732
|
+
const flexGrow = (0, $cda3cc4b1114cf23$export$6f43503e166de6fb)(panels, id, sizes);
|
|
698
733
|
return {
|
|
699
734
|
flexBasis: 0,
|
|
700
735
|
flexGrow: flexGrow,
|
|
@@ -710,7 +745,7 @@ function $19bf0050f73d236b$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
710
745
|
direction,
|
|
711
746
|
sizes
|
|
712
747
|
]);
|
|
713
|
-
const registerPanel = (0, $
|
|
748
|
+
const registerPanel = (0, $2IMI0$react.useCallback)((id, panel)=>{
|
|
714
749
|
setPanels((prevPanels)=>{
|
|
715
750
|
if (prevPanels.has(id)) return prevPanels;
|
|
716
751
|
const nextPanels = new Map(prevPanels);
|
|
@@ -718,40 +753,50 @@ function $19bf0050f73d236b$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
718
753
|
return nextPanels;
|
|
719
754
|
});
|
|
720
755
|
}, []);
|
|
721
|
-
const registerResizeHandle = (0, $
|
|
756
|
+
const registerResizeHandle = (0, $2IMI0$react.useCallback)((handleId)=>{
|
|
722
757
|
const resizeHandler = (event)=>{
|
|
723
758
|
event.preventDefault();
|
|
724
759
|
const { direction: direction , panels: panels , sizes: prevSizes } = committedValuesRef.current;
|
|
725
|
-
const panelsArray = (0, $
|
|
726
|
-
const [idBefore, idAfter] = (0, $
|
|
760
|
+
const panelsArray = (0, $cda3cc4b1114cf23$export$a861c0ad45885494)(panels);
|
|
761
|
+
const [idBefore, idAfter] = (0, $cda3cc4b1114cf23$export$68d3a33c21dfbe27)(groupId, handleId, panelsArray);
|
|
727
762
|
if (idBefore == null || idAfter == null) return;
|
|
728
|
-
const movement = (0, $
|
|
763
|
+
const movement = (0, $47eee9224cfec8e8$export$354b17c0684607ed)(event, groupId, handleId, panelsArray, direction, prevSizes, initialDragStateRef.current);
|
|
729
764
|
if (movement === 0) return;
|
|
730
|
-
const groupElement = (0, $
|
|
765
|
+
const groupElement = (0, $cda3cc4b1114cf23$export$5e67632cf3550a9c)(groupId);
|
|
731
766
|
const rect = groupElement.getBoundingClientRect();
|
|
732
767
|
const isHorizontal = direction === "horizontal";
|
|
733
768
|
const size = isHorizontal ? rect.width : rect.height;
|
|
734
769
|
const delta = movement / size * 100;
|
|
735
|
-
const nextSizes = (0, $
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
770
|
+
const nextSizes = (0, $cda3cc4b1114cf23$export$f50bae335f53943c)(event, panels, idBefore, idAfter, delta, prevSizes, panelSizeBeforeCollapse.current, initialDragStateRef.current);
|
|
771
|
+
const sizesChanged = !(0, $d31ef7445a11a6c5$export$b141efd0b0fb9174)(prevSizes, nextSizes);
|
|
772
|
+
// Don't update cursor for resizes triggered by keyboard interactions.
|
|
773
|
+
if ((0, $47eee9224cfec8e8$export$764db16956f554f8)(event) || (0, $47eee9224cfec8e8$export$c4dfce035d43d1e0)(event)) // Watch for multiple subsequent deltas; this might occur for tiny cursor movements.
|
|
774
|
+
// In this case, Panel sizes might not change–
|
|
775
|
+
// but updating cursor in this scenario would cause a flicker.
|
|
776
|
+
{
|
|
777
|
+
if (prevDeltaRef.current != delta) {
|
|
778
|
+
if (!sizesChanged) {
|
|
779
|
+
// If the pointer has moved too far to resize the panel any further,
|
|
780
|
+
// update the cursor style for a visual clue.
|
|
781
|
+
// This mimics VS Code behavior.
|
|
782
|
+
if (isHorizontal) (0, $08745f7373322b05$export$d395b5dfd066a659)(movement < 0 ? "horizontal-min" : "horizontal-max");
|
|
783
|
+
else (0, $08745f7373322b05$export$d395b5dfd066a659)(movement < 0 ? "vertical-min" : "vertical-max");
|
|
784
|
+
} else // Reset the cursor style to the the normal resize cursor.
|
|
785
|
+
(0, $08745f7373322b05$export$d395b5dfd066a659)(isHorizontal ? "horizontal" : "vertical");
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
if (sizesChanged) {
|
|
745
789
|
// If resize change handlers have been declared, this is the time to call them.
|
|
746
|
-
(0, $
|
|
790
|
+
(0, $cda3cc4b1114cf23$export$b8e48269e4faa934)(panelsArray, prevSizes, nextSizes);
|
|
747
791
|
setSizes(nextSizes);
|
|
748
792
|
}
|
|
793
|
+
prevDeltaRef.current = delta;
|
|
749
794
|
};
|
|
750
795
|
return resizeHandler;
|
|
751
796
|
}, [
|
|
752
797
|
groupId
|
|
753
798
|
]);
|
|
754
|
-
const unregisterPanel = (0, $
|
|
799
|
+
const unregisterPanel = (0, $2IMI0$react.useCallback)((id)=>{
|
|
755
800
|
setPanels((prevPanels)=>{
|
|
756
801
|
if (!prevPanels.has(id)) return prevPanels;
|
|
757
802
|
const nextPanels = new Map(prevPanels);
|
|
@@ -759,72 +804,74 @@ function $19bf0050f73d236b$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
759
804
|
return nextPanels;
|
|
760
805
|
});
|
|
761
806
|
}, []);
|
|
762
|
-
const collapsePanel = (0, $
|
|
807
|
+
const collapsePanel = (0, $2IMI0$react.useCallback)((id)=>{
|
|
763
808
|
const { panels: panels , sizes: prevSizes } = committedValuesRef.current;
|
|
764
809
|
const panel = panels.get(id);
|
|
765
810
|
if (panel == null || !panel.collapsible) return;
|
|
766
|
-
const panelsArray = (0, $
|
|
811
|
+
const panelsArray = (0, $cda3cc4b1114cf23$export$a861c0ad45885494)(panels);
|
|
767
812
|
const index = panelsArray.indexOf(panel);
|
|
768
813
|
if (index < 0) return;
|
|
769
814
|
const currentSize = prevSizes[index];
|
|
770
815
|
if (currentSize === 0) // Panel is already collapsed.
|
|
771
816
|
return;
|
|
772
817
|
panelSizeBeforeCollapse.current.set(id, currentSize);
|
|
773
|
-
const [idBefore, idAfter] = (0, $
|
|
818
|
+
const [idBefore, idAfter] = (0, $cda3cc4b1114cf23$export$5a5b0c1d38c23c3b)(id, panelsArray);
|
|
774
819
|
if (idBefore == null || idAfter == null) return;
|
|
775
820
|
const isLastPanel = index === panelsArray.length - 1;
|
|
776
821
|
const delta = isLastPanel ? currentSize : 0 - currentSize;
|
|
777
|
-
const nextSizes = (0, $
|
|
822
|
+
const nextSizes = (0, $cda3cc4b1114cf23$export$f50bae335f53943c)(null, panels, idBefore, idAfter, delta, prevSizes, panelSizeBeforeCollapse.current, null);
|
|
778
823
|
if (prevSizes !== nextSizes) {
|
|
779
824
|
// If resize change handlers have been declared, this is the time to call them.
|
|
780
|
-
(0, $
|
|
825
|
+
(0, $cda3cc4b1114cf23$export$b8e48269e4faa934)(panelsArray, prevSizes, nextSizes);
|
|
781
826
|
setSizes(nextSizes);
|
|
782
827
|
}
|
|
783
828
|
}, []);
|
|
784
|
-
const expandPanel = (0, $
|
|
829
|
+
const expandPanel = (0, $2IMI0$react.useCallback)((id)=>{
|
|
785
830
|
const { panels: panels , sizes: prevSizes } = committedValuesRef.current;
|
|
786
831
|
const panel = panels.get(id);
|
|
787
832
|
if (panel == null) return;
|
|
788
833
|
const sizeBeforeCollapse = panelSizeBeforeCollapse.current.get(id) || panel.minSize;
|
|
789
834
|
if (!sizeBeforeCollapse) return;
|
|
790
|
-
const panelsArray = (0, $
|
|
835
|
+
const panelsArray = (0, $cda3cc4b1114cf23$export$a861c0ad45885494)(panels);
|
|
791
836
|
const index = panelsArray.indexOf(panel);
|
|
792
837
|
if (index < 0) return;
|
|
793
838
|
const currentSize = prevSizes[index];
|
|
794
839
|
if (currentSize !== 0) // Panel is already expanded.
|
|
795
840
|
return;
|
|
796
|
-
const [idBefore, idAfter] = (0, $
|
|
841
|
+
const [idBefore, idAfter] = (0, $cda3cc4b1114cf23$export$5a5b0c1d38c23c3b)(id, panelsArray);
|
|
797
842
|
if (idBefore == null || idAfter == null) return;
|
|
798
843
|
const isLastPanel = index === panelsArray.length - 1;
|
|
799
844
|
const delta = isLastPanel ? 0 - sizeBeforeCollapse : sizeBeforeCollapse;
|
|
800
|
-
const nextSizes = (0, $
|
|
845
|
+
const nextSizes = (0, $cda3cc4b1114cf23$export$f50bae335f53943c)(null, panels, idBefore, idAfter, delta, prevSizes, panelSizeBeforeCollapse.current, null);
|
|
801
846
|
if (prevSizes !== nextSizes) {
|
|
802
847
|
// If resize change handlers have been declared, this is the time to call them.
|
|
803
|
-
(0, $
|
|
848
|
+
(0, $cda3cc4b1114cf23$export$b8e48269e4faa934)(panelsArray, prevSizes, nextSizes);
|
|
804
849
|
setSizes(nextSizes);
|
|
805
850
|
}
|
|
806
851
|
}, []);
|
|
807
|
-
const resizePanel = (0, $
|
|
852
|
+
const resizePanel = (0, $2IMI0$react.useCallback)((id, nextSize)=>{
|
|
808
853
|
const { panels: panels , sizes: prevSizes } = committedValuesRef.current;
|
|
809
854
|
const panel = panels.get(id);
|
|
810
855
|
if (panel == null) return;
|
|
811
|
-
const panelsArray = (0, $
|
|
856
|
+
const panelsArray = (0, $cda3cc4b1114cf23$export$a861c0ad45885494)(panels);
|
|
812
857
|
const index = panelsArray.indexOf(panel);
|
|
813
858
|
if (index < 0) return;
|
|
814
859
|
const currentSize = prevSizes[index];
|
|
815
860
|
if (currentSize === nextSize) return;
|
|
816
|
-
|
|
861
|
+
if (panel.collapsible && nextSize === 0) ;
|
|
862
|
+
else nextSize = Math.min(panel.maxSize, Math.max(panel.minSize, nextSize));
|
|
863
|
+
const [idBefore, idAfter] = (0, $cda3cc4b1114cf23$export$5a5b0c1d38c23c3b)(id, panelsArray);
|
|
817
864
|
if (idBefore == null || idAfter == null) return;
|
|
818
865
|
const isLastPanel = index === panelsArray.length - 1;
|
|
819
866
|
const delta = isLastPanel ? currentSize - nextSize : nextSize - currentSize;
|
|
820
|
-
const nextSizes = (0, $
|
|
867
|
+
const nextSizes = (0, $cda3cc4b1114cf23$export$f50bae335f53943c)(null, panels, idBefore, idAfter, delta, prevSizes, panelSizeBeforeCollapse.current, null);
|
|
821
868
|
if (prevSizes !== nextSizes) {
|
|
822
869
|
// If resize change handlers have been declared, this is the time to call them.
|
|
823
|
-
(0, $
|
|
870
|
+
(0, $cda3cc4b1114cf23$export$b8e48269e4faa934)(panelsArray, prevSizes, nextSizes);
|
|
824
871
|
setSizes(nextSizes);
|
|
825
872
|
}
|
|
826
873
|
}, []);
|
|
827
|
-
const context = (0, $
|
|
874
|
+
const context = (0, $2IMI0$react.useMemo)(()=>({
|
|
828
875
|
activeHandleId: activeHandleId,
|
|
829
876
|
collapsePanel: collapsePanel,
|
|
830
877
|
direction: direction,
|
|
@@ -836,11 +883,19 @@ function $19bf0050f73d236b$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
836
883
|
resizePanel: resizePanel,
|
|
837
884
|
startDragging: (id, event)=>{
|
|
838
885
|
setActiveHandleId(id);
|
|
839
|
-
|
|
886
|
+
if ((0, $47eee9224cfec8e8$export$764db16956f554f8)(event) || (0, $47eee9224cfec8e8$export$c4dfce035d43d1e0)(event)) {
|
|
887
|
+
const handleElement = (0, $cda3cc4b1114cf23$export$2e27d3a347680388)(id);
|
|
888
|
+
initialDragStateRef.current = {
|
|
889
|
+
dragHandleRect: handleElement.getBoundingClientRect(),
|
|
890
|
+
dragOffset: (0, $47eee9224cfec8e8$export$ec391ce65b083ed4)(event, id, direction),
|
|
891
|
+
sizes: committedValuesRef.current.sizes
|
|
892
|
+
};
|
|
893
|
+
}
|
|
840
894
|
},
|
|
841
895
|
stopDragging: ()=>{
|
|
842
|
-
(0, $
|
|
896
|
+
(0, $08745f7373322b05$export$b61932ee18f96e08)();
|
|
843
897
|
setActiveHandleId(null);
|
|
898
|
+
initialDragStateRef.current = null;
|
|
844
899
|
},
|
|
845
900
|
unregisterPanel: unregisterPanel
|
|
846
901
|
}), [
|
|
@@ -862,10 +917,11 @@ function $19bf0050f73d236b$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
862
917
|
overflow: "hidden",
|
|
863
918
|
width: "100%"
|
|
864
919
|
};
|
|
865
|
-
return (0, $
|
|
866
|
-
children: (0, $
|
|
920
|
+
return (0, $2IMI0$react.createElement)((0, $b9cf028330e7f243$export$7d8c6d083caec74a).Provider, {
|
|
921
|
+
children: (0, $2IMI0$react.createElement)(Type, {
|
|
867
922
|
children: children,
|
|
868
923
|
className: classNameFromProps,
|
|
924
|
+
"data-panel-group": "",
|
|
869
925
|
"data-panel-group-direction": direction,
|
|
870
926
|
"data-panel-group-id": groupId,
|
|
871
927
|
style: {
|
|
@@ -879,7 +935,7 @@ function $19bf0050f73d236b$export$1d05749f6f573bb({ autoSaveId: autoSaveId , chi
|
|
|
879
935
|
// Workaround for Parcel scope hoisting (which renames objects/functions).
|
|
880
936
|
// Casting to :any is required to avoid corrupting the generated TypeScript types.
|
|
881
937
|
// See github.com/parcel-bundler/parcel/issues/8724
|
|
882
|
-
$
|
|
938
|
+
$cec4cafe75f3db78$export$1d05749f6f573bb.displayName = "PanelGroup";
|
|
883
939
|
|
|
884
940
|
|
|
885
941
|
|
|
@@ -887,16 +943,16 @@ $19bf0050f73d236b$export$1d05749f6f573bb.displayName = "PanelGroup";
|
|
|
887
943
|
|
|
888
944
|
|
|
889
945
|
|
|
890
|
-
function $
|
|
891
|
-
const divElementRef = (0, $
|
|
892
|
-
const panelGroupContext = (0, $
|
|
946
|
+
function $3a26a712c9163348$export$8829ecf6b6b15484({ children: children = null , className: classNameFromProps = "" , disabled: disabled = false , id: idFromProps = null , style: styleFromProps = {} , tagName: Type = "div" }) {
|
|
947
|
+
const divElementRef = (0, $2IMI0$react.useRef)(null);
|
|
948
|
+
const panelGroupContext = (0, $2IMI0$react.useContext)((0, $b9cf028330e7f243$export$7d8c6d083caec74a));
|
|
893
949
|
if (panelGroupContext === null) throw Error(`PanelResizeHandle components must be rendered within a PanelGroup container`);
|
|
894
950
|
const { activeHandleId: activeHandleId , direction: direction , groupId: groupId , registerResizeHandle: registerResizeHandle , startDragging: startDragging , stopDragging: stopDragging } = panelGroupContext;
|
|
895
|
-
const resizeHandleId = (0, $
|
|
951
|
+
const resizeHandleId = (0, $b1693d8d8f570e9c$export$2e2bcd8739ae039)(idFromProps);
|
|
896
952
|
const isDragging = activeHandleId === resizeHandleId;
|
|
897
|
-
const [isFocused, setIsFocused] = (0, $
|
|
898
|
-
const [resizeHandler, setResizeHandler] = (0, $
|
|
899
|
-
const stopDraggingAndBlur = (0, $
|
|
953
|
+
const [isFocused, setIsFocused] = (0, $2IMI0$react.useState)(false);
|
|
954
|
+
const [resizeHandler, setResizeHandler] = (0, $2IMI0$react.useState)(null);
|
|
955
|
+
const stopDraggingAndBlur = (0, $2IMI0$react.useCallback)(()=>{
|
|
900
956
|
// Clicking on the drag handle shouldn't leave it focused;
|
|
901
957
|
// That would cause the PanelGroup to think it was still active.
|
|
902
958
|
const div = divElementRef.current;
|
|
@@ -905,7 +961,7 @@ function $01377e07790cf46f$export$8829ecf6b6b15484({ children: children = null ,
|
|
|
905
961
|
}, [
|
|
906
962
|
stopDragging
|
|
907
963
|
]);
|
|
908
|
-
(0, $
|
|
964
|
+
(0, $2IMI0$react.useEffect)(()=>{
|
|
909
965
|
if (disabled) setResizeHandler(null);
|
|
910
966
|
else {
|
|
911
967
|
const resizeHandler = registerResizeHandle(resizeHandleId);
|
|
@@ -916,7 +972,7 @@ function $01377e07790cf46f$export$8829ecf6b6b15484({ children: children = null ,
|
|
|
916
972
|
resizeHandleId,
|
|
917
973
|
registerResizeHandle
|
|
918
974
|
]);
|
|
919
|
-
(0, $
|
|
975
|
+
(0, $2IMI0$react.useEffect)(()=>{
|
|
920
976
|
if (disabled || resizeHandler == null || !isDragging) return;
|
|
921
977
|
const onMove = (event)=>{
|
|
922
978
|
resizeHandler(event);
|
|
@@ -940,17 +996,17 @@ function $01377e07790cf46f$export$8829ecf6b6b15484({ children: children = null ,
|
|
|
940
996
|
resizeHandler,
|
|
941
997
|
stopDraggingAndBlur
|
|
942
998
|
]);
|
|
943
|
-
(0, $
|
|
999
|
+
(0, $a695670cc57a5969$export$33b0bea6ac3ffb03)({
|
|
944
1000
|
disabled: disabled,
|
|
945
1001
|
handleId: resizeHandleId,
|
|
946
1002
|
resizeHandler: resizeHandler
|
|
947
1003
|
});
|
|
948
1004
|
const style = {
|
|
949
|
-
cursor: (0, $
|
|
1005
|
+
cursor: (0, $08745f7373322b05$export$fa35f3322c52262f)(direction),
|
|
950
1006
|
touchAction: "none",
|
|
951
1007
|
userSelect: "none"
|
|
952
1008
|
};
|
|
953
|
-
return (0, $
|
|
1009
|
+
return (0, $2IMI0$react.createElement)(Type, {
|
|
954
1010
|
children: children,
|
|
955
1011
|
className: classNameFromProps,
|
|
956
1012
|
"data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
|
|
@@ -977,7 +1033,7 @@ function $01377e07790cf46f$export$8829ecf6b6b15484({ children: children = null ,
|
|
|
977
1033
|
// Workaround for Parcel scope hoisting (which renames objects/functions).
|
|
978
1034
|
// Casting to :any is required to avoid corrupting the generated TypeScript types.
|
|
979
1035
|
// See github.com/parcel-bundler/parcel/issues/8724
|
|
980
|
-
$
|
|
1036
|
+
$3a26a712c9163348$export$8829ecf6b6b15484.displayName = "PanelResizeHandle";
|
|
981
1037
|
|
|
982
1038
|
|
|
983
1039
|
|