@linzjs/windows 4.0.0 → 4.0.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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./useConstFunction";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* When calling external non-react components, and you can't update the function when state changes,
|
|
5
|
+
* use this to proxy the dynamic function with a static function.
|
|
6
|
+
*/
|
|
7
|
+
export const useConstFunction = <Args extends never[], R, TFn extends (...args: Args) => R>(fn: TFn): TFn => {
|
|
8
|
+
const functionRef = useRef<TFn>(fn);
|
|
9
|
+
const proxyRef = useRef<TFn>(((...args: Args) => functionRef.current(...args)) as TFn);
|
|
10
|
+
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
functionRef.current = fn;
|
|
13
|
+
}, [fn]);
|
|
14
|
+
|
|
15
|
+
return proxyRef.current;
|
|
16
|
+
};
|
|
@@ -60,15 +60,13 @@ export const PanelHeader = ({
|
|
|
60
60
|
</div>
|
|
61
61
|
{(dockTo || !disablePopout || !disableClose) && <div className={"WindowPanel-divider-right"} />}
|
|
62
62
|
<div className={"WindowPanel-buttons"}>
|
|
63
|
-
{
|
|
63
|
+
{onDockClick && <PanelHeaderButton aria-label={"Dock"} onClick={() => onDockClick()} icon={"ic_left_col"} />}
|
|
64
|
+
{!onDockClick &&
|
|
65
|
+
dockTo &&
|
|
64
66
|
(docked ? (
|
|
65
67
|
<PanelHeaderButton aria-label={"Undock"} onClick={undock} icon={"ic_close_list"} />
|
|
66
68
|
) : (
|
|
67
|
-
<PanelHeaderButton
|
|
68
|
-
aria-label={"Dock"}
|
|
69
|
-
onClick={() => (onDockClick ? onDockClick() : dock(dockTo))}
|
|
70
|
-
icon={"ic_left_col"}
|
|
71
|
-
/>
|
|
69
|
+
<PanelHeaderButton aria-label={"Dock"} onClick={() => dock(dockTo)} icon={"ic_left_col"} />
|
|
72
70
|
))}
|
|
73
71
|
{!disablePopout && (
|
|
74
72
|
<PanelHeaderButton
|