react-resizable-panels 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,11 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.0.9
4
+ * [#13](https://github.com/bvaughn/react-resizable-panels/issues/13): `PanelResizeHandle` should declare "separator" role and implement the recommended ["Window Splitter" pattern](https://www.w3.org/WAI/ARIA/apg/patterns/windowsplitter/)
5
+
6
+ ## 0.0.8
7
+ * [#7](https://github.com/bvaughn/react-resizable-panels/issues/7): Support "touch" events for mobile compatibility.
8
+
3
9
  ## 0.0.7
4
10
  * Add `PanelContext` with `activeHandleId` property identifying the resize handle currently being dragged (or `null`). This enables more customized UI/UX when resizing is in progress.
5
11
  ## 0.0.6
6
12
  * [#5](https://github.com/bvaughn/react-resizable-panels/issues/5): Removed `panelBefore` and `panelAfter` props from `PanelResizeHandle`. `PanelGroup` now infers this based on position within the group.
7
13
  ## 0.0.5
8
- * TypeScript props type fix
14
+ * TypeScript props type fix for `PanelGroup`'s `children` prop.
9
15
 
10
16
  ## 0.0.4
11
17
  * [#8](https://github.com/bvaughn/react-resizable-panels/issues/8): Added optional `order` prop to `Panel` to improve conditional rendering.
@@ -1 +1 @@
1
- {"mappings":";AAAA,iBAAwB,YAAY,GAAG,UAAU,CAAC;ACIlD,OAAO,MAAM;oBACK,MAAM,GAAG,IAAI;EAChB,CAAC;ACChB,sBAA8B,EAC5B,QAAe,EACf,SAAc,EACd,WAAiB,EACjB,EAAE,EACF,OAAa,EACb,KAAY,GACb,EAAE;IACD,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,eAwCA;AE9CD,aAAa;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,SAAS,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAQF,2BAAmC,EACjC,UAAU,EACV,QAAe,EACf,SAAc,EACd,SAAS,EACT,MAAM,EACN,KAAK,GACN,EAAE,KAAK,eAqNP;ACpPD,kCAA0C,EACxC,QAAe,EACf,SAAc,EACd,QAAgB,EAChB,EAAE,EAAE,MAAa,GAClB,EAAE;IACD,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACpB,eA6EA","sources":["packages/react-resizable-panels/src/src/types.ts","packages/react-resizable-panels/src/src/PanelContexts.ts","packages/react-resizable-panels/src/src/Panel.tsx","packages/react-resizable-panels/src/src/hooks/useUniqueId.ts","packages/react-resizable-panels/src/src/PanelGroup.tsx","packages/react-resizable-panels/src/src/PanelResizeHandle.tsx","packages/react-resizable-panels/src/src/index.ts","packages/react-resizable-panels/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,"import Panel from \"./Panel\";\nimport { PanelContext } from \"./PanelContexts\";\nimport PanelGroup from \"./PanelGroup\";\nimport PanelResizeHandle from \"./PanelResizeHandle\";\n\nexport { Panel, PanelContext, PanelGroup, PanelResizeHandle };\n"],"names":[],"version":3,"file":"react-resizable-panels.d.ts.map","sourceRoot":"../../../"}
1
+ {"mappings":";AAAA,iBAAwB,YAAY,GAAG,UAAU,CAAC;ACIlD,OAAO,MAAM;oBACK,MAAM,GAAG,IAAI;EAChB,CAAC;ACChB,sBAA8B,EAC5B,QAAe,EACf,SAAc,EACd,WAAiB,EACjB,EAAE,EACF,OAAa,EACb,KAAY,GACb,EAAE;IACD,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,eA6CA;AO/BD,aAAa;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,SAAS,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAMF,2BAAmC,EACjC,UAAU,EACV,QAAe,EACf,SAAc,EACd,SAAS,EACT,MAAM,EACN,KAAK,GACN,EAAE,KAAK,eA8OP;AC9RD,kCAA0C,EACxC,QAAe,EACf,SAAc,EACd,QAAgB,EAChB,EAAE,EAAE,MAAa,GAClB,EAAE;IACD,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACpB,eAyFA","sources":["packages/react-resizable-panels/src/src/types.ts","packages/react-resizable-panels/src/src/PanelContexts.ts","packages/react-resizable-panels/src/src/Panel.tsx","packages/react-resizable-panels/src/src/hooks/useUniqueId.ts","packages/react-resizable-panels/src/src/utils/serialization.ts","packages/react-resizable-panels/src/src/utils/coordinates.ts","packages/react-resizable-panels/src/src/constants.ts","packages/react-resizable-panels/src/src/utils/group.ts","packages/react-resizable-panels/src/src/hooks/useWindowSplitterBehavior.ts","packages/react-resizable-panels/src/src/PanelGroup.tsx","packages/react-resizable-panels/src/src/PanelResizeHandle.tsx","packages/react-resizable-panels/src/src/index.ts","packages/react-resizable-panels/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,"import Panel from \"./Panel\";\nimport { PanelContext } from \"./PanelContexts\";\nimport PanelGroup from \"./PanelGroup\";\nimport PanelResizeHandle from \"./PanelResizeHandle\";\n\nexport { Panel, PanelContext, PanelGroup, PanelResizeHandle };\n"],"names":[],"version":3,"file":"react-resizable-panels.d.ts.map","sourceRoot":"../../../"}
@@ -46,6 +46,8 @@ function $6d390b7f2e6b107f$export$2e2bcd8739ae039({ children: children = null ,
46
46
  const style = getPanelStyle(id);
47
47
  return /*#__PURE__*/ (0, $b2QPe$reactjsxdevruntime.jsxDEV)("div", {
48
48
  className: className,
49
+ "data-panel-id": id,
50
+ id: `data-panel-id-${id}`,
49
51
  style: style,
50
52
  children: children
51
53
  }, void 0, false, {
@@ -95,7 +97,280 @@ function $e045b0dd313f33c7$export$af183b313c61be4f(autoSaveId, panelIds, sizes)
95
97
  }
96
98
 
97
99
 
98
- const $d428eaeef644efb2$var$PRECISION = 5;
100
+ const $f5af57c8e042a4ad$var$element = document.createElement("div");
101
+ $f5af57c8e042a4ad$var$element.getBoundingClientRect();
102
+ function $f5af57c8e042a4ad$export$70637efcd850e4ef(event, prevCoordinates, dimensions, direction) {
103
+ const { screenX: prevScreenX , screenY: prevScreenY } = prevCoordinates;
104
+ const { height: height , width: width } = dimensions;
105
+ const getMovementBetween = (current, prev)=>prev === 0 ? 0 : current - prev;
106
+ if ($f5af57c8e042a4ad$export$e7bf60a870f429b0(event)) {
107
+ let movementX = 0;
108
+ let movementY = 0;
109
+ const size = direction === "horizontal" ? width : height;
110
+ const denominator = event.shiftKey ? 10 : 100;
111
+ const delta = size / denominator;
112
+ switch(event.key){
113
+ case "ArrowDown":
114
+ movementY = delta;
115
+ break;
116
+ case "ArrowLeft":
117
+ movementX = -delta;
118
+ break;
119
+ case "ArrowRight":
120
+ movementX = delta;
121
+ break;
122
+ case "ArrowUp":
123
+ movementY = -delta;
124
+ break;
125
+ case "End":
126
+ if (direction === "horizontal") movementX = size;
127
+ else movementY = size;
128
+ break;
129
+ case "Home":
130
+ if (direction === "horizontal") movementX = -size;
131
+ else movementY = -size;
132
+ break;
133
+ }
134
+ // Estimate screen X/Y to be the center of the resize handle.
135
+ // Otherwise the first mouse/touch event after a keyboard event will appear to "jump"
136
+ let screenX = 0;
137
+ let screenY = 0;
138
+ if (document.activeElement) {
139
+ const rect = document.activeElement.getBoundingClientRect();
140
+ screenX = rect.left + rect.width / 2;
141
+ screenY = rect.top + rect.height / 2;
142
+ }
143
+ return {
144
+ movementX: movementX,
145
+ movementY: movementY,
146
+ screenX: screenX,
147
+ screenY: screenY
148
+ };
149
+ } else if ($f5af57c8e042a4ad$export$ce897e7f0aa63661(event)) {
150
+ const firstTouch = event.touches[0];
151
+ return {
152
+ movementX: getMovementBetween(firstTouch.screenX, prevScreenX),
153
+ movementY: getMovementBetween(firstTouch.screenY, prevScreenY),
154
+ screenX: firstTouch.screenX,
155
+ screenY: firstTouch.screenY
156
+ };
157
+ } else if ($f5af57c8e042a4ad$export$5107d838cdd17dee(event)) return {
158
+ movementX: getMovementBetween(event.screenX, prevScreenX),
159
+ movementY: getMovementBetween(event.screenY, prevScreenY),
160
+ screenX: event.screenX,
161
+ screenY: event.screenY
162
+ };
163
+ else throw Error(`Unsupported event type: "${event.type}"`);
164
+ }
165
+ function $f5af57c8e042a4ad$export$e7bf60a870f429b0(event) {
166
+ return event.type === "keydown";
167
+ }
168
+ function $f5af57c8e042a4ad$export$5107d838cdd17dee(event) {
169
+ return event.type === "mousemove";
170
+ }
171
+ function $f5af57c8e042a4ad$export$ce897e7f0aa63661(event) {
172
+ return event.type === "touchmove";
173
+ }
174
+
175
+
176
+ const $3237bc4a138172cd$export$d6d3992f3becc879 = 5;
177
+
178
+
179
+ function $d520236daad9c5d5$export$f50bae335f53943c(panels, idBefore, idAfter, delta, prevSizes) {
180
+ if (delta === 0) return prevSizes;
181
+ const panelsArray = $d520236daad9c5d5$export$a861c0ad45885494(panels);
182
+ const nextSizes = prevSizes.concat();
183
+ let deltaApplied = 0;
184
+ // A resizing panel affects the panels before or after it.
185
+ //
186
+ // A negative delta means the panel immediately after the resizer should grow/expand by decreasing its offset.
187
+ // Other panels may also need to shrink/contract (and shift) to make room, depending on the min weights.
188
+ //
189
+ // A positive delta means the panel immediately before the resizer should "expand".
190
+ // This is accomplished by shrinking/contracting (and shifting) one or more of the panels after the resizer.
191
+ let pivotId = delta < 0 ? idBefore : idAfter;
192
+ let index = panelsArray.findIndex((panel)=>panel.id === pivotId);
193
+ while(true){
194
+ const panel = panelsArray[index];
195
+ const prevSize = prevSizes[index];
196
+ const nextSize = Math.max(prevSize - Math.abs(delta), panel.minSize);
197
+ if (prevSize !== nextSize) {
198
+ deltaApplied += prevSize - nextSize;
199
+ nextSizes[index] = nextSize;
200
+ if (deltaApplied.toPrecision((0, $3237bc4a138172cd$export$d6d3992f3becc879)) >= delta.toPrecision((0, $3237bc4a138172cd$export$d6d3992f3becc879))) break;
201
+ }
202
+ if (delta < 0) {
203
+ if (--index < 0) break;
204
+ } else {
205
+ if (++index >= panelsArray.length) break;
206
+ }
207
+ }
208
+ // If we were unable to resize any of the panels panels, return the previous state.
209
+ // This will essentially bailout and ignore the "mousemove" event.
210
+ if (deltaApplied === 0) return prevSizes;
211
+ // Adjust the pivot panel before, but only by the amount that surrounding panels were able to shrink/contract.
212
+ pivotId = delta < 0 ? idAfter : idBefore;
213
+ index = panelsArray.findIndex((panel)=>panel.id === pivotId);
214
+ nextSizes[index] = prevSizes[index] + deltaApplied;
215
+ return nextSizes;
216
+ }
217
+ function $d520236daad9c5d5$export$622cea445a1c5b7d(panels, id, direction, sizes, height, width) {
218
+ const panelsArray = $d520236daad9c5d5$export$a861c0ad45885494(panels);
219
+ let index = panelsArray.findIndex((panel)=>panel.id === id);
220
+ if (index < 0) return 0;
221
+ let scaledOffset = 0;
222
+ for(index = index - 1; index >= 0; index--){
223
+ const panel = panelsArray[index];
224
+ scaledOffset += $d520236daad9c5d5$export$31b21d0167753bb4(panels, panel.id, direction, sizes, height, width);
225
+ }
226
+ return Math.round(scaledOffset);
227
+ }
228
+ function $d520236daad9c5d5$export$7361ed18ff57179e(id) {
229
+ const element = document.querySelector(`[data-panel-id="${id}"]`);
230
+ if (element) return element;
231
+ return null;
232
+ }
233
+ function $d520236daad9c5d5$export$2e27d3a347680388(id) {
234
+ const element = document.querySelector(`[data-panel-resize-handle-id="${id}"]`);
235
+ if (element) return element;
236
+ return null;
237
+ }
238
+ function $d520236daad9c5d5$export$96a40be80fb6c3c8(id) {
239
+ const handles = $d520236daad9c5d5$export$8d0cd3c32ddc045e();
240
+ const index = handles.findIndex((handle)=>handle.getAttribute("data-panel-resize-handle-id") === id);
241
+ return index ?? null;
242
+ }
243
+ function $d520236daad9c5d5$export$8d0cd3c32ddc045e() {
244
+ return Array.from(document.querySelectorAll(`[data-panel-resize-handle-id]`));
245
+ }
246
+ function $d520236daad9c5d5$export$ae14931f0a0256a3(groupId) {
247
+ return Array.from(document.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${groupId}"]`));
248
+ }
249
+ function $d520236daad9c5d5$export$68d3a33c21dfbe27(groupId, handleId, panelsArray) {
250
+ const handle = $d520236daad9c5d5$export$2e27d3a347680388(handleId);
251
+ const handles = $d520236daad9c5d5$export$ae14931f0a0256a3(groupId);
252
+ const index = handles.indexOf(handle);
253
+ const idBefore = panelsArray[index]?.id ?? null;
254
+ const idAfter = panelsArray[index + 1]?.id ?? null;
255
+ return [
256
+ idBefore,
257
+ idAfter
258
+ ];
259
+ }
260
+ function $d520236daad9c5d5$export$a861c0ad45885494(panels) {
261
+ return Array.from(panels.values()).sort((a, b)=>a.order - b.order);
262
+ }
263
+ function $d520236daad9c5d5$export$31b21d0167753bb4(panels, id, direction, sizes, height, width) {
264
+ const totalSize = direction === "horizontal" ? width : height;
265
+ if (panels.size === 1) return totalSize;
266
+ const panelsArray = $d520236daad9c5d5$export$a861c0ad45885494(panels);
267
+ const index = panelsArray.findIndex((panel)=>panel.id === id);
268
+ const size = sizes[index];
269
+ if (size == null) return 0;
270
+ return Math.round(size * totalSize);
271
+ }
272
+
273
+
274
+
275
+
276
+
277
+ function $63be9a96d8675f03$export$d9fcbe062527d159({ committedValuesRef: committedValuesRef , groupId: groupId , panels: panels , setSizes: setSizes , sizes: sizes }) {
278
+ (0, $b2QPe$react.useEffect)(()=>{
279
+ const { direction: direction , height: height , panels: panels , width: width } = committedValuesRef.current;
280
+ const handles = (0, $d520236daad9c5d5$export$ae14931f0a0256a3)(groupId);
281
+ const cleanupFunctions = handles.map((handle)=>{
282
+ const handleId = handle.getAttribute("data-panel-resize-handle-id");
283
+ const panelsArray = (0, $d520236daad9c5d5$export$a861c0ad45885494)(panels);
284
+ const [idBefore, idAfter] = (0, $d520236daad9c5d5$export$68d3a33c21dfbe27)(groupId, handleId, panelsArray);
285
+ if (idBefore == null || idAfter == null) return ()=>{};
286
+ const ariaValueMax = panelsArray.reduce((difference, panel)=>{
287
+ if (panel.id !== idBefore) return difference - panel.minSize;
288
+ return difference;
289
+ }, 1);
290
+ const ariaValueMin = panelsArray.find((panel)=>panel.id == idBefore)?.minSize ?? 0;
291
+ const size = (0, $d520236daad9c5d5$export$31b21d0167753bb4)(panels, idBefore, direction, sizes, height, width);
292
+ const ariaValueNow = size / (direction === "horizontal" ? width : height);
293
+ handle.setAttribute("aria-valuemax", "" + Math.round(100 * ariaValueMax));
294
+ handle.setAttribute("aria-valuemin", "" + Math.round(100 * ariaValueMin));
295
+ handle.setAttribute("aria-valuenow", "" + Math.round(100 * ariaValueNow));
296
+ const onKeyDown = (event)=>{
297
+ switch(event.key){
298
+ case "Enter":
299
+ {
300
+ const index = panelsArray.findIndex((panel)=>panel.id === idBefore);
301
+ if (index >= 0) {
302
+ const panelData = panelsArray[index];
303
+ const size = sizes[index];
304
+ if (size != null) {
305
+ let delta = 0;
306
+ if (size.toPrecision((0, $3237bc4a138172cd$export$d6d3992f3becc879)) <= panelData.minSize.toPrecision((0, $3237bc4a138172cd$export$d6d3992f3becc879))) delta = direction === "horizontal" ? width : height;
307
+ else delta = -(direction === "horizontal" ? width : height);
308
+ const nextSizes = (0, $d520236daad9c5d5$export$f50bae335f53943c)(panels, idBefore, idAfter, delta, sizes);
309
+ if (sizes !== nextSizes) setSizes(nextSizes);
310
+ }
311
+ }
312
+ break;
313
+ }
314
+ }
315
+ };
316
+ handle.addEventListener("keydown", onKeyDown);
317
+ const panelBefore = (0, $d520236daad9c5d5$export$7361ed18ff57179e)(idBefore);
318
+ if (panelBefore != null) handle.setAttribute("aria-controls", panelBefore.id);
319
+ return ()=>{
320
+ handle.removeAttribute("aria-valuemax");
321
+ handle.removeAttribute("aria-valuemin");
322
+ handle.removeAttribute("aria-valuenow");
323
+ handle.removeEventListener("keydown", onKeyDown);
324
+ if (panelBefore != null) handle.removeAttribute("aria-controls");
325
+ };
326
+ });
327
+ return ()=>{
328
+ cleanupFunctions.forEach((cleanupFunction)=>cleanupFunction());
329
+ };
330
+ }, [
331
+ groupId,
332
+ panels,
333
+ sizes
334
+ ]);
335
+ }
336
+ function $63be9a96d8675f03$export$33b0bea6ac3ffb03({ disabled: disabled , handleId: handleId , resizeHandler: resizeHandler }) {
337
+ (0, $b2QPe$react.useEffect)(()=>{
338
+ if (disabled || resizeHandler == null) return;
339
+ const handleElement = (0, $d520236daad9c5d5$export$2e27d3a347680388)(handleId);
340
+ if (handleElement == null) return;
341
+ const onKeyDown = (event)=>{
342
+ switch(event.key){
343
+ case "ArrowDown":
344
+ case "ArrowLeft":
345
+ case "ArrowRight":
346
+ case "ArrowUp":
347
+ case "End":
348
+ case "Home":
349
+ resizeHandler(event);
350
+ break;
351
+ case "F6":
352
+ {
353
+ const handles = (0, $d520236daad9c5d5$export$8d0cd3c32ddc045e)();
354
+ const index = (0, $d520236daad9c5d5$export$96a40be80fb6c3c8)(handleId);
355
+ const nextIndex = event.shiftKey ? index > 0 ? index - 1 : handles.length - 1 : index + 1 < handles.length ? index + 1 : 0;
356
+ const nextHandle = handles[nextIndex];
357
+ nextHandle.focus();
358
+ break;
359
+ }
360
+ }
361
+ };
362
+ handleElement.addEventListener("keydown", onKeyDown);
363
+ return ()=>{
364
+ handleElement.removeEventListener("keydown", onKeyDown);
365
+ };
366
+ }, [
367
+ disabled,
368
+ handleId,
369
+ resizeHandler
370
+ ]);
371
+ }
372
+
373
+
99
374
  function $d428eaeef644efb2$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , children: children = null , className: className = "" , direction: direction , height: height , width: width }) {
100
375
  const groupId = (0, $6d548a0d130941e3$export$2e2bcd8739ae039)();
101
376
  const [activeHandleId, setActiveHandleId] = (0, $b2QPe$react.useState)(null);
@@ -110,6 +385,12 @@ function $d428eaeef644efb2$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
110
385
  sizes: sizes,
111
386
  width: width
112
387
  });
388
+ // Tracks the most recent coordinates of a touch/mouse event.
389
+ // This is needed to calculate movement (because TouchEvent doesn't support movementX and movementY).
390
+ const prevCoordinatesRef = (0, $b2QPe$react.useRef)({
391
+ screenX: 0,
392
+ screenY: 0
393
+ });
113
394
  (0, $b2QPe$react.useLayoutEffect)(()=>{
114
395
  committedValuesRef.current.direction = direction;
115
396
  committedValuesRef.current.height = height;
@@ -117,6 +398,13 @@ function $d428eaeef644efb2$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
117
398
  committedValuesRef.current.sizes = sizes;
118
399
  committedValuesRef.current.width = width;
119
400
  });
401
+ (0, $63be9a96d8675f03$export$d9fcbe062527d159)({
402
+ committedValuesRef: committedValuesRef,
403
+ groupId: groupId,
404
+ panels: panels,
405
+ setSizes: setSizes,
406
+ sizes: sizes
407
+ });
120
408
  // Once all panels have registered themselves,
121
409
  // Compute the initial sizes based on default weights.
122
410
  // This assumes that panels register during initial mount (no conditional rendering)!
@@ -129,12 +417,12 @@ function $d428eaeef644efb2$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
129
417
  // default size should be restored from local storage if possible.
130
418
  let defaultSizes = undefined;
131
419
  if (autoSaveId) {
132
- const panelIds = $d428eaeef644efb2$var$panelsMapToSortedArray(panels).map((panel)=>panel.id);
420
+ const panelIds = (0, $d520236daad9c5d5$export$a861c0ad45885494)(panels).map((panel)=>panel.id);
133
421
  defaultSizes = (0, $e045b0dd313f33c7$export$9c80c6617f0386da)(autoSaveId, panelIds);
134
422
  }
135
423
  if (defaultSizes != null) setSizes(defaultSizes);
136
424
  else {
137
- const panelsArray = $d428eaeef644efb2$var$panelsMapToSortedArray(panels);
425
+ const panelsArray = (0, $d520236daad9c5d5$export$a861c0ad45885494)(panels);
138
426
  const totalWeight = panelsArray.reduce((weight, panel)=>{
139
427
  return weight + panel.defaultSize;
140
428
  }, 0);
@@ -148,7 +436,7 @@ function $d428eaeef644efb2$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
148
436
  // If this panel has been configured to persist sizing information, save sizes to local storage.
149
437
  if (autoSaveId) {
150
438
  if (sizes.length === 0 || sizes.length !== panels.size) return;
151
- const panelIds = $d428eaeef644efb2$var$panelsMapToSortedArray(panels).map((panel)=>panel.id);
439
+ const panelIds = (0, $d520236daad9c5d5$export$a861c0ad45885494)(panels).map((panel)=>panel.id);
152
440
  (0, $e045b0dd313f33c7$export$af183b313c61be4f)(autoSaveId, panelIds, sizes);
153
441
  }
154
442
  }, [
@@ -158,8 +446,8 @@ function $d428eaeef644efb2$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
158
446
  ]);
159
447
  const getPanelStyle = (0, $b2QPe$react.useCallback)((id)=>{
160
448
  const { panels: panels } = committedValuesRef.current;
161
- const offset = $d428eaeef644efb2$var$getOffset(panels, id, direction, sizes, height, width);
162
- const size = $d428eaeef644efb2$var$getSize(panels, id, direction, sizes, height, width);
449
+ const offset = (0, $d520236daad9c5d5$export$622cea445a1c5b7d)(panels, id, direction, sizes, height, width);
450
+ const size = (0, $d520236daad9c5d5$export$31b21d0167753bb4)(panels, id, direction, sizes, height, width);
163
451
  if (direction === "horizontal") return {
164
452
  height: "100%",
165
453
  position: "absolute",
@@ -188,21 +476,25 @@ function $d428eaeef644efb2$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
188
476
  return nextPanels;
189
477
  });
190
478
  }, []);
191
- const registerResizeHandle = (0, $b2QPe$react.useCallback)((id)=>{
479
+ const registerResizeHandle = (0, $b2QPe$react.useCallback)((handleId)=>{
192
480
  const resizeHandler = (event)=>{
193
481
  event.preventDefault();
194
482
  const { direction: direction , height: height , panels: panels , sizes: prevSizes , width: width } = committedValuesRef.current;
195
- const handle = document.querySelector(`[data-panel-resize-handle-id="${id}"]`);
196
- const handles = Array.from(document.querySelectorAll(`[data-panel-group-id="${groupId}"]`));
197
- const index = handles.indexOf(handle);
198
- const panelsArray = $d428eaeef644efb2$var$panelsMapToSortedArray(panels);
199
- const idBefore = panelsArray[index]?.id ?? null;
200
- const idAfter = panelsArray[index + 1]?.id ?? null;
483
+ const panelsArray = (0, $d520236daad9c5d5$export$a861c0ad45885494)(panels);
484
+ const [idBefore, idAfter] = (0, $d520236daad9c5d5$export$68d3a33c21dfbe27)(groupId, handleId, panelsArray);
201
485
  if (idBefore == null || idAfter == null) return;
486
+ const nextCoordinates = (0, $f5af57c8e042a4ad$export$70637efcd850e4ef)(event, prevCoordinatesRef.current, {
487
+ height: height,
488
+ width: width
489
+ }, direction);
490
+ prevCoordinatesRef.current = {
491
+ screenX: nextCoordinates.screenX,
492
+ screenY: nextCoordinates.screenY
493
+ };
202
494
  const isHorizontal = direction === "horizontal";
203
- const movement = isHorizontal ? event.movementX : event.movementY;
495
+ const movement = isHorizontal ? nextCoordinates.movementX : nextCoordinates.movementY;
204
496
  const delta = isHorizontal ? movement / width : movement / height;
205
- const nextSizes = $d428eaeef644efb2$var$adjustByDelta(panels, idBefore, idAfter, delta, prevSizes);
497
+ const nextSizes = (0, $d520236daad9c5d5$export$f50bae335f53943c)(panels, idBefore, idAfter, delta, prevSizes);
206
498
  if (prevSizes !== nextSizes) setSizes(nextSizes);
207
499
  };
208
500
  return resizeHandler;
@@ -224,7 +516,13 @@ function $d428eaeef644efb2$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
224
516
  registerPanel: registerPanel,
225
517
  registerResizeHandle: registerResizeHandle,
226
518
  startDragging: (id)=>setActiveHandleId(id),
227
- stopDragging: ()=>setActiveHandleId(null),
519
+ stopDragging: ()=>{
520
+ setActiveHandleId(null);
521
+ prevCoordinatesRef.current = {
522
+ screenX: 0,
523
+ screenY: 0
524
+ };
525
+ },
228
526
  unregisterPanel: unregisterPanel
229
527
  }), [
230
528
  direction,
@@ -248,81 +546,21 @@ function $d428eaeef644efb2$export$2e2bcd8739ae039({ autoSaveId: autoSaveId , chi
248
546
  children: children
249
547
  }, void 0, false, {
250
548
  fileName: "packages/react-resizable-panels/src/PanelGroup.tsx",
251
- lineNumber: 247,
549
+ lineNumber: 290,
252
550
  columnNumber: 9
253
551
  }, this)
254
552
  }, void 0, false, {
255
553
  fileName: "packages/react-resizable-panels/src/PanelGroup.tsx",
256
- lineNumber: 246,
554
+ lineNumber: 289,
257
555
  columnNumber: 7
258
556
  }, this)
259
557
  }, void 0, false, {
260
558
  fileName: "packages/react-resizable-panels/src/PanelGroup.tsx",
261
- lineNumber: 245,
559
+ lineNumber: 288,
262
560
  columnNumber: 5
263
561
  }, this);
264
562
  }
265
- function $d428eaeef644efb2$var$adjustByDelta(panels, idBefore, idAfter, delta, prevSizes) {
266
- if (delta === 0) return prevSizes;
267
- const panelsArray = $d428eaeef644efb2$var$panelsMapToSortedArray(panels);
268
- const nextSizes = prevSizes.concat();
269
- let deltaApplied = 0;
270
- // A resizing panel affects the panels before or after it.
271
- //
272
- // A negative delta means the panel immediately after the resizer should grow/expand by decreasing its offset.
273
- // Other panels may also need to shrink/contract (and shift) to make room, depending on the min weights.
274
- //
275
- // A positive delta means the panel immediately before the resizer should "expand".
276
- // This is accomplished by shrinking/contracting (and shifting) one or more of the panels after the resizer.
277
- let pivotId = delta < 0 ? idBefore : idAfter;
278
- let index = panelsArray.findIndex((panel)=>panel.id === pivotId);
279
- while(true){
280
- const panel = panelsArray[index];
281
- const prevSize = prevSizes[index];
282
- const nextSize = Math.max(prevSize - Math.abs(delta), panel.minSize);
283
- if (prevSize !== nextSize) {
284
- deltaApplied += prevSize - nextSize;
285
- nextSizes[index] = nextSize;
286
- if (deltaApplied.toPrecision($d428eaeef644efb2$var$PRECISION) >= delta.toPrecision($d428eaeef644efb2$var$PRECISION)) break;
287
- }
288
- if (delta < 0) {
289
- if (--index < 0) break;
290
- } else {
291
- if (++index >= panelsArray.length) break;
292
- }
293
- }
294
- // If we were unable to resize any of the panels panels, return the previous state.
295
- // This will essentially bailout and ignore the "mousemove" event.
296
- if (deltaApplied === 0) return prevSizes;
297
- // Adjust the pivot panel before, but only by the amount that surrounding panels were able to shrink/contract.
298
- pivotId = delta < 0 ? idAfter : idBefore;
299
- index = panelsArray.findIndex((panel)=>panel.id === pivotId);
300
- nextSizes[index] = prevSizes[index] + deltaApplied;
301
- return nextSizes;
302
- }
303
- function $d428eaeef644efb2$var$getOffset(panels, id, direction, sizes, height, width) {
304
- const panelsArray = $d428eaeef644efb2$var$panelsMapToSortedArray(panels);
305
- let index = panelsArray.findIndex((panel)=>panel.id === id);
306
- if (index < 0) return 0;
307
- let scaledOffset = 0;
308
- for(index = index - 1; index >= 0; index--){
309
- const panel = panelsArray[index];
310
- scaledOffset += $d428eaeef644efb2$var$getSize(panels, panel.id, direction, sizes, height, width);
311
- }
312
- return Math.round(scaledOffset);
313
- }
314
- function $d428eaeef644efb2$var$getSize(panels, id, direction, sizes, height, width) {
315
- const totalSize = direction === "horizontal" ? width : height;
316
- if (panels.size === 1) return totalSize;
317
- const panelsArray = $d428eaeef644efb2$var$panelsMapToSortedArray(panels);
318
- const index = panelsArray.findIndex((panel)=>panel.id === id);
319
- const size = sizes[index];
320
- if (size == null) return 0;
321
- return Math.round(size * totalSize);
322
- }
323
- function $d428eaeef644efb2$var$panelsMapToSortedArray(panels) {
324
- return Array.from(panels.values()).sort((a, b)=>a.order - b.order);
325
- }
563
+
326
564
 
327
565
 
328
566
 
@@ -346,25 +584,24 @@ function $d578a49f00f1bdeb$export$2e2bcd8739ae039({ children: children = null ,
346
584
  }
347
585
  }, [
348
586
  disabled,
349
- groupId,
350
587
  id,
351
588
  registerResizeHandle
352
589
  ]);
353
590
  (0, $b2QPe$react.useEffect)(()=>{
354
591
  if (disabled || resizeHandler == null || !isDragging) return;
355
592
  document.body.style.cursor = direction === "horizontal" ? "ew-resize" : "ns-resize";
356
- const onMouseMove = (event)=>{
593
+ const onMove = (event)=>{
357
594
  resizeHandler(event);
358
595
  };
359
596
  document.body.addEventListener("mouseleave", stopDragging);
360
- document.body.addEventListener("mousemove", onMouseMove);
361
- document.body.addEventListener("touchmove", onMouseMove);
597
+ document.body.addEventListener("mousemove", onMove);
598
+ document.body.addEventListener("touchmove", onMove);
362
599
  document.body.addEventListener("mouseup", stopDragging);
363
600
  return ()=>{
364
601
  document.body.style.cursor = "";
365
602
  document.body.removeEventListener("mouseleave", stopDragging);
366
- document.body.removeEventListener("mousemove", onMouseMove);
367
- document.body.removeEventListener("touchmove", onMouseMove);
603
+ document.body.removeEventListener("mousemove", onMove);
604
+ document.body.removeEventListener("touchmove", onMove);
368
605
  document.body.removeEventListener("mouseup", stopDragging);
369
606
  };
370
607
  }, [
@@ -374,21 +611,31 @@ function $d578a49f00f1bdeb$export$2e2bcd8739ae039({ children: children = null ,
374
611
  resizeHandler,
375
612
  stopDragging
376
613
  ]);
614
+ (0, $63be9a96d8675f03$export$33b0bea6ac3ffb03)({
615
+ disabled: disabled,
616
+ handleId: id,
617
+ resizeHandler: resizeHandler
618
+ });
377
619
  return /*#__PURE__*/ (0, $b2QPe$reactjsxdevruntime.jsxDEV)("div", {
378
620
  className: className,
379
621
  "data-panel-group-id": groupId,
622
+ "data-panel-resize-handle-enabled": !disabled,
380
623
  "data-panel-resize-handle-id": id,
381
624
  onMouseDown: ()=>startDragging(id),
382
625
  onMouseUp: stopDragging,
383
- onTouchStart: ()=>startDragging(id),
626
+ onTouchCancel: stopDragging,
384
627
  onTouchEnd: stopDragging,
628
+ onTouchStart: ()=>startDragging(id),
629
+ role: "separator",
385
630
  style: {
386
- cursor: direction === "horizontal" ? "ew-resize" : "ns-resize"
631
+ cursor: direction === "horizontal" ? "ew-resize" : "ns-resize",
632
+ touchAction: "none"
387
633
  },
634
+ tabIndex: 0,
388
635
  children: children
389
636
  }, void 0, false, {
390
637
  fileName: "packages/react-resizable-panels/src/PanelResizeHandle.tsx",
391
- lineNumber: 80,
638
+ lineNumber: 87,
392
639
  columnNumber: 5
393
640
  }, this);
394
641
  }