react-resizable-panels 4.11.1 → 4.12.0
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.
|
@@ -112,8 +112,13 @@ export declare type GroupProps = HTMLAttributes<HTMLDivElement> & {
|
|
|
112
112
|
*
|
|
113
113
|
* ℹ️ For layout changes caused by pointer events, this method is not called until the pointer has been released.
|
|
114
114
|
* This method is recommended when saving layouts to some storage api.
|
|
115
|
+
*
|
|
116
|
+
* ℹ️ The second argument contains meta information about the layout change.
|
|
117
|
+
* The `isUserInteraction` attribute signals whether the resize was caused by direct user input.
|
|
118
|
+
* It is true for resizes caused by pointer or keyboard input
|
|
119
|
+
* and false for other triggers (e.g. imperative API calls, initial mount, etc.)
|
|
115
120
|
*/
|
|
116
|
-
onLayoutChanged?: (layout: Layout) => void
|
|
121
|
+
onLayoutChanged?: (layout: Layout, meta: LayoutChangedMeta) => void;
|
|
117
122
|
/**
|
|
118
123
|
* Minimum size of the resizable hit target area (either `Separator` or `Panel` edge)
|
|
119
124
|
* This threshold ensures are large enough to avoid mis-clicks.
|
|
@@ -153,6 +158,22 @@ export declare type Layout = {
|
|
|
153
158
|
[id: string]: number;
|
|
154
159
|
};
|
|
155
160
|
|
|
161
|
+
/**
|
|
162
|
+
* Metadata describing a completed layout change, passed as the second argument
|
|
163
|
+
* to the `onLayoutChanged` callback. See #716.
|
|
164
|
+
*/
|
|
165
|
+
export declare type LayoutChangedMeta = {
|
|
166
|
+
/**
|
|
167
|
+
* `true` when the change was caused by the user directly manipulating a
|
|
168
|
+
* separator — releasing a pointer drag or pressing a resize key (arrow keys,
|
|
169
|
+
* Home/End, Enter). `false` for every other source (programmatic `setLayout`
|
|
170
|
+
* and other imperative API calls, constraint recompute, default-size change,
|
|
171
|
+
* initial mount), because the library cannot attribute the caller's intent
|
|
172
|
+
* there.
|
|
173
|
+
*/
|
|
174
|
+
isUserInteraction: boolean;
|
|
175
|
+
};
|
|
176
|
+
|
|
156
177
|
export declare type LayoutStorage = Pick<Storage, "getItem" | "setItem">;
|
|
157
178
|
|
|
158
179
|
export declare type OnGroupLayoutChange = GroupProps["onLayoutChange"];
|
|
@@ -409,13 +430,18 @@ export declare type SizeUnit = "px" | "%" | "em" | "rem" | "vh" | "vw";
|
|
|
409
430
|
* Saves and restores group layouts between page loads.
|
|
410
431
|
* It can be configured to store values using `localStorage`, `sessionStorage`, cookies, or any other persistence layer that makes sense for your application.
|
|
411
432
|
*/
|
|
412
|
-
export declare function useDefaultLayout({ debounceSaveMs, panelIds, storage, ...rest }: {
|
|
433
|
+
export declare function useDefaultLayout({ debounceSaveMs, onlySaveAfterUserInteractions, panelIds, storage, ...rest }: {
|
|
413
434
|
/**
|
|
414
435
|
* Debounce save operation by the specified number of milliseconds; defaults to 100ms
|
|
415
436
|
*
|
|
416
437
|
* @deprecated Use the {@link onLayoutChanged} callback instead; it does not require debouncing
|
|
417
438
|
*/
|
|
418
439
|
debounceSaveMs?: number;
|
|
440
|
+
/**
|
|
441
|
+
* Only auto-save layouts that were directly caused by user input (e.g. keyboard or mouse events).
|
|
442
|
+
* Ignore layout changes resulting from imperative API calls or window resize events.
|
|
443
|
+
*/
|
|
444
|
+
onlySaveAfterUserInteractions?: boolean;
|
|
419
445
|
/**
|
|
420
446
|
* For Groups that contain conditionally-rendered Panels, this prop can be used to save and restore multiple layouts.
|
|
421
447
|
*
|
|
@@ -455,7 +481,7 @@ export declare function useDefaultLayout({ debounceSaveMs, panelIds, storage, ..
|
|
|
455
481
|
/**
|
|
456
482
|
* Attach this callback on the `Group` as the `onLayoutChanged` prop.
|
|
457
483
|
*/
|
|
458
|
-
onLayoutChanged: (layout: Layout) => void
|
|
484
|
+
onLayoutChanged: (layout: Layout, meta: LayoutChangedMeta) => void;
|
|
459
485
|
};
|
|
460
486
|
|
|
461
487
|
/**
|