MCPcopy Create free account
hub / github.com/bvaughn/react-resizable-panels / getTabsetDropTarget

Function getTabsetDropTarget

lib/workspace/utils/getDropTarget.ts:321–366  ·  view source on GitHub ↗
({
  clientX,
  clientY,
  element,
  isExternal,
  isMoveOnly,
  isSplittable,
  sourceTabsetId,
  tabList,
  tabPanels,
  tabsetId
}: {
  clientX: number;
  clientY: number;
  element: Element;
  isExternal: boolean;
  /** Tabsets kept when empty can be moved, but not merged into other tabsets (which would leave them behind, empty);
   * those of other workspaces aren't moved at all (see isExternalDropDisabled) */
  isMoveOnly: boolean;
  isSplittable: boolean;
  sourceTabsetId: string;
  tabList: HTMLElement | null | undefined;
  tabPanels: HTMLElement | null | undefined;
  tabsetId: string;
})

Source from the content-addressed store, hash-verified

319}
320
321function getTabsetDropTarget({
322 clientX,
323 clientY,
324 element,
325 isExternal,
326 isMoveOnly,
327 isSplittable,
328 sourceTabsetId,
329 tabList,
330 tabPanels,
331 tabsetId
332}: {
333 clientX: number;
334 clientY: number;
335 element: Element;
336 isExternal: boolean;
337 /** Tabsets kept when empty can be moved, but not merged into other tabsets (which would leave them behind, empty);
338 * those of other workspaces aren't moved at all (see isExternalDropDisabled) */
339 isMoveOnly: boolean;
340 isSplittable: boolean;
341 sourceTabsetId: string;
342 tabList: HTMLElement | null | undefined;
343 tabPanels: HTMLElement | null | undefined;
344 tabsetId: string;
345}): TabDropTarget | undefined {
346 // A tabset can't be dropped onto itself
347 if (!isExternal && tabsetId === sourceTabsetId) {
348 return undefined;
349 }
350
351 if (tabList?.contains(element)) {
352 return isMoveOnly
353 ? undefined
354 : { index: getTabListIndex(tabList, clientX, clientY), tabsetId };
355 }
356
357 if (tabPanels?.contains(element)) {
358 const region = isSplittable
359 ? getDropRegion(tabPanels.getBoundingClientRect(), clientX, clientY)
360 : "center";
361
362 return region === "center" && isMoveOnly ? undefined : { region, tabsetId };
363 }
364
365 return undefined;
366}

Callers 1

getDropTargetFunction · 0.85

Calls 2

getTabListIndexFunction · 0.90
getDropRegionFunction · 0.90

Tested by

no test coverage detected