react-resizable-panels 0.0.54 → 0.0.56

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.
Files changed (86) hide show
  1. package/.eslintrc.cjs +26 -0
  2. package/CHANGELOG.md +253 -80
  3. package/README.md +55 -49
  4. package/dist/declarations/src/Panel.d.ts +76 -20
  5. package/dist/declarations/src/PanelGroup.d.ts +29 -21
  6. package/dist/declarations/src/PanelResizeHandle.d.ts +1 -1
  7. package/dist/declarations/src/index.d.ts +5 -5
  8. package/dist/declarations/src/types.d.ts +3 -25
  9. package/dist/declarations/src/vendor/react.d.ts +4 -4
  10. package/dist/react-resizable-panels.browser.cjs.js +1279 -796
  11. package/dist/react-resizable-panels.browser.development.cjs.js +1404 -809
  12. package/dist/react-resizable-panels.browser.development.esm.js +1398 -803
  13. package/dist/react-resizable-panels.browser.esm.js +1279 -796
  14. package/dist/react-resizable-panels.cjs.js +1279 -796
  15. package/dist/react-resizable-panels.cjs.js.map +1 -0
  16. package/dist/react-resizable-panels.development.cjs.js +1399 -804
  17. package/dist/react-resizable-panels.development.esm.js +1400 -805
  18. package/dist/react-resizable-panels.development.node.cjs.js +1172 -755
  19. package/dist/react-resizable-panels.development.node.esm.js +1173 -756
  20. package/dist/react-resizable-panels.esm.js +1279 -796
  21. package/dist/react-resizable-panels.esm.js.map +1 -0
  22. package/dist/react-resizable-panels.node.cjs.js +1064 -749
  23. package/dist/react-resizable-panels.node.esm.js +1065 -750
  24. package/jest.config.js +10 -0
  25. package/package.json +3 -1
  26. package/src/Panel.test.tsx +308 -0
  27. package/src/Panel.ts +179 -127
  28. package/src/PanelGroup.test.tsx +210 -0
  29. package/src/PanelGroup.ts +751 -580
  30. package/src/PanelGroupContext.ts +33 -0
  31. package/src/PanelResizeHandle.ts +13 -8
  32. package/src/hooks/useUniqueId.ts +1 -1
  33. package/src/hooks/useWindowSplitterBehavior.ts +9 -161
  34. package/src/hooks/useWindowSplitterPanelGroupBehavior.ts +185 -0
  35. package/src/index.ts +24 -11
  36. package/src/types.ts +3 -29
  37. package/src/utils/adjustLayoutByDelta.test.ts +1808 -0
  38. package/src/utils/adjustLayoutByDelta.ts +211 -0
  39. package/src/utils/calculateAriaValues.test.ts +111 -0
  40. package/src/utils/calculateAriaValues.ts +67 -0
  41. package/src/utils/calculateDeltaPercentage.ts +68 -0
  42. package/src/utils/calculateDragOffsetPercentage.ts +30 -0
  43. package/src/utils/calculateUnsafeDefaultLayout.test.ts +92 -0
  44. package/src/utils/calculateUnsafeDefaultLayout.ts +55 -0
  45. package/src/utils/callPanelCallbacks.ts +81 -0
  46. package/src/utils/compareLayouts.test.ts +9 -0
  47. package/src/utils/compareLayouts.ts +12 -0
  48. package/src/utils/computePanelFlexBoxStyle.ts +44 -0
  49. package/src/utils/computePercentagePanelConstraints.test.ts +71 -0
  50. package/src/utils/computePercentagePanelConstraints.ts +56 -0
  51. package/src/utils/convertPercentageToPixels.test.ts +9 -0
  52. package/src/utils/convertPercentageToPixels.ts +6 -0
  53. package/src/utils/convertPixelConstraintsToPercentages.ts +55 -0
  54. package/src/utils/convertPixelsToPercentage.test.ts +9 -0
  55. package/src/utils/convertPixelsToPercentage.ts +6 -0
  56. package/src/utils/determinePivotIndices.ts +10 -0
  57. package/src/utils/dom/calculateAvailablePanelSizeInPixels.ts +29 -0
  58. package/src/utils/dom/getAvailableGroupSizePixels.ts +29 -0
  59. package/src/utils/dom/getPanelElement.ts +7 -0
  60. package/src/utils/dom/getPanelGroupElement.ts +7 -0
  61. package/src/utils/dom/getResizeHandleElement.ts +9 -0
  62. package/src/utils/dom/getResizeHandleElementIndex.ts +12 -0
  63. package/src/utils/dom/getResizeHandleElementsForGroup.ts +9 -0
  64. package/src/utils/dom/getResizeHandlePanelIds.ts +18 -0
  65. package/src/utils/events.ts +13 -0
  66. package/src/utils/getPercentageSizeFromMixedSizes.test.ts +47 -0
  67. package/src/utils/getPercentageSizeFromMixedSizes.ts +15 -0
  68. package/src/utils/getResizeEventCursorPosition.ts +19 -0
  69. package/src/utils/initializeDefaultStorage.ts +26 -0
  70. package/src/utils/numbers/fuzzyCompareNumbers.test.ts +16 -0
  71. package/src/utils/numbers/fuzzyCompareNumbers.ts +17 -0
  72. package/src/utils/numbers/fuzzyNumbersEqual.ts +9 -0
  73. package/src/utils/resizePanel.ts +41 -0
  74. package/src/utils/serialization.ts +9 -4
  75. package/src/utils/shouldMonitorPixelBasedConstraints.test.ts +23 -0
  76. package/src/utils/shouldMonitorPixelBasedConstraints.ts +13 -0
  77. package/src/utils/test-utils.ts +136 -0
  78. package/src/utils/validatePanelConstraints.test.ts +151 -0
  79. package/src/utils/validatePanelConstraints.ts +103 -0
  80. package/src/utils/validatePanelGroupLayout.test.ts +233 -0
  81. package/src/utils/validatePanelGroupLayout.ts +88 -0
  82. package/src/vendor/react.ts +4 -0
  83. package/.eslintrc.json +0 -22
  84. package/src/PanelContexts.ts +0 -20
  85. package/src/utils/coordinates.ts +0 -149
  86. package/src/utils/group.ts +0 -315
@@ -0,0 +1,33 @@
1
+ import { PanelData } from "./Panel";
2
+ import { MixedSizes } from "./types";
3
+ import { CSSProperties, createContext } from "./vendor/react";
4
+
5
+ export type ResizeEvent = KeyboardEvent | MouseEvent | TouchEvent;
6
+ export type ResizeHandler = (event: ResizeEvent) => void;
7
+
8
+ export type DragState = {
9
+ dragHandleId: string;
10
+ dragHandleRect: DOMRect;
11
+ initialCursorPosition: number;
12
+ initialLayout: number[];
13
+ };
14
+
15
+ export const PanelGroupContext = createContext<{
16
+ collapsePanel: (panelData: PanelData) => void;
17
+ direction: "horizontal" | "vertical";
18
+ dragState: DragState | null;
19
+ expandPanel: (panelData: PanelData) => void;
20
+ getPanelSize: (panelData: PanelData) => MixedSizes;
21
+ getPanelStyle: (panelData: PanelData) => CSSProperties;
22
+ groupId: string;
23
+ isPanelCollapsed: (panelData: PanelData) => boolean;
24
+ isPanelExpanded: (panelData: PanelData) => boolean;
25
+ registerPanel: (panelData: PanelData) => void;
26
+ registerResizeHandle: (dragHandleId: string) => ResizeHandler;
27
+ resizePanel: (panelData: PanelData, mixedSizes: Partial<MixedSizes>) => void;
28
+ startDragging: (dragHandleId: string, event: ResizeEvent) => void;
29
+ stopDragging: () => void;
30
+ unregisterPanel: (panelData: PanelData) => void;
31
+ } | null>(null);
32
+
33
+ PanelGroupContext.displayName = "PanelGroupContext";
@@ -1,3 +1,4 @@
1
+ import useUniqueId from "./hooks/useUniqueId";
1
2
  import {
2
3
  createElement,
3
4
  CSSProperties,
@@ -11,17 +12,17 @@ import {
11
12
  useRef,
12
13
  useState,
13
14
  } from "./vendor/react";
14
- import useUniqueId from "./hooks/useUniqueId";
15
15
 
16
16
  import { useWindowSplitterResizeHandlerBehavior } from "./hooks/useWindowSplitterBehavior";
17
- import { PanelGroupContext } from "./PanelContexts";
18
- import type {
19
- ResizeHandler,
17
+ import {
18
+ PanelGroupContext,
20
19
  ResizeEvent,
21
- PanelResizeHandleOnDragging,
22
- } from "./types";
20
+ ResizeHandler,
21
+ } from "./PanelGroupContext";
23
22
  import { getCursorStyle } from "./utils/cursor";
24
23
 
24
+ export type PanelResizeHandleOnDragging = (isDragging: boolean) => void;
25
+
25
26
  export type PanelResizeHandleProps = {
26
27
  children?: ReactNode;
27
28
  className?: string;
@@ -59,8 +60,8 @@ export function PanelResizeHandle({
59
60
  }
60
61
 
61
62
  const {
62
- activeHandleId,
63
63
  direction,
64
+ dragState,
64
65
  groupId,
65
66
  registerResizeHandle,
66
67
  startDragging,
@@ -68,7 +69,7 @@ export function PanelResizeHandle({
68
69
  } = panelGroupContext;
69
70
 
70
71
  const resizeHandleId = useUniqueId(idFromProps);
71
- const isDragging = activeHandleId === resizeHandleId;
72
+ const isDragging = dragState?.dragHandleId === resizeHandleId;
72
73
 
73
74
  const [isFocused, setIsFocused] = useState(false);
74
75
 
@@ -150,6 +151,10 @@ export function PanelResizeHandle({
150
151
  return createElement(Type, {
151
152
  children,
152
153
  className: classNameFromProps,
154
+
155
+ // CSS selectors
156
+ "data-resize-handle": "",
157
+
153
158
  "data-resize-handle-active": isDragging
154
159
  ? "pointer"
155
160
  : isFocused
@@ -15,5 +15,5 @@ export default function useUniqueId(
15
15
  idRef.current = "" + counter++;
16
16
  }
17
17
 
18
- return idRef.current;
18
+ return idFromParams ?? idRef.current;
19
19
  }
@@ -1,166 +1,12 @@
1
- import { RefObject, useEffect } from "../vendor/react";
2
- import { PRECISION } from "../constants";
3
-
4
- import { CommittedValues, PanelDataMap } from "../PanelGroup";
5
1
  import { ResizeHandler } from "../types";
6
- import {
7
- adjustByDelta,
8
- getPanel,
9
- getPanelGroup,
10
- getResizeHandle,
11
- getResizeHandleIndex,
12
- getResizeHandlePanelIds,
13
- getResizeHandles,
14
- getResizeHandlesForGroup,
15
- getFlexGrow,
16
- panelsMapToSortedArray,
17
- } from "../utils/group";
18
2
  import { assert } from "../utils/assert";
3
+ import { getResizeHandleElement } from "../utils/dom/getResizeHandleElement";
4
+ import { getResizeHandleElementIndex } from "../utils/dom/getResizeHandleElementIndex";
5
+ import { getResizeHandleElementsForGroup } from "../utils/dom/getResizeHandleElementsForGroup";
6
+ import { useEffect } from "../vendor/react";
19
7
 
20
8
  // https://www.w3.org/WAI/ARIA/apg/patterns/windowsplitter/
21
9
 
22
- export function useWindowSplitterPanelGroupBehavior({
23
- committedValuesRef,
24
- groupId,
25
- panels,
26
- setSizes,
27
- sizes,
28
- panelSizeBeforeCollapse,
29
- }: {
30
- committedValuesRef: RefObject<CommittedValues>;
31
- groupId: string;
32
- panels: PanelDataMap;
33
- setSizes: (sizes: number[]) => void;
34
- sizes: number[];
35
- panelSizeBeforeCollapse: RefObject<Map<string, number>>;
36
- }): void {
37
- useEffect(() => {
38
- const { direction, panels } = committedValuesRef.current!;
39
-
40
- const groupElement = getPanelGroup(groupId)!;
41
- const { height, width } = groupElement.getBoundingClientRect();
42
-
43
- const handles = getResizeHandlesForGroup(groupId);
44
- const cleanupFunctions = handles.map((handle) => {
45
- const handleId = handle.getAttribute("data-panel-resize-handle-id")!;
46
- const panelsArray = panelsMapToSortedArray(panels);
47
-
48
- const [idBefore, idAfter] = getResizeHandlePanelIds(
49
- groupId,
50
- handleId,
51
- panelsArray
52
- );
53
- if (idBefore == null || idAfter == null) {
54
- return () => {};
55
- }
56
-
57
- let minSize = 0;
58
- let maxSize = 100;
59
- let totalMinSize = 0;
60
- let totalMaxSize = 0;
61
-
62
- // A panel's effective min/max sizes also need to account for other panel's sizes.
63
- panelsArray.forEach((panelData) => {
64
- if (panelData.current.id === idBefore) {
65
- maxSize = panelData.current.maxSize;
66
- minSize = panelData.current.minSize;
67
- } else {
68
- totalMinSize += panelData.current.minSize;
69
- totalMaxSize += panelData.current.maxSize;
70
- }
71
- });
72
-
73
- const ariaValueMax = Math.min(maxSize, 100 - totalMinSize);
74
- const ariaValueMin = Math.max(
75
- minSize,
76
- (panelsArray.length - 1) * 100 - totalMaxSize
77
- );
78
-
79
- const flexGrow = getFlexGrow(panels, idBefore, sizes);
80
-
81
- handle.setAttribute("aria-valuemax", "" + Math.round(ariaValueMax));
82
- handle.setAttribute("aria-valuemin", "" + Math.round(ariaValueMin));
83
- handle.setAttribute("aria-valuenow", "" + Math.round(parseInt(flexGrow)));
84
-
85
- const onKeyDown = (event: KeyboardEvent) => {
86
- if (event.defaultPrevented) {
87
- return;
88
- }
89
-
90
- switch (event.key) {
91
- case "Enter": {
92
- event.preventDefault();
93
-
94
- const index = panelsArray.findIndex(
95
- (panel) => panel.current.id === idBefore
96
- );
97
- if (index >= 0) {
98
- const panelData = panelsArray[index];
99
- const size = sizes[index];
100
- if (size != null) {
101
- let delta = 0;
102
- if (
103
- size.toPrecision(PRECISION) <=
104
- panelData.current.minSize.toPrecision(PRECISION)
105
- ) {
106
- delta = direction === "horizontal" ? width : height;
107
- } else {
108
- delta = -(direction === "horizontal" ? width : height);
109
- }
110
-
111
- const nextSizes = adjustByDelta(
112
- event,
113
- panels,
114
- idBefore,
115
- idAfter,
116
- delta,
117
- sizes,
118
- panelSizeBeforeCollapse.current!,
119
- null
120
- );
121
- if (sizes !== nextSizes) {
122
- setSizes(nextSizes);
123
- }
124
- }
125
- }
126
- break;
127
- }
128
- }
129
- };
130
-
131
- handle.addEventListener("keydown", onKeyDown);
132
-
133
- const panelBefore = getPanel(idBefore);
134
- if (panelBefore != null) {
135
- handle.setAttribute("aria-controls", panelBefore.id);
136
- }
137
-
138
- return () => {
139
- handle.removeAttribute("aria-valuemax");
140
- handle.removeAttribute("aria-valuemin");
141
- handle.removeAttribute("aria-valuenow");
142
-
143
- handle.removeEventListener("keydown", onKeyDown);
144
-
145
- if (panelBefore != null) {
146
- handle.removeAttribute("aria-controls");
147
- }
148
- };
149
- });
150
-
151
- return () => {
152
- cleanupFunctions.forEach((cleanupFunction) => cleanupFunction());
153
- };
154
- }, [
155
- committedValuesRef,
156
- groupId,
157
- panels,
158
- panelSizeBeforeCollapse,
159
- setSizes,
160
- sizes,
161
- ]);
162
- }
163
-
164
10
  export function useWindowSplitterResizeHandlerBehavior({
165
11
  disabled,
166
12
  handleId,
@@ -175,7 +21,7 @@ export function useWindowSplitterResizeHandlerBehavior({
175
21
  return;
176
22
  }
177
23
 
178
- const handleElement = getResizeHandle(handleId);
24
+ const handleElement = getResizeHandleElement(handleId);
179
25
  if (handleElement == null) {
180
26
  return;
181
27
  }
@@ -200,8 +46,10 @@ export function useWindowSplitterResizeHandlerBehavior({
200
46
  case "F6": {
201
47
  event.preventDefault();
202
48
 
203
- const handles = getResizeHandles();
204
- const index = getResizeHandleIndex(handleId);
49
+ const groupId = handleElement.getAttribute("data-panel-group-id")!;
50
+
51
+ const handles = getResizeHandleElementsForGroup(groupId);
52
+ const index = getResizeHandleElementIndex(groupId, handleId);
205
53
 
206
54
  assert(index !== null);
207
55
 
@@ -0,0 +1,185 @@
1
+ import { isDevelopment } from "#is-development";
2
+ import { PanelData } from "../Panel";
3
+ import { PRECISION } from "../constants";
4
+ import { Direction } from "../types";
5
+ import { adjustLayoutByDelta } from "../utils/adjustLayoutByDelta";
6
+ import { assert } from "../utils/assert";
7
+ import { calculateAriaValues } from "../utils/calculateAriaValues";
8
+ import { determinePivotIndices } from "../utils/determinePivotIndices";
9
+ import { calculateAvailablePanelSizeInPixels } from "../utils/dom/calculateAvailablePanelSizeInPixels";
10
+ import { getAvailableGroupSizePixels } from "../utils/dom/getAvailableGroupSizePixels";
11
+ import { getPanelGroupElement } from "../utils/dom/getPanelGroupElement";
12
+ import { getResizeHandleElementsForGroup } from "../utils/dom/getResizeHandleElementsForGroup";
13
+ import { getResizeHandlePanelIds } from "../utils/dom/getResizeHandlePanelIds";
14
+ import { getPercentageSizeFromMixedSizes } from "../utils/getPercentageSizeFromMixedSizes";
15
+ import { RefObject, useEffect, useRef } from "../vendor/react";
16
+ import useIsomorphicLayoutEffect from "./useIsomorphicEffect";
17
+
18
+ // https://www.w3.org/WAI/ARIA/apg/patterns/windowsplitter/
19
+
20
+ export function useWindowSplitterPanelGroupBehavior({
21
+ committedValuesRef,
22
+ groupId,
23
+ layout,
24
+ panelDataArray,
25
+ setLayout,
26
+ }: {
27
+ committedValuesRef: RefObject<{
28
+ direction: Direction;
29
+ panelDataArray: PanelData[];
30
+ }>;
31
+ groupId: string;
32
+ layout: number[];
33
+ panelDataArray: PanelData[];
34
+ setLayout: (sizes: number[]) => void;
35
+ }): void {
36
+ const devWarningsRef = useRef<{
37
+ didWarnAboutMissingResizeHandle: boolean;
38
+ }>({
39
+ didWarnAboutMissingResizeHandle: false,
40
+ });
41
+
42
+ useIsomorphicLayoutEffect(() => {
43
+ const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
44
+ const resizeHandleElements = getResizeHandleElementsForGroup(groupId);
45
+
46
+ for (let index = 0; index < panelDataArray.length - 1; index++) {
47
+ const { valueMax, valueMin, valueNow } = calculateAriaValues({
48
+ groupSizePixels,
49
+ layout,
50
+ panelsArray: panelDataArray,
51
+ pivotIndices: [index, index + 1],
52
+ });
53
+
54
+ const resizeHandleElement = resizeHandleElements[index];
55
+ if (resizeHandleElement == null) {
56
+ if (isDevelopment) {
57
+ const { didWarnAboutMissingResizeHandle } = devWarningsRef.current;
58
+
59
+ if (!didWarnAboutMissingResizeHandle) {
60
+ devWarningsRef.current.didWarnAboutMissingResizeHandle = true;
61
+
62
+ console.warn(
63
+ `WARNING: Missing resize handle for PanelGroup "${groupId}"`
64
+ );
65
+ }
66
+ }
67
+ } else {
68
+ resizeHandleElement.setAttribute(
69
+ "aria-controls",
70
+ panelDataArray[index].id
71
+ );
72
+ resizeHandleElement.setAttribute(
73
+ "aria-valuemax",
74
+ "" + Math.round(valueMax)
75
+ );
76
+ resizeHandleElement.setAttribute(
77
+ "aria-valuemin",
78
+ "" + Math.round(valueMin)
79
+ );
80
+ resizeHandleElement.setAttribute(
81
+ "aria-valuenow",
82
+ "" + Math.round(valueNow)
83
+ );
84
+ }
85
+ }
86
+
87
+ return () => {
88
+ resizeHandleElements.forEach((resizeHandleElement, index) => {
89
+ resizeHandleElement.removeAttribute("aria-controls");
90
+ resizeHandleElement.removeAttribute("aria-valuemax");
91
+ resizeHandleElement.removeAttribute("aria-valuemin");
92
+ resizeHandleElement.removeAttribute("aria-valuenow");
93
+ });
94
+ };
95
+ }, [groupId, layout, panelDataArray]);
96
+
97
+ useEffect(() => {
98
+ const { direction, panelDataArray } = committedValuesRef.current!;
99
+
100
+ const groupElement = getPanelGroupElement(groupId);
101
+ assert(groupElement != null, `No group found for id "${groupId}"`);
102
+
103
+ const { height, width } = groupElement.getBoundingClientRect();
104
+
105
+ const handles = getResizeHandleElementsForGroup(groupId);
106
+ const cleanupFunctions = handles.map((handle) => {
107
+ const handleId = handle.getAttribute("data-panel-resize-handle-id")!;
108
+
109
+ const [idBefore, idAfter] = getResizeHandlePanelIds(
110
+ groupId,
111
+ handleId,
112
+ panelDataArray
113
+ );
114
+ if (idBefore == null || idAfter == null) {
115
+ return () => {};
116
+ }
117
+
118
+ const onKeyDown = (event: KeyboardEvent) => {
119
+ if (event.defaultPrevented) {
120
+ return;
121
+ }
122
+
123
+ switch (event.key) {
124
+ case "Enter": {
125
+ event.preventDefault();
126
+
127
+ const index = panelDataArray.findIndex(
128
+ (panelData) => panelData.id === idBefore
129
+ );
130
+ if (index >= 0) {
131
+ const panelData = panelDataArray[index];
132
+ const size = layout[index];
133
+ if (size != null) {
134
+ const groupSizePixels = getAvailableGroupSizePixels(groupId);
135
+
136
+ const minSize =
137
+ getPercentageSizeFromMixedSizes(
138
+ {
139
+ sizePercentage: panelData.constraints.minSizePercentage,
140
+ sizePixels: panelData.constraints.minSizePixels,
141
+ },
142
+ groupSizePixels
143
+ ) ?? 0;
144
+
145
+ let delta = 0;
146
+ if (
147
+ size.toPrecision(PRECISION) <= minSize.toPrecision(PRECISION)
148
+ ) {
149
+ delta = direction === "horizontal" ? width : height;
150
+ } else {
151
+ delta = -(direction === "horizontal" ? width : height);
152
+ }
153
+
154
+ const nextLayout = adjustLayoutByDelta({
155
+ delta,
156
+ groupSizePixels,
157
+ layout,
158
+ panelConstraints: panelDataArray.map(
159
+ (panelData) => panelData.constraints
160
+ ),
161
+ pivotIndices: determinePivotIndices(groupId, handleId),
162
+ trigger: "keyboard",
163
+ });
164
+ if (layout !== nextLayout) {
165
+ setLayout(nextLayout);
166
+ }
167
+ }
168
+ }
169
+ break;
170
+ }
171
+ }
172
+ };
173
+
174
+ handle.addEventListener("keydown", onKeyDown);
175
+
176
+ return () => {
177
+ handle.removeEventListener("keydown", onKeyDown);
178
+ };
179
+ });
180
+
181
+ return () => {
182
+ cleanupFunctions.forEach((cleanupFunction) => cleanupFunction());
183
+ };
184
+ }, [committedValuesRef, groupId, layout, panelDataArray, setLayout]);
185
+ }
package/src/index.ts CHANGED
@@ -2,30 +2,43 @@ import { Panel } from "./Panel";
2
2
  import { PanelGroup } from "./PanelGroup";
3
3
  import { PanelResizeHandle } from "./PanelResizeHandle";
4
4
 
5
- import type { ImperativePanelHandle, PanelProps } from "./Panel";
6
- import type { ImperativePanelGroupHandle, PanelGroupProps } from "./PanelGroup";
7
- import type { PanelResizeHandleProps } from "./PanelResizeHandle";
5
+ import type { MixedSizes } from "./types";
6
+
8
7
  import type {
9
- PanelGroupOnLayout,
10
- PanelGroupStorage,
8
+ ImperativePanelHandle,
11
9
  PanelOnCollapse,
10
+ PanelOnExpand,
12
11
  PanelOnResize,
12
+ PanelProps,
13
+ } from "./Panel";
14
+ import type {
15
+ ImperativePanelGroupHandle,
16
+ PanelGroupOnLayout,
17
+ PanelGroupProps,
18
+ PanelGroupStorage,
19
+ } from "./PanelGroup";
20
+ import type {
13
21
  PanelResizeHandleOnDragging,
14
- } from "./types";
22
+ PanelResizeHandleProps,
23
+ } from "./PanelResizeHandle";
15
24
 
16
25
  export {
17
26
  // TypeScript types
18
27
  ImperativePanelGroupHandle,
19
28
  ImperativePanelHandle,
20
- Panel,
21
- PanelOnCollapse,
22
- PanelOnResize,
23
- PanelGroup,
29
+ MixedSizes,
24
30
  PanelGroupOnLayout,
25
31
  PanelGroupProps,
26
32
  PanelGroupStorage,
33
+ PanelOnCollapse,
34
+ PanelOnExpand,
35
+ PanelOnResize,
27
36
  PanelProps,
28
- PanelResizeHandle,
29
37
  PanelResizeHandleOnDragging,
30
38
  PanelResizeHandleProps,
39
+
40
+ // React components
41
+ Panel,
42
+ PanelGroup,
43
+ PanelResizeHandle,
31
44
  };
package/src/types.ts CHANGED
@@ -1,34 +1,8 @@
1
- import { RefObject } from "./vendor/react";
2
-
3
1
  export type Direction = "horizontal" | "vertical";
4
2
 
5
- export type PanelGroupStorage = {
6
- getItem(name: string): string | null;
7
- setItem(name: string, value: string): void;
8
- };
9
-
10
- export type PanelGroupOnLayout = (sizes: number[]) => void;
11
- export type PanelOnCollapse = (collapsed: boolean) => void;
12
- export type PanelOnResize = (size: number, prevSize: number) => void;
13
- export type PanelResizeHandleOnDragging = (isDragging: boolean) => void;
14
-
15
- export type PanelCallbackRef = RefObject<{
16
- onCollapse: PanelOnCollapse | null;
17
- onResize: PanelOnResize | null;
18
- }>;
19
-
20
- export type PanelData = {
21
- current: {
22
- callbacksRef: PanelCallbackRef;
23
- collapsedSize: number;
24
- collapsible: boolean;
25
- defaultSize: number | null;
26
- id: string;
27
- idWasAutoGenerated: boolean;
28
- maxSize: number;
29
- minSize: number;
30
- order: number | null;
31
- };
3
+ export type MixedSizes = {
4
+ sizePercentage: number;
5
+ sizePixels: number;
32
6
  };
33
7
 
34
8
  export type ResizeEvent = KeyboardEvent | MouseEvent | TouchEvent;