react-resizable-panels 0.0.52 → 0.0.54
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/CHANGELOG.md +7 -0
- package/dist/declarations/src/Panel.d.ts +2 -2
- package/dist/declarations/src/PanelGroup.d.ts +2 -2
- package/dist/declarations/src/PanelResizeHandle.d.ts +5 -2
- package/dist/declarations/src/index.d.ts +7 -7
- package/dist/declarations/src/types.d.ts +2 -1
- package/dist/react-resizable-panels.browser.cjs.js +1432 -0
- package/dist/react-resizable-panels.browser.cjs.mjs +5 -0
- package/dist/react-resizable-panels.browser.development.cjs.js +1455 -0
- package/dist/react-resizable-panels.browser.development.cjs.mjs +5 -0
- package/dist/react-resizable-panels.browser.development.esm.js +1429 -0
- package/dist/react-resizable-panels.browser.esm.js +1406 -0
- package/dist/react-resizable-panels.cjs.js +17 -19
- package/dist/react-resizable-panels.development.cjs.js +42 -28
- package/dist/react-resizable-panels.development.cjs.mjs +5 -0
- package/dist/react-resizable-panels.development.esm.js +42 -28
- package/dist/react-resizable-panels.development.node.cjs.js +1373 -0
- package/dist/react-resizable-panels.development.node.cjs.mjs +5 -0
- package/dist/react-resizable-panels.development.node.esm.js +1347 -0
- package/dist/react-resizable-panels.esm.js +17 -19
- package/dist/react-resizable-panels.node.cjs.js +1345 -0
- package/dist/react-resizable-panels.node.cjs.mjs +5 -0
- package/dist/react-resizable-panels.node.esm.js +1319 -0
- package/package.json +26 -1
- package/src/Panel.ts +5 -5
- package/src/PanelContexts.ts +1 -4
- package/src/PanelGroup.ts +48 -10
- package/src/PanelResizeHandle.ts +1 -4
- package/src/env-conditions/browser.ts +1 -0
- package/src/env-conditions/node.ts +1 -0
- package/src/env-conditions/unknown.ts +1 -0
- package/src/hooks/useIsomorphicEffect.ts +2 -9
- package/src/types.ts +1 -0
- package/src/utils/group.ts +8 -2
- package/dist/react-resizable-panels.cjs.js.map +0 -1
- package/dist/react-resizable-panels.esm.js.map +0 -1
- package/src/utils/ssr.ts +0 -7
|
@@ -24,6 +24,8 @@ function _interopNamespace(e) {
|
|
|
24
24
|
|
|
25
25
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
26
26
|
|
|
27
|
+
const isBrowser = typeof window !== "undefined";
|
|
28
|
+
|
|
27
29
|
// This module exists to work around Webpack issue https://github.com/webpack/webpack/issues/14814
|
|
28
30
|
|
|
29
31
|
// eslint-disable-next-line no-restricted-imports
|
|
@@ -45,8 +47,7 @@ const {
|
|
|
45
47
|
// `toString()` prevents bundlers from trying to `import { useId } from 'react'`
|
|
46
48
|
const useId = React__namespace["useId".toString()];
|
|
47
49
|
|
|
48
|
-
const
|
|
49
|
-
const useIsomorphicLayoutEffect = canUseEffectHooks ? useLayoutEffect : () => {};
|
|
50
|
+
const useIsomorphicLayoutEffect = isBrowser ? useLayoutEffect : () => {};
|
|
50
51
|
|
|
51
52
|
const wrappedUseId = typeof useId === "function" ? useId : () => null;
|
|
52
53
|
let counter = 0;
|
|
@@ -60,10 +61,6 @@ function useUniqueId(idFromParams = null) {
|
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
const PanelGroupContext = createContext(null);
|
|
63
|
-
|
|
64
|
-
// Workaround for Parcel scope hoisting (which renames objects/functions).
|
|
65
|
-
// Casting to :any is required to avoid corrupting the generated TypeScript types.
|
|
66
|
-
// See github.com/parcel-bundler/parcel/issues/8724
|
|
67
64
|
PanelGroupContext.displayName = "PanelGroupContext";
|
|
68
65
|
|
|
69
66
|
function PanelWithForwardedRef({
|
|
@@ -131,6 +128,7 @@ function PanelWithForwardedRef({
|
|
|
131
128
|
collapsible,
|
|
132
129
|
defaultSize,
|
|
133
130
|
id: panelId,
|
|
131
|
+
idWasAutoGenerated: idFromProps == null,
|
|
134
132
|
maxSize,
|
|
135
133
|
minSize,
|
|
136
134
|
order
|
|
@@ -142,6 +140,7 @@ function PanelWithForwardedRef({
|
|
|
142
140
|
panelDataRef.current.collapsible = collapsible;
|
|
143
141
|
panelDataRef.current.defaultSize = defaultSize;
|
|
144
142
|
panelDataRef.current.id = panelId;
|
|
143
|
+
panelDataRef.current.idWasAutoGenerated = idFromProps == null;
|
|
145
144
|
panelDataRef.current.maxSize = maxSize;
|
|
146
145
|
panelDataRef.current.minSize = minSize;
|
|
147
146
|
panelDataRef.current.order = order;
|
|
@@ -181,10 +180,6 @@ const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
|
|
|
181
180
|
...props,
|
|
182
181
|
forwardedRef: ref
|
|
183
182
|
}));
|
|
184
|
-
|
|
185
|
-
// Workaround for Parcel scope hoisting (which renames objects/functions).
|
|
186
|
-
// Casting to :any is required to avoid corrupting the generated TypeScript types.
|
|
187
|
-
// See github.com/parcel-bundler/parcel/issues/8724
|
|
188
183
|
PanelWithForwardedRef.displayName = "Panel";
|
|
189
184
|
Panel.displayName = "forwardRef(Panel)";
|
|
190
185
|
|
|
@@ -286,12 +281,18 @@ function adjustByDelta(event, panels, idBefore, idAfter, delta, prevSizes, panel
|
|
|
286
281
|
}
|
|
287
282
|
function callPanelCallbacks(panelsArray, sizes, panelIdToLastNotifiedSizeMap) {
|
|
288
283
|
sizes.forEach((size, index) => {
|
|
284
|
+
const panelRef = panelsArray[index];
|
|
285
|
+
if (!panelRef) {
|
|
286
|
+
// Handle initial mount (when panels are registered too late to be in the panels array)
|
|
287
|
+
// The subsequent render+effects will handle the resize notification
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
289
290
|
const {
|
|
290
291
|
callbacksRef,
|
|
291
292
|
collapsedSize,
|
|
292
293
|
collapsible,
|
|
293
294
|
id
|
|
294
|
-
} =
|
|
295
|
+
} = panelRef.current;
|
|
295
296
|
const lastNotifiedSize = panelIdToLastNotifiedSizeMap[id];
|
|
296
297
|
if (lastNotifiedSize !== size) {
|
|
297
298
|
panelIdToLastNotifiedSizeMap[id] = size;
|
|
@@ -839,6 +840,11 @@ function PanelGroupWithForwardedRef({
|
|
|
839
840
|
// We store the initial Panel sizes in this ref, and apply move deltas to them instead of to the current sizes.
|
|
840
841
|
// This has the benefit of causing force-collapsed panels to spring back open if drag is reversed.
|
|
841
842
|
const initialDragStateRef = useRef(null);
|
|
843
|
+
useRef({
|
|
844
|
+
didLogDefaultSizeWarning: false,
|
|
845
|
+
didLogIdAndOrderWarning: false,
|
|
846
|
+
prevPanelIds: []
|
|
847
|
+
});
|
|
842
848
|
|
|
843
849
|
// Use a ref to guard against users passing inline props
|
|
844
850
|
const callbacksRef = useRef({
|
|
@@ -1286,10 +1292,6 @@ const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwar
|
|
|
1286
1292
|
...props,
|
|
1287
1293
|
forwardedRef: ref
|
|
1288
1294
|
}));
|
|
1289
|
-
|
|
1290
|
-
// Workaround for Parcel scope hoisting (which renames objects/functions).
|
|
1291
|
-
// Casting to :any is required to avoid corrupting the generated TypeScript types.
|
|
1292
|
-
// See github.com/parcel-bundler/parcel/issues/8724
|
|
1293
1295
|
PanelGroupWithForwardedRef.displayName = "PanelGroup";
|
|
1294
1296
|
PanelGroup.displayName = "forwardRef(PanelGroup)";
|
|
1295
1297
|
|
|
@@ -1425,10 +1427,6 @@ function PanelResizeHandle({
|
|
|
1425
1427
|
tabIndex: 0
|
|
1426
1428
|
});
|
|
1427
1429
|
}
|
|
1428
|
-
|
|
1429
|
-
// Workaround for Parcel scope hoisting (which renames objects/functions).
|
|
1430
|
-
// Casting to :any is required to avoid corrupting the generated TypeScript types.
|
|
1431
|
-
// See github.com/parcel-bundler/parcel/issues/8724
|
|
1432
1430
|
PanelResizeHandle.displayName = "PanelResizeHandle";
|
|
1433
1431
|
|
|
1434
1432
|
exports.Panel = Panel;
|
|
@@ -24,6 +24,8 @@ function _interopNamespace(e) {
|
|
|
24
24
|
|
|
25
25
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
26
26
|
|
|
27
|
+
const isBrowser = typeof window !== "undefined";
|
|
28
|
+
|
|
27
29
|
// This module exists to work around Webpack issue https://github.com/webpack/webpack/issues/14814
|
|
28
30
|
|
|
29
31
|
// eslint-disable-next-line no-restricted-imports
|
|
@@ -45,8 +47,7 @@ const {
|
|
|
45
47
|
// `toString()` prevents bundlers from trying to `import { useId } from 'react'`
|
|
46
48
|
const useId = React__namespace["useId".toString()];
|
|
47
49
|
|
|
48
|
-
const
|
|
49
|
-
const useIsomorphicLayoutEffect = canUseEffectHooks ? useLayoutEffect : () => {};
|
|
50
|
+
const useIsomorphicLayoutEffect = isBrowser ? useLayoutEffect : () => {};
|
|
50
51
|
|
|
51
52
|
const wrappedUseId = typeof useId === "function" ? useId : () => null;
|
|
52
53
|
let counter = 0;
|
|
@@ -60,10 +61,6 @@ function useUniqueId(idFromParams = null) {
|
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
const PanelGroupContext = createContext(null);
|
|
63
|
-
|
|
64
|
-
// Workaround for Parcel scope hoisting (which renames objects/functions).
|
|
65
|
-
// Casting to :any is required to avoid corrupting the generated TypeScript types.
|
|
66
|
-
// See github.com/parcel-bundler/parcel/issues/8724
|
|
67
64
|
PanelGroupContext.displayName = "PanelGroupContext";
|
|
68
65
|
|
|
69
66
|
function PanelWithForwardedRef({
|
|
@@ -131,6 +128,7 @@ function PanelWithForwardedRef({
|
|
|
131
128
|
collapsible,
|
|
132
129
|
defaultSize,
|
|
133
130
|
id: panelId,
|
|
131
|
+
idWasAutoGenerated: idFromProps == null,
|
|
134
132
|
maxSize,
|
|
135
133
|
minSize,
|
|
136
134
|
order
|
|
@@ -142,6 +140,7 @@ function PanelWithForwardedRef({
|
|
|
142
140
|
panelDataRef.current.collapsible = collapsible;
|
|
143
141
|
panelDataRef.current.defaultSize = defaultSize;
|
|
144
142
|
panelDataRef.current.id = panelId;
|
|
143
|
+
panelDataRef.current.idWasAutoGenerated = idFromProps == null;
|
|
145
144
|
panelDataRef.current.maxSize = maxSize;
|
|
146
145
|
panelDataRef.current.minSize = minSize;
|
|
147
146
|
panelDataRef.current.order = order;
|
|
@@ -181,10 +180,6 @@ const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
|
|
|
181
180
|
...props,
|
|
182
181
|
forwardedRef: ref
|
|
183
182
|
}));
|
|
184
|
-
|
|
185
|
-
// Workaround for Parcel scope hoisting (which renames objects/functions).
|
|
186
|
-
// Casting to :any is required to avoid corrupting the generated TypeScript types.
|
|
187
|
-
// See github.com/parcel-bundler/parcel/issues/8724
|
|
188
183
|
PanelWithForwardedRef.displayName = "Panel";
|
|
189
184
|
Panel.displayName = "forwardRef(Panel)";
|
|
190
185
|
|
|
@@ -286,12 +281,18 @@ function adjustByDelta(event, panels, idBefore, idAfter, delta, prevSizes, panel
|
|
|
286
281
|
}
|
|
287
282
|
function callPanelCallbacks(panelsArray, sizes, panelIdToLastNotifiedSizeMap) {
|
|
288
283
|
sizes.forEach((size, index) => {
|
|
284
|
+
const panelRef = panelsArray[index];
|
|
285
|
+
if (!panelRef) {
|
|
286
|
+
// Handle initial mount (when panels are registered too late to be in the panels array)
|
|
287
|
+
// The subsequent render+effects will handle the resize notification
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
289
290
|
const {
|
|
290
291
|
callbacksRef,
|
|
291
292
|
collapsedSize,
|
|
292
293
|
collapsible,
|
|
293
294
|
id
|
|
294
|
-
} =
|
|
295
|
+
} = panelRef.current;
|
|
295
296
|
const lastNotifiedSize = panelIdToLastNotifiedSizeMap[id];
|
|
296
297
|
if (lastNotifiedSize !== size) {
|
|
297
298
|
panelIdToLastNotifiedSizeMap[id] = size;
|
|
@@ -772,13 +773,6 @@ function savePanelGroupLayout(autoSaveId, panels, sizes, storage) {
|
|
|
772
773
|
}
|
|
773
774
|
}
|
|
774
775
|
|
|
775
|
-
function isServerRendering() {
|
|
776
|
-
try {
|
|
777
|
-
return typeof window === undefined;
|
|
778
|
-
} catch (error) {}
|
|
779
|
-
return true;
|
|
780
|
-
}
|
|
781
|
-
|
|
782
776
|
const debounceMap = {};
|
|
783
777
|
|
|
784
778
|
// PanelGroup might be rendering in a server-side environment where localStorage is not available
|
|
@@ -846,6 +840,11 @@ function PanelGroupWithForwardedRef({
|
|
|
846
840
|
// We store the initial Panel sizes in this ref, and apply move deltas to them instead of to the current sizes.
|
|
847
841
|
// This has the benefit of causing force-collapsed panels to spring back open if drag is reversed.
|
|
848
842
|
const initialDragStateRef = useRef(null);
|
|
843
|
+
const devWarningsRef = useRef({
|
|
844
|
+
didLogDefaultSizeWarning: false,
|
|
845
|
+
didLogIdAndOrderWarning: false,
|
|
846
|
+
prevPanelIds: []
|
|
847
|
+
});
|
|
849
848
|
|
|
850
849
|
// Use a ref to guard against users passing inline props
|
|
851
850
|
const callbacksRef = useRef({
|
|
@@ -996,6 +995,26 @@ function PanelGroupWithForwardedRef({
|
|
|
996
995
|
}
|
|
997
996
|
debounceMap[autoSaveId](autoSaveId, panelsArray, sizes, storage);
|
|
998
997
|
}
|
|
998
|
+
{
|
|
999
|
+
const {
|
|
1000
|
+
didLogIdAndOrderWarning,
|
|
1001
|
+
prevPanelIds
|
|
1002
|
+
} = devWarningsRef.current;
|
|
1003
|
+
if (!didLogIdAndOrderWarning) {
|
|
1004
|
+
const {
|
|
1005
|
+
panels
|
|
1006
|
+
} = committedValuesRef.current;
|
|
1007
|
+
const panelIds = Array.from(panels.keys());
|
|
1008
|
+
devWarningsRef.current.prevPanelIds = panelIds;
|
|
1009
|
+
const panelsHaveChanged = prevPanelIds.length > 0 && !areEqual(prevPanelIds, panelIds);
|
|
1010
|
+
if (panelsHaveChanged) {
|
|
1011
|
+
if (Array.from(panels.values()).find(panel => panel.current.idWasAutoGenerated || panel.current.order == null)) {
|
|
1012
|
+
devWarningsRef.current.didLogIdAndOrderWarning = true;
|
|
1013
|
+
console.warn(`WARNING: Panel id and order props recommended when panels are dynamically rendered`);
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
999
1018
|
}, [autoSaveId, panels, sizes, storage]);
|
|
1000
1019
|
const getPanelStyle = useCallback((id, defaultSize) => {
|
|
1001
1020
|
const {
|
|
@@ -1007,8 +1026,11 @@ function PanelGroupWithForwardedRef({
|
|
|
1007
1026
|
// At this point the best we can do is render everything with the same size.
|
|
1008
1027
|
if (panels.size === 0) {
|
|
1009
1028
|
{
|
|
1010
|
-
if (
|
|
1011
|
-
|
|
1029
|
+
if (!devWarningsRef.current.didLogDefaultSizeWarning) {
|
|
1030
|
+
if (!isBrowser && defaultSize == null) {
|
|
1031
|
+
devWarningsRef.current.didLogDefaultSizeWarning = true;
|
|
1032
|
+
console.warn(`WARNING: Panel defaultSize prop recommended to avoid layout shift after server rendering`);
|
|
1033
|
+
}
|
|
1012
1034
|
}
|
|
1013
1035
|
}
|
|
1014
1036
|
return {
|
|
@@ -1298,10 +1320,6 @@ const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwar
|
|
|
1298
1320
|
...props,
|
|
1299
1321
|
forwardedRef: ref
|
|
1300
1322
|
}));
|
|
1301
|
-
|
|
1302
|
-
// Workaround for Parcel scope hoisting (which renames objects/functions).
|
|
1303
|
-
// Casting to :any is required to avoid corrupting the generated TypeScript types.
|
|
1304
|
-
// See github.com/parcel-bundler/parcel/issues/8724
|
|
1305
1323
|
PanelGroupWithForwardedRef.displayName = "PanelGroup";
|
|
1306
1324
|
PanelGroup.displayName = "forwardRef(PanelGroup)";
|
|
1307
1325
|
|
|
@@ -1437,10 +1455,6 @@ function PanelResizeHandle({
|
|
|
1437
1455
|
tabIndex: 0
|
|
1438
1456
|
});
|
|
1439
1457
|
}
|
|
1440
|
-
|
|
1441
|
-
// Workaround for Parcel scope hoisting (which renames objects/functions).
|
|
1442
|
-
// Casting to :any is required to avoid corrupting the generated TypeScript types.
|
|
1443
|
-
// See github.com/parcel-bundler/parcel/issues/8724
|
|
1444
1458
|
PanelResizeHandle.displayName = "PanelResizeHandle";
|
|
1445
1459
|
|
|
1446
1460
|
exports.Panel = Panel;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
+
const isBrowser = typeof window !== "undefined";
|
|
4
|
+
|
|
3
5
|
// This module exists to work around Webpack issue https://github.com/webpack/webpack/issues/14814
|
|
4
6
|
|
|
5
7
|
// eslint-disable-next-line no-restricted-imports
|
|
@@ -21,8 +23,7 @@ const {
|
|
|
21
23
|
// `toString()` prevents bundlers from trying to `import { useId } from 'react'`
|
|
22
24
|
const useId = React["useId".toString()];
|
|
23
25
|
|
|
24
|
-
const
|
|
25
|
-
const useIsomorphicLayoutEffect = canUseEffectHooks ? useLayoutEffect : () => {};
|
|
26
|
+
const useIsomorphicLayoutEffect = isBrowser ? useLayoutEffect : () => {};
|
|
26
27
|
|
|
27
28
|
const wrappedUseId = typeof useId === "function" ? useId : () => null;
|
|
28
29
|
let counter = 0;
|
|
@@ -36,10 +37,6 @@ function useUniqueId(idFromParams = null) {
|
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
const PanelGroupContext = createContext(null);
|
|
39
|
-
|
|
40
|
-
// Workaround for Parcel scope hoisting (which renames objects/functions).
|
|
41
|
-
// Casting to :any is required to avoid corrupting the generated TypeScript types.
|
|
42
|
-
// See github.com/parcel-bundler/parcel/issues/8724
|
|
43
40
|
PanelGroupContext.displayName = "PanelGroupContext";
|
|
44
41
|
|
|
45
42
|
function PanelWithForwardedRef({
|
|
@@ -107,6 +104,7 @@ function PanelWithForwardedRef({
|
|
|
107
104
|
collapsible,
|
|
108
105
|
defaultSize,
|
|
109
106
|
id: panelId,
|
|
107
|
+
idWasAutoGenerated: idFromProps == null,
|
|
110
108
|
maxSize,
|
|
111
109
|
minSize,
|
|
112
110
|
order
|
|
@@ -118,6 +116,7 @@ function PanelWithForwardedRef({
|
|
|
118
116
|
panelDataRef.current.collapsible = collapsible;
|
|
119
117
|
panelDataRef.current.defaultSize = defaultSize;
|
|
120
118
|
panelDataRef.current.id = panelId;
|
|
119
|
+
panelDataRef.current.idWasAutoGenerated = idFromProps == null;
|
|
121
120
|
panelDataRef.current.maxSize = maxSize;
|
|
122
121
|
panelDataRef.current.minSize = minSize;
|
|
123
122
|
panelDataRef.current.order = order;
|
|
@@ -157,10 +156,6 @@ const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
|
|
|
157
156
|
...props,
|
|
158
157
|
forwardedRef: ref
|
|
159
158
|
}));
|
|
160
|
-
|
|
161
|
-
// Workaround for Parcel scope hoisting (which renames objects/functions).
|
|
162
|
-
// Casting to :any is required to avoid corrupting the generated TypeScript types.
|
|
163
|
-
// See github.com/parcel-bundler/parcel/issues/8724
|
|
164
159
|
PanelWithForwardedRef.displayName = "Panel";
|
|
165
160
|
Panel.displayName = "forwardRef(Panel)";
|
|
166
161
|
|
|
@@ -262,12 +257,18 @@ function adjustByDelta(event, panels, idBefore, idAfter, delta, prevSizes, panel
|
|
|
262
257
|
}
|
|
263
258
|
function callPanelCallbacks(panelsArray, sizes, panelIdToLastNotifiedSizeMap) {
|
|
264
259
|
sizes.forEach((size, index) => {
|
|
260
|
+
const panelRef = panelsArray[index];
|
|
261
|
+
if (!panelRef) {
|
|
262
|
+
// Handle initial mount (when panels are registered too late to be in the panels array)
|
|
263
|
+
// The subsequent render+effects will handle the resize notification
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
265
266
|
const {
|
|
266
267
|
callbacksRef,
|
|
267
268
|
collapsedSize,
|
|
268
269
|
collapsible,
|
|
269
270
|
id
|
|
270
|
-
} =
|
|
271
|
+
} = panelRef.current;
|
|
271
272
|
const lastNotifiedSize = panelIdToLastNotifiedSizeMap[id];
|
|
272
273
|
if (lastNotifiedSize !== size) {
|
|
273
274
|
panelIdToLastNotifiedSizeMap[id] = size;
|
|
@@ -748,13 +749,6 @@ function savePanelGroupLayout(autoSaveId, panels, sizes, storage) {
|
|
|
748
749
|
}
|
|
749
750
|
}
|
|
750
751
|
|
|
751
|
-
function isServerRendering() {
|
|
752
|
-
try {
|
|
753
|
-
return typeof window === undefined;
|
|
754
|
-
} catch (error) {}
|
|
755
|
-
return true;
|
|
756
|
-
}
|
|
757
|
-
|
|
758
752
|
const debounceMap = {};
|
|
759
753
|
|
|
760
754
|
// PanelGroup might be rendering in a server-side environment where localStorage is not available
|
|
@@ -822,6 +816,11 @@ function PanelGroupWithForwardedRef({
|
|
|
822
816
|
// We store the initial Panel sizes in this ref, and apply move deltas to them instead of to the current sizes.
|
|
823
817
|
// This has the benefit of causing force-collapsed panels to spring back open if drag is reversed.
|
|
824
818
|
const initialDragStateRef = useRef(null);
|
|
819
|
+
const devWarningsRef = useRef({
|
|
820
|
+
didLogDefaultSizeWarning: false,
|
|
821
|
+
didLogIdAndOrderWarning: false,
|
|
822
|
+
prevPanelIds: []
|
|
823
|
+
});
|
|
825
824
|
|
|
826
825
|
// Use a ref to guard against users passing inline props
|
|
827
826
|
const callbacksRef = useRef({
|
|
@@ -972,6 +971,26 @@ function PanelGroupWithForwardedRef({
|
|
|
972
971
|
}
|
|
973
972
|
debounceMap[autoSaveId](autoSaveId, panelsArray, sizes, storage);
|
|
974
973
|
}
|
|
974
|
+
{
|
|
975
|
+
const {
|
|
976
|
+
didLogIdAndOrderWarning,
|
|
977
|
+
prevPanelIds
|
|
978
|
+
} = devWarningsRef.current;
|
|
979
|
+
if (!didLogIdAndOrderWarning) {
|
|
980
|
+
const {
|
|
981
|
+
panels
|
|
982
|
+
} = committedValuesRef.current;
|
|
983
|
+
const panelIds = Array.from(panels.keys());
|
|
984
|
+
devWarningsRef.current.prevPanelIds = panelIds;
|
|
985
|
+
const panelsHaveChanged = prevPanelIds.length > 0 && !areEqual(prevPanelIds, panelIds);
|
|
986
|
+
if (panelsHaveChanged) {
|
|
987
|
+
if (Array.from(panels.values()).find(panel => panel.current.idWasAutoGenerated || panel.current.order == null)) {
|
|
988
|
+
devWarningsRef.current.didLogIdAndOrderWarning = true;
|
|
989
|
+
console.warn(`WARNING: Panel id and order props recommended when panels are dynamically rendered`);
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
}
|
|
975
994
|
}, [autoSaveId, panels, sizes, storage]);
|
|
976
995
|
const getPanelStyle = useCallback((id, defaultSize) => {
|
|
977
996
|
const {
|
|
@@ -983,8 +1002,11 @@ function PanelGroupWithForwardedRef({
|
|
|
983
1002
|
// At this point the best we can do is render everything with the same size.
|
|
984
1003
|
if (panels.size === 0) {
|
|
985
1004
|
{
|
|
986
|
-
if (
|
|
987
|
-
|
|
1005
|
+
if (!devWarningsRef.current.didLogDefaultSizeWarning) {
|
|
1006
|
+
if (!isBrowser && defaultSize == null) {
|
|
1007
|
+
devWarningsRef.current.didLogDefaultSizeWarning = true;
|
|
1008
|
+
console.warn(`WARNING: Panel defaultSize prop recommended to avoid layout shift after server rendering`);
|
|
1009
|
+
}
|
|
988
1010
|
}
|
|
989
1011
|
}
|
|
990
1012
|
return {
|
|
@@ -1274,10 +1296,6 @@ const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwar
|
|
|
1274
1296
|
...props,
|
|
1275
1297
|
forwardedRef: ref
|
|
1276
1298
|
}));
|
|
1277
|
-
|
|
1278
|
-
// Workaround for Parcel scope hoisting (which renames objects/functions).
|
|
1279
|
-
// Casting to :any is required to avoid corrupting the generated TypeScript types.
|
|
1280
|
-
// See github.com/parcel-bundler/parcel/issues/8724
|
|
1281
1299
|
PanelGroupWithForwardedRef.displayName = "PanelGroup";
|
|
1282
1300
|
PanelGroup.displayName = "forwardRef(PanelGroup)";
|
|
1283
1301
|
|
|
@@ -1413,10 +1431,6 @@ function PanelResizeHandle({
|
|
|
1413
1431
|
tabIndex: 0
|
|
1414
1432
|
});
|
|
1415
1433
|
}
|
|
1416
|
-
|
|
1417
|
-
// Workaround for Parcel scope hoisting (which renames objects/functions).
|
|
1418
|
-
// Casting to :any is required to avoid corrupting the generated TypeScript types.
|
|
1419
|
-
// See github.com/parcel-bundler/parcel/issues/8724
|
|
1420
1434
|
PanelResizeHandle.displayName = "PanelResizeHandle";
|
|
1421
1435
|
|
|
1422
1436
|
export { Panel, PanelGroup, PanelResizeHandle };
|