ywana-core8 0.2.17 → 0.2.19
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 +231 -0
- package/dist/index.js +245 -2
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +245 -2
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +245 -2
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/desktop/Desktop.stories.jsx +522 -14
- package/src/desktop/index.js +1 -0
- package/src/desktop/window.css +231 -0
- package/src/desktop/window.js +341 -8
package/dist/index.umd.js
CHANGED
@@ -32421,7 +32421,7 @@ const rows = [
|
|
32421
32421
|
isResizing && "window--resizing",
|
32422
32422
|
className
|
32423
32423
|
].filter(Boolean).join(" ");
|
32424
|
-
return /* @__PURE__ */ React.createElement(
|
32424
|
+
return /* @__PURE__ */ React.createElement(WindowInstanceProvider, { windowId: id }, /* @__PURE__ */ React.createElement(
|
32425
32425
|
"div",
|
32426
32426
|
{
|
32427
32427
|
ref: windowRef,
|
@@ -32517,8 +32517,244 @@ const rows = [
|
|
32517
32517
|
className: "window__resize-handle window__resize-handle--sw",
|
32518
32518
|
onMouseDown: (e) => handleResizeStart(e, "sw")
|
32519
32519
|
}
|
32520
|
+
)),
|
32521
|
+
/* @__PURE__ */ React.createElement(FloatingElementsRenderer, null)
|
32522
|
+
));
|
32523
|
+
};
|
32524
|
+
const WindowInstanceContext = React.createContext(null);
|
32525
|
+
const WindowInstanceProvider = ({ windowId, children }) => {
|
32526
|
+
const [dialogs, setDialogs] = React.useState([]);
|
32527
|
+
const [notifications, setNotifications] = React.useState([]);
|
32528
|
+
const [tooltips, setTooltips] = React.useState([]);
|
32529
|
+
const [contextMenus, setContextMenus] = React.useState([]);
|
32530
|
+
const [overlays, setOverlays] = React.useState([]);
|
32531
|
+
const idCounterRef = React.useRef(0);
|
32532
|
+
const generateId = React.useCallback(() => {
|
32533
|
+
return `${windowId}-element-${++idCounterRef.current}`;
|
32534
|
+
}, [windowId]);
|
32535
|
+
const showDialog = React.useCallback((config) => {
|
32536
|
+
const id = generateId();
|
32537
|
+
const dialog = {
|
32538
|
+
id,
|
32539
|
+
type: "dialog",
|
32540
|
+
...config,
|
32541
|
+
createdAt: Date.now(),
|
32542
|
+
onClose: () => hideDialog(id)
|
32543
|
+
};
|
32544
|
+
setDialogs((prev) => [...prev, dialog]);
|
32545
|
+
return id;
|
32546
|
+
}, [generateId]);
|
32547
|
+
const hideDialog = React.useCallback((id) => {
|
32548
|
+
setDialogs((prev) => prev.filter((dialog) => dialog.id !== id));
|
32549
|
+
}, []);
|
32550
|
+
const hideAllDialogs = React.useCallback(() => {
|
32551
|
+
setDialogs([]);
|
32552
|
+
}, []);
|
32553
|
+
const showNotification = React.useCallback((config) => {
|
32554
|
+
const id = generateId();
|
32555
|
+
const notification = {
|
32556
|
+
id,
|
32557
|
+
type: "notification",
|
32558
|
+
duration: 5e3,
|
32559
|
+
...config,
|
32560
|
+
createdAt: Date.now(),
|
32561
|
+
onClose: () => hideNotification(id)
|
32562
|
+
};
|
32563
|
+
setNotifications((prev) => [...prev, notification]);
|
32564
|
+
if (notification.duration > 0) {
|
32565
|
+
setTimeout(() => hideNotification(id), notification.duration);
|
32566
|
+
}
|
32567
|
+
return id;
|
32568
|
+
}, [generateId]);
|
32569
|
+
const hideNotification = React.useCallback((id) => {
|
32570
|
+
setNotifications((prev) => prev.filter((notification) => notification.id !== id));
|
32571
|
+
}, []);
|
32572
|
+
const hideAllNotifications = React.useCallback(() => {
|
32573
|
+
setNotifications([]);
|
32574
|
+
}, []);
|
32575
|
+
const showTooltip = React.useCallback((config) => {
|
32576
|
+
const id = generateId();
|
32577
|
+
const tooltip = { id, type: "tooltip", ...config, createdAt: Date.now() };
|
32578
|
+
setTooltips((prev) => [...prev, tooltip]);
|
32579
|
+
return id;
|
32580
|
+
}, [generateId]);
|
32581
|
+
const hideTooltip = React.useCallback((id) => {
|
32582
|
+
setTooltips((prev) => prev.filter((tooltip) => tooltip.id !== id));
|
32583
|
+
}, []);
|
32584
|
+
const hideAllTooltips = React.useCallback(() => {
|
32585
|
+
setTooltips([]);
|
32586
|
+
}, []);
|
32587
|
+
const showContextMenu = React.useCallback((config) => {
|
32588
|
+
setContextMenus([]);
|
32589
|
+
const id = generateId();
|
32590
|
+
const contextMenu = {
|
32591
|
+
id,
|
32592
|
+
type: "contextMenu",
|
32593
|
+
...config,
|
32594
|
+
createdAt: Date.now(),
|
32595
|
+
onClose: () => hideContextMenu(id)
|
32596
|
+
};
|
32597
|
+
setContextMenus([contextMenu]);
|
32598
|
+
return id;
|
32599
|
+
}, [generateId]);
|
32600
|
+
const hideContextMenu = React.useCallback((id) => {
|
32601
|
+
setContextMenus((prev) => prev.filter((menu) => menu.id !== id));
|
32602
|
+
}, []);
|
32603
|
+
const hideAllContextMenus = React.useCallback(() => {
|
32604
|
+
setContextMenus([]);
|
32605
|
+
}, []);
|
32606
|
+
const showOverlay = React.useCallback((config) => {
|
32607
|
+
const id = generateId();
|
32608
|
+
const overlay = {
|
32609
|
+
id,
|
32610
|
+
type: "overlay",
|
32611
|
+
...config,
|
32612
|
+
createdAt: Date.now(),
|
32613
|
+
onClose: () => hideOverlay(id)
|
32614
|
+
};
|
32615
|
+
setOverlays((prev) => [...prev, overlay]);
|
32616
|
+
return id;
|
32617
|
+
}, [generateId]);
|
32618
|
+
const hideOverlay = React.useCallback((id) => {
|
32619
|
+
setOverlays((prev) => prev.filter((overlay) => overlay.id !== id));
|
32620
|
+
}, []);
|
32621
|
+
const hideAllOverlays = React.useCallback(() => {
|
32622
|
+
setOverlays([]);
|
32623
|
+
}, []);
|
32624
|
+
const clearAll = React.useCallback(() => {
|
32625
|
+
setDialogs([]);
|
32626
|
+
setNotifications([]);
|
32627
|
+
setTooltips([]);
|
32628
|
+
setContextMenus([]);
|
32629
|
+
setOverlays([]);
|
32630
|
+
}, []);
|
32631
|
+
const value = {
|
32632
|
+
windowId,
|
32633
|
+
dialogs,
|
32634
|
+
notifications,
|
32635
|
+
tooltips,
|
32636
|
+
contextMenus,
|
32637
|
+
overlays,
|
32638
|
+
showDialog,
|
32639
|
+
hideDialog,
|
32640
|
+
hideAllDialogs,
|
32641
|
+
showNotification,
|
32642
|
+
hideNotification,
|
32643
|
+
hideAllNotifications,
|
32644
|
+
showTooltip,
|
32645
|
+
hideTooltip,
|
32646
|
+
hideAllTooltips,
|
32647
|
+
showContextMenu,
|
32648
|
+
hideContextMenu,
|
32649
|
+
hideAllContextMenus,
|
32650
|
+
showOverlay,
|
32651
|
+
hideOverlay,
|
32652
|
+
hideAllOverlays,
|
32653
|
+
clearAll,
|
32654
|
+
generateId
|
32655
|
+
};
|
32656
|
+
return /* @__PURE__ */ React.createElement(WindowInstanceContext.Provider, { value }, children);
|
32657
|
+
};
|
32658
|
+
const useWindowInstance = () => {
|
32659
|
+
const context = React.useContext(WindowInstanceContext);
|
32660
|
+
if (!context) {
|
32661
|
+
throw new Error("useWindowInstance must be used within a WindowInstanceProvider");
|
32662
|
+
}
|
32663
|
+
return context;
|
32664
|
+
};
|
32665
|
+
const useWindowDialogs = () => {
|
32666
|
+
const { dialogs, showDialog, hideDialog, hideAllDialogs } = useWindowInstance();
|
32667
|
+
return { dialogs, showDialog, hideDialog, hideAllDialogs };
|
32668
|
+
};
|
32669
|
+
const useWindowNotifications = () => {
|
32670
|
+
const { notifications, showNotification, hideNotification, hideAllNotifications } = useWindowInstance();
|
32671
|
+
return { notifications, showNotification, hideNotification, hideAllNotifications };
|
32672
|
+
};
|
32673
|
+
const useWindowTooltips = () => {
|
32674
|
+
const { tooltips, showTooltip, hideTooltip, hideAllTooltips } = useWindowInstance();
|
32675
|
+
return { tooltips, showTooltip, hideTooltip, hideAllTooltips };
|
32676
|
+
};
|
32677
|
+
const useWindowContextMenus = () => {
|
32678
|
+
const { contextMenus, showContextMenu, hideContextMenu, hideAllContextMenus } = useWindowInstance();
|
32679
|
+
return { contextMenus, showContextMenu, hideContextMenu, hideAllContextMenus };
|
32680
|
+
};
|
32681
|
+
const useWindowOverlays = () => {
|
32682
|
+
const { overlays, showOverlay, hideOverlay, hideAllOverlays } = useWindowInstance();
|
32683
|
+
return { overlays, showOverlay, hideOverlay, hideAllOverlays };
|
32684
|
+
};
|
32685
|
+
const FloatingElementsRenderer = () => {
|
32686
|
+
const { dialogs, notifications, tooltips, contextMenus, overlays } = useWindowInstance();
|
32687
|
+
return /* @__PURE__ */ React.createElement("div", { className: "window-floating-elements" }, overlays.map((overlay) => /* @__PURE__ */ React.createElement("div", { key: overlay.id, className: "window-overlay" }, /* @__PURE__ */ React.createElement("div", { className: "window-overlay__content" }, overlay.content, overlay.showCloseButton !== false && /* @__PURE__ */ React.createElement(
|
32688
|
+
"button",
|
32689
|
+
{
|
32690
|
+
className: "window-dialog__close",
|
32691
|
+
onClick: () => overlay.onClose && overlay.onClose(),
|
32692
|
+
style: { position: "absolute", top: "8px", right: "8px" }
|
32693
|
+
},
|
32694
|
+
"×"
|
32695
|
+
)))), dialogs.map((dialog) => /* @__PURE__ */ React.createElement("div", { key: dialog.id, className: "window-dialog" }, /* @__PURE__ */ React.createElement("div", { className: "window-dialog__content" }, dialog.title && /* @__PURE__ */ React.createElement("div", { className: "window-dialog__header" }, /* @__PURE__ */ React.createElement("h3", { className: "window-dialog__title" }, dialog.title), /* @__PURE__ */ React.createElement(
|
32696
|
+
"button",
|
32697
|
+
{
|
32698
|
+
className: "window-dialog__close",
|
32699
|
+
onClick: () => dialog.onClose && dialog.onClose()
|
32700
|
+
},
|
32701
|
+
"×"
|
32702
|
+
)), /* @__PURE__ */ React.createElement("div", { className: "window-dialog__body" }, dialog.content), dialog.actions && /* @__PURE__ */ React.createElement("div", { className: "window-dialog__footer" }, dialog.actions)))), notifications.map((notification) => /* @__PURE__ */ React.createElement(
|
32703
|
+
"div",
|
32704
|
+
{
|
32705
|
+
key: notification.id,
|
32706
|
+
className: `window-notification window-notification--${notification.type || "info"}`,
|
32707
|
+
style: {
|
32708
|
+
top: `${16 + notifications.indexOf(notification) * 80}px`
|
32709
|
+
}
|
32710
|
+
},
|
32711
|
+
notification.icon && /* @__PURE__ */ React.createElement("div", { style: { fontSize: "18px", flexShrink: 0 } }, notification.icon),
|
32712
|
+
/* @__PURE__ */ React.createElement("div", { className: "window-notification__content" }, notification.title && /* @__PURE__ */ React.createElement("div", { className: "window-notification__title" }, notification.title), /* @__PURE__ */ React.createElement("div", { className: "window-notification__message" }, notification.message)),
|
32713
|
+
/* @__PURE__ */ React.createElement(
|
32714
|
+
"button",
|
32715
|
+
{
|
32716
|
+
className: "window-notification__close",
|
32717
|
+
onClick: () => notification.onClose && notification.onClose()
|
32718
|
+
},
|
32719
|
+
"×"
|
32720
|
+
)
|
32721
|
+
)), tooltips.map((tooltip) => /* @__PURE__ */ React.createElement(
|
32722
|
+
"div",
|
32723
|
+
{
|
32724
|
+
key: tooltip.id,
|
32725
|
+
className: "window-tooltip",
|
32726
|
+
style: {
|
32727
|
+
left: tooltip.x,
|
32728
|
+
top: tooltip.y,
|
32729
|
+
transform: tooltip.position === "top" ? "translateX(-50%) translateY(-100%)" : "translateX(-50%)"
|
32730
|
+
}
|
32731
|
+
},
|
32732
|
+
tooltip.text
|
32733
|
+
)), contextMenus.map((menu) => /* @__PURE__ */ React.createElement(
|
32734
|
+
"div",
|
32735
|
+
{
|
32736
|
+
key: menu.id,
|
32737
|
+
className: "window-context-menu",
|
32738
|
+
style: {
|
32739
|
+
left: menu.x,
|
32740
|
+
top: menu.y
|
32741
|
+
}
|
32742
|
+
},
|
32743
|
+
menu.items && menu.items.map((item, index) => /* @__PURE__ */ React.createElement(
|
32744
|
+
"div",
|
32745
|
+
{
|
32746
|
+
key: index,
|
32747
|
+
className: "window-context-menu__item",
|
32748
|
+
onClick: () => {
|
32749
|
+
item.onClick && item.onClick();
|
32750
|
+
menu.onClose && menu.onClose();
|
32751
|
+
}
|
32752
|
+
},
|
32753
|
+
item.icon && /* @__PURE__ */ React.createElement("span", null, item.icon),
|
32754
|
+
/* @__PURE__ */ React.createElement("span", null, item.label),
|
32755
|
+
item.shortcut && /* @__PURE__ */ React.createElement("span", { style: { marginLeft: "auto", fontSize: "11px", color: "#999" } }, item.shortcut)
|
32520
32756
|
))
|
32521
|
-
);
|
32757
|
+
)));
|
32522
32758
|
};
|
32523
32759
|
const ApplicationMenu = ({ isOpen, onClose }) => {
|
32524
32760
|
console.log("ApplicationMenu render - isOpen:", isOpen, "onClose:", onClose);
|
@@ -43185,6 +43421,7 @@ Middle click: Close`
|
|
43185
43421
|
exports2.ViewerTest = ViewerTest;
|
43186
43422
|
exports2.WaitScreen = WaitScreen;
|
43187
43423
|
exports2.Window = Window;
|
43424
|
+
exports2.WindowInstanceProvider = WindowInstanceProvider;
|
43188
43425
|
exports2.WindowManager = WindowManager;
|
43189
43426
|
exports2.WindowProvider = WindowProvider;
|
43190
43427
|
exports2.Wizard = Wizard;
|
@@ -43198,7 +43435,13 @@ Middle click: Close`
|
|
43198
43435
|
exports2.useCreateWindow = useCreateWindow;
|
43199
43436
|
exports2.useHashPage = useHashPage;
|
43200
43437
|
exports2.useWindow = useWindow;
|
43438
|
+
exports2.useWindowContextMenus = useWindowContextMenus;
|
43439
|
+
exports2.useWindowDialogs = useWindowDialogs;
|
43440
|
+
exports2.useWindowInstance = useWindowInstance;
|
43441
|
+
exports2.useWindowNotifications = useWindowNotifications;
|
43442
|
+
exports2.useWindowOverlays = useWindowOverlays;
|
43201
43443
|
exports2.useWindowStats = useWindowStats;
|
43444
|
+
exports2.useWindowTooltips = useWindowTooltips;
|
43202
43445
|
exports2.useWindows = useWindows;
|
43203
43446
|
exports2.validatePassword = validatePassword;
|
43204
43447
|
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|