@window-splitter/react 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/.storybook/main.ts +17 -0
  2. package/.storybook/preview.ts +14 -0
  3. package/.tshy/build.json +8 -0
  4. package/.tshy/commonjs.json +19 -0
  5. package/.tshy/esm.json +18 -0
  6. package/.turbo/turbo-build.log +5 -0
  7. package/.turbo/turbo-lint.log +5 -0
  8. package/CHANGELOG.md +606 -0
  9. package/README.md +53 -0
  10. package/dist/commonjs/ReactWindowSplitter.d.ts +19 -0
  11. package/dist/commonjs/ReactWindowSplitter.d.ts.map +1 -0
  12. package/dist/commonjs/ReactWindowSplitter.js +558 -0
  13. package/dist/commonjs/ReactWindowSplitter.js.map +1 -0
  14. package/dist/commonjs/ReactWindowSplitter.stories.d.ts +47 -0
  15. package/dist/commonjs/ReactWindowSplitter.stories.d.ts.map +1 -0
  16. package/dist/commonjs/ReactWindowSplitter.stories.js +330 -0
  17. package/dist/commonjs/ReactWindowSplitter.stories.js.map +1 -0
  18. package/dist/commonjs/ReactWindowSplitter.test.d.ts +2 -0
  19. package/dist/commonjs/ReactWindowSplitter.test.d.ts.map +1 -0
  20. package/dist/commonjs/ReactWindowSplitter.test.js +219 -0
  21. package/dist/commonjs/ReactWindowSplitter.test.js.map +1 -0
  22. package/dist/commonjs/bundle.size.d.ts +2 -0
  23. package/dist/commonjs/bundle.size.d.ts.map +1 -0
  24. package/dist/commonjs/bundle.size.js +29 -0
  25. package/dist/commonjs/bundle.size.js.map +1 -0
  26. package/dist/commonjs/index.d.ts +3 -0
  27. package/dist/commonjs/index.d.ts.map +1 -0
  28. package/dist/commonjs/index.js +18 -0
  29. package/dist/commonjs/index.js.map +1 -0
  30. package/dist/commonjs/package.json +3 -0
  31. package/dist/commonjs/useIndexedChildren.d.ts +8 -0
  32. package/dist/commonjs/useIndexedChildren.d.ts.map +1 -0
  33. package/dist/commonjs/useIndexedChildren.js +81 -0
  34. package/dist/commonjs/useIndexedChildren.js.map +1 -0
  35. package/dist/commonjs/useMove.d.ts +8 -0
  36. package/dist/commonjs/useMove.d.ts.map +1 -0
  37. package/dist/commonjs/useMove.js +19 -0
  38. package/dist/commonjs/useMove.js.map +1 -0
  39. package/dist/esm/ReactWindowSplitter.d.ts +19 -0
  40. package/dist/esm/ReactWindowSplitter.d.ts.map +1 -0
  41. package/dist/esm/ReactWindowSplitter.js +532 -0
  42. package/dist/esm/ReactWindowSplitter.js.map +1 -0
  43. package/dist/esm/ReactWindowSplitter.stories.d.ts +47 -0
  44. package/dist/esm/ReactWindowSplitter.stories.d.ts.map +1 -0
  45. package/dist/esm/ReactWindowSplitter.stories.js +286 -0
  46. package/dist/esm/ReactWindowSplitter.stories.js.map +1 -0
  47. package/dist/esm/ReactWindowSplitter.test.d.ts +2 -0
  48. package/dist/esm/ReactWindowSplitter.test.d.ts.map +1 -0
  49. package/dist/esm/ReactWindowSplitter.test.js +191 -0
  50. package/dist/esm/ReactWindowSplitter.test.js.map +1 -0
  51. package/dist/esm/bundle.size.d.ts +2 -0
  52. package/dist/esm/bundle.size.d.ts.map +1 -0
  53. package/dist/esm/bundle.size.js +4 -0
  54. package/dist/esm/bundle.size.js.map +1 -0
  55. package/dist/esm/index.d.ts +3 -0
  56. package/dist/esm/index.d.ts.map +1 -0
  57. package/dist/esm/index.js +2 -0
  58. package/dist/esm/index.js.map +1 -0
  59. package/dist/esm/package.json +3 -0
  60. package/dist/esm/useIndexedChildren.d.ts +8 -0
  61. package/dist/esm/useIndexedChildren.d.ts.map +1 -0
  62. package/dist/esm/useIndexedChildren.js +54 -0
  63. package/dist/esm/useIndexedChildren.js.map +1 -0
  64. package/dist/esm/useMove.d.ts +8 -0
  65. package/dist/esm/useMove.d.ts.map +1 -0
  66. package/dist/esm/useMove.js +16 -0
  67. package/dist/esm/useMove.js.map +1 -0
  68. package/eslint.config.js +3 -0
  69. package/package.json +108 -0
  70. package/rsbuild.config.js +25 -0
  71. package/src/ReactWindowSplitter.stories.tsx +705 -0
  72. package/src/ReactWindowSplitter.test.tsx +384 -0
  73. package/src/ReactWindowSplitter.tsx +884 -0
  74. package/src/__snapshots__/ReactWindowSplitter.test.tsx.snap +58 -0
  75. package/src/bundle.size.ts +4 -0
  76. package/src/index.ts +2 -0
  77. package/src/useIndexedChildren.tsx +79 -0
  78. package/src/useMove.ts +22 -0
  79. package/tsconfig.json +6 -0
  80. package/vitest.config.ts +20 -0
  81. package/vitest.setup.ts +7 -0
@@ -0,0 +1,558 @@
1
+ "use client";
2
+ "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || function (mod) {
20
+ if (mod && mod.__esModule) return mod;
21
+ var result = {};
22
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
+ __setModuleDefault(result, mod);
24
+ return result;
25
+ };
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.PanelResizer = exports.Panel = exports.PanelGroup = void 0;
28
+ const interface_1 = require("@window-splitter/interface");
29
+ const react_1 = __importStar(require("react"));
30
+ const state_1 = require("@window-splitter/state");
31
+ const utils_1 = require("@react-aria/utils");
32
+ const useIndexedChildren_js_1 = require("./useIndexedChildren.js");
33
+ const useMove_js_1 = require("./useMove.js");
34
+ // #region Components
35
+ const GroupMachineState = (0, react_1.createContext)({
36
+ current: undefined,
37
+ });
38
+ const GroupMachineContext = (0, react_1.createContext)(undefined);
39
+ const GroupMachineStateContextRef = (0, react_1.createContext)({
40
+ current: undefined,
41
+ });
42
+ const GroupMachineActor = (0, react_1.createContext)(() => { });
43
+ const GroupMachine = {
44
+ useSelector(selector) {
45
+ const context = (0, react_1.useContext)(GroupMachineContext);
46
+ if (!context) {
47
+ throw new Error("GroupMachineContext must be used within a GroupMachineProvider");
48
+ }
49
+ return selector({ context });
50
+ },
51
+ useActorRef: () => {
52
+ const send = (0, react_1.useContext)(GroupMachineActor);
53
+ return { send };
54
+ },
55
+ useContextRef: () => {
56
+ const ref = (0, react_1.useContext)(GroupMachineStateContextRef);
57
+ if (!ref) {
58
+ throw new Error("GroupMachineContext must be used within a GroupMachineProvider");
59
+ }
60
+ return ref;
61
+ },
62
+ Provider: ({ input, children, }) => {
63
+ const [intiialValue, send, state] = (0, react_1.useMemo)(() => (0, state_1.groupMachine)(input, (value) => {
64
+ currentContextRef.current = value;
65
+ setCurrentValue({ ...value });
66
+ }),
67
+ // We only want this to run once, we dont care about changes to the input
68
+ // eslint-disable-next-line react-hooks/exhaustive-deps
69
+ []);
70
+ const currentContextRef = (0, react_1.useRef)(intiialValue);
71
+ const [currentValue, setCurrentValue] = (0, react_1.useState)(intiialValue);
72
+ (0, react_1.useEffect)(() => {
73
+ send({ type: "unlockGroup" });
74
+ return () => {
75
+ // When we were on xstate we could fire off event during unmount and if the parent group
76
+ // unmounted too the events would never apply. With out own state machine code it doesn't
77
+ // do that so we have to lock the group as it unmounts so it's children don't de-register.
78
+ send({ type: "lockGroup" });
79
+ };
80
+ }, [send]);
81
+ return (react_1.default.createElement(GroupMachineState.Provider, { value: state },
82
+ react_1.default.createElement(GroupMachineStateContextRef.Provider, { value: currentContextRef },
83
+ react_1.default.createElement(GroupMachineContext.Provider, { value: currentValue },
84
+ react_1.default.createElement(GroupMachineActor.Provider, { value: send }, children)))));
85
+ },
86
+ };
87
+ const InitialMapContext = (0, react_1.createContext)([]);
88
+ const PreRenderContext = (0, react_1.createContext)(false);
89
+ function PrerenderTree({ children, onPrerender, }) {
90
+ const [shouldPrerender, setShouldPrerender] = react_1.default.useState(true);
91
+ (0, utils_1.useLayoutEffect)(() => {
92
+ setShouldPrerender(false);
93
+ onPrerender();
94
+ // We only want this to run once
95
+ // eslint-disable-next-line react-hooks/exhaustive-deps
96
+ }, []);
97
+ return shouldPrerender ? (react_1.default.createElement("div", { className: "opacity-0 absolute" },
98
+ react_1.default.createElement(PreRenderContext.Provider, { value: true }, children))) : null;
99
+ }
100
+ function useGroupItem(itemArg) {
101
+ const isPrerender = react_1.default.useContext(PreRenderContext);
102
+ const initialMap = react_1.default.useContext(InitialMapContext);
103
+ const generatedId = (0, utils_1.useId)();
104
+ const id = itemArg.id || generatedId;
105
+ const { index } = (0, useIndexedChildren_js_1.useIndex)();
106
+ const item = { ...itemArg, id };
107
+ if (isPrerender) {
108
+ if (!initialMap.find((i) => i.id === item.id)) {
109
+ initialMap.push(item);
110
+ }
111
+ return item;
112
+ }
113
+ // The way this hooks is called is never conditional so the usage here is fine
114
+ /* eslint-disable react-hooks/rules-of-hooks */
115
+ const currentItem = GroupMachine.useSelector(({ context }) => context.items[index]);
116
+ const { send } = GroupMachine.useActorRef();
117
+ const machineRef = GroupMachine.useContextRef();
118
+ const onCollapseChangeRef = (0, state_1.isPanelData)(itemArg)
119
+ ? itemArg.onCollapseChange
120
+ : undefined;
121
+ const onResizeRef = (0, state_1.isPanelData)(itemArg) ? itemArg.onResize : undefined;
122
+ const onUnmountRef = (0, react_1.useRef)(undefined);
123
+ // We register panels before layout so it looks good
124
+ (0, utils_1.useLayoutEffect)(() => {
125
+ const context = machineRef.current;
126
+ if (!context) {
127
+ return;
128
+ }
129
+ let contextItem;
130
+ if (itemArg.id) {
131
+ contextItem = context.items.find((i) => i.id === itemArg.id);
132
+ if (!contextItem) {
133
+ if (!itemArg.id) {
134
+ throw new Error("When using dynamic panels you must provide an id on the items. This applies to React strict mode as well.");
135
+ }
136
+ if ((0, state_1.isPanelData)(itemArg)) {
137
+ send({
138
+ type: "registerDynamicPanel",
139
+ data: { ...itemArg, order: index },
140
+ });
141
+ }
142
+ else {
143
+ send({
144
+ type: "registerPanelHandle",
145
+ data: (0, state_1.initializePanelHandleData)({
146
+ ...itemArg,
147
+ order: index,
148
+ }),
149
+ });
150
+ }
151
+ }
152
+ else if (onCollapseChangeRef || onResizeRef) {
153
+ send({
154
+ type: "rebindPanelCallbacks",
155
+ data: {
156
+ id: itemArg.id,
157
+ onCollapseChange: onCollapseChangeRef,
158
+ onResize: onResizeRef,
159
+ },
160
+ });
161
+ }
162
+ }
163
+ else {
164
+ contextItem = context.items[index];
165
+ }
166
+ const unmountId = contextItem?.id || itemArg.id;
167
+ onUnmountRef.current = () => {
168
+ if (!unmountId)
169
+ return;
170
+ const el = document.querySelector(`[data-splitter-id="${unmountId}"]`);
171
+ if (el || !unmountId) {
172
+ return;
173
+ }
174
+ if ((0, state_1.isPanelData)(itemArg)) {
175
+ send({ type: "unregisterPanel", id: unmountId });
176
+ }
177
+ else {
178
+ send({ type: "unregisterPanelHandle", id: unmountId });
179
+ }
180
+ };
181
+ }, [index, itemArg, machineRef, send, onCollapseChangeRef, onResizeRef]);
182
+ // And unregister after layout so we can tell if the element was actually removed.
183
+ react_1.default.useEffect(() => {
184
+ return () => {
185
+ onUnmountRef.current?.();
186
+ onUnmountRef.current = undefined;
187
+ };
188
+ }, []);
189
+ return currentItem || item;
190
+ /* eslint-enable react-hooks/rules-of-hooks */
191
+ }
192
+ /** A group of panels that has constraints and a user can resize */
193
+ exports.PanelGroup = react_1.default.forwardRef(function PanelGroup({ children, ...props }, ref) {
194
+ const [hasPreRendered, setHasPreRendered] = (0, react_1.useState)(false);
195
+ const initialMap = (0, react_1.useRef)([]);
196
+ const indexedChildren = (0, useIndexedChildren_js_1.useIndexedChildren)(children);
197
+ return (react_1.default.createElement(InitialMapContext.Provider, { value: initialMap.current },
198
+ !hasPreRendered && (react_1.default.createElement(PrerenderTree, { onPrerender: () => setHasPreRendered(true) }, indexedChildren)),
199
+ react_1.default.createElement(PanelGroupImpl, { ref: ref, initialItems: initialMap, ...props }, indexedChildren)));
200
+ });
201
+ const PanelGroupImpl = react_1.default.forwardRef(function PanelGroupImpl({ autosaveId, autosaveStrategy = "localStorage", snapshot: snapshotProp, initialItems, ...props }, ref) {
202
+ const defaultGroupId = `panel-group-${(0, utils_1.useId)()}`;
203
+ const groupId = autosaveId || props.id || defaultGroupId;
204
+ const [snapshot, setSnapshot] = react_1.default.useState(snapshotProp);
205
+ if (typeof window !== "undefined" &&
206
+ autosaveId &&
207
+ !snapshot &&
208
+ autosaveStrategy === "localStorage") {
209
+ const localSnapshot = localStorage.getItem(autosaveId);
210
+ if (localSnapshot) {
211
+ setSnapshot(JSON.parse(localSnapshot));
212
+ }
213
+ else {
214
+ setSnapshot(true);
215
+ }
216
+ }
217
+ const snapshotMemo = (0, react_1.useMemo)(() => {
218
+ return typeof snapshot === "object" ? (0, state_1.prepareSnapshot)(snapshot) : undefined;
219
+ }, [snapshot]);
220
+ return (react_1.default.createElement(GroupMachine.Provider, { input: {
221
+ orientation: props.orientation,
222
+ groupId,
223
+ items: initialItems.current,
224
+ autosaveStrategy,
225
+ ...(typeof snapshotMemo === "object" ? snapshotMemo : undefined),
226
+ } },
227
+ react_1.default.createElement(PanelGroupImplementation, { ref: ref, ...props })));
228
+ });
229
+ const PanelGroupImplementation = react_1.default.forwardRef(function PanelGroupImplementation({ handle, orientation: orientationProp, ...props }, outerRef) {
230
+ const { send } = GroupMachine.useActorRef();
231
+ const machineRef = GroupMachine.useContextRef();
232
+ const innerRef = react_1.default.useRef(null);
233
+ const ref = (0, utils_1.mergeRefs)(outerRef, innerRef);
234
+ const orientation = GroupMachine.useSelector((state) => state.context.orientation);
235
+ const groupId = GroupMachine.useSelector((state) => state.context.groupId);
236
+ const template = GroupMachine.useSelector((state) => (0, state_1.buildTemplate)(state.context));
237
+ // When the prop for `orientation` updates also update the state machine
238
+ if (orientationProp && orientationProp !== orientation) {
239
+ send({ type: "setOrientation", orientation: orientationProp });
240
+ }
241
+ // Track the size of the group
242
+ (0, utils_1.useLayoutEffect)(() => {
243
+ const { current: el } = innerRef;
244
+ if (!el) {
245
+ return;
246
+ }
247
+ const observer = new ResizeObserver((entries) => {
248
+ const entry = entries[0];
249
+ if (!entry) {
250
+ return;
251
+ }
252
+ send({ type: "setSize", size: entry.contentRect });
253
+ });
254
+ observer.observe(el);
255
+ send({ type: "setSize", size: el.getBoundingClientRect() });
256
+ return () => {
257
+ observer.disconnect();
258
+ };
259
+ }, [send, innerRef, groupId]);
260
+ const childIds = GroupMachine.useSelector((state) => state.context.items.map((i) => i.id).join(","));
261
+ (0, utils_1.useLayoutEffect)(() => {
262
+ return (0, interface_1.measureGroupChildren)(groupId, (childrenSizes) => {
263
+ send({ type: "setActualItemsSize", childrenSizes });
264
+ });
265
+ }, [send, groupId, childIds]);
266
+ // useDebugGroupMachineContext({ id: groupId });
267
+ const fallbackHandleRef = react_1.default.useRef(null);
268
+ const state = (0, react_1.useContext)(GroupMachineState);
269
+ (0, react_1.useImperativeHandle)(handle || fallbackHandleRef, () => {
270
+ return {
271
+ getId: () => groupId,
272
+ getPixelSizes: () => (0, state_1.getPanelGroupPixelSizes)(machineRef.current),
273
+ getPercentageSizes: () => (0, state_1.getPanelGroupPercentageSizes)(machineRef.current),
274
+ setSizes: (updates) => {
275
+ const context = machineRef.current;
276
+ for (let index = 0; index < updates.length; index++) {
277
+ const item = context.items[index];
278
+ const update = updates[index];
279
+ if (item && (0, state_1.isPanelData)(item) && update) {
280
+ send({
281
+ type: "setPanelPixelSize",
282
+ panelId: item.id,
283
+ size: update,
284
+ });
285
+ }
286
+ }
287
+ },
288
+ getTemplate: () => {
289
+ const context = machineRef.current;
290
+ return (0, state_1.buildTemplate)({ ...context, items: (0, state_1.prepareItems)(context) });
291
+ },
292
+ getState: () => (state.current === "idle" ? "idle" : "dragging"),
293
+ };
294
+ });
295
+ return (react_1.default.createElement("div", { ref: ref, "data-group-id": groupId, "data-group-orientation": orientation, ...(0, interface_1.mergeAttributes)(props, {
296
+ style: {
297
+ display: "grid",
298
+ gridTemplateColumns: orientation === "horizontal" ? template : undefined,
299
+ gridTemplateRows: orientation === "vertical" ? template : undefined,
300
+ height: "100%",
301
+ },
302
+ }) }));
303
+ });
304
+ /** A panel within a `PanelGroup` */
305
+ exports.Panel = react_1.default.forwardRef(function Panel({ defaultCollapsed, min, max, default: defaultSize, collapsedSize, onCollapseChange, onResize, collapseAnimation, isStaticAtRest, ...props }, outerRef) {
306
+ const { collapsible = false, collapsed } = props;
307
+ const isPrerender = react_1.default.useContext(PreRenderContext);
308
+ const onCollapseChangeRef = react_1.default.useRef(onCollapseChange);
309
+ (0, react_1.useEffect)(() => {
310
+ onCollapseChangeRef.current = onCollapseChange;
311
+ }, [onCollapseChange]);
312
+ const onResizeRef = react_1.default.useRef(onResize);
313
+ (0, react_1.useEffect)(() => {
314
+ onResizeRef.current = onResize;
315
+ }, [onResize]);
316
+ const panelDataRef = react_1.default.useMemo(() => {
317
+ return (0, state_1.initializePanel)({
318
+ min: min,
319
+ max: max,
320
+ collapsible: collapsible,
321
+ collapsed: collapsed,
322
+ collapsedSize: collapsedSize,
323
+ onCollapseChange: onCollapseChangeRef,
324
+ collapseAnimation: collapseAnimation,
325
+ onResize: onResizeRef,
326
+ id: props.id,
327
+ defaultCollapsed,
328
+ default: defaultSize,
329
+ isStaticAtRest,
330
+ });
331
+ }, [
332
+ collapseAnimation,
333
+ collapsed,
334
+ collapsedSize,
335
+ collapsible,
336
+ defaultCollapsed,
337
+ max,
338
+ min,
339
+ props.id,
340
+ defaultSize,
341
+ isStaticAtRest,
342
+ ]);
343
+ const { id: panelId } = useGroupItem(panelDataRef);
344
+ if (isPrerender) {
345
+ return null;
346
+ }
347
+ return (react_1.default.createElement(PanelVisible, { ref: outerRef, panelProp: panelDataRef, ...props, panelId: panelId }));
348
+ });
349
+ const PanelVisible = react_1.default.forwardRef(function PanelVisible({ collapsible = false, collapsed, handle, panelId, panelProp, ...props }, outerRef) {
350
+ const innerRef = react_1.default.useRef(null);
351
+ const ref = (0, utils_1.mergeRefs)(outerRef, innerRef);
352
+ const { send } = GroupMachine.useActorRef();
353
+ const machineRef = GroupMachine.useContextRef();
354
+ const groupId = GroupMachine.useSelector((state) => state.context.groupId);
355
+ const panel = GroupMachine.useSelector(({ context }) => {
356
+ try {
357
+ return (0, state_1.getPanelWithId)(context, panelId);
358
+ }
359
+ catch {
360
+ return undefined;
361
+ }
362
+ });
363
+ const contraintChanged = panel && (0, state_1.haveConstraintsChangedForPanel)(panelProp, panel);
364
+ const onConstraintChange = (0, utils_1.useEffectEvent)(() => {
365
+ if (contraintChanged) {
366
+ send({
367
+ type: "updateConstraints",
368
+ data: { ...panelProp, id: panel.id },
369
+ });
370
+ }
371
+ });
372
+ react_1.default.useEffect(() => {
373
+ if (contraintChanged) {
374
+ onConstraintChange();
375
+ }
376
+ }, [send, contraintChanged, onConstraintChange]);
377
+ // For controlled collapse we track if the `collapse` prop changes
378
+ // and update the state machine if it does.
379
+ react_1.default.useEffect(() => {
380
+ if (typeof collapsed !== "undefined") {
381
+ const context = machineRef.current;
382
+ if (context.items.length === 0) {
383
+ return;
384
+ }
385
+ const p = (0, state_1.getPanelWithId)(context, panelId);
386
+ if (collapsed === true && !p.collapsed) {
387
+ send({ type: "collapsePanel", panelId, controlled: true });
388
+ }
389
+ else if (collapsed === false && p.collapsed) {
390
+ send({ type: "expandPanel", panelId, controlled: true });
391
+ }
392
+ }
393
+ }, [send, collapsed, panelId, machineRef]);
394
+ const fallbackHandleRef = react_1.default.useRef(null);
395
+ (0, react_1.useImperativeHandle)(handle || fallbackHandleRef, () => {
396
+ return {
397
+ getId: () => panelId,
398
+ collapse: () => {
399
+ if (collapsible) {
400
+ // TODO: setting controlled here might be wrong
401
+ send({ type: "collapsePanel", panelId, controlled: true });
402
+ }
403
+ },
404
+ isCollapsed: () => Boolean(collapsible && panel?.collapsed),
405
+ expand: () => {
406
+ if (collapsible) {
407
+ send({ type: "expandPanel", panelId, controlled: true });
408
+ }
409
+ },
410
+ isExpanded: () => Boolean(collapsible && !panel?.collapsed),
411
+ getPixelSize: () => {
412
+ const context = machineRef.current;
413
+ return (0, state_1.getPanelPixelSize)(context, panelId);
414
+ },
415
+ setSize: (size) => {
416
+ send({ type: "setPanelPixelSize", panelId, size });
417
+ },
418
+ getPercentageSize: () => {
419
+ const context = machineRef.current;
420
+ return (0, state_1.getPanelPercentageSize)(context, panelId);
421
+ },
422
+ };
423
+ });
424
+ return (react_1.default.createElement("div", { ref: ref, ...(0, interface_1.mergeAttributes)(props, (0, interface_1.getPanelDomAttributes)({
425
+ groupId,
426
+ id: panelId,
427
+ collapsed,
428
+ collapsible: panel?.collapsible,
429
+ }), {
430
+ style: {
431
+ minWidth: 0,
432
+ minHeight: 0,
433
+ overflow: "hidden",
434
+ },
435
+ }) }));
436
+ });
437
+ /** A resize handle to place between panels. */
438
+ exports.PanelResizer = react_1.default.forwardRef(function PanelResizer(props, ref) {
439
+ const { size = "0px" } = props;
440
+ const isPrerender = react_1.default.useContext(PreRenderContext);
441
+ const data = react_1.default.useMemo(() => ({
442
+ type: "handle",
443
+ size: (0, state_1.parseUnit)(size),
444
+ id: props.id,
445
+ }), [size, props.id]);
446
+ useGroupItem(data);
447
+ if (isPrerender) {
448
+ return null;
449
+ }
450
+ return react_1.default.createElement(PanelResizerVisible, { ref: ref, panelHandleProp: data, ...props });
451
+ });
452
+ const PanelResizerVisible = react_1.default.forwardRef(function PanelResizerVisible({ size = "0px", disabled, onDragStart, onDrag, onDragEnd, panelHandleProp, ...props }, outerRef) {
453
+ const innerRef = react_1.default.useRef(null);
454
+ const ref = (0, utils_1.mergeRefs)(outerRef, innerRef);
455
+ const unit = (0, state_1.parseUnit)(size);
456
+ const { send } = GroupMachine.useActorRef();
457
+ const { index } = (0, useIndexedChildren_js_1.useIndex)();
458
+ const handleId = GroupMachine.useSelector(({ context }) => context.items[index]?.id || "");
459
+ const panelHandle = GroupMachine.useSelector(({ context }) => context.items[index]);
460
+ const panelBeforeHandle = GroupMachine.useSelector(({ context }) => {
461
+ const panel = context.items[index - 1];
462
+ if (!panel)
463
+ return undefined;
464
+ if (!(0, state_1.isPanelData)(panel))
465
+ return undefined;
466
+ return panel;
467
+ });
468
+ const collapsiblePanel = GroupMachine.useSelector(({ context }) => {
469
+ try {
470
+ return (0, state_1.getCollapsiblePanelForHandleId)(context, handleId);
471
+ }
472
+ catch {
473
+ return undefined;
474
+ }
475
+ });
476
+ const orientation = GroupMachine.useSelector((state) => state.context.orientation);
477
+ const groupsSize = GroupMachine.useSelector((state) => (0, state_1.getGroupSize)(state.context));
478
+ const overshoot = GroupMachine.useSelector((state) => state.context.dragOvershoot);
479
+ const activeDragHandleId = GroupMachine.useSelector((state) => state.context.activeDragHandleId);
480
+ const groupId = GroupMachine.useSelector((state) => state.context.groupId);
481
+ const [isDragging, setIsDragging] = react_1.default.useState(false);
482
+ let cursor;
483
+ if (disabled) {
484
+ cursor = "default";
485
+ }
486
+ else {
487
+ cursor = (0, state_1.getCursor)({ dragOvershoot: overshoot, orientation });
488
+ }
489
+ const { moveProps } = (0, useMove_js_1.useMove)({
490
+ onMoveStart: () => {
491
+ send({ type: "dragHandleStart", handleId: handleId });
492
+ onDragStart?.();
493
+ setIsDragging(true);
494
+ document.body.style.cursor = cursor || "auto";
495
+ },
496
+ onMove: (e) => {
497
+ send({ type: "dragHandle", handleId: handleId, value: e });
498
+ onDrag?.();
499
+ },
500
+ onMoveEnd: () => {
501
+ send({ type: "dragHandleEnd", handleId: handleId });
502
+ onDragEnd?.();
503
+ setIsDragging(false);
504
+ document.body.style.cursor = "auto";
505
+ },
506
+ });
507
+ const contraintChanged = panelHandle &&
508
+ (0, state_1.haveConstraintsChangedForPanelHandle)(panelHandleProp, panelHandle);
509
+ const onConstraintChange = (0, utils_1.useEffectEvent)(() => {
510
+ if (contraintChanged) {
511
+ send({
512
+ type: "updateConstraints",
513
+ data: { ...panelHandleProp, id: handleId },
514
+ });
515
+ }
516
+ });
517
+ react_1.default.useEffect(() => {
518
+ if (contraintChanged) {
519
+ onConstraintChange();
520
+ }
521
+ }, [send, contraintChanged, onConstraintChange]);
522
+ const onKeyDown = (e) => {
523
+ if (e.key === "Enter" && collapsiblePanel) {
524
+ if (collapsiblePanel.collapsed) {
525
+ send({ type: "expandPanel", panelId: collapsiblePanel.id });
526
+ }
527
+ else {
528
+ send({ type: "collapsePanel", panelId: collapsiblePanel.id });
529
+ }
530
+ }
531
+ };
532
+ return (react_1.default.createElement("div", { ref: ref, ...(0, interface_1.mergeAttributes)(props, disabled
533
+ ? {}
534
+ : (0, interface_1.mergeAttributes)(moveProps, {
535
+ onKeyDown,
536
+ tabIndex: 0,
537
+ }), (0, interface_1.getPanelResizerDomAttributes)({
538
+ groupId,
539
+ id: handleId,
540
+ orientation,
541
+ isDragging,
542
+ activeDragHandleId,
543
+ disabled,
544
+ controlsId: panelBeforeHandle?.id,
545
+ min: panelBeforeHandle?.min,
546
+ max: panelBeforeHandle?.max,
547
+ currentValue: panelBeforeHandle?.currentValue,
548
+ groupSize: groupsSize,
549
+ }), {
550
+ style: {
551
+ cursor,
552
+ ...(orientation === "horizontal"
553
+ ? { width: unit.value.toNumber(), height: "100%" }
554
+ : { height: unit.value.toNumber(), width: "100%" }),
555
+ },
556
+ }) }));
557
+ });
558
+ //# sourceMappingURL=ReactWindowSplitter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReactWindowSplitter.js","sourceRoot":"","sources":["../../src/ReactWindowSplitter.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,0DAUoC;AACpC,+CAQe;AACf,kDA4BgC;AAChC,6CAK2B;AAC3B,mEAAuE;AACvE,6CAAuC;AAEv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roupChildren,\n PanelGroupHandle,\n PanelHandle,\n SharedPanelGroupProps,\n SharedPanelProps,\n SharedPanelResizerProps,\n mergeAttributes,\n} from \"@window-splitter/interface\";\nimport React, {\n useEffect,\n useImperativeHandle,\n createContext,\n useRef,\n useState,\n useMemo,\n useContext,\n} from \"react\";\nimport {\n buildTemplate,\n getCollapsiblePanelForHandleId,\n getGroupSize,\n getPanelWithId,\n groupMachine,\n GroupMachineContextValue,\n initializePanel,\n InitializePanelHandleData,\n isPanelData,\n Item,\n PanelData,\n parseUnit,\n prepareItems,\n prepareSnapshot,\n getPanelGroupPixelSizes,\n getPanelGroupPercentageSizes,\n getPanelPixelSize,\n getPanelPercentageSize,\n getCursor,\n haveConstraintsChangedForPanel,\n PanelHandleData,\n ParsedPixelUnit,\n haveConstraintsChangedForPanelHandle,\n GroupMachineInput,\n GroupMachineEvent,\n State,\n initializePanelHandleData,\n} from \"@window-splitter/state\";\nimport {\n useEffectEvent,\n useId,\n useLayoutEffect,\n mergeRefs,\n} from \"@react-aria/utils\";\nimport { useIndex, useIndexedChildren } from \"./useIndexedChildren.js\";\nimport { useMove } from \"./useMove.js\";\n\n// #region Components\n\nconst GroupMachineState = createContext<{ current: State | undefined }>({\n current: undefined,\n});\nconst GroupMachineContext = createContext<GroupMachineContextValue | undefined>(\n undefined\n);\nconst GroupMachineStateContextRef = createContext<\n React.MutableRefObject<GroupMachineContextValue>\n>({\n current: undefined,\n} as unknown as React.MutableRefObject<GroupMachineContextValue>);\nconst GroupMachineActor = createContext<(e: GroupMachineEvent) => void>(\n () => {}\n);\nconst GroupMachine = {\n useSelector<R>(\n selector: (data: { context: GroupMachineContextValue }) => R\n ): R {\n const context = useContext(GroupMachineContext);\n if (!context) {\n throw new Error(\n \"GroupMachineContext must be used within a GroupMachineProvider\"\n );\n }\n return selector({ context });\n },\n useActorRef: () => {\n const send = useContext(GroupMachineActor);\n return { send };\n },\n useContextRef: () => {\n const ref = useContext(GroupMachineStateContextRef);\n if (!ref) {\n throw new Error(\n \"GroupMachineContext must be used within a GroupMachineProvider\"\n );\n }\n return ref;\n },\n Provider: ({\n input,\n children,\n }: {\n input: GroupMachineInput;\n children: React.ReactNode;\n }) => {\n const [intiialValue, send, state] = useMemo(\n () =>\n groupMachine(input, (value) => {\n currentContextRef.current = value;\n setCurrentValue({ ...value });\n }),\n // We only want this to run once, we dont care about changes to the input\n // eslint-disable-next-line react-hooks/exhaustive-deps\n []\n );\n const currentContextRef = useRef(intiialValue);\n const [currentValue, setCurrentValue] = useState(intiialValue);\n\n useEffect(() => {\n send({ type: \"unlockGroup\" });\n\n return () => {\n // When we were on xstate we could fire off event during unmount and if the parent group\n // unmounted too the events would never apply. With out own state machine code it doesn't\n // do that so we have to lock the group as it unmounts so it's children don't de-register.\n send({ type: \"lockGroup\" });\n };\n }, [send]);\n\n return (\n <GroupMachineState.Provider value={state}>\n <GroupMachineStateContextRef.Provider value={currentContextRef}>\n <GroupMachineContext.Provider value={currentValue}>\n <GroupMachineActor.Provider value={send}>\n {children}\n </GroupMachineActor.Provider>\n </GroupMachineContext.Provider>\n </GroupMachineStateContextRef.Provider>\n </GroupMachineState.Provider>\n );\n },\n};\n\n// function useDebugGroupMachineContext({ id }: { id: string }) {\n// const value = GroupMachineContext.useSelector((state) => state.value);\n// const context = GroupMachineContext.useSelector((state) => state.context);\n// console.log(\n// \"GROUP CONTEXT\",\n// buildTemplate(context),\n// context.size,\n// context.items.map((item) =>\n// isPanelData(item)\n// ? {\n// type: item.currentValue.type,\n// value: item.currentValue.value.toNumber(),\n// }\n// : { type: item.size.type, value: item.size.value.toNumber() }\n// )\n// );\n// }\n\nexport interface PanelGroupProps\n extends React.HTMLAttributes<HTMLDivElement>,\n SharedPanelGroupProps {\n /** Imperative handle to control the group */\n handle?: React.Ref<PanelGroupHandle>;\n}\n\nconst InitialMapContext = createContext<Item[]>([]);\nconst PreRenderContext = createContext(false);\n\nfunction PrerenderTree({\n children,\n onPrerender,\n}: {\n children: React.ReactNode;\n onPrerender: () => void;\n}) {\n const [shouldPrerender, setShouldPrerender] = React.useState(true);\n\n useLayoutEffect(() => {\n setShouldPrerender(false);\n onPrerender();\n // We only want this to run once\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return shouldPrerender ? (\n <div className=\"opacity-0 absolute\">\n <PreRenderContext.Provider value>{children}</PreRenderContext.Provider>\n </div>\n ) : null;\n}\n\nfunction useGroupItem<T extends Item>(\n itemArg: Omit<T, \"id\"> & { id?: string }\n): T {\n const isPrerender = React.useContext(PreRenderContext);\n const initialMap = React.useContext(InitialMapContext);\n const generatedId = useId();\n const id = itemArg.id || generatedId;\n const { index } = useIndex();\n const item = { ...itemArg, id } as T;\n\n if (isPrerender) {\n if (!initialMap.find((i) => i.id === item.id)) {\n initialMap.push(item);\n }\n return item;\n }\n\n // The way this hooks is called is never conditional so the usage here is fine\n /* eslint-disable react-hooks/rules-of-hooks */\n const currentItem = GroupMachine.useSelector(\n ({ context }) => context.items[index]\n ) as T;\n const { send } = GroupMachine.useActorRef();\n const machineRef = GroupMachine.useContextRef();\n\n const onCollapseChangeRef = isPanelData(itemArg)\n ? itemArg.onCollapseChange\n : undefined;\n const onResizeRef = isPanelData(itemArg) ? itemArg.onResize : undefined;\n const onUnmountRef = useRef<(() => void) | undefined>(undefined);\n\n // We register panels before layout so it looks good\n useLayoutEffect(() => {\n const context = machineRef.current;\n\n if (!context) {\n return;\n }\n\n let contextItem: Item | undefined;\n\n if (itemArg.id) {\n contextItem = context.items.find((i) => i.id === itemArg.id);\n\n if (!contextItem) {\n if (!itemArg.id) {\n throw new Error(\n \"When using dynamic panels you must provide an id on the items. This applies to React strict mode as well.\"\n );\n }\n\n if (isPanelData(itemArg)) {\n send({\n type: \"registerDynamicPanel\",\n data: { ...itemArg, order: index },\n });\n } else {\n send({\n type: \"registerPanelHandle\",\n data: initializePanelHandleData({\n ...(itemArg as unknown as InitializePanelHandleData),\n order: index,\n }),\n });\n }\n } else if (onCollapseChangeRef || onResizeRef) {\n send({\n type: \"rebindPanelCallbacks\",\n data: {\n id: itemArg.id,\n onCollapseChange: onCollapseChangeRef,\n onResize: onResizeRef,\n },\n });\n }\n } else {\n contextItem = context.items[index];\n }\n\n const unmountId = contextItem?.id || itemArg.id;\n\n onUnmountRef.current = () => {\n if (!unmountId) return;\n\n const el = document.querySelector(\n `[data-splitter-id=\"${unmountId}\"]`\n ) as HTMLElement;\n\n if (el || !unmountId) {\n return;\n }\n\n if (isPanelData(itemArg)) {\n send({ type: \"unregisterPanel\", id: unmountId });\n } else {\n send({ type: \"unregisterPanelHandle\", id: unmountId });\n }\n };\n }, [index, itemArg, machineRef, send, onCollapseChangeRef, onResizeRef]);\n\n // And unregister after layout so we can tell if the element was actually removed.\n React.useEffect(() => {\n return () => {\n onUnmountRef.current?.();\n onUnmountRef.current = undefined;\n };\n }, []);\n\n return currentItem || item;\n /* eslint-enable react-hooks/rules-of-hooks */\n}\n\n/** A group of panels that has constraints and a user can resize */\nexport const PanelGroup = React.forwardRef<HTMLDivElement, PanelGroupProps>(\n function PanelGroup({ children, ...props }, ref) {\n const [hasPreRendered, setHasPreRendered] = useState(false);\n const initialMap = useRef<Item[]>([]);\n const indexedChildren = useIndexedChildren(children);\n\n return (\n <InitialMapContext.Provider value={initialMap.current}>\n {!hasPreRendered && (\n <PrerenderTree onPrerender={() => setHasPreRendered(true)}>\n {indexedChildren}\n </PrerenderTree>\n )}\n\n <PanelGroupImpl ref={ref} initialItems={initialMap} {...props}>\n {indexedChildren}\n </PanelGroupImpl>\n </InitialMapContext.Provider>\n );\n }\n);\n\nconst PanelGroupImpl = React.forwardRef<\n HTMLDivElement,\n PanelGroupProps & {\n initialItems: { current: Item[] };\n }\n>(function PanelGroupImpl(\n {\n autosaveId,\n autosaveStrategy = \"localStorage\",\n snapshot: snapshotProp,\n initialItems,\n ...props\n },\n ref\n) {\n const defaultGroupId = `panel-group-${useId()}`;\n const groupId = autosaveId || props.id || defaultGroupId;\n const [snapshot, setSnapshot] = React.useState<\n GroupMachineContextValue | true | undefined\n >(snapshotProp);\n\n if (\n typeof window !== \"undefined\" &&\n autosaveId &&\n !snapshot &&\n autosaveStrategy === \"localStorage\"\n ) {\n const localSnapshot = localStorage.getItem(autosaveId);\n\n if (localSnapshot) {\n setSnapshot(JSON.parse(localSnapshot));\n } else {\n setSnapshot(true);\n }\n }\n\n const snapshotMemo = useMemo(() => {\n return typeof snapshot === \"object\" ? prepareSnapshot(snapshot) : undefined;\n }, [snapshot]);\n\n return (\n <GroupMachine.Provider\n input={{\n orientation: props.orientation,\n groupId,\n items: initialItems.current,\n autosaveStrategy,\n ...(typeof snapshotMemo === \"object\" ? snapshotMemo : undefined),\n }}\n >\n <PanelGroupImplementation ref={ref} {...props} />\n </GroupMachine.Provider>\n );\n});\n\nconst PanelGroupImplementation = React.forwardRef<\n HTMLDivElement,\n PanelGroupProps\n>(function PanelGroupImplementation(\n { handle, orientation: orientationProp, ...props },\n outerRef\n) {\n const { send } = GroupMachine.useActorRef();\n const machineRef = GroupMachine.useContextRef();\n const innerRef = React.useRef<HTMLDivElement>(null);\n const ref = mergeRefs(outerRef, innerRef);\n const orientation = GroupMachine.useSelector(\n (state) => state.context.orientation\n );\n const groupId = GroupMachine.useSelector((state) => state.context.groupId);\n const template = GroupMachine.useSelector((state) =>\n buildTemplate(state.context)\n );\n\n // When the prop for `orientation` updates also update the state machine\n if (orientationProp && orientationProp !== orientation) {\n send({ type: \"setOrientation\", orientation: orientationProp });\n }\n\n // Track the size of the group\n useLayoutEffect(() => {\n const { current: el } = innerRef;\n\n if (!el) {\n return;\n }\n\n const observer = new ResizeObserver((entries) => {\n const entry = entries[0];\n\n if (!entry) {\n return;\n }\n\n send({ type: \"setSize\", size: entry.contentRect });\n });\n\n observer.observe(el);\n\n send({ type: \"setSize\", size: el.getBoundingClientRect() });\n\n return () => {\n observer.disconnect();\n };\n }, [send, innerRef, groupId]);\n\n const childIds = GroupMachine.useSelector((state) =>\n state.context.items.map((i) => i.id).join(\",\")\n );\n useLayoutEffect(() => {\n return measureGroupChildren(groupId, (childrenSizes) => {\n send({ type: \"setActualItemsSize\", childrenSizes });\n });\n }, [send, groupId, childIds]);\n\n // useDebugGroupMachineContext({ id: groupId });\n\n const fallbackHandleRef = React.useRef<PanelGroupHandle>(null);\n const state = useContext(GroupMachineState);\n\n useImperativeHandle(handle || fallbackHandleRef, () => {\n return {\n getId: () => groupId,\n getPixelSizes: () => getPanelGroupPixelSizes(machineRef.current),\n getPercentageSizes: () =>\n getPanelGroupPercentageSizes(machineRef.current),\n setSizes: (updates) => {\n const context = machineRef.current;\n\n for (let index = 0; index < updates.length; index++) {\n const item = context.items[index];\n const update = updates[index];\n\n if (item && isPanelData(item) && update) {\n send({\n type: \"setPanelPixelSize\",\n panelId: item.id,\n size: update,\n });\n }\n }\n },\n getTemplate: () => {\n const context = machineRef.current;\n return buildTemplate({ ...context, items: prepareItems(context) });\n },\n getState: () => (state.current === \"idle\" ? \"idle\" : \"dragging\"),\n };\n });\n\n return (\n <div\n ref={ref}\n data-group-id={groupId}\n data-group-orientation={orientation}\n {...mergeAttributes(props, {\n style: {\n display: \"grid\",\n gridTemplateColumns:\n orientation === \"horizontal\" ? template : undefined,\n gridTemplateRows: orientation === \"vertical\" ? template : undefined,\n height: \"100%\",\n },\n })}\n />\n );\n});\n\nexport interface PanelProps\n extends SharedPanelProps<boolean>,\n Omit<React.HTMLAttributes<HTMLDivElement>, \"onResize\"> {\n /** Imperative handle to control the panel */\n handle?: React.Ref<PanelHandle>;\n}\n\n/** A panel within a `PanelGroup` */\nexport const Panel = React.forwardRef<HTMLDivElement, PanelProps>(\n function Panel(\n {\n defaultCollapsed,\n min,\n max,\n default: defaultSize,\n collapsedSize,\n onCollapseChange,\n onResize,\n collapseAnimation,\n isStaticAtRest,\n ...props\n },\n outerRef\n ) {\n const { collapsible = false, collapsed } = props;\n const isPrerender = React.useContext(PreRenderContext);\n const onCollapseChangeRef = React.useRef(onCollapseChange);\n useEffect(() => {\n onCollapseChangeRef.current = onCollapseChange;\n }, [onCollapseChange]);\n const onResizeRef = React.useRef(onResize);\n useEffect(() => {\n onResizeRef.current = onResize;\n }, [onResize]);\n const panelDataRef = React.useMemo(() => {\n return initializePanel({\n min: min,\n max: max,\n collapsible: collapsible,\n collapsed: collapsed,\n collapsedSize: collapsedSize,\n onCollapseChange: onCollapseChangeRef,\n collapseAnimation: collapseAnimation,\n onResize: onResizeRef,\n id: props.id,\n defaultCollapsed,\n default: defaultSize,\n isStaticAtRest,\n });\n }, [\n collapseAnimation,\n collapsed,\n collapsedSize,\n collapsible,\n defaultCollapsed,\n max,\n min,\n props.id,\n defaultSize,\n isStaticAtRest,\n ]);\n\n const { id: panelId } = useGroupItem(panelDataRef);\n\n if (isPrerender) {\n return null;\n }\n\n return (\n <PanelVisible\n ref={outerRef}\n panelProp={panelDataRef}\n {...props}\n panelId={panelId}\n />\n );\n }\n);\n\nconst PanelVisible = React.forwardRef<\n HTMLDivElement,\n Omit<\n PanelProps,\n | \"collapsedSize\"\n | \"onCollapseChange\"\n | \"defaultCollapsed\"\n | \"min\"\n | \"max\"\n | \"collapseAnimation\"\n | \"onResize\"\n > & {\n panelId: string;\n /** The latest prop that was received by the `Panel` component */\n panelProp: Omit<PanelData, \"id\">;\n }\n>(function PanelVisible(\n { collapsible = false, collapsed, handle, panelId, panelProp, ...props },\n outerRef\n) {\n const innerRef = React.useRef<HTMLDivElement>(null);\n const ref = mergeRefs(outerRef, innerRef);\n const { send } = GroupMachine.useActorRef();\n const machineRef = GroupMachine.useContextRef();\n const groupId = GroupMachine.useSelector((state) => state.context.groupId);\n const panel = GroupMachine.useSelector(({ context }) => {\n try {\n return getPanelWithId(context, panelId);\n } catch {\n return undefined;\n }\n });\n\n const contraintChanged =\n panel && haveConstraintsChangedForPanel(panelProp, panel);\n\n const onConstraintChange = useEffectEvent(() => {\n if (contraintChanged) {\n send({\n type: \"updateConstraints\",\n data: { ...panelProp, id: panel.id },\n });\n }\n });\n\n React.useEffect(() => {\n if (contraintChanged) {\n onConstraintChange();\n }\n }, [send, contraintChanged, onConstraintChange]);\n\n // For controlled collapse we track if the `collapse` prop changes\n // and update the state machine if it does.\n React.useEffect(() => {\n if (typeof collapsed !== \"undefined\") {\n const context = machineRef.current;\n\n if (context.items.length === 0) {\n return;\n }\n\n const p = getPanelWithId(context, panelId);\n\n if (collapsed === true && !p.collapsed) {\n send({ type: \"collapsePanel\", panelId, controlled: true });\n } else if (collapsed === false && p.collapsed) {\n send({ type: \"expandPanel\", panelId, controlled: true });\n }\n }\n }, [send, collapsed, panelId, machineRef]);\n\n const fallbackHandleRef = React.useRef<PanelHandle>(null);\n\n useImperativeHandle(handle || fallbackHandleRef, () => {\n return {\n getId: () => panelId,\n collapse: () => {\n if (collapsible) {\n // TODO: setting controlled here might be wrong\n send({ type: \"collapsePanel\", panelId, controlled: true });\n }\n },\n isCollapsed: () => Boolean(collapsible && panel?.collapsed),\n expand: () => {\n if (collapsible) {\n send({ type: \"expandPanel\", panelId, controlled: true });\n }\n },\n isExpanded: () => Boolean(collapsible && !panel?.collapsed),\n getPixelSize: () => {\n const context = machineRef.current;\n return getPanelPixelSize(context, panelId);\n },\n setSize: (size) => {\n send({ type: \"setPanelPixelSize\", panelId, size });\n },\n getPercentageSize: () => {\n const context = machineRef.current;\n return getPanelPercentageSize(context, panelId);\n },\n };\n });\n\n return (\n <div\n ref={ref}\n {...mergeAttributes(\n props,\n getPanelDomAttributes({\n groupId,\n id: panelId,\n collapsed,\n collapsible: panel?.collapsible,\n }),\n {\n style: {\n minWidth: 0,\n minHeight: 0,\n overflow: \"hidden\",\n },\n }\n )}\n />\n );\n});\n\nexport interface PanelResizerProps\n extends SharedPanelResizerProps,\n Omit<\n React.HTMLAttributes<HTMLDivElement>,\n \"onDragStart\" | \"onDrag\" | \"onDragEnd\"\n > {}\n\n/** A resize handle to place between panels. */\nexport const PanelResizer = React.forwardRef<HTMLDivElement, PanelResizerProps>(\n function PanelResizer(props, ref) {\n const { size = \"0px\" } = props;\n const isPrerender = React.useContext(PreRenderContext);\n const data = React.useMemo(\n () => ({\n type: \"handle\" as const,\n size: parseUnit(size) as ParsedPixelUnit,\n id: props.id,\n }),\n [size, props.id]\n );\n\n useGroupItem(data);\n\n if (isPrerender) {\n return null;\n }\n\n return <PanelResizerVisible ref={ref} panelHandleProp={data} {...props} />;\n }\n);\n\nconst PanelResizerVisible = React.forwardRef<\n HTMLDivElement,\n PanelResizerProps & { panelHandleProp: Omit<PanelHandleData, \"id\"> }\n>(function PanelResizerVisible(\n {\n size = \"0px\",\n disabled,\n onDragStart,\n onDrag,\n onDragEnd,\n panelHandleProp,\n ...props\n },\n outerRef\n) {\n const innerRef = React.useRef<HTMLDivElement>(null);\n const ref = mergeRefs(outerRef, innerRef);\n const unit = parseUnit(size);\n const { send } = GroupMachine.useActorRef();\n const { index } = useIndex();\n const handleId = GroupMachine.useSelector(\n ({ context }) => context.items[index]?.id || \"\"\n );\n const panelHandle = GroupMachine.useSelector(\n ({ context }) => context.items[index] as PanelHandleData\n );\n const panelBeforeHandle = GroupMachine.useSelector(({ context }) => {\n const panel = context.items[index - 1];\n if (!panel) return undefined;\n if (!isPanelData(panel)) return undefined;\n return panel;\n });\n const collapsiblePanel = GroupMachine.useSelector(({ context }) => {\n try {\n return getCollapsiblePanelForHandleId(context, handleId);\n } catch {\n return undefined;\n }\n });\n const orientation = GroupMachine.useSelector(\n (state) => state.context.orientation\n );\n const groupsSize = GroupMachine.useSelector((state) =>\n getGroupSize(state.context)\n );\n const overshoot = GroupMachine.useSelector(\n (state) => state.context.dragOvershoot\n );\n const activeDragHandleId = GroupMachine.useSelector(\n (state) => state.context.activeDragHandleId\n );\n const groupId = GroupMachine.useSelector((state) => state.context.groupId);\n const [isDragging, setIsDragging] = React.useState(false);\n\n let cursor: React.CSSProperties[\"cursor\"];\n\n if (disabled) {\n cursor = \"default\";\n } else {\n cursor = getCursor({ dragOvershoot: overshoot, orientation });\n }\n\n const { moveProps } = useMove({\n onMoveStart: () => {\n send({ type: \"dragHandleStart\", handleId: handleId });\n onDragStart?.();\n setIsDragging(true);\n document.body.style.cursor = cursor || \"auto\";\n },\n onMove: (e) => {\n send({ type: \"dragHandle\", handleId: handleId, value: e });\n onDrag?.();\n },\n onMoveEnd: () => {\n send({ type: \"dragHandleEnd\", handleId: handleId });\n onDragEnd?.();\n setIsDragging(false);\n document.body.style.cursor = \"auto\";\n },\n });\n\n const contraintChanged =\n panelHandle &&\n haveConstraintsChangedForPanelHandle(panelHandleProp, panelHandle);\n\n const onConstraintChange = useEffectEvent(() => {\n if (contraintChanged) {\n send({\n type: \"updateConstraints\",\n data: { ...panelHandleProp, id: handleId },\n });\n }\n });\n\n React.useEffect(() => {\n if (contraintChanged) {\n onConstraintChange();\n }\n }, [send, contraintChanged, onConstraintChange]);\n\n const onKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n if (e.key === \"Enter\" && collapsiblePanel) {\n if (collapsiblePanel.collapsed) {\n send({ type: \"expandPanel\", panelId: collapsiblePanel.id });\n } else {\n send({ type: \"collapsePanel\", panelId: collapsiblePanel.id });\n }\n }\n };\n\n return (\n <div\n ref={ref as unknown as React.Ref<HTMLDivElement>}\n {...mergeAttributes(\n props,\n disabled\n ? {}\n : mergeAttributes(moveProps as React.HTMLAttributes<HTMLDivElement>, {\n onKeyDown,\n tabIndex: 0,\n }),\n getPanelResizerDomAttributes({\n groupId,\n id: handleId,\n orientation,\n isDragging,\n activeDragHandleId,\n disabled,\n controlsId: panelBeforeHandle?.id,\n min: panelBeforeHandle?.min,\n max: panelBeforeHandle?.max,\n currentValue: panelBeforeHandle?.currentValue,\n groupSize: groupsSize,\n }),\n {\n style: {\n cursor,\n ...(orientation === \"horizontal\"\n ? { width: unit.value.toNumber(), height: \"100%\" }\n : { height: unit.value.toNumber(), width: \"100%\" }),\n },\n }\n )}\n />\n );\n});\n\n// #endregion\n"]}