@linzjs/windows 4.1.1 → 4.1.3
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.
|
@@ -17,6 +17,7 @@ import React, {
|
|
|
17
17
|
} from "react";
|
|
18
18
|
import { createPortal } from "react-dom";
|
|
19
19
|
import { useInterval } from "usehooks-ts";
|
|
20
|
+
import { v4 } from "uuid";
|
|
20
21
|
|
|
21
22
|
export interface LuiModalAsyncInstance {
|
|
22
23
|
uuid: string;
|
|
@@ -106,7 +107,7 @@ export const LuiModalAsyncContextProvider = ({ children }: PropsWithChildren<unk
|
|
|
106
107
|
args: any,
|
|
107
108
|
showModalProps?: ShowModalProps,
|
|
108
109
|
): PromiseWithResolve<any> => {
|
|
109
|
-
const uuid =
|
|
110
|
+
const uuid = v4();
|
|
110
111
|
let extResolve: PromiseWithResolve<any>["resolve"];
|
|
111
112
|
const promise = new Promise((resolve) => {
|
|
112
113
|
extResolve = resolve;
|
package/dist/panel/Panel.tsx
CHANGED
|
@@ -6,13 +6,14 @@ import { PanelInstanceContext } from "./PanelInstanceContext";
|
|
|
6
6
|
import { PanelsContext } from "./PanelsContext";
|
|
7
7
|
import { PopoutWindow } from "./PopoutWindow";
|
|
8
8
|
import clsx from "clsx";
|
|
9
|
-
import { PropsWithChildren, ReactElement, useContext, useEffect, useMemo } from "react";
|
|
9
|
+
import { PropsWithChildren, ReactElement, useContext, useEffect, useMemo, useRef } from "react";
|
|
10
10
|
import { createPortal } from "react-dom";
|
|
11
11
|
import { PopinWindow } from "./PopinWIndow";
|
|
12
12
|
import { PanelProps } from "./types/PanelProps";
|
|
13
13
|
import { useConstFunction } from "../common";
|
|
14
14
|
|
|
15
15
|
export const Panel = (props: PanelProps): ReactElement => {
|
|
16
|
+
const panelRef = useRef<HTMLDivElement>(null);
|
|
16
17
|
const { title, size = { width: 320, height: 200 }, className, children, onClose } = props;
|
|
17
18
|
|
|
18
19
|
const { dockElements, nextStackPosition } = useContext(PanelsContext);
|
|
@@ -30,6 +31,16 @@ export const Panel = (props: PanelProps): ReactElement => {
|
|
|
30
31
|
setTitle(title);
|
|
31
32
|
}, [setTitle, title]);
|
|
32
33
|
|
|
34
|
+
// We only want to update the title when it changes
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (panelRef.current) {
|
|
37
|
+
const doc = panelRef.current.ownerDocument;
|
|
38
|
+
if (doc) {
|
|
39
|
+
doc.title = title;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}, [title]);
|
|
43
|
+
|
|
33
44
|
const dockElement = docked && dockId && dockElements[dockId];
|
|
34
45
|
|
|
35
46
|
/**
|
|
@@ -55,6 +66,7 @@ export const Panel = (props: PanelProps): ReactElement => {
|
|
|
55
66
|
) : panelPoppedOut ? (
|
|
56
67
|
<PopoutWindow name={uniqueId} title={title} size={size}>
|
|
57
68
|
<div
|
|
69
|
+
ref={panelRef}
|
|
58
70
|
style={{
|
|
59
71
|
display: "flex",
|
|
60
72
|
flexDirection: "column",
|
|
@@ -5,6 +5,7 @@ import React, { Fragment, PropsWithChildren, ReactElement, useCallback, useMemo,
|
|
|
5
5
|
import { useInterval } from "usehooks-ts";
|
|
6
6
|
import { PanelStateOptions } from "./types/PanelStateOptions";
|
|
7
7
|
import { PanelPosition } from "./types";
|
|
8
|
+
import { v4 } from "uuid";
|
|
8
9
|
|
|
9
10
|
export interface PanelsContextProviderProps {
|
|
10
11
|
baseZIndex?: number;
|
|
@@ -58,7 +59,7 @@ export const PanelsContextProvider = ({
|
|
|
58
59
|
);
|
|
59
60
|
|
|
60
61
|
const openPanel = useCallback(
|
|
61
|
-
({ componentFn, poppedOut = false, uniqueId =
|
|
62
|
+
({ componentFn, poppedOut = false, uniqueId = v4() }: OpenPanelOptions): void => {
|
|
62
63
|
try {
|
|
63
64
|
const existingPanelInstance = panelInstances.find((pi) => pi.uniqueId === uniqueId);
|
|
64
65
|
if (existingPanelInstance) {
|
|
@@ -3,7 +3,7 @@ import { makePopoutId, popoutWindowDivId } from "./generateId";
|
|
|
3
3
|
import { copyStyleSheets, observeStyleSheetChanges } from "./handleStyleSheetsChanges";
|
|
4
4
|
import createCache from "@emotion/cache";
|
|
5
5
|
import { CacheProvider } from "@emotion/react";
|
|
6
|
-
import { Dispatch, ReactElement, ReactNode, SetStateAction, useContext, useEffect,
|
|
6
|
+
import { Dispatch, ReactElement, ReactNode, SetStateAction, useContext, useEffect, useState } from "react";
|
|
7
7
|
import ReactDOM from "react-dom";
|
|
8
8
|
import { useRestoreStateFrom, useSaveStateIn } from "./usePanelStateHandler";
|
|
9
9
|
import { PanelPosition, PanelSize } from "./types";
|
|
@@ -128,18 +128,9 @@ export const PopoutWindow = ({
|
|
|
128
128
|
}: PopoutWindowProps): ReactElement | null => {
|
|
129
129
|
const { setPanelWindow } = useContext(PanelInstanceContext);
|
|
130
130
|
|
|
131
|
-
const extWindow = useRef<Window | null>(null);
|
|
132
|
-
|
|
133
131
|
const [containerElement, setContainerElement] = useState<HTMLElement>();
|
|
134
132
|
const [headElement, setHeadElement] = useState<HTMLElement>();
|
|
135
133
|
|
|
136
|
-
// We only want to update the title when it changes
|
|
137
|
-
useEffect(() => {
|
|
138
|
-
if (extWindow.current) {
|
|
139
|
-
extWindow.current.document.title = title;
|
|
140
|
-
}
|
|
141
|
-
}, [title]);
|
|
142
|
-
|
|
143
134
|
const savedState = useRestoreStateFrom({ panelPoppedOut: true, uniqueId: name });
|
|
144
135
|
|
|
145
136
|
const panelPosition = savedState?.panelPosition ?? { x: 300, y: 200 };
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"popout"
|
|
14
14
|
],
|
|
15
15
|
"main": "./dist/index.ts",
|
|
16
|
-
"version": "4.1.
|
|
16
|
+
"version": "4.1.3",
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"@linzjs/lui": ">=21",
|
|
19
19
|
"lodash-es": ">=4",
|
|
@@ -49,9 +49,11 @@
|
|
|
49
49
|
"@emotion/cache": "^11.13.5",
|
|
50
50
|
"@emotion/react": "^11.13.5",
|
|
51
51
|
"@emotion/styled": "^11.13.5",
|
|
52
|
+
"@types/uuid": "^10.0.0",
|
|
52
53
|
"lodash-es": ">=4",
|
|
53
54
|
"react-rnd": "^10.4.13",
|
|
54
|
-
"usehooks-ts": "^3.1.0"
|
|
55
|
+
"usehooks-ts": "^3.1.0",
|
|
56
|
+
"uuid": "^11.0.4"
|
|
55
57
|
},
|
|
56
58
|
"devDependencies": {
|
|
57
59
|
"@chromatic-com/storybook": "^3.2.2",
|