@window-splitter/react 1.1.4 → 1.1.5--canary.b95ee23.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.
- package/.turbo/turbo-build.log +1 -1
- package/dist/commonjs/ReactWindowSplitter.d.ts.map +1 -1
- package/dist/commonjs/ReactWindowSplitter.js +15 -2
- package/dist/commonjs/ReactWindowSplitter.js.map +1 -1
- package/dist/commonjs/ReactWindowSplitter.test.js +56 -0
- package/dist/commonjs/ReactWindowSplitter.test.js.map +1 -1
- package/dist/esm/ReactWindowSplitter.d.ts.map +1 -1
- package/dist/esm/ReactWindowSplitter.js +15 -2
- package/dist/esm/ReactWindowSplitter.js.map +1 -1
- package/dist/esm/ReactWindowSplitter.test.js +56 -0
- package/dist/esm/ReactWindowSplitter.test.js.map +1 -1
- package/package.json +5 -5
- package/src/ReactWindowSplitter.test.tsx +118 -0
- package/src/ReactWindowSplitter.tsx +26 -5
- package/src/__screenshots__/ReactWindowSplitter.test.tsx/direct-DOM-animation-path-grid-template-updates-on-the-DOM-during-collapse-animation-1.png +0 -0
|
@@ -75,6 +75,9 @@ const GroupMachineStateContextRef = createContext<
|
|
|
75
75
|
const GroupMachineActor = createContext<(e: GroupMachineEvent) => void>(
|
|
76
76
|
() => {}
|
|
77
77
|
);
|
|
78
|
+
const GroupMachineAnimationDomRef = createContext<
|
|
79
|
+
React.MutableRefObject<HTMLElement | null>
|
|
80
|
+
>({ current: null });
|
|
78
81
|
const GroupMachine = {
|
|
79
82
|
useSelector<R>(
|
|
80
83
|
selector: (data: { context: GroupMachineContextValue }) => R
|
|
@@ -107,12 +110,17 @@ const GroupMachine = {
|
|
|
107
110
|
input: GroupMachineInput;
|
|
108
111
|
children: React.ReactNode;
|
|
109
112
|
}) => {
|
|
113
|
+
const animationDomRef = useRef<HTMLElement | null>(null);
|
|
110
114
|
const [initialValue, send, state] = useMemo(
|
|
111
115
|
() =>
|
|
112
|
-
groupMachine(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
+
groupMachine(
|
|
117
|
+
input,
|
|
118
|
+
(value) => {
|
|
119
|
+
currentContextRef.current = value;
|
|
120
|
+
setCurrentValue({ ...value });
|
|
121
|
+
},
|
|
122
|
+
() => animationDomRef.current
|
|
123
|
+
),
|
|
116
124
|
// We only want this to run once, we dont care about changes to the input
|
|
117
125
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
118
126
|
[]
|
|
@@ -136,7 +144,9 @@ const GroupMachine = {
|
|
|
136
144
|
<GroupMachineStateContextRef.Provider value={currentContextRef}>
|
|
137
145
|
<GroupMachineContext.Provider value={currentValue}>
|
|
138
146
|
<GroupMachineActor.Provider value={send}>
|
|
139
|
-
{
|
|
147
|
+
<GroupMachineAnimationDomRef.Provider value={animationDomRef}>
|
|
148
|
+
{children}
|
|
149
|
+
</GroupMachineAnimationDomRef.Provider>
|
|
140
150
|
</GroupMachineActor.Provider>
|
|
141
151
|
</GroupMachineContext.Provider>
|
|
142
152
|
</GroupMachineStateContextRef.Provider>
|
|
@@ -414,6 +424,7 @@ const PanelGroupImplementation = React.forwardRef<
|
|
|
414
424
|
) {
|
|
415
425
|
const { send } = GroupMachine.useActorRef();
|
|
416
426
|
const machineRef = GroupMachine.useContextRef();
|
|
427
|
+
const animationDomRef = useContext(GroupMachineAnimationDomRef);
|
|
417
428
|
const innerRef = React.useRef<HTMLDivElement>(null);
|
|
418
429
|
const ref = mergeRefs(outerRef, innerRef);
|
|
419
430
|
const orientation = GroupMachine.useSelector(
|
|
@@ -429,6 +440,16 @@ const PanelGroupImplementation = React.forwardRef<
|
|
|
429
440
|
send({ type: "setOrientation", orientation: orientationProp });
|
|
430
441
|
}
|
|
431
442
|
|
|
443
|
+
// Register the group's DOM element so the machine can write
|
|
444
|
+
// grid-template directly during collapse/expand animations,
|
|
445
|
+
// bypassing React re-renders for each animation frame.
|
|
446
|
+
useLayoutEffect(() => {
|
|
447
|
+
animationDomRef.current = innerRef.current;
|
|
448
|
+
return () => {
|
|
449
|
+
animationDomRef.current = null;
|
|
450
|
+
};
|
|
451
|
+
}, [animationDomRef]);
|
|
452
|
+
|
|
432
453
|
// Track the size of the group
|
|
433
454
|
useLayoutEffect(() => {
|
|
434
455
|
const { current: el } = innerRef;
|