react-resizable-panels 2.1.7 → 2.1.8

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.
@@ -1,32 +1,12 @@
1
1
  import * as React from 'react';
2
-
3
- // This module exists to work around Webpack issue https://github.com/webpack/webpack/issues/14814
4
-
5
- // eslint-disable-next-line no-restricted-imports
6
-
7
- const {
8
- createElement,
9
- createContext,
10
- createRef,
11
- forwardRef,
12
- useCallback,
13
- useContext,
14
- useEffect,
15
- useImperativeHandle,
16
- useLayoutEffect,
17
- useMemo,
18
- useRef,
19
- useState
20
- } = React;
21
-
22
- // `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
23
- const useId = React[`useId${Math.random()}`.slice(0, 5)];
2
+ import { createContext, useRef, forwardRef, createElement, useContext, useImperativeHandle, useState, useCallback, useEffect, useMemo } from 'react';
24
3
 
25
4
  // The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
26
5
 
27
6
  const PanelGroupContext = createContext(null);
28
7
  PanelGroupContext.displayName = "PanelGroupContext";
29
8
 
9
+ const useId = React["useId".toString()];
30
10
  const wrappedUseId = typeof useId === "function" ? useId : () => null;
31
11
  let counter = 0;
32
12
  function useUniqueId(idFromParams = null) {
@@ -121,7 +101,7 @@ function PanelWithForwardedRef({
121
101
  ...rest,
122
102
  children,
123
103
  className: classNameFromProps,
124
- id: idFromProps,
104
+ id: panelId,
125
105
  style: {
126
106
  ...style,
127
107
  ...styleFromProps
@@ -606,7 +586,9 @@ function updateListeners() {
606
586
  body
607
587
  } = ownerDocument;
608
588
  body.removeEventListener("contextmenu", handlePointerUp);
609
- body.removeEventListener("pointerdown", handlePointerDown);
589
+ body.removeEventListener("pointerdown", handlePointerDown, {
590
+ capture: true
591
+ });
610
592
  body.removeEventListener("pointerleave", handlePointerMove);
611
593
  body.removeEventListener("pointermove", handlePointerMove);
612
594
  });
@@ -2016,8 +1998,11 @@ function PanelResizeHandle({
2016
1998
  hitAreaMargins,
2017
1999
  id: idFromProps,
2018
2000
  onBlur,
2001
+ onClick,
2019
2002
  onDragging,
2020
2003
  onFocus,
2004
+ onPointerDown,
2005
+ onPointerUp,
2021
2006
  style: styleFromProps = {},
2022
2007
  tabIndex = 0,
2023
2008
  tagName: Type = "div",
@@ -2028,10 +2013,16 @@ function PanelResizeHandle({
2028
2013
 
2029
2014
  // Use a ref to guard against users passing inline props
2030
2015
  const callbacksRef = useRef({
2031
- onDragging
2016
+ onClick,
2017
+ onDragging,
2018
+ onPointerDown,
2019
+ onPointerUp
2032
2020
  });
2033
2021
  useEffect(() => {
2022
+ callbacksRef.current.onClick = onClick;
2034
2023
  callbacksRef.current.onDragging = onDragging;
2024
+ callbacksRef.current.onPointerDown = onPointerDown;
2025
+ callbacksRef.current.onPointerUp = onPointerUp;
2035
2026
  });
2036
2027
  const panelGroupContext = useContext(PanelGroupContext);
2037
2028
  if (panelGroupContext === null) {
@@ -2071,20 +2062,22 @@ function PanelResizeHandle({
2071
2062
  }
2072
2063
  const element = elementRef.current;
2073
2064
  assert(element, "Element ref not attached");
2065
+ let didMove = false;
2074
2066
  const setResizeHandlerState = (action, isActive, event) => {
2075
2067
  if (isActive) {
2076
2068
  switch (action) {
2077
2069
  case "down":
2078
2070
  {
2079
2071
  setState("drag");
2072
+ didMove = false;
2080
2073
  assert(event, 'Expected event to be defined for "down" action');
2081
2074
  startDragging(resizeHandleId, event);
2082
2075
  const {
2083
- onDragging
2076
+ onDragging,
2077
+ onPointerDown
2084
2078
  } = callbacksRef.current;
2085
- if (onDragging) {
2086
- onDragging(true);
2087
- }
2079
+ onDragging === null || onDragging === void 0 ? void 0 : onDragging(true);
2080
+ onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown();
2088
2081
  break;
2089
2082
  }
2090
2083
  case "move":
@@ -2092,6 +2085,7 @@ function PanelResizeHandle({
2092
2085
  const {
2093
2086
  state
2094
2087
  } = committedValuesRef.current;
2088
+ didMove = true;
2095
2089
  if (state !== "drag") {
2096
2090
  setState("hover");
2097
2091
  }
@@ -2104,10 +2098,14 @@ function PanelResizeHandle({
2104
2098
  setState("hover");
2105
2099
  stopDragging();
2106
2100
  const {
2107
- onDragging
2101
+ onClick,
2102
+ onDragging,
2103
+ onPointerUp
2108
2104
  } = callbacksRef.current;
2109
- if (onDragging) {
2110
- onDragging(false);
2105
+ onDragging === null || onDragging === void 0 ? void 0 : onDragging(false);
2106
+ onPointerUp === null || onPointerUp === void 0 ? void 0 : onPointerUp();
2107
+ if (!didMove) {
2108
+ onClick === null || onClick === void 0 ? void 0 : onClick();
2111
2109
  }
2112
2110
  break;
2113
2111
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-resizable-panels",
3
- "version": "2.1.7",
3
+ "version": "2.1.8",
4
4
  "description": "React components for resizable panel groups/layouts",
5
5
  "author": "Brian Vaughn <brian.david.vaughn@gmail.com>",
6
6
  "license": "MIT",
@@ -79,7 +79,6 @@
79
79
  "@babel/plugin-proposal-nullish-coalescing-operator": "7.18.6",
80
80
  "@babel/plugin-proposal-optional-chaining": "7.21.0",
81
81
  "eslint": "^8.37.0",
82
- "eslint-plugin-no-restricted-imports": "^0.0.0",
83
82
  "eslint-plugin-react-hooks": "^4.6.0",
84
83
  "jest": "^29.7.0",
85
84
  "jest-environment-jsdom": "^29.7.0",
@@ -1,7 +0,0 @@
1
- import * as React from "react";
2
- import type { CSSProperties, ElementType, ForwardedRef, HTMLAttributes, MouseEvent, PropsWithChildren, ReactElement, ReactNode, RefObject, TouchEvent } from "react";
3
- declare const createElement: typeof React.createElement, createContext: typeof React.createContext, createRef: typeof React.createRef, forwardRef: typeof React.forwardRef, useCallback: typeof React.useCallback, useContext: typeof React.useContext, useEffect: typeof React.useEffect, useImperativeHandle: typeof React.useImperativeHandle, useMemo: typeof React.useMemo, useRef: typeof React.useRef, useState: typeof React.useState;
4
- declare const useId: () => string;
5
- declare const useLayoutEffect_do_not_use_directly: typeof React.useLayoutEffect;
6
- export { createElement, createContext, createRef, forwardRef, useCallback, useContext, useEffect, useId, useImperativeHandle, useLayoutEffect_do_not_use_directly, useMemo, useRef, useState, };
7
- export type { CSSProperties, ElementType, ForwardedRef, HTMLAttributes, MouseEvent, PropsWithChildren, ReactElement, ReactNode, RefObject, TouchEvent, };