@linzjs/windows 7.0.0 → 7.1.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.
|
@@ -3,7 +3,7 @@ import '@linzjs/lui/dist/scss/base.scss';
|
|
|
3
3
|
import '@linzjs/lui/dist/fonts';
|
|
4
4
|
|
|
5
5
|
import clsx from 'clsx';
|
|
6
|
-
import { delay } from 'lodash';
|
|
6
|
+
import { delay } from 'lodash-es';
|
|
7
7
|
import React, { CSSProperties, PropsWithChildren, ReactElement, useContext, useEffect, useRef } from 'react';
|
|
8
8
|
|
|
9
9
|
import { LuiModalAsyncInstanceContext } from './LuiModalAsyncInstanceContext';
|
|
@@ -2,8 +2,7 @@ import { LuiButton, LuiCheckboxInput, LuiMiniSpinner } from '@linzjs/lui';
|
|
|
2
2
|
import { LuiButtonProps } from '@linzjs/lui/dist/components/LuiButton/LuiButton';
|
|
3
3
|
import { IconName } from '@linzjs/lui/dist/components/LuiIcon/LuiIcon';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
|
-
import { flatMap } from 'lodash';
|
|
6
|
-
import { omit, pick } from 'lodash-es';
|
|
5
|
+
import { flatMap, omit, pick } from 'lodash-es';
|
|
7
6
|
import React, { PropsWithChildren, ReactElement, useCallback, useMemo, useState } from 'react';
|
|
8
7
|
|
|
9
8
|
import { debugLog } from '../common/debug';
|
package/dist/panel/Panel.tsx
CHANGED
|
@@ -15,11 +15,13 @@ import {
|
|
|
15
15
|
useState,
|
|
16
16
|
} from 'react';
|
|
17
17
|
import { createPortal } from 'react-dom';
|
|
18
|
+
import { useInterval } from 'usehooks-ts';
|
|
18
19
|
|
|
19
20
|
import { PanelInstanceContext } from './PanelInstanceContext';
|
|
20
21
|
import { PanelsContext } from './PanelsContext';
|
|
21
22
|
import { PopinWindow } from './PopinWIndow';
|
|
22
23
|
import { PopoutWindow } from './PopoutWindow';
|
|
24
|
+
import { PanelPosition } from './types';
|
|
23
25
|
import { PanelProps } from './types/PanelProps';
|
|
24
26
|
import { useRestoreStateFrom } from './usePanelStateHandler';
|
|
25
27
|
|
|
@@ -27,7 +29,7 @@ const defaultInitialSize = { width: 320, height: 200 };
|
|
|
27
29
|
|
|
28
30
|
export const Panel = (props: PanelProps): ReactElement => {
|
|
29
31
|
const panelRef = useRef<HTMLDivElement>(null);
|
|
30
|
-
const { title, size = defaultInitialSize, className, children } = props;
|
|
32
|
+
const { title, size = defaultInitialSize, className, ignoreSavedState, children } = props;
|
|
31
33
|
|
|
32
34
|
const { dockElements, nextStackPosition } = useContext(PanelsContext);
|
|
33
35
|
const { panelPoppedOut, uniqueId, setTitle, dockId, docked } = useContext(PanelInstanceContext);
|
|
@@ -48,33 +50,77 @@ export const Panel = (props: PanelProps): ReactElement => {
|
|
|
48
50
|
}
|
|
49
51
|
}, [title]);
|
|
50
52
|
|
|
51
|
-
const [panelPosition, setPanelPosition] = useState(() => {
|
|
52
|
-
|
|
53
|
+
const [panelPosition, setPanelPosition] = useState((): PanelPosition => {
|
|
54
|
+
const pos = props.position;
|
|
55
|
+
if (!ignoreSavedState && savedState?.panelPosition) {
|
|
53
56
|
return savedState.panelPosition;
|
|
54
57
|
}
|
|
55
58
|
|
|
56
|
-
|
|
59
|
+
// PanelPosition
|
|
60
|
+
if (pos && typeof pos === 'object' && 'selector' in pos) {
|
|
61
|
+
const b = document.querySelector(pos.selector)?.getBoundingClientRect();
|
|
62
|
+
if (b) {
|
|
63
|
+
return { x: b[pos.edgeX ?? 'left'] + (pos.offsetX ?? 0), y: b[pos.edgeY ?? 'bottom'] + (pos.offsetY ?? 0) };
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (pos === 'center') {
|
|
57
68
|
return {
|
|
58
69
|
x: Math.max((window.innerWidth - size.width) / 2, 0),
|
|
59
70
|
y: Math.max((window.innerHeight - size.height) / 2, 0),
|
|
60
71
|
};
|
|
61
72
|
}
|
|
62
73
|
|
|
63
|
-
if (
|
|
64
|
-
return
|
|
74
|
+
if (pos != null && pos !== 'tile') {
|
|
75
|
+
return pos as PanelPosition;
|
|
65
76
|
}
|
|
66
77
|
|
|
67
78
|
return nextStackPosition();
|
|
68
79
|
});
|
|
69
80
|
|
|
70
|
-
|
|
81
|
+
useInterval(
|
|
82
|
+
() => {
|
|
83
|
+
const pos = props.position;
|
|
84
|
+
if (pos && typeof pos === 'object' && 'selector' in pos) {
|
|
85
|
+
const b = document.querySelector(pos.selector)?.getBoundingClientRect();
|
|
86
|
+
if (b) {
|
|
87
|
+
const newPos = {
|
|
88
|
+
x: b[pos.edgeX ?? 'left'] + (pos.offsetX ?? 0),
|
|
89
|
+
y: b[pos.edgeY ?? 'bottom'] + (pos.offsetY ?? 0),
|
|
90
|
+
};
|
|
91
|
+
if (newPos.x !== panelPosition.x || newPos.y !== panelPosition.y) {
|
|
92
|
+
setPanelPosition(newPos);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
props.position && typeof props.position === 'object' && 'selector' in props.position ? 250 : null,
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
const cropSizeToWindow = useCallback((size: NumberSize) => {
|
|
101
|
+
return typeof window !== 'undefined' && window.innerWidth && window.innerHeight
|
|
102
|
+
? {
|
|
103
|
+
width: Math.min(window.document.body?.clientWidth ?? window.innerWidth, size.width),
|
|
104
|
+
height: Math.min(window.document.body?.clientHeight ?? window.innerHeight, size.height),
|
|
105
|
+
}
|
|
106
|
+
: size;
|
|
107
|
+
}, []);
|
|
108
|
+
|
|
109
|
+
const [panelSize, _setPanelSize] = useState<NumberSize>(() => {
|
|
71
110
|
if (savedState?.panelSize) {
|
|
72
|
-
return savedState.panelSize;
|
|
111
|
+
return cropSizeToWindow(savedState.panelSize);
|
|
73
112
|
}
|
|
74
113
|
|
|
75
114
|
return size ?? { width: 320, height: 200 };
|
|
76
115
|
});
|
|
77
116
|
|
|
117
|
+
const setPanelSize = useCallback(
|
|
118
|
+
(size: NumberSize) => {
|
|
119
|
+
_setPanelSize(cropSizeToWindow(size));
|
|
120
|
+
},
|
|
121
|
+
[cropSizeToWindow],
|
|
122
|
+
);
|
|
123
|
+
|
|
78
124
|
const setInitialPanelSize = useCallback(
|
|
79
125
|
(size: NumberSize) => {
|
|
80
126
|
// If panel was already sized from state, then don't resize
|
|
@@ -84,7 +130,7 @@ export const Panel = (props: PanelProps): ReactElement => {
|
|
|
84
130
|
|
|
85
131
|
setPanelSize(size);
|
|
86
132
|
},
|
|
87
|
-
[savedState?.panelSize],
|
|
133
|
+
[savedState?.panelSize, setPanelSize],
|
|
88
134
|
);
|
|
89
135
|
|
|
90
136
|
const dockElement = docked && dockId && dockElements[dockId];
|
|
@@ -3,6 +3,14 @@ import { PropsWithChildren } from 'react';
|
|
|
3
3
|
import { PanelPosition } from './PanelPosition';
|
|
4
4
|
import { PanelSize } from './PanelSize';
|
|
5
5
|
|
|
6
|
+
export interface PanelRelativePositon {
|
|
7
|
+
selector: string;
|
|
8
|
+
edgeX?: 'left' | 'right';
|
|
9
|
+
edgeY?: 'top' | 'bottom';
|
|
10
|
+
offsetX?: number;
|
|
11
|
+
offsetY?: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
6
14
|
interface _PanelProps {
|
|
7
15
|
className?: string;
|
|
8
16
|
maxHeight?: number | string;
|
|
@@ -10,10 +18,11 @@ interface _PanelProps {
|
|
|
10
18
|
minHeight?: number | string;
|
|
11
19
|
minWidth?: number | string;
|
|
12
20
|
modal?: boolean;
|
|
13
|
-
position?: PanelPosition | 'tile' | 'center';
|
|
21
|
+
position?: PanelPosition | PanelRelativePositon | 'tile' | 'center';
|
|
14
22
|
resizeable?: boolean;
|
|
15
23
|
size?: PanelSize;
|
|
16
24
|
title: string;
|
|
25
|
+
ignoreSavedState?: boolean;
|
|
17
26
|
}
|
|
18
27
|
|
|
19
28
|
export type PanelProps = PropsWithChildren<_PanelProps>;
|
package/package.json
CHANGED
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
"popout"
|
|
14
14
|
],
|
|
15
15
|
"main": "./dist/index.ts",
|
|
16
|
-
"version": "7.
|
|
16
|
+
"version": "7.1.0",
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"@linzjs/lui": ">=21",
|
|
19
19
|
"lodash-es": ">=4",
|
|
20
|
-
"react": ">=
|
|
21
|
-
"react-dom": ">=
|
|
20
|
+
"react": ">=18",
|
|
21
|
+
"react-dom": ">=18"
|
|
22
22
|
},
|
|
23
23
|
"files": [
|
|
24
24
|
"dist"
|
|
@@ -59,16 +59,16 @@
|
|
|
59
59
|
"uuid": "^13.0.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@chromatic-com/storybook": "^4.1.
|
|
63
|
-
"@linzjs/lui": "^23.14.
|
|
62
|
+
"@chromatic-com/storybook": "^4.1.2",
|
|
63
|
+
"@linzjs/lui": "^23.14.4",
|
|
64
64
|
"@linzjs/step-ag-grid": "^29.5.1",
|
|
65
65
|
"@linzjs/style": "^5.4.0",
|
|
66
|
-
"@rollup/plugin-commonjs": "^28.0.
|
|
66
|
+
"@rollup/plugin-commonjs": "^28.0.9",
|
|
67
67
|
"@rollup/plugin-json": "^6.1.0",
|
|
68
68
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
69
|
-
"@storybook/addon-docs": "^9.1.
|
|
70
|
-
"@storybook/addon-links": "^9.1.
|
|
71
|
-
"@storybook/react-vite": "^9.1.
|
|
69
|
+
"@storybook/addon-docs": "^9.1.16",
|
|
70
|
+
"@storybook/addon-links": "^9.1.16",
|
|
71
|
+
"@storybook/react-vite": "^9.1.16",
|
|
72
72
|
"@testing-library/dom": "^10.4.1",
|
|
73
73
|
"@testing-library/react": "^16.3.0",
|
|
74
74
|
"@testing-library/user-event": "^14.6.1",
|
|
@@ -76,24 +76,24 @@
|
|
|
76
76
|
"@types/node": "^22.18.12",
|
|
77
77
|
"@types/react": "^19.2.2",
|
|
78
78
|
"@types/react-dom": "^19.2.2",
|
|
79
|
-
"@vitejs/plugin-react-swc": "^4.
|
|
80
|
-
"@vitest/ui": "^4.0.
|
|
81
|
-
"ag-grid-community": "^34.3.
|
|
82
|
-
"ag-grid-react": "^34.3.
|
|
79
|
+
"@vitejs/plugin-react-swc": "^4.2.0",
|
|
80
|
+
"@vitest/ui": "^4.0.5",
|
|
81
|
+
"ag-grid-community": "^34.3.1",
|
|
82
|
+
"ag-grid-react": "^34.3.1",
|
|
83
83
|
"eslint-plugin-react": "^7.37.5",
|
|
84
|
-
"eslint-plugin-storybook": "9.1.
|
|
84
|
+
"eslint-plugin-storybook": "^9.1.16",
|
|
85
85
|
"jsdom": "^27.0.1",
|
|
86
86
|
"mkdirp": "^3.0.1",
|
|
87
87
|
"npm-run-all": "^4.1.5",
|
|
88
|
-
"react": "
|
|
88
|
+
"react": "18.3.1",
|
|
89
89
|
"react-app-polyfill": "^3.0.0",
|
|
90
|
-
"react-dom": "
|
|
90
|
+
"react-dom": "18.3.1",
|
|
91
91
|
"rollup": "^4.52.5",
|
|
92
92
|
"rollup-plugin-copy": "^3.5.0",
|
|
93
93
|
"sass": "^1.93.2",
|
|
94
|
-
"sass-loader": "^16.0.
|
|
94
|
+
"sass-loader": "^16.0.6",
|
|
95
95
|
"semantic-release": "^24.2.9",
|
|
96
|
-
"storybook": "^9.1.
|
|
96
|
+
"storybook": "^9.1.16",
|
|
97
97
|
"style-loader": "^4.0.0",
|
|
98
98
|
"stylelint": "^16.25.0",
|
|
99
99
|
"stylelint-config-recommended": "^17.0.0",
|
|
@@ -102,14 +102,14 @@
|
|
|
102
102
|
"stylelint-prettier": "5.0.3",
|
|
103
103
|
"stylelint-scss": "6.12.1",
|
|
104
104
|
"typescript": "^5.9.3",
|
|
105
|
-
"vite": "^7.1.
|
|
105
|
+
"vite": "^7.1.12",
|
|
106
106
|
"vite-plugin-html": "^3.2.2",
|
|
107
107
|
"vite-tsconfig-paths": "^5.1.4",
|
|
108
|
-
"vitest": "^4.0.
|
|
108
|
+
"vitest": "^4.0.5"
|
|
109
109
|
},
|
|
110
110
|
"optionalDependencies": {
|
|
111
111
|
"@rollup/rollup-linux-x64-gnu": "^4.52.5",
|
|
112
|
-
"@swc/core-linux-x64-gnu": "^1.
|
|
112
|
+
"@swc/core-linux-x64-gnu": "^1.14.0"
|
|
113
113
|
},
|
|
114
114
|
"browserslist": {
|
|
115
115
|
"production": [
|