react-resizable-panels 2.0.21 → 2.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/react-resizable-panels.browser.cjs.js +12 -4
- package/dist/react-resizable-panels.browser.development.cjs.js +12 -4
- package/dist/react-resizable-panels.browser.development.esm.js +12 -4
- package/dist/react-resizable-panels.browser.esm.js +12 -4
- package/dist/react-resizable-panels.cjs.js +12 -4
- package/dist/react-resizable-panels.development.cjs.js +12 -4
- package/dist/react-resizable-panels.development.esm.js +12 -4
- package/dist/react-resizable-panels.development.node.cjs.js +12 -4
- package/dist/react-resizable-panels.development.node.esm.js +12 -4
- package/dist/react-resizable-panels.esm.js +12 -4
- package/dist/react-resizable-panels.node.cjs.js +12 -4
- package/dist/react-resizable-panels.node.esm.js +12 -4
- package/package.json +1 -1
- package/src/PanelGroup.ts +43 -31
- package/src/hooks/useForceUpdate.ts +7 -0
- package/src/vendor/react.ts +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.0.23
|
|
4
|
+
|
|
5
|
+
- Improve obfuscation for `React.useId` references (#382)
|
|
6
|
+
|
|
7
|
+
## 2.0.22
|
|
8
|
+
|
|
9
|
+
- Force eager layout re-calculation after panel added/removed (#375)
|
|
10
|
+
|
|
3
11
|
## 2.0.21
|
|
4
12
|
|
|
5
13
|
- Handle pointer event edge case with different origin iframes (#374)
|
|
@@ -43,8 +43,8 @@ const {
|
|
|
43
43
|
useState
|
|
44
44
|
} = React__namespace;
|
|
45
45
|
|
|
46
|
-
// `
|
|
47
|
-
const useId = React__namespace[
|
|
46
|
+
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
|
|
47
|
+
const useId = React__namespace[`useId${Math.random()}`.slice(0, 5)];
|
|
48
48
|
const useLayoutEffect_do_not_use_directly = useLayoutEffect;
|
|
49
49
|
|
|
50
50
|
// The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
|
|
@@ -687,6 +687,11 @@ function updateResizeHandlerStates(action, event) {
|
|
|
687
687
|
});
|
|
688
688
|
}
|
|
689
689
|
|
|
690
|
+
function useForceUpdate() {
|
|
691
|
+
const [_, setCount] = useState(0);
|
|
692
|
+
return useCallback(() => setCount(prevCount => prevCount + 1), []);
|
|
693
|
+
}
|
|
694
|
+
|
|
690
695
|
function assert(expectedCondition, message) {
|
|
691
696
|
if (!expectedCondition) {
|
|
692
697
|
console.error(message);
|
|
@@ -1596,6 +1601,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1596
1601
|
const panelGroupElementRef = useRef(null);
|
|
1597
1602
|
const [dragState, setDragState] = useState(null);
|
|
1598
1603
|
const [layout, setLayout] = useState([]);
|
|
1604
|
+
const forceUpdate = useForceUpdate();
|
|
1599
1605
|
const panelIdToLastNotifiedSizeMapRef = useRef({});
|
|
1600
1606
|
const panelSizeBeforeCollapseRef = useRef(new Map());
|
|
1601
1607
|
const prevDeltaRef = useRef(0);
|
|
@@ -1858,7 +1864,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1858
1864
|
}
|
|
1859
1865
|
});
|
|
1860
1866
|
eagerValuesRef.current.panelDataArrayChanged = true;
|
|
1861
|
-
|
|
1867
|
+
forceUpdate();
|
|
1868
|
+
}, [forceUpdate]);
|
|
1862
1869
|
|
|
1863
1870
|
// (Re)calculate group layout whenever panels are registered or unregistered.
|
|
1864
1871
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -2090,8 +2097,9 @@ function PanelGroupWithForwardedRef({
|
|
|
2090
2097
|
// Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
|
|
2091
2098
|
delete panelIdToLastNotifiedSizeMapRef.current[panelData.id];
|
|
2092
2099
|
eagerValuesRef.current.panelDataArrayChanged = true;
|
|
2100
|
+
forceUpdate();
|
|
2093
2101
|
}
|
|
2094
|
-
}, []);
|
|
2102
|
+
}, [forceUpdate]);
|
|
2095
2103
|
const context = useMemo(() => ({
|
|
2096
2104
|
collapsePanel,
|
|
2097
2105
|
direction,
|
|
@@ -43,8 +43,8 @@ const {
|
|
|
43
43
|
useState
|
|
44
44
|
} = React__namespace;
|
|
45
45
|
|
|
46
|
-
// `
|
|
47
|
-
const useId = React__namespace[
|
|
46
|
+
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
|
|
47
|
+
const useId = React__namespace[`useId${Math.random()}`.slice(0, 5)];
|
|
48
48
|
const useLayoutEffect_do_not_use_directly = useLayoutEffect;
|
|
49
49
|
|
|
50
50
|
// The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
|
|
@@ -693,6 +693,11 @@ function updateResizeHandlerStates(action, event) {
|
|
|
693
693
|
});
|
|
694
694
|
}
|
|
695
695
|
|
|
696
|
+
function useForceUpdate() {
|
|
697
|
+
const [_, setCount] = useState(0);
|
|
698
|
+
return useCallback(() => setCount(prevCount => prevCount + 1), []);
|
|
699
|
+
}
|
|
700
|
+
|
|
696
701
|
function assert(expectedCondition, message) {
|
|
697
702
|
if (!expectedCondition) {
|
|
698
703
|
console.error(message);
|
|
@@ -1660,6 +1665,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1660
1665
|
const panelGroupElementRef = useRef(null);
|
|
1661
1666
|
const [dragState, setDragState] = useState(null);
|
|
1662
1667
|
const [layout, setLayout] = useState([]);
|
|
1668
|
+
const forceUpdate = useForceUpdate();
|
|
1663
1669
|
const panelIdToLastNotifiedSizeMapRef = useRef({});
|
|
1664
1670
|
const panelSizeBeforeCollapseRef = useRef(new Map());
|
|
1665
1671
|
const prevDeltaRef = useRef(0);
|
|
@@ -1964,7 +1970,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1964
1970
|
}
|
|
1965
1971
|
});
|
|
1966
1972
|
eagerValuesRef.current.panelDataArrayChanged = true;
|
|
1967
|
-
|
|
1973
|
+
forceUpdate();
|
|
1974
|
+
}, [forceUpdate]);
|
|
1968
1975
|
|
|
1969
1976
|
// (Re)calculate group layout whenever panels are registered or unregistered.
|
|
1970
1977
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -2196,8 +2203,9 @@ function PanelGroupWithForwardedRef({
|
|
|
2196
2203
|
// Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
|
|
2197
2204
|
delete panelIdToLastNotifiedSizeMapRef.current[panelData.id];
|
|
2198
2205
|
eagerValuesRef.current.panelDataArrayChanged = true;
|
|
2206
|
+
forceUpdate();
|
|
2199
2207
|
}
|
|
2200
|
-
}, []);
|
|
2208
|
+
}, [forceUpdate]);
|
|
2201
2209
|
const context = useMemo(() => ({
|
|
2202
2210
|
collapsePanel,
|
|
2203
2211
|
direction,
|
|
@@ -19,8 +19,8 @@ const {
|
|
|
19
19
|
useState
|
|
20
20
|
} = React;
|
|
21
21
|
|
|
22
|
-
// `
|
|
23
|
-
const useId = React[
|
|
22
|
+
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
|
|
23
|
+
const useId = React[`useId${Math.random()}`.slice(0, 5)];
|
|
24
24
|
const useLayoutEffect_do_not_use_directly = useLayoutEffect;
|
|
25
25
|
|
|
26
26
|
// The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
|
|
@@ -669,6 +669,11 @@ function updateResizeHandlerStates(action, event) {
|
|
|
669
669
|
});
|
|
670
670
|
}
|
|
671
671
|
|
|
672
|
+
function useForceUpdate() {
|
|
673
|
+
const [_, setCount] = useState(0);
|
|
674
|
+
return useCallback(() => setCount(prevCount => prevCount + 1), []);
|
|
675
|
+
}
|
|
676
|
+
|
|
672
677
|
function assert(expectedCondition, message) {
|
|
673
678
|
if (!expectedCondition) {
|
|
674
679
|
console.error(message);
|
|
@@ -1636,6 +1641,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1636
1641
|
const panelGroupElementRef = useRef(null);
|
|
1637
1642
|
const [dragState, setDragState] = useState(null);
|
|
1638
1643
|
const [layout, setLayout] = useState([]);
|
|
1644
|
+
const forceUpdate = useForceUpdate();
|
|
1639
1645
|
const panelIdToLastNotifiedSizeMapRef = useRef({});
|
|
1640
1646
|
const panelSizeBeforeCollapseRef = useRef(new Map());
|
|
1641
1647
|
const prevDeltaRef = useRef(0);
|
|
@@ -1940,7 +1946,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1940
1946
|
}
|
|
1941
1947
|
});
|
|
1942
1948
|
eagerValuesRef.current.panelDataArrayChanged = true;
|
|
1943
|
-
|
|
1949
|
+
forceUpdate();
|
|
1950
|
+
}, [forceUpdate]);
|
|
1944
1951
|
|
|
1945
1952
|
// (Re)calculate group layout whenever panels are registered or unregistered.
|
|
1946
1953
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -2172,8 +2179,9 @@ function PanelGroupWithForwardedRef({
|
|
|
2172
2179
|
// Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
|
|
2173
2180
|
delete panelIdToLastNotifiedSizeMapRef.current[panelData.id];
|
|
2174
2181
|
eagerValuesRef.current.panelDataArrayChanged = true;
|
|
2182
|
+
forceUpdate();
|
|
2175
2183
|
}
|
|
2176
|
-
}, []);
|
|
2184
|
+
}, [forceUpdate]);
|
|
2177
2185
|
const context = useMemo(() => ({
|
|
2178
2186
|
collapsePanel,
|
|
2179
2187
|
direction,
|
|
@@ -19,8 +19,8 @@ const {
|
|
|
19
19
|
useState
|
|
20
20
|
} = React;
|
|
21
21
|
|
|
22
|
-
// `
|
|
23
|
-
const useId = React[
|
|
22
|
+
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
|
|
23
|
+
const useId = React[`useId${Math.random()}`.slice(0, 5)];
|
|
24
24
|
const useLayoutEffect_do_not_use_directly = useLayoutEffect;
|
|
25
25
|
|
|
26
26
|
// The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
|
|
@@ -663,6 +663,11 @@ function updateResizeHandlerStates(action, event) {
|
|
|
663
663
|
});
|
|
664
664
|
}
|
|
665
665
|
|
|
666
|
+
function useForceUpdate() {
|
|
667
|
+
const [_, setCount] = useState(0);
|
|
668
|
+
return useCallback(() => setCount(prevCount => prevCount + 1), []);
|
|
669
|
+
}
|
|
670
|
+
|
|
666
671
|
function assert(expectedCondition, message) {
|
|
667
672
|
if (!expectedCondition) {
|
|
668
673
|
console.error(message);
|
|
@@ -1572,6 +1577,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1572
1577
|
const panelGroupElementRef = useRef(null);
|
|
1573
1578
|
const [dragState, setDragState] = useState(null);
|
|
1574
1579
|
const [layout, setLayout] = useState([]);
|
|
1580
|
+
const forceUpdate = useForceUpdate();
|
|
1575
1581
|
const panelIdToLastNotifiedSizeMapRef = useRef({});
|
|
1576
1582
|
const panelSizeBeforeCollapseRef = useRef(new Map());
|
|
1577
1583
|
const prevDeltaRef = useRef(0);
|
|
@@ -1834,7 +1840,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1834
1840
|
}
|
|
1835
1841
|
});
|
|
1836
1842
|
eagerValuesRef.current.panelDataArrayChanged = true;
|
|
1837
|
-
|
|
1843
|
+
forceUpdate();
|
|
1844
|
+
}, [forceUpdate]);
|
|
1838
1845
|
|
|
1839
1846
|
// (Re)calculate group layout whenever panels are registered or unregistered.
|
|
1840
1847
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -2066,8 +2073,9 @@ function PanelGroupWithForwardedRef({
|
|
|
2066
2073
|
// Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
|
|
2067
2074
|
delete panelIdToLastNotifiedSizeMapRef.current[panelData.id];
|
|
2068
2075
|
eagerValuesRef.current.panelDataArrayChanged = true;
|
|
2076
|
+
forceUpdate();
|
|
2069
2077
|
}
|
|
2070
|
-
}, []);
|
|
2078
|
+
}, [forceUpdate]);
|
|
2071
2079
|
const context = useMemo(() => ({
|
|
2072
2080
|
collapsePanel,
|
|
2073
2081
|
direction,
|
|
@@ -45,8 +45,8 @@ const {
|
|
|
45
45
|
useState
|
|
46
46
|
} = React__namespace;
|
|
47
47
|
|
|
48
|
-
// `
|
|
49
|
-
const useId = React__namespace[
|
|
48
|
+
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
|
|
49
|
+
const useId = React__namespace[`useId${Math.random()}`.slice(0, 5)];
|
|
50
50
|
const useLayoutEffect_do_not_use_directly = useLayoutEffect;
|
|
51
51
|
|
|
52
52
|
// The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
|
|
@@ -689,6 +689,11 @@ function updateResizeHandlerStates(action, event) {
|
|
|
689
689
|
});
|
|
690
690
|
}
|
|
691
691
|
|
|
692
|
+
function useForceUpdate() {
|
|
693
|
+
const [_, setCount] = useState(0);
|
|
694
|
+
return useCallback(() => setCount(prevCount => prevCount + 1), []);
|
|
695
|
+
}
|
|
696
|
+
|
|
692
697
|
function assert(expectedCondition, message) {
|
|
693
698
|
if (!expectedCondition) {
|
|
694
699
|
console.error(message);
|
|
@@ -1598,6 +1603,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1598
1603
|
const panelGroupElementRef = useRef(null);
|
|
1599
1604
|
const [dragState, setDragState] = useState(null);
|
|
1600
1605
|
const [layout, setLayout] = useState([]);
|
|
1606
|
+
const forceUpdate = useForceUpdate();
|
|
1601
1607
|
const panelIdToLastNotifiedSizeMapRef = useRef({});
|
|
1602
1608
|
const panelSizeBeforeCollapseRef = useRef(new Map());
|
|
1603
1609
|
const prevDeltaRef = useRef(0);
|
|
@@ -1860,7 +1866,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1860
1866
|
}
|
|
1861
1867
|
});
|
|
1862
1868
|
eagerValuesRef.current.panelDataArrayChanged = true;
|
|
1863
|
-
|
|
1869
|
+
forceUpdate();
|
|
1870
|
+
}, [forceUpdate]);
|
|
1864
1871
|
|
|
1865
1872
|
// (Re)calculate group layout whenever panels are registered or unregistered.
|
|
1866
1873
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -2092,8 +2099,9 @@ function PanelGroupWithForwardedRef({
|
|
|
2092
2099
|
// Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
|
|
2093
2100
|
delete panelIdToLastNotifiedSizeMapRef.current[panelData.id];
|
|
2094
2101
|
eagerValuesRef.current.panelDataArrayChanged = true;
|
|
2102
|
+
forceUpdate();
|
|
2095
2103
|
}
|
|
2096
|
-
}, []);
|
|
2104
|
+
}, [forceUpdate]);
|
|
2097
2105
|
const context = useMemo(() => ({
|
|
2098
2106
|
collapsePanel,
|
|
2099
2107
|
direction,
|
|
@@ -45,8 +45,8 @@ const {
|
|
|
45
45
|
useState
|
|
46
46
|
} = React__namespace;
|
|
47
47
|
|
|
48
|
-
// `
|
|
49
|
-
const useId = React__namespace[
|
|
48
|
+
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
|
|
49
|
+
const useId = React__namespace[`useId${Math.random()}`.slice(0, 5)];
|
|
50
50
|
const useLayoutEffect_do_not_use_directly = useLayoutEffect;
|
|
51
51
|
|
|
52
52
|
// The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
|
|
@@ -700,6 +700,11 @@ function updateResizeHandlerStates(action, event) {
|
|
|
700
700
|
});
|
|
701
701
|
}
|
|
702
702
|
|
|
703
|
+
function useForceUpdate() {
|
|
704
|
+
const [_, setCount] = useState(0);
|
|
705
|
+
return useCallback(() => setCount(prevCount => prevCount + 1), []);
|
|
706
|
+
}
|
|
707
|
+
|
|
703
708
|
function assert(expectedCondition, message) {
|
|
704
709
|
if (!expectedCondition) {
|
|
705
710
|
console.error(message);
|
|
@@ -1667,6 +1672,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1667
1672
|
const panelGroupElementRef = useRef(null);
|
|
1668
1673
|
const [dragState, setDragState] = useState(null);
|
|
1669
1674
|
const [layout, setLayout] = useState([]);
|
|
1675
|
+
const forceUpdate = useForceUpdate();
|
|
1670
1676
|
const panelIdToLastNotifiedSizeMapRef = useRef({});
|
|
1671
1677
|
const panelSizeBeforeCollapseRef = useRef(new Map());
|
|
1672
1678
|
const prevDeltaRef = useRef(0);
|
|
@@ -1971,7 +1977,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1971
1977
|
}
|
|
1972
1978
|
});
|
|
1973
1979
|
eagerValuesRef.current.panelDataArrayChanged = true;
|
|
1974
|
-
|
|
1980
|
+
forceUpdate();
|
|
1981
|
+
}, [forceUpdate]);
|
|
1975
1982
|
|
|
1976
1983
|
// (Re)calculate group layout whenever panels are registered or unregistered.
|
|
1977
1984
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -2203,8 +2210,9 @@ function PanelGroupWithForwardedRef({
|
|
|
2203
2210
|
// Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
|
|
2204
2211
|
delete panelIdToLastNotifiedSizeMapRef.current[panelData.id];
|
|
2205
2212
|
eagerValuesRef.current.panelDataArrayChanged = true;
|
|
2213
|
+
forceUpdate();
|
|
2206
2214
|
}
|
|
2207
|
-
}, []);
|
|
2215
|
+
}, [forceUpdate]);
|
|
2208
2216
|
const context = useMemo(() => ({
|
|
2209
2217
|
collapsePanel,
|
|
2210
2218
|
direction,
|
|
@@ -21,8 +21,8 @@ const {
|
|
|
21
21
|
useState
|
|
22
22
|
} = React;
|
|
23
23
|
|
|
24
|
-
// `
|
|
25
|
-
const useId = React[
|
|
24
|
+
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
|
|
25
|
+
const useId = React[`useId${Math.random()}`.slice(0, 5)];
|
|
26
26
|
const useLayoutEffect_do_not_use_directly = useLayoutEffect;
|
|
27
27
|
|
|
28
28
|
// The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
|
|
@@ -676,6 +676,11 @@ function updateResizeHandlerStates(action, event) {
|
|
|
676
676
|
});
|
|
677
677
|
}
|
|
678
678
|
|
|
679
|
+
function useForceUpdate() {
|
|
680
|
+
const [_, setCount] = useState(0);
|
|
681
|
+
return useCallback(() => setCount(prevCount => prevCount + 1), []);
|
|
682
|
+
}
|
|
683
|
+
|
|
679
684
|
function assert(expectedCondition, message) {
|
|
680
685
|
if (!expectedCondition) {
|
|
681
686
|
console.error(message);
|
|
@@ -1643,6 +1648,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1643
1648
|
const panelGroupElementRef = useRef(null);
|
|
1644
1649
|
const [dragState, setDragState] = useState(null);
|
|
1645
1650
|
const [layout, setLayout] = useState([]);
|
|
1651
|
+
const forceUpdate = useForceUpdate();
|
|
1646
1652
|
const panelIdToLastNotifiedSizeMapRef = useRef({});
|
|
1647
1653
|
const panelSizeBeforeCollapseRef = useRef(new Map());
|
|
1648
1654
|
const prevDeltaRef = useRef(0);
|
|
@@ -1947,7 +1953,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1947
1953
|
}
|
|
1948
1954
|
});
|
|
1949
1955
|
eagerValuesRef.current.panelDataArrayChanged = true;
|
|
1950
|
-
|
|
1956
|
+
forceUpdate();
|
|
1957
|
+
}, [forceUpdate]);
|
|
1951
1958
|
|
|
1952
1959
|
// (Re)calculate group layout whenever panels are registered or unregistered.
|
|
1953
1960
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -2179,8 +2186,9 @@ function PanelGroupWithForwardedRef({
|
|
|
2179
2186
|
// Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
|
|
2180
2187
|
delete panelIdToLastNotifiedSizeMapRef.current[panelData.id];
|
|
2181
2188
|
eagerValuesRef.current.panelDataArrayChanged = true;
|
|
2189
|
+
forceUpdate();
|
|
2182
2190
|
}
|
|
2183
|
-
}, []);
|
|
2191
|
+
}, [forceUpdate]);
|
|
2184
2192
|
const context = useMemo(() => ({
|
|
2185
2193
|
collapsePanel,
|
|
2186
2194
|
direction,
|
|
@@ -43,8 +43,8 @@ const {
|
|
|
43
43
|
useState
|
|
44
44
|
} = React__namespace;
|
|
45
45
|
|
|
46
|
-
// `
|
|
47
|
-
const useId = React__namespace[
|
|
46
|
+
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
|
|
47
|
+
const useId = React__namespace[`useId${Math.random()}`.slice(0, 5)];
|
|
48
48
|
|
|
49
49
|
// The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
|
|
50
50
|
|
|
@@ -662,6 +662,11 @@ function updateResizeHandlerStates(action, event) {
|
|
|
662
662
|
});
|
|
663
663
|
}
|
|
664
664
|
|
|
665
|
+
function useForceUpdate() {
|
|
666
|
+
const [_, setCount] = useState(0);
|
|
667
|
+
return useCallback(() => setCount(prevCount => prevCount + 1), []);
|
|
668
|
+
}
|
|
669
|
+
|
|
665
670
|
function assert(expectedCondition, message) {
|
|
666
671
|
if (!expectedCondition) {
|
|
667
672
|
console.error(message);
|
|
@@ -1499,6 +1504,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1499
1504
|
const panelGroupElementRef = useRef(null);
|
|
1500
1505
|
const [dragState, setDragState] = useState(null);
|
|
1501
1506
|
const [layout, setLayout] = useState([]);
|
|
1507
|
+
const forceUpdate = useForceUpdate();
|
|
1502
1508
|
const panelIdToLastNotifiedSizeMapRef = useRef({});
|
|
1503
1509
|
const panelSizeBeforeCollapseRef = useRef(new Map());
|
|
1504
1510
|
const prevDeltaRef = useRef(0);
|
|
@@ -1795,7 +1801,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1795
1801
|
}
|
|
1796
1802
|
});
|
|
1797
1803
|
eagerValuesRef.current.panelDataArrayChanged = true;
|
|
1798
|
-
|
|
1804
|
+
forceUpdate();
|
|
1805
|
+
}, [forceUpdate]);
|
|
1799
1806
|
const registerResizeHandle = useCallback(dragHandleId => {
|
|
1800
1807
|
return function resizeHandler(event) {
|
|
1801
1808
|
event.preventDefault();
|
|
@@ -1971,8 +1978,9 @@ function PanelGroupWithForwardedRef({
|
|
|
1971
1978
|
// Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
|
|
1972
1979
|
delete panelIdToLastNotifiedSizeMapRef.current[panelData.id];
|
|
1973
1980
|
eagerValuesRef.current.panelDataArrayChanged = true;
|
|
1981
|
+
forceUpdate();
|
|
1974
1982
|
}
|
|
1975
|
-
}, []);
|
|
1983
|
+
}, [forceUpdate]);
|
|
1976
1984
|
const context = useMemo(() => ({
|
|
1977
1985
|
collapsePanel,
|
|
1978
1986
|
direction,
|
|
@@ -19,8 +19,8 @@ const {
|
|
|
19
19
|
useState
|
|
20
20
|
} = React;
|
|
21
21
|
|
|
22
|
-
// `
|
|
23
|
-
const useId = React[
|
|
22
|
+
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
|
|
23
|
+
const useId = React[`useId${Math.random()}`.slice(0, 5)];
|
|
24
24
|
|
|
25
25
|
// The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
|
|
26
26
|
|
|
@@ -638,6 +638,11 @@ function updateResizeHandlerStates(action, event) {
|
|
|
638
638
|
});
|
|
639
639
|
}
|
|
640
640
|
|
|
641
|
+
function useForceUpdate() {
|
|
642
|
+
const [_, setCount] = useState(0);
|
|
643
|
+
return useCallback(() => setCount(prevCount => prevCount + 1), []);
|
|
644
|
+
}
|
|
645
|
+
|
|
641
646
|
function assert(expectedCondition, message) {
|
|
642
647
|
if (!expectedCondition) {
|
|
643
648
|
console.error(message);
|
|
@@ -1475,6 +1480,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1475
1480
|
const panelGroupElementRef = useRef(null);
|
|
1476
1481
|
const [dragState, setDragState] = useState(null);
|
|
1477
1482
|
const [layout, setLayout] = useState([]);
|
|
1483
|
+
const forceUpdate = useForceUpdate();
|
|
1478
1484
|
const panelIdToLastNotifiedSizeMapRef = useRef({});
|
|
1479
1485
|
const panelSizeBeforeCollapseRef = useRef(new Map());
|
|
1480
1486
|
const prevDeltaRef = useRef(0);
|
|
@@ -1771,7 +1777,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1771
1777
|
}
|
|
1772
1778
|
});
|
|
1773
1779
|
eagerValuesRef.current.panelDataArrayChanged = true;
|
|
1774
|
-
|
|
1780
|
+
forceUpdate();
|
|
1781
|
+
}, [forceUpdate]);
|
|
1775
1782
|
const registerResizeHandle = useCallback(dragHandleId => {
|
|
1776
1783
|
return function resizeHandler(event) {
|
|
1777
1784
|
event.preventDefault();
|
|
@@ -1947,8 +1954,9 @@ function PanelGroupWithForwardedRef({
|
|
|
1947
1954
|
// Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
|
|
1948
1955
|
delete panelIdToLastNotifiedSizeMapRef.current[panelData.id];
|
|
1949
1956
|
eagerValuesRef.current.panelDataArrayChanged = true;
|
|
1957
|
+
forceUpdate();
|
|
1950
1958
|
}
|
|
1951
|
-
}, []);
|
|
1959
|
+
}, [forceUpdate]);
|
|
1952
1960
|
const context = useMemo(() => ({
|
|
1953
1961
|
collapsePanel,
|
|
1954
1962
|
direction,
|
|
@@ -21,8 +21,8 @@ const {
|
|
|
21
21
|
useState
|
|
22
22
|
} = React;
|
|
23
23
|
|
|
24
|
-
// `
|
|
25
|
-
const useId = React[
|
|
24
|
+
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
|
|
25
|
+
const useId = React[`useId${Math.random()}`.slice(0, 5)];
|
|
26
26
|
const useLayoutEffect_do_not_use_directly = useLayoutEffect;
|
|
27
27
|
|
|
28
28
|
// The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
|
|
@@ -665,6 +665,11 @@ function updateResizeHandlerStates(action, event) {
|
|
|
665
665
|
});
|
|
666
666
|
}
|
|
667
667
|
|
|
668
|
+
function useForceUpdate() {
|
|
669
|
+
const [_, setCount] = useState(0);
|
|
670
|
+
return useCallback(() => setCount(prevCount => prevCount + 1), []);
|
|
671
|
+
}
|
|
672
|
+
|
|
668
673
|
function assert(expectedCondition, message) {
|
|
669
674
|
if (!expectedCondition) {
|
|
670
675
|
console.error(message);
|
|
@@ -1574,6 +1579,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1574
1579
|
const panelGroupElementRef = useRef(null);
|
|
1575
1580
|
const [dragState, setDragState] = useState(null);
|
|
1576
1581
|
const [layout, setLayout] = useState([]);
|
|
1582
|
+
const forceUpdate = useForceUpdate();
|
|
1577
1583
|
const panelIdToLastNotifiedSizeMapRef = useRef({});
|
|
1578
1584
|
const panelSizeBeforeCollapseRef = useRef(new Map());
|
|
1579
1585
|
const prevDeltaRef = useRef(0);
|
|
@@ -1836,7 +1842,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1836
1842
|
}
|
|
1837
1843
|
});
|
|
1838
1844
|
eagerValuesRef.current.panelDataArrayChanged = true;
|
|
1839
|
-
|
|
1845
|
+
forceUpdate();
|
|
1846
|
+
}, [forceUpdate]);
|
|
1840
1847
|
|
|
1841
1848
|
// (Re)calculate group layout whenever panels are registered or unregistered.
|
|
1842
1849
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -2068,8 +2075,9 @@ function PanelGroupWithForwardedRef({
|
|
|
2068
2075
|
// Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
|
|
2069
2076
|
delete panelIdToLastNotifiedSizeMapRef.current[panelData.id];
|
|
2070
2077
|
eagerValuesRef.current.panelDataArrayChanged = true;
|
|
2078
|
+
forceUpdate();
|
|
2071
2079
|
}
|
|
2072
|
-
}, []);
|
|
2080
|
+
}, [forceUpdate]);
|
|
2073
2081
|
const context = useMemo(() => ({
|
|
2074
2082
|
collapsePanel,
|
|
2075
2083
|
direction,
|
|
@@ -43,8 +43,8 @@ const {
|
|
|
43
43
|
useState
|
|
44
44
|
} = React__namespace;
|
|
45
45
|
|
|
46
|
-
// `
|
|
47
|
-
const useId = React__namespace[
|
|
46
|
+
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
|
|
47
|
+
const useId = React__namespace[`useId${Math.random()}`.slice(0, 5)];
|
|
48
48
|
|
|
49
49
|
// The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
|
|
50
50
|
|
|
@@ -651,6 +651,11 @@ function updateResizeHandlerStates(action, event) {
|
|
|
651
651
|
});
|
|
652
652
|
}
|
|
653
653
|
|
|
654
|
+
function useForceUpdate() {
|
|
655
|
+
const [_, setCount] = useState(0);
|
|
656
|
+
return useCallback(() => setCount(prevCount => prevCount + 1), []);
|
|
657
|
+
}
|
|
658
|
+
|
|
654
659
|
function assert(expectedCondition, message) {
|
|
655
660
|
if (!expectedCondition) {
|
|
656
661
|
console.error(message);
|
|
@@ -1440,6 +1445,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1440
1445
|
const panelGroupElementRef = useRef(null);
|
|
1441
1446
|
const [dragState, setDragState] = useState(null);
|
|
1442
1447
|
const [layout, setLayout] = useState([]);
|
|
1448
|
+
const forceUpdate = useForceUpdate();
|
|
1443
1449
|
const panelIdToLastNotifiedSizeMapRef = useRef({});
|
|
1444
1450
|
const panelSizeBeforeCollapseRef = useRef(new Map());
|
|
1445
1451
|
const prevDeltaRef = useRef(0);
|
|
@@ -1694,7 +1700,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1694
1700
|
}
|
|
1695
1701
|
});
|
|
1696
1702
|
eagerValuesRef.current.panelDataArrayChanged = true;
|
|
1697
|
-
|
|
1703
|
+
forceUpdate();
|
|
1704
|
+
}, [forceUpdate]);
|
|
1698
1705
|
const registerResizeHandle = useCallback(dragHandleId => {
|
|
1699
1706
|
return function resizeHandler(event) {
|
|
1700
1707
|
event.preventDefault();
|
|
@@ -1870,8 +1877,9 @@ function PanelGroupWithForwardedRef({
|
|
|
1870
1877
|
// Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
|
|
1871
1878
|
delete panelIdToLastNotifiedSizeMapRef.current[panelData.id];
|
|
1872
1879
|
eagerValuesRef.current.panelDataArrayChanged = true;
|
|
1880
|
+
forceUpdate();
|
|
1873
1881
|
}
|
|
1874
|
-
}, []);
|
|
1882
|
+
}, [forceUpdate]);
|
|
1875
1883
|
const context = useMemo(() => ({
|
|
1876
1884
|
collapsePanel,
|
|
1877
1885
|
direction,
|
|
@@ -19,8 +19,8 @@ const {
|
|
|
19
19
|
useState
|
|
20
20
|
} = React;
|
|
21
21
|
|
|
22
|
-
// `
|
|
23
|
-
const useId = React[
|
|
22
|
+
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
|
|
23
|
+
const useId = React[`useId${Math.random()}`.slice(0, 5)];
|
|
24
24
|
|
|
25
25
|
// The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
|
|
26
26
|
|
|
@@ -627,6 +627,11 @@ function updateResizeHandlerStates(action, event) {
|
|
|
627
627
|
});
|
|
628
628
|
}
|
|
629
629
|
|
|
630
|
+
function useForceUpdate() {
|
|
631
|
+
const [_, setCount] = useState(0);
|
|
632
|
+
return useCallback(() => setCount(prevCount => prevCount + 1), []);
|
|
633
|
+
}
|
|
634
|
+
|
|
630
635
|
function assert(expectedCondition, message) {
|
|
631
636
|
if (!expectedCondition) {
|
|
632
637
|
console.error(message);
|
|
@@ -1416,6 +1421,7 @@ function PanelGroupWithForwardedRef({
|
|
|
1416
1421
|
const panelGroupElementRef = useRef(null);
|
|
1417
1422
|
const [dragState, setDragState] = useState(null);
|
|
1418
1423
|
const [layout, setLayout] = useState([]);
|
|
1424
|
+
const forceUpdate = useForceUpdate();
|
|
1419
1425
|
const panelIdToLastNotifiedSizeMapRef = useRef({});
|
|
1420
1426
|
const panelSizeBeforeCollapseRef = useRef(new Map());
|
|
1421
1427
|
const prevDeltaRef = useRef(0);
|
|
@@ -1670,7 +1676,8 @@ function PanelGroupWithForwardedRef({
|
|
|
1670
1676
|
}
|
|
1671
1677
|
});
|
|
1672
1678
|
eagerValuesRef.current.panelDataArrayChanged = true;
|
|
1673
|
-
|
|
1679
|
+
forceUpdate();
|
|
1680
|
+
}, [forceUpdate]);
|
|
1674
1681
|
const registerResizeHandle = useCallback(dragHandleId => {
|
|
1675
1682
|
return function resizeHandler(event) {
|
|
1676
1683
|
event.preventDefault();
|
|
@@ -1846,8 +1853,9 @@ function PanelGroupWithForwardedRef({
|
|
|
1846
1853
|
// Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
|
|
1847
1854
|
delete panelIdToLastNotifiedSizeMapRef.current[panelData.id];
|
|
1848
1855
|
eagerValuesRef.current.panelDataArrayChanged = true;
|
|
1856
|
+
forceUpdate();
|
|
1849
1857
|
}
|
|
1850
|
-
}, []);
|
|
1858
|
+
}, [forceUpdate]);
|
|
1851
1859
|
const context = useMemo(() => ({
|
|
1852
1860
|
collapsePanel,
|
|
1853
1861
|
direction,
|
package/package.json
CHANGED
package/src/PanelGroup.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
EXCEEDED_VERTICAL_MIN,
|
|
14
14
|
reportConstraintsViolation,
|
|
15
15
|
} from "./PanelResizeHandleRegistry";
|
|
16
|
+
import { useForceUpdate } from "./hooks/useForceUpdate";
|
|
16
17
|
import useIsomorphicLayoutEffect from "./hooks/useIsomorphicEffect";
|
|
17
18
|
import useUniqueId from "./hooks/useUniqueId";
|
|
18
19
|
import { useWindowSplitterPanelGroupBehavior } from "./hooks/useWindowSplitterPanelGroupBehavior";
|
|
@@ -123,6 +124,7 @@ function PanelGroupWithForwardedRef({
|
|
|
123
124
|
const panelGroupElementRef = useRef<HTMLDivElement | null>(null);
|
|
124
125
|
const [dragState, setDragState] = useState<DragState | null>(null);
|
|
125
126
|
const [layout, setLayout] = useState<number[]>([]);
|
|
127
|
+
const forceUpdate = useForceUpdate();
|
|
126
128
|
|
|
127
129
|
const panelIdToLastNotifiedSizeMapRef = useRef<Record<string, number>>({});
|
|
128
130
|
const panelSizeBeforeCollapseRef = useRef<Map<string, number>>(new Map());
|
|
@@ -521,26 +523,31 @@ function PanelGroupWithForwardedRef({
|
|
|
521
523
|
return !collapsible || fuzzyCompareNumbers(panelSize, collapsedSize) > 0;
|
|
522
524
|
}, []);
|
|
523
525
|
|
|
524
|
-
const registerPanel = useCallback(
|
|
525
|
-
|
|
526
|
+
const registerPanel = useCallback(
|
|
527
|
+
(panelData: PanelData) => {
|
|
528
|
+
const { panelDataArray } = eagerValuesRef.current;
|
|
526
529
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
530
|
+
panelDataArray.push(panelData);
|
|
531
|
+
panelDataArray.sort((panelA, panelB) => {
|
|
532
|
+
const orderA = panelA.order;
|
|
533
|
+
const orderB = panelB.order;
|
|
534
|
+
if (orderA == null && orderB == null) {
|
|
535
|
+
return 0;
|
|
536
|
+
} else if (orderA == null) {
|
|
537
|
+
return -1;
|
|
538
|
+
} else if (orderB == null) {
|
|
539
|
+
return 1;
|
|
540
|
+
} else {
|
|
541
|
+
return orderA - orderB;
|
|
542
|
+
}
|
|
543
|
+
});
|
|
541
544
|
|
|
542
|
-
|
|
543
|
-
|
|
545
|
+
eagerValuesRef.current.panelDataArrayChanged = true;
|
|
546
|
+
|
|
547
|
+
forceUpdate();
|
|
548
|
+
},
|
|
549
|
+
[forceUpdate]
|
|
550
|
+
);
|
|
544
551
|
|
|
545
552
|
// (Re)calculate group layout whenever panels are registered or unregistered.
|
|
546
553
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -844,22 +851,27 @@ function PanelGroupWithForwardedRef({
|
|
|
844
851
|
setDragState(null);
|
|
845
852
|
}, []);
|
|
846
853
|
|
|
847
|
-
const unregisterPanel = useCallback(
|
|
848
|
-
|
|
854
|
+
const unregisterPanel = useCallback(
|
|
855
|
+
(panelData: PanelData) => {
|
|
856
|
+
const { panelDataArray } = eagerValuesRef.current;
|
|
849
857
|
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
858
|
+
const index = findPanelDataIndex(panelDataArray, panelData);
|
|
859
|
+
if (index >= 0) {
|
|
860
|
+
panelDataArray.splice(index, 1);
|
|
853
861
|
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
862
|
+
// TRICKY
|
|
863
|
+
// When a panel is removed from the group, we should delete the most recent prev-size entry for it.
|
|
864
|
+
// If we don't do this, then a conditionally rendered panel might not call onResize when it's re-mounted.
|
|
865
|
+
// Strict effects mode makes this tricky though because all panels will be registered, unregistered, then re-registered on mount.
|
|
866
|
+
delete panelIdToLastNotifiedSizeMapRef.current[panelData.id];
|
|
859
867
|
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
868
|
+
eagerValuesRef.current.panelDataArrayChanged = true;
|
|
869
|
+
|
|
870
|
+
forceUpdate();
|
|
871
|
+
}
|
|
872
|
+
},
|
|
873
|
+
[forceUpdate]
|
|
874
|
+
);
|
|
863
875
|
|
|
864
876
|
const context = useMemo(
|
|
865
877
|
() =>
|
package/src/vendor/react.ts
CHANGED
|
@@ -36,8 +36,10 @@ const {
|
|
|
36
36
|
useState,
|
|
37
37
|
} = React;
|
|
38
38
|
|
|
39
|
-
// `
|
|
40
|
-
const useId = (React as any)[
|
|
39
|
+
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
|
|
40
|
+
const useId = (React as any)[
|
|
41
|
+
`useId${Math.random()}`.slice(0, 5)
|
|
42
|
+
] as () => string;
|
|
41
43
|
|
|
42
44
|
const useLayoutEffect_do_not_use_directly = useLayoutEffect;
|
|
43
45
|
|