@linzjs/windows 3.7.0 → 4.0.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/LuiModalAsync/LuiModalAsyncContextProvider.tsx +1 -2
- package/dist/index.ts +1 -0
- package/dist/panel/OpenPanelButton.tsx +6 -6
- package/dist/panel/OpenPanelIcon.tsx +6 -18
- package/dist/panel/Panel.tsx +11 -0
- package/dist/panel/PanelHeader.tsx +7 -1
- package/dist/panel/PanelInstanceContextProvider.tsx +2 -2
- package/dist/panel/PanelsContext.tsx +4 -4
- package/dist/panel/PanelsContextProvider.tsx +3 -3
- package/package.json +18 -18
|
@@ -17,7 +17,6 @@ import React, {
|
|
|
17
17
|
} from "react";
|
|
18
18
|
import { createPortal } from "react-dom";
|
|
19
19
|
import { useInterval } from "usehooks-ts";
|
|
20
|
-
import { v4 as makeUuid } from "uuid";
|
|
21
20
|
|
|
22
21
|
export interface LuiModalAsyncInstance {
|
|
23
22
|
uuid: string;
|
|
@@ -107,7 +106,7 @@ export const LuiModalAsyncContextProvider = ({ children }: PropsWithChildren<unk
|
|
|
107
106
|
args: any,
|
|
108
107
|
showModalProps?: ShowModalProps,
|
|
109
108
|
): PromiseWithResolve<any> => {
|
|
110
|
-
const uuid =
|
|
109
|
+
const uuid = crypto.randomUUID();
|
|
111
110
|
let extResolve: PromiseWithResolve<any>["resolve"];
|
|
112
111
|
const promise = new Promise((resolve) => {
|
|
113
112
|
extResolve = resolve;
|
package/dist/index.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
// Simple button to open panel and show panel state
|
|
2
|
-
import { PanelsContext } from "./PanelsContext";
|
|
3
|
-
import {
|
|
2
|
+
import { OpenPanelOptions, PanelsContext } from "./PanelsContext";
|
|
3
|
+
import { useContext } from "react";
|
|
4
4
|
|
|
5
|
-
interface OpenPanelButtonProps {
|
|
5
|
+
interface OpenPanelButtonProps extends OpenPanelOptions {
|
|
6
|
+
uniqueId?: string;
|
|
6
7
|
buttonText: string;
|
|
7
|
-
component: () => ReactElement;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export const OpenPanelButton = ({ buttonText,
|
|
10
|
+
export const OpenPanelButton = ({ buttonText, ...openPanelOptions }: OpenPanelButtonProps) => {
|
|
11
11
|
const { openPanel, openPanels } = useContext(PanelsContext);
|
|
12
12
|
|
|
13
13
|
return (
|
|
14
|
-
<button onClick={() => openPanel(
|
|
14
|
+
<button onClick={() => openPanel(openPanelOptions)}>
|
|
15
15
|
Show {buttonText} {openPanels.has(buttonText) ? "(Open)" : ""}
|
|
16
16
|
</button>
|
|
17
17
|
);
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import "./OpenPanelIcon.scss";
|
|
2
2
|
|
|
3
|
-
import { PanelsContext } from "./PanelsContext";
|
|
3
|
+
import { OpenPanelOptions, PanelsContext } from "./PanelsContext";
|
|
4
4
|
import clsx from "clsx";
|
|
5
|
-
import {
|
|
6
|
-
import { v4 as uuid } from "uuid";
|
|
5
|
+
import { ReactNode, useContext, useRef } from "react";
|
|
7
6
|
|
|
8
7
|
import { LuiIcon } from "@linzjs/lui";
|
|
9
8
|
import { IconName } from "@linzjs/lui/dist/components/LuiIcon/LuiIcon";
|
|
@@ -22,29 +21,24 @@ export const ButtonIconVerticalGroup = ({ children }: { children: ReactNode }) =
|
|
|
22
21
|
|
|
23
22
|
export const ButtonIconSeparator = () => <div className="OpenPanelIcon-separator"> </div>;
|
|
24
23
|
|
|
25
|
-
interface OpenPanelIconProps {
|
|
26
|
-
uniqueId?: string;
|
|
24
|
+
interface OpenPanelIconProps extends OpenPanelOptions {
|
|
27
25
|
iconTitle: string;
|
|
28
26
|
icon: IconName;
|
|
29
|
-
component: () => ReactElement;
|
|
30
27
|
disabled?: boolean;
|
|
31
28
|
className?: string;
|
|
32
29
|
testId?: string;
|
|
33
|
-
isPoppedOut?: boolean;
|
|
34
30
|
}
|
|
35
31
|
|
|
36
32
|
export const OpenPanelIcon = ({
|
|
37
33
|
iconTitle,
|
|
38
|
-
uniqueId,
|
|
39
34
|
icon,
|
|
40
|
-
component,
|
|
41
35
|
className,
|
|
42
36
|
disabled,
|
|
43
37
|
testId,
|
|
44
|
-
|
|
38
|
+
...openPanelOptions
|
|
45
39
|
}: OpenPanelIconProps) => {
|
|
46
40
|
const { openPanel, openPanels } = useContext(PanelsContext);
|
|
47
|
-
const id = useRef(uniqueId ??
|
|
41
|
+
const id = useRef(openPanelOptions.uniqueId ?? crypto.randomUUID());
|
|
48
42
|
|
|
49
43
|
return (
|
|
50
44
|
<button
|
|
@@ -56,13 +50,7 @@ export const OpenPanelIcon = ({
|
|
|
56
50
|
disabled && "OpenPanelIcon-disabled",
|
|
57
51
|
)}
|
|
58
52
|
title={iconTitle}
|
|
59
|
-
onClick={() =>
|
|
60
|
-
openPanel({
|
|
61
|
-
componentFn: component,
|
|
62
|
-
uniqueId: id.current,
|
|
63
|
-
isPoppedOut,
|
|
64
|
-
})
|
|
65
|
-
}
|
|
53
|
+
onClick={() => openPanel(openPanelOptions)}
|
|
66
54
|
disabled={disabled}
|
|
67
55
|
data-testid={testId}
|
|
68
56
|
>
|
package/dist/panel/Panel.tsx
CHANGED
|
@@ -19,6 +19,7 @@ import React, {
|
|
|
19
19
|
} from "react";
|
|
20
20
|
import { createPortal } from "react-dom";
|
|
21
21
|
import { Rnd } from "react-rnd";
|
|
22
|
+
import { useConstFunction } from "../common/useConstFunction";
|
|
22
23
|
|
|
23
24
|
export interface PanelProps {
|
|
24
25
|
title: string;
|
|
@@ -32,10 +33,12 @@ export interface PanelProps {
|
|
|
32
33
|
minWidth?: number | string;
|
|
33
34
|
modal?: boolean;
|
|
34
35
|
resizeable?: boolean;
|
|
36
|
+
onClose?: () => void;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
export const Panel = ({
|
|
38
40
|
title,
|
|
41
|
+
onClose,
|
|
39
42
|
size = { width: 320, height: 200 },
|
|
40
43
|
maxHeight,
|
|
41
44
|
maxWidth,
|
|
@@ -53,6 +56,14 @@ export const Panel = ({
|
|
|
53
56
|
const { panelPoppedOut, bounds, zIndex, bringPanelToFront, uniqueId, setTitle, dockId, docked } =
|
|
54
57
|
useContext(PanelInstanceContext);
|
|
55
58
|
|
|
59
|
+
const onCloseConstFn = useConstFunction(onClose ?? (() => {}));
|
|
60
|
+
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
return () => {
|
|
63
|
+
onCloseConstFn?.();
|
|
64
|
+
};
|
|
65
|
+
}, [onCloseConstFn]);
|
|
66
|
+
|
|
56
67
|
const [panelPosition, setPanelPosition] = useState(() => {
|
|
57
68
|
switch (position) {
|
|
58
69
|
case "center":
|
|
@@ -13,6 +13,7 @@ export interface PanelHeaderProps {
|
|
|
13
13
|
extraRight?: ReactNode;
|
|
14
14
|
helpUrl?: string;
|
|
15
15
|
onHelpClick?: () => void;
|
|
16
|
+
onDockClick?: () => void;
|
|
16
17
|
dockTo?: string;
|
|
17
18
|
disableClose?: boolean;
|
|
18
19
|
disablePopout?: boolean;
|
|
@@ -24,6 +25,7 @@ export const PanelHeader = ({
|
|
|
24
25
|
extraRight,
|
|
25
26
|
helpUrl,
|
|
26
27
|
onHelpClick,
|
|
28
|
+
onDockClick,
|
|
27
29
|
dockTo,
|
|
28
30
|
disableClose,
|
|
29
31
|
disablePopout,
|
|
@@ -62,7 +64,11 @@ export const PanelHeader = ({
|
|
|
62
64
|
(docked ? (
|
|
63
65
|
<PanelHeaderButton aria-label={"Undock"} onClick={undock} icon={"ic_close_list"} />
|
|
64
66
|
) : (
|
|
65
|
-
<PanelHeaderButton
|
|
67
|
+
<PanelHeaderButton
|
|
68
|
+
aria-label={"Dock"}
|
|
69
|
+
onClick={() => (onDockClick ? onDockClick() : dock(dockTo))}
|
|
70
|
+
icon={"ic_left_col"}
|
|
71
|
+
/>
|
|
66
72
|
))}
|
|
67
73
|
{!disablePopout && (
|
|
68
74
|
<PanelHeaderButton
|
|
@@ -14,7 +14,7 @@ export const PanelInstanceContextProvider = ({
|
|
|
14
14
|
panelInstance: PanelInstance;
|
|
15
15
|
children: ReactNode;
|
|
16
16
|
}): ReactElement => {
|
|
17
|
-
const { closePanel, bringPanelToFront } = useContext(PanelsContext);
|
|
17
|
+
const { closePanel, bringPanelToFront, dockElements } = useContext(PanelsContext);
|
|
18
18
|
const [title, setTitle] = useState("");
|
|
19
19
|
const [dockId, setDockId] = useState<string>();
|
|
20
20
|
|
|
@@ -55,7 +55,7 @@ export const PanelInstanceContextProvider = ({
|
|
|
55
55
|
},
|
|
56
56
|
bringPanelToFront: () => bringPanelToFront(panelInstance),
|
|
57
57
|
zIndex: panelInstance.zIndex,
|
|
58
|
-
docked: !poppedOut && !!dockId,
|
|
58
|
+
docked: !poppedOut && !!dockId && !!dockElements[dockId],
|
|
59
59
|
dockId,
|
|
60
60
|
dock,
|
|
61
61
|
undock,
|
|
@@ -13,15 +13,15 @@ export interface PanelInstance {
|
|
|
13
13
|
window: Window | null;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export interface
|
|
16
|
+
export interface OpenPanelOptions {
|
|
17
|
+
uniqueId?: string;
|
|
17
18
|
componentFn: () => ReactElement;
|
|
18
|
-
|
|
19
|
-
uniqueId: string;
|
|
19
|
+
poppedOut?: boolean;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export interface PanelsContextType {
|
|
23
23
|
openPanels: Set<string>;
|
|
24
|
-
openPanel: (args:
|
|
24
|
+
openPanel: (args: OpenPanelOptions) => void;
|
|
25
25
|
closePanel: (panelInstance: PanelInstance) => void;
|
|
26
26
|
bringPanelToFront: (panelInstance: PanelInstance) => void;
|
|
27
27
|
nextStackPosition: () => PanelPosition;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PanelInstanceContextProvider } from "./PanelInstanceContextProvider";
|
|
2
|
-
import {
|
|
2
|
+
import { OpenPanelOptions, 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
|
-
({ componentFn,
|
|
57
|
+
({ componentFn, poppedOut = false, uniqueId = crypto.randomUUID() }: OpenPanelOptions): 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,
|
|
77
77
|
window: null,
|
|
78
78
|
},
|
|
79
79
|
]);
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"popout"
|
|
14
14
|
],
|
|
15
15
|
"main": "./dist/index.ts",
|
|
16
|
-
"version": "
|
|
16
|
+
"version": "4.0.0",
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"@linzjs/lui": ">=21",
|
|
19
19
|
"lodash-es": ">=4",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"build": "run-s clean stylelint lint lint-circular-deps bundle",
|
|
35
35
|
"yalc": "run-s clean bundle && yalc publish",
|
|
36
36
|
"clean": "rimraf dist && mkdirp ./dist",
|
|
37
|
-
"bundle": "rollup -c",
|
|
37
|
+
"bundle": "tsc --noEmit && rollup -c",
|
|
38
38
|
"test": "jest",
|
|
39
39
|
"stylelint": "stylelint src/**/*.scss src/**/*.css --fix",
|
|
40
40
|
"lint": "eslint ./src --ext .js,.ts,.tsx --fix --cache --ignore-path .gitignore",
|
|
@@ -51,8 +51,7 @@
|
|
|
51
51
|
"@emotion/styled": "^11.13.5",
|
|
52
52
|
"lodash-es": ">=4",
|
|
53
53
|
"react-rnd": "^10.4.13",
|
|
54
|
-
"usehooks-ts": "^3.1.0"
|
|
55
|
-
"uuid": "^11.0.3"
|
|
54
|
+
"usehooks-ts": "^3.1.0"
|
|
56
55
|
},
|
|
57
56
|
"devDependencies": {
|
|
58
57
|
"@chromatic-com/storybook": "^3.2.2",
|
|
@@ -63,16 +62,15 @@
|
|
|
63
62
|
"@rollup/plugin-commonjs": "^28.0.1",
|
|
64
63
|
"@rollup/plugin-json": "^6.1.0",
|
|
65
64
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
66
|
-
"@storybook/addon-docs": "^8.4.
|
|
67
|
-
"@storybook/addon-essentials": "^8.4.
|
|
68
|
-
"@storybook/addon-interactions": "^8.4.
|
|
69
|
-
"@storybook/addon-links": "^8.4.
|
|
70
|
-
"@storybook/addon-mdx-gfm": "^8.4.
|
|
71
|
-
"@storybook/blocks": "^8.4.
|
|
72
|
-
"@storybook/react": "^8.4.
|
|
73
|
-
"@storybook/react-vite": "^8.4.
|
|
74
|
-
"@storybook/test": "^8.4.
|
|
75
|
-
"@storybook/test-runner": "^0.20.0",
|
|
65
|
+
"@storybook/addon-docs": "^8.4.7",
|
|
66
|
+
"@storybook/addon-essentials": "^8.4.7",
|
|
67
|
+
"@storybook/addon-interactions": "^8.4.7",
|
|
68
|
+
"@storybook/addon-links": "^8.4.7",
|
|
69
|
+
"@storybook/addon-mdx-gfm": "^8.4.7",
|
|
70
|
+
"@storybook/blocks": "^8.4.7",
|
|
71
|
+
"@storybook/react": "^8.4.7",
|
|
72
|
+
"@storybook/react-vite": "^8.4.7",
|
|
73
|
+
"@storybook/test": "^8.4.7",
|
|
76
74
|
"@testing-library/jest-dom": "^6.6.3",
|
|
77
75
|
"@testing-library/react": "^16.0.1",
|
|
78
76
|
"@testing-library/user-event": "^14.5.2",
|
|
@@ -82,7 +80,6 @@
|
|
|
82
80
|
"@types/node": "^22.10.1",
|
|
83
81
|
"@types/react": "^18.3.12",
|
|
84
82
|
"@types/react-dom": "^18.3.1",
|
|
85
|
-
"@types/uuid": "^10.0.0",
|
|
86
83
|
"@typescript-eslint/eslint-plugin": "^7.17.0",
|
|
87
84
|
"@typescript-eslint/parser": "^7.17.0",
|
|
88
85
|
"ag-grid-community": "^32.3.3",
|
|
@@ -112,10 +109,10 @@
|
|
|
112
109
|
"react-dom": "^18.3.1",
|
|
113
110
|
"rollup": "^4.28.0",
|
|
114
111
|
"rollup-plugin-copy": "^3.5.0",
|
|
115
|
-
"sass": "^1.
|
|
116
|
-
"sass-loader": "^
|
|
112
|
+
"sass": "^1.83.0",
|
|
113
|
+
"sass-loader": "^16.0.4",
|
|
117
114
|
"semantic-release": "^22.0.12",
|
|
118
|
-
"storybook": "^8.4.
|
|
115
|
+
"storybook": "^8.4.7",
|
|
119
116
|
"style-loader": "^4.0.0",
|
|
120
117
|
"stylelint": "^16.11.0",
|
|
121
118
|
"stylelint-config-recommended": "^14.0.1",
|
|
@@ -126,6 +123,9 @@
|
|
|
126
123
|
"typescript": "^5.7.2",
|
|
127
124
|
"vite": "^5.4.11"
|
|
128
125
|
},
|
|
126
|
+
"optionalDependencies": {
|
|
127
|
+
"@rollup/rollup-linux-x64-gnu": "^4.28.1"
|
|
128
|
+
},
|
|
129
129
|
"eslintConfig": {
|
|
130
130
|
"extends": [
|
|
131
131
|
"react-app",
|