react-resizable-panels 0.0.39 → 0.0.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -0
- package/README.md +2 -0
- package/dist/react-resizable-panels.d.ts +3 -3
- package/dist/react-resizable-panels.d.ts.map +1 -1
- package/dist/react-resizable-panels.js +39 -23
- package/dist/react-resizable-panels.js.map +1 -1
- package/dist/react-resizable-panels.module.js +39 -23
- package/dist/react-resizable-panels.module.js.map +1 -1
- package/package.json +2 -2
- package/src/Panel.ts +1 -1
- package/src/PanelGroup.ts +6 -6
- package/src/PanelResizeHandle.ts +4 -4
- package/src/hooks/useWindowSplitterBehavior.ts +7 -4
- package/src/types.ts +1 -1
- package/src/utils/assert.ts +10 -0
- package/src/utils/coordinates.ts +2 -2
- package/src/utils/debounce.ts +3 -1
- package/src/utils/group.ts +15 -3
package/src/utils/debounce.ts
CHANGED
|
@@ -5,7 +5,9 @@ export default function debounce<T extends Function>(
|
|
|
5
5
|
let timeoutId: NodeJS.Timeout | null = null;
|
|
6
6
|
|
|
7
7
|
let callable = (...args: any) => {
|
|
8
|
-
|
|
8
|
+
if (timeoutId !== null) {
|
|
9
|
+
clearTimeout(timeoutId);
|
|
10
|
+
}
|
|
9
11
|
|
|
10
12
|
timeoutId = setTimeout(() => {
|
|
11
13
|
callback(...args);
|
package/src/utils/group.ts
CHANGED
|
@@ -124,7 +124,7 @@ export function callPanelCallbacks(
|
|
|
124
124
|
const prevSize = prevSizes[index];
|
|
125
125
|
if (prevSize !== nextSize) {
|
|
126
126
|
const { callbacksRef, collapsible } = panelsArray[index];
|
|
127
|
-
const { onCollapse, onResize } = callbacksRef.current
|
|
127
|
+
const { onCollapse, onResize } = callbacksRef.current!;
|
|
128
128
|
|
|
129
129
|
if (onResize) {
|
|
130
130
|
onResize(nextSize);
|
|
@@ -238,7 +238,7 @@ export function getResizeHandlePanelIds(
|
|
|
238
238
|
): [idBefore: string | null, idAfter: string | null] {
|
|
239
239
|
const handle = getResizeHandle(handleId);
|
|
240
240
|
const handles = getResizeHandlesForGroup(groupId);
|
|
241
|
-
const index = handles.indexOf(handle);
|
|
241
|
+
const index = handle ? handles.indexOf(handle) : -1;
|
|
242
242
|
|
|
243
243
|
const idBefore: string | null = panelsArray[index]?.id ?? null;
|
|
244
244
|
const idAfter: string | null = panelsArray[index + 1]?.id ?? null;
|
|
@@ -249,7 +249,19 @@ export function getResizeHandlePanelIds(
|
|
|
249
249
|
export function panelsMapToSortedArray(
|
|
250
250
|
panels: Map<string, PanelData>
|
|
251
251
|
): PanelData[] {
|
|
252
|
-
return Array.from(panels.values()).sort((
|
|
252
|
+
return Array.from(panels.values()).sort((panelA, panelB) => {
|
|
253
|
+
const orderA = panelA.order;
|
|
254
|
+
const orderB = panelB.order;
|
|
255
|
+
if (orderA == null && orderB == null) {
|
|
256
|
+
return 0;
|
|
257
|
+
} else if (orderA == null) {
|
|
258
|
+
return -1;
|
|
259
|
+
} else if (orderB == null) {
|
|
260
|
+
return 1;
|
|
261
|
+
} else {
|
|
262
|
+
return orderA - orderB;
|
|
263
|
+
}
|
|
264
|
+
});
|
|
253
265
|
}
|
|
254
266
|
|
|
255
267
|
function safeResizePanel(
|