react-resizable-panels 3.0.1 → 3.0.2

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.
@@ -1081,14 +1081,22 @@ function determinePivotIndices(groupId, dragHandleId, panelGroupElement) {
1081
1081
  return index != null ? [index, index + 1] : [-1, -1];
1082
1082
  }
1083
1083
 
1084
+ function isHTMLElement(target) {
1085
+ if (target instanceof HTMLElement) {
1086
+ return true;
1087
+ }
1088
+
1089
+ // Fallback to duck typing to handle edge case of portals within a popup window
1090
+ return typeof target === "object" && target !== null && "tagName" in target && "getAttribute" in target;
1091
+ }
1092
+
1084
1093
  function getPanelGroupElement(id, rootElement = document) {
1085
- var _dataset;
1086
- //If the root element is the PanelGroup
1087
- if (rootElement instanceof HTMLElement && (rootElement === null || rootElement === void 0 ? void 0 : (_dataset = rootElement.dataset) === null || _dataset === void 0 ? void 0 : _dataset.panelGroupId) == id) {
1094
+ // If the root element is the PanelGroup
1095
+ if (isHTMLElement(rootElement) && rootElement.dataset.panelGroupId == id) {
1088
1096
  return rootElement;
1089
1097
  }
1090
1098
 
1091
- //Else query children
1099
+ // Else query children
1092
1100
  const element = rootElement.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
1093
1101
  if (element) {
1094
1102
  return element;
@@ -1075,14 +1075,22 @@ function determinePivotIndices(groupId, dragHandleId, panelGroupElement) {
1075
1075
  return index != null ? [index, index + 1] : [-1, -1];
1076
1076
  }
1077
1077
 
1078
+ function isHTMLElement(target) {
1079
+ if (target instanceof HTMLElement) {
1080
+ return true;
1081
+ }
1082
+
1083
+ // Fallback to duck typing to handle edge case of portals within a popup window
1084
+ return typeof target === "object" && target !== null && "tagName" in target && "getAttribute" in target;
1085
+ }
1086
+
1078
1087
  function getPanelGroupElement(id, rootElement = document) {
1079
- var _dataset;
1080
- //If the root element is the PanelGroup
1081
- if (rootElement instanceof HTMLElement && (rootElement === null || rootElement === void 0 ? void 0 : (_dataset = rootElement.dataset) === null || _dataset === void 0 ? void 0 : _dataset.panelGroupId) == id) {
1088
+ // If the root element is the PanelGroup
1089
+ if (isHTMLElement(rootElement) && rootElement.dataset.panelGroupId == id) {
1082
1090
  return rootElement;
1083
1091
  }
1084
1092
 
1085
- //Else query children
1093
+ // Else query children
1086
1094
  const element = rootElement.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
1087
1095
  if (element) {
1088
1096
  return element;
@@ -1012,14 +1012,22 @@ function determinePivotIndices(groupId, dragHandleId, panelGroupElement) {
1012
1012
  return index != null ? [index, index + 1] : [-1, -1];
1013
1013
  }
1014
1014
 
1015
+ function isHTMLElement(target) {
1016
+ if (target instanceof HTMLElement) {
1017
+ return true;
1018
+ }
1019
+
1020
+ // Fallback to duck typing to handle edge case of portals within a popup window
1021
+ return typeof target === "object" && target !== null && "tagName" in target && "getAttribute" in target;
1022
+ }
1023
+
1015
1024
  function getPanelGroupElement(id, rootElement = document) {
1016
- var _dataset;
1017
- //If the root element is the PanelGroup
1018
- if (rootElement instanceof HTMLElement && (rootElement === null || rootElement === void 0 ? void 0 : (_dataset = rootElement.dataset) === null || _dataset === void 0 ? void 0 : _dataset.panelGroupId) == id) {
1025
+ // If the root element is the PanelGroup
1026
+ if (isHTMLElement(rootElement) && rootElement.dataset.panelGroupId == id) {
1019
1027
  return rootElement;
1020
1028
  }
1021
1029
 
1022
- //Else query children
1030
+ // Else query children
1023
1031
  const element = rootElement.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
1024
1032
  if (element) {
1025
1033
  return element;
@@ -1088,14 +1088,22 @@ function determinePivotIndices(groupId, dragHandleId, panelGroupElement) {
1088
1088
  return index != null ? [index, index + 1] : [-1, -1];
1089
1089
  }
1090
1090
 
1091
+ function isHTMLElement(target) {
1092
+ if (target instanceof HTMLElement) {
1093
+ return true;
1094
+ }
1095
+
1096
+ // Fallback to duck typing to handle edge case of portals within a popup window
1097
+ return typeof target === "object" && target !== null && "tagName" in target && "getAttribute" in target;
1098
+ }
1099
+
1091
1100
  function getPanelGroupElement(id, rootElement = document) {
1092
- var _dataset;
1093
- //If the root element is the PanelGroup
1094
- if (rootElement instanceof HTMLElement && (rootElement === null || rootElement === void 0 ? void 0 : (_dataset = rootElement.dataset) === null || _dataset === void 0 ? void 0 : _dataset.panelGroupId) == id) {
1101
+ // If the root element is the PanelGroup
1102
+ if (isHTMLElement(rootElement) && rootElement.dataset.panelGroupId == id) {
1095
1103
  return rootElement;
1096
1104
  }
1097
1105
 
1098
- //Else query children
1106
+ // Else query children
1099
1107
  const element = rootElement.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
1100
1108
  if (element) {
1101
1109
  return element;
@@ -1001,14 +1001,22 @@ function determinePivotIndices(groupId, dragHandleId, panelGroupElement) {
1001
1001
  return index != null ? [index, index + 1] : [-1, -1];
1002
1002
  }
1003
1003
 
1004
+ function isHTMLElement(target) {
1005
+ if (target instanceof HTMLElement) {
1006
+ return true;
1007
+ }
1008
+
1009
+ // Fallback to duck typing to handle edge case of portals within a popup window
1010
+ return typeof target === "object" && target !== null && "tagName" in target && "getAttribute" in target;
1011
+ }
1012
+
1004
1013
  function getPanelGroupElement(id, rootElement = document) {
1005
- var _dataset;
1006
- //If the root element is the PanelGroup
1007
- if (rootElement instanceof HTMLElement && (rootElement === null || rootElement === void 0 ? void 0 : (_dataset = rootElement.dataset) === null || _dataset === void 0 ? void 0 : _dataset.panelGroupId) == id) {
1014
+ // If the root element is the PanelGroup
1015
+ if (isHTMLElement(rootElement) && rootElement.dataset.panelGroupId == id) {
1008
1016
  return rootElement;
1009
1017
  }
1010
1018
 
1011
- //Else query children
1019
+ // Else query children
1012
1020
  const element = rootElement.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
1013
1021
  if (element) {
1014
1022
  return element;
@@ -1077,14 +1077,22 @@ function determinePivotIndices(groupId, dragHandleId, panelGroupElement) {
1077
1077
  return index != null ? [index, index + 1] : [-1, -1];
1078
1078
  }
1079
1079
 
1080
+ function isHTMLElement(target) {
1081
+ if (target instanceof HTMLElement) {
1082
+ return true;
1083
+ }
1084
+
1085
+ // Fallback to duck typing to handle edge case of portals within a popup window
1086
+ return typeof target === "object" && target !== null && "tagName" in target && "getAttribute" in target;
1087
+ }
1088
+
1080
1089
  function getPanelGroupElement(id, rootElement = document) {
1081
- var _dataset;
1082
- //If the root element is the PanelGroup
1083
- if (rootElement instanceof HTMLElement && (rootElement === null || rootElement === void 0 ? void 0 : (_dataset = rootElement.dataset) === null || _dataset === void 0 ? void 0 : _dataset.panelGroupId) == id) {
1090
+ // If the root element is the PanelGroup
1091
+ if (isHTMLElement(rootElement) && rootElement.dataset.panelGroupId == id) {
1084
1092
  return rootElement;
1085
1093
  }
1086
1094
 
1087
- //Else query children
1095
+ // Else query children
1088
1096
  const element = rootElement.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
1089
1097
  if (element) {
1090
1098
  return element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-resizable-panels",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "type": "module",
5
5
  "description": "React components for resizable panel groups/layouts",
6
6
  "author": "Brian Vaughn <brian.david.vaughn@gmail.com>",