react-resizable-panels 2.1.3 → 2.1.5

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,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.1.5
4
+
5
+ - Add react v19 to peer deps
6
+
7
+ ## 2.1.4
8
+
9
+ - Improve TypeScript HTML tag type generics (#407)
10
+ - Edge case check to make sure resize handle hasn't been unmounted while dragging (#410)
11
+
3
12
  ## 2.1.3
4
13
 
5
14
  - Edge case bug fix for a resize handle unmounting while being dragged (#402)
@@ -30,7 +30,7 @@ export type ImperativePanelHandle = {
30
30
  isExpanded: () => boolean;
31
31
  resize: (size: number) => void;
32
32
  };
33
- export type PanelProps = Omit<HTMLAttributes<keyof HTMLElementTagNameMap>, "id" | "onResize"> & PropsWithChildren<{
33
+ export type PanelProps<T extends keyof HTMLElementTagNameMap = keyof HTMLElementTagNameMap> = Omit<HTMLAttributes<HTMLElementTagNameMap[T]>, "id" | "onResize"> & PropsWithChildren<{
34
34
  className?: string;
35
35
  collapsedSize?: number | undefined;
36
36
  collapsible?: boolean | undefined;
@@ -43,7 +43,7 @@ export type PanelProps = Omit<HTMLAttributes<keyof HTMLElementTagNameMap>, "id"
43
43
  onResize?: PanelOnResize;
44
44
  order?: number;
45
45
  style?: object;
46
- tagName?: keyof HTMLElementTagNameMap;
46
+ tagName?: T;
47
47
  }>;
48
48
  export declare function PanelWithForwardedRef({ children, className: classNameFromProps, collapsedSize, collapsible, defaultSize, forwardedRef, id: idFromProps, maxSize, minSize, onCollapse, onExpand, onResize, order, style: styleFromProps, tagName: Type, ...rest }: PanelProps & {
49
49
  forwardedRef: ForwardedRef<ImperativePanelHandle>;
@@ -51,7 +51,7 @@ export declare function PanelWithForwardedRef({ children, className: classNameFr
51
51
  export declare namespace PanelWithForwardedRef {
52
52
  var displayName: string;
53
53
  }
54
- export declare const Panel: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<keyof HTMLElementTagNameMap>, "id" | "onResize"> & {
54
+ export declare const Panel: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLObjectElement | HTMLElement | HTMLSlotElement | HTMLStyleElement | HTMLTitleElement | HTMLAnchorElement | HTMLAreaElement | HTMLAudioElement | HTMLBaseElement | HTMLQuoteElement | HTMLBodyElement | HTMLBRElement | HTMLButtonElement | HTMLCanvasElement | HTMLTableCaptionElement | HTMLTableColElement | HTMLDataElement | HTMLDataListElement | HTMLModElement | HTMLDetailsElement | HTMLDialogElement | HTMLDivElement | HTMLDListElement | HTMLEmbedElement | HTMLFieldSetElement | HTMLFormElement | HTMLHeadingElement | HTMLHeadElement | HTMLHRElement | HTMLHtmlElement | HTMLIFrameElement | HTMLImageElement | HTMLInputElement | HTMLLabelElement | HTMLLegendElement | HTMLLIElement | HTMLLinkElement | HTMLMapElement | HTMLMenuElement | HTMLMetaElement | HTMLMeterElement | HTMLOListElement | HTMLOptGroupElement | HTMLOptionElement | HTMLOutputElement | HTMLParagraphElement | HTMLPictureElement | HTMLPreElement | HTMLProgressElement | HTMLScriptElement | HTMLSelectElement | HTMLSourceElement | HTMLSpanElement | HTMLTableElement | HTMLTableSectionElement | HTMLTableCellElement | HTMLTemplateElement | HTMLTextAreaElement | HTMLTimeElement | HTMLTableRowElement | HTMLTrackElement | HTMLUListElement | HTMLVideoElement>, "id" | "onResize"> & {
55
55
  className?: string | undefined;
56
56
  collapsedSize?: number | undefined;
57
57
  collapsible?: boolean | undefined;
@@ -600,7 +600,7 @@ function recalculateIntersectingHandles({
600
600
  // Clicking on an element "above" a handle (e.g. a modal) should prevent a hit though
601
601
  // so at this point we need to compare stacking order of a potentially intersecting drag handle,
602
602
  // and the element that was actually clicked/touched
603
- if (targetElement !== null && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
603
+ if (targetElement !== null && document.contains(targetElement) && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
604
604
  // Calculating stacking order has a cost, so we should avoid it if possible
605
605
  // That is why we only check potentially intersecting handles,
606
606
  // and why we skip if the event target is within the handle's DOM
@@ -606,7 +606,7 @@ function recalculateIntersectingHandles({
606
606
  // Clicking on an element "above" a handle (e.g. a modal) should prevent a hit though
607
607
  // so at this point we need to compare stacking order of a potentially intersecting drag handle,
608
608
  // and the element that was actually clicked/touched
609
- if (targetElement !== null && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
609
+ if (targetElement !== null && document.contains(targetElement) && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
610
610
  // Calculating stacking order has a cost, so we should avoid it if possible
611
611
  // That is why we only check potentially intersecting handles,
612
612
  // and why we skip if the event target is within the handle's DOM
@@ -582,7 +582,7 @@ function recalculateIntersectingHandles({
582
582
  // Clicking on an element "above" a handle (e.g. a modal) should prevent a hit though
583
583
  // so at this point we need to compare stacking order of a potentially intersecting drag handle,
584
584
  // and the element that was actually clicked/touched
585
- if (targetElement !== null && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
585
+ if (targetElement !== null && document.contains(targetElement) && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
586
586
  // Calculating stacking order has a cost, so we should avoid it if possible
587
587
  // That is why we only check potentially intersecting handles,
588
588
  // and why we skip if the event target is within the handle's DOM
@@ -576,7 +576,7 @@ function recalculateIntersectingHandles({
576
576
  // Clicking on an element "above" a handle (e.g. a modal) should prevent a hit though
577
577
  // so at this point we need to compare stacking order of a potentially intersecting drag handle,
578
578
  // and the element that was actually clicked/touched
579
- if (targetElement !== null && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
579
+ if (targetElement !== null && document.contains(targetElement) && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
580
580
  // Calculating stacking order has a cost, so we should avoid it if possible
581
581
  // That is why we only check potentially intersecting handles,
582
582
  // and why we skip if the event target is within the handle's DOM
@@ -602,7 +602,7 @@ function recalculateIntersectingHandles({
602
602
  // Clicking on an element "above" a handle (e.g. a modal) should prevent a hit though
603
603
  // so at this point we need to compare stacking order of a potentially intersecting drag handle,
604
604
  // and the element that was actually clicked/touched
605
- if (targetElement !== null && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
605
+ if (targetElement !== null && document.contains(targetElement) && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
606
606
  // Calculating stacking order has a cost, so we should avoid it if possible
607
607
  // That is why we only check potentially intersecting handles,
608
608
  // and why we skip if the event target is within the handle's DOM
@@ -613,7 +613,7 @@ function recalculateIntersectingHandles({
613
613
  // Clicking on an element "above" a handle (e.g. a modal) should prevent a hit though
614
614
  // so at this point we need to compare stacking order of a potentially intersecting drag handle,
615
615
  // and the element that was actually clicked/touched
616
- if (targetElement !== null && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
616
+ if (targetElement !== null && document.contains(targetElement) && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
617
617
  // Calculating stacking order has a cost, so we should avoid it if possible
618
618
  // That is why we only check potentially intersecting handles,
619
619
  // and why we skip if the event target is within the handle's DOM
@@ -589,7 +589,7 @@ function recalculateIntersectingHandles({
589
589
  // Clicking on an element "above" a handle (e.g. a modal) should prevent a hit though
590
590
  // so at this point we need to compare stacking order of a potentially intersecting drag handle,
591
591
  // and the element that was actually clicked/touched
592
- if (targetElement !== null && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
592
+ if (targetElement !== null && document.contains(targetElement) && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
593
593
  // Calculating stacking order has a cost, so we should avoid it if possible
594
594
  // That is why we only check potentially intersecting handles,
595
595
  // and why we skip if the event target is within the handle's DOM
@@ -575,7 +575,7 @@ function recalculateIntersectingHandles({
575
575
  // Clicking on an element "above" a handle (e.g. a modal) should prevent a hit though
576
576
  // so at this point we need to compare stacking order of a potentially intersecting drag handle,
577
577
  // and the element that was actually clicked/touched
578
- if (targetElement !== null && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
578
+ if (targetElement !== null && document.contains(targetElement) && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
579
579
  // Calculating stacking order has a cost, so we should avoid it if possible
580
580
  // That is why we only check potentially intersecting handles,
581
581
  // and why we skip if the event target is within the handle's DOM
@@ -551,7 +551,7 @@ function recalculateIntersectingHandles({
551
551
  // Clicking on an element "above" a handle (e.g. a modal) should prevent a hit though
552
552
  // so at this point we need to compare stacking order of a potentially intersecting drag handle,
553
553
  // and the element that was actually clicked/touched
554
- if (targetElement !== null && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
554
+ if (targetElement !== null && document.contains(targetElement) && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
555
555
  // Calculating stacking order has a cost, so we should avoid it if possible
556
556
  // That is why we only check potentially intersecting handles,
557
557
  // and why we skip if the event target is within the handle's DOM
@@ -578,7 +578,7 @@ function recalculateIntersectingHandles({
578
578
  // Clicking on an element "above" a handle (e.g. a modal) should prevent a hit though
579
579
  // so at this point we need to compare stacking order of a potentially intersecting drag handle,
580
580
  // and the element that was actually clicked/touched
581
- if (targetElement !== null && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
581
+ if (targetElement !== null && document.contains(targetElement) && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
582
582
  // Calculating stacking order has a cost, so we should avoid it if possible
583
583
  // That is why we only check potentially intersecting handles,
584
584
  // and why we skip if the event target is within the handle's DOM
@@ -564,7 +564,7 @@ function recalculateIntersectingHandles({
564
564
  // Clicking on an element "above" a handle (e.g. a modal) should prevent a hit though
565
565
  // so at this point we need to compare stacking order of a potentially intersecting drag handle,
566
566
  // and the element that was actually clicked/touched
567
- if (targetElement !== null && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
567
+ if (targetElement !== null && document.contains(targetElement) && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
568
568
  // Calculating stacking order has a cost, so we should avoid it if possible
569
569
  // That is why we only check potentially intersecting handles,
570
570
  // and why we skip if the event target is within the handle's DOM
@@ -540,7 +540,7 @@ function recalculateIntersectingHandles({
540
540
  // Clicking on an element "above" a handle (e.g. a modal) should prevent a hit though
541
541
  // so at this point we need to compare stacking order of a potentially intersecting drag handle,
542
542
  // and the element that was actually clicked/touched
543
- if (targetElement !== null && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
543
+ if (targetElement !== null && document.contains(targetElement) && dragHandleElement !== targetElement && !dragHandleElement.contains(targetElement) && !targetElement.contains(dragHandleElement) &&
544
544
  // Calculating stacking order has a cost, so we should avoid it if possible
545
545
  // That is why we only check potentially intersecting handles,
546
546
  // and why we skip if the event target is within the handle's DOM
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-resizable-panels",
3
- "version": "2.1.3",
3
+ "version": "2.1.5",
4
4
  "description": "React components for resizable panel groups/layouts",
5
5
  "author": "Brian Vaughn <brian.david.vaughn@gmail.com>",
6
6
  "license": "MIT",
@@ -81,8 +81,8 @@
81
81
  "react-dom": "experimental"
82
82
  },
83
83
  "peerDependencies": {
84
- "react": "^16.14.0 || ^17.0.0 || ^18.0.0",
85
- "react-dom": "^16.14.0 || ^17.0.0 || ^18.0.0"
84
+ "react": "^16.14.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc",
85
+ "react-dom": "^16.14.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc"
86
86
  },
87
87
  "browserslist": [
88
88
  "Chrome 79"
Binary file
package/src/Panel.ts CHANGED
@@ -54,10 +54,9 @@ export type ImperativePanelHandle = {
54
54
  resize: (size: number) => void;
55
55
  };
56
56
 
57
- export type PanelProps = Omit<
58
- HTMLAttributes<keyof HTMLElementTagNameMap>,
59
- "id" | "onResize"
60
- > &
57
+ export type PanelProps<
58
+ T extends keyof HTMLElementTagNameMap = keyof HTMLElementTagNameMap,
59
+ > = Omit<HTMLAttributes<HTMLElementTagNameMap[T]>, "id" | "onResize"> &
61
60
  PropsWithChildren<{
62
61
  className?: string;
63
62
  collapsedSize?: number | undefined;
@@ -71,7 +70,7 @@ export type PanelProps = Omit<
71
70
  onResize?: PanelOnResize;
72
71
  order?: number;
73
72
  style?: object;
74
- tagName?: keyof HTMLElementTagNameMap;
73
+ tagName?: T;
75
74
  }>;
76
75
 
77
76
  export function PanelWithForwardedRef({
@@ -197,6 +197,7 @@ function recalculateIntersectingHandles({
197
197
  // and the element that was actually clicked/touched
198
198
  if (
199
199
  targetElement !== null &&
200
+ document.contains(targetElement) &&
200
201
  dragHandleElement !== targetElement &&
201
202
  !dragHandleElement.contains(targetElement) &&
202
203
  !targetElement.contains(dragHandleElement) &&