@linzjs/windows 10.3.1 → 11.0.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.
- package/dist/LuiModalAsync/LuiModalAsync.d.ts +14 -0
- package/dist/LuiModalAsync/LuiModalAsync.js +45 -0
- package/dist/LuiModalAsync/LuiModalAsync.js.map +1 -0
- package/dist/LuiModalAsync/LuiModalAsync.scss +1 -2
- package/dist/LuiModalAsync/LuiModalAsyncButtonGroup.d.ts +19 -0
- package/dist/LuiModalAsync/LuiModalAsyncButtonGroup.js +27 -0
- package/dist/LuiModalAsync/LuiModalAsyncButtonGroup.js.map +1 -0
- package/dist/LuiModalAsync/LuiModalAsyncContent.d.ts +6 -0
- package/dist/LuiModalAsync/LuiModalAsyncContent.js +7 -0
- package/dist/LuiModalAsync/LuiModalAsyncContent.js.map +1 -0
- package/dist/LuiModalAsync/LuiModalAsyncContext.d.ts +28 -0
- package/dist/LuiModalAsync/LuiModalAsyncContext.js +9 -0
- package/dist/LuiModalAsync/LuiModalAsyncContext.js.map +1 -0
- package/dist/LuiModalAsync/LuiModalAsyncContextProvider.d.ts +54 -0
- package/dist/LuiModalAsync/LuiModalAsyncContextProvider.js +160 -0
- package/dist/LuiModalAsync/LuiModalAsyncContextProvider.js.map +1 -0
- package/dist/LuiModalAsync/LuiModalAsyncHeader.d.ts +15 -0
- package/dist/LuiModalAsync/LuiModalAsyncHeader.js +23 -0
- package/dist/LuiModalAsync/LuiModalAsyncHeader.js.map +1 -0
- package/dist/LuiModalAsync/LuiModalAsyncInstanceContext.d.ts +13 -0
- package/dist/LuiModalAsync/LuiModalAsyncInstanceContext.js +13 -0
- package/dist/LuiModalAsync/LuiModalAsyncInstanceContext.js.map +1 -0
- package/dist/LuiModalAsync/LuiModalAsyncMain.d.ts +5 -0
- package/dist/LuiModalAsync/LuiModalAsyncMain.js +6 -0
- package/dist/LuiModalAsync/LuiModalAsyncMain.js.map +1 -0
- package/dist/LuiModalAsync/index.js +12 -0
- package/dist/LuiModalAsync/index.js.map +1 -0
- package/dist/LuiModalAsync/useLuiModalPrefab.d.ts +56 -0
- package/dist/LuiModalAsync/useLuiModalPrefab.js +118 -0
- package/dist/LuiModalAsync/useLuiModalPrefab.js.map +1 -0
- package/dist/LuiModalAsync/useLuiModalUpload.d.ts +16 -0
- package/dist/LuiModalAsync/useLuiModalUpload.js +34 -0
- package/dist/LuiModalAsync/useLuiModalUpload.js.map +1 -0
- package/dist/LuiModalAsync/useShowAsyncModal.d.ts +6 -0
- package/dist/LuiModalAsync/useShowAsyncModal.js +13 -0
- package/dist/LuiModalAsync/useShowAsyncModal.js.map +1 -0
- package/dist/common/debug.d.ts +1 -0
- package/dist/common/debug.js +11 -0
- package/dist/common/debug.js.map +1 -0
- package/dist/common/index.js +3 -0
- package/dist/common/index.js.map +1 -0
- package/dist/common/useConstFunction.d.ts +5 -0
- package/dist/common/useConstFunction.js +17 -0
- package/dist/common/useConstFunction.js.map +1 -0
- package/dist/common/useInterval.d.ts +17 -0
- package/dist/common/{useInterval.ts → useInterval.js} +21 -25
- package/dist/common/useInterval.js.map +1 -0
- package/dist/common/useIsomorphicLayoutEffect.d.ts +17 -0
- package/dist/common/{useIsomorphicLayoutEffect.ts → useIsomorphicLayoutEffect.js} +1 -1
- package/dist/common/useIsomorphicLayoutEffect.js.map +1 -0
- package/dist/common/util.d.ts +3 -0
- package/dist/common/util.js +25 -0
- package/dist/common/util.js.map +1 -0
- package/dist/common/uuid.d.ts +1 -0
- package/dist/common/{uuid.ts → uuid.js} +1 -1
- package/dist/common/uuid.js.map +1 -0
- package/dist/components/CopyableText.d.ts +9 -0
- package/dist/components/CopyableText.js +29 -0
- package/dist/components/CopyableText.js.map +1 -0
- package/dist/components/index.js +2 -0
- package/dist/components/index.js.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/panel/OpenPanelButton.d.ts +8 -0
- package/dist/panel/OpenPanelButton.js +11 -0
- package/dist/panel/OpenPanelButton.js.map +1 -0
- package/dist/panel/Panel.d.ts +10 -0
- package/dist/panel/Panel.js +122 -0
- package/dist/panel/Panel.js.map +1 -0
- package/dist/panel/PanelContext.d.ts +10 -0
- package/dist/panel/PanelContext.js +13 -0
- package/dist/panel/PanelContext.js.map +1 -0
- package/dist/panel/PanelDock.d.ts +5 -0
- package/dist/panel/PanelDock.js +9 -0
- package/dist/panel/PanelDock.js.map +1 -0
- package/dist/panel/PanelHeader.d.ts +15 -0
- package/dist/panel/PanelHeader.js +33 -0
- package/dist/panel/PanelHeader.js.map +1 -0
- package/dist/panel/PanelHeaderButton.d.ts +8 -0
- package/dist/panel/PanelHeaderButton.js +16 -0
- package/dist/panel/PanelHeaderButton.js.map +1 -0
- package/dist/panel/PanelInline.d.ts +10 -0
- package/dist/panel/PanelInline.js +26 -0
- package/dist/panel/PanelInline.js.map +1 -0
- package/dist/panel/PanelInstanceContext.d.ts +21 -0
- package/dist/panel/PanelInstanceContext.js +25 -0
- package/dist/panel/PanelInstanceContext.js.map +1 -0
- package/dist/panel/PanelInstanceContextProvider.d.ts +11 -0
- package/dist/panel/PanelInstanceContextProvider.js +50 -0
- package/dist/panel/PanelInstanceContextProvider.js.map +1 -0
- package/dist/panel/PanelsContext.d.ts +33 -0
- package/dist/panel/PanelsContext.js +19 -0
- package/dist/panel/PanelsContext.js.map +1 -0
- package/dist/panel/PanelsContextProvider.d.ts +12 -0
- package/dist/panel/PanelsContextProvider.js +145 -0
- package/dist/panel/PanelsContextProvider.js.map +1 -0
- package/dist/panel/PopinWIndow.d.ts +11 -0
- package/dist/panel/PopinWIndow.js +74 -0
- package/dist/panel/PopinWIndow.js.map +1 -0
- package/dist/panel/PopoutWindow.d.ts +17 -0
- package/dist/panel/PopoutWindow.js +72 -0
- package/dist/panel/PopoutWindow.js.map +1 -0
- package/dist/panel/generateId.d.ts +6 -0
- package/dist/panel/{generateId.ts → generateId.js} +3 -4
- package/dist/panel/generateId.js.map +1 -0
- package/dist/panel/handleStyleSheetsChanges.d.ts +9 -0
- package/dist/panel/handleStyleSheetsChanges.js +65 -0
- package/dist/panel/handleStyleSheetsChanges.js.map +1 -0
- package/dist/panel/index.js +13 -0
- package/dist/panel/index.js.map +1 -0
- package/dist/panel/openExternalWindow.d.ts +23 -0
- package/dist/panel/openExternalWindow.js +62 -0
- package/dist/panel/openExternalWindow.js.map +1 -0
- package/dist/panel/types/{PanelPosition.ts → PanelPosition.d.ts} +2 -2
- package/dist/panel/types/PanelPosition.js +2 -0
- package/dist/panel/types/PanelPosition.js.map +1 -0
- package/dist/panel/types/PanelProps.d.ts +19 -0
- package/dist/panel/types/PanelProps.js +2 -0
- package/dist/panel/types/PanelProps.js.map +1 -0
- package/dist/panel/types/{PanelRestoredState.ts → PanelRestoredState.d.ts} +3 -4
- package/dist/panel/types/PanelRestoredState.js +2 -0
- package/dist/panel/types/PanelRestoredState.js.map +1 -0
- package/dist/panel/types/PanelSize.d.ts +8 -0
- package/dist/panel/types/PanelSize.js +2 -0
- package/dist/panel/types/PanelSize.js.map +1 -0
- package/dist/panel/types/{PanelState.ts → PanelState.d.ts} +5 -8
- package/dist/panel/types/PanelState.js +2 -0
- package/dist/panel/types/PanelState.js.map +1 -0
- package/dist/panel/types/{PanelStateOptions.ts → PanelStateOptions.d.ts} +4 -6
- package/dist/panel/types/PanelStateOptions.js +2 -0
- package/dist/panel/types/PanelStateOptions.js.map +1 -0
- package/dist/panel/types/index.js +7 -0
- package/dist/panel/types/index.js.map +1 -0
- package/dist/panel/usePanelStateHandler.d.ts +8 -0
- package/dist/panel/usePanelStateHandler.js +81 -0
- package/dist/panel/usePanelStateHandler.js.map +1 -0
- package/dist/ribbon/RibbonButton.d.ts +21 -0
- package/dist/ribbon/RibbonButton.js +28 -0
- package/dist/ribbon/RibbonButton.js.map +1 -0
- package/dist/ribbon/RibbonButtonLink.d.ts +12 -0
- package/dist/ribbon/RibbonButtonLink.js +11 -0
- package/dist/ribbon/RibbonButtonLink.js.map +1 -0
- package/dist/ribbon/RibbonButtonOpenPanel.d.ts +5 -0
- package/dist/ribbon/RibbonButtonOpenPanel.js +11 -0
- package/dist/ribbon/RibbonButtonOpenPanel.js.map +1 -0
- package/dist/ribbon/RibbonButtonSlider.d.ts +11 -0
- package/dist/ribbon/RibbonButtonSlider.js +28 -0
- package/dist/ribbon/RibbonButtonSlider.js.map +1 -0
- package/dist/ribbon/RibbonButtonSliderContext.d.ts +25 -0
- package/dist/ribbon/RibbonButtonSliderContext.js +25 -0
- package/dist/ribbon/RibbonButtonSliderContext.js.map +1 -0
- package/dist/ribbon/RibbonContainer.d.ts +10 -0
- package/dist/ribbon/RibbonContainer.js +7 -0
- package/dist/ribbon/RibbonContainer.js.map +1 -0
- package/dist/ribbon/RibbonDeprecated.d.ts +10 -0
- package/dist/ribbon/RibbonDeprecated.js +13 -0
- package/dist/ribbon/RibbonDeprecated.js.map +1 -0
- package/dist/ribbon/RibbonMenu.d.ts +7 -0
- package/dist/ribbon/RibbonMenu.js +12 -0
- package/dist/ribbon/RibbonMenu.js.map +1 -0
- package/dist/ribbon/RibbonMenuOption.d.ts +17 -0
- package/dist/ribbon/RibbonMenuOption.js +26 -0
- package/dist/ribbon/RibbonMenuOption.js.map +1 -0
- package/dist/ribbon/RibbonMenuSeparator.d.ts +2 -0
- package/dist/ribbon/RibbonMenuSeparator.js +6 -0
- package/dist/ribbon/RibbonMenuSeparator.js.map +1 -0
- package/dist/ribbon/RibbonSeparator.d.ts +2 -0
- package/dist/ribbon/RibbonSeparator.js +4 -0
- package/dist/ribbon/RibbonSeparator.js.map +1 -0
- package/dist/ribbon/index.js +12 -0
- package/dist/ribbon/index.js.map +1 -0
- package/package.json +15 -8
- package/dist/LuiModalAsync/LuiModalAsync.tsx +0 -82
- package/dist/LuiModalAsync/LuiModalAsyncButtonGroup.tsx +0 -55
- package/dist/LuiModalAsync/LuiModalAsyncContent.tsx +0 -9
- package/dist/LuiModalAsync/LuiModalAsyncContext.tsx +0 -52
- package/dist/LuiModalAsync/LuiModalAsyncContextProvider.tsx +0 -223
- package/dist/LuiModalAsync/LuiModalAsyncHeader.tsx +0 -67
- package/dist/LuiModalAsync/LuiModalAsyncInstanceContext.ts +0 -24
- package/dist/LuiModalAsync/LuiModalAsyncMain.tsx +0 -8
- package/dist/LuiModalAsync/useLuiModalPrefab.tsx +0 -227
- package/dist/LuiModalAsync/useLuiModalUpload.tsx +0 -79
- package/dist/LuiModalAsync/useShowAsyncModal.ts +0 -34
- package/dist/common/debug.ts +0 -9
- package/dist/common/useConstFunction.ts +0 -22
- package/dist/common/util.ts +0 -31
- package/dist/components/CopyableText.tsx +0 -58
- package/dist/panel/OpenPanelButton.tsx +0 -52
- package/dist/panel/Panel.tsx +0 -211
- package/dist/panel/PanelContext.ts +0 -22
- package/dist/panel/PanelDock.tsx +0 -20
- package/dist/panel/PanelHeader.tsx +0 -105
- package/dist/panel/PanelHeaderButton.tsx +0 -26
- package/dist/panel/PanelInline.tsx +0 -46
- package/dist/panel/PanelInstanceContext.ts +0 -44
- package/dist/panel/PanelInstanceContextProvider.tsx +0 -75
- package/dist/panel/PanelsContext.tsx +0 -56
- package/dist/panel/PanelsContextProvider.tsx +0 -220
- package/dist/panel/PopinWIndow.tsx +0 -147
- package/dist/panel/PopoutWindow.tsx +0 -117
- package/dist/panel/handleStyleSheetsChanges.ts +0 -71
- package/dist/panel/openExternalWindow.ts +0 -98
- package/dist/panel/types/PanelProps.ts +0 -22
- package/dist/panel/types/PanelSize.ts +0 -9
- package/dist/panel/usePanelStateHandler.tsx +0 -102
- package/dist/ribbon/RibbonButton.tsx +0 -112
- package/dist/ribbon/RibbonButtonLink.tsx +0 -27
- package/dist/ribbon/RibbonButtonOpenPanel.tsx +0 -23
- package/dist/ribbon/RibbonButtonSlider.tsx +0 -66
- package/dist/ribbon/RibbonButtonSliderContext.tsx +0 -34
- package/dist/ribbon/RibbonContainer.tsx +0 -19
- package/dist/ribbon/RibbonDeprecated.tsx +0 -27
- package/dist/ribbon/RibbonMenu.tsx +0 -25
- package/dist/ribbon/RibbonMenuOption.tsx +0 -67
- package/dist/ribbon/RibbonMenuSeparator.tsx +0 -5
- package/dist/ribbon/RibbonSeparator.tsx +0 -3
- /package/dist/LuiModalAsync/{index.ts → index.d.ts} +0 -0
- /package/dist/common/{index.ts → index.d.ts} +0 -0
- /package/dist/components/{index.ts → index.d.ts} +0 -0
- /package/dist/{index.ts → index.d.ts} +0 -0
- /package/dist/panel/{index.ts → index.d.ts} +0 -0
- /package/dist/panel/types/{index.ts → index.d.ts} +0 -0
- /package/dist/ribbon/{index.ts → index.d.ts} +0 -0
package/dist/panel/Panel.tsx
DELETED
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
import '../index.scss';
|
|
2
|
-
|
|
3
|
-
import clsx from 'clsx';
|
|
4
|
-
import { isEqual, pick } from 'lodash-es';
|
|
5
|
-
import {
|
|
6
|
-
forwardRef,
|
|
7
|
-
PropsWithChildren,
|
|
8
|
-
ReactElement,
|
|
9
|
-
useCallback,
|
|
10
|
-
useContext,
|
|
11
|
-
useEffect,
|
|
12
|
-
useRef,
|
|
13
|
-
useState,
|
|
14
|
-
} from 'react';
|
|
15
|
-
import { createPortal } from 'react-dom';
|
|
16
|
-
|
|
17
|
-
import { PanelInstanceContext } from './PanelInstanceContext';
|
|
18
|
-
import { PanelsContext } from './PanelsContext';
|
|
19
|
-
import { PopinWindow } from './PopinWIndow';
|
|
20
|
-
import { PopoutWindow } from './PopoutWindow';
|
|
21
|
-
import { PanelPosition } from './types/PanelPosition';
|
|
22
|
-
import { PanelProps } from './types/PanelProps';
|
|
23
|
-
import { PanelSize } from './types/PanelSize';
|
|
24
|
-
import { useRestoreStateFrom } from './usePanelStateHandler';
|
|
25
|
-
import { useInterval } from '../common/useInterval';
|
|
26
|
-
|
|
27
|
-
const defaultInitialSize = { width: 320, height: 200 };
|
|
28
|
-
|
|
29
|
-
export const Panel = (props: PanelProps): ReactElement => {
|
|
30
|
-
const panelRef = useRef<HTMLDivElement>(null);
|
|
31
|
-
const { title, size = defaultInitialSize, className, dynamicBounds, children } = props;
|
|
32
|
-
|
|
33
|
-
const { dockElements, nextStackPosition } = useContext(PanelsContext);
|
|
34
|
-
const { panelPoppedOut, uniqueId, setTitle, dockId, docked, hidden } = useContext(PanelInstanceContext);
|
|
35
|
-
|
|
36
|
-
const savedState = useRestoreStateFrom({ uniqueId, panelPoppedOut: false });
|
|
37
|
-
|
|
38
|
-
const lastPanelHeightRef = useRef(panelRef.current?.clientHeight);
|
|
39
|
-
lastPanelHeightRef.current = panelRef.current?.clientHeight ?? lastPanelHeightRef.current ?? 400;
|
|
40
|
-
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
setTitle(title);
|
|
43
|
-
}, [setTitle, title]);
|
|
44
|
-
|
|
45
|
-
// We only want to update the title when it changes
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if (panelRef.current) {
|
|
48
|
-
const doc = panelRef.current.ownerDocument;
|
|
49
|
-
if (doc) {
|
|
50
|
-
doc.title = title;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}, [title]);
|
|
54
|
-
|
|
55
|
-
const [panelPosition, setPanelPosition] = useState((): PanelPosition => {
|
|
56
|
-
if (dynamicBounds) {
|
|
57
|
-
const result = dynamicBounds();
|
|
58
|
-
if (result) {
|
|
59
|
-
return pick(result, ['x', 'y']);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const pos = props.position;
|
|
64
|
-
if (props.resizeable !== false && savedState?.panelPosition) {
|
|
65
|
-
return savedState.panelPosition;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (pos === 'center') {
|
|
69
|
-
const height = size.height === 'auto' ? 400 : size.height;
|
|
70
|
-
return {
|
|
71
|
-
x: Math.max((window.innerWidth - size.width) / 2, 0),
|
|
72
|
-
y: Math.max((window.innerHeight - height) / 2, 0),
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (pos != null && pos !== 'tile') {
|
|
77
|
-
return pos;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return nextStackPosition();
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
const cropSizeToWindow = useCallback((size: PanelSize): PanelSize => {
|
|
84
|
-
return typeof window !== 'undefined' && window.innerWidth && window.innerHeight
|
|
85
|
-
? {
|
|
86
|
-
width: Math.min(window.document.body?.clientWidth ?? window.innerWidth, size.width),
|
|
87
|
-
height:
|
|
88
|
-
size.height === 'auto'
|
|
89
|
-
? 'auto'
|
|
90
|
-
: Math.min(window.document.body?.clientHeight ?? window.innerHeight, size.height),
|
|
91
|
-
}
|
|
92
|
-
: size;
|
|
93
|
-
}, []);
|
|
94
|
-
|
|
95
|
-
const [panelSize, _setPanelSize] = useState<PanelSize>(() => {
|
|
96
|
-
const result = dynamicBounds?.();
|
|
97
|
-
if (result) {
|
|
98
|
-
return pick(result, ['width', 'height']);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (props.resizeable !== false && savedState?.panelSize) {
|
|
102
|
-
return cropSizeToWindow(savedState.panelSize);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return size ?? { width: 320, height: 200 };
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
const setPanelSize = useCallback(
|
|
109
|
-
(size: PanelSize) => {
|
|
110
|
-
_setPanelSize(cropSizeToWindow(size));
|
|
111
|
-
},
|
|
112
|
-
[cropSizeToWindow],
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
const setInitialPanelSize = useCallback(
|
|
116
|
-
(size: PanelSize) => {
|
|
117
|
-
// If panel was already sized from state, then don't resize
|
|
118
|
-
if (props.resizeable !== false && savedState?.panelSize) {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
setPanelSize(size);
|
|
123
|
-
},
|
|
124
|
-
[props.resizeable, savedState?.panelSize, setPanelSize],
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
const dynamicResize = useCallback(() => {
|
|
128
|
-
const bounds = dynamicBounds?.();
|
|
129
|
-
if (!bounds) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
const newPosition = pick(bounds, ['x', 'y']);
|
|
133
|
-
if (!isEqual(newPosition, panelPosition)) {
|
|
134
|
-
setPanelPosition(newPosition);
|
|
135
|
-
}
|
|
136
|
-
const newSize = pick(bounds, ['width', 'height']);
|
|
137
|
-
if (!isEqual(newSize, panelSize)) {
|
|
138
|
-
setPanelSize(newSize);
|
|
139
|
-
}
|
|
140
|
-
}, [dynamicBounds, panelPosition, panelSize, setPanelSize]);
|
|
141
|
-
|
|
142
|
-
useEffect(() => {
|
|
143
|
-
window.addEventListener('resize', dynamicResize);
|
|
144
|
-
|
|
145
|
-
return () => {
|
|
146
|
-
window.removeEventListener('resize', dynamicResize);
|
|
147
|
-
};
|
|
148
|
-
}, [dynamicResize]);
|
|
149
|
-
|
|
150
|
-
useInterval(dynamicResize, dynamicBounds ? 250 : null);
|
|
151
|
-
|
|
152
|
-
const dockElement = docked && dockId && dockElements[dockId];
|
|
153
|
-
return (
|
|
154
|
-
<>
|
|
155
|
-
{dockElement && dockElement.isConnected ? (
|
|
156
|
-
createPortal(children, dockElement)
|
|
157
|
-
) : panelPoppedOut ? (
|
|
158
|
-
<PopoutWindow
|
|
159
|
-
name={uniqueId}
|
|
160
|
-
title={title}
|
|
161
|
-
size={{ width: size.width, height: lastPanelHeightRef.current }}
|
|
162
|
-
popInPanelPosition={panelPosition}
|
|
163
|
-
popInPanelSize={{
|
|
164
|
-
width: panelSize.width,
|
|
165
|
-
height: panelSize.height === 'auto' ? lastPanelHeightRef.current : panelSize.height,
|
|
166
|
-
}}
|
|
167
|
-
>
|
|
168
|
-
<div
|
|
169
|
-
ref={panelRef}
|
|
170
|
-
style={{
|
|
171
|
-
display: 'flex',
|
|
172
|
-
flexDirection: 'column',
|
|
173
|
-
width: '100%',
|
|
174
|
-
height: '100%',
|
|
175
|
-
}}
|
|
176
|
-
className={className}
|
|
177
|
-
>
|
|
178
|
-
{children}
|
|
179
|
-
</div>
|
|
180
|
-
</PopoutWindow>
|
|
181
|
-
) : (
|
|
182
|
-
<PopinWindow
|
|
183
|
-
{...props}
|
|
184
|
-
panelPosition={panelPosition}
|
|
185
|
-
setPanelPosition={setPanelPosition}
|
|
186
|
-
panelSize={panelSize}
|
|
187
|
-
setPanelSize={setPanelSize}
|
|
188
|
-
setInitialPanelSize={setInitialPanelSize}
|
|
189
|
-
hidden={hidden}
|
|
190
|
-
>
|
|
191
|
-
{children}
|
|
192
|
-
</PopinWindow>
|
|
193
|
-
)}
|
|
194
|
-
</>
|
|
195
|
-
);
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
export interface PanelContentProps {
|
|
199
|
-
className?: string | undefined;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export const PanelContent = forwardRef<HTMLDivElement, PropsWithChildren<PanelContentProps>>(function PanelContentFr(
|
|
203
|
-
{ children, className },
|
|
204
|
-
ref,
|
|
205
|
-
) {
|
|
206
|
-
return (
|
|
207
|
-
<div className={clsx(`WindowPanel-content`, className)} ref={ref}>
|
|
208
|
-
{children}
|
|
209
|
-
</div>
|
|
210
|
-
);
|
|
211
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { createContext } from 'react';
|
|
2
|
-
|
|
3
|
-
import { PanelSize } from './types';
|
|
4
|
-
|
|
5
|
-
export interface PanelContextType {
|
|
6
|
-
resizePanel: (size: Partial<PanelSize>) => void;
|
|
7
|
-
initialResizePanel: (size: Partial<PanelSize>) => void;
|
|
8
|
-
resizeable: boolean;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const NoContextError = () => {
|
|
12
|
-
console.error('Missing PanelContext Provider');
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Provides access to closing/popping panels
|
|
17
|
-
*/
|
|
18
|
-
export const PanelContext = createContext<PanelContextType>({
|
|
19
|
-
resizePanel: NoContextError,
|
|
20
|
-
initialResizePanel: NoContextError,
|
|
21
|
-
resizeable: true,
|
|
22
|
-
});
|
package/dist/panel/PanelDock.tsx
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { PropsWithChildren, ReactElement, useContext } from 'react';
|
|
2
|
-
|
|
3
|
-
import { PanelsContext } from './PanelsContext';
|
|
4
|
-
|
|
5
|
-
export interface PanelDockProps {
|
|
6
|
-
id: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const PanelDock = ({ id, children }: PropsWithChildren<PanelDockProps>): ReactElement => {
|
|
10
|
-
const { setDockElement } = useContext(PanelsContext);
|
|
11
|
-
|
|
12
|
-
const setElement = (element: HTMLDivElement) => setDockElement(id, element);
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<div className={'panelDock'}>
|
|
16
|
-
<div ref={setElement} className={'panelDock-content'} />
|
|
17
|
-
<div className={'panelDock-empty'}>{children}</div>
|
|
18
|
-
</div>
|
|
19
|
-
);
|
|
20
|
-
};
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { LuiIcon } from '@linzjs/lui';
|
|
2
|
-
import { LuiIconName } from '@linzjs/lui/dist/assets/svg-content';
|
|
3
|
-
import clsx from 'clsx';
|
|
4
|
-
import { ReactElement, useContext, useState } from 'react';
|
|
5
|
-
|
|
6
|
-
import { PanelContext } from './PanelContext';
|
|
7
|
-
import { PanelHeaderButton } from './PanelHeaderButton';
|
|
8
|
-
import { PanelInstanceContext } from './PanelInstanceContext';
|
|
9
|
-
|
|
10
|
-
export interface PanelHeaderProps {
|
|
11
|
-
icon?: LuiIconName;
|
|
12
|
-
extraLeft?: ReactElement;
|
|
13
|
-
extraRight?: ReactElement;
|
|
14
|
-
helpUrl?: string;
|
|
15
|
-
onHelpClick?: () => void;
|
|
16
|
-
onDockClick?: () => void;
|
|
17
|
-
// Popped out windows are native so will not fire this, if you use this make the panel non popout!
|
|
18
|
-
// Return true to close the panel, otherwise false to keep it open.
|
|
19
|
-
onCloseClickPoppedInPanelOnly?: () => Promise<boolean> | boolean;
|
|
20
|
-
dockTo?: string;
|
|
21
|
-
disableClose?: boolean;
|
|
22
|
-
disablePopout?: boolean;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const PanelHeader = ({
|
|
26
|
-
icon,
|
|
27
|
-
extraLeft,
|
|
28
|
-
extraRight,
|
|
29
|
-
helpUrl,
|
|
30
|
-
onHelpClick,
|
|
31
|
-
onDockClick,
|
|
32
|
-
onCloseClickPoppedInPanelOnly,
|
|
33
|
-
dockTo,
|
|
34
|
-
disableClose,
|
|
35
|
-
disablePopout,
|
|
36
|
-
}: PanelHeaderProps) => {
|
|
37
|
-
const { resizeable } = useContext(PanelContext);
|
|
38
|
-
const { panelClose, panelTogglePopout, panelPoppedOut, title, dock, undock, docked } =
|
|
39
|
-
useContext(PanelInstanceContext);
|
|
40
|
-
const [cursor, setCursor] = useState<'grab' | 'grabbing'>('grab');
|
|
41
|
-
|
|
42
|
-
const headerMouseDown = () => {
|
|
43
|
-
if (!panelPoppedOut) {
|
|
44
|
-
setCursor('grabbing');
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<div
|
|
50
|
-
className={clsx('WindowPanel-header', resizeable && 'draggable-handle')}
|
|
51
|
-
onMouseDown={headerMouseDown}
|
|
52
|
-
onMouseUp={() => !panelPoppedOut && setCursor('grab')}
|
|
53
|
-
style={resizeable ? { cursor } : {}}
|
|
54
|
-
>
|
|
55
|
-
<div className={'WindowPanel-header-title'}>
|
|
56
|
-
{icon && <LuiIcon name={icon} alt={'icon'} size={'md'} className={'WindowPanel-header-title-icon'} />}
|
|
57
|
-
{title}
|
|
58
|
-
</div>
|
|
59
|
-
{extraLeft && <div className={'WindowPanel-divider-left'} />}
|
|
60
|
-
<div className={'WindowPanel-children'}>{extraLeft}</div>
|
|
61
|
-
<div className={'WindowPanel-buttons'}>
|
|
62
|
-
{extraRight}
|
|
63
|
-
{(helpUrl || onHelpClick) && (
|
|
64
|
-
<PanelHeaderButton aria-label={'Get help'} href={helpUrl} onClick={onHelpClick} icon={'ic_help_outline'} />
|
|
65
|
-
)}
|
|
66
|
-
</div>
|
|
67
|
-
{(dockTo || !disablePopout || !disableClose) && <div className={'WindowPanel-divider-right'} />}
|
|
68
|
-
<div className={'WindowPanel-buttons'}>
|
|
69
|
-
{onDockClick && <PanelHeaderButton aria-label={'Dock'} onClick={() => onDockClick()} icon={'ic_left_col'} />}
|
|
70
|
-
{!onDockClick &&
|
|
71
|
-
dockTo &&
|
|
72
|
-
(docked ? (
|
|
73
|
-
<PanelHeaderButton aria-label={'Undock'} onClick={undock} icon={'ic_close_list'} />
|
|
74
|
-
) : (
|
|
75
|
-
<PanelHeaderButton aria-label={'Dock'} onClick={() => dock(dockTo)} icon={'ic_left_col'} />
|
|
76
|
-
))}
|
|
77
|
-
{!disablePopout && (
|
|
78
|
-
<PanelHeaderButton
|
|
79
|
-
aria-label={panelPoppedOut ? 'Pop-in' : 'Pop-out'}
|
|
80
|
-
onClick={panelTogglePopout}
|
|
81
|
-
icon={panelPoppedOut ? 'ic_pop_back' : 'ic_launch_new window_open'}
|
|
82
|
-
/>
|
|
83
|
-
)}
|
|
84
|
-
{!disableClose && (
|
|
85
|
-
<PanelHeaderButton
|
|
86
|
-
aria-label={'Close'}
|
|
87
|
-
onClick={() => {
|
|
88
|
-
if (onCloseClickPoppedInPanelOnly) {
|
|
89
|
-
void (async () => {
|
|
90
|
-
const result = await onCloseClickPoppedInPanelOnly();
|
|
91
|
-
if (result) {
|
|
92
|
-
panelClose();
|
|
93
|
-
}
|
|
94
|
-
})();
|
|
95
|
-
} else {
|
|
96
|
-
panelClose();
|
|
97
|
-
}
|
|
98
|
-
}}
|
|
99
|
-
icon={'ic_clear'}
|
|
100
|
-
/>
|
|
101
|
-
)}
|
|
102
|
-
</div>
|
|
103
|
-
</div>
|
|
104
|
-
);
|
|
105
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { LuiButton, LuiIcon } from '@linzjs/lui';
|
|
2
|
-
import { LuiIconName } from '@linzjs/lui/dist/assets/svg-content';
|
|
3
|
-
|
|
4
|
-
export interface PanelHeaderButtonProps {
|
|
5
|
-
'aria-label': string;
|
|
6
|
-
href?: string;
|
|
7
|
-
icon: LuiIconName;
|
|
8
|
-
onClick?: () => void;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const PanelHeaderButton = ({ 'aria-label': ariaLabel, href, icon, onClick }: PanelHeaderButtonProps) => (
|
|
12
|
-
<LuiButton
|
|
13
|
-
level={'plain-text'}
|
|
14
|
-
className={'lui-button-icon-only'}
|
|
15
|
-
size={'sm'}
|
|
16
|
-
href={href}
|
|
17
|
-
onClick={onClick}
|
|
18
|
-
openInNewTab={!!href}
|
|
19
|
-
title={ariaLabel}
|
|
20
|
-
buttonProps={{
|
|
21
|
-
onTouchStart: onClick,
|
|
22
|
-
}}
|
|
23
|
-
>
|
|
24
|
-
<LuiIcon name={icon} alt={ariaLabel} size={'md'} />
|
|
25
|
-
</LuiButton>
|
|
26
|
-
);
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { CSSProperties, forwardRef, PropsWithChildren } from 'react';
|
|
2
|
-
|
|
3
|
-
import { PanelContext } from './PanelContext';
|
|
4
|
-
import { PanelInstanceContext } from './PanelInstanceContext';
|
|
5
|
-
import { v4 } from '../common/uuid';
|
|
6
|
-
import clsx from 'clsx';
|
|
7
|
-
|
|
8
|
-
export interface PanelInlineProps {
|
|
9
|
-
title: string;
|
|
10
|
-
className?: string;
|
|
11
|
-
width?: CSSProperties['width'];
|
|
12
|
-
height?: CSSProperties['height'];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const PanelInline = forwardRef<HTMLDivElement, PropsWithChildren<PanelInlineProps>>(function PanelInline(
|
|
16
|
-
{ title, className, width, height, children },
|
|
17
|
-
ref,
|
|
18
|
-
) {
|
|
19
|
-
return (
|
|
20
|
-
<PanelContext.Provider value={{ resizeable: false, resizePanel: () => {}, initialResizePanel: () => {} }}>
|
|
21
|
-
<PanelInstanceContext.Provider
|
|
22
|
-
value={{
|
|
23
|
-
setTitle: () => {},
|
|
24
|
-
title,
|
|
25
|
-
zIndex: 1500,
|
|
26
|
-
uniqueId: v4(),
|
|
27
|
-
dock: () => {},
|
|
28
|
-
panelClose: () => {},
|
|
29
|
-
dockId: undefined,
|
|
30
|
-
docked: false,
|
|
31
|
-
bringPanelToFront: () => {},
|
|
32
|
-
hidden: false,
|
|
33
|
-
setPanelWindow: () => {},
|
|
34
|
-
panelTogglePopout: () => {},
|
|
35
|
-
undock: () => {},
|
|
36
|
-
panelPoppedOut: false,
|
|
37
|
-
bounds: undefined,
|
|
38
|
-
}}
|
|
39
|
-
>
|
|
40
|
-
<div ref={ref} className={clsx('WindowPanel', className)} title={title} style={{ width, height }}>
|
|
41
|
-
{children}
|
|
42
|
-
</div>
|
|
43
|
-
</PanelInstanceContext.Provider>
|
|
44
|
-
</PanelContext.Provider>
|
|
45
|
-
);
|
|
46
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { createContext } from 'react';
|
|
2
|
-
|
|
3
|
-
export interface PanelInstanceContextType {
|
|
4
|
-
title: string;
|
|
5
|
-
setTitle: (title: string) => void;
|
|
6
|
-
uniqueId: string;
|
|
7
|
-
bounds: string | Element | undefined;
|
|
8
|
-
panelTogglePopout: () => void;
|
|
9
|
-
panelClose: () => void;
|
|
10
|
-
setPanelWindow: (w: Window) => void;
|
|
11
|
-
bringPanelToFront: () => void;
|
|
12
|
-
panelPoppedOut: boolean;
|
|
13
|
-
zIndex: number;
|
|
14
|
-
dockId: string | undefined;
|
|
15
|
-
docked: boolean;
|
|
16
|
-
dock: (id: string) => void;
|
|
17
|
-
undock: () => void;
|
|
18
|
-
hidden?: boolean;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const NoContextError = () => {
|
|
22
|
-
console.error('Missing PanelInstanceContext Provider');
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Provides access to closing/popping panels
|
|
27
|
-
*/
|
|
28
|
-
export const PanelInstanceContext = createContext<PanelInstanceContextType>({
|
|
29
|
-
title: 'Missing PanelInstanceContext Provider: title',
|
|
30
|
-
uniqueId: 'Missing PanelInstanceContext Provider: uniqueId',
|
|
31
|
-
bounds: document.body,
|
|
32
|
-
setTitle: NoContextError,
|
|
33
|
-
panelTogglePopout: NoContextError,
|
|
34
|
-
panelClose: NoContextError,
|
|
35
|
-
setPanelWindow: NoContextError,
|
|
36
|
-
bringPanelToFront: NoContextError,
|
|
37
|
-
dock: NoContextError,
|
|
38
|
-
undock: NoContextError,
|
|
39
|
-
docked: false,
|
|
40
|
-
dockId: undefined,
|
|
41
|
-
panelPoppedOut: false,
|
|
42
|
-
zIndex: 0,
|
|
43
|
-
hidden: false,
|
|
44
|
-
});
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { PropsWithChildren, ReactElement, useCallback, useContext, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { PanelInstanceContext } from './PanelInstanceContext';
|
|
4
|
-
import { PanelInstance, PanelsContext } from './PanelsContext';
|
|
5
|
-
import { useRestoreStateFrom } from './usePanelStateHandler';
|
|
6
|
-
|
|
7
|
-
export interface PanelInstanceContextProviderProps {
|
|
8
|
-
hidden?: boolean;
|
|
9
|
-
bounds?: string | Element;
|
|
10
|
-
panelInstance: PanelInstance;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Provides access to closing/popping panels
|
|
15
|
-
*/
|
|
16
|
-
export const PanelInstanceContextProvider = ({
|
|
17
|
-
panelInstance,
|
|
18
|
-
bounds,
|
|
19
|
-
hidden,
|
|
20
|
-
children,
|
|
21
|
-
}: PropsWithChildren<PanelInstanceContextProviderProps>): ReactElement => {
|
|
22
|
-
const { closePanel, bringPanelToFront, dockElements } = useContext(PanelsContext);
|
|
23
|
-
const [title, setTitle] = useState('');
|
|
24
|
-
const [dockId, setDockId] = useState<string>();
|
|
25
|
-
|
|
26
|
-
const savedState = useRestoreStateFrom({ uniqueId: panelInstance.uniqueId });
|
|
27
|
-
const [poppedOut, setPoppedOut] = useState(savedState?.panelPoppedOut ?? panelInstance.poppedOut);
|
|
28
|
-
|
|
29
|
-
const togglePopOut = useCallback(() => {
|
|
30
|
-
panelInstance.window = null;
|
|
31
|
-
setPoppedOut(!poppedOut);
|
|
32
|
-
}, [panelInstance, poppedOut]);
|
|
33
|
-
|
|
34
|
-
const dock = useCallback(
|
|
35
|
-
(id: string) => {
|
|
36
|
-
if (poppedOut) togglePopOut();
|
|
37
|
-
setDockId(id);
|
|
38
|
-
},
|
|
39
|
-
[poppedOut, togglePopOut],
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
const undock = useCallback(() => setDockId(undefined), []);
|
|
43
|
-
|
|
44
|
-
const uniqueId = panelInstance.uniqueId;
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<PanelInstanceContext.Provider
|
|
48
|
-
value={{
|
|
49
|
-
title,
|
|
50
|
-
setTitle,
|
|
51
|
-
uniqueId,
|
|
52
|
-
bounds,
|
|
53
|
-
panelClose: () => {
|
|
54
|
-
panelInstance.window?.close();
|
|
55
|
-
panelInstance.window = null;
|
|
56
|
-
closePanel(uniqueId);
|
|
57
|
-
},
|
|
58
|
-
panelTogglePopout: togglePopOut,
|
|
59
|
-
panelPoppedOut: poppedOut,
|
|
60
|
-
setPanelWindow: (w: Window) => {
|
|
61
|
-
panelInstance.window = w;
|
|
62
|
-
},
|
|
63
|
-
bringPanelToFront: () => bringPanelToFront(uniqueId),
|
|
64
|
-
zIndex: panelInstance.zIndex,
|
|
65
|
-
docked: !poppedOut && !!dockId && !!dockElements[dockId],
|
|
66
|
-
dockId,
|
|
67
|
-
dock,
|
|
68
|
-
undock,
|
|
69
|
-
hidden,
|
|
70
|
-
}}
|
|
71
|
-
>
|
|
72
|
-
{children}
|
|
73
|
-
</PanelInstanceContext.Provider>
|
|
74
|
-
);
|
|
75
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { createContext, ReactElement } from 'react';
|
|
2
|
-
|
|
3
|
-
import { PanelPosition } from './types';
|
|
4
|
-
import { PanelStateOptions } from './types/PanelStateOptions';
|
|
5
|
-
|
|
6
|
-
export interface PanelInstance {
|
|
7
|
-
uniqueId: string;
|
|
8
|
-
componentInstance: ReactElement;
|
|
9
|
-
zIndex: number;
|
|
10
|
-
poppedOut: boolean;
|
|
11
|
-
window: Window | null;
|
|
12
|
-
onClose?: () => void;
|
|
13
|
-
hidden: boolean;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface OpenPanelOptions {
|
|
17
|
-
uniqueId?: string;
|
|
18
|
-
componentFn: () => ReactElement;
|
|
19
|
-
poppedOut?: boolean;
|
|
20
|
-
onClose?: () => void;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface PanelsContextType {
|
|
24
|
-
openPanels: Set<string>;
|
|
25
|
-
hasOpenPanel: (panelId: string) => boolean;
|
|
26
|
-
// returns unique id of panel that was created/or already found, otherwise null on error.
|
|
27
|
-
openPanel: (args: OpenPanelOptions) => string | null;
|
|
28
|
-
closePanel: (uniqueId: string | string[]) => void;
|
|
29
|
-
hidePanel: (uniqueId: string | string[]) => void;
|
|
30
|
-
unhidePanel: (uniqueId: string | string[]) => void;
|
|
31
|
-
hasHiddenPanel: (uniqueId: string) => boolean;
|
|
32
|
-
bringPanelToFront: (panelUniqueId: string) => void;
|
|
33
|
-
nextStackPosition: () => PanelPosition;
|
|
34
|
-
dockElements: Record<string, HTMLDivElement>;
|
|
35
|
-
setDockElement: (id: string, element: HTMLDivElement) => void;
|
|
36
|
-
panelStateOptions?: PanelStateOptions | null;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const NoContext = <T,>(): T => {
|
|
40
|
-
console.error('Missing PanelContext Provider');
|
|
41
|
-
return undefined as T;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export const PanelsContext = createContext<PanelsContextType>({
|
|
45
|
-
openPanels: new Set(),
|
|
46
|
-
hasOpenPanel: () => false,
|
|
47
|
-
openPanel: NoContext,
|
|
48
|
-
closePanel: NoContext,
|
|
49
|
-
hidePanel: NoContext,
|
|
50
|
-
unhidePanel: NoContext,
|
|
51
|
-
hasHiddenPanel: NoContext,
|
|
52
|
-
bringPanelToFront: NoContext,
|
|
53
|
-
dockElements: {},
|
|
54
|
-
setDockElement: NoContext,
|
|
55
|
-
nextStackPosition: () => ({ x: 0, y: 0 }),
|
|
56
|
-
});
|