@iamevan/react-resizable-panels 3.0.6
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/README.md +260 -0
- package/dist/declarations/src/Panel.d.ts +70 -0
- package/dist/declarations/src/PanelGroup.d.ts +38 -0
- package/dist/declarations/src/PanelResizeHandle.d.ts +23 -0
- package/dist/declarations/src/PanelResizeHandleRegistry.d.ts +19 -0
- package/dist/declarations/src/constants.d.ts +15 -0
- package/dist/declarations/src/hooks/usePanelGroupContext.d.ts +4 -0
- package/dist/declarations/src/index.d.ts +23 -0
- package/dist/declarations/src/types.d.ts +3 -0
- package/dist/declarations/src/utils/assert.d.ts +1 -0
- package/dist/declarations/src/utils/csp.d.ts +2 -0
- package/dist/declarations/src/utils/cursor.d.ts +18 -0
- package/dist/declarations/src/utils/dom/getPanelElement.d.ts +1 -0
- package/dist/declarations/src/utils/dom/getPanelElementsForGroup.d.ts +1 -0
- package/dist/declarations/src/utils/dom/getPanelGroupElement.d.ts +1 -0
- package/dist/declarations/src/utils/dom/getResizeHandleElement.d.ts +1 -0
- package/dist/declarations/src/utils/dom/getResizeHandleElementIndex.d.ts +1 -0
- package/dist/declarations/src/utils/dom/getResizeHandleElementsForGroup.d.ts +1 -0
- package/dist/declarations/src/utils/dom/getResizeHandlePanelIds.d.ts +2 -0
- package/dist/declarations/src/utils/rects/getIntersectingRectangle.d.ts +2 -0
- package/dist/declarations/src/utils/rects/intersects.d.ts +2 -0
- package/dist/declarations/src/utils/rects/types.d.ts +6 -0
- package/dist/iamevan-react-resizable-panels.browser.development.js +2592 -0
- package/dist/iamevan-react-resizable-panels.browser.js +2486 -0
- package/dist/iamevan-react-resizable-panels.d.ts +2 -0
- package/dist/iamevan-react-resizable-panels.development.edge-light.js +2365 -0
- package/dist/iamevan-react-resizable-panels.development.js +2599 -0
- package/dist/iamevan-react-resizable-panels.edge-light.js +2264 -0
- package/dist/iamevan-react-resizable-panels.js +2488 -0
- package/package.json +84 -0
package/README.md
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
# react-resizable-panels
|
|
2
|
+
|
|
3
|
+
React components for resizable panel groups/layouts
|
|
4
|
+
|
|
5
|
+
```jsx
|
|
6
|
+
import { Panel, PanelGroup, PanelResizeHandle } from "react-resizable-panels";
|
|
7
|
+
|
|
8
|
+
<PanelGroup autoSaveId="example" direction="horizontal">
|
|
9
|
+
<Panel defaultSize={25}>
|
|
10
|
+
<SourcesExplorer />
|
|
11
|
+
</Panel>
|
|
12
|
+
<PanelResizeHandle />
|
|
13
|
+
<Panel>
|
|
14
|
+
<SourceViewer />
|
|
15
|
+
</Panel>
|
|
16
|
+
<PanelResizeHandle />
|
|
17
|
+
<Panel defaultSize={25}>
|
|
18
|
+
<Console />
|
|
19
|
+
</Panel>
|
|
20
|
+
</PanelGroup>;
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## If you like this project, 🎉 [become a sponsor](https://github.com/sponsors/bvaughn/) or ☕ [buy me a coffee](http://givebrian.coffee/)
|
|
24
|
+
|
|
25
|
+
## Props
|
|
26
|
+
|
|
27
|
+
### `PanelGroup`
|
|
28
|
+
|
|
29
|
+
| prop | type | description |
|
|
30
|
+
| :----------- | :--------------------------- | :--------------------------------------------------------------- |
|
|
31
|
+
| `autoSaveId` | `?string` | Unique id used to auto-save group arrangement via `localStorage` |
|
|
32
|
+
| `children` | `ReactNode` | Arbitrary React element(s) |
|
|
33
|
+
| `className` | `?string` | Class name to attach to root element |
|
|
34
|
+
| `direction` | `"horizontal" \| "vertical"` | Group orientation |
|
|
35
|
+
| `id` | `?string` | Group id; falls back to `useId` when not provided |
|
|
36
|
+
| `onLayout` | `?(sizes: number[]) => void` | Called when group layout changes |
|
|
37
|
+
| `storage` | `?PanelGroupStorage` | Custom storage API; defaults to `localStorage` <sup>1</sup> |
|
|
38
|
+
| `style` | `?CSSProperties` | CSS style to attach to root element |
|
|
39
|
+
| `tagName` | `?string = "div"` | HTML element tag name for root element |
|
|
40
|
+
|
|
41
|
+
<sup>1</sup>: Storage API must define the following _synchronous_ methods:
|
|
42
|
+
|
|
43
|
+
- `getItem: (name:string) => string`
|
|
44
|
+
- `setItem: (name: string, value: string) => void`
|
|
45
|
+
|
|
46
|
+
`PanelGroup` components also expose an imperative API for manual resizing:
|
|
47
|
+
| method | description |
|
|
48
|
+
| :---------------------------- | :--------------------------------------------------------------- |
|
|
49
|
+
| `getId(): string` | Gets the panel group's ID. |
|
|
50
|
+
| `getLayout(): number[]` | Gets the panel group's current _layout_ (`[1 - 100, ...]`). |
|
|
51
|
+
| `setLayout(layout: number[])` | Resize panel group to the specified _layout_ (`[1 - 100, ...]`). |
|
|
52
|
+
|
|
53
|
+
### `Panel`
|
|
54
|
+
|
|
55
|
+
| prop | type | description |
|
|
56
|
+
| :-------------- | :------------------------ | :-------------------------------------------------------------------------------------------- |
|
|
57
|
+
| `children` | `ReactNode` | Arbitrary React element(s) |
|
|
58
|
+
| `className` | `?string` | Class name to attach to root element |
|
|
59
|
+
| `collapsedSize` | `?number=0` | Panel should collapse to this size |
|
|
60
|
+
| `collapsible` | `?boolean=false` | Panel should collapse when resized beyond its `minSize` |
|
|
61
|
+
| `defaultSize` | `?number` | Initial size of panel (numeric value between 1-100) |
|
|
62
|
+
| `id` | `?string` | Panel id (unique within group); falls back to `useId` when not provided |
|
|
63
|
+
| `maxSize` | `?number = 100` | Maximum allowable size of panel (numeric value between 1-100); defaults to `100` |
|
|
64
|
+
| `minSize` | `?number = 10` | Minimum allowable size of panel (numeric value between 1-100); defaults to `10` |
|
|
65
|
+
| `onCollapse` | `?() => void` | Called when panel is collapsed |
|
|
66
|
+
| `onExpand` | `?() => void` | Called when panel is expanded |
|
|
67
|
+
| `onResize` | `?(size: number) => void` | Called when panel is resized; `size` parameter is a numeric value between 1-100. <sup>1</sup> |
|
|
68
|
+
| `order` | `?number` | Order of panel within group; required for groups with conditionally rendered panels |
|
|
69
|
+
| `style` | `?CSSProperties` | CSS style to attach to root element |
|
|
70
|
+
| `tagName` | `?string = "div"` | HTML element tag name for root element |
|
|
71
|
+
|
|
72
|
+
<sup>1</sup>: If any `Panel` has an `onResize` callback, the `order` prop should be provided for all `Panel`s.
|
|
73
|
+
|
|
74
|
+
`Panel` components also expose an imperative API for manual resizing:
|
|
75
|
+
| method | description |
|
|
76
|
+
| :----------------------- | :--------------------------------------------------------------------------------- |
|
|
77
|
+
| `collapse()` | If panel is `collapsible`, collapse it fully. |
|
|
78
|
+
| `expand()` | If panel is currently _collapsed_, expand it to its most recent size. |
|
|
79
|
+
| `getId(): string` | Gets the ID of the panel. |
|
|
80
|
+
| `getSize(): number` | Gets the current size of the panel as a percentage (`1 - 100`). |
|
|
81
|
+
| `isCollapsed(): boolean` | Returns `true` if the panel is currently _collapsed_ (`size === 0`). |
|
|
82
|
+
| `isExpanded(): boolean` | Returns `true` if the panel is currently _not collapsed_ (`!isCollapsed()`). |
|
|
83
|
+
| `resize(size: number)` | Resize panel to the specified _percentage_ (`1 - 100`). |
|
|
84
|
+
|
|
85
|
+
### `PanelResizeHandle`
|
|
86
|
+
|
|
87
|
+
| prop | type | description |
|
|
88
|
+
| :--------------- | :-------------------------------------------- | :------------------------------------------------------------------------------ |
|
|
89
|
+
| `children` | `?ReactNode` | Custom drag UI; can be any arbitrary React element(s) |
|
|
90
|
+
| `className` | `?string` | Class name to attach to root element |
|
|
91
|
+
| `hitAreaMargins` | `?{ coarse: number = 15; fine: number = 5; }` | Allow this much margin when determining resizable handle hit detection |
|
|
92
|
+
| `disabled` | `?boolean` | Disable drag handle |
|
|
93
|
+
| `id` | `?string` | Resize handle id (unique within group); falls back to `useId` when not provided |
|
|
94
|
+
| `onDragging` | `?(isDragging: boolean) => void` | Called when group layout changes |
|
|
95
|
+
| `style` | `?CSSProperties` | CSS style to attach to root element |
|
|
96
|
+
| `tagName` | `?string = "div"` | HTML element tag name for root element |
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## FAQ
|
|
101
|
+
|
|
102
|
+
### Can panel sizes be specified in pixels?
|
|
103
|
+
|
|
104
|
+
No. Pixel-based constraints [added significant complexity](https://github.com/bvaughn/react-resizable-panels/pull/176) to the initialization and validation logic and so I've decided not to support them. You may be able to implement a version of this yourself following [a pattern like this](https://github.com/bvaughn/react-resizable-panels/issues/46#issuecomment-1368108416) but it is not officially supported by this library.
|
|
105
|
+
|
|
106
|
+
### How can I fix layout/sizing problems with conditionally rendered panels?
|
|
107
|
+
|
|
108
|
+
The `Panel` API doesn't _require_ `id` and `order` props because they aren't necessary for static layouts. When panels are conditionally rendered though, it's best to supply these values.
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
<PanelGroup direction="horizontal">
|
|
112
|
+
{renderSideBar && (
|
|
113
|
+
<>
|
|
114
|
+
<Panel id="sidebar" minSize={25} order={1}>
|
|
115
|
+
<Sidebar />
|
|
116
|
+
</Panel>
|
|
117
|
+
<PanelResizeHandle />
|
|
118
|
+
</>
|
|
119
|
+
)}
|
|
120
|
+
<Panel minSize={25} order={2}>
|
|
121
|
+
<Main />
|
|
122
|
+
</Panel>
|
|
123
|
+
</PanelGroup>
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Can I attach a ref to the DOM elements?
|
|
127
|
+
|
|
128
|
+
No. I think exposing two refs (one for the component's imperative API and one for a DOM element) would be awkward. This library does export several utility methods for accessing the underlying DOM elements though. For example:
|
|
129
|
+
|
|
130
|
+
```tsx
|
|
131
|
+
import {
|
|
132
|
+
getPanelElement,
|
|
133
|
+
getPanelGroupElement,
|
|
134
|
+
getResizeHandleElement,
|
|
135
|
+
Panel,
|
|
136
|
+
PanelGroup,
|
|
137
|
+
PanelResizeHandle,
|
|
138
|
+
} from "react-resizable-panels";
|
|
139
|
+
|
|
140
|
+
export function Example() {
|
|
141
|
+
const refs = useRef();
|
|
142
|
+
|
|
143
|
+
useEffect(() => {
|
|
144
|
+
const groupElement = getPanelGroupElement("group");
|
|
145
|
+
const leftPanelElement = getPanelElement("left-panel");
|
|
146
|
+
const rightPanelElement = getPanelElement("right-panel");
|
|
147
|
+
const resizeHandleElement = getResizeHandleElement("resize-handle");
|
|
148
|
+
|
|
149
|
+
// If you want to, you can store them in a ref to pass around
|
|
150
|
+
refs.current = {
|
|
151
|
+
groupElement,
|
|
152
|
+
leftPanelElement,
|
|
153
|
+
rightPanelElement,
|
|
154
|
+
resizeHandleElement,
|
|
155
|
+
};
|
|
156
|
+
}, []);
|
|
157
|
+
|
|
158
|
+
return (
|
|
159
|
+
<PanelGroup direction="horizontal" id="group">
|
|
160
|
+
<Panel id="left-panel">{/* ... */}</Panel>
|
|
161
|
+
<PanelResizeHandle id="resize-handle" />
|
|
162
|
+
<Panel id="right-panel">{/* ... */}</Panel>
|
|
163
|
+
</PanelGroup>
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Why don't I see any resize UI?
|
|
169
|
+
|
|
170
|
+
This likely means that you haven't applied any CSS to style the resize handles. By default, a resize handle is just an empty DOM element. To add styling, use the `className` or `style` props:
|
|
171
|
+
|
|
172
|
+
```tsx
|
|
173
|
+
// Tailwind example
|
|
174
|
+
<PanelResizeHandle className="w-2 bg-blue-800" />
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Can panel sizes be persistent?
|
|
178
|
+
|
|
179
|
+
Yes. Panel groups with an `autoSaveId` prop will automatically save and restore their layouts on mount.
|
|
180
|
+
|
|
181
|
+
### How can I use persistent layouts with SSR?
|
|
182
|
+
|
|
183
|
+
By default, this library uses `localStorage` to persist layouts. With server rendering, this can cause a flicker when the default layout (rendered on the server) is replaced with the persisted layout (in `localStorage`). The way to avoid this flicker is to also persist the layout with a cookie like so:
|
|
184
|
+
|
|
185
|
+
#### Server component
|
|
186
|
+
|
|
187
|
+
```tsx
|
|
188
|
+
import ResizablePanels from "@/app/ResizablePanels";
|
|
189
|
+
import { cookies } from "next/headers";
|
|
190
|
+
|
|
191
|
+
export function ServerComponent() {
|
|
192
|
+
const layout = cookies().get("react-resizable-panels:layout");
|
|
193
|
+
|
|
194
|
+
let defaultLayout;
|
|
195
|
+
if (layout) {
|
|
196
|
+
defaultLayout = JSON.parse(layout.value);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return <ClientComponent defaultLayout={defaultLayout} />;
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
#### Client component
|
|
204
|
+
|
|
205
|
+
```tsx
|
|
206
|
+
"use client";
|
|
207
|
+
|
|
208
|
+
import { Panel, PanelGroup, PanelResizeHandle } from "react-resizable-panels";
|
|
209
|
+
|
|
210
|
+
export function ClientComponent({
|
|
211
|
+
defaultLayout = [33, 67],
|
|
212
|
+
}: {
|
|
213
|
+
defaultLayout: number[] | undefined;
|
|
214
|
+
}) {
|
|
215
|
+
const onLayout = (sizes: number[]) => {
|
|
216
|
+
document.cookie = `react-resizable-panels:layout=${JSON.stringify(sizes)}`;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
return (
|
|
220
|
+
<PanelGroup direction="horizontal" onLayout={onLayout}>
|
|
221
|
+
<Panel defaultSize={defaultLayout[0]}>{/* ... */}</Panel>
|
|
222
|
+
<PanelResizeHandle className="w-2 bg-blue-800" />
|
|
223
|
+
<Panel defaultSize={defaultLayout[1]}>{/* ... */}</Panel>
|
|
224
|
+
</PanelGroup>
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
> [!NOTE]
|
|
230
|
+
> Be sure to specify a `defaultSize` prop for **every** `Panel` component to avoid layout flicker.
|
|
231
|
+
|
|
232
|
+
A demo of this is available [here](https://github.com/bvaughn/react-resizable-panels-demo-ssr).
|
|
233
|
+
|
|
234
|
+
#### How can I set the [CSP `"nonce"`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce) attribute?
|
|
235
|
+
|
|
236
|
+
```js
|
|
237
|
+
import { setNonce } from "react-resizable-panels";
|
|
238
|
+
|
|
239
|
+
setNonce("your-nonce-value-here");
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
#### How can I disable global cursor styles?
|
|
243
|
+
|
|
244
|
+
```js
|
|
245
|
+
import { disableGlobalCursorStyles } from "react-resizable-panels";
|
|
246
|
+
|
|
247
|
+
disableGlobalCursorStyles();
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
#### How can I override the global cursor styles?
|
|
251
|
+
|
|
252
|
+
```js
|
|
253
|
+
import { customizeGlobalCursorStyles, type CustomCursorStyleConfig } from "react-resizable-panels";
|
|
254
|
+
|
|
255
|
+
function customCursor({ isPointerDown }: CustomCursorStyleConfig) {
|
|
256
|
+
return isPointerDown ? "grabbing" : "grab";
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
customizeGlobalCursorStyles(customCursor);
|
|
260
|
+
```
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { ForwardedRef, HTMLAttributes, PropsWithChildren, ReactElement } from "react";
|
|
2
|
+
export type PanelOnCollapse = () => void;
|
|
3
|
+
export type PanelOnExpand = () => void;
|
|
4
|
+
export type PanelOnResize = (size: number, prevSize: number | undefined) => void;
|
|
5
|
+
export type PanelCallbacks = {
|
|
6
|
+
onCollapse?: PanelOnCollapse;
|
|
7
|
+
onExpand?: PanelOnExpand;
|
|
8
|
+
onResize?: PanelOnResize;
|
|
9
|
+
};
|
|
10
|
+
export type PanelConstraints = {
|
|
11
|
+
collapsedSize?: number | undefined;
|
|
12
|
+
collapsible?: boolean | undefined;
|
|
13
|
+
defaultSize?: number | undefined;
|
|
14
|
+
maxSize?: number | undefined;
|
|
15
|
+
minSize?: number | undefined;
|
|
16
|
+
};
|
|
17
|
+
export type PanelData = {
|
|
18
|
+
callbacks: PanelCallbacks;
|
|
19
|
+
constraints: PanelConstraints;
|
|
20
|
+
id: string;
|
|
21
|
+
idIsFromProps: boolean;
|
|
22
|
+
order: number | undefined;
|
|
23
|
+
};
|
|
24
|
+
export type ImperativePanelHandle = {
|
|
25
|
+
collapse: () => void;
|
|
26
|
+
expand: (minSize?: number) => void;
|
|
27
|
+
getId(): string;
|
|
28
|
+
getSize(): number;
|
|
29
|
+
isCollapsed: () => boolean;
|
|
30
|
+
isExpanded: () => boolean;
|
|
31
|
+
resize: (size: number) => void;
|
|
32
|
+
};
|
|
33
|
+
export type PanelProps<T extends keyof HTMLElementTagNameMap = keyof HTMLElementTagNameMap> = Omit<HTMLAttributes<HTMLElementTagNameMap[T]>, "id" | "onResize"> & PropsWithChildren<{
|
|
34
|
+
className?: string;
|
|
35
|
+
collapsedSize?: number | undefined;
|
|
36
|
+
collapsible?: boolean | undefined;
|
|
37
|
+
defaultSize?: number | undefined;
|
|
38
|
+
id?: string;
|
|
39
|
+
maxSize?: number | undefined;
|
|
40
|
+
minSize?: number | undefined;
|
|
41
|
+
onCollapse?: PanelOnCollapse;
|
|
42
|
+
onExpand?: PanelOnExpand;
|
|
43
|
+
onResize?: PanelOnResize;
|
|
44
|
+
order?: number;
|
|
45
|
+
style?: object;
|
|
46
|
+
tagName?: T;
|
|
47
|
+
}>;
|
|
48
|
+
export declare function PanelWithForwardedRef({ children, className: classNameFromProps, collapsedSize, collapsible, defaultSize, forwardedRef, id: idFromProps, maxSize, minSize, onCollapse, onExpand, onResize, order, style: styleFromProps, tagName: Type, ...rest }: PanelProps & {
|
|
49
|
+
forwardedRef: ForwardedRef<ImperativePanelHandle>;
|
|
50
|
+
}): ReactElement;
|
|
51
|
+
export declare namespace PanelWithForwardedRef {
|
|
52
|
+
var displayName: string;
|
|
53
|
+
}
|
|
54
|
+
export declare const Panel: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLObjectElement | HTMLElement | HTMLAnchorElement | HTMLAreaElement | HTMLAudioElement | HTMLBaseElement | HTMLQuoteElement | HTMLBodyElement | HTMLBRElement | HTMLButtonElement | HTMLCanvasElement | HTMLTableCaptionElement | HTMLTableColElement | HTMLDataElement | HTMLDataListElement | HTMLModElement | HTMLDetailsElement | HTMLDialogElement | HTMLDivElement | HTMLDListElement | HTMLEmbedElement | HTMLFieldSetElement | HTMLFormElement | HTMLHeadingElement | HTMLHeadElement | HTMLHRElement | HTMLHtmlElement | HTMLIFrameElement | HTMLImageElement | HTMLInputElement | HTMLLabelElement | HTMLLegendElement | HTMLLIElement | HTMLLinkElement | HTMLMapElement | HTMLMenuElement | HTMLMetaElement | HTMLMeterElement | HTMLOListElement | HTMLOptGroupElement | HTMLOptionElement | HTMLOutputElement | HTMLParagraphElement | HTMLPictureElement | HTMLPreElement | HTMLProgressElement | HTMLScriptElement | HTMLSelectElement | HTMLSlotElement | HTMLSourceElement | HTMLSpanElement | HTMLStyleElement | HTMLTableElement | HTMLTableSectionElement | HTMLTableCellElement | HTMLTemplateElement | HTMLTextAreaElement | HTMLTimeElement | HTMLTitleElement | HTMLTableRowElement | HTMLTrackElement | HTMLUListElement | HTMLVideoElement>, "id" | "onResize"> & {
|
|
55
|
+
className?: string;
|
|
56
|
+
collapsedSize?: number | undefined;
|
|
57
|
+
collapsible?: boolean | undefined;
|
|
58
|
+
defaultSize?: number | undefined;
|
|
59
|
+
id?: string;
|
|
60
|
+
maxSize?: number | undefined;
|
|
61
|
+
minSize?: number | undefined;
|
|
62
|
+
onCollapse?: PanelOnCollapse;
|
|
63
|
+
onExpand?: PanelOnExpand;
|
|
64
|
+
onResize?: PanelOnResize;
|
|
65
|
+
order?: number;
|
|
66
|
+
style?: object;
|
|
67
|
+
tagName?: keyof HTMLElementTagNameMap | undefined;
|
|
68
|
+
} & {
|
|
69
|
+
children?: import("react").ReactNode | undefined;
|
|
70
|
+
} & import("react").RefAttributes<ImperativePanelHandle>>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { CSSProperties, HTMLAttributes, PropsWithChildren } from "react";
|
|
2
|
+
import { Direction } from "./types.js";
|
|
3
|
+
export type ImperativePanelGroupHandle = {
|
|
4
|
+
getId: () => string;
|
|
5
|
+
getLayout: () => number[];
|
|
6
|
+
setLayout: (layout: number[]) => void;
|
|
7
|
+
};
|
|
8
|
+
export type PanelGroupStorage = {
|
|
9
|
+
getItem(name: string): string | null;
|
|
10
|
+
setItem(name: string, value: string): void;
|
|
11
|
+
};
|
|
12
|
+
export type PanelGroupOnLayout = (layout: number[]) => void;
|
|
13
|
+
export type PanelGroupProps = Omit<HTMLAttributes<keyof HTMLElementTagNameMap>, "id"> & PropsWithChildren<{
|
|
14
|
+
autoSaveId?: string | null;
|
|
15
|
+
className?: string;
|
|
16
|
+
direction: Direction;
|
|
17
|
+
id?: string | null;
|
|
18
|
+
keyboardResizeBy?: number | null;
|
|
19
|
+
onLayout?: PanelGroupOnLayout | null;
|
|
20
|
+
storage?: PanelGroupStorage;
|
|
21
|
+
style?: CSSProperties;
|
|
22
|
+
tagName?: keyof HTMLElementTagNameMap;
|
|
23
|
+
dir?: "auto" | "ltr" | "rtl" | undefined;
|
|
24
|
+
}>;
|
|
25
|
+
export declare const PanelGroup: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<keyof HTMLElementTagNameMap>, "id"> & {
|
|
26
|
+
autoSaveId?: string | null;
|
|
27
|
+
className?: string;
|
|
28
|
+
direction: Direction;
|
|
29
|
+
id?: string | null;
|
|
30
|
+
keyboardResizeBy?: number | null;
|
|
31
|
+
onLayout?: PanelGroupOnLayout | null;
|
|
32
|
+
storage?: PanelGroupStorage;
|
|
33
|
+
style?: CSSProperties;
|
|
34
|
+
tagName?: keyof HTMLElementTagNameMap;
|
|
35
|
+
dir?: "auto" | "ltr" | "rtl" | undefined;
|
|
36
|
+
} & {
|
|
37
|
+
children?: import("react").ReactNode | undefined;
|
|
38
|
+
} & import("react").RefAttributes<ImperativePanelGroupHandle>>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CSSProperties, HTMLAttributes, PropsWithChildren, ReactElement } from "react";
|
|
2
|
+
import { PointerHitAreaMargins } from "./PanelResizeHandleRegistry.js";
|
|
3
|
+
export type PanelResizeHandleOnDragging = (isDragging: boolean) => void;
|
|
4
|
+
export type ResizeHandlerState = "drag" | "hover" | "inactive";
|
|
5
|
+
export type PanelResizeHandleProps = Omit<HTMLAttributes<keyof HTMLElementTagNameMap>, "id" | "onBlur" | "onClick" | "onFocus" | "onPointerDown" | "onPointerUp"> & PropsWithChildren<{
|
|
6
|
+
className?: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
hitAreaMargins?: PointerHitAreaMargins;
|
|
9
|
+
id?: string | null;
|
|
10
|
+
onBlur?: () => void;
|
|
11
|
+
onClick?: () => void;
|
|
12
|
+
onDragging?: PanelResizeHandleOnDragging;
|
|
13
|
+
onFocus?: () => void;
|
|
14
|
+
onPointerDown?: () => void;
|
|
15
|
+
onPointerUp?: () => void;
|
|
16
|
+
style?: CSSProperties;
|
|
17
|
+
tabIndex?: number;
|
|
18
|
+
tagName?: keyof HTMLElementTagNameMap;
|
|
19
|
+
}>;
|
|
20
|
+
export declare function PanelResizeHandle({ children, className: classNameFromProps, disabled, hitAreaMargins, id: idFromProps, onBlur, onClick, onDragging, onFocus, onPointerDown, onPointerUp, style: styleFromProps, tabIndex, tagName: Type, ...rest }: PanelResizeHandleProps): ReactElement;
|
|
21
|
+
export declare namespace PanelResizeHandle {
|
|
22
|
+
var displayName: string;
|
|
23
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Direction, ResizeEvent } from "./types.js";
|
|
2
|
+
export type ResizeHandlerAction = "down" | "move" | "up";
|
|
3
|
+
export type SetResizeHandlerState = (action: ResizeHandlerAction, isActive: boolean, event: ResizeEvent | null) => void;
|
|
4
|
+
export type PointerHitAreaMargins = {
|
|
5
|
+
coarse: number;
|
|
6
|
+
fine: number;
|
|
7
|
+
};
|
|
8
|
+
export type ResizeHandlerData = {
|
|
9
|
+
direction: Direction;
|
|
10
|
+
element: HTMLElement;
|
|
11
|
+
hitAreaMargins: PointerHitAreaMargins;
|
|
12
|
+
setResizeHandlerState: SetResizeHandlerState;
|
|
13
|
+
};
|
|
14
|
+
export declare const EXCEEDED_HORIZONTAL_MIN = 1;
|
|
15
|
+
export declare const EXCEEDED_HORIZONTAL_MAX = 2;
|
|
16
|
+
export declare const EXCEEDED_VERTICAL_MIN = 4;
|
|
17
|
+
export declare const EXCEEDED_VERTICAL_MAX = 8;
|
|
18
|
+
export declare function registerResizeHandle(resizeHandleId: string, element: HTMLElement, direction: Direction, hitAreaMargins: PointerHitAreaMargins, setResizeHandlerState: SetResizeHandlerState): () => void;
|
|
19
|
+
export declare function reportConstraintsViolation(resizeHandleId: string, flag: number): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const DATA_ATTRIBUTES: {
|
|
2
|
+
readonly group: "data-panel-group";
|
|
3
|
+
readonly groupDirection: "data-panel-group-direction";
|
|
4
|
+
readonly groupId: "data-panel-group-id";
|
|
5
|
+
readonly panel: "data-panel";
|
|
6
|
+
readonly panelCollapsible: "data-panel-collapsible";
|
|
7
|
+
readonly panelId: "data-panel-id";
|
|
8
|
+
readonly panelSize: "data-panel-size";
|
|
9
|
+
readonly resizeHandle: "data-resize-handle";
|
|
10
|
+
readonly resizeHandleActive: "data-resize-handle-active";
|
|
11
|
+
readonly resizeHandleEnabled: "data-panel-resize-handle-enabled";
|
|
12
|
+
readonly resizeHandleId: "data-panel-resize-handle-id";
|
|
13
|
+
readonly resizeHandleState: "data-resize-handle-state";
|
|
14
|
+
};
|
|
15
|
+
export declare const PRECISION = 10;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Panel } from "./Panel.js";
|
|
2
|
+
import { PanelGroup } from "./PanelGroup.js";
|
|
3
|
+
import { PanelResizeHandle } from "./PanelResizeHandle.js";
|
|
4
|
+
import { DATA_ATTRIBUTES } from "./constants.js";
|
|
5
|
+
import { usePanelGroupContext } from "./hooks/usePanelGroupContext.js";
|
|
6
|
+
import { assert } from "./utils/assert.js";
|
|
7
|
+
import { setNonce } from "./utils/csp.js";
|
|
8
|
+
import { customizeGlobalCursorStyles, disableGlobalCursorStyles, enableGlobalCursorStyles } from "./utils/cursor.js";
|
|
9
|
+
import { getPanelElement } from "./utils/dom/getPanelElement.js";
|
|
10
|
+
import { getPanelElementsForGroup } from "./utils/dom/getPanelElementsForGroup.js";
|
|
11
|
+
import { getPanelGroupElement } from "./utils/dom/getPanelGroupElement.js";
|
|
12
|
+
import { getResizeHandleElement } from "./utils/dom/getResizeHandleElement.js";
|
|
13
|
+
import { getResizeHandleElementIndex } from "./utils/dom/getResizeHandleElementIndex.js";
|
|
14
|
+
import { getResizeHandleElementsForGroup } from "./utils/dom/getResizeHandleElementsForGroup.js";
|
|
15
|
+
import { getResizeHandlePanelIds } from "./utils/dom/getResizeHandlePanelIds.js";
|
|
16
|
+
import { getIntersectingRectangle } from "./utils/rects/getIntersectingRectangle.js";
|
|
17
|
+
import { intersects } from "./utils/rects/intersects.js";
|
|
18
|
+
import type { ImperativePanelHandle, PanelOnCollapse, PanelOnExpand, PanelOnResize, PanelProps } from "./Panel.js";
|
|
19
|
+
import type { ImperativePanelGroupHandle, PanelGroupOnLayout, PanelGroupProps, PanelGroupStorage } from "./PanelGroup.js";
|
|
20
|
+
import type { PanelResizeHandleOnDragging, PanelResizeHandleProps } from "./PanelResizeHandle.js";
|
|
21
|
+
import type { PointerHitAreaMargins } from "./PanelResizeHandleRegistry.js";
|
|
22
|
+
import type { CustomCursorStyleConfig } from "./utils/cursor.js";
|
|
23
|
+
export { ImperativePanelGroupHandle, ImperativePanelHandle, PanelGroupOnLayout, PanelGroupProps, PanelGroupStorage, PanelOnCollapse, PanelOnExpand, PanelOnResize, PanelProps, PanelResizeHandleOnDragging, PanelResizeHandleProps, PointerHitAreaMargins, Panel, PanelGroup, PanelResizeHandle, usePanelGroupContext, assert, getIntersectingRectangle, intersects, getPanelElement, getPanelElementsForGroup, getPanelGroupElement, getResizeHandleElement, getResizeHandleElementIndex, getResizeHandleElementsForGroup, getResizeHandlePanelIds, setNonce, customizeGlobalCursorStyles, disableGlobalCursorStyles, enableGlobalCursorStyles, CustomCursorStyleConfig, DATA_ATTRIBUTES, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function assert(expectedCondition: any, message: string): asserts expectedCondition;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type CursorState = "horizontal" | "intersection" | "vertical";
|
|
2
|
+
export type CustomCursorStyleConfig = {
|
|
3
|
+
exceedsHorizontalMaximum: boolean;
|
|
4
|
+
exceedsHorizontalMinimum: boolean;
|
|
5
|
+
exceedsVerticalMaximum: boolean;
|
|
6
|
+
exceedsVerticalMinimum: boolean;
|
|
7
|
+
intersectsHorizontalDragHandle: boolean;
|
|
8
|
+
intersectsVerticalDragHandle: boolean;
|
|
9
|
+
isPointerDown: boolean;
|
|
10
|
+
};
|
|
11
|
+
type GetCustomCursorStyleFunction = (config: CustomCursorStyleConfig) => string;
|
|
12
|
+
export declare function customizeGlobalCursorStyles(callback: GetCustomCursorStyleFunction | null): void;
|
|
13
|
+
export declare function disableGlobalCursorStyles(): void;
|
|
14
|
+
export declare function enableGlobalCursorStyles(): void;
|
|
15
|
+
export declare function getCursorStyle(state: CursorState, constraintFlags: number, isPointerDown: boolean): string;
|
|
16
|
+
export declare function resetGlobalCursorStyle(): void;
|
|
17
|
+
export declare function setGlobalCursorStyle(state: CursorState, constraintFlags: number, isPointerDown: boolean): void;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getPanelElement(id: string, scope?: ParentNode | HTMLElement): HTMLElement | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getPanelElementsForGroup(groupId: string, scope?: ParentNode | HTMLElement): HTMLElement[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getPanelGroupElement(id: string, rootElement?: ParentNode | HTMLElement): HTMLElement | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getResizeHandleElement(id: string, scope?: ParentNode | HTMLElement): HTMLElement | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getResizeHandleElementIndex(groupId: string, id: string, scope?: ParentNode | HTMLElement): number | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getResizeHandleElementsForGroup(groupId: string, scope?: ParentNode | HTMLElement): HTMLElement[];
|