react-resizable-panels 4.0.0-alpha.0 → 4.0.0-alpha.1
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.
|
@@ -7,13 +7,6 @@ import { Ref } from 'react';
|
|
|
7
7
|
import { RefObject } from 'react';
|
|
8
8
|
import { SetStateAction } from 'react';
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
* Panel group direction corresponds to the `flex-direction` CSS property.
|
|
12
|
-
* It determines how panels are are placed in the group group and the direction they can be resized in.
|
|
13
|
-
* Horizontal corresponds to flex "row" and vertical to "column".
|
|
14
|
-
*/
|
|
15
|
-
export declare type Direction = "horizontal" | "vertical";
|
|
16
|
-
|
|
17
10
|
/**
|
|
18
11
|
* A Group wraps a set of resizable Panel components.
|
|
19
12
|
* Group content can be resized _horizontally_ or _vertically_.
|
|
@@ -21,17 +14,21 @@ export declare type Direction = "horizontal" | "vertical";
|
|
|
21
14
|
* For unit testing purposes, Group elements always include the following data attributes:
|
|
22
15
|
*
|
|
23
16
|
* ```html
|
|
24
|
-
* <div data-group
|
|
17
|
+
* <div data-group="your-group-id">
|
|
25
18
|
* ```
|
|
26
19
|
*/
|
|
27
|
-
export declare function Group({ children, className, defaultLayout,
|
|
20
|
+
export declare function Group({ children, className, defaultLayout, disableCursor, disabled, elementRef, groupRef, id: idProp, onLayoutChange: onLayoutChangeUnstable, orientation, style }: GroupProps): JSX.Element;
|
|
28
21
|
|
|
29
22
|
/**
|
|
30
23
|
* Imperative Group API.
|
|
24
|
+
*
|
|
25
|
+
* ℹ️ The `useGroupRef` and `useGroupCallbackRef` hooks are exported for convenience use in TypeScript projects.
|
|
31
26
|
*/
|
|
32
27
|
declare interface GroupImperativeHandle {
|
|
33
28
|
/**
|
|
34
29
|
* Get the Group's current layout as a map of Panel id to percentage (0..100)
|
|
30
|
+
*
|
|
31
|
+
* @return Map of Panel id to percentage (0..100)
|
|
35
32
|
*/
|
|
36
33
|
getLayout: () => {
|
|
37
34
|
[panelId: string]: number;
|
|
@@ -51,11 +48,11 @@ export declare type GroupProps = {
|
|
|
51
48
|
/**
|
|
52
49
|
* Panel and Separator components that comprise this group.
|
|
53
50
|
*/
|
|
54
|
-
children?: ReactNode;
|
|
51
|
+
children?: ReactNode | undefined;
|
|
55
52
|
/**
|
|
56
53
|
* CSS class name.
|
|
57
54
|
*/
|
|
58
|
-
className?: string;
|
|
55
|
+
className?: string | undefined;
|
|
59
56
|
/**
|
|
60
57
|
* Default layout for the Group.
|
|
61
58
|
*
|
|
@@ -63,24 +60,20 @@ export declare type GroupProps = {
|
|
|
63
60
|
*
|
|
64
61
|
* ⚠️ Refer to the documentation for how to avoid layout shift when using server components.
|
|
65
62
|
*/
|
|
66
|
-
defaultLayout?: Layout;
|
|
67
|
-
/**
|
|
68
|
-
* Specifies the resizable direction ("horizontal" or "vertical"); defaults to "horizontal"
|
|
69
|
-
*/
|
|
70
|
-
direction?: "horizontal" | "vertical";
|
|
63
|
+
defaultLayout?: Layout | undefined;
|
|
71
64
|
/**
|
|
72
65
|
* This library sets custom mouse cursor styles to indicate drag state.
|
|
73
66
|
* Use this prop to disable that behavior for Panels and Separators in this group.
|
|
74
67
|
*/
|
|
75
|
-
disableCursor?: boolean;
|
|
68
|
+
disableCursor?: boolean | undefined;
|
|
76
69
|
/**
|
|
77
70
|
* Disable resize functionality.
|
|
78
71
|
*/
|
|
79
|
-
disabled?: boolean;
|
|
72
|
+
disabled?: boolean | undefined;
|
|
80
73
|
/**
|
|
81
74
|
* Ref attached to the root `HTMLDivElement`.
|
|
82
75
|
*/
|
|
83
|
-
elementRef?: Ref<HTMLDivElement
|
|
76
|
+
elementRef?: Ref<HTMLDivElement> | undefined;
|
|
84
77
|
/**
|
|
85
78
|
* Exposes the following imperative API:
|
|
86
79
|
* - `getLayout(): Layout`
|
|
@@ -88,24 +81,28 @@ export declare type GroupProps = {
|
|
|
88
81
|
*
|
|
89
82
|
* ℹ️ The `useGroupRef` and `useGroupCallbackRef` hooks are exported for convenience use in TypeScript projects.
|
|
90
83
|
*/
|
|
91
|
-
groupRef?: Ref<GroupImperativeHandle
|
|
84
|
+
groupRef?: Ref<GroupImperativeHandle> | undefined;
|
|
92
85
|
/**
|
|
93
86
|
* Uniquely identifies this group within an application.
|
|
94
87
|
* Falls back to `useId` when not provided.
|
|
95
88
|
*
|
|
96
|
-
* ℹ️ This value will also be assigned to the `data-group
|
|
89
|
+
* ℹ️ This value will also be assigned to the `data-group` attribute.
|
|
97
90
|
*/
|
|
98
|
-
id?: string | number;
|
|
91
|
+
id?: string | number | undefined;
|
|
99
92
|
/**
|
|
100
93
|
* Called when panel sizes change; receives a map of Panel id to size.
|
|
101
94
|
*/
|
|
102
|
-
onLayoutChange?: (layout: Layout) => void;
|
|
95
|
+
onLayoutChange?: (layout: Layout) => void | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* Specifies the resizable orientation ("horizontal" or "vertical"); defaults to "horizontal"
|
|
98
|
+
*/
|
|
99
|
+
orientation?: "horizontal" | "vertical" | undefined;
|
|
103
100
|
/**
|
|
104
101
|
* CSS properties.
|
|
105
102
|
*
|
|
106
103
|
* ⚠️ The following styles cannot be overridden: `display`, `flex-direction`, `flex-wrap`, and `overflow`.
|
|
107
104
|
*/
|
|
108
|
-
style?: CSSProperties;
|
|
105
|
+
style?: CSSProperties | undefined;
|
|
109
106
|
};
|
|
110
107
|
|
|
111
108
|
/**
|
|
@@ -115,10 +112,18 @@ export declare type Layout = {
|
|
|
115
112
|
[id: string]: number;
|
|
116
113
|
};
|
|
117
114
|
|
|
115
|
+
export declare type LayoutStorage = Pick<Storage, "getItem" | "setItem">;
|
|
116
|
+
|
|
118
117
|
export declare type OnGroupLayoutChange = GroupProps["onLayoutChange"];
|
|
119
118
|
|
|
120
119
|
export declare type OnPanelResize = PanelProps["onResize"];
|
|
121
120
|
|
|
121
|
+
/**
|
|
122
|
+
* Panel group orientation loosely relates to the `aria-orientation` attribute.
|
|
123
|
+
* It determines how panels are are laid out within the group group and the direction they can be resized in.
|
|
124
|
+
*/
|
|
125
|
+
export declare type Orientation = "horizontal" | "vertical";
|
|
126
|
+
|
|
122
127
|
/**
|
|
123
128
|
* A Panel wraps resizable content and can be configured with min/max size constraints and collapsible behavior.
|
|
124
129
|
*
|
|
@@ -131,27 +136,33 @@ export declare type OnPanelResize = PanelProps["onResize"];
|
|
|
131
136
|
* For unit testing purposes, Panel elements always include the following data attributes:
|
|
132
137
|
*
|
|
133
138
|
* ```html
|
|
134
|
-
* <div data-panel
|
|
139
|
+
* <div data-panel="your-panel-id">
|
|
135
140
|
* ```
|
|
136
141
|
*/
|
|
137
142
|
export declare function Panel({ children, className, collapsedSize, collapsible, defaultSize, elementRef, id: idProp, maxSize, minSize, onResize: onResizeUnstable, panelRef, style }: PanelProps): JSX.Element;
|
|
138
143
|
|
|
139
144
|
/**
|
|
140
145
|
* Imperative Panel API
|
|
146
|
+
*
|
|
147
|
+
* ℹ️ The `usePanelRef` and `usePanelCallbackRef` hooks are exported for convenience use in TypeScript projects.
|
|
141
148
|
*/
|
|
142
149
|
declare interface PanelImperativeHandle {
|
|
143
150
|
/**
|
|
144
151
|
* Collapse the Panel to it's `collapsedSize`.
|
|
145
|
-
*
|
|
152
|
+
*
|
|
153
|
+
* ⚠️ This method will do nothing if the Panel is not `collapsible` or if it is already collapsed.
|
|
146
154
|
*/
|
|
147
155
|
collapse: () => void;
|
|
148
156
|
/**
|
|
149
157
|
* Expand a collapsed Panel to its most recent size.
|
|
150
|
-
*
|
|
158
|
+
*
|
|
159
|
+
* ⚠️ This method will do nothing if the Panel is not currently collapsed.
|
|
151
160
|
*/
|
|
152
161
|
expand: () => void;
|
|
153
162
|
/**
|
|
154
163
|
* Get the current size of the Panel in pixels as well as a percentage of the parent group (0..100).
|
|
164
|
+
*
|
|
165
|
+
* @return Panel size (in pixels and as a percentage of the parent group)
|
|
155
166
|
*/
|
|
156
167
|
getSize: () => PanelSize;
|
|
157
168
|
/**
|
|
@@ -160,7 +171,11 @@ declare interface PanelImperativeHandle {
|
|
|
160
171
|
isCollapsed: () => boolean;
|
|
161
172
|
/**
|
|
162
173
|
* Update the Panel's size.
|
|
163
|
-
*
|
|
174
|
+
*
|
|
175
|
+
* ℹ️ Size may be specified in pixel format (number) or as a percentage (string).
|
|
176
|
+
*
|
|
177
|
+
* @param size New panel size
|
|
178
|
+
* @return Applied size (after validation)
|
|
164
179
|
*/
|
|
165
180
|
resize: (size: number | string) => void;
|
|
166
181
|
}
|
|
@@ -171,46 +186,46 @@ export declare type PanelProps = PropsWithChildren<{
|
|
|
171
186
|
*
|
|
172
187
|
* ⚠️ Class is applied to nested `HTMLDivElement` to avoid styles that interfere with Flex layout.
|
|
173
188
|
*/
|
|
174
|
-
className?: string;
|
|
189
|
+
className?: string | undefined;
|
|
175
190
|
/**
|
|
176
191
|
* Panel size when collapsed; defaults to 0.
|
|
177
192
|
*/
|
|
178
|
-
collapsedSize?: number | string;
|
|
193
|
+
collapsedSize?: number | string | undefined;
|
|
179
194
|
/**
|
|
180
195
|
* This panel can be collapsed.
|
|
181
196
|
*
|
|
182
197
|
* ℹ️ A collapsible panel will collapse when it's size is less than of the specified `minSize`
|
|
183
198
|
*/
|
|
184
|
-
collapsible?: boolean;
|
|
199
|
+
collapsible?: boolean | undefined;
|
|
185
200
|
/**
|
|
186
201
|
* Default size of Panel within its parent group; default is auto-assigned based on the total number of Panels.
|
|
187
202
|
*/
|
|
188
|
-
defaultSize?: number | string;
|
|
203
|
+
defaultSize?: number | string | undefined;
|
|
189
204
|
/**
|
|
190
205
|
* Ref attached to the root `HTMLDivElement`.
|
|
191
206
|
*/
|
|
192
|
-
elementRef?: Ref<HTMLDivElement
|
|
207
|
+
elementRef?: Ref<HTMLDivElement> | undefined;
|
|
193
208
|
/**
|
|
194
209
|
* Uniquely identifies this panel within the parent group.
|
|
195
210
|
* Falls back to `useId` when not provided.
|
|
196
211
|
*
|
|
197
212
|
* ℹ️ This prop is used to associate persisted group layouts with the original panel.
|
|
198
213
|
*
|
|
199
|
-
* ℹ️ This value will also be assigned to the `data-panel
|
|
214
|
+
* ℹ️ This value will also be assigned to the `data-panel` attribute.
|
|
200
215
|
*/
|
|
201
|
-
id?: string | number;
|
|
216
|
+
id?: string | number | undefined;
|
|
202
217
|
/**
|
|
203
218
|
* Maximum size of Panel within its parent group; defaults to 100%.
|
|
204
219
|
*/
|
|
205
|
-
maxSize?: number | string;
|
|
220
|
+
maxSize?: number | string | undefined;
|
|
206
221
|
/**
|
|
207
222
|
* Minimum size of Panel within its parent group; defaults to 0%.
|
|
208
223
|
*/
|
|
209
|
-
minSize?: number | string;
|
|
224
|
+
minSize?: number | string | undefined;
|
|
210
225
|
/**
|
|
211
226
|
* Called when panel sizes change; receives a map of Panel id to size.
|
|
212
227
|
*/
|
|
213
|
-
onResize?: (panelSize: PanelSize) => void;
|
|
228
|
+
onResize?: ((panelSize: PanelSize, id: string | number | undefined) => void) | undefined;
|
|
214
229
|
/**
|
|
215
230
|
* Exposes the following imperative API:
|
|
216
231
|
* - `collapse(): void`
|
|
@@ -222,13 +237,13 @@ export declare type PanelProps = PropsWithChildren<{
|
|
|
222
237
|
*
|
|
223
238
|
* ℹ️ The `usePanelRef` and `usePanelCallbackRef` hooks are exported for convenience use in TypeScript projects.
|
|
224
239
|
*/
|
|
225
|
-
panelRef?: Ref<PanelImperativeHandle
|
|
240
|
+
panelRef?: Ref<PanelImperativeHandle> | undefined;
|
|
226
241
|
/**
|
|
227
242
|
* CSS properties.
|
|
228
243
|
*
|
|
229
244
|
* ⚠️ Style is applied to nested `HTMLDivElement` to avoid styles that interfere with Flex layout.
|
|
230
245
|
*/
|
|
231
|
-
style?: CSSProperties;
|
|
246
|
+
style?: CSSProperties | undefined;
|
|
232
247
|
}>;
|
|
233
248
|
|
|
234
249
|
export declare type PanelSize = {
|
|
@@ -244,7 +259,7 @@ export declare type PanelSize = {
|
|
|
244
259
|
* For unit testing purposes, Separator elements always include the following data attributes:
|
|
245
260
|
*
|
|
246
261
|
* ```html
|
|
247
|
-
* <div data-separator
|
|
262
|
+
* <div data-separator="your-separator-id" role="separator" />
|
|
248
263
|
* ```
|
|
249
264
|
*/
|
|
250
265
|
export declare function Separator({ children, className, elementRef, id: idProp, style }: SeparatorProps): JSX.Element;
|
|
@@ -257,18 +272,18 @@ export declare type SeparatorProps = PropsWithChildren<{
|
|
|
257
272
|
*
|
|
258
273
|
* ⚠️ The following properties cannot be overridden: `flex-grow`, `flex-shrink`
|
|
259
274
|
*/
|
|
260
|
-
className?: string;
|
|
275
|
+
className?: string | undefined;
|
|
261
276
|
/**
|
|
262
277
|
* Ref attached to the root `HTMLDivElement`.
|
|
263
278
|
*/
|
|
264
|
-
elementRef?: Ref<HTMLDivElement
|
|
279
|
+
elementRef?: Ref<HTMLDivElement> | undefined;
|
|
265
280
|
/**
|
|
266
281
|
* Uniquely identifies the separator within the parent group.
|
|
267
282
|
* Falls back to `useId` when not provided.
|
|
268
283
|
*
|
|
269
|
-
* ℹ️ This value will also be assigned to the `data-separator
|
|
284
|
+
* ℹ️ This value will also be assigned to the `data-separator` attribute.
|
|
270
285
|
*/
|
|
271
|
-
id?: string | number;
|
|
286
|
+
id?: string | number | undefined;
|
|
272
287
|
/**
|
|
273
288
|
* CSS properties.
|
|
274
289
|
*
|
|
@@ -276,17 +291,17 @@ export declare type SeparatorProps = PropsWithChildren<{
|
|
|
276
291
|
*
|
|
277
292
|
* ⚠️ The following properties cannot be overridden: `flex-grow`, `flex-shrink`
|
|
278
293
|
*/
|
|
279
|
-
style?: CSSProperties;
|
|
294
|
+
style?: CSSProperties | undefined;
|
|
280
295
|
}>;
|
|
281
296
|
|
|
282
297
|
export declare type SizeUnit = "px" | "%" | "em" | "rem" | "vh" | "vw";
|
|
283
298
|
|
|
284
299
|
export declare function useDefaultLayout({ groupId, storage }: {
|
|
285
300
|
groupId: string;
|
|
286
|
-
storage
|
|
301
|
+
storage: LayoutStorage;
|
|
287
302
|
}): {
|
|
288
|
-
defaultLayout:
|
|
289
|
-
onLayoutChange: (layout: Layout) => void;
|
|
303
|
+
defaultLayout: any;
|
|
304
|
+
onLayoutChange: (layout: Layout) => void | undefined;
|
|
290
305
|
};
|
|
291
306
|
|
|
292
307
|
/**
|