react-resizable-panels 0.0.37 → 0.0.39
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/.eslintrc.json +22 -0
- package/CHANGELOG.md +8 -0
- package/dist/react-resizable-panels.d.ts +1 -1
- package/dist/react-resizable-panels.d.ts.map +1 -1
- package/dist/react-resizable-panels.js +83 -54
- package/dist/react-resizable-panels.js.map +1 -1
- package/dist/react-resizable-panels.module.js +84 -55
- package/dist/react-resizable-panels.module.js.map +1 -1
- package/package.json +5 -1
- package/src/Panel.ts +1 -1
- package/src/PanelContexts.ts +1 -1
- package/src/PanelGroup.ts +4 -4
- package/src/PanelResizeHandle.ts +21 -9
- package/src/hooks/useIsomorphicEffect.ts +1 -1
- package/src/hooks/useUniqueId.ts +5 -2
- package/src/hooks/useWindowSplitterBehavior.ts +23 -2
- package/src/types.ts +1 -1
- package/src/vendor/react.ts +61 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RefObject, useEffect } from "react";
|
|
1
|
+
import { RefObject, useEffect } from "../vendor/react";
|
|
2
2
|
import { PRECISION } from "../constants";
|
|
3
3
|
|
|
4
4
|
import { CommittedValues, PanelDataMap } from "../PanelGroup";
|
|
@@ -82,8 +82,14 @@ export function useWindowSplitterPanelGroupBehavior({
|
|
|
82
82
|
handle.setAttribute("aria-valuenow", "" + Math.round(parseInt(flexGrow)));
|
|
83
83
|
|
|
84
84
|
const onKeyDown = (event: KeyboardEvent) => {
|
|
85
|
+
if (event.defaultPrevented) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
85
89
|
switch (event.key) {
|
|
86
90
|
case "Enter": {
|
|
91
|
+
event.preventDefault();
|
|
92
|
+
|
|
87
93
|
const index = panelsArray.findIndex(
|
|
88
94
|
(panel) => panel.id === idBefore
|
|
89
95
|
);
|
|
@@ -144,7 +150,14 @@ export function useWindowSplitterPanelGroupBehavior({
|
|
|
144
150
|
return () => {
|
|
145
151
|
cleanupFunctions.forEach((cleanupFunction) => cleanupFunction());
|
|
146
152
|
};
|
|
147
|
-
}, [
|
|
153
|
+
}, [
|
|
154
|
+
committedValuesRef,
|
|
155
|
+
groupId,
|
|
156
|
+
panels,
|
|
157
|
+
panelSizeBeforeCollapse,
|
|
158
|
+
setSizes,
|
|
159
|
+
sizes,
|
|
160
|
+
]);
|
|
148
161
|
}
|
|
149
162
|
|
|
150
163
|
export function useWindowSplitterResizeHandlerBehavior({
|
|
@@ -167,6 +180,10 @@ export function useWindowSplitterResizeHandlerBehavior({
|
|
|
167
180
|
}
|
|
168
181
|
|
|
169
182
|
const onKeyDown = (event: KeyboardEvent) => {
|
|
183
|
+
if (event.defaultPrevented) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
|
|
170
187
|
switch (event.key) {
|
|
171
188
|
case "ArrowDown":
|
|
172
189
|
case "ArrowLeft":
|
|
@@ -174,10 +191,14 @@ export function useWindowSplitterResizeHandlerBehavior({
|
|
|
174
191
|
case "ArrowUp":
|
|
175
192
|
case "End":
|
|
176
193
|
case "Home": {
|
|
194
|
+
event.preventDefault();
|
|
195
|
+
|
|
177
196
|
resizeHandler(event);
|
|
178
197
|
break;
|
|
179
198
|
}
|
|
180
199
|
case "F6": {
|
|
200
|
+
event.preventDefault();
|
|
201
|
+
|
|
181
202
|
const handles = getResizeHandles();
|
|
182
203
|
const index = getResizeHandleIndex(handleId);
|
|
183
204
|
|
package/src/types.ts
CHANGED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// This module exists to work around Webpack issue https://github.com/webpack/webpack/issues/14814
|
|
2
|
+
// and limitations with ParcelJS parsing of the useId workaround (used below).
|
|
3
|
+
// For the time being, all react-resizable-panels must import "react" with the "* as React" syntax.
|
|
4
|
+
// To avoid mistakes, we use the ESLint "no-restricted-imports" to prevent "react" imports except in this file.
|
|
5
|
+
// See https://github.com/bvaughn/react-resizable-panels/issues/118
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line no-restricted-imports
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
|
|
10
|
+
// eslint-disable-next-line no-restricted-imports
|
|
11
|
+
import type {
|
|
12
|
+
CSSProperties,
|
|
13
|
+
ElementType,
|
|
14
|
+
ForwardedRef,
|
|
15
|
+
MouseEvent,
|
|
16
|
+
ReactNode,
|
|
17
|
+
RefObject,
|
|
18
|
+
TouchEvent,
|
|
19
|
+
} from "react";
|
|
20
|
+
|
|
21
|
+
const {
|
|
22
|
+
createElement,
|
|
23
|
+
createContext,
|
|
24
|
+
forwardRef,
|
|
25
|
+
useCallback,
|
|
26
|
+
useContext,
|
|
27
|
+
useEffect,
|
|
28
|
+
useImperativeHandle,
|
|
29
|
+
useLayoutEffect,
|
|
30
|
+
useMemo,
|
|
31
|
+
useRef,
|
|
32
|
+
useState,
|
|
33
|
+
} = React;
|
|
34
|
+
|
|
35
|
+
// `toString()` prevents bundlers from trying to `import { useId } from 'react'`
|
|
36
|
+
const useId = (React as any)["useId".toString()] as () => string;
|
|
37
|
+
|
|
38
|
+
export {
|
|
39
|
+
createElement,
|
|
40
|
+
createContext,
|
|
41
|
+
forwardRef,
|
|
42
|
+
useCallback,
|
|
43
|
+
useContext,
|
|
44
|
+
useEffect,
|
|
45
|
+
useId,
|
|
46
|
+
useImperativeHandle,
|
|
47
|
+
useLayoutEffect,
|
|
48
|
+
useMemo,
|
|
49
|
+
useRef,
|
|
50
|
+
useState,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export type {
|
|
54
|
+
CSSProperties,
|
|
55
|
+
ElementType,
|
|
56
|
+
ForwardedRef,
|
|
57
|
+
MouseEvent,
|
|
58
|
+
ReactNode,
|
|
59
|
+
RefObject,
|
|
60
|
+
TouchEvent,
|
|
61
|
+
};
|