react-resizable-panels 0.0.63 → 1.0.0-rc.2

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 (74) hide show
  1. package/.eslintrc.cjs +1 -0
  2. package/CHANGELOG.md +5 -0
  3. package/dist/declarations/src/Panel.d.ts +19 -34
  4. package/dist/declarations/src/PanelGroup.d.ts +9 -13
  5. package/dist/declarations/src/PanelResizeHandle.d.ts +5 -7
  6. package/dist/declarations/src/index.d.ts +2 -2
  7. package/dist/declarations/src/types.d.ts +0 -7
  8. package/dist/declarations/src/utils/assert.d.ts +1 -0
  9. package/dist/declarations/src/vendor/react.d.ts +2 -2
  10. package/dist/react-resizable-panels.browser.cjs.js +253 -518
  11. package/dist/react-resizable-panels.browser.cjs.mjs +2 -1
  12. package/dist/react-resizable-panels.browser.development.cjs.js +279 -574
  13. package/dist/react-resizable-panels.browser.development.cjs.mjs +2 -1
  14. package/dist/react-resizable-panels.browser.development.esm.js +279 -575
  15. package/dist/react-resizable-panels.browser.esm.js +253 -519
  16. package/dist/react-resizable-panels.cjs.d.ts +88 -1
  17. package/dist/react-resizable-panels.cjs.d.ts.map +1 -1
  18. package/dist/react-resizable-panels.cjs.js +1481 -1983
  19. package/dist/react-resizable-panels.cjs.js.map +1 -1
  20. package/dist/react-resizable-panels.cjs.mjs +2 -1
  21. package/dist/react-resizable-panels.development.cjs.js +281 -576
  22. package/dist/react-resizable-panels.development.cjs.mjs +2 -1
  23. package/dist/react-resizable-panels.development.esm.js +281 -577
  24. package/dist/react-resizable-panels.development.node.cjs.js +267 -502
  25. package/dist/react-resizable-panels.development.node.cjs.mjs +2 -1
  26. package/dist/react-resizable-panels.development.node.esm.js +267 -503
  27. package/dist/react-resizable-panels.esm.js +1476 -1959
  28. package/dist/react-resizable-panels.esm.js.map +1 -1
  29. package/dist/react-resizable-panels.node.cjs.js +239 -444
  30. package/dist/react-resizable-panels.node.cjs.mjs +2 -1
  31. package/dist/react-resizable-panels.node.esm.js +239 -445
  32. package/package.json +1 -1
  33. package/src/Panel.test.tsx +74 -73
  34. package/src/Panel.ts +44 -68
  35. package/src/PanelGroup.test.tsx +43 -42
  36. package/src/PanelGroup.ts +221 -411
  37. package/src/PanelGroupContext.ts +2 -3
  38. package/src/PanelResizeHandle.test.tsx +68 -0
  39. package/src/PanelResizeHandle.ts +31 -22
  40. package/src/hooks/useWindowSplitterBehavior.ts +2 -1
  41. package/src/hooks/useWindowSplitterPanelGroupBehavior.ts +22 -33
  42. package/src/index.ts +4 -3
  43. package/src/types.ts +0 -9
  44. package/src/utils/adjustLayoutByDelta.test.ts +206 -336
  45. package/src/utils/adjustLayoutByDelta.ts +59 -51
  46. package/src/utils/assert.ts +1 -1
  47. package/src/utils/calculateAriaValues.test.ts +6 -11
  48. package/src/utils/calculateAriaValues.ts +7 -29
  49. package/src/utils/calculateDeltaPercentage.ts +8 -15
  50. package/src/utils/calculateDragOffsetPercentage.ts +11 -5
  51. package/src/utils/calculateUnsafeDefaultLayout.test.ts +4 -9
  52. package/src/utils/calculateUnsafeDefaultLayout.ts +13 -18
  53. package/src/utils/callPanelCallbacks.ts +11 -46
  54. package/src/utils/getResizeEventCursorPosition.ts +2 -0
  55. package/src/utils/resizePanel.test.ts +6 -52
  56. package/src/utils/resizePanel.ts +24 -46
  57. package/src/utils/test-utils.ts +6 -7
  58. package/src/utils/validatePanelConstraints.test.ts +12 -65
  59. package/src/utils/validatePanelConstraints.ts +26 -67
  60. package/src/utils/validatePanelGroupLayout.test.ts +27 -142
  61. package/src/utils/validatePanelGroupLayout.ts +17 -13
  62. package/src/vendor/react.ts +2 -0
  63. package/src/utils/computePercentagePanelConstraints.test.ts +0 -98
  64. package/src/utils/computePercentagePanelConstraints.ts +0 -56
  65. package/src/utils/convertPercentageToPixels.test.ts +0 -9
  66. package/src/utils/convertPercentageToPixels.ts +0 -6
  67. package/src/utils/convertPixelConstraintsToPercentages.test.ts +0 -47
  68. package/src/utils/convertPixelConstraintsToPercentages.ts +0 -72
  69. package/src/utils/convertPixelsToPercentage.test.ts +0 -9
  70. package/src/utils/convertPixelsToPercentage.ts +0 -6
  71. package/src/utils/getPercentageSizeFromMixedSizes.test.ts +0 -47
  72. package/src/utils/getPercentageSizeFromMixedSizes.ts +0 -15
  73. package/src/utils/shouldMonitorPixelBasedConstraints.test.ts +0 -23
  74. package/src/utils/shouldMonitorPixelBasedConstraints.ts +0 -13
@@ -1,2108 +1,1625 @@
1
- import * as React from 'react';
1
+ import * as $jhddX$react from "react";
2
2
 
3
- const isBrowser = typeof window !== "undefined";
3
+ const $6901cffdef780071$export$4e09c449d6c407f7 = true;
4
4
 
5
- // This module exists to work around Webpack issue https://github.com/webpack/webpack/issues/14814
6
5
 
7
- // eslint-disable-next-line no-restricted-imports
6
+ const $aedbef154d609804$export$df77466336fe5355 = true;
7
+
8
8
 
9
- const {
10
- createElement,
11
- createContext,
12
- createRef,
13
- forwardRef,
14
- useCallback,
15
- useContext,
16
- useEffect,
17
- useImperativeHandle,
18
- useLayoutEffect,
19
- useMemo,
20
- useRef,
21
- useState
22
- } = React;
9
+ // This module exists to work around Webpack issue https://github.com/webpack/webpack/issues/14814
10
+ // and limitations with ParcelJS parsing of the useId workaround (used below).
11
+ // For the time being, all react-resizable-panels must import "react" with the "* as React" syntax.
12
+ // To avoid mistakes, we use the ESLint "no-restricted-imports" to prevent "react" imports except in this file.
13
+ // See https://github.com/bvaughn/react-resizable-panels/issues/118
14
+ // eslint-disable-next-line no-restricted-imports
23
15
 
16
+ const { createElement: $ef07efbe5fa7d87e$export$c8a8987d4410bf2d, createContext: $ef07efbe5fa7d87e$export$fd42f52fd3ae1109, createRef: $ef07efbe5fa7d87e$export$7d1e3a5e95ceca43, forwardRef: $ef07efbe5fa7d87e$export$257a8862b851cb5b, useCallback: $ef07efbe5fa7d87e$export$35808ee640e87ca7, useContext: $ef07efbe5fa7d87e$export$fae74005e78b1a27, useEffect: $ef07efbe5fa7d87e$export$6d9c69b0de29b591, useImperativeHandle: $ef07efbe5fa7d87e$export$d5a552a76deda3c2, useLayoutEffect: $ef07efbe5fa7d87e$export$e5c5a5f917a5871c, useMemo: $ef07efbe5fa7d87e$export$1538c33de8887b59, useRef: $ef07efbe5fa7d87e$export$b8f5890fc79d6aca, useState: $ef07efbe5fa7d87e$export$60241385465d0a34 } = $jhddX$react;
24
17
  // `toString()` prevents bundlers from trying to `import { useId } from 'react'`
25
- const useId = React["useId".toString()];
26
-
27
- const PanelGroupContext = createContext(null);
28
- PanelGroupContext.displayName = "PanelGroupContext";
29
-
30
- const useIsomorphicLayoutEffect = isBrowser ? useLayoutEffect : () => {};
31
-
32
- const wrappedUseId = typeof useId === "function" ? useId : () => null;
33
- let counter = 0;
34
- function useUniqueId(idFromParams = null) {
35
- const idFromUseId = wrappedUseId();
36
- const idRef = useRef(idFromParams || idFromUseId || null);
37
- if (idRef.current === null) {
38
- idRef.current = "" + counter++;
39
- }
40
- return idFromParams !== null && idFromParams !== void 0 ? idFromParams : idRef.current;
18
+ const $ef07efbe5fa7d87e$export$f680877a34711e37 = $jhddX$react["useId".toString()];
19
+
20
+
21
+ const $e30963544e64b604$export$7d8c6d083caec74a = (0, $ef07efbe5fa7d87e$export$fd42f52fd3ae1109)(null);
22
+ $e30963544e64b604$export$7d8c6d083caec74a.displayName = "PanelGroupContext";
23
+
24
+
25
+
26
+
27
+ const $3f95d3e171760903$var$useIsomorphicLayoutEffect = (0, $6901cffdef780071$export$4e09c449d6c407f7) ? (0, $ef07efbe5fa7d87e$export$e5c5a5f917a5871c) : ()=>{};
28
+ var $3f95d3e171760903$export$2e2bcd8739ae039 = $3f95d3e171760903$var$useIsomorphicLayoutEffect;
29
+
30
+
31
+
32
+ const $e504a2438473eda9$var$wrappedUseId = typeof (0, $ef07efbe5fa7d87e$export$f680877a34711e37) === "function" ? (0, $ef07efbe5fa7d87e$export$f680877a34711e37) : ()=>null;
33
+ let $e504a2438473eda9$var$counter = 0;
34
+ function $e504a2438473eda9$export$2e2bcd8739ae039(idFromParams = null) {
35
+ const idFromUseId = $e504a2438473eda9$var$wrappedUseId();
36
+ const idRef = (0, $ef07efbe5fa7d87e$export$b8f5890fc79d6aca)(idFromParams || idFromUseId || null);
37
+ if (idRef.current === null) idRef.current = "" + $e504a2438473eda9$var$counter++;
38
+ return idFromParams !== null && idFromParams !== void 0 ? idFromParams : idRef.current;
41
39
  }
42
40
 
43
- function PanelWithForwardedRef({
44
- children,
45
- className: classNameFromProps = "",
46
- collapsedSizePercentage,
47
- collapsedSizePixels,
48
- collapsible,
49
- dataAttributes,
50
- defaultSizePercentage,
51
- defaultSizePixels,
52
- forwardedRef,
53
- id: idFromProps,
54
- maxSizePercentage,
55
- maxSizePixels,
56
- minSizePercentage,
57
- minSizePixels,
58
- onCollapse,
59
- onExpand,
60
- onResize,
61
- order,
62
- style: styleFromProps,
63
- tagName: Type = "div"
64
- }) {
65
- const context = useContext(PanelGroupContext);
66
- if (context === null) {
67
- throw Error(`Panel components must be rendered within a PanelGroup container`);
68
- }
69
- const {
70
- collapsePanel,
71
- expandPanel,
72
- getPanelSize,
73
- getPanelStyle,
74
- groupId,
75
- isPanelCollapsed,
76
- registerPanel,
77
- resizePanel,
78
- unregisterPanel
79
- } = context;
80
- const panelId = useUniqueId(idFromProps);
81
- const panelDataRef = useRef({
82
- callbacks: {
83
- onCollapse,
84
- onExpand,
85
- onResize
86
- },
87
- constraints: {
88
- collapsedSizePercentage,
89
- collapsedSizePixels,
90
- collapsible,
91
- defaultSizePercentage,
92
- defaultSizePixels,
93
- maxSizePercentage,
94
- maxSizePixels,
95
- minSizePercentage,
96
- minSizePixels
97
- },
98
- id: panelId,
99
- idIsFromProps: idFromProps !== undefined,
100
- order
101
- });
102
- useRef({
103
- didLogMissingDefaultSizeWarning: false
104
- });
105
- useIsomorphicLayoutEffect(() => {
106
- const {
107
- callbacks,
108
- constraints
109
- } = panelDataRef.current;
110
- panelDataRef.current.id = panelId;
111
- panelDataRef.current.idIsFromProps = idFromProps !== undefined;
112
- panelDataRef.current.order = order;
113
- callbacks.onCollapse = onCollapse;
114
- callbacks.onExpand = onExpand;
115
- callbacks.onResize = onResize;
116
- constraints.collapsedSizePercentage = collapsedSizePercentage;
117
- constraints.collapsedSizePixels = collapsedSizePixels;
118
- constraints.collapsible = collapsible;
119
- constraints.defaultSizePercentage = defaultSizePercentage;
120
- constraints.defaultSizePixels = defaultSizePixels;
121
- constraints.maxSizePercentage = maxSizePercentage;
122
- constraints.maxSizePixels = maxSizePixels;
123
- constraints.minSizePercentage = minSizePercentage;
124
- constraints.minSizePixels = minSizePixels;
125
- });
126
- useIsomorphicLayoutEffect(() => {
127
- const panelData = panelDataRef.current;
128
- registerPanel(panelData);
129
- return () => {
130
- unregisterPanel(panelData);
131
- };
132
- }, [order, panelId, registerPanel, unregisterPanel]);
133
- useImperativeHandle(forwardedRef, () => ({
134
- collapse: () => {
135
- collapsePanel(panelDataRef.current);
136
- },
137
- expand: () => {
138
- expandPanel(panelDataRef.current);
139
- },
140
- getId() {
141
- return panelId;
142
- },
143
- getSize() {
144
- return getPanelSize(panelDataRef.current);
145
- },
146
- isCollapsed() {
147
- return isPanelCollapsed(panelDataRef.current);
148
- },
149
- isExpanded() {
150
- return !isPanelCollapsed(panelDataRef.current);
151
- },
152
- resize: mixedSizes => {
153
- resizePanel(panelDataRef.current, mixedSizes);
41
+
42
+
43
+ function $c33df6d7c39fd3ee$export$35d79d63a6984ee1({ children: children, className: classNameFromProps = "", collapsedSize: collapsedSize, collapsible: collapsible, defaultSize: defaultSize, forwardedRef: forwardedRef, id: idFromProps, maxSize: maxSize, minSize: minSize, onCollapse: onCollapse, onExpand: onExpand, onResize: onResize, order: order, style: styleFromProps, tagName: Type = "div", ...rest }) {
44
+ const context = (0, $ef07efbe5fa7d87e$export$fae74005e78b1a27)((0, $e30963544e64b604$export$7d8c6d083caec74a));
45
+ if (context === null) throw Error(`Panel components must be rendered within a PanelGroup container`);
46
+ const { collapsePanel: collapsePanel, expandPanel: expandPanel, getPanelSize: getPanelSize, getPanelStyle: getPanelStyle, groupId: groupId, isPanelCollapsed: isPanelCollapsed, registerPanel: registerPanel, resizePanel: resizePanel, unregisterPanel: unregisterPanel } = context;
47
+ const panelId = (0, $e504a2438473eda9$export$2e2bcd8739ae039)(idFromProps);
48
+ const panelDataRef = (0, $ef07efbe5fa7d87e$export$b8f5890fc79d6aca)({
49
+ callbacks: {
50
+ onCollapse: onCollapse,
51
+ onExpand: onExpand,
52
+ onResize: onResize
53
+ },
54
+ constraints: {
55
+ collapsedSize: collapsedSize,
56
+ collapsible: collapsible,
57
+ defaultSize: defaultSize,
58
+ maxSize: maxSize,
59
+ minSize: minSize
60
+ },
61
+ id: panelId,
62
+ idIsFromProps: idFromProps !== undefined,
63
+ order: order
64
+ });
65
+ const devWarningsRef = (0, $ef07efbe5fa7d87e$export$b8f5890fc79d6aca)({
66
+ didLogMissingDefaultSizeWarning: false
67
+ });
68
+ // Normally we wouldn't log a warning during render,
69
+ // but effects don't run on the server, so we can't do it there
70
+ if (0, $aedbef154d609804$export$df77466336fe5355) {
71
+ if (!devWarningsRef.current.didLogMissingDefaultSizeWarning) {
72
+ if (!(0, $6901cffdef780071$export$4e09c449d6c407f7) && defaultSize == null) {
73
+ devWarningsRef.current.didLogMissingDefaultSizeWarning = true;
74
+ console.warn(`WARNING: Panel defaultSize prop recommended to avoid layout shift after server rendering`);
75
+ }
76
+ }
154
77
  }
155
- }), [collapsePanel, expandPanel, getPanelSize, isPanelCollapsed, panelId, resizePanel]);
156
- const style = getPanelStyle(panelDataRef.current);
157
- return createElement(Type, {
158
- children,
159
- className: classNameFromProps,
160
- style: {
161
- ...style,
162
- ...styleFromProps
163
- },
164
- ...dataAttributes,
165
- // CSS selectors
166
- "data-panel": "",
167
- "data-panel-id": panelId,
168
- "data-panel-group-id": groupId,
169
- // e2e test attributes
170
- "data-panel-collapsible": undefined,
171
- "data-panel-size": undefined
172
- });
173
- }
174
- const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
175
- ...props,
176
- forwardedRef: ref
177
- }));
178
- PanelWithForwardedRef.displayName = "Panel";
179
- Panel.displayName = "forwardRef(Panel)";
180
-
181
- function convertPixelsToPercentage(pixels, groupSizePixels) {
182
- return pixels / groupSizePixels * 100;
78
+ (0, $3f95d3e171760903$export$2e2bcd8739ae039)(()=>{
79
+ const { callbacks: callbacks, constraints: constraints } = panelDataRef.current;
80
+ panelDataRef.current.id = panelId;
81
+ panelDataRef.current.idIsFromProps = idFromProps !== undefined;
82
+ panelDataRef.current.order = order;
83
+ callbacks.onCollapse = onCollapse;
84
+ callbacks.onExpand = onExpand;
85
+ callbacks.onResize = onResize;
86
+ constraints.collapsedSize = collapsedSize;
87
+ constraints.collapsible = collapsible;
88
+ constraints.defaultSize = defaultSize;
89
+ constraints.maxSize = maxSize;
90
+ constraints.minSize = minSize;
91
+ });
92
+ (0, $3f95d3e171760903$export$2e2bcd8739ae039)(()=>{
93
+ const panelData = panelDataRef.current;
94
+ registerPanel(panelData);
95
+ return ()=>{
96
+ unregisterPanel(panelData);
97
+ };
98
+ }, [
99
+ order,
100
+ panelId,
101
+ registerPanel,
102
+ unregisterPanel
103
+ ]);
104
+ (0, $ef07efbe5fa7d87e$export$d5a552a76deda3c2)(forwardedRef, ()=>({
105
+ collapse: ()=>{
106
+ collapsePanel(panelDataRef.current);
107
+ },
108
+ expand: ()=>{
109
+ expandPanel(panelDataRef.current);
110
+ },
111
+ getId () {
112
+ return panelId;
113
+ },
114
+ getSize () {
115
+ return getPanelSize(panelDataRef.current);
116
+ },
117
+ isCollapsed () {
118
+ return isPanelCollapsed(panelDataRef.current);
119
+ },
120
+ isExpanded () {
121
+ return !isPanelCollapsed(panelDataRef.current);
122
+ },
123
+ resize: (size)=>{
124
+ resizePanel(panelDataRef.current, size);
125
+ }
126
+ }), [
127
+ collapsePanel,
128
+ expandPanel,
129
+ getPanelSize,
130
+ isPanelCollapsed,
131
+ panelId,
132
+ resizePanel
133
+ ]);
134
+ const style = getPanelStyle(panelDataRef.current);
135
+ return (0, $ef07efbe5fa7d87e$export$c8a8987d4410bf2d)(Type, {
136
+ ...rest,
137
+ children: children,
138
+ className: classNameFromProps,
139
+ style: {
140
+ ...style,
141
+ ...styleFromProps
142
+ },
143
+ // CSS selectors
144
+ "data-panel": "",
145
+ "data-panel-id": panelId,
146
+ "data-panel-group-id": groupId,
147
+ // e2e test attributes
148
+ "data-panel-collapsible": (0, $aedbef154d609804$export$df77466336fe5355) ? collapsible || undefined : undefined,
149
+ "data-panel-size": (0, $aedbef154d609804$export$df77466336fe5355) ? parseFloat("" + style.flexGrow).toFixed(1) : undefined
150
+ });
183
151
  }
152
+ const $c33df6d7c39fd3ee$export$2ddb90ad54e5f587 = (0, $ef07efbe5fa7d87e$export$257a8862b851cb5b)((props, ref)=>(0, $ef07efbe5fa7d87e$export$c8a8987d4410bf2d)($c33df6d7c39fd3ee$export$35d79d63a6984ee1, {
153
+ ...props,
154
+ forwardedRef: ref
155
+ }));
156
+ $c33df6d7c39fd3ee$export$35d79d63a6984ee1.displayName = "Panel";
157
+ $c33df6d7c39fd3ee$export$2ddb90ad54e5f587.displayName = "forwardRef(Panel)";
158
+
159
+
184
160
 
185
- function convertPixelConstraintsToPercentages(panelConstraints, groupSizePixels) {
186
- let {
187
- collapsedSizePercentage = 0,
188
- collapsedSizePixels,
189
- defaultSizePercentage,
190
- defaultSizePixels,
191
- maxSizePercentage = 100,
192
- maxSizePixels,
193
- minSizePercentage = 0,
194
- minSizePixels
195
- } = panelConstraints;
196
- const hasPixelConstraints = collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null;
197
- if (hasPixelConstraints && groupSizePixels <= 0) {
198
- console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
199
- return {
200
- collapsedSizePercentage: 0,
201
- defaultSizePercentage,
202
- maxSizePercentage: 0,
203
- minSizePercentage: 0
204
- };
205
- }
206
- if (collapsedSizePixels != null) {
207
- collapsedSizePercentage = convertPixelsToPercentage(collapsedSizePixels, groupSizePixels);
208
- }
209
- if (defaultSizePixels != null) {
210
- defaultSizePercentage = convertPixelsToPercentage(defaultSizePixels, groupSizePixels);
211
- }
212
- if (minSizePixels != null) {
213
- minSizePercentage = convertPixelsToPercentage(minSizePixels, groupSizePixels);
214
- }
215
- if (maxSizePixels != null) {
216
- maxSizePercentage = convertPixelsToPercentage(maxSizePixels, groupSizePixels);
217
- }
218
- return {
219
- collapsedSizePercentage,
220
- defaultSizePercentage,
221
- maxSizePercentage,
222
- minSizePercentage
223
- };
224
- }
225
161
 
226
- function computePercentagePanelConstraints(panelConstraintsArray, panelIndex, groupSizePixels) {
227
- // All panel constraints, excluding the current one
228
- let totalMinConstraints = 0;
229
- let totalMaxConstraints = 0;
230
- for (let index = 0; index < panelConstraintsArray.length; index++) {
231
- if (index !== panelIndex) {
232
- const {
233
- collapsible
234
- } = panelConstraintsArray[index];
235
- const {
236
- collapsedSizePercentage,
237
- maxSizePercentage,
238
- minSizePercentage
239
- } = convertPixelConstraintsToPercentages(panelConstraintsArray[index], groupSizePixels);
240
- totalMaxConstraints += maxSizePercentage;
241
- totalMinConstraints += collapsible ? collapsedSizePercentage : minSizePercentage;
162
+
163
+
164
+
165
+ function $5f33910cd46e8ae7$export$a7a9523472993e97(expectedCondition, message = "Assertion failed!") {
166
+ if (!expectedCondition) {
167
+ console.error(message);
168
+ throw Error(message);
242
169
  }
243
- }
244
- const {
245
- collapsedSizePercentage,
246
- defaultSizePercentage,
247
- maxSizePercentage,
248
- minSizePercentage
249
- } = convertPixelConstraintsToPercentages(panelConstraintsArray[panelIndex], groupSizePixels);
250
- return {
251
- collapsedSizePercentage,
252
- defaultSizePercentage,
253
- maxSizePercentage: panelConstraintsArray.length > 1 ? Math.min(maxSizePercentage, 100 - totalMinConstraints) : maxSizePercentage,
254
- minSizePercentage: panelConstraintsArray.length > 1 ? Math.max(minSizePercentage, 100 - totalMaxConstraints) : minSizePercentage
255
- };
256
170
  }
257
171
 
258
- const PRECISION = 10;
259
-
260
- function fuzzyCompareNumbers(actual, expected, fractionDigits = PRECISION) {
261
- actual = parseFloat(actual.toFixed(fractionDigits));
262
- expected = parseFloat(expected.toFixed(fractionDigits));
263
- const delta = actual - expected;
264
- if (delta === 0) {
265
- return 0;
266
- } else {
267
- return delta > 0 ? 1 : -1;
268
- }
172
+
173
+ const $a8e83be196252871$export$d6d3992f3becc879 = 10;
174
+
175
+
176
+ function $fa17b68d3c9353a3$export$1d75b1119dff900(actual, expected, fractionDigits = (0, $a8e83be196252871$export$d6d3992f3becc879)) {
177
+ actual = parseFloat(actual.toFixed(fractionDigits));
178
+ expected = parseFloat(expected.toFixed(fractionDigits));
179
+ const delta = actual - expected;
180
+ if (delta === 0) return 0;
181
+ else return delta > 0 ? 1 : -1;
269
182
  }
270
183
 
271
- function fuzzyNumbersEqual(actual, expected, fractionDigits) {
272
- return fuzzyCompareNumbers(actual, expected, fractionDigits) === 0;
184
+
185
+
186
+ function $ee71a189401d6914$export$db9c8bd2fae72e82(actual, expected, fractionDigits) {
187
+ return (0, $fa17b68d3c9353a3$export$1d75b1119dff900)(actual, expected, fractionDigits) === 0;
273
188
  }
274
189
 
275
- // Panel size must be in percentages; pixel values should be pre-converted
276
- function resizePanel({
277
- groupSizePixels,
278
- panelConstraints,
279
- panelIndex,
280
- size
281
- }) {
282
- const hasPixelConstraints = panelConstraints.some(({
283
- collapsedSizePixels,
284
- defaultSizePixels,
285
- minSizePixels,
286
- maxSizePixels
287
- }) => collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null);
288
- if (hasPixelConstraints && groupSizePixels <= 0) {
289
- console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
290
- return 0;
291
- }
292
- let {
293
- collapsible
294
- } = panelConstraints[panelIndex];
295
- const {
296
- collapsedSizePercentage,
297
- maxSizePercentage,
298
- minSizePercentage
299
- } = computePercentagePanelConstraints(panelConstraints, panelIndex, groupSizePixels);
300
- if (minSizePercentage != null) {
301
- if (fuzzyCompareNumbers(size, minSizePercentage) < 0) {
302
- if (collapsible) {
303
- // Collapsible panels should snap closed or open only once they cross the halfway point between collapsed and min size.
304
- const halfwayPoint = (collapsedSizePercentage + minSizePercentage) / 2;
305
- if (fuzzyCompareNumbers(size, halfwayPoint) < 0) {
306
- size = collapsedSizePercentage;
307
- } else {
308
- size = minSizePercentage;
309
- }
310
- } else {
311
- size = minSizePercentage;
312
- }
190
+
191
+
192
+
193
+
194
+ function $40f29f7a20511409$export$2f98edcf4006376f({ panelConstraints: panelConstraintsArray, panelIndex: panelIndex, size: size }) {
195
+ const panelConstraints = panelConstraintsArray[panelIndex];
196
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(panelConstraints != null);
197
+ let { collapsedSize: collapsedSize = 0, collapsible: collapsible, maxSize: maxSize = 100, minSize: minSize = 0 } = panelConstraints;
198
+ if ((0, $fa17b68d3c9353a3$export$1d75b1119dff900)(size, minSize) < 0) {
199
+ if (collapsible) {
200
+ // Collapsible panels should snap closed or open only once they cross the halfway point between collapsed and min size.
201
+ const halfwayPoint = (collapsedSize + minSize) / 2;
202
+ if ((0, $fa17b68d3c9353a3$export$1d75b1119dff900)(size, halfwayPoint) < 0) size = collapsedSize;
203
+ else size = minSize;
204
+ } else size = minSize;
313
205
  }
314
- }
315
- if (maxSizePercentage != null) {
316
- size = Math.min(maxSizePercentage, size);
317
- }
318
- return size;
206
+ size = Math.min(maxSize, size);
207
+ size = parseFloat(size.toFixed((0, $a8e83be196252871$export$d6d3992f3becc879)));
208
+ return size;
319
209
  }
320
210
 
321
- // All units must be in percentages; pixel values should be pre-converted
322
- function adjustLayoutByDelta({
323
- delta,
324
- groupSizePixels,
325
- layout: prevLayout,
326
- panelConstraints,
327
- pivotIndices,
328
- trigger
329
- }) {
330
- if (fuzzyNumbersEqual(delta, 0)) {
331
- return prevLayout;
332
- }
333
- const nextLayout = [...prevLayout];
334
- let deltaApplied = 0;
335
-
336
- //const DEBUG = [];
337
- //DEBUG.push(`adjustLayoutByDelta() ${prevLayout.join(", ")}`);
338
- //DEBUG.push(` delta: ${delta}`);
339
- //DEBUG.push(` pivotIndices: ${pivotIndices.join(", ")}`);
340
- //DEBUG.push(` trigger: ${trigger}`);
341
- //DEBUG.push("");
342
-
343
- // A resizing panel affects the panels before or after it.
344
- //
345
- // A negative delta means the panel(s) immediately after the resize handle should grow/expand by decreasing its offset.
346
- // Other panels may also need to shrink/contract (and shift) to make room, depending on the min weights.
347
- //
348
- // A positive delta means the panel(s) immediately before the resize handle should "expand".
349
- // This is accomplished by shrinking/contracting (and shifting) one or more of the panels after the resize handle.
350
-
351
- {
211
+
212
+ function $fe96098ae4f2a44d$export$7fead5cc734d205b({ delta: delta, layout: prevLayout, panelConstraints: panelConstraintsArray, pivotIndices: pivotIndices, trigger: trigger }) {
213
+ if ((0, $ee71a189401d6914$export$db9c8bd2fae72e82)(delta, 0)) return prevLayout;
214
+ const nextLayout = [
215
+ ...prevLayout
216
+ ];
217
+ const [firstPivotIndex, secondPivotIndex] = pivotIndices;
218
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(firstPivotIndex != null);
219
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(secondPivotIndex != null);
220
+ let deltaApplied = 0;
352
221
  // If this is a resize triggered by a keyboard event, our logic for expanding/collapsing is different.
353
222
  // We no longer check the halfway threshold because this may prevent the panel from expanding at all.
354
223
  if (trigger === "keyboard") {
355
- {
356
- // Check if we should expand a collapsed panel
357
- const index = delta < 0 ? pivotIndices[1] : pivotIndices[0];
358
- const constraints = panelConstraints[index];
359
- //DEBUG.push(`edge case check 1: ${index}`);
360
- //DEBUG.push(` -> collapsible? ${constraints.collapsible}`);
361
- if (constraints.collapsible) {
362
- const prevSize = prevLayout[index];
363
- const {
364
- collapsedSizePercentage,
365
- minSizePercentage
366
- } = computePercentagePanelConstraints(panelConstraints, index, groupSizePixels);
367
- if (fuzzyNumbersEqual(prevSize, collapsedSizePercentage)) {
368
- const localDelta = minSizePercentage - prevSize;
369
- //DEBUG.push(` -> expand delta: ${localDelta}`);
370
-
371
- if (fuzzyCompareNumbers(localDelta, Math.abs(delta)) > 0) {
372
- delta = delta < 0 ? 0 - localDelta : localDelta;
373
- //DEBUG.push(` -> delta: ${delta}`);
224
+ {
225
+ // Check if we should expand a collapsed panel
226
+ const index = delta < 0 ? secondPivotIndex : firstPivotIndex;
227
+ const panelConstraints = panelConstraintsArray[index];
228
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(panelConstraints);
229
+ //DEBUG.push(`edge case check 1: ${index}`);
230
+ //DEBUG.push(` -> collapsible? ${constraints.collapsible}`);
231
+ if (panelConstraints.collapsible) {
232
+ const prevSize = prevLayout[index];
233
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(prevSize != null);
234
+ const panelConstraints = panelConstraintsArray[index];
235
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(panelConstraints);
236
+ const { collapsedSize: collapsedSize = 0, minSize: minSize = 0 } = panelConstraints;
237
+ if ((0, $ee71a189401d6914$export$db9c8bd2fae72e82)(prevSize, collapsedSize)) {
238
+ const localDelta = minSize - prevSize;
239
+ //DEBUG.push(` -> expand delta: ${localDelta}`);
240
+ if ((0, $fa17b68d3c9353a3$export$1d75b1119dff900)(localDelta, Math.abs(delta)) > 0) delta = delta < 0 ? 0 - localDelta : localDelta;
241
+ }
374
242
  }
375
- }
376
243
  }
377
- }
378
-
379
- {
380
- // Check if we should collapse a panel at its minimum size
381
- const index = delta < 0 ? pivotIndices[0] : pivotIndices[1];
382
- const constraints = panelConstraints[index];
383
- //DEBUG.push(`edge case check 2: ${index}`);
384
- //DEBUG.push(` -> collapsible? ${constraints.collapsible}`);
385
- if (constraints.collapsible) {
386
- const prevSize = prevLayout[index];
387
- const {
388
- collapsedSizePercentage,
389
- minSizePercentage
390
- } = computePercentagePanelConstraints(panelConstraints, index, groupSizePixels);
391
- if (fuzzyNumbersEqual(prevSize, minSizePercentage)) {
392
- const localDelta = prevSize - collapsedSizePercentage;
393
- //DEBUG.push(` -> expand delta: ${localDelta}`);
394
-
395
- if (fuzzyCompareNumbers(localDelta, Math.abs(delta)) > 0) {
396
- delta = delta < 0 ? 0 - localDelta : localDelta;
397
- //DEBUG.push(` -> delta: ${delta}`);
244
+ {
245
+ // Check if we should collapse a panel at its minimum size
246
+ const index = delta < 0 ? firstPivotIndex : secondPivotIndex;
247
+ const panelConstraints = panelConstraintsArray[index];
248
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(panelConstraints);
249
+ const { collapsible: collapsible } = panelConstraints;
250
+ //DEBUG.push(`edge case check 2: ${index}`);
251
+ //DEBUG.push(` -> collapsible? ${collapsible}`);
252
+ if (collapsible) {
253
+ const prevSize = prevLayout[index];
254
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(prevSize != null);
255
+ const panelConstraints = panelConstraintsArray[index];
256
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(panelConstraints);
257
+ const { collapsedSize: collapsedSize = 0, minSize: minSize = 0 } = panelConstraints;
258
+ if ((0, $ee71a189401d6914$export$db9c8bd2fae72e82)(prevSize, minSize)) {
259
+ const localDelta = prevSize - collapsedSize;
260
+ //DEBUG.push(` -> expand delta: ${localDelta}`);
261
+ if ((0, $fa17b68d3c9353a3$export$1d75b1119dff900)(localDelta, Math.abs(delta)) > 0) delta = delta < 0 ? 0 - localDelta : localDelta;
262
+ }
398
263
  }
399
- }
400
264
  }
401
- }
402
265
  }
266
+ {
267
+ // Pre-calculate max available delta in the opposite direction of our pivot.
268
+ // This will be the maximum amount we're allowed to expand/contract the panels in the primary direction.
269
+ // If this amount is less than the requested delta, adjust the requested delta.
270
+ // If this amount is greater than the requested delta, that's useful information too–
271
+ // as an expanding panel might change from collapsed to min size.
272
+ const increment = delta < 0 ? 1 : -1;
273
+ let index = delta < 0 ? secondPivotIndex : firstPivotIndex;
274
+ let maxAvailableDelta = 0;
275
+ //DEBUG.push("pre calc...");
276
+ while(true){
277
+ const prevSize = prevLayout[index];
278
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(prevSize != null);
279
+ const maxSafeSize = (0, $40f29f7a20511409$export$2f98edcf4006376f)({
280
+ panelConstraints: panelConstraintsArray,
281
+ panelIndex: index,
282
+ size: 100
283
+ });
284
+ const delta = maxSafeSize - prevSize;
285
+ //DEBUG.push(` ${index}: ${prevSize} -> ${maxSafeSize}`);
286
+ maxAvailableDelta += delta;
287
+ index += increment;
288
+ if (index < 0 || index >= panelConstraintsArray.length) break;
289
+ }
290
+ //DEBUG.push(` -> max available delta: ${maxAvailableDelta}`);
291
+ const minAbsDelta = Math.min(Math.abs(delta), Math.abs(maxAvailableDelta));
292
+ delta = delta < 0 ? 0 - minAbsDelta : minAbsDelta;
293
+ //DEBUG.push(` -> adjusted delta: ${delta}`);
403
294
  //DEBUG.push("");
404
- }
405
-
406
- {
407
- // Pre-calculate max available delta in the opposite direction of our pivot.
408
- // This will be the maximum amount we're allowed to expand/contract the panels in the primary direction.
409
- // If this amount is less than the requested delta, adjust the requested delta.
410
- // If this amount is greater than the requested delta, that's useful information too–
411
- // as an expanding panel might change from collapsed to min size.
412
-
413
- const increment = delta < 0 ? 1 : -1;
414
- let index = delta < 0 ? pivotIndices[1] : pivotIndices[0];
415
- let maxAvailableDelta = 0;
416
-
417
- //DEBUG.push("pre calc...");
418
- while (true) {
419
- const prevSize = prevLayout[index];
420
- const maxSafeSize = resizePanel({
421
- groupSizePixels,
422
- panelConstraints,
423
- panelIndex: index,
424
- size: 100
425
- });
426
- const delta = maxSafeSize - prevSize;
427
- //DEBUG.push(` ${index}: ${prevSize} -> ${maxSafeSize}`);
428
-
429
- maxAvailableDelta += delta;
430
- index += increment;
431
- if (index < 0 || index >= panelConstraints.length) {
432
- break;
433
- }
434
295
  }
435
-
436
- //DEBUG.push(` -> max available delta: ${maxAvailableDelta}`);
437
- const minAbsDelta = Math.min(Math.abs(delta), Math.abs(maxAvailableDelta));
438
- delta = delta < 0 ? 0 - minAbsDelta : minAbsDelta;
439
- //DEBUG.push(` -> adjusted delta: ${delta}`);
296
+ {
297
+ // Delta added to a panel needs to be subtracted from other panels (within the constraints that those panels allow).
298
+ const pivotIndex = delta < 0 ? firstPivotIndex : secondPivotIndex;
299
+ let index = pivotIndex;
300
+ while(index >= 0 && index < panelConstraintsArray.length){
301
+ const deltaRemaining = Math.abs(delta) - Math.abs(deltaApplied);
302
+ const prevSize = prevLayout[index];
303
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(prevSize != null);
304
+ const unsafeSize = prevSize - deltaRemaining;
305
+ const safeSize = (0, $40f29f7a20511409$export$2f98edcf4006376f)({
306
+ panelConstraints: panelConstraintsArray,
307
+ panelIndex: index,
308
+ size: unsafeSize
309
+ });
310
+ if (!(0, $ee71a189401d6914$export$db9c8bd2fae72e82)(prevSize, safeSize)) {
311
+ deltaApplied += prevSize - safeSize;
312
+ nextLayout[index] = safeSize;
313
+ if (deltaApplied.toPrecision(3).localeCompare(Math.abs(delta).toPrecision(3), undefined, {
314
+ numeric: true
315
+ }) >= 0) break;
316
+ }
317
+ if (delta < 0) index--;
318
+ else index++;
319
+ }
320
+ }
321
+ //DEBUG.push(`after 1: ${nextLayout.join(", ")}`);
322
+ //DEBUG.push(` deltaApplied: ${deltaApplied}`);
440
323
  //DEBUG.push("");
441
- }
442
-
443
- {
444
- // Delta added to a panel needs to be subtracted from other panels (within the constraints that those panels allow).
445
-
446
- const pivotIndex = delta < 0 ? pivotIndices[0] : pivotIndices[1];
447
- let index = pivotIndex;
448
- while (index >= 0 && index < panelConstraints.length) {
449
- const deltaRemaining = Math.abs(delta) - Math.abs(deltaApplied);
450
- const prevSize = prevLayout[index];
451
- const unsafeSize = prevSize - deltaRemaining;
452
- const safeSize = resizePanel({
453
- groupSizePixels,
454
- panelConstraints,
455
- panelIndex: index,
456
- size: unsafeSize
457
- });
458
- if (!fuzzyNumbersEqual(prevSize, safeSize)) {
459
- deltaApplied += prevSize - safeSize;
460
- nextLayout[index] = safeSize;
461
- if (deltaApplied.toPrecision(3).localeCompare(Math.abs(delta).toPrecision(3), undefined, {
462
- numeric: true
463
- }) >= 0) {
464
- break;
324
+ // If we were unable to resize any of the panels panels, return the previous state.
325
+ // This will essentially bailout and ignore e.g. drags past a panel's boundaries
326
+ if ((0, $ee71a189401d6914$export$db9c8bd2fae72e82)(deltaApplied, 0)) //console.log(DEBUG.join("\n"));
327
+ return prevLayout;
328
+ {
329
+ // Now distribute the applied delta to the panels in the other direction
330
+ const pivotIndex = delta < 0 ? secondPivotIndex : firstPivotIndex;
331
+ const prevSize = prevLayout[pivotIndex];
332
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(prevSize != null);
333
+ const unsafeSize = prevSize + deltaApplied;
334
+ const safeSize = (0, $40f29f7a20511409$export$2f98edcf4006376f)({
335
+ panelConstraints: panelConstraintsArray,
336
+ panelIndex: pivotIndex,
337
+ size: unsafeSize
338
+ });
339
+ // Adjust the pivot panel before, but only by the amount that surrounding panels were able to shrink/contract.
340
+ nextLayout[pivotIndex] = safeSize;
341
+ // Edge case where expanding or contracting one panel caused another one to change collapsed state
342
+ if (!(0, $ee71a189401d6914$export$db9c8bd2fae72e82)(safeSize, unsafeSize)) {
343
+ let deltaRemaining = unsafeSize - safeSize;
344
+ const pivotIndex = delta < 0 ? secondPivotIndex : firstPivotIndex;
345
+ let index = pivotIndex;
346
+ while(index >= 0 && index < panelConstraintsArray.length){
347
+ const prevSize = nextLayout[index];
348
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(prevSize != null);
349
+ const unsafeSize = prevSize + deltaRemaining;
350
+ const safeSize = (0, $40f29f7a20511409$export$2f98edcf4006376f)({
351
+ panelConstraints: panelConstraintsArray,
352
+ panelIndex: index,
353
+ size: unsafeSize
354
+ });
355
+ if (!(0, $ee71a189401d6914$export$db9c8bd2fae72e82)(prevSize, safeSize)) {
356
+ deltaRemaining -= safeSize - prevSize;
357
+ nextLayout[index] = safeSize;
358
+ }
359
+ if ((0, $ee71a189401d6914$export$db9c8bd2fae72e82)(deltaRemaining, 0)) break;
360
+ if (delta > 0) index--;
361
+ else index++;
362
+ }
465
363
  }
466
- }
467
- if (delta < 0) {
468
- index--;
469
- } else {
470
- index++;
471
- }
472
364
  }
473
- }
474
- //DEBUG.push(`after 1: ${nextLayout.join(", ")}`);
475
- //DEBUG.push(` deltaApplied: ${deltaApplied}`);
476
- //DEBUG.push("");
477
-
478
- // If we were unable to resize any of the panels panels, return the previous state.
479
- // This will essentially bailout and ignore e.g. drags past a panel's boundaries
480
- if (fuzzyNumbersEqual(deltaApplied, 0)) {
365
+ //DEBUG.push(`after 2: ${nextLayout.join(", ")}`);
366
+ //DEBUG.push(` deltaApplied: ${deltaApplied}`);
367
+ //DEBUG.push("");
368
+ const totalSize = nextLayout.reduce((total, size)=>size + total, 0);
369
+ //DEBUG.push(`total size: ${totalSize}`);
481
370
  //console.log(DEBUG.join("\n"));
482
- return prevLayout;
483
- }
484
- {
485
- // Now distribute the applied delta to the panels in the other direction
486
- const pivotIndex = delta < 0 ? pivotIndices[1] : pivotIndices[0];
487
- const unsafeSize = prevLayout[pivotIndex] + deltaApplied;
488
- const safeSize = resizePanel({
489
- groupSizePixels,
490
- panelConstraints,
491
- panelIndex: pivotIndex,
492
- size: unsafeSize
493
- });
371
+ if (!(0, $ee71a189401d6914$export$db9c8bd2fae72e82)(totalSize, 100)) return prevLayout;
372
+ return nextLayout;
373
+ }
494
374
 
495
- // Adjust the pivot panel before, but only by the amount that surrounding panels were able to shrink/contract.
496
- nextLayout[pivotIndex] = safeSize;
497
375
 
498
- // Edge case where expanding or contracting one panel caused another one to change collapsed state
499
- if (!fuzzyNumbersEqual(safeSize, unsafeSize)) {
500
- let deltaRemaining = unsafeSize - safeSize;
501
- const pivotIndex = delta < 0 ? pivotIndices[1] : pivotIndices[0];
502
- let index = pivotIndex;
503
- while (index >= 0 && index < panelConstraints.length) {
504
- const prevSize = nextLayout[index];
505
- const unsafeSize = prevSize + deltaRemaining;
506
- const safeSize = resizePanel({
507
- groupSizePixels,
508
- panelConstraints,
509
- panelIndex: index,
510
- size: unsafeSize
511
- });
512
- if (!fuzzyNumbersEqual(prevSize, safeSize)) {
513
- deltaRemaining -= safeSize - prevSize;
514
- nextLayout[index] = safeSize;
515
- }
516
- if (fuzzyNumbersEqual(deltaRemaining, 0)) {
517
- break;
518
- }
519
- if (delta > 0) {
520
- index--;
376
+
377
+
378
+ function $a662cadf71ffedbc$export$b8372a468ba36f7d({ layout: layout, panelsArray: panelsArray, pivotIndices: pivotIndices }) {
379
+ let currentMinSize = 0;
380
+ let currentMaxSize = 100;
381
+ let totalMinSize = 0;
382
+ let totalMaxSize = 0;
383
+ const firstIndex = pivotIndices[0];
384
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(firstIndex != null);
385
+ // A panel's effective min/max sizes also need to account for other panel's sizes.
386
+ panelsArray.forEach((panelData, index)=>{
387
+ const { constraints: constraints } = panelData;
388
+ const { maxSize: maxSize = 100, minSize: minSize = 0 } = constraints;
389
+ if (index === firstIndex) {
390
+ currentMinSize = minSize;
391
+ currentMaxSize = maxSize;
521
392
  } else {
522
- index++;
393
+ totalMinSize += minSize;
394
+ totalMaxSize += maxSize;
523
395
  }
524
- }
525
- }
526
- }
527
- //DEBUG.push(`after 2: ${nextLayout.join(", ")}`);
528
- //DEBUG.push(` deltaApplied: ${deltaApplied}`);
529
- //DEBUG.push("");
530
-
531
- const totalSize = nextLayout.reduce((total, size) => size + total, 0);
532
- deltaApplied = 100 - totalSize;
533
- //DEBUG.push(`total size: ${totalSize}`);
534
- //DEBUG.push(` deltaApplied: ${deltaApplied}`);
535
- //console.log(DEBUG.join("\n"));
536
-
537
- if (!fuzzyNumbersEqual(totalSize, 100)) {
538
- return prevLayout;
539
- }
540
- return nextLayout;
396
+ });
397
+ const valueMax = Math.min(currentMaxSize, 100 - totalMinSize);
398
+ const valueMin = Math.max(currentMinSize, 100 - totalMaxSize);
399
+ const valueNow = layout[firstIndex];
400
+ return {
401
+ valueMax: valueMax,
402
+ valueMin: valueMin,
403
+ valueNow: valueNow
404
+ };
541
405
  }
542
406
 
543
- function assert(expectedCondition, message = "Assertion failed!") {
544
- if (!expectedCondition) {
545
- console.error(message);
546
- throw Error(message);
547
- }
548
- }
549
407
 
550
- function getPercentageSizeFromMixedSizes({
551
- sizePercentage,
552
- sizePixels
553
- }, groupSizePixels) {
554
- if (sizePercentage != null) {
555
- return sizePercentage;
556
- } else if (sizePixels != null) {
557
- return convertPixelsToPercentage(sizePixels, groupSizePixels);
558
- }
559
- return undefined;
408
+ function $9196ba7c0d09e3f3$export$63eb605e437b214f(groupId) {
409
+ return Array.from(document.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${groupId}"]`));
560
410
  }
561
411
 
562
- function calculateAriaValues({
563
- groupSizePixels,
564
- layout,
565
- panelsArray,
566
- pivotIndices
567
- }) {
568
- let currentMinSize = 0;
569
- let currentMaxSize = 100;
570
- let totalMinSize = 0;
571
- let totalMaxSize = 0;
572
-
573
- // A panel's effective min/max sizes also need to account for other panel's sizes.
574
- panelsArray.forEach((panelData, index) => {
575
- var _getPercentageSizeFro, _getPercentageSizeFro2;
576
- const {
577
- constraints
578
- } = panelData;
579
- const {
580
- maxSizePercentage,
581
- maxSizePixels,
582
- minSizePercentage,
583
- minSizePixels
584
- } = constraints;
585
- const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
586
- sizePercentage: minSizePercentage,
587
- sizePixels: minSizePixels
588
- }, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
589
- const maxSize = (_getPercentageSizeFro2 = getPercentageSizeFromMixedSizes({
590
- sizePercentage: maxSizePercentage,
591
- sizePixels: maxSizePixels
592
- }, groupSizePixels)) !== null && _getPercentageSizeFro2 !== void 0 ? _getPercentageSizeFro2 : 100;
593
- if (index === pivotIndices[0]) {
594
- currentMinSize = minSize;
595
- currentMaxSize = maxSize;
596
- } else {
597
- totalMinSize += minSize;
598
- totalMaxSize += maxSize;
599
- }
600
- });
601
- const valueMax = Math.min(currentMaxSize, 100 - totalMinSize);
602
- const valueMin = Math.max(currentMinSize, 100 - totalMaxSize);
603
- const valueNow = layout[pivotIndices[0]];
604
- return {
605
- valueMax,
606
- valueMin,
607
- valueNow
608
- };
609
- }
610
412
 
611
- function getResizeHandleElementsForGroup(groupId) {
612
- return Array.from(document.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${groupId}"]`));
413
+ function $a144d12e0d2017d1$export$4c92fedbbc2381ca(groupId, id) {
414
+ const handles = (0, $9196ba7c0d09e3f3$export$63eb605e437b214f)(groupId);
415
+ const index = handles.findIndex((handle)=>handle.getAttribute("data-panel-resize-handle-id") === id);
416
+ return index !== null && index !== void 0 ? index : null;
613
417
  }
614
418
 
615
- function getResizeHandleElementIndex(groupId, id) {
616
- const handles = getResizeHandleElementsForGroup(groupId);
617
- const index = handles.findIndex(handle => handle.getAttribute("data-panel-resize-handle-id") === id);
618
- return index !== null && index !== void 0 ? index : null;
619
- }
620
419
 
621
- function determinePivotIndices(groupId, dragHandleId) {
622
- const index = getResizeHandleElementIndex(groupId, dragHandleId);
623
- return index != null ? [index, index + 1] : [-1, -1];
420
+ function $0a239c1e1cd1e940$export$cf92598869f99b8f(groupId, dragHandleId) {
421
+ const index = (0, $a144d12e0d2017d1$export$4c92fedbbc2381ca)(groupId, dragHandleId);
422
+ return index != null ? [
423
+ index,
424
+ index + 1
425
+ ] : [
426
+ -1,
427
+ -1
428
+ ];
624
429
  }
625
430
 
626
- function getPanelGroupElement(id) {
627
- const element = document.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
628
- if (element) {
629
- return element;
630
- }
631
- return null;
632
- }
633
431
 
634
- function calculateAvailablePanelSizeInPixels(groupId) {
635
- const panelGroupElement = getPanelGroupElement(groupId);
636
- if (panelGroupElement == null) {
637
- return NaN;
638
- }
639
- const direction = panelGroupElement.getAttribute("data-panel-group-direction");
640
- const resizeHandles = getResizeHandleElementsForGroup(groupId);
641
- if (direction === "horizontal") {
642
- return panelGroupElement.offsetWidth - resizeHandles.reduce((accumulated, handle) => {
643
- return accumulated + handle.offsetWidth;
644
- }, 0);
645
- } else {
646
- return panelGroupElement.offsetHeight - resizeHandles.reduce((accumulated, handle) => {
647
- return accumulated + handle.offsetHeight;
648
- }, 0);
649
- }
432
+ function $18131dcc0be2e4e0$export$4e72aefa594058df(id) {
433
+ const element = document.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
434
+ if (element) return element;
435
+ return null;
650
436
  }
651
437
 
652
- function getAvailableGroupSizePixels(groupId) {
653
- const panelGroupElement = getPanelGroupElement(groupId);
654
- if (panelGroupElement == null) {
655
- return NaN;
656
- }
657
- const direction = panelGroupElement.getAttribute("data-panel-group-direction");
658
- const resizeHandles = getResizeHandleElementsForGroup(groupId);
659
- if (direction === "horizontal") {
660
- return panelGroupElement.offsetWidth - resizeHandles.reduce((accumulated, handle) => {
661
- return accumulated + handle.offsetWidth;
662
- }, 0);
663
- } else {
664
- return panelGroupElement.offsetHeight - resizeHandles.reduce((accumulated, handle) => {
665
- return accumulated + handle.offsetHeight;
666
- }, 0);
667
- }
668
- }
669
438
 
670
- function getResizeHandleElement(id) {
671
- const element = document.querySelector(`[data-panel-resize-handle-id="${id}"]`);
672
- if (element) {
673
- return element;
674
- }
675
- return null;
439
+
440
+ function $99b0d18e36332b26$export$4c5229c874a62620(id) {
441
+ const element = document.querySelector(`[data-panel-resize-handle-id="${id}"]`);
442
+ if (element) return element;
443
+ return null;
676
444
  }
677
445
 
678
- function getResizeHandlePanelIds(groupId, handleId, panelsArray) {
679
- var _panelsArray$index$id, _panelsArray$index, _panelsArray$id, _panelsArray;
680
- const handle = getResizeHandleElement(handleId);
681
- const handles = getResizeHandleElementsForGroup(groupId);
682
- const index = handle ? handles.indexOf(handle) : -1;
683
- const idBefore = (_panelsArray$index$id = (_panelsArray$index = panelsArray[index]) === null || _panelsArray$index === void 0 ? void 0 : _panelsArray$index.id) !== null && _panelsArray$index$id !== void 0 ? _panelsArray$index$id : null;
684
- const idAfter = (_panelsArray$id = (_panelsArray = panelsArray[index + 1]) === null || _panelsArray === void 0 ? void 0 : _panelsArray.id) !== null && _panelsArray$id !== void 0 ? _panelsArray$id : null;
685
- return [idBefore, idAfter];
446
+
447
+
448
+ function $1420c4509c675b80$export$68d3a33c21dfbe27(groupId, handleId, panelsArray) {
449
+ var _panelsArray_index, _panelsArray_;
450
+ const handle = (0, $99b0d18e36332b26$export$4c5229c874a62620)(handleId);
451
+ const handles = (0, $9196ba7c0d09e3f3$export$63eb605e437b214f)(groupId);
452
+ const index = handle ? handles.indexOf(handle) : -1;
453
+ var _panelsArray_index_id;
454
+ const idBefore = (_panelsArray_index_id = (_panelsArray_index = panelsArray[index]) === null || _panelsArray_index === void 0 ? void 0 : _panelsArray_index.id) !== null && _panelsArray_index_id !== void 0 ? _panelsArray_index_id : null;
455
+ var _panelsArray__id;
456
+ const idAfter = (_panelsArray__id = (_panelsArray_ = panelsArray[index + 1]) === null || _panelsArray_ === void 0 ? void 0 : _panelsArray_.id) !== null && _panelsArray__id !== void 0 ? _panelsArray__id : null;
457
+ return [
458
+ idBefore,
459
+ idAfter
460
+ ];
686
461
  }
687
462
 
688
- // https://www.w3.org/WAI/ARIA/apg/patterns/windowsplitter/
689
-
690
- function useWindowSplitterPanelGroupBehavior({
691
- committedValuesRef,
692
- eagerValuesRef,
693
- groupId,
694
- layout,
695
- panelDataArray,
696
- setLayout
697
- }) {
698
- useRef({
699
- didWarnAboutMissingResizeHandle: false
700
- });
701
- useIsomorphicLayoutEffect(() => {
702
- const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
703
- const resizeHandleElements = getResizeHandleElementsForGroup(groupId);
704
- for (let index = 0; index < panelDataArray.length - 1; index++) {
705
- const {
706
- valueMax,
707
- valueMin,
708
- valueNow
709
- } = calculateAriaValues({
710
- groupSizePixels,
711
- layout,
712
- panelsArray: panelDataArray,
713
- pivotIndices: [index, index + 1]
714
- });
715
- const resizeHandleElement = resizeHandleElements[index];
716
- if (resizeHandleElement == null) ; else {
717
- resizeHandleElement.setAttribute("aria-controls", panelDataArray[index].id);
718
- resizeHandleElement.setAttribute("aria-valuemax", "" + Math.round(valueMax));
719
- resizeHandleElement.setAttribute("aria-valuemin", "" + Math.round(valueMin));
720
- resizeHandleElement.setAttribute("aria-valuenow", "" + Math.round(valueNow));
721
- }
722
- }
723
- return () => {
724
- resizeHandleElements.forEach((resizeHandleElement, index) => {
725
- resizeHandleElement.removeAttribute("aria-controls");
726
- resizeHandleElement.removeAttribute("aria-valuemax");
727
- resizeHandleElement.removeAttribute("aria-valuemin");
728
- resizeHandleElement.removeAttribute("aria-valuenow");
729
- });
730
- };
731
- }, [groupId, layout, panelDataArray]);
732
- useEffect(() => {
733
- const {
734
- panelDataArray
735
- } = eagerValuesRef.current;
736
- const groupElement = getPanelGroupElement(groupId);
737
- assert(groupElement != null, `No group found for id "${groupId}"`);
738
- const handles = getResizeHandleElementsForGroup(groupId);
739
- const cleanupFunctions = handles.map(handle => {
740
- const handleId = handle.getAttribute("data-panel-resize-handle-id");
741
- const [idBefore, idAfter] = getResizeHandlePanelIds(groupId, handleId, panelDataArray);
742
- if (idBefore == null || idAfter == null) {
743
- return () => {};
744
- }
745
- const onKeyDown = event => {
746
- if (event.defaultPrevented) {
747
- return;
748
- }
749
- switch (event.key) {
750
- case "Enter":
751
- {
752
- event.preventDefault();
753
- const index = panelDataArray.findIndex(panelData => panelData.id === idBefore);
754
- if (index >= 0) {
755
- const panelData = panelDataArray[index];
756
- const size = layout[index];
757
- if (size != null && panelData.constraints.collapsible) {
758
- var _getPercentageSizeFro, _getPercentageSizeFro2;
759
- const groupSizePixels = getAvailableGroupSizePixels(groupId);
760
- const collapsedSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
761
- sizePercentage: panelData.constraints.collapsedSizePercentage,
762
- sizePixels: panelData.constraints.collapsedSizePixels
763
- }, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
764
- const minSize = (_getPercentageSizeFro2 = getPercentageSizeFromMixedSizes({
765
- sizePercentage: panelData.constraints.minSizePercentage,
766
- sizePixels: panelData.constraints.minSizePixels
767
- }, groupSizePixels)) !== null && _getPercentageSizeFro2 !== void 0 ? _getPercentageSizeFro2 : 0;
768
- const nextLayout = adjustLayoutByDelta({
769
- delta: fuzzyNumbersEqual(size, collapsedSize) ? minSize - collapsedSize : collapsedSize - size,
770
- groupSizePixels,
771
- layout,
772
- panelConstraints: panelDataArray.map(panelData => panelData.constraints),
773
- pivotIndices: determinePivotIndices(groupId, handleId),
774
- trigger: "keyboard"
775
- });
776
- if (layout !== nextLayout) {
777
- setLayout(nextLayout);
778
- }
463
+
464
+
465
+
466
+
467
+ function $20152a6c44989ce6$export$d9fcbe062527d159({ committedValuesRef: committedValuesRef, eagerValuesRef: eagerValuesRef, groupId: groupId, layout: layout, panelDataArray: panelDataArray, setLayout: setLayout }) {
468
+ const devWarningsRef = (0, $ef07efbe5fa7d87e$export$b8f5890fc79d6aca)({
469
+ didWarnAboutMissingResizeHandle: false
470
+ });
471
+ (0, $3f95d3e171760903$export$2e2bcd8739ae039)(()=>{
472
+ const resizeHandleElements = (0, $9196ba7c0d09e3f3$export$63eb605e437b214f)(groupId);
473
+ for(let index = 0; index < panelDataArray.length - 1; index++){
474
+ const { valueMax: valueMax, valueMin: valueMin, valueNow: valueNow } = (0, $a662cadf71ffedbc$export$b8372a468ba36f7d)({
475
+ layout: layout,
476
+ panelsArray: panelDataArray,
477
+ pivotIndices: [
478
+ index,
479
+ index + 1
480
+ ]
481
+ });
482
+ const resizeHandleElement = resizeHandleElements[index];
483
+ if (resizeHandleElement == null) {
484
+ if (0, $aedbef154d609804$export$df77466336fe5355) {
485
+ const { didWarnAboutMissingResizeHandle: didWarnAboutMissingResizeHandle } = devWarningsRef.current;
486
+ if (!didWarnAboutMissingResizeHandle) {
487
+ devWarningsRef.current.didWarnAboutMissingResizeHandle = true;
488
+ console.warn(`WARNING: Missing resize handle for PanelGroup "${groupId}"`);
489
+ }
779
490
  }
780
- }
781
- break;
491
+ } else {
492
+ const panelData = panelDataArray[index];
493
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(panelData);
494
+ resizeHandleElement.setAttribute("aria-controls", panelData.id);
495
+ resizeHandleElement.setAttribute("aria-valuemax", "" + Math.round(valueMax));
496
+ resizeHandleElement.setAttribute("aria-valuemin", "" + Math.round(valueMin));
497
+ resizeHandleElement.setAttribute("aria-valuenow", valueNow != null ? "" + Math.round(valueNow) : "");
782
498
  }
783
499
  }
784
- };
785
- handle.addEventListener("keydown", onKeyDown);
786
- return () => {
787
- handle.removeEventListener("keydown", onKeyDown);
788
- };
789
- });
790
- return () => {
791
- cleanupFunctions.forEach(cleanupFunction => cleanupFunction());
792
- };
793
- }, [committedValuesRef, eagerValuesRef, groupId, layout, panelDataArray, setLayout]);
500
+ return ()=>{
501
+ resizeHandleElements.forEach((resizeHandleElement, index)=>{
502
+ resizeHandleElement.removeAttribute("aria-controls");
503
+ resizeHandleElement.removeAttribute("aria-valuemax");
504
+ resizeHandleElement.removeAttribute("aria-valuemin");
505
+ resizeHandleElement.removeAttribute("aria-valuenow");
506
+ });
507
+ };
508
+ }, [
509
+ groupId,
510
+ layout,
511
+ panelDataArray
512
+ ]);
513
+ (0, $ef07efbe5fa7d87e$export$6d9c69b0de29b591)(()=>{
514
+ const eagerValues = eagerValuesRef.current;
515
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(eagerValues);
516
+ const { panelDataArray: panelDataArray } = eagerValues;
517
+ const groupElement = (0, $18131dcc0be2e4e0$export$4e72aefa594058df)(groupId);
518
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(groupElement != null, `No group found for id "${groupId}"`);
519
+ const handles = (0, $9196ba7c0d09e3f3$export$63eb605e437b214f)(groupId);
520
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(handles);
521
+ const cleanupFunctions = handles.map((handle)=>{
522
+ const handleId = handle.getAttribute("data-panel-resize-handle-id");
523
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(handleId);
524
+ const [idBefore, idAfter] = (0, $1420c4509c675b80$export$68d3a33c21dfbe27)(groupId, handleId, panelDataArray);
525
+ if (idBefore == null || idAfter == null) return ()=>{};
526
+ const onKeyDown = (event)=>{
527
+ if (event.defaultPrevented) return;
528
+ switch(event.key){
529
+ case "Enter":
530
+ {
531
+ event.preventDefault();
532
+ const index = panelDataArray.findIndex((panelData)=>panelData.id === idBefore);
533
+ if (index >= 0) {
534
+ const panelData = panelDataArray[index];
535
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(panelData);
536
+ const size = layout[index];
537
+ const { collapsedSize: collapsedSize = 0, collapsible: collapsible, minSize: minSize = 0 } = panelData.constraints;
538
+ if (size != null && collapsible) {
539
+ const nextLayout = (0, $fe96098ae4f2a44d$export$7fead5cc734d205b)({
540
+ delta: (0, $ee71a189401d6914$export$db9c8bd2fae72e82)(size, collapsedSize) ? minSize - collapsedSize : collapsedSize - size,
541
+ layout: layout,
542
+ panelConstraints: panelDataArray.map((panelData)=>panelData.constraints),
543
+ pivotIndices: (0, $0a239c1e1cd1e940$export$cf92598869f99b8f)(groupId, handleId),
544
+ trigger: "keyboard"
545
+ });
546
+ if (layout !== nextLayout) setLayout(nextLayout);
547
+ }
548
+ }
549
+ break;
550
+ }
551
+ }
552
+ };
553
+ handle.addEventListener("keydown", onKeyDown);
554
+ return ()=>{
555
+ handle.removeEventListener("keydown", onKeyDown);
556
+ };
557
+ });
558
+ return ()=>{
559
+ cleanupFunctions.forEach((cleanupFunction)=>cleanupFunction());
560
+ };
561
+ }, [
562
+ committedValuesRef,
563
+ eagerValuesRef,
564
+ groupId,
565
+ layout,
566
+ panelDataArray,
567
+ setLayout
568
+ ]);
794
569
  }
795
570
 
796
- function areEqual(arrayA, arrayB) {
797
- if (arrayA.length !== arrayB.length) {
798
- return false;
799
- }
800
- for (let index = 0; index < arrayA.length; index++) {
801
- if (arrayA[index] !== arrayB[index]) {
802
- return false;
571
+
572
+
573
+ function $c892f0f705e6ded5$export$b141efd0b0fb9174(arrayA, arrayB) {
574
+ if (arrayA.length !== arrayB.length) return false;
575
+ for(let index = 0; index < arrayA.length; index++){
576
+ if (arrayA[index] !== arrayB[index]) return false;
803
577
  }
804
- }
805
- return true;
578
+ return true;
806
579
  }
807
580
 
808
- function isKeyDown(event) {
809
- return event.type === "keydown";
581
+
582
+
583
+
584
+
585
+
586
+
587
+ function $5bf95d6f4b7f490d$export$e7bf60a870f429b0(event) {
588
+ return event.type === "keydown";
810
589
  }
811
- function isMouseEvent(event) {
812
- return event.type.startsWith("mouse");
590
+ function $5bf95d6f4b7f490d$export$764db16956f554f8(event) {
591
+ return event.type.startsWith("mouse");
813
592
  }
814
- function isTouchEvent(event) {
815
- return event.type.startsWith("touch");
593
+ function $5bf95d6f4b7f490d$export$c4dfce035d43d1e0(event) {
594
+ return event.type.startsWith("touch");
816
595
  }
817
596
 
818
- function getResizeEventCursorPosition(direction, event) {
819
- const isHorizontal = direction === "horizontal";
820
- if (isMouseEvent(event)) {
821
- return isHorizontal ? event.clientX : event.clientY;
822
- } else if (isTouchEvent(event)) {
823
- const firstTouch = event.touches[0];
824
- return isHorizontal ? firstTouch.screenX : firstTouch.screenY;
825
- } else {
826
- throw Error(`Unsupported event type "${event.type}"`);
827
- }
828
- }
829
597
 
830
- function calculateDragOffsetPercentage(event, dragHandleId, direction, initialDragState) {
831
- const isHorizontal = direction === "horizontal";
832
- const handleElement = getResizeHandleElement(dragHandleId);
833
- const groupId = handleElement.getAttribute("data-panel-group-id");
834
- let {
835
- initialCursorPosition
836
- } = initialDragState;
837
- const cursorPosition = getResizeEventCursorPosition(direction, event);
838
- const groupElement = getPanelGroupElement(groupId);
839
- const groupRect = groupElement.getBoundingClientRect();
840
- const groupSizeInPixels = isHorizontal ? groupRect.width : groupRect.height;
841
- const offsetPixels = cursorPosition - initialCursorPosition;
842
- const offsetPercentage = offsetPixels / groupSizeInPixels * 100;
843
- return offsetPercentage;
598
+ function $a568cbd9a3e686f5$export$ae0c59ca751ba81d(direction, event) {
599
+ const isHorizontal = direction === "horizontal";
600
+ if ((0, $5bf95d6f4b7f490d$export$764db16956f554f8)(event)) return isHorizontal ? event.clientX : event.clientY;
601
+ else if ((0, $5bf95d6f4b7f490d$export$c4dfce035d43d1e0)(event)) {
602
+ const firstTouch = event.touches[0];
603
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(firstTouch);
604
+ return isHorizontal ? firstTouch.screenX : firstTouch.screenY;
605
+ } else throw Error(`Unsupported event type "${event.type}"`);
844
606
  }
845
607
 
846
- // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/movementX
847
- function calculateDeltaPercentage(event, groupId, dragHandleId, direction, initialDragState, keyboardResizeByOptions) {
848
- if (isKeyDown(event)) {
608
+
609
+ function $27aab610d2a81ebc$export$e3b8a38f1f6abc89(event, dragHandleId, direction, initialDragState) {
849
610
  const isHorizontal = direction === "horizontal";
850
- const groupElement = getPanelGroupElement(groupId);
851
- const rect = groupElement.getBoundingClientRect();
852
- const groupSizeInPixels = isHorizontal ? rect.width : rect.height;
853
- let delta = 0;
854
- if (event.shiftKey) {
855
- delta = 100;
856
- } else if (keyboardResizeByOptions.percentage != null) {
857
- delta = keyboardResizeByOptions.percentage;
858
- } else if (keyboardResizeByOptions.pixels != null) {
859
- delta = keyboardResizeByOptions.pixels / groupSizeInPixels;
611
+ const handleElement = (0, $99b0d18e36332b26$export$4c5229c874a62620)(dragHandleId);
612
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(handleElement);
613
+ const groupId = handleElement.getAttribute("data-panel-group-id");
614
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(groupId);
615
+ let { initialCursorPosition: initialCursorPosition } = initialDragState;
616
+ const cursorPosition = (0, $a568cbd9a3e686f5$export$ae0c59ca751ba81d)(direction, event);
617
+ const groupElement = (0, $18131dcc0be2e4e0$export$4e72aefa594058df)(groupId);
618
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(groupElement);
619
+ const groupRect = groupElement.getBoundingClientRect();
620
+ const groupSizeInPixels = isHorizontal ? groupRect.width : groupRect.height;
621
+ const offsetPixels = cursorPosition - initialCursorPosition;
622
+ const offsetPercentage = offsetPixels / groupSizeInPixels * 100;
623
+ return offsetPercentage;
624
+ }
625
+
626
+
627
+
628
+ function $c845d5a27273095d$export$b08134b65f9db46a(event, dragHandleId, direction, initialDragState, keyboardResizeBy) {
629
+ if ((0, $5bf95d6f4b7f490d$export$e7bf60a870f429b0)(event)) {
630
+ const isHorizontal = direction === "horizontal";
631
+ let delta = 0;
632
+ if (event.shiftKey) delta = 100;
633
+ else if (keyboardResizeBy != null) delta = keyboardResizeBy;
634
+ else delta = 10;
635
+ let movement = 0;
636
+ switch(event.key){
637
+ case "ArrowDown":
638
+ movement = isHorizontal ? 0 : delta;
639
+ break;
640
+ case "ArrowLeft":
641
+ movement = isHorizontal ? -delta : 0;
642
+ break;
643
+ case "ArrowRight":
644
+ movement = isHorizontal ? delta : 0;
645
+ break;
646
+ case "ArrowUp":
647
+ movement = isHorizontal ? 0 : -delta;
648
+ break;
649
+ case "End":
650
+ movement = 100;
651
+ break;
652
+ case "Home":
653
+ movement = -100;
654
+ break;
655
+ }
656
+ return movement;
860
657
  } else {
861
- delta = 10;
658
+ if (initialDragState == null) return 0;
659
+ return (0, $27aab610d2a81ebc$export$e3b8a38f1f6abc89)(event, dragHandleId, direction, initialDragState);
862
660
  }
863
- let movement = 0;
864
- switch (event.key) {
865
- case "ArrowDown":
866
- movement = isHorizontal ? 0 : delta;
867
- break;
868
- case "ArrowLeft":
869
- movement = isHorizontal ? -delta : 0;
870
- break;
871
- case "ArrowRight":
872
- movement = isHorizontal ? delta : 0;
873
- break;
874
- case "ArrowUp":
875
- movement = isHorizontal ? 0 : -delta;
876
- break;
877
- case "End":
878
- movement = 100;
879
- break;
880
- case "Home":
881
- movement = -100;
882
- break;
883
- }
884
- return movement;
885
- } else {
886
- return calculateDragOffsetPercentage(event, dragHandleId, direction, initialDragState);
887
- }
888
661
  }
889
662
 
890
- function calculateUnsafeDefaultLayout({
891
- groupSizePixels,
892
- panelDataArray
893
- }) {
894
- const layout = Array(panelDataArray.length);
895
- const panelDataConstraints = panelDataArray.map(panelData => panelData.constraints);
896
- let numPanelsWithSizes = 0;
897
- let remainingSize = 100;
898
-
899
- // Distribute default sizes first
900
- for (let index = 0; index < panelDataArray.length; index++) {
901
- const {
902
- defaultSizePercentage
903
- } = computePercentagePanelConstraints(panelDataConstraints, index, groupSizePixels);
904
- if (defaultSizePercentage != null) {
905
- numPanelsWithSizes++;
906
- layout[index] = defaultSizePercentage;
907
- remainingSize -= defaultSizePercentage;
663
+
664
+
665
+ function $457c46ca858cf2c6$export$47337a21c443778e({ panelDataArray: panelDataArray }) {
666
+ const layout = Array(panelDataArray.length);
667
+ const panelConstraintsArray = panelDataArray.map((panelData)=>panelData.constraints);
668
+ let numPanelsWithSizes = 0;
669
+ let remainingSize = 100;
670
+ // Distribute default sizes first
671
+ for(let index = 0; index < panelDataArray.length; index++){
672
+ const panelConstraints = panelConstraintsArray[index];
673
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(panelConstraints);
674
+ const { defaultSize: defaultSize } = panelConstraints;
675
+ if (defaultSize != null) {
676
+ numPanelsWithSizes++;
677
+ layout[index] = defaultSize;
678
+ remainingSize -= defaultSize;
679
+ }
908
680
  }
909
- }
910
-
911
- // Remaining size should be distributed evenly between panels without default sizes
912
- for (let index = 0; index < panelDataArray.length; index++) {
913
- const {
914
- defaultSizePercentage
915
- } = computePercentagePanelConstraints(panelDataConstraints, index, groupSizePixels);
916
- if (defaultSizePercentage != null) {
917
- continue;
681
+ // Remaining size should be distributed evenly between panels without default sizes
682
+ for(let index = 0; index < panelDataArray.length; index++){
683
+ const panelConstraints = panelConstraintsArray[index];
684
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(panelConstraints);
685
+ const { defaultSize: defaultSize } = panelConstraints;
686
+ if (defaultSize != null) continue;
687
+ const numRemainingPanels = panelDataArray.length - numPanelsWithSizes;
688
+ const size = remainingSize / numRemainingPanels;
689
+ numPanelsWithSizes++;
690
+ layout[index] = size;
691
+ remainingSize -= size;
918
692
  }
919
- const numRemainingPanels = panelDataArray.length - numPanelsWithSizes;
920
- const size = remainingSize / numRemainingPanels;
921
- numPanelsWithSizes++;
922
- layout[index] = size;
923
- remainingSize -= size;
924
- }
925
- return layout;
693
+ return layout;
926
694
  }
927
695
 
928
- function convertPercentageToPixels(percentage, groupSizePixels) {
929
- return percentage / 100 * groupSizePixels;
930
- }
931
696
 
932
- // Layout should be pre-converted into percentages
933
- function callPanelCallbacks(groupId, panelsArray, layout, panelIdToLastNotifiedMixedSizesMap) {
934
- const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
935
- layout.forEach((sizePercentage, index) => {
936
- const panelData = panelsArray[index];
937
- if (!panelData) {
938
- // Handle initial mount (when panels are registered too late to be in the panels array)
939
- // The subsequent render+effects will handle the resize notification
940
- return;
941
- }
942
- const {
943
- callbacks,
944
- constraints,
945
- id: panelId
946
- } = panelData;
947
- const {
948
- collapsible
949
- } = constraints;
950
- const mixedSizes = {
951
- sizePercentage,
952
- sizePixels: convertPercentageToPixels(sizePercentage, groupSizePixels)
953
- };
954
- const lastNotifiedMixedSizes = panelIdToLastNotifiedMixedSizesMap[panelId];
955
- if (lastNotifiedMixedSizes == null || mixedSizes.sizePercentage !== lastNotifiedMixedSizes.sizePercentage || mixedSizes.sizePixels !== lastNotifiedMixedSizes.sizePixels) {
956
- panelIdToLastNotifiedMixedSizesMap[panelId] = mixedSizes;
957
- const {
958
- onCollapse,
959
- onExpand,
960
- onResize
961
- } = callbacks;
962
- if (onResize) {
963
- onResize(mixedSizes, lastNotifiedMixedSizes);
964
- }
965
- if (collapsible && (onCollapse || onExpand)) {
966
- var _getPercentageSizeFro;
967
- const collapsedSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
968
- sizePercentage: constraints.collapsedSizePercentage,
969
- sizePixels: constraints.collapsedSizePixels
970
- }, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
971
- const size = getPercentageSizeFromMixedSizes(mixedSizes, groupSizePixels);
972
- if (onExpand && (lastNotifiedMixedSizes == null || lastNotifiedMixedSizes.sizePercentage === collapsedSize) && size !== collapsedSize) {
973
- onExpand();
974
- }
975
- if (onCollapse && (lastNotifiedMixedSizes == null || lastNotifiedMixedSizes.sizePercentage !== collapsedSize) && size === collapsedSize) {
976
- onCollapse();
697
+
698
+ function $2743876c6469fb21$export$b8e48269e4faa934(panelsArray, layout, panelIdToLastNotifiedSizeMap) {
699
+ layout.forEach((size, index)=>{
700
+ const panelData = panelsArray[index];
701
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(panelData);
702
+ const { callbacks: callbacks, constraints: constraints, id: panelId } = panelData;
703
+ const { collapsedSize: collapsedSize = 0, collapsible: collapsible } = constraints;
704
+ const lastNotifiedSize = panelIdToLastNotifiedSizeMap[panelId];
705
+ if (lastNotifiedSize == null || size !== lastNotifiedSize) {
706
+ panelIdToLastNotifiedSizeMap[panelId] = size;
707
+ const { onCollapse: onCollapse, onExpand: onExpand, onResize: onResize } = callbacks;
708
+ if (onResize) onResize(size, lastNotifiedSize);
709
+ if (collapsible && (onCollapse || onExpand)) {
710
+ if (onExpand && (lastNotifiedSize == null || lastNotifiedSize === collapsedSize) && size !== collapsedSize) onExpand();
711
+ if (onCollapse && (lastNotifiedSize == null || lastNotifiedSize !== collapsedSize) && size === collapsedSize) onCollapse();
712
+ }
977
713
  }
978
- }
979
- }
980
- });
714
+ });
981
715
  }
982
716
 
983
- function compareLayouts(a, b) {
984
- if (a.length !== b.length) {
985
- return false;
986
- } else {
987
- for (let index = 0; index < a.length; index++) {
988
- if (a[index] != b[index]) {
989
- return false;
990
- }
717
+
718
+ function $81d2449822663a2a$export$a10903e2e57656c1(a, b) {
719
+ if (a.length !== b.length) return false;
720
+ else for(let index = 0; index < a.length; index++){
721
+ if (a[index] != b[index]) return false;
991
722
  }
992
- }
993
- return true;
723
+ return true;
994
724
  }
995
725
 
996
- // This method returns a number between 1 and 100 representing
997
726
 
998
- // the % of the group's overall space this panel should occupy.
999
- function computePanelFlexBoxStyle({
1000
- dragState,
1001
- layout,
1002
- panelData,
1003
- panelIndex,
1004
- precision = 3
1005
- }) {
1006
- const size = layout[panelIndex];
1007
- let flexGrow;
1008
- if (panelData.length === 1) {
1009
- flexGrow = "1";
1010
- } else if (size == null) {
1011
- // Initial render (before panels have registered themselves)
727
+ // This method returns a number between 1 and 100 representing
728
+ function $d4957558c333bad2$export$fc25f3248e61edf5({ dragState: dragState, layout: layout, panelData: panelData, panelIndex: panelIndex, precision: precision = 3 }) {
729
+ const size = layout[panelIndex];
730
+ let flexGrow;
731
+ if (panelData.length === 1) flexGrow = "1";
732
+ else if (size == null) // Initial render (before panels have registered themselves)
1012
733
  flexGrow = "1";
1013
- } else {
1014
- flexGrow = size.toPrecision(precision);
1015
- }
1016
- return {
1017
- flexBasis: 0,
1018
- flexGrow,
1019
- flexShrink: 1,
1020
- // Without this, Panel sizes may be unintentionally overridden by their content
1021
- overflow: "hidden",
1022
- // Disable pointer events inside of a panel during resize
1023
- // This avoid edge cases like nested iframes
1024
- pointerEvents: dragState !== null ? "none" : undefined
1025
- };
734
+ else flexGrow = size.toPrecision(precision);
735
+ return {
736
+ flexBasis: 0,
737
+ flexGrow: flexGrow,
738
+ flexShrink: 1,
739
+ // Without this, Panel sizes may be unintentionally overridden by their content
740
+ overflow: "hidden",
741
+ // Disable pointer events inside of a panel during resize
742
+ // This avoid edge cases like nested iframes
743
+ pointerEvents: dragState !== null ? "none" : undefined
744
+ };
1026
745
  }
1027
746
 
1028
- let currentState = null;
1029
- let element = null;
1030
- function getCursorStyle(state) {
1031
- switch (state) {
1032
- case "horizontal":
1033
- return "ew-resize";
1034
- case "horizontal-max":
1035
- return "w-resize";
1036
- case "horizontal-min":
1037
- return "e-resize";
1038
- case "vertical":
1039
- return "ns-resize";
1040
- case "vertical-max":
1041
- return "n-resize";
1042
- case "vertical-min":
1043
- return "s-resize";
1044
- }
747
+
748
+ let $8d9d88bebf1a8ace$var$currentState = null;
749
+ let $8d9d88bebf1a8ace$var$element = null;
750
+ function $8d9d88bebf1a8ace$export$fa35f3322c52262f(state) {
751
+ switch(state){
752
+ case "horizontal":
753
+ return "ew-resize";
754
+ case "horizontal-max":
755
+ return "w-resize";
756
+ case "horizontal-min":
757
+ return "e-resize";
758
+ case "vertical":
759
+ return "ns-resize";
760
+ case "vertical-max":
761
+ return "n-resize";
762
+ case "vertical-min":
763
+ return "s-resize";
764
+ }
1045
765
  }
1046
- function resetGlobalCursorStyle() {
1047
- if (element !== null) {
1048
- document.head.removeChild(element);
1049
- currentState = null;
1050
- element = null;
1051
- }
766
+ function $8d9d88bebf1a8ace$export$b61932ee18f96e08() {
767
+ if ($8d9d88bebf1a8ace$var$element !== null) {
768
+ document.head.removeChild($8d9d88bebf1a8ace$var$element);
769
+ $8d9d88bebf1a8ace$var$currentState = null;
770
+ $8d9d88bebf1a8ace$var$element = null;
771
+ }
1052
772
  }
1053
- function setGlobalCursorStyle(state) {
1054
- if (currentState === state) {
1055
- return;
1056
- }
1057
- currentState = state;
1058
- const style = getCursorStyle(state);
1059
- if (element === null) {
1060
- element = document.createElement("style");
1061
- document.head.appendChild(element);
1062
- }
1063
- element.innerHTML = `*{cursor: ${style}!important;}`;
773
+ function $8d9d88bebf1a8ace$export$d395b5dfd066a659(state) {
774
+ if ($8d9d88bebf1a8ace$var$currentState === state) return;
775
+ $8d9d88bebf1a8ace$var$currentState = state;
776
+ const style = $8d9d88bebf1a8ace$export$fa35f3322c52262f(state);
777
+ if ($8d9d88bebf1a8ace$var$element === null) {
778
+ $8d9d88bebf1a8ace$var$element = document.createElement("style");
779
+ document.head.appendChild($8d9d88bebf1a8ace$var$element);
780
+ }
781
+ $8d9d88bebf1a8ace$var$element.innerHTML = `*{cursor: ${style}!important;}`;
1064
782
  }
1065
783
 
1066
- function debounce(callback, durationMs = 10) {
1067
- let timeoutId = null;
1068
- let callable = (...args) => {
1069
- if (timeoutId !== null) {
1070
- clearTimeout(timeoutId);
1071
- }
1072
- timeoutId = setTimeout(() => {
1073
- callback(...args);
1074
- }, durationMs);
1075
- };
1076
- return callable;
784
+
785
+ function $f7d932e9304c1581$export$2e2bcd8739ae039(callback, durationMs = 10) {
786
+ let timeoutId = null;
787
+ let callable = (...args)=>{
788
+ if (timeoutId !== null) clearTimeout(timeoutId);
789
+ timeoutId = setTimeout(()=>{
790
+ callback(...args);
791
+ }, durationMs);
792
+ };
793
+ return callable;
1077
794
  }
1078
795
 
1079
- function getPanelElementsForGroup(groupId) {
1080
- return Array.from(document.querySelectorAll(`[data-panel][data-panel-group-id="${groupId}"]`));
796
+
797
+
798
+ function $8b4e4613c531093d$export$80bbb698e7429afe(groupId) {
799
+ return Array.from(document.querySelectorAll(`[data-panel][data-panel-group-id="${groupId}"]`));
1081
800
  }
1082
801
 
1083
- // PanelGroup might be rendering in a server-side environment where localStorage is not available
1084
- // or on a browser with cookies/storage disabled.
1085
- // In either case, this function avoids accessing localStorage until needed,
1086
- // and avoids throwing user-visible errors.
1087
- function initializeDefaultStorage(storageObject) {
1088
- try {
1089
- if (typeof localStorage !== "undefined") {
1090
- // Bypass this check for future calls
1091
- storageObject.getItem = name => {
1092
- return localStorage.getItem(name);
1093
- };
1094
- storageObject.setItem = (name, value) => {
1095
- localStorage.setItem(name, value);
1096
- };
1097
- } else {
1098
- throw new Error("localStorage not supported in this environment");
802
+
803
+
804
+
805
+
806
+ function $a7cb003aae329b18$export$cb0adc12c8406347(storageObject) {
807
+ try {
808
+ if (typeof localStorage !== "undefined") {
809
+ // Bypass this check for future calls
810
+ storageObject.getItem = (name)=>{
811
+ return localStorage.getItem(name);
812
+ };
813
+ storageObject.setItem = (name, value)=>{
814
+ localStorage.setItem(name, value);
815
+ };
816
+ } else throw new Error("localStorage not supported in this environment");
817
+ } catch (error) {
818
+ console.error(error);
819
+ storageObject.getItem = ()=>null;
820
+ storageObject.setItem = ()=>{};
1099
821
  }
1100
- } catch (error) {
1101
- console.error(error);
1102
- storageObject.getItem = () => null;
1103
- storageObject.setItem = () => {};
1104
- }
1105
822
  }
1106
823
 
824
+
1107
825
  // Note that Panel ids might be user-provided (stable) or useId generated (non-deterministic)
1108
826
  // so they should not be used as part of the serialization key.
1109
827
  // Using the min/max size attributes should work well enough as a backup.
1110
828
  // Pre-sorting by minSize allows remembering layouts even if panels are re-ordered/dragged.
1111
- function getSerializationKey(panels) {
1112
- return panels.map(panel => {
1113
- const {
1114
- constraints,
1115
- id,
1116
- idIsFromProps,
1117
- order
1118
- } = panel;
1119
- if (idIsFromProps) {
1120
- return id;
1121
- } else {
1122
- return `${order}:${JSON.stringify(constraints)}`;
1123
- }
1124
- }).sort((a, b) => a.localeCompare(b)).join(",");
829
+ function $6889c3a3ed41cfd1$var$getSerializationKey(panels) {
830
+ return panels.map((panel)=>{
831
+ const { constraints: constraints, id: id, idIsFromProps: idIsFromProps, order: order } = panel;
832
+ if (idIsFromProps) return id;
833
+ else return `${order}:${JSON.stringify(constraints)}`;
834
+ }).sort((a, b)=>a.localeCompare(b)).join(",");
1125
835
  }
1126
- function loadSerializedPanelGroupState(autoSaveId, storage) {
1127
- try {
1128
- const serialized = storage.getItem(`PanelGroup:sizes:${autoSaveId}`);
1129
- if (serialized) {
1130
- const parsed = JSON.parse(serialized);
1131
- if (typeof parsed === "object" && parsed != null) {
1132
- return parsed;
1133
- }
1134
- }
1135
- } catch (error) {}
1136
- return null;
836
+ function $6889c3a3ed41cfd1$var$loadSerializedPanelGroupState(autoSaveId, storage) {
837
+ try {
838
+ const serialized = storage.getItem(`PanelGroup:sizes:${autoSaveId}`);
839
+ if (serialized) {
840
+ const parsed = JSON.parse(serialized);
841
+ if (typeof parsed === "object" && parsed != null) return parsed;
842
+ }
843
+ } catch (error) {}
844
+ return null;
1137
845
  }
1138
- function loadPanelLayout(autoSaveId, panels, storage) {
1139
- const state = loadSerializedPanelGroupState(autoSaveId, storage);
1140
- if (state) {
1141
- var _state$key;
1142
- const key = getSerializationKey(panels);
1143
- return (_state$key = state[key]) !== null && _state$key !== void 0 ? _state$key : null;
1144
- }
1145
- return null;
846
+ function $6889c3a3ed41cfd1$export$9c80c6617f0386da(autoSaveId, panels, storage) {
847
+ const state = $6889c3a3ed41cfd1$var$loadSerializedPanelGroupState(autoSaveId, storage);
848
+ if (state) {
849
+ const key = $6889c3a3ed41cfd1$var$getSerializationKey(panels);
850
+ var _state_key;
851
+ return (_state_key = state[key]) !== null && _state_key !== void 0 ? _state_key : null;
852
+ }
853
+ return null;
1146
854
  }
1147
- function savePanelGroupLayout(autoSaveId, panels, sizes, storage) {
1148
- const key = getSerializationKey(panels);
1149
- const state = loadSerializedPanelGroupState(autoSaveId, storage) || {};
1150
- state[key] = sizes;
1151
- try {
1152
- storage.setItem(`PanelGroup:sizes:${autoSaveId}`, JSON.stringify(state));
1153
- } catch (error) {
1154
- console.error(error);
1155
- }
855
+ function $6889c3a3ed41cfd1$export$af183b313c61be4f(autoSaveId, panels, sizes, storage) {
856
+ const key = $6889c3a3ed41cfd1$var$getSerializationKey(panels);
857
+ const state = $6889c3a3ed41cfd1$var$loadSerializedPanelGroupState(autoSaveId, storage) || {};
858
+ state[key] = sizes;
859
+ try {
860
+ storage.setItem(`PanelGroup:sizes:${autoSaveId}`, JSON.stringify(state));
861
+ } catch (error) {
862
+ console.error(error);
863
+ }
1156
864
  }
1157
865
 
1158
- function shouldMonitorPixelBasedConstraints(constraints) {
1159
- return constraints.some(constraints => {
1160
- return constraints.collapsedSizePixels !== undefined || constraints.maxSizePixels !== undefined || constraints.minSizePixels !== undefined;
1161
- });
1162
- }
1163
866
 
1164
- // All units must be in percentages; pixel values should be pre-converted
1165
- function validatePanelGroupLayout({
1166
- groupSizePixels,
1167
- layout: prevLayout,
1168
- panelConstraints
1169
- }) {
1170
- const nextLayout = [...prevLayout];
1171
-
1172
- // Validate layout expectations
1173
- if (nextLayout.length !== panelConstraints.length) {
1174
- throw Error(`Invalid ${panelConstraints.length} panel layout: ${nextLayout.map(size => `${size}%`).join(", ")}`);
1175
- } else if (!fuzzyNumbersEqual(nextLayout.reduce((accumulated, current) => accumulated + current, 0), 100)) ;
1176
- let remainingSize = 0;
1177
-
1178
- // First pass: Validate the proposed layout given each panel's constraints
1179
- for (let index = 0; index < panelConstraints.length; index++) {
1180
- const unsafeSize = nextLayout[index];
1181
- const safeSize = resizePanel({
1182
- groupSizePixels,
1183
- panelConstraints,
1184
- panelIndex: index,
1185
- size: unsafeSize
1186
- });
1187
- if (unsafeSize != safeSize) {
1188
- remainingSize += unsafeSize - safeSize;
1189
- nextLayout[index] = safeSize;
1190
- }
1191
- }
1192
-
1193
- // If there is additional, left over space, assign it to any panel(s) that permits it
1194
- // (It's not worth taking multiple additional passes to evenly distribute)
1195
- if (!fuzzyNumbersEqual(remainingSize, 0)) {
1196
- for (let index = 0; index < panelConstraints.length; index++) {
1197
- const prevSize = nextLayout[index];
1198
- const unsafeSize = prevSize + remainingSize;
1199
- const safeSize = resizePanel({
1200
- groupSizePixels,
1201
- panelConstraints,
1202
- panelIndex: index,
1203
- size: unsafeSize
1204
- });
1205
- if (prevSize !== safeSize) {
1206
- remainingSize -= safeSize - prevSize;
1207
- nextLayout[index] = safeSize;
1208
-
1209
- // Once we've used up the remainder, bail
1210
- if (fuzzyNumbersEqual(remainingSize, 0)) {
1211
- break;
867
+
868
+
869
+ function $006440f9579d3b07$export$d00cfefa2c395b39({ panelConstraints: panelConstraintsArray, panelId: panelId, panelIndex: panelIndex }) {
870
+ if (0, $aedbef154d609804$export$df77466336fe5355) {
871
+ const warnings = [];
872
+ const panelConstraints = panelConstraintsArray[panelIndex];
873
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(panelConstraints);
874
+ const { collapsedSize: collapsedSize = 0, defaultSize: defaultSize, maxSize: maxSize = 100, minSize: minSize = 0 } = panelConstraints;
875
+ if (minSize > maxSize) warnings.push(`min size (${minSize}%) should not be greater than max size (${maxSize}%)`);
876
+ if (defaultSize != null) {
877
+ if (defaultSize < 0) warnings.push("default size should not be less than 0");
878
+ else if (defaultSize < minSize) warnings.push("default size should not be less than min size");
879
+ if (defaultSize > 100) warnings.push("default size should not be greater than 100");
880
+ else if (defaultSize > maxSize) warnings.push("default size should not be greater than max size");
881
+ }
882
+ if (collapsedSize > minSize) warnings.push("collapsed size should not be greater than min size");
883
+ if (warnings.length > 0) {
884
+ const name = panelId != null ? `Panel "${panelId}"` : "Panel";
885
+ console.warn(`${name} has an invalid configuration:\n\n${warnings.join("\n")}`);
886
+ return false;
1212
887
  }
1213
- }
1214
888
  }
1215
- }
1216
- return nextLayout;
889
+ return true;
1217
890
  }
1218
891
 
1219
- const LOCAL_STORAGE_DEBOUNCE_INTERVAL = 100;
1220
- const defaultStorage = {
1221
- getItem: name => {
1222
- initializeDefaultStorage(defaultStorage);
1223
- return defaultStorage.getItem(name);
1224
- },
1225
- setItem: (name, value) => {
1226
- initializeDefaultStorage(defaultStorage);
1227
- defaultStorage.setItem(name, value);
1228
- }
1229
- };
1230
- const debounceMap = {};
1231
- function PanelGroupWithForwardedRef({
1232
- autoSaveId = null,
1233
- children,
1234
- className: classNameFromProps = "",
1235
- dataAttributes,
1236
- direction,
1237
- forwardedRef,
1238
- id: idFromProps,
1239
- onLayout = null,
1240
- keyboardResizeByPercentage = null,
1241
- keyboardResizeByPixels = null,
1242
- storage = defaultStorage,
1243
- style: styleFromProps,
1244
- tagName: Type = "div"
1245
- }) {
1246
- const groupId = useUniqueId(idFromProps);
1247
- const [dragState, setDragState] = useState(null);
1248
- const [layout, setLayout] = useState([]);
1249
- const panelIdToLastNotifiedMixedSizesMapRef = useRef({});
1250
- const panelSizeBeforeCollapseRef = useRef(new Map());
1251
- const prevDeltaRef = useRef(0);
1252
- const committedValuesRef = useRef({
1253
- autoSaveId,
1254
- direction,
1255
- dragState,
1256
- id: groupId,
1257
- keyboardResizeByPercentage,
1258
- keyboardResizeByPixels,
1259
- onLayout,
1260
- storage
1261
- });
1262
- const eagerValuesRef = useRef({
1263
- layout,
1264
- panelDataArray: []
1265
- });
1266
- useRef({
1267
- didLogIdAndOrderWarning: false,
1268
- didLogPanelConstraintsWarning: false,
1269
- prevPanelIds: []
1270
- });
1271
- useImperativeHandle(forwardedRef, () => ({
1272
- getId: () => committedValuesRef.current.id,
1273
- getLayout: () => {
1274
- const {
1275
- id: groupId
1276
- } = committedValuesRef.current;
1277
- const {
1278
- layout
1279
- } = eagerValuesRef.current;
1280
- const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
1281
- return layout.map(sizePercentage => {
1282
- return {
1283
- sizePercentage,
1284
- sizePixels: convertPercentageToPixels(sizePercentage, groupSizePixels)
1285
- };
1286
- });
1287
- },
1288
- setLayout: mixedSizes => {
1289
- const {
1290
- id: groupId,
1291
- onLayout
1292
- } = committedValuesRef.current;
1293
- const {
1294
- layout: prevLayout,
1295
- panelDataArray
1296
- } = eagerValuesRef.current;
1297
- const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
1298
- const unsafeLayout = mixedSizes.map(mixedSize => getPercentageSizeFromMixedSizes(mixedSize, groupSizePixels));
1299
- const safeLayout = validatePanelGroupLayout({
1300
- groupSizePixels,
1301
- layout: unsafeLayout,
1302
- panelConstraints: panelDataArray.map(panelData => panelData.constraints)
1303
- });
1304
- if (!areEqual(prevLayout, safeLayout)) {
1305
- setLayout(safeLayout);
1306
- eagerValuesRef.current.layout = safeLayout;
1307
- if (onLayout) {
1308
- onLayout(safeLayout.map(sizePercentage => ({
1309
- sizePercentage,
1310
- sizePixels: convertPercentageToPixels(sizePercentage, groupSizePixels)
1311
- })));
1312
- }
1313
- callPanelCallbacks(groupId, panelDataArray, safeLayout, panelIdToLastNotifiedMixedSizesMapRef.current);
1314
- }
1315
- }
1316
- }), []);
1317
- useIsomorphicLayoutEffect(() => {
1318
- committedValuesRef.current.autoSaveId = autoSaveId;
1319
- committedValuesRef.current.direction = direction;
1320
- committedValuesRef.current.dragState = dragState;
1321
- committedValuesRef.current.id = groupId;
1322
- committedValuesRef.current.onLayout = onLayout;
1323
- committedValuesRef.current.storage = storage;
1324
-
1325
- // panelDataArray and layout are updated in-sync with scheduled state updates.
1326
- // TODO [217] Move these values into a separate ref
1327
- });
1328
-
1329
- useWindowSplitterPanelGroupBehavior({
1330
- committedValuesRef,
1331
- eagerValuesRef,
1332
- groupId,
1333
- layout,
1334
- panelDataArray: eagerValuesRef.current.panelDataArray,
1335
- setLayout
1336
- });
1337
- useEffect(() => {
1338
- const {
1339
- panelDataArray
1340
- } = eagerValuesRef.current;
1341
-
1342
- // If this panel has been configured to persist sizing information, save sizes to local storage.
1343
- if (autoSaveId) {
1344
- if (layout.length === 0 || layout.length !== panelDataArray.length) {
1345
- return;
1346
- }
1347
-
1348
- // Limit the frequency of localStorage updates.
1349
- if (!debounceMap[autoSaveId]) {
1350
- debounceMap[autoSaveId] = debounce(savePanelGroupLayout, LOCAL_STORAGE_DEBOUNCE_INTERVAL);
1351
- }
1352
- debounceMap[autoSaveId](autoSaveId, panelDataArray, layout, storage);
1353
- }
1354
- }, [autoSaveId, layout, storage]);
1355
- useIsomorphicLayoutEffect(() => {
1356
- const {
1357
- layout: prevLayout,
1358
- panelDataArray
1359
- } = eagerValuesRef.current;
1360
- const constraints = panelDataArray.map(({
1361
- constraints
1362
- }) => constraints);
1363
- if (!shouldMonitorPixelBasedConstraints(constraints)) {
1364
- // Avoid the overhead of ResizeObserver if no pixel constraints require monitoring
1365
- return;
1366
- }
1367
- if (typeof ResizeObserver === "undefined") {
1368
- console.warn(`WARNING: Pixel based constraints require ResizeObserver but it is not supported by the current browser.`);
1369
- } else {
1370
- const resizeObserver = new ResizeObserver(() => {
1371
- const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
1372
- const {
1373
- onLayout
1374
- } = committedValuesRef.current;
1375
- const nextLayout = validatePanelGroupLayout({
1376
- groupSizePixels,
1377
- layout: prevLayout,
1378
- panelConstraints: panelDataArray.map(panelData => panelData.constraints)
1379
- });
1380
- if (!areEqual(prevLayout, nextLayout)) {
1381
- setLayout(nextLayout);
1382
- eagerValuesRef.current.layout = nextLayout;
1383
- if (onLayout) {
1384
- onLayout(nextLayout.map(sizePercentage => ({
1385
- sizePercentage,
1386
- sizePixels: convertPercentageToPixels(sizePercentage, groupSizePixels)
1387
- })));
1388
- }
1389
- callPanelCallbacks(groupId, panelDataArray, nextLayout, panelIdToLastNotifiedMixedSizesMapRef.current);
892
+
893
+
894
+
895
+
896
+
897
+ function $6f1a05873bb6ec6f$export$64432a52a1035c18({ layout: prevLayout, panelConstraints: panelConstraints }) {
898
+ const nextLayout = [
899
+ ...prevLayout
900
+ ];
901
+ const nextLayoutTotalSize = nextLayout.reduce((accumulated, current)=>accumulated + current, 0);
902
+ // Validate layout expectations
903
+ if (nextLayout.length !== panelConstraints.length) throw Error(`Invalid ${panelConstraints.length} panel layout: ${nextLayout.map((size)=>`${size}%`).join(", ")}`);
904
+ else if (!(0, $ee71a189401d6914$export$db9c8bd2fae72e82)(nextLayoutTotalSize, 100)) {
905
+ // This is not ideal so we should warn about it, but it may be recoverable in some cases
906
+ // (especially if the amount is small)
907
+ if (0, $aedbef154d609804$export$df77466336fe5355) console.warn(`WARNING: Invalid layout total size: ${nextLayout.map((size)=>`${size}%`).join(", ")}. Layout normalization will be applied.`);
908
+ for(let index = 0; index < panelConstraints.length; index++){
909
+ const unsafeSize = nextLayout[index];
910
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(unsafeSize != null);
911
+ const safeSize = 100 / nextLayoutTotalSize * unsafeSize;
912
+ nextLayout[index] = safeSize;
1390
913
  }
1391
- });
1392
- resizeObserver.observe(getPanelGroupElement(groupId));
1393
- return () => {
1394
- resizeObserver.disconnect();
1395
- };
1396
914
  }
1397
- }, [groupId]);
1398
-
1399
- // DEV warnings
1400
- useEffect(() => {
1401
- });
1402
-
1403
- // External APIs are safe to memoize via committed values ref
1404
- const collapsePanel = useCallback(panelData => {
1405
- const {
1406
- onLayout
1407
- } = committedValuesRef.current;
1408
- const {
1409
- layout: prevLayout,
1410
- panelDataArray
1411
- } = eagerValuesRef.current;
1412
- if (panelData.constraints.collapsible) {
1413
- const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
1414
- const {
1415
- collapsedSizePercentage,
1416
- panelSizePercentage,
1417
- pivotIndices,
1418
- groupSizePixels
1419
- } = panelDataHelper(groupId, panelDataArray, panelData, prevLayout);
1420
- if (panelSizePercentage !== collapsedSizePercentage) {
1421
- // Store size before collapse;
1422
- // This is the size that gets restored if the expand() API is used.
1423
- panelSizeBeforeCollapseRef.current.set(panelData.id, panelSizePercentage);
1424
- const isLastPanel = panelDataArray.indexOf(panelData) === panelDataArray.length - 1;
1425
- const delta = isLastPanel ? panelSizePercentage - collapsedSizePercentage : collapsedSizePercentage - panelSizePercentage;
1426
- const nextLayout = adjustLayoutByDelta({
1427
- delta,
1428
- groupSizePixels,
1429
- layout: prevLayout,
1430
- panelConstraints: panelConstraintsArray,
1431
- pivotIndices,
1432
- trigger: "imperative-api"
915
+ let remainingSize = 0;
916
+ // First pass: Validate the proposed layout given each panel's constraints
917
+ for(let index = 0; index < panelConstraints.length; index++){
918
+ const unsafeSize = nextLayout[index];
919
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(unsafeSize != null);
920
+ const safeSize = (0, $40f29f7a20511409$export$2f98edcf4006376f)({
921
+ panelConstraints: panelConstraints,
922
+ panelIndex: index,
923
+ size: unsafeSize
1433
924
  });
1434
- if (!compareLayouts(prevLayout, nextLayout)) {
1435
- setLayout(nextLayout);
1436
- eagerValuesRef.current.layout = nextLayout;
1437
- if (onLayout) {
1438
- onLayout(nextLayout.map(sizePercentage => ({
1439
- sizePercentage,
1440
- sizePixels: convertPercentageToPixels(sizePercentage, groupSizePixels)
1441
- })));
1442
- }
1443
- callPanelCallbacks(groupId, panelDataArray, nextLayout, panelIdToLastNotifiedMixedSizesMapRef.current);
925
+ if (unsafeSize != safeSize) {
926
+ remainingSize += unsafeSize - safeSize;
927
+ nextLayout[index] = safeSize;
1444
928
  }
1445
- }
1446
929
  }
1447
- }, [groupId]);
1448
-
1449
- // External APIs are safe to memoize via committed values ref
1450
- const expandPanel = useCallback(panelData => {
1451
- const {
1452
- onLayout
1453
- } = committedValuesRef.current;
1454
- const {
1455
- layout: prevLayout,
1456
- panelDataArray
1457
- } = eagerValuesRef.current;
1458
- if (panelData.constraints.collapsible) {
1459
- const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
1460
- const {
1461
- collapsedSizePercentage,
1462
- panelSizePercentage,
1463
- minSizePercentage,
1464
- pivotIndices,
1465
- groupSizePixels
1466
- } = panelDataHelper(groupId, panelDataArray, panelData, prevLayout);
1467
- if (panelSizePercentage === collapsedSizePercentage) {
1468
- // Restore this panel to the size it was before it was collapsed, if possible.
1469
- const prevPanelSizePercentage = panelSizeBeforeCollapseRef.current.get(panelData.id);
1470
- const baseSizePercentage = prevPanelSizePercentage != null && prevPanelSizePercentage >= minSizePercentage ? prevPanelSizePercentage : minSizePercentage;
1471
- const isLastPanel = panelDataArray.indexOf(panelData) === panelDataArray.length - 1;
1472
- const delta = isLastPanel ? panelSizePercentage - baseSizePercentage : baseSizePercentage - panelSizePercentage;
1473
- const nextLayout = adjustLayoutByDelta({
1474
- delta,
1475
- groupSizePixels,
1476
- layout: prevLayout,
1477
- panelConstraints: panelConstraintsArray,
1478
- pivotIndices,
1479
- trigger: "imperative-api"
930
+ // If there is additional, left over space, assign it to any panel(s) that permits it
931
+ // (It's not worth taking multiple additional passes to evenly distribute)
932
+ if (!(0, $ee71a189401d6914$export$db9c8bd2fae72e82)(remainingSize, 0)) for(let index = 0; index < panelConstraints.length; index++){
933
+ const prevSize = nextLayout[index];
934
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(prevSize != null);
935
+ const unsafeSize = prevSize + remainingSize;
936
+ const safeSize = (0, $40f29f7a20511409$export$2f98edcf4006376f)({
937
+ panelConstraints: panelConstraints,
938
+ panelIndex: index,
939
+ size: unsafeSize
1480
940
  });
1481
- if (!compareLayouts(prevLayout, nextLayout)) {
1482
- setLayout(nextLayout);
1483
- eagerValuesRef.current.layout = nextLayout;
1484
- if (onLayout) {
1485
- onLayout(nextLayout.map(sizePercentage => ({
1486
- sizePercentage,
1487
- sizePixels: convertPercentageToPixels(sizePercentage, groupSizePixels)
1488
- })));
1489
- }
1490
- callPanelCallbacks(groupId, panelDataArray, nextLayout, panelIdToLastNotifiedMixedSizesMapRef.current);
941
+ if (prevSize !== safeSize) {
942
+ remainingSize -= safeSize - prevSize;
943
+ nextLayout[index] = safeSize;
944
+ // Once we've used up the remainder, bail
945
+ if ((0, $ee71a189401d6914$export$db9c8bd2fae72e82)(remainingSize, 0)) break;
1491
946
  }
1492
- }
1493
- }
1494
- }, [groupId]);
1495
-
1496
- // External APIs are safe to memoize via committed values ref
1497
- const getPanelSize = useCallback(panelData => {
1498
- const {
1499
- layout,
1500
- panelDataArray
1501
- } = eagerValuesRef.current;
1502
- const {
1503
- panelSizePercentage,
1504
- panelSizePixels
1505
- } = panelDataHelper(groupId, panelDataArray, panelData, layout);
1506
- return {
1507
- sizePercentage: panelSizePercentage,
1508
- sizePixels: panelSizePixels
1509
- };
1510
- }, [groupId]);
1511
-
1512
- // This API should never read from committedValuesRef
1513
- const getPanelStyle = useCallback(panelData => {
1514
- const {
1515
- panelDataArray
1516
- } = eagerValuesRef.current;
1517
- const panelIndex = panelDataArray.indexOf(panelData);
1518
- return computePanelFlexBoxStyle({
1519
- dragState,
1520
- layout,
1521
- panelData: panelDataArray,
1522
- panelIndex
1523
- });
1524
- }, [dragState, layout]);
1525
-
1526
- // External APIs are safe to memoize via committed values ref
1527
- const isPanelCollapsed = useCallback(panelData => {
1528
- const {
1529
- layout,
1530
- panelDataArray
1531
- } = eagerValuesRef.current;
1532
- const {
1533
- collapsedSizePercentage,
1534
- collapsible,
1535
- panelSizePercentage
1536
- } = panelDataHelper(groupId, panelDataArray, panelData, layout);
1537
- return collapsible === true && panelSizePercentage === collapsedSizePercentage;
1538
- }, [groupId]);
1539
-
1540
- // External APIs are safe to memoize via committed values ref
1541
- const isPanelExpanded = useCallback(panelData => {
1542
- const {
1543
- layout,
1544
- panelDataArray
1545
- } = eagerValuesRef.current;
1546
- const {
1547
- collapsedSizePercentage,
1548
- collapsible,
1549
- panelSizePercentage
1550
- } = panelDataHelper(groupId, panelDataArray, panelData, layout);
1551
- return !collapsible || panelSizePercentage > collapsedSizePercentage;
1552
- }, [groupId]);
1553
- const registerPanel = useCallback(panelData => {
1554
- const {
1555
- autoSaveId,
1556
- id: groupId,
1557
- onLayout,
1558
- storage
1559
- } = committedValuesRef.current;
1560
- const {
1561
- layout: prevLayout,
1562
- panelDataArray
1563
- } = eagerValuesRef.current;
1564
- panelDataArray.push(panelData);
1565
- panelDataArray.sort((panelA, panelB) => {
1566
- const orderA = panelA.order;
1567
- const orderB = panelB.order;
1568
- if (orderA == null && orderB == null) {
1569
- return 0;
1570
- } else if (orderA == null) {
1571
- return -1;
1572
- } else if (orderB == null) {
1573
- return 1;
1574
- } else {
1575
- return orderA - orderB;
1576
- }
1577
- });
1578
-
1579
- // Wait until all panels have registered before we try to compute layout;
1580
- // doing it earlier is both wasteful and may trigger misleading warnings in development mode.
1581
- const panelElements = getPanelElementsForGroup(groupId);
1582
- if (panelElements.length !== panelDataArray.length) {
1583
- return;
1584
947
  }
948
+ return nextLayout;
949
+ }
1585
950
 
1586
- // If this panel has been configured to persist sizing information,
1587
- // default size should be restored from local storage if possible.
1588
- let unsafeLayout = null;
1589
- if (autoSaveId) {
1590
- unsafeLayout = loadPanelLayout(autoSaveId, panelDataArray, storage);
1591
- }
1592
- const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
1593
- if (groupSizePixels <= 0) {
1594
- if (shouldMonitorPixelBasedConstraints(panelDataArray.map(({
1595
- constraints
1596
- }) => constraints))) {
1597
- // Wait until the group has rendered a non-zero size before computing layout.
1598
- return;
1599
- }
1600
- }
1601
- if (unsafeLayout == null) {
1602
- unsafeLayout = calculateUnsafeDefaultLayout({
1603
- groupSizePixels,
1604
- panelDataArray
1605
- });
1606
- }
1607
951
 
1608
- // Validate even saved layouts in case something has changed since last render
1609
- // e.g. for pixel groups, this could be the size of the window
1610
- const nextLayout = validatePanelGroupLayout({
1611
- groupSizePixels,
1612
- layout: unsafeLayout,
1613
- panelConstraints: panelDataArray.map(panelData => panelData.constraints)
1614
- });
1615
952
 
1616
- // Offscreen mode makes this a bit weird;
1617
- // Panels unregister when hidden and re-register when shown again,
1618
- // but the overall layout doesn't change between these two cases.
1619
- setLayout(nextLayout);
1620
- eagerValuesRef.current.layout = nextLayout;
1621
- if (!areEqual(prevLayout, nextLayout)) {
1622
- if (onLayout) {
1623
- onLayout(nextLayout.map(sizePercentage => ({
1624
- sizePercentage,
1625
- sizePixels: convertPercentageToPixels(sizePercentage, groupSizePixels)
1626
- })));
1627
- }
1628
- callPanelCallbacks(groupId, panelDataArray, nextLayout, panelIdToLastNotifiedMixedSizesMapRef.current);
953
+ const $3daa5d4c086ea816$var$LOCAL_STORAGE_DEBOUNCE_INTERVAL = 100;
954
+ const $3daa5d4c086ea816$var$defaultStorage = {
955
+ getItem: (name)=>{
956
+ (0, $a7cb003aae329b18$export$cb0adc12c8406347)($3daa5d4c086ea816$var$defaultStorage);
957
+ return $3daa5d4c086ea816$var$defaultStorage.getItem(name);
958
+ },
959
+ setItem: (name, value)=>{
960
+ (0, $a7cb003aae329b18$export$cb0adc12c8406347)($3daa5d4c086ea816$var$defaultStorage);
961
+ $3daa5d4c086ea816$var$defaultStorage.setItem(name, value);
1629
962
  }
1630
- }, []);
1631
- const registerResizeHandle = useCallback(dragHandleId => {
1632
- return function resizeHandler(event) {
1633
- event.preventDefault();
1634
- const {
1635
- direction,
1636
- dragState,
963
+ };
964
+ const $3daa5d4c086ea816$var$debounceMap = {};
965
+ function $3daa5d4c086ea816$var$PanelGroupWithForwardedRef({ autoSaveId: autoSaveId = null, children: children, className: classNameFromProps = "", direction: direction, forwardedRef: forwardedRef, id: idFromProps = null, onLayout: onLayout = null, keyboardResizeBy: keyboardResizeBy = null, storage: storage = $3daa5d4c086ea816$var$defaultStorage, style: styleFromProps, tagName: Type = "div", ...rest }) {
966
+ const groupId = (0, $e504a2438473eda9$export$2e2bcd8739ae039)(idFromProps);
967
+ const [dragState, setDragState] = (0, $ef07efbe5fa7d87e$export$60241385465d0a34)(null);
968
+ const [layout, setLayout] = (0, $ef07efbe5fa7d87e$export$60241385465d0a34)([]);
969
+ const panelIdToLastNotifiedSizeMapRef = (0, $ef07efbe5fa7d87e$export$b8f5890fc79d6aca)({});
970
+ const panelSizeBeforeCollapseRef = (0, $ef07efbe5fa7d87e$export$b8f5890fc79d6aca)(new Map());
971
+ const prevDeltaRef = (0, $ef07efbe5fa7d87e$export$b8f5890fc79d6aca)(0);
972
+ const committedValuesRef = (0, $ef07efbe5fa7d87e$export$b8f5890fc79d6aca)({
973
+ autoSaveId: autoSaveId,
974
+ direction: direction,
975
+ dragState: dragState,
1637
976
  id: groupId,
1638
- keyboardResizeByPercentage,
1639
- keyboardResizeByPixels,
1640
- onLayout
1641
- } = committedValuesRef.current;
1642
- const {
1643
- layout: prevLayout,
1644
- panelDataArray
1645
- } = eagerValuesRef.current;
1646
- const {
1647
- initialLayout
1648
- } = dragState !== null && dragState !== void 0 ? dragState : {};
1649
- const pivotIndices = determinePivotIndices(groupId, dragHandleId);
1650
- let delta = calculateDeltaPercentage(event, groupId, dragHandleId, direction, dragState, {
1651
- percentage: keyboardResizeByPercentage,
1652
- pixels: keyboardResizeByPixels
1653
- });
1654
- if (delta === 0) {
1655
- return;
1656
- }
1657
-
1658
- // Support RTL layouts
1659
- const isHorizontal = direction === "horizontal";
1660
- if (document.dir === "rtl" && isHorizontal) {
1661
- delta = -delta;
1662
- }
1663
- const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
1664
- const panelConstraints = panelDataArray.map(panelData => panelData.constraints);
1665
- const nextLayout = adjustLayoutByDelta({
1666
- delta,
1667
- groupSizePixels,
1668
- layout: initialLayout !== null && initialLayout !== void 0 ? initialLayout : prevLayout,
1669
- panelConstraints,
1670
- pivotIndices,
1671
- trigger: isKeyDown(event) ? "keyboard" : "mouse-or-touch"
1672
- });
1673
- const layoutChanged = !compareLayouts(prevLayout, nextLayout);
1674
-
1675
- // Only update the cursor for layout changes triggered by touch/mouse events (not keyboard)
1676
- // Update the cursor even if the layout hasn't changed (we may need to show an invalid cursor state)
1677
- if (isMouseEvent(event) || isTouchEvent(event)) {
1678
- // Watch for multiple subsequent deltas; this might occur for tiny cursor movements.
1679
- // In this case, Panel sizes might not change–
1680
- // but updating cursor in this scenario would cause a flicker.
1681
- if (prevDeltaRef.current != delta) {
1682
- prevDeltaRef.current = delta;
1683
- if (!layoutChanged) {
1684
- // If the pointer has moved too far to resize the panel any further,
1685
- // update the cursor style for a visual clue.
1686
- // This mimics VS Code behavior.
1687
-
1688
- if (isHorizontal) {
1689
- setGlobalCursorStyle(delta < 0 ? "horizontal-min" : "horizontal-max");
1690
- } else {
1691
- setGlobalCursorStyle(delta < 0 ? "vertical-min" : "vertical-max");
977
+ keyboardResizeBy: keyboardResizeBy,
978
+ onLayout: onLayout,
979
+ storage: storage
980
+ });
981
+ const eagerValuesRef = (0, $ef07efbe5fa7d87e$export$b8f5890fc79d6aca)({
982
+ layout: layout,
983
+ panelDataArray: []
984
+ });
985
+ const devWarningsRef = (0, $ef07efbe5fa7d87e$export$b8f5890fc79d6aca)({
986
+ didLogIdAndOrderWarning: false,
987
+ didLogPanelConstraintsWarning: false,
988
+ prevPanelIds: []
989
+ });
990
+ (0, $ef07efbe5fa7d87e$export$d5a552a76deda3c2)(forwardedRef, ()=>({
991
+ getId: ()=>committedValuesRef.current.id,
992
+ getLayout: ()=>{
993
+ const { layout: layout } = eagerValuesRef.current;
994
+ return layout;
995
+ },
996
+ setLayout: (unsafeLayout)=>{
997
+ const { onLayout: onLayout } = committedValuesRef.current;
998
+ const { layout: prevLayout, panelDataArray: panelDataArray } = eagerValuesRef.current;
999
+ const safeLayout = (0, $6f1a05873bb6ec6f$export$64432a52a1035c18)({
1000
+ layout: unsafeLayout,
1001
+ panelConstraints: panelDataArray.map((panelData)=>panelData.constraints)
1002
+ });
1003
+ if (!(0, $c892f0f705e6ded5$export$b141efd0b0fb9174)(prevLayout, safeLayout)) {
1004
+ setLayout(safeLayout);
1005
+ eagerValuesRef.current.layout = safeLayout;
1006
+ if (onLayout) onLayout(safeLayout);
1007
+ (0, $2743876c6469fb21$export$b8e48269e4faa934)(panelDataArray, safeLayout, panelIdToLastNotifiedSizeMapRef.current);
1008
+ }
1009
+ }
1010
+ }), []);
1011
+ (0, $3f95d3e171760903$export$2e2bcd8739ae039)(()=>{
1012
+ committedValuesRef.current.autoSaveId = autoSaveId;
1013
+ committedValuesRef.current.direction = direction;
1014
+ committedValuesRef.current.dragState = dragState;
1015
+ committedValuesRef.current.id = groupId;
1016
+ committedValuesRef.current.onLayout = onLayout;
1017
+ committedValuesRef.current.storage = storage;
1018
+ });
1019
+ (0, $20152a6c44989ce6$export$d9fcbe062527d159)({
1020
+ committedValuesRef: committedValuesRef,
1021
+ eagerValuesRef: eagerValuesRef,
1022
+ groupId: groupId,
1023
+ layout: layout,
1024
+ panelDataArray: eagerValuesRef.current.panelDataArray,
1025
+ setLayout: setLayout
1026
+ });
1027
+ (0, $ef07efbe5fa7d87e$export$6d9c69b0de29b591)(()=>{
1028
+ const { panelDataArray: panelDataArray } = eagerValuesRef.current;
1029
+ // If this panel has been configured to persist sizing information, save sizes to local storage.
1030
+ if (autoSaveId) {
1031
+ if (layout.length === 0 || layout.length !== panelDataArray.length) return;
1032
+ let debouncedSave = $3daa5d4c086ea816$var$debounceMap[autoSaveId];
1033
+ // Limit the frequency of localStorage updates.
1034
+ if (debouncedSave == null) {
1035
+ debouncedSave = (0, $f7d932e9304c1581$export$2e2bcd8739ae039)((0, $6889c3a3ed41cfd1$export$af183b313c61be4f), $3daa5d4c086ea816$var$LOCAL_STORAGE_DEBOUNCE_INTERVAL);
1036
+ $3daa5d4c086ea816$var$debounceMap[autoSaveId] = debouncedSave;
1692
1037
  }
1693
- } else {
1694
- // Reset the cursor style to the the normal resize cursor.
1695
- setGlobalCursorStyle(isHorizontal ? "horizontal" : "vertical");
1696
- }
1038
+ debouncedSave(autoSaveId, panelDataArray, layout, storage);
1697
1039
  }
1698
- }
1699
- if (layoutChanged) {
1700
- setLayout(nextLayout);
1701
- eagerValuesRef.current.layout = nextLayout;
1702
- if (onLayout) {
1703
- onLayout(nextLayout.map(sizePercentage => ({
1704
- sizePercentage,
1705
- sizePixels: convertPercentageToPixels(sizePercentage, groupSizePixels)
1706
- })));
1040
+ }, [
1041
+ autoSaveId,
1042
+ layout,
1043
+ storage
1044
+ ]);
1045
+ // DEV warnings
1046
+ (0, $ef07efbe5fa7d87e$export$6d9c69b0de29b591)(()=>{
1047
+ if (0, $aedbef154d609804$export$df77466336fe5355) {
1048
+ const { panelDataArray: panelDataArray } = eagerValuesRef.current;
1049
+ const { didLogIdAndOrderWarning: didLogIdAndOrderWarning, didLogPanelConstraintsWarning: didLogPanelConstraintsWarning, prevPanelIds: prevPanelIds } = devWarningsRef.current;
1050
+ if (!didLogIdAndOrderWarning) {
1051
+ const panelIds = panelDataArray.map(({ id: id })=>id);
1052
+ devWarningsRef.current.prevPanelIds = panelIds;
1053
+ const panelsHaveChanged = prevPanelIds.length > 0 && !(0, $c892f0f705e6ded5$export$b141efd0b0fb9174)(prevPanelIds, panelIds);
1054
+ if (panelsHaveChanged) {
1055
+ if (panelDataArray.find(({ idIsFromProps: idIsFromProps, order: order })=>!idIsFromProps || order == null)) {
1056
+ devWarningsRef.current.didLogIdAndOrderWarning = true;
1057
+ console.warn(`WARNING: Panel id and order props recommended when panels are dynamically rendered`);
1058
+ }
1059
+ }
1060
+ }
1061
+ if (!didLogPanelConstraintsWarning) {
1062
+ const panelConstraints = panelDataArray.map((panelData)=>panelData.constraints);
1063
+ for(let panelIndex = 0; panelIndex < panelConstraints.length; panelIndex++){
1064
+ const panelData = panelDataArray[panelIndex];
1065
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(panelData);
1066
+ const isValid = (0, $006440f9579d3b07$export$d00cfefa2c395b39)({
1067
+ panelConstraints: panelConstraints,
1068
+ panelId: panelData.id,
1069
+ panelIndex: panelIndex
1070
+ });
1071
+ if (!isValid) {
1072
+ devWarningsRef.current.didLogPanelConstraintsWarning = true;
1073
+ break;
1074
+ }
1075
+ }
1076
+ }
1707
1077
  }
1708
- callPanelCallbacks(groupId, panelDataArray, nextLayout, panelIdToLastNotifiedMixedSizesMapRef.current);
1709
- }
1710
- };
1711
- }, []);
1712
-
1713
- // External APIs are safe to memoize via committed values ref
1714
- const resizePanel = useCallback((panelData, mixedSizes) => {
1715
- const {
1716
- onLayout
1717
- } = committedValuesRef.current;
1718
- const {
1719
- layout: prevLayout,
1720
- panelDataArray
1721
- } = eagerValuesRef.current;
1722
- const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
1723
- const {
1724
- groupSizePixels,
1725
- panelSizePercentage,
1726
- pivotIndices
1727
- } = panelDataHelper(groupId, panelDataArray, panelData, prevLayout);
1728
- const sizePercentage = getPercentageSizeFromMixedSizes(mixedSizes, groupSizePixels);
1729
- const isLastPanel = panelDataArray.indexOf(panelData) === panelDataArray.length - 1;
1730
- const delta = isLastPanel ? panelSizePercentage - sizePercentage : sizePercentage - panelSizePercentage;
1731
- const nextLayout = adjustLayoutByDelta({
1732
- delta,
1733
- groupSizePixels,
1734
- layout: prevLayout,
1735
- panelConstraints: panelConstraintsArray,
1736
- pivotIndices,
1737
- trigger: "imperative-api"
1738
- });
1739
- if (!compareLayouts(prevLayout, nextLayout)) {
1740
- setLayout(nextLayout);
1741
- eagerValuesRef.current.layout = nextLayout;
1742
- if (onLayout) {
1743
- onLayout(nextLayout.map(sizePercentage => ({
1744
- sizePercentage,
1745
- sizePixels: convertPercentageToPixels(sizePercentage, groupSizePixels)
1746
- })));
1747
- }
1748
- callPanelCallbacks(groupId, panelDataArray, nextLayout, panelIdToLastNotifiedMixedSizesMapRef.current);
1749
- }
1750
- }, [groupId]);
1751
- const startDragging = useCallback((dragHandleId, event) => {
1752
- const {
1753
- direction
1754
- } = committedValuesRef.current;
1755
- const {
1756
- layout
1757
- } = eagerValuesRef.current;
1758
- const handleElement = getResizeHandleElement(dragHandleId);
1759
- const initialCursorPosition = getResizeEventCursorPosition(direction, event);
1760
- setDragState({
1761
- dragHandleId,
1762
- dragHandleRect: handleElement.getBoundingClientRect(),
1763
- initialCursorPosition,
1764
- initialLayout: layout
1765
1078
  });
1766
- }, []);
1767
- const stopDragging = useCallback(() => {
1768
- resetGlobalCursorStyle();
1769
- setDragState(null);
1770
- }, []);
1771
- const unregisterPanelRef = useRef({
1772
- pendingPanelIds: new Set(),
1773
- timeout: null
1774
- });
1775
- const unregisterPanel = useCallback(panelData => {
1776
- const {
1777
- id: groupId,
1778
- onLayout
1779
- } = committedValuesRef.current;
1780
- const {
1781
- layout: prevLayout,
1782
- panelDataArray
1783
- } = eagerValuesRef.current;
1784
- const index = panelDataArray.indexOf(panelData);
1785
- if (index >= 0) {
1786
- panelDataArray.splice(index, 1);
1787
- unregisterPanelRef.current.pendingPanelIds.add(panelData.id);
1788
- }
1789
- if (unregisterPanelRef.current.timeout != null) {
1790
- clearTimeout(unregisterPanelRef.current.timeout);
1791
- }
1792
-
1793
- // Batch panel unmounts so that we only calculate layout once;
1794
- // This is more efficient and avoids misleading warnings in development mode.
1795
- // We can't check the DOM to detect this because Panel elements have not yet been removed.
1796
- unregisterPanelRef.current.timeout = setTimeout(() => {
1797
- const {
1798
- pendingPanelIds
1799
- } = unregisterPanelRef.current;
1800
- const map = panelIdToLastNotifiedMixedSizesMapRef.current;
1801
-
1802
- // TRICKY
1803
- // Strict effects mode
1804
- let unmountDueToStrictMode = false;
1805
- pendingPanelIds.forEach(panelId => {
1806
- pendingPanelIds.delete(panelId);
1807
- if (panelDataArray.find(({
1808
- id
1809
- }) => id === panelId) == null) {
1810
- unmountDueToStrictMode = true;
1811
-
1812
- // TRICKY
1813
- // When a panel is removed from the group, we should delete the most recent prev-size entry for it.
1814
- // If we don't do this, then a conditionally rendered panel might not call onResize when it's re-mounted.
1815
- // Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
1816
- delete map[panelData.id];
1079
+ // External APIs are safe to memoize via committed values ref
1080
+ const collapsePanel = (0, $ef07efbe5fa7d87e$export$35808ee640e87ca7)((panelData)=>{
1081
+ const { onLayout: onLayout } = committedValuesRef.current;
1082
+ const { layout: prevLayout, panelDataArray: panelDataArray } = eagerValuesRef.current;
1083
+ if (panelData.constraints.collapsible) {
1084
+ const panelConstraintsArray = panelDataArray.map((panelData)=>panelData.constraints);
1085
+ const { collapsedSize: collapsedSize = 0, panelSize: panelSize, pivotIndices: pivotIndices } = $3daa5d4c086ea816$var$panelDataHelper(panelDataArray, panelData, prevLayout);
1086
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(panelSize != null);
1087
+ if (panelSize !== collapsedSize) {
1088
+ // Store size before collapse;
1089
+ // This is the size that gets restored if the expand() API is used.
1090
+ panelSizeBeforeCollapseRef.current.set(panelData.id, panelSize);
1091
+ const isLastPanel = $3daa5d4c086ea816$var$findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
1092
+ const delta = isLastPanel ? panelSize - collapsedSize : collapsedSize - panelSize;
1093
+ const nextLayout = (0, $fe96098ae4f2a44d$export$7fead5cc734d205b)({
1094
+ delta: delta,
1095
+ layout: prevLayout,
1096
+ panelConstraints: panelConstraintsArray,
1097
+ pivotIndices: pivotIndices,
1098
+ trigger: "imperative-api"
1099
+ });
1100
+ if (!(0, $81d2449822663a2a$export$a10903e2e57656c1)(prevLayout, nextLayout)) {
1101
+ setLayout(nextLayout);
1102
+ eagerValuesRef.current.layout = nextLayout;
1103
+ if (onLayout) onLayout(nextLayout);
1104
+ (0, $2743876c6469fb21$export$b8e48269e4faa934)(panelDataArray, nextLayout, panelIdToLastNotifiedSizeMapRef.current);
1105
+ }
1106
+ }
1817
1107
  }
1818
- });
1819
- if (!unmountDueToStrictMode) {
1820
- return;
1821
- }
1822
- if (panelDataArray.length === 0) {
1823
- // The group is unmounting; skip layout calculation.
1824
- return;
1825
- }
1826
- const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
1827
- let unsafeLayout = calculateUnsafeDefaultLayout({
1828
- groupSizePixels,
1829
- panelDataArray
1830
- });
1831
-
1832
- // Validate even saved layouts in case something has changed since last render
1833
- // e.g. for pixel groups, this could be the size of the window
1834
- const nextLayout = validatePanelGroupLayout({
1835
- groupSizePixels,
1836
- layout: unsafeLayout,
1837
- panelConstraints: panelDataArray.map(panelData => panelData.constraints)
1838
- });
1839
- if (!areEqual(prevLayout, nextLayout)) {
1108
+ }, []);
1109
+ // External APIs are safe to memoize via committed values ref
1110
+ const expandPanel = (0, $ef07efbe5fa7d87e$export$35808ee640e87ca7)((panelData)=>{
1111
+ const { onLayout: onLayout } = committedValuesRef.current;
1112
+ const { layout: prevLayout, panelDataArray: panelDataArray } = eagerValuesRef.current;
1113
+ if (panelData.constraints.collapsible) {
1114
+ const panelConstraintsArray = panelDataArray.map((panelData)=>panelData.constraints);
1115
+ const { collapsedSize: collapsedSize = 0, panelSize: panelSize, minSize: minSize = 0, pivotIndices: pivotIndices } = $3daa5d4c086ea816$var$panelDataHelper(panelDataArray, panelData, prevLayout);
1116
+ if (panelSize === collapsedSize) {
1117
+ // Restore this panel to the size it was before it was collapsed, if possible.
1118
+ const prevPanelSize = panelSizeBeforeCollapseRef.current.get(panelData.id);
1119
+ const baseSize = prevPanelSize != null && prevPanelSize >= minSize ? prevPanelSize : minSize;
1120
+ const isLastPanel = $3daa5d4c086ea816$var$findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
1121
+ const delta = isLastPanel ? panelSize - baseSize : baseSize - panelSize;
1122
+ const nextLayout = (0, $fe96098ae4f2a44d$export$7fead5cc734d205b)({
1123
+ delta: delta,
1124
+ layout: prevLayout,
1125
+ panelConstraints: panelConstraintsArray,
1126
+ pivotIndices: pivotIndices,
1127
+ trigger: "imperative-api"
1128
+ });
1129
+ if (!(0, $81d2449822663a2a$export$a10903e2e57656c1)(prevLayout, nextLayout)) {
1130
+ setLayout(nextLayout);
1131
+ eagerValuesRef.current.layout = nextLayout;
1132
+ if (onLayout) onLayout(nextLayout);
1133
+ (0, $2743876c6469fb21$export$b8e48269e4faa934)(panelDataArray, nextLayout, panelIdToLastNotifiedSizeMapRef.current);
1134
+ }
1135
+ }
1136
+ }
1137
+ }, []);
1138
+ // External APIs are safe to memoize via committed values ref
1139
+ const getPanelSize = (0, $ef07efbe5fa7d87e$export$35808ee640e87ca7)((panelData)=>{
1140
+ const { layout: layout, panelDataArray: panelDataArray } = eagerValuesRef.current;
1141
+ const { panelSize: panelSize } = $3daa5d4c086ea816$var$panelDataHelper(panelDataArray, panelData, layout);
1142
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(panelSize != null);
1143
+ return panelSize;
1144
+ }, []);
1145
+ // This API should never read from committedValuesRef
1146
+ const getPanelStyle = (0, $ef07efbe5fa7d87e$export$35808ee640e87ca7)((panelData)=>{
1147
+ const { panelDataArray: panelDataArray } = eagerValuesRef.current;
1148
+ const panelIndex = $3daa5d4c086ea816$var$findPanelDataIndex(panelDataArray, panelData);
1149
+ return (0, $d4957558c333bad2$export$fc25f3248e61edf5)({
1150
+ dragState: dragState,
1151
+ layout: layout,
1152
+ panelData: panelDataArray,
1153
+ panelIndex: panelIndex
1154
+ });
1155
+ }, [
1156
+ dragState,
1157
+ layout
1158
+ ]);
1159
+ // External APIs are safe to memoize via committed values ref
1160
+ const isPanelCollapsed = (0, $ef07efbe5fa7d87e$export$35808ee640e87ca7)((panelData)=>{
1161
+ const { layout: layout, panelDataArray: panelDataArray } = eagerValuesRef.current;
1162
+ const { collapsedSize: collapsedSize, collapsible: collapsible, panelSize: panelSize } = $3daa5d4c086ea816$var$panelDataHelper(panelDataArray, panelData, layout);
1163
+ return collapsible === true && panelSize === collapsedSize;
1164
+ }, []);
1165
+ // External APIs are safe to memoize via committed values ref
1166
+ const isPanelExpanded = (0, $ef07efbe5fa7d87e$export$35808ee640e87ca7)((panelData)=>{
1167
+ const { layout: layout, panelDataArray: panelDataArray } = eagerValuesRef.current;
1168
+ const { collapsedSize: collapsedSize = 0, collapsible: collapsible, panelSize: panelSize } = $3daa5d4c086ea816$var$panelDataHelper(panelDataArray, panelData, layout);
1169
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(panelSize != null);
1170
+ return !collapsible || panelSize > collapsedSize;
1171
+ }, []);
1172
+ const registerPanel = (0, $ef07efbe5fa7d87e$export$35808ee640e87ca7)((panelData)=>{
1173
+ const { autoSaveId: autoSaveId, id: groupId, onLayout: onLayout, storage: storage } = committedValuesRef.current;
1174
+ const { layout: prevLayout, panelDataArray: panelDataArray } = eagerValuesRef.current;
1175
+ // HACK
1176
+ // This appears to be triggered by some React Suspense+Offscreen+StrictMode bug;
1177
+ // see app.replay.io/recording/17b6e11d-4500-4173-b23d-61dfd141fed1
1178
+ const index = $3daa5d4c086ea816$var$findPanelDataIndex(panelDataArray, panelData);
1179
+ if (index >= 0) {
1180
+ if (panelData.idIsFromProps) console.warn(`Panel with id "${panelData.id}" registered twice`);
1181
+ else console.warn(`Panel registered twice`);
1182
+ return;
1183
+ }
1184
+ panelDataArray.push(panelData);
1185
+ panelDataArray.sort((panelA, panelB)=>{
1186
+ const orderA = panelA.order;
1187
+ const orderB = panelB.order;
1188
+ if (orderA == null && orderB == null) return 0;
1189
+ else if (orderA == null) return -1;
1190
+ else if (orderB == null) return 1;
1191
+ else return orderA - orderB;
1192
+ });
1193
+ // Wait until all panels have registered before we try to compute layout;
1194
+ // doing it earlier is both wasteful and may trigger misleading warnings in development mode.
1195
+ const panelElements = (0, $8b4e4613c531093d$export$80bbb698e7429afe)(groupId);
1196
+ if (panelElements.length !== panelDataArray.length) return;
1197
+ // If this panel has been configured to persist sizing information,
1198
+ // default size should be restored from local storage if possible.
1199
+ let unsafeLayout = null;
1200
+ if (autoSaveId) unsafeLayout = (0, $6889c3a3ed41cfd1$export$9c80c6617f0386da)(autoSaveId, panelDataArray, storage);
1201
+ if (unsafeLayout == null) unsafeLayout = (0, $457c46ca858cf2c6$export$47337a21c443778e)({
1202
+ panelDataArray: panelDataArray
1203
+ });
1204
+ // Validate even saved layouts in case something has changed since last render
1205
+ // e.g. for pixel groups, this could be the size of the window
1206
+ const nextLayout = (0, $6f1a05873bb6ec6f$export$64432a52a1035c18)({
1207
+ layout: unsafeLayout,
1208
+ panelConstraints: panelDataArray.map((panelData)=>panelData.constraints)
1209
+ });
1210
+ // Offscreen mode makes this a bit weird;
1211
+ // Panels unregister when hidden and re-register when shown again,
1212
+ // but the overall layout doesn't change between these two cases.
1840
1213
  setLayout(nextLayout);
1841
1214
  eagerValuesRef.current.layout = nextLayout;
1842
- if (onLayout) {
1843
- onLayout(nextLayout.map(sizePercentage => ({
1844
- sizePercentage,
1845
- sizePixels: convertPercentageToPixels(sizePercentage, groupSizePixels)
1846
- })));
1215
+ if (!(0, $c892f0f705e6ded5$export$b141efd0b0fb9174)(prevLayout, nextLayout)) {
1216
+ if (onLayout) onLayout(nextLayout);
1217
+ (0, $2743876c6469fb21$export$b8e48269e4faa934)(panelDataArray, nextLayout, panelIdToLastNotifiedSizeMapRef.current);
1847
1218
  }
1848
- callPanelCallbacks(groupId, panelDataArray, nextLayout, panelIdToLastNotifiedMixedSizesMapRef.current);
1849
- }
1850
- }, 0);
1851
- }, []);
1852
- const context = useMemo(() => ({
1853
- collapsePanel,
1854
- direction,
1855
- dragState,
1856
- expandPanel,
1857
- getPanelSize,
1858
- getPanelStyle,
1859
- groupId,
1860
- isPanelCollapsed,
1861
- isPanelExpanded,
1862
- registerPanel,
1863
- registerResizeHandle,
1864
- resizePanel,
1865
- startDragging,
1866
- stopDragging,
1867
- unregisterPanel
1868
- }), [collapsePanel, dragState, direction, expandPanel, getPanelSize, getPanelStyle, groupId, isPanelCollapsed, isPanelExpanded, registerPanel, registerResizeHandle, resizePanel, startDragging, stopDragging, unregisterPanel]);
1869
- const style = {
1870
- display: "flex",
1871
- flexDirection: direction === "horizontal" ? "row" : "column",
1872
- height: "100%",
1873
- overflow: "hidden",
1874
- width: "100%"
1875
- };
1876
- return createElement(PanelGroupContext.Provider, {
1877
- value: context
1878
- }, createElement(Type, {
1879
- children,
1880
- className: classNameFromProps,
1881
- style: {
1882
- ...style,
1883
- ...styleFromProps
1884
- },
1885
- ...dataAttributes,
1886
- // CSS selectors
1887
- "data-panel-group": "",
1888
- "data-panel-group-direction": direction,
1889
- "data-panel-group-id": groupId
1890
- }));
1219
+ }, []);
1220
+ const registerResizeHandle = (0, $ef07efbe5fa7d87e$export$35808ee640e87ca7)((dragHandleId)=>{
1221
+ return function resizeHandler(event) {
1222
+ event.preventDefault();
1223
+ const { direction: direction, dragState: dragState, id: groupId, keyboardResizeBy: keyboardResizeBy, onLayout: onLayout } = committedValuesRef.current;
1224
+ const { layout: prevLayout, panelDataArray: panelDataArray } = eagerValuesRef.current;
1225
+ const { initialLayout: initialLayout } = dragState !== null && dragState !== void 0 ? dragState : {};
1226
+ const pivotIndices = (0, $0a239c1e1cd1e940$export$cf92598869f99b8f)(groupId, dragHandleId);
1227
+ let delta = (0, $c845d5a27273095d$export$b08134b65f9db46a)(event, dragHandleId, direction, dragState, keyboardResizeBy);
1228
+ if (delta === 0) return;
1229
+ // Support RTL layouts
1230
+ const isHorizontal = direction === "horizontal";
1231
+ if (document.dir === "rtl" && isHorizontal) delta = -delta;
1232
+ const panelConstraints = panelDataArray.map((panelData)=>panelData.constraints);
1233
+ const nextLayout = (0, $fe96098ae4f2a44d$export$7fead5cc734d205b)({
1234
+ delta: delta,
1235
+ layout: initialLayout !== null && initialLayout !== void 0 ? initialLayout : prevLayout,
1236
+ panelConstraints: panelConstraints,
1237
+ pivotIndices: pivotIndices,
1238
+ trigger: (0, $5bf95d6f4b7f490d$export$e7bf60a870f429b0)(event) ? "keyboard" : "mouse-or-touch"
1239
+ });
1240
+ const layoutChanged = !(0, $81d2449822663a2a$export$a10903e2e57656c1)(prevLayout, nextLayout);
1241
+ // Only update the cursor for layout changes triggered by touch/mouse events (not keyboard)
1242
+ // Update the cursor even if the layout hasn't changed (we may need to show an invalid cursor state)
1243
+ if ((0, $5bf95d6f4b7f490d$export$764db16956f554f8)(event) || (0, $5bf95d6f4b7f490d$export$c4dfce035d43d1e0)(event)) // Watch for multiple subsequent deltas; this might occur for tiny cursor movements.
1244
+ // In this case, Panel sizes might not change–
1245
+ // but updating cursor in this scenario would cause a flicker.
1246
+ {
1247
+ if (prevDeltaRef.current != delta) {
1248
+ prevDeltaRef.current = delta;
1249
+ if (!layoutChanged) {
1250
+ // If the pointer has moved too far to resize the panel any further,
1251
+ // update the cursor style for a visual clue.
1252
+ // This mimics VS Code behavior.
1253
+ if (isHorizontal) (0, $8d9d88bebf1a8ace$export$d395b5dfd066a659)(delta < 0 ? "horizontal-min" : "horizontal-max");
1254
+ else (0, $8d9d88bebf1a8ace$export$d395b5dfd066a659)(delta < 0 ? "vertical-min" : "vertical-max");
1255
+ } else // Reset the cursor style to the the normal resize cursor.
1256
+ (0, $8d9d88bebf1a8ace$export$d395b5dfd066a659)(isHorizontal ? "horizontal" : "vertical");
1257
+ }
1258
+ }
1259
+ if (layoutChanged) {
1260
+ setLayout(nextLayout);
1261
+ eagerValuesRef.current.layout = nextLayout;
1262
+ if (onLayout) onLayout(nextLayout);
1263
+ (0, $2743876c6469fb21$export$b8e48269e4faa934)(panelDataArray, nextLayout, panelIdToLastNotifiedSizeMapRef.current);
1264
+ }
1265
+ };
1266
+ }, []);
1267
+ // External APIs are safe to memoize via committed values ref
1268
+ const resizePanel = (0, $ef07efbe5fa7d87e$export$35808ee640e87ca7)((panelData, unsafePanelSize)=>{
1269
+ const { onLayout: onLayout } = committedValuesRef.current;
1270
+ const { layout: prevLayout, panelDataArray: panelDataArray } = eagerValuesRef.current;
1271
+ const panelConstraintsArray = panelDataArray.map((panelData)=>panelData.constraints);
1272
+ const { panelSize: panelSize, pivotIndices: pivotIndices } = $3daa5d4c086ea816$var$panelDataHelper(panelDataArray, panelData, prevLayout);
1273
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(panelSize != null);
1274
+ const isLastPanel = $3daa5d4c086ea816$var$findPanelDataIndex(panelDataArray, panelData) === panelDataArray.length - 1;
1275
+ const delta = isLastPanel ? panelSize - unsafePanelSize : unsafePanelSize - panelSize;
1276
+ const nextLayout = (0, $fe96098ae4f2a44d$export$7fead5cc734d205b)({
1277
+ delta: delta,
1278
+ layout: prevLayout,
1279
+ panelConstraints: panelConstraintsArray,
1280
+ pivotIndices: pivotIndices,
1281
+ trigger: "imperative-api"
1282
+ });
1283
+ if (!(0, $81d2449822663a2a$export$a10903e2e57656c1)(prevLayout, nextLayout)) {
1284
+ setLayout(nextLayout);
1285
+ eagerValuesRef.current.layout = nextLayout;
1286
+ if (onLayout) onLayout(nextLayout);
1287
+ (0, $2743876c6469fb21$export$b8e48269e4faa934)(panelDataArray, nextLayout, panelIdToLastNotifiedSizeMapRef.current);
1288
+ }
1289
+ }, []);
1290
+ const startDragging = (0, $ef07efbe5fa7d87e$export$35808ee640e87ca7)((dragHandleId, event)=>{
1291
+ const { direction: direction } = committedValuesRef.current;
1292
+ const { layout: layout } = eagerValuesRef.current;
1293
+ const handleElement = (0, $99b0d18e36332b26$export$4c5229c874a62620)(dragHandleId);
1294
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(handleElement);
1295
+ const initialCursorPosition = (0, $a568cbd9a3e686f5$export$ae0c59ca751ba81d)(direction, event);
1296
+ setDragState({
1297
+ dragHandleId: dragHandleId,
1298
+ dragHandleRect: handleElement.getBoundingClientRect(),
1299
+ initialCursorPosition: initialCursorPosition,
1300
+ initialLayout: layout
1301
+ });
1302
+ }, []);
1303
+ const stopDragging = (0, $ef07efbe5fa7d87e$export$35808ee640e87ca7)(()=>{
1304
+ (0, $8d9d88bebf1a8ace$export$b61932ee18f96e08)();
1305
+ setDragState(null);
1306
+ }, []);
1307
+ const unregisterPanelRef = (0, $ef07efbe5fa7d87e$export$b8f5890fc79d6aca)({
1308
+ pendingPanelIds: new Set(),
1309
+ timeout: null
1310
+ });
1311
+ const unregisterPanel = (0, $ef07efbe5fa7d87e$export$35808ee640e87ca7)((panelData)=>{
1312
+ const { onLayout: onLayout } = committedValuesRef.current;
1313
+ const { layout: prevLayout, panelDataArray: panelDataArray } = eagerValuesRef.current;
1314
+ const index = $3daa5d4c086ea816$var$findPanelDataIndex(panelDataArray, panelData);
1315
+ if (index >= 0) {
1316
+ panelDataArray.splice(index, 1);
1317
+ unregisterPanelRef.current.pendingPanelIds.add(panelData.id);
1318
+ }
1319
+ if (unregisterPanelRef.current.timeout != null) clearTimeout(unregisterPanelRef.current.timeout);
1320
+ // Batch panel unmounts so that we only calculate layout once;
1321
+ // This is more efficient and avoids misleading warnings in development mode.
1322
+ // We can't check the DOM to detect this because Panel elements have not yet been removed.
1323
+ unregisterPanelRef.current.timeout = setTimeout(()=>{
1324
+ const { pendingPanelIds: pendingPanelIds } = unregisterPanelRef.current;
1325
+ const panelIdToLastNotifiedSizeMap = panelIdToLastNotifiedSizeMapRef.current;
1326
+ // TRICKY
1327
+ // Strict effects mode
1328
+ let unmountDueToStrictMode = false;
1329
+ pendingPanelIds.forEach((panelId)=>{
1330
+ pendingPanelIds.delete(panelId);
1331
+ if (panelDataArray.find(({ id: id })=>id === panelId) != null) unmountDueToStrictMode = true;
1332
+ else // TRICKY
1333
+ // When a panel is removed from the group, we should delete the most recent prev-size entry for it.
1334
+ // If we don't do this, then a conditionally rendered panel might not call onResize when it's re-mounted.
1335
+ // Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
1336
+ delete panelIdToLastNotifiedSizeMap[panelId];
1337
+ });
1338
+ if (unmountDueToStrictMode) return;
1339
+ if (panelDataArray.length === 0) // The group is unmounting; skip layout calculation.
1340
+ return;
1341
+ let unsafeLayout = (0, $457c46ca858cf2c6$export$47337a21c443778e)({
1342
+ panelDataArray: panelDataArray
1343
+ });
1344
+ // Validate even saved layouts in case something has changed since last render
1345
+ // e.g. for pixel groups, this could be the size of the window
1346
+ const nextLayout = (0, $6f1a05873bb6ec6f$export$64432a52a1035c18)({
1347
+ layout: unsafeLayout,
1348
+ panelConstraints: panelDataArray.map((panelData)=>panelData.constraints)
1349
+ });
1350
+ if (!(0, $c892f0f705e6ded5$export$b141efd0b0fb9174)(prevLayout, nextLayout)) {
1351
+ setLayout(nextLayout);
1352
+ eagerValuesRef.current.layout = nextLayout;
1353
+ if (onLayout) onLayout(nextLayout);
1354
+ (0, $2743876c6469fb21$export$b8e48269e4faa934)(panelDataArray, nextLayout, panelIdToLastNotifiedSizeMapRef.current);
1355
+ }
1356
+ }, 0);
1357
+ }, []);
1358
+ const context = (0, $ef07efbe5fa7d87e$export$1538c33de8887b59)(()=>({
1359
+ collapsePanel: collapsePanel,
1360
+ direction: direction,
1361
+ dragState: dragState,
1362
+ expandPanel: expandPanel,
1363
+ getPanelSize: getPanelSize,
1364
+ getPanelStyle: getPanelStyle,
1365
+ groupId: groupId,
1366
+ isPanelCollapsed: isPanelCollapsed,
1367
+ isPanelExpanded: isPanelExpanded,
1368
+ registerPanel: registerPanel,
1369
+ registerResizeHandle: registerResizeHandle,
1370
+ resizePanel: resizePanel,
1371
+ startDragging: startDragging,
1372
+ stopDragging: stopDragging,
1373
+ unregisterPanel: unregisterPanel
1374
+ }), [
1375
+ collapsePanel,
1376
+ dragState,
1377
+ direction,
1378
+ expandPanel,
1379
+ getPanelSize,
1380
+ getPanelStyle,
1381
+ groupId,
1382
+ isPanelCollapsed,
1383
+ isPanelExpanded,
1384
+ registerPanel,
1385
+ registerResizeHandle,
1386
+ resizePanel,
1387
+ startDragging,
1388
+ stopDragging,
1389
+ unregisterPanel
1390
+ ]);
1391
+ const style = {
1392
+ display: "flex",
1393
+ flexDirection: direction === "horizontal" ? "row" : "column",
1394
+ height: "100%",
1395
+ overflow: "hidden",
1396
+ width: "100%"
1397
+ };
1398
+ return (0, $ef07efbe5fa7d87e$export$c8a8987d4410bf2d)((0, $e30963544e64b604$export$7d8c6d083caec74a).Provider, {
1399
+ value: context
1400
+ }, (0, $ef07efbe5fa7d87e$export$c8a8987d4410bf2d)(Type, {
1401
+ ...rest,
1402
+ children: children,
1403
+ className: classNameFromProps,
1404
+ style: {
1405
+ ...style,
1406
+ ...styleFromProps
1407
+ },
1408
+ // CSS selectors
1409
+ "data-panel-group": "",
1410
+ "data-panel-group-direction": direction,
1411
+ "data-panel-group-id": groupId
1412
+ }));
1891
1413
  }
1892
- const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwardedRef, {
1893
- ...props,
1894
- forwardedRef: ref
1895
- }));
1896
- PanelGroupWithForwardedRef.displayName = "PanelGroup";
1897
- PanelGroup.displayName = "forwardRef(PanelGroup)";
1898
- function panelDataHelper(groupId, panelDataArray, panelData, layout) {
1899
- const panelConstraintsArray = panelDataArray.map(panelData => panelData.constraints);
1900
- const panelIndex = panelDataArray.indexOf(panelData);
1901
- const panelConstraints = panelConstraintsArray[panelIndex];
1902
- const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
1903
- const percentagePanelConstraints = computePercentagePanelConstraints(panelConstraintsArray, panelIndex, groupSizePixels);
1904
- const isLastPanel = panelIndex === panelDataArray.length - 1;
1905
- const pivotIndices = isLastPanel ? [panelIndex - 1, panelIndex] : [panelIndex, panelIndex + 1];
1906
- const panelSizePercentage = layout[panelIndex];
1907
- const panelSizePixels = convertPercentageToPixels(panelSizePercentage, groupSizePixels);
1908
- return {
1909
- ...percentagePanelConstraints,
1910
- collapsible: panelConstraints.collapsible,
1911
- panelSizePercentage,
1912
- panelSizePixels,
1913
- groupSizePixels,
1914
- pivotIndices
1915
- };
1414
+ const $3daa5d4c086ea816$export$1d05749f6f573bb = (0, $ef07efbe5fa7d87e$export$257a8862b851cb5b)((props, ref)=>(0, $ef07efbe5fa7d87e$export$c8a8987d4410bf2d)($3daa5d4c086ea816$var$PanelGroupWithForwardedRef, {
1415
+ ...props,
1416
+ forwardedRef: ref
1417
+ }));
1418
+ $3daa5d4c086ea816$var$PanelGroupWithForwardedRef.displayName = "PanelGroup";
1419
+ $3daa5d4c086ea816$export$1d05749f6f573bb.displayName = "forwardRef(PanelGroup)";
1420
+ function $3daa5d4c086ea816$var$findPanelDataIndex(panelDataArray, panelData) {
1421
+ return panelDataArray.findIndex((prevPanelData)=>prevPanelData === panelData || prevPanelData.id === panelData.id);
1422
+ }
1423
+ function $3daa5d4c086ea816$var$panelDataHelper(panelDataArray, panelData, layout) {
1424
+ const panelConstraintsArray = panelDataArray.map((panelData)=>panelData.constraints);
1425
+ const panelIndex = $3daa5d4c086ea816$var$findPanelDataIndex(panelDataArray, panelData);
1426
+ const panelConstraints = panelConstraintsArray[panelIndex];
1427
+ const isLastPanel = panelIndex === panelDataArray.length - 1;
1428
+ const pivotIndices = isLastPanel ? [
1429
+ panelIndex - 1,
1430
+ panelIndex
1431
+ ] : [
1432
+ panelIndex,
1433
+ panelIndex + 1
1434
+ ];
1435
+ const panelSize = layout[panelIndex];
1436
+ return {
1437
+ ...panelConstraints,
1438
+ panelSize: panelSize,
1439
+ pivotIndices: pivotIndices
1440
+ };
1916
1441
  }
1917
1442
 
1918
- // https://www.w3.org/WAI/ARIA/apg/patterns/windowsplitter/
1919
1443
 
1920
- function useWindowSplitterResizeHandlerBehavior({
1921
- disabled,
1922
- handleId,
1923
- resizeHandler
1924
- }) {
1925
- useEffect(() => {
1926
- if (disabled || resizeHandler == null) {
1927
- return;
1928
- }
1929
- const handleElement = getResizeHandleElement(handleId);
1930
- if (handleElement == null) {
1931
- return;
1932
- }
1933
- const onKeyDown = event => {
1934
- if (event.defaultPrevented) {
1935
- return;
1936
- }
1937
- switch (event.key) {
1938
- case "ArrowDown":
1939
- case "ArrowLeft":
1940
- case "ArrowRight":
1941
- case "ArrowUp":
1942
- case "End":
1943
- case "Home":
1944
- {
1945
- event.preventDefault();
1946
- resizeHandler(event);
1947
- break;
1948
- }
1949
- case "F6":
1950
- {
1951
- event.preventDefault();
1952
- const groupId = handleElement.getAttribute("data-panel-group-id");
1953
- const handles = getResizeHandleElementsForGroup(groupId);
1954
- const index = getResizeHandleElementIndex(groupId, handleId);
1955
- assert(index !== null);
1956
- const nextIndex = event.shiftKey ? index > 0 ? index - 1 : handles.length - 1 : index + 1 < handles.length ? index + 1 : 0;
1957
- const nextHandle = handles[nextIndex];
1958
- nextHandle.focus();
1959
- break;
1960
- }
1961
- }
1962
- };
1963
- handleElement.addEventListener("keydown", onKeyDown);
1964
- return () => {
1965
- handleElement.removeEventListener("keydown", onKeyDown);
1966
- };
1967
- }, [disabled, handleId, resizeHandler]);
1444
+
1445
+
1446
+
1447
+
1448
+
1449
+
1450
+
1451
+ function $4a90471e7083b52f$export$33b0bea6ac3ffb03({ disabled: disabled, handleId: handleId, resizeHandler: resizeHandler }) {
1452
+ (0, $ef07efbe5fa7d87e$export$6d9c69b0de29b591)(()=>{
1453
+ if (disabled || resizeHandler == null) return;
1454
+ const handleElement = (0, $99b0d18e36332b26$export$4c5229c874a62620)(handleId);
1455
+ if (handleElement == null) return;
1456
+ const onKeyDown = (event)=>{
1457
+ if (event.defaultPrevented) return;
1458
+ switch(event.key){
1459
+ case "ArrowDown":
1460
+ case "ArrowLeft":
1461
+ case "ArrowRight":
1462
+ case "ArrowUp":
1463
+ case "End":
1464
+ case "Home":
1465
+ event.preventDefault();
1466
+ resizeHandler(event);
1467
+ break;
1468
+ case "F6":
1469
+ {
1470
+ event.preventDefault();
1471
+ const groupId = handleElement.getAttribute("data-panel-group-id");
1472
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(groupId);
1473
+ const handles = (0, $9196ba7c0d09e3f3$export$63eb605e437b214f)(groupId);
1474
+ const index = (0, $a144d12e0d2017d1$export$4c92fedbbc2381ca)(groupId, handleId);
1475
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(index !== null);
1476
+ const nextIndex = event.shiftKey ? index > 0 ? index - 1 : handles.length - 1 : index + 1 < handles.length ? index + 1 : 0;
1477
+ const nextHandle = handles[nextIndex];
1478
+ nextHandle.focus();
1479
+ break;
1480
+ }
1481
+ }
1482
+ };
1483
+ handleElement.addEventListener("keydown", onKeyDown);
1484
+ return ()=>{
1485
+ handleElement.removeEventListener("keydown", onKeyDown);
1486
+ };
1487
+ }, [
1488
+ disabled,
1489
+ handleId,
1490
+ resizeHandler
1491
+ ]);
1968
1492
  }
1969
1493
 
1970
- function PanelResizeHandle({
1971
- children = null,
1972
- className: classNameFromProps = "",
1973
- dataAttributes,
1974
- disabled = false,
1975
- id: idFromProps = null,
1976
- onDragging,
1977
- style: styleFromProps = {},
1978
- tagName: Type = "div"
1979
- }) {
1980
- const divElementRef = useRef(null);
1981
-
1982
- // Use a ref to guard against users passing inline props
1983
- const callbacksRef = useRef({
1984
- onDragging
1985
- });
1986
- useEffect(() => {
1987
- callbacksRef.current.onDragging = onDragging;
1988
- });
1989
- const panelGroupContext = useContext(PanelGroupContext);
1990
- if (panelGroupContext === null) {
1991
- throw Error(`PanelResizeHandle components must be rendered within a PanelGroup container`);
1992
- }
1993
- const {
1994
- direction,
1995
- dragState,
1996
- groupId,
1997
- registerResizeHandle,
1998
- startDragging,
1999
- stopDragging
2000
- } = panelGroupContext;
2001
- const resizeHandleId = useUniqueId(idFromProps);
2002
- const isDragging = (dragState === null || dragState === void 0 ? void 0 : dragState.dragHandleId) === resizeHandleId;
2003
- const [isFocused, setIsFocused] = useState(false);
2004
- const [resizeHandler, setResizeHandler] = useState(null);
2005
- const stopDraggingAndBlur = useCallback(() => {
2006
- // Clicking on the drag handle shouldn't leave it focused;
2007
- // That would cause the PanelGroup to think it was still active.
2008
- const div = divElementRef.current;
2009
- div.blur();
2010
- stopDragging();
2011
- const {
2012
- onDragging
2013
- } = callbacksRef.current;
2014
- if (onDragging) {
2015
- onDragging(false);
2016
- }
2017
- }, [stopDragging]);
2018
- useEffect(() => {
2019
- if (disabled) {
2020
- setResizeHandler(null);
2021
- } else {
2022
- const resizeHandler = registerResizeHandle(resizeHandleId);
2023
- setResizeHandler(() => resizeHandler);
2024
- }
2025
- }, [disabled, resizeHandleId, registerResizeHandle]);
2026
- useEffect(() => {
2027
- if (disabled || resizeHandler == null || !isDragging) {
2028
- return;
2029
- }
2030
- const onMove = event => {
2031
- resizeHandler(event);
2032
- };
2033
- const onMouseLeave = event => {
2034
- resizeHandler(event);
2035
- };
2036
- const divElement = divElementRef.current;
2037
- const targetDocument = divElement.ownerDocument;
2038
- targetDocument.body.addEventListener("contextmenu", stopDraggingAndBlur);
2039
- targetDocument.body.addEventListener("mousemove", onMove);
2040
- targetDocument.body.addEventListener("touchmove", onMove);
2041
- targetDocument.body.addEventListener("mouseleave", onMouseLeave);
2042
- window.addEventListener("mouseup", stopDraggingAndBlur);
2043
- window.addEventListener("touchend", stopDraggingAndBlur);
2044
- return () => {
2045
- targetDocument.body.removeEventListener("contextmenu", stopDraggingAndBlur);
2046
- targetDocument.body.removeEventListener("mousemove", onMove);
2047
- targetDocument.body.removeEventListener("touchmove", onMove);
2048
- targetDocument.body.removeEventListener("mouseleave", onMouseLeave);
2049
- window.removeEventListener("mouseup", stopDraggingAndBlur);
2050
- window.removeEventListener("touchend", stopDraggingAndBlur);
1494
+
1495
+
1496
+
1497
+
1498
+ function $971f2c37f9d2b98e$export$8829ecf6b6b15484({ children: children = null, className: classNameFromProps = "", disabled: disabled = false, id: idFromProps, onDragging: onDragging, style: styleFromProps = {}, tabIndex: tabIndex = 0, tagName: Type = "div", ...rest }) {
1499
+ const divElementRef = (0, $ef07efbe5fa7d87e$export$b8f5890fc79d6aca)(null);
1500
+ // Use a ref to guard against users passing inline props
1501
+ const callbacksRef = (0, $ef07efbe5fa7d87e$export$b8f5890fc79d6aca)({
1502
+ onDragging: onDragging
1503
+ });
1504
+ (0, $ef07efbe5fa7d87e$export$6d9c69b0de29b591)(()=>{
1505
+ callbacksRef.current.onDragging = onDragging;
1506
+ });
1507
+ const panelGroupContext = (0, $ef07efbe5fa7d87e$export$fae74005e78b1a27)((0, $e30963544e64b604$export$7d8c6d083caec74a));
1508
+ if (panelGroupContext === null) throw Error(`PanelResizeHandle components must be rendered within a PanelGroup container`);
1509
+ const { direction: direction, dragState: dragState, groupId: groupId, registerResizeHandle: registerResizeHandle, startDragging: startDragging, stopDragging: stopDragging } = panelGroupContext;
1510
+ const resizeHandleId = (0, $e504a2438473eda9$export$2e2bcd8739ae039)(idFromProps);
1511
+ const isDragging = (dragState === null || dragState === void 0 ? void 0 : dragState.dragHandleId) === resizeHandleId;
1512
+ const [isFocused, setIsFocused] = (0, $ef07efbe5fa7d87e$export$60241385465d0a34)(false);
1513
+ const [resizeHandler, setResizeHandler] = (0, $ef07efbe5fa7d87e$export$60241385465d0a34)(null);
1514
+ const stopDraggingAndBlur = (0, $ef07efbe5fa7d87e$export$35808ee640e87ca7)(()=>{
1515
+ // Clicking on the drag handle shouldn't leave it focused;
1516
+ // That would cause the PanelGroup to think it was still active.
1517
+ const divElement = divElementRef.current;
1518
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(divElement);
1519
+ divElement.blur();
1520
+ stopDragging();
1521
+ const { onDragging: onDragging } = callbacksRef.current;
1522
+ if (onDragging) onDragging(false);
1523
+ }, [
1524
+ stopDragging
1525
+ ]);
1526
+ (0, $ef07efbe5fa7d87e$export$6d9c69b0de29b591)(()=>{
1527
+ if (disabled) setResizeHandler(null);
1528
+ else {
1529
+ const resizeHandler = registerResizeHandle(resizeHandleId);
1530
+ setResizeHandler(()=>resizeHandler);
1531
+ }
1532
+ }, [
1533
+ disabled,
1534
+ resizeHandleId,
1535
+ registerResizeHandle
1536
+ ]);
1537
+ (0, $ef07efbe5fa7d87e$export$6d9c69b0de29b591)(()=>{
1538
+ if (disabled || resizeHandler == null || !isDragging) return;
1539
+ const onMove = (event)=>{
1540
+ resizeHandler(event);
1541
+ };
1542
+ const onMouseLeave = (event)=>{
1543
+ resizeHandler(event);
1544
+ };
1545
+ const divElement = divElementRef.current;
1546
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(divElement);
1547
+ const targetDocument = divElement.ownerDocument;
1548
+ targetDocument.body.addEventListener("contextmenu", stopDraggingAndBlur);
1549
+ targetDocument.body.addEventListener("mousemove", onMove);
1550
+ targetDocument.body.addEventListener("touchmove", onMove);
1551
+ targetDocument.body.addEventListener("mouseleave", onMouseLeave);
1552
+ window.addEventListener("mouseup", stopDraggingAndBlur);
1553
+ window.addEventListener("touchend", stopDraggingAndBlur);
1554
+ return ()=>{
1555
+ targetDocument.body.removeEventListener("contextmenu", stopDraggingAndBlur);
1556
+ targetDocument.body.removeEventListener("mousemove", onMove);
1557
+ targetDocument.body.removeEventListener("touchmove", onMove);
1558
+ targetDocument.body.removeEventListener("mouseleave", onMouseLeave);
1559
+ window.removeEventListener("mouseup", stopDraggingAndBlur);
1560
+ window.removeEventListener("touchend", stopDraggingAndBlur);
1561
+ };
1562
+ }, [
1563
+ direction,
1564
+ disabled,
1565
+ isDragging,
1566
+ resizeHandler,
1567
+ stopDraggingAndBlur
1568
+ ]);
1569
+ (0, $4a90471e7083b52f$export$33b0bea6ac3ffb03)({
1570
+ disabled: disabled,
1571
+ handleId: resizeHandleId,
1572
+ resizeHandler: resizeHandler
1573
+ });
1574
+ const style = {
1575
+ cursor: (0, $8d9d88bebf1a8ace$export$fa35f3322c52262f)(direction),
1576
+ touchAction: "none",
1577
+ userSelect: "none"
2051
1578
  };
2052
- }, [direction, disabled, isDragging, resizeHandler, stopDraggingAndBlur]);
2053
- useWindowSplitterResizeHandlerBehavior({
2054
- disabled,
2055
- handleId: resizeHandleId,
2056
- resizeHandler
2057
- });
2058
- const style = {
2059
- cursor: getCursorStyle(direction),
2060
- touchAction: "none",
2061
- userSelect: "none"
2062
- };
2063
- return createElement(Type, {
2064
- children,
2065
- className: classNameFromProps,
2066
- onBlur: () => setIsFocused(false),
2067
- onFocus: () => setIsFocused(true),
2068
- onMouseDown: event => {
2069
- startDragging(resizeHandleId, event.nativeEvent);
2070
- const {
2071
- onDragging
2072
- } = callbacksRef.current;
2073
- if (onDragging) {
2074
- onDragging(true);
2075
- }
2076
- },
2077
- onMouseUp: stopDraggingAndBlur,
2078
- onTouchCancel: stopDraggingAndBlur,
2079
- onTouchEnd: stopDraggingAndBlur,
2080
- onTouchStart: event => {
2081
- startDragging(resizeHandleId, event.nativeEvent);
2082
- const {
2083
- onDragging
2084
- } = callbacksRef.current;
2085
- if (onDragging) {
2086
- onDragging(true);
2087
- }
2088
- },
2089
- ref: divElementRef,
2090
- role: "separator",
2091
- style: {
2092
- ...style,
2093
- ...styleFromProps
2094
- },
2095
- tabIndex: 0,
2096
- ...dataAttributes,
2097
- // CSS selectors
2098
- "data-panel-group-direction": direction,
2099
- "data-panel-group-id": groupId,
2100
- "data-resize-handle": "",
2101
- "data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
2102
- "data-panel-resize-handle-enabled": !disabled,
2103
- "data-panel-resize-handle-id": resizeHandleId
2104
- });
1579
+ return (0, $ef07efbe5fa7d87e$export$c8a8987d4410bf2d)(Type, {
1580
+ ...rest,
1581
+ children: children,
1582
+ className: classNameFromProps,
1583
+ onBlur: ()=>setIsFocused(false),
1584
+ onFocus: ()=>setIsFocused(true),
1585
+ onMouseDown: (event)=>{
1586
+ startDragging(resizeHandleId, event.nativeEvent);
1587
+ const callbacks = callbacksRef.current;
1588
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(callbacks);
1589
+ const { onDragging: onDragging } = callbacks;
1590
+ if (onDragging) onDragging(true);
1591
+ },
1592
+ onMouseUp: stopDraggingAndBlur,
1593
+ onTouchCancel: stopDraggingAndBlur,
1594
+ onTouchEnd: stopDraggingAndBlur,
1595
+ onTouchStart: (event)=>{
1596
+ startDragging(resizeHandleId, event.nativeEvent);
1597
+ const callbacks = callbacksRef.current;
1598
+ (0, $5f33910cd46e8ae7$export$a7a9523472993e97)(callbacks);
1599
+ const { onDragging: onDragging } = callbacks;
1600
+ if (onDragging) onDragging(true);
1601
+ },
1602
+ ref: divElementRef,
1603
+ role: "separator",
1604
+ style: {
1605
+ ...style,
1606
+ ...styleFromProps
1607
+ },
1608
+ tabIndex: tabIndex,
1609
+ // CSS selectors
1610
+ "data-panel-group-direction": direction,
1611
+ "data-panel-group-id": groupId,
1612
+ "data-resize-handle": "",
1613
+ "data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
1614
+ "data-panel-resize-handle-enabled": !disabled,
1615
+ "data-panel-resize-handle-id": resizeHandleId
1616
+ });
2105
1617
  }
2106
- PanelResizeHandle.displayName = "PanelResizeHandle";
1618
+ $971f2c37f9d2b98e$export$8829ecf6b6b15484.displayName = "PanelResizeHandle";
1619
+
1620
+
1621
+
1622
+
2107
1623
 
2108
- export { Panel, PanelGroup, PanelResizeHandle };
1624
+ export {$5f33910cd46e8ae7$export$a7a9523472993e97 as assert, $c33df6d7c39fd3ee$export$2ddb90ad54e5f587 as Panel, $3daa5d4c086ea816$export$1d05749f6f573bb as PanelGroup, $971f2c37f9d2b98e$export$8829ecf6b6b15484 as PanelResizeHandle};
1625
+ //# sourceMappingURL=react-resizable-panels.esm.js.map