@linzjs/windows 7.1.0 → 7.2.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/dist/panel/Panel.tsx
CHANGED
|
@@ -107,7 +107,7 @@ export const Panel = (props: PanelProps): ReactElement => {
|
|
|
107
107
|
}, []);
|
|
108
108
|
|
|
109
109
|
const [panelSize, _setPanelSize] = useState<NumberSize>(() => {
|
|
110
|
-
if (savedState?.panelSize) {
|
|
110
|
+
if (!ignoreSavedState && savedState?.panelSize) {
|
|
111
111
|
return cropSizeToWindow(savedState.panelSize);
|
|
112
112
|
}
|
|
113
113
|
|
|
@@ -48,7 +48,7 @@ export const PanelInstanceContextProvider = ({
|
|
|
48
48
|
panelClose: () => {
|
|
49
49
|
panelInstance.window?.close();
|
|
50
50
|
panelInstance.window = null;
|
|
51
|
-
closePanel(panelInstance);
|
|
51
|
+
closePanel(panelInstance.uniqueId);
|
|
52
52
|
},
|
|
53
53
|
panelTogglePopout: togglePopOut,
|
|
54
54
|
panelPoppedOut: poppedOut,
|
|
@@ -21,8 +21,9 @@ export interface OpenPanelOptions {
|
|
|
21
21
|
|
|
22
22
|
export interface PanelsContextType {
|
|
23
23
|
openPanels: Set<string>;
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
// returns unique id of panel that was created/or arleady found, otherwise null on error.
|
|
25
|
+
openPanel: (args: OpenPanelOptions) => string | null;
|
|
26
|
+
closePanel: (uniqueId: string) => void;
|
|
26
27
|
bringPanelToFront: (panelInstance: PanelInstance) => void;
|
|
27
28
|
nextStackPosition: () => PanelPosition;
|
|
28
29
|
dockElements: Record<string, HTMLDivElement>;
|
|
@@ -30,8 +31,9 @@ export interface PanelsContextType {
|
|
|
30
31
|
panelStateOptions?: PanelStateOptions | null;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
const NoContext = () => {
|
|
34
|
+
const NoContext = <T,>(): T => {
|
|
34
35
|
console.error('Missing PanelContext Provider');
|
|
36
|
+
return undefined as T;
|
|
35
37
|
};
|
|
36
38
|
|
|
37
39
|
export const PanelsContext = createContext<PanelsContextType>({
|
|
@@ -67,7 +67,7 @@ export const PanelsContextProvider = ({
|
|
|
67
67
|
);
|
|
68
68
|
|
|
69
69
|
const openPanel = useCallback(
|
|
70
|
-
({ componentFn, poppedOut = false, uniqueId = v4(), onClose }: OpenPanelOptions):
|
|
70
|
+
({ componentFn, poppedOut = false, uniqueId = v4(), onClose }: OpenPanelOptions): string | null => {
|
|
71
71
|
try {
|
|
72
72
|
const existingPanelInstance = panelInstances.find((pi) => pi.uniqueId === uniqueId);
|
|
73
73
|
if (existingPanelInstance) {
|
|
@@ -76,7 +76,7 @@ export const PanelsContextProvider = ({
|
|
|
76
76
|
} else {
|
|
77
77
|
bringPanelToFront(existingPanelInstance);
|
|
78
78
|
}
|
|
79
|
-
return;
|
|
79
|
+
return existingPanelInstance.uniqueId;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
// If there are any exceptions the modal won't show
|
|
@@ -91,16 +91,18 @@ export const PanelsContextProvider = ({
|
|
|
91
91
|
onClose,
|
|
92
92
|
},
|
|
93
93
|
]);
|
|
94
|
+
return uniqueId;
|
|
94
95
|
} catch (e) {
|
|
95
96
|
console.error(e);
|
|
97
|
+
return null;
|
|
96
98
|
}
|
|
97
99
|
},
|
|
98
100
|
[baseZIndex, bringPanelToFront, panelInstances],
|
|
99
101
|
);
|
|
100
102
|
|
|
101
103
|
const closePanel = useCallback(
|
|
102
|
-
(
|
|
103
|
-
const panelNames = castArray(
|
|
104
|
+
(closePanelUniqueIds: string | string[]) => {
|
|
105
|
+
const panelNames = castArray(closePanelUniqueIds);
|
|
104
106
|
const [closedPanelInstances, stillOpenPanelInstances] = partition(panelInstances, (pi) =>
|
|
105
107
|
panelNames.includes(pi.uniqueId),
|
|
106
108
|
);
|
|
@@ -120,7 +122,7 @@ export const PanelsContextProvider = ({
|
|
|
120
122
|
*/
|
|
121
123
|
useInterval(() => {
|
|
122
124
|
// close any panels that have a window that is closed
|
|
123
|
-
closePanel(panelInstances.filter((pi) => pi.window?.closed));
|
|
125
|
+
closePanel(panelInstances.filter((pi) => pi.window?.closed).map((panel) => panel.uniqueId));
|
|
124
126
|
}, 500);
|
|
125
127
|
|
|
126
128
|
/**
|