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.
@@ -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
- clearTimeout(timeoutId);
8
+ if (timeoutId !== null) {
9
+ clearTimeout(timeoutId);
10
+ }
9
11
 
10
12
  timeoutId = setTimeout(() => {
11
13
  callback(...args);
@@ -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((a, b) => a.order - b.order);
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(