react-resizable-panels 0.0.8 → 0.0.10

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.
@@ -38,6 +38,8 @@ function $ad28bce87b00c2be$export$2e2bcd8739ae039({ children: children = null ,
38
38
  const style = getPanelStyle(id);
39
39
  return /*#__PURE__*/ (0, $fpI56$jsxDEV)("div", {
40
40
  className: className,
41
+ "data-panel-id": id,
42
+ id: `data-panel-id-${id}`,
41
43
  style: style,
42
44
  children: children
43
45
  }, void 0, false, {
@@ -87,31 +89,253 @@ function $6ff1a22b27cc039d$export$af183b313c61be4f(autoSaveId, panelIds, sizes)
87
89
  }
88
90
 
89
91
 
90
- function $4b6140a59f4bd98c$export$70637efcd850e4ef(event, prevCoordinates) {
91
- const { screenX: prevScreenX , screenY: prevScreenY } = prevCoordinates;
92
- const getMovementBetween = (current, prev)=>prev === 0 ? 0 : current - prev;
93
- if ($4b6140a59f4bd98c$export$ce897e7f0aa63661(event)) {
94
- const firstTouch = event.touches[0];
95
- return {
96
- movementX: getMovementBetween(firstTouch.screenX, prevScreenX),
97
- movementY: getMovementBetween(firstTouch.screenY, prevScreenY),
98
- screenX: firstTouch.screenX,
99
- screenY: firstTouch.screenY
100
- };
92
+ const $fc25b75732bfda27$export$d6d3992f3becc879 = 5;
93
+
94
+
95
+ function $f30c804b5fe6cc1a$export$f50bae335f53943c(panels, idBefore, idAfter, delta, prevSizes) {
96
+ if (delta === 0) return prevSizes;
97
+ const panelsArray = $f30c804b5fe6cc1a$export$a861c0ad45885494(panels);
98
+ const nextSizes = prevSizes.concat();
99
+ let deltaApplied = 0;
100
+ // A resizing panel affects the panels before or after it.
101
+ //
102
+ // A negative delta means the panel immediately after the resizer should grow/expand by decreasing its offset.
103
+ // Other panels may also need to shrink/contract (and shift) to make room, depending on the min weights.
104
+ //
105
+ // A positive delta means the panel immediately before the resizer should "expand".
106
+ // This is accomplished by shrinking/contracting (and shifting) one or more of the panels after the resizer.
107
+ let pivotId = delta < 0 ? idBefore : idAfter;
108
+ let index = panelsArray.findIndex((panel)=>panel.id === pivotId);
109
+ while(true){
110
+ const panel = panelsArray[index];
111
+ const prevSize = prevSizes[index];
112
+ const nextSize = Math.max(prevSize - Math.abs(delta), panel.minSize);
113
+ if (prevSize !== nextSize) {
114
+ deltaApplied += prevSize - nextSize;
115
+ nextSizes[index] = nextSize;
116
+ if (deltaApplied.toPrecision((0, $fc25b75732bfda27$export$d6d3992f3becc879)) >= delta.toPrecision((0, $fc25b75732bfda27$export$d6d3992f3becc879))) break;
117
+ }
118
+ if (delta < 0) {
119
+ if (--index < 0) break;
120
+ } else {
121
+ if (++index >= panelsArray.length) break;
122
+ }
123
+ }
124
+ // If we were unable to resize any of the panels panels, return the previous state.
125
+ // This will essentially bailout and ignore the "mousemove" event.
126
+ if (deltaApplied === 0) return prevSizes;
127
+ // Adjust the pivot panel before, but only by the amount that surrounding panels were able to shrink/contract.
128
+ pivotId = delta < 0 ? idAfter : idBefore;
129
+ index = panelsArray.findIndex((panel)=>panel.id === pivotId);
130
+ nextSizes[index] = prevSizes[index] + deltaApplied;
131
+ return nextSizes;
132
+ }
133
+ function $f30c804b5fe6cc1a$export$622cea445a1c5b7d(panels, id, direction, sizes, height, width) {
134
+ const panelsArray = $f30c804b5fe6cc1a$export$a861c0ad45885494(panels);
135
+ let index = panelsArray.findIndex((panel)=>panel.id === id);
136
+ if (index < 0) return 0;
137
+ let scaledOffset = 0;
138
+ for(index = index - 1; index >= 0; index--){
139
+ const panel = panelsArray[index];
140
+ scaledOffset += $f30c804b5fe6cc1a$export$31b21d0167753bb4(panels, panel.id, direction, sizes, height, width);
141
+ }
142
+ return Math.round(scaledOffset);
143
+ }
144
+ function $f30c804b5fe6cc1a$export$7361ed18ff57179e(id) {
145
+ const element = document.querySelector(`[data-panel-id="${id}"]`);
146
+ if (element) return element;
147
+ return null;
148
+ }
149
+ function $f30c804b5fe6cc1a$export$2e27d3a347680388(id) {
150
+ const element = document.querySelector(`[data-panel-resize-handle-id="${id}"]`);
151
+ if (element) return element;
152
+ return null;
153
+ }
154
+ function $f30c804b5fe6cc1a$export$96a40be80fb6c3c8(id) {
155
+ const handles = $f30c804b5fe6cc1a$export$8d0cd3c32ddc045e();
156
+ const index = handles.findIndex((handle)=>handle.getAttribute("data-panel-resize-handle-id") === id);
157
+ return index ?? null;
158
+ }
159
+ function $f30c804b5fe6cc1a$export$8d0cd3c32ddc045e() {
160
+ return Array.from(document.querySelectorAll(`[data-panel-resize-handle-id]`));
161
+ }
162
+ function $f30c804b5fe6cc1a$export$ae14931f0a0256a3(groupId) {
163
+ return Array.from(document.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${groupId}"]`));
164
+ }
165
+ function $f30c804b5fe6cc1a$export$68d3a33c21dfbe27(groupId, handleId, panelsArray) {
166
+ const handle = $f30c804b5fe6cc1a$export$2e27d3a347680388(handleId);
167
+ const handles = $f30c804b5fe6cc1a$export$ae14931f0a0256a3(groupId);
168
+ const index = handles.indexOf(handle);
169
+ const idBefore = panelsArray[index]?.id ?? null;
170
+ const idAfter = panelsArray[index + 1]?.id ?? null;
171
+ return [
172
+ idBefore,
173
+ idAfter
174
+ ];
175
+ }
176
+ function $f30c804b5fe6cc1a$export$a861c0ad45885494(panels) {
177
+ return Array.from(panels.values()).sort((a, b)=>a.order - b.order);
178
+ }
179
+ function $f30c804b5fe6cc1a$export$31b21d0167753bb4(panels, id, direction, sizes, height, width) {
180
+ const totalSize = direction === "horizontal" ? width : height;
181
+ if (panels.size === 1) return totalSize;
182
+ const panelsArray = $f30c804b5fe6cc1a$export$a861c0ad45885494(panels);
183
+ const index = panelsArray.findIndex((panel)=>panel.id === id);
184
+ const size = sizes[index];
185
+ if (size == null) return 0;
186
+ return Math.round(size * totalSize);
187
+ }
188
+
189
+
190
+ const $96f6397ae645d178$var$element = document.createElement("div");
191
+ $96f6397ae645d178$var$element.getBoundingClientRect();
192
+ function $96f6397ae645d178$export$354b17c0684607ed(event, handleId, { height: height , width: width }, direction) {
193
+ const isHorizontal = direction === "horizontal";
194
+ const size = isHorizontal ? width : height;
195
+ if ($96f6397ae645d178$export$e7bf60a870f429b0(event)) {
196
+ const denominator = event.shiftKey ? 10 : 100;
197
+ const delta = size / denominator;
198
+ switch(event.key){
199
+ case "ArrowDown":
200
+ return delta;
201
+ case "ArrowLeft":
202
+ return -delta;
203
+ case "ArrowRight":
204
+ return delta;
205
+ case "ArrowUp":
206
+ return -delta;
207
+ case "End":
208
+ if (isHorizontal) return size;
209
+ else return size;
210
+ case "Home":
211
+ if (isHorizontal) return -size;
212
+ else return -size;
213
+ }
214
+ } else {
215
+ const handleElement = (0, $f30c804b5fe6cc1a$export$2e27d3a347680388)(handleId);
216
+ const rect = handleElement.getBoundingClientRect();
217
+ const elementOffset = isHorizontal ? rect.left : rect.top;
218
+ let pointerOffset = 0;
219
+ if ($96f6397ae645d178$export$5107d838cdd17dee(event)) pointerOffset = isHorizontal ? event.clientX : event.clientY;
220
+ else {
221
+ const firstTouch = event.touches[0];
222
+ pointerOffset = isHorizontal ? firstTouch.screenX : firstTouch.screenY;
223
+ }
224
+ return pointerOffset - elementOffset;
101
225
  }
102
- return {
103
- movementX: getMovementBetween(event.screenX, prevScreenX),
104
- movementY: getMovementBetween(event.screenY, prevScreenY),
105
- screenX: event.screenX,
106
- screenY: event.screenY
107
- };
108
226
  }
109
- function $4b6140a59f4bd98c$export$ce897e7f0aa63661(event) {
227
+ function $96f6397ae645d178$export$e7bf60a870f429b0(event) {
228
+ return event.type === "keydown";
229
+ }
230
+ function $96f6397ae645d178$export$5107d838cdd17dee(event) {
231
+ return event.type === "mousemove";
232
+ }
233
+ function $96f6397ae645d178$export$ce897e7f0aa63661(event) {
110
234
  return event.type === "touchmove";
111
235
  }
112
236
 
113
237
 
114
- const $c44ee3356398c8a1$var$PRECISION = 5;
238
+
239
+
240
+
241
+
242
+ function $99ad02c951ec80d0$export$d9fcbe062527d159({ committedValuesRef: committedValuesRef , groupId: groupId , panels: panels , setSizes: setSizes , sizes: sizes }) {
243
+ (0, $fpI56$useEffect)(()=>{
244
+ const { direction: direction , height: height , panels: panels , width: width } = committedValuesRef.current;
245
+ const handles = (0, $f30c804b5fe6cc1a$export$ae14931f0a0256a3)(groupId);
246
+ const cleanupFunctions = handles.map((handle)=>{
247
+ const handleId = handle.getAttribute("data-panel-resize-handle-id");
248
+ const panelsArray = (0, $f30c804b5fe6cc1a$export$a861c0ad45885494)(panels);
249
+ const [idBefore, idAfter] = (0, $f30c804b5fe6cc1a$export$68d3a33c21dfbe27)(groupId, handleId, panelsArray);
250
+ if (idBefore == null || idAfter == null) return ()=>{};
251
+ const ariaValueMax = panelsArray.reduce((difference, panel)=>{
252
+ if (panel.id !== idBefore) return difference - panel.minSize;
253
+ return difference;
254
+ }, 1);
255
+ const ariaValueMin = panelsArray.find((panel)=>panel.id == idBefore)?.minSize ?? 0;
256
+ const size = (0, $f30c804b5fe6cc1a$export$31b21d0167753bb4)(panels, idBefore, direction, sizes, height, width);
257
+ const ariaValueNow = size / (direction === "horizontal" ? width : height);
258
+ handle.setAttribute("aria-valuemax", "" + Math.round(100 * ariaValueMax));
259
+ handle.setAttribute("aria-valuemin", "" + Math.round(100 * ariaValueMin));
260
+ handle.setAttribute("aria-valuenow", "" + Math.round(100 * ariaValueNow));
261
+ const onKeyDown = (event)=>{
262
+ switch(event.key){
263
+ case "Enter":
264
+ {
265
+ const index = panelsArray.findIndex((panel)=>panel.id === idBefore);
266
+ if (index >= 0) {
267
+ const panelData = panelsArray[index];
268
+ const size = sizes[index];
269
+ if (size != null) {
270
+ let delta = 0;
271
+ if (size.toPrecision((0, $fc25b75732bfda27$export$d6d3992f3becc879)) <= panelData.minSize.toPrecision((0, $fc25b75732bfda27$export$d6d3992f3becc879))) delta = direction === "horizontal" ? width : height;
272
+ else delta = -(direction === "horizontal" ? width : height);
273
+ const nextSizes = (0, $f30c804b5fe6cc1a$export$f50bae335f53943c)(panels, idBefore, idAfter, delta, sizes);
274
+ if (sizes !== nextSizes) setSizes(nextSizes);
275
+ }
276
+ }
277
+ break;
278
+ }
279
+ }
280
+ };
281
+ handle.addEventListener("keydown", onKeyDown);
282
+ const panelBefore = (0, $f30c804b5fe6cc1a$export$7361ed18ff57179e)(idBefore);
283
+ if (panelBefore != null) handle.setAttribute("aria-controls", panelBefore.id);
284
+ return ()=>{
285
+ handle.removeAttribute("aria-valuemax");
286
+ handle.removeAttribute("aria-valuemin");
287
+ handle.removeAttribute("aria-valuenow");
288
+ handle.removeEventListener("keydown", onKeyDown);
289
+ if (panelBefore != null) handle.removeAttribute("aria-controls");
290
+ };
291
+ });
292
+ return ()=>{
293
+ cleanupFunctions.forEach((cleanupFunction)=>cleanupFunction());
294
+ };
295
+ }, [
296
+ groupId,
297
+ panels,
298
+ sizes
299
+ ]);
300
+ }
301
+ function $99ad02c951ec80d0$export$33b0bea6ac3ffb03({ disabled: disabled , handleId: handleId , resizeHandler: resizeHandler }) {
302
+ (0, $fpI56$useEffect)(()=>{
303
+ if (disabled || resizeHandler == null) return;
304
+ const handleElement = (0, $f30c804b5fe6cc1a$export$2e27d3a347680388)(handleId);
305
+ if (handleElement == null) return;
306
+ const onKeyDown = (event)=>{
307
+ switch(event.key){
308
+ case "ArrowDown":
309
+ case "ArrowLeft":
310
+ case "ArrowRight":
311
+ case "ArrowUp":
312
+ case "End":
313
+ case "Home":
314
+ resizeHandler(event);
315
+ break;
316
+ case "F6":
317
+ {
318
+ const handles = (0, $f30c804b5fe6cc1a$export$8d0cd3c32ddc045e)();
319
+ const index = (0, $f30c804b5fe6cc1a$export$96a40be80fb6c3c8)(handleId);
320
+ const nextIndex = event.shiftKey ? index > 0 ? index - 1 : handles.length - 1 : index + 1 < handles.length ? index + 1 : 0;
321
+ const nextHandle = handles[nextIndex];
322
+ nextHandle.focus();
323
+ break;
324
+ }
325
+ }
326
+ };
327
+ handleElement.addEventListener("keydown", onKeyDown);
328
+ return ()=>{
329
+ handleElement.removeEventListener("keydown", onKeyDown);
330
+ };
331
+ }, [
332
+ disabled,
333
+ handleId,
334
+ resizeHandler
335
+ ]);
336
+ }
337
+
338
+
115
339
  function $c44ee3356398c8a1$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , children: children = null , className: className = "" , direction: direction , height: height , width: width }) {
116
340
  const groupId = (0, $968185313205dcfa$export$2e2bcd8739ae039)();
117
341
  const [activeHandleId, setActiveHandleId] = (0, $fpI56$useState)(null);
@@ -126,12 +350,6 @@ function $c44ee3356398c8a1$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
126
350
  sizes: sizes,
127
351
  width: width
128
352
  });
129
- // Tracks the most recent coordinates of a touch/mouse event.
130
- // This is needed to calculate movement (because TouchEvent doesn't support movementX and movementY).
131
- const prevCoordinatesRef = (0, $fpI56$useRef)({
132
- screenX: 0,
133
- screenY: 0
134
- });
135
353
  (0, $fpI56$useLayoutEffect)(()=>{
136
354
  committedValuesRef.current.direction = direction;
137
355
  committedValuesRef.current.height = height;
@@ -139,6 +357,13 @@ function $c44ee3356398c8a1$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
139
357
  committedValuesRef.current.sizes = sizes;
140
358
  committedValuesRef.current.width = width;
141
359
  });
360
+ (0, $99ad02c951ec80d0$export$d9fcbe062527d159)({
361
+ committedValuesRef: committedValuesRef,
362
+ groupId: groupId,
363
+ panels: panels,
364
+ setSizes: setSizes,
365
+ sizes: sizes
366
+ });
142
367
  // Once all panels have registered themselves,
143
368
  // Compute the initial sizes based on default weights.
144
369
  // This assumes that panels register during initial mount (no conditional rendering)!
@@ -151,12 +376,12 @@ function $c44ee3356398c8a1$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
151
376
  // default size should be restored from local storage if possible.
152
377
  let defaultSizes = undefined;
153
378
  if (autoSaveId) {
154
- const panelIds = $c44ee3356398c8a1$var$panelsMapToSortedArray(panels).map((panel)=>panel.id);
379
+ const panelIds = (0, $f30c804b5fe6cc1a$export$a861c0ad45885494)(panels).map((panel)=>panel.id);
155
380
  defaultSizes = (0, $6ff1a22b27cc039d$export$9c80c6617f0386da)(autoSaveId, panelIds);
156
381
  }
157
382
  if (defaultSizes != null) setSizes(defaultSizes);
158
383
  else {
159
- const panelsArray = $c44ee3356398c8a1$var$panelsMapToSortedArray(panels);
384
+ const panelsArray = (0, $f30c804b5fe6cc1a$export$a861c0ad45885494)(panels);
160
385
  const totalWeight = panelsArray.reduce((weight, panel)=>{
161
386
  return weight + panel.defaultSize;
162
387
  }, 0);
@@ -170,7 +395,7 @@ function $c44ee3356398c8a1$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
170
395
  // If this panel has been configured to persist sizing information, save sizes to local storage.
171
396
  if (autoSaveId) {
172
397
  if (sizes.length === 0 || sizes.length !== panels.size) return;
173
- const panelIds = $c44ee3356398c8a1$var$panelsMapToSortedArray(panels).map((panel)=>panel.id);
398
+ const panelIds = (0, $f30c804b5fe6cc1a$export$a861c0ad45885494)(panels).map((panel)=>panel.id);
174
399
  (0, $6ff1a22b27cc039d$export$af183b313c61be4f)(autoSaveId, panelIds, sizes);
175
400
  }
176
401
  }, [
@@ -180,8 +405,8 @@ function $c44ee3356398c8a1$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
180
405
  ]);
181
406
  const getPanelStyle = (0, $fpI56$useCallback)((id)=>{
182
407
  const { panels: panels } = committedValuesRef.current;
183
- const offset = $c44ee3356398c8a1$var$getOffset(panels, id, direction, sizes, height, width);
184
- const size = $c44ee3356398c8a1$var$getSize(panels, id, direction, sizes, height, width);
408
+ const offset = (0, $f30c804b5fe6cc1a$export$622cea445a1c5b7d)(panels, id, direction, sizes, height, width);
409
+ const size = (0, $f30c804b5fe6cc1a$export$31b21d0167753bb4)(panels, id, direction, sizes, height, width);
185
410
  if (direction === "horizontal") return {
186
411
  height: "100%",
187
412
  position: "absolute",
@@ -210,26 +435,20 @@ function $c44ee3356398c8a1$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
210
435
  return nextPanels;
211
436
  });
212
437
  }, []);
213
- const registerResizeHandle = (0, $fpI56$useCallback)((id)=>{
438
+ const registerResizeHandle = (0, $fpI56$useCallback)((handleId)=>{
214
439
  const resizeHandler = (event)=>{
215
440
  event.preventDefault();
216
441
  const { direction: direction , height: height , panels: panels , sizes: prevSizes , width: width } = committedValuesRef.current;
217
- const handle = document.querySelector(`[data-panel-resize-handle-id="${id}"]`);
218
- const handles = Array.from(document.querySelectorAll(`[data-panel-group-id="${groupId}"]`));
219
- const index = handles.indexOf(handle);
220
- const panelsArray = $c44ee3356398c8a1$var$panelsMapToSortedArray(panels);
221
- const idBefore = panelsArray[index]?.id ?? null;
222
- const idAfter = panelsArray[index + 1]?.id ?? null;
442
+ const panelsArray = (0, $f30c804b5fe6cc1a$export$a861c0ad45885494)(panels);
443
+ const [idBefore, idAfter] = (0, $f30c804b5fe6cc1a$export$68d3a33c21dfbe27)(groupId, handleId, panelsArray);
223
444
  if (idBefore == null || idAfter == null) return;
224
- const nextCoordinates = (0, $4b6140a59f4bd98c$export$70637efcd850e4ef)(event, prevCoordinatesRef.current);
225
- prevCoordinatesRef.current = {
226
- screenX: nextCoordinates.screenX,
227
- screenY: nextCoordinates.screenY
228
- };
445
+ const movement = (0, $96f6397ae645d178$export$354b17c0684607ed)(event, handleId, {
446
+ height: height,
447
+ width: width
448
+ }, direction);
229
449
  const isHorizontal = direction === "horizontal";
230
- const movement = isHorizontal ? nextCoordinates.movementX : nextCoordinates.movementY;
231
450
  const delta = isHorizontal ? movement / width : movement / height;
232
- const nextSizes = $c44ee3356398c8a1$var$adjustByDelta(panels, idBefore, idAfter, delta, prevSizes);
451
+ const nextSizes = (0, $f30c804b5fe6cc1a$export$f50bae335f53943c)(panels, idBefore, idAfter, delta, prevSizes);
233
452
  if (prevSizes !== nextSizes) setSizes(nextSizes);
234
453
  };
235
454
  return resizeHandler;
@@ -253,10 +472,6 @@ function $c44ee3356398c8a1$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
253
472
  startDragging: (id)=>setActiveHandleId(id),
254
473
  stopDragging: ()=>{
255
474
  setActiveHandleId(null);
256
- prevCoordinatesRef.current = {
257
- screenX: 0,
258
- screenY: 0
259
- };
260
475
  },
261
476
  unregisterPanel: unregisterPanel
262
477
  }), [
@@ -281,81 +496,21 @@ function $c44ee3356398c8a1$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
281
496
  children: children
282
497
  }, void 0, false, {
283
498
  fileName: "packages/react-resizable-panels/src/PanelGroup.tsx",
284
- lineNumber: 273,
499
+ lineNumber: 272,
285
500
  columnNumber: 9
286
501
  }, this)
287
502
  }, void 0, false, {
288
503
  fileName: "packages/react-resizable-panels/src/PanelGroup.tsx",
289
- lineNumber: 272,
504
+ lineNumber: 271,
290
505
  columnNumber: 7
291
506
  }, this)
292
507
  }, void 0, false, {
293
508
  fileName: "packages/react-resizable-panels/src/PanelGroup.tsx",
294
- lineNumber: 271,
509
+ lineNumber: 270,
295
510
  columnNumber: 5
296
511
  }, this);
297
512
  }
298
- function $c44ee3356398c8a1$var$adjustByDelta(panels, idBefore, idAfter, delta, prevSizes) {
299
- if (delta === 0) return prevSizes;
300
- const panelsArray = $c44ee3356398c8a1$var$panelsMapToSortedArray(panels);
301
- const nextSizes = prevSizes.concat();
302
- let deltaApplied = 0;
303
- // A resizing panel affects the panels before or after it.
304
- //
305
- // A negative delta means the panel immediately after the resizer should grow/expand by decreasing its offset.
306
- // Other panels may also need to shrink/contract (and shift) to make room, depending on the min weights.
307
- //
308
- // A positive delta means the panel immediately before the resizer should "expand".
309
- // This is accomplished by shrinking/contracting (and shifting) one or more of the panels after the resizer.
310
- let pivotId = delta < 0 ? idBefore : idAfter;
311
- let index = panelsArray.findIndex((panel)=>panel.id === pivotId);
312
- while(true){
313
- const panel = panelsArray[index];
314
- const prevSize = prevSizes[index];
315
- const nextSize = Math.max(prevSize - Math.abs(delta), panel.minSize);
316
- if (prevSize !== nextSize) {
317
- deltaApplied += prevSize - nextSize;
318
- nextSizes[index] = nextSize;
319
- if (deltaApplied.toPrecision($c44ee3356398c8a1$var$PRECISION) >= delta.toPrecision($c44ee3356398c8a1$var$PRECISION)) break;
320
- }
321
- if (delta < 0) {
322
- if (--index < 0) break;
323
- } else {
324
- if (++index >= panelsArray.length) break;
325
- }
326
- }
327
- // If we were unable to resize any of the panels panels, return the previous state.
328
- // This will essentially bailout and ignore the "mousemove" event.
329
- if (deltaApplied === 0) return prevSizes;
330
- // Adjust the pivot panel before, but only by the amount that surrounding panels were able to shrink/contract.
331
- pivotId = delta < 0 ? idAfter : idBefore;
332
- index = panelsArray.findIndex((panel)=>panel.id === pivotId);
333
- nextSizes[index] = prevSizes[index] + deltaApplied;
334
- return nextSizes;
335
- }
336
- function $c44ee3356398c8a1$var$getOffset(panels, id, direction, sizes, height, width) {
337
- const panelsArray = $c44ee3356398c8a1$var$panelsMapToSortedArray(panels);
338
- let index = panelsArray.findIndex((panel)=>panel.id === id);
339
- if (index < 0) return 0;
340
- let scaledOffset = 0;
341
- for(index = index - 1; index >= 0; index--){
342
- const panel = panelsArray[index];
343
- scaledOffset += $c44ee3356398c8a1$var$getSize(panels, panel.id, direction, sizes, height, width);
344
- }
345
- return Math.round(scaledOffset);
346
- }
347
- function $c44ee3356398c8a1$var$getSize(panels, id, direction, sizes, height, width) {
348
- const totalSize = direction === "horizontal" ? width : height;
349
- if (panels.size === 1) return totalSize;
350
- const panelsArray = $c44ee3356398c8a1$var$panelsMapToSortedArray(panels);
351
- const index = panelsArray.findIndex((panel)=>panel.id === id);
352
- const size = sizes[index];
353
- if (size == null) return 0;
354
- return Math.round(size * totalSize);
355
- }
356
- function $c44ee3356398c8a1$var$panelsMapToSortedArray(panels) {
357
- return Array.from(panels.values()).sort((a, b)=>a.order - b.order);
358
- }
513
+
359
514
 
360
515
 
361
516
 
@@ -363,6 +518,7 @@ function $c44ee3356398c8a1$var$panelsMapToSortedArray(panels) {
363
518
 
364
519
 
365
520
  function $b067b37706bb37b8$export$2e2bcd8739ae039({ children: children = null , className: className = "" , disabled: disabled = false , id: idProp = null }) {
521
+ const divElementRef = (0, $b067b37706bb37b8$import$65588215f5c347c3$b8f5890fc79d6aca)(null);
366
522
  const panelContext = (0, $fpI56$useContext)((0, $f922724f4bad4884$export$f34532ac99e32150));
367
523
  const panelGroupContext = (0, $fpI56$useContext)((0, $f922724f4bad4884$export$7d8c6d083caec74a));
368
524
  if (panelContext === null || panelGroupContext === null) throw Error(`PanelResizeHandle components must be rendered within a PanelGroup container`);
@@ -371,6 +527,15 @@ function $b067b37706bb37b8$export$2e2bcd8739ae039({ children: children = null ,
371
527
  const { direction: direction , groupId: groupId , registerResizeHandle: registerResizeHandle , startDragging: startDragging , stopDragging: stopDragging } = panelGroupContext;
372
528
  const isDragging = activeHandleId === id;
373
529
  const [resizeHandler, setResizeHandler] = (0, $fpI56$useState)(null);
530
+ const stopDraggingAndBlur = (0, $b067b37706bb37b8$import$65588215f5c347c3$35808ee640e87ca7)(()=>{
531
+ // Clicking on the drag handle shouldn't leave it focused;
532
+ // That would cause the PanelGroup to think it was still active.
533
+ const div = divElementRef.current;
534
+ div.blur();
535
+ stopDragging();
536
+ }, [
537
+ stopDragging
538
+ ]);
374
539
  (0, $fpI56$useEffect)(()=>{
375
540
  if (disabled) setResizeHandler(null);
376
541
  else {
@@ -379,7 +544,6 @@ function $b067b37706bb37b8$export$2e2bcd8739ae039({ children: children = null ,
379
544
  }
380
545
  }, [
381
546
  disabled,
382
- groupId,
383
547
  id,
384
548
  registerResizeHandle
385
549
  ]);
@@ -389,41 +553,50 @@ function $b067b37706bb37b8$export$2e2bcd8739ae039({ children: children = null ,
389
553
  const onMove = (event)=>{
390
554
  resizeHandler(event);
391
555
  };
392
- document.body.addEventListener("mouseleave", stopDragging);
556
+ document.body.addEventListener("mouseleave", stopDraggingAndBlur);
393
557
  document.body.addEventListener("mousemove", onMove);
394
558
  document.body.addEventListener("touchmove", onMove);
395
- document.body.addEventListener("mouseup", stopDragging);
559
+ document.body.addEventListener("mouseup", stopDraggingAndBlur);
396
560
  return ()=>{
397
561
  document.body.style.cursor = "";
398
- document.body.removeEventListener("mouseleave", stopDragging);
562
+ document.body.removeEventListener("mouseleave", stopDraggingAndBlur);
399
563
  document.body.removeEventListener("mousemove", onMove);
400
564
  document.body.removeEventListener("touchmove", onMove);
401
- document.body.removeEventListener("mouseup", stopDragging);
565
+ document.body.removeEventListener("mouseup", stopDraggingAndBlur);
402
566
  };
403
567
  }, [
404
568
  direction,
405
569
  disabled,
406
570
  isDragging,
407
571
  resizeHandler,
408
- stopDragging
572
+ stopDraggingAndBlur
409
573
  ]);
574
+ (0, $99ad02c951ec80d0$export$33b0bea6ac3ffb03)({
575
+ disabled: disabled,
576
+ handleId: id,
577
+ resizeHandler: resizeHandler
578
+ });
410
579
  return /*#__PURE__*/ (0, $fpI56$jsxDEV)("div", {
411
580
  className: className,
412
581
  "data-panel-group-id": groupId,
582
+ "data-panel-resize-handle-enabled": !disabled,
413
583
  "data-panel-resize-handle-id": id,
414
584
  onMouseDown: ()=>startDragging(id),
415
- onMouseUp: stopDragging,
416
- onTouchCancel: stopDragging,
417
- onTouchEnd: stopDragging,
585
+ onMouseUp: stopDraggingAndBlur,
586
+ onTouchCancel: stopDraggingAndBlur,
587
+ onTouchEnd: stopDraggingAndBlur,
418
588
  onTouchStart: ()=>startDragging(id),
589
+ ref: divElementRef,
590
+ role: "separator",
419
591
  style: {
420
592
  cursor: direction === "horizontal" ? "ew-resize" : "ns-resize",
421
593
  touchAction: "none"
422
594
  },
595
+ tabIndex: 0,
423
596
  children: children
424
597
  }, void 0, false, {
425
598
  fileName: "packages/react-resizable-panels/src/PanelResizeHandle.tsx",
426
- lineNumber: 80,
599
+ lineNumber: 105,
427
600
  columnNumber: 5
428
601
  }, this);
429
602
  }