@linzjs/windows 3.5.4 → 3.6.1
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.
|
@@ -30,6 +30,7 @@ interface OpenPanelIconProps {
|
|
|
30
30
|
disabled?: boolean;
|
|
31
31
|
className?: string;
|
|
32
32
|
testId?: string;
|
|
33
|
+
isPoppedOut?: boolean;
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
export const OpenPanelIcon = ({
|
|
@@ -40,6 +41,7 @@ export const OpenPanelIcon = ({
|
|
|
40
41
|
className,
|
|
41
42
|
disabled,
|
|
42
43
|
testId,
|
|
44
|
+
isPoppedOut = false,
|
|
43
45
|
}: OpenPanelIconProps) => {
|
|
44
46
|
const { openPanel, openPanels } = useContext(PanelsContext);
|
|
45
47
|
const id = useRef(uniqueId ?? uuid());
|
|
@@ -54,7 +56,13 @@ export const OpenPanelIcon = ({
|
|
|
54
56
|
disabled && "OpenPanelIcon-disabled",
|
|
55
57
|
)}
|
|
56
58
|
title={iconTitle}
|
|
57
|
-
onClick={() =>
|
|
59
|
+
onClick={() =>
|
|
60
|
+
openPanel({
|
|
61
|
+
componentFn: component,
|
|
62
|
+
uniqueId: id.current,
|
|
63
|
+
isPoppedOut,
|
|
64
|
+
})
|
|
65
|
+
}
|
|
58
66
|
disabled={disabled}
|
|
59
67
|
data-testid={testId}
|
|
60
68
|
>
|
|
@@ -17,7 +17,8 @@ export const PanelInstanceContextProvider = ({
|
|
|
17
17
|
const { closePanel, bringPanelToFront } = useContext(PanelsContext);
|
|
18
18
|
const [title, setTitle] = useState("");
|
|
19
19
|
const [dockId, setDockId] = useState<string>();
|
|
20
|
-
|
|
20
|
+
|
|
21
|
+
const [poppedOut, setPoppedOut] = useState(panelInstance.poppedOut);
|
|
21
22
|
|
|
22
23
|
const togglePopOut = useCallback(() => {
|
|
23
24
|
panelInstance.window = null;
|
|
@@ -13,9 +13,15 @@ export interface PanelInstance {
|
|
|
13
13
|
window: Window | null;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
export interface OpenPanel {
|
|
17
|
+
componentFn: () => ReactElement;
|
|
18
|
+
isPoppedOut?: boolean;
|
|
19
|
+
uniqueId: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
16
22
|
export interface PanelsContextType {
|
|
17
23
|
openPanels: Set<string>;
|
|
18
|
-
openPanel: (
|
|
24
|
+
openPanel: (args: OpenPanel) => void;
|
|
19
25
|
closePanel: (panelInstance: PanelInstance) => void;
|
|
20
26
|
bringPanelToFront: (panelInstance: PanelInstance) => void;
|
|
21
27
|
nextStackPosition: () => PanelPosition;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PanelInstanceContextProvider } from "./PanelInstanceContextProvider";
|
|
2
|
-
import { PanelInstance, PanelPosition, PanelsContext } from "./PanelsContext";
|
|
2
|
+
import { OpenPanel, PanelInstance, PanelPosition, PanelsContext } from "./PanelsContext";
|
|
3
3
|
import { castArray, maxBy, sortBy } from "lodash-es";
|
|
4
4
|
import React, { Fragment, PropsWithChildren, ReactElement, useCallback, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { useInterval } from "usehooks-ts";
|
|
@@ -54,7 +54,7 @@ export const PanelsContextProvider = ({
|
|
|
54
54
|
);
|
|
55
55
|
|
|
56
56
|
const openPanel = useCallback(
|
|
57
|
-
(
|
|
57
|
+
({ componentFn, isPoppedOut = false, uniqueId }: OpenPanel): void => {
|
|
58
58
|
try {
|
|
59
59
|
const existingPanelInstance = panelInstances.find((pi) => pi.uniqueId === uniqueId);
|
|
60
60
|
if (existingPanelInstance) {
|
|
@@ -73,7 +73,7 @@ export const PanelsContextProvider = ({
|
|
|
73
73
|
uniqueId,
|
|
74
74
|
componentInstance: componentFn(),
|
|
75
75
|
zIndex: baseZIndex + panelInstances.length,
|
|
76
|
-
poppedOut:
|
|
76
|
+
poppedOut: isPoppedOut,
|
|
77
77
|
window: null,
|
|
78
78
|
},
|
|
79
79
|
]);
|