ywana-core8 0.2.5 → 0.2.6
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/index.css +682 -0
- package/dist/index.js +28 -3
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +28 -3
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +28 -3
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/desktop/Desktop.stories.jsx +170 -0
- package/src/desktop/WindowContext.js +1 -0
- package/src/desktop/WindowManager.js +23 -0
- package/src/desktop/desktop-linux.css +232 -0
- package/src/desktop/desktop-macos.css +260 -0
- package/src/desktop/desktop-windows.css +190 -0
- package/src/desktop/desktop.js +8 -2
- package/src/desktop/window.js +9 -2
package/dist/index.js
CHANGED
@@ -31869,6 +31869,24 @@ class WindowManager {
|
|
31869
31869
|
this.notifyListeners();
|
31870
31870
|
return true;
|
31871
31871
|
}
|
31872
|
+
/**
|
31873
|
+
* Update window size
|
31874
|
+
*/
|
31875
|
+
updateWindowSize(windowId, size) {
|
31876
|
+
const window2 = this.windows.get(windowId);
|
31877
|
+
if (!window2) return false;
|
31878
|
+
const minWidth = 200;
|
31879
|
+
const minHeight = 150;
|
31880
|
+
const maxWidth = this.desktopSize.width;
|
31881
|
+
const maxHeight = this.desktopSize.height - 50;
|
31882
|
+
const constrainedSize = {
|
31883
|
+
width: Math.max(minWidth, Math.min(size.width || window2.size.width, maxWidth)),
|
31884
|
+
height: Math.max(minHeight, Math.min(size.height || window2.size.height, maxHeight))
|
31885
|
+
};
|
31886
|
+
window2.size = { ...window2.size, ...constrainedSize };
|
31887
|
+
this.notifyListeners();
|
31888
|
+
return true;
|
31889
|
+
}
|
31872
31890
|
/**
|
31873
31891
|
* Get all windows
|
31874
31892
|
*/
|
@@ -32031,6 +32049,7 @@ const WindowProvider = ({ children, desktopSize }) => {
|
|
32031
32049
|
minimizeWindow: (id, minimize) => windowManagerRef.current.minimizeWindow(id, minimize),
|
32032
32050
|
maximizeWindow: (id, maximize) => windowManagerRef.current.maximizeWindow(id, maximize),
|
32033
32051
|
updateWindowPosition: (id, position) => windowManagerRef.current.updateWindowPosition(id, position),
|
32052
|
+
updateWindowSize: (id, size) => windowManagerRef.current.updateWindowSize(id, size),
|
32034
32053
|
// Window queries
|
32035
32054
|
getWindow: (id) => windowManagerRef.current.getWindow(id),
|
32036
32055
|
getAllWindows: () => windowManagerRef.current.getAllWindows(),
|
@@ -32093,11 +32112,16 @@ const Window = ({
|
|
32093
32112
|
}) => {
|
32094
32113
|
const windowRef = React.useRef(null);
|
32095
32114
|
const headerRef = React.useRef(null);
|
32096
|
-
const { getWindow, updateWindowPosition, closeWindow, minimizeWindow, maximizeWindow, focusWindow } = useWindows();
|
32115
|
+
const { getWindow, updateWindowPosition, updateWindowSize, closeWindow, minimizeWindow, maximizeWindow, focusWindow } = useWindows();
|
32097
32116
|
const windowData = getWindow(id);
|
32098
32117
|
const [isDragging, setIsDragging] = React.useState(false);
|
32099
32118
|
const [dragOffset, setDragOffset] = React.useState({ x: 0, y: 0 });
|
32100
32119
|
const [dragStartPosition, setDragStartPosition] = React.useState({ x: 0, y: 0 });
|
32120
|
+
const [isResizing, setIsResizing] = React.useState(false);
|
32121
|
+
const [resizeDirection, setResizeDirection] = React.useState("");
|
32122
|
+
const [resizeStartSize, setResizeStartSize] = React.useState({ width: 0, height: 0 });
|
32123
|
+
const [resizeStartPosition, setResizeStartPosition] = React.useState({ x: 0, y: 0 });
|
32124
|
+
const [resizeStartMouse, setResizeStartMouse] = React.useState({ x: 0, y: 0 });
|
32101
32125
|
if (!windowData) {
|
32102
32126
|
return null;
|
32103
32127
|
}
|
@@ -32632,7 +32656,7 @@ const AppProvider = ({ children, appManager = defaultAppManager }) => {
|
|
32632
32656
|
};
|
32633
32657
|
return /* @__PURE__ */ React.createElement(AppContext.Provider, { value }, children);
|
32634
32658
|
};
|
32635
|
-
const DesktopLayout = ({ children, className = "", ...props }) => {
|
32659
|
+
const DesktopLayout = ({ children, className = "", theme = "windows", ...props }) => {
|
32636
32660
|
const desktopRef = React.useRef(null);
|
32637
32661
|
const { windowManager } = useWindows();
|
32638
32662
|
React.useEffect(() => {
|
@@ -32663,11 +32687,12 @@ const DesktopLayout = ({ children, className = "", ...props }) => {
|
|
32663
32687
|
e.preventDefault();
|
32664
32688
|
console.log("Desktop context menu at:", e.clientX, e.clientY);
|
32665
32689
|
};
|
32690
|
+
const themeClass = `desktop--${theme}`;
|
32666
32691
|
return /* @__PURE__ */ React.createElement(
|
32667
32692
|
"div",
|
32668
32693
|
{
|
32669
32694
|
ref: desktopRef,
|
32670
|
-
className: `desktop ${className}`,
|
32695
|
+
className: `desktop ${themeClass} ${className}`,
|
32671
32696
|
onContextMenu: handleContextMenu,
|
32672
32697
|
...props
|
32673
32698
|
},
|