@asymmetric-effort/specifyjs 0.2.140 → 0.2.142

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.
@@ -11896,7 +11896,15 @@ var WindowManagerContext = createContext({
11896
11896
  },
11897
11897
  minimizeAll: () => {
11898
11898
  },
11899
- focusedWindowId: null
11899
+ focusedWindowId: null,
11900
+ setMenuBar: () => {
11901
+ },
11902
+ clearMenuBar: () => {
11903
+ },
11904
+ activeMenuBar: null,
11905
+ signalDock: () => {
11906
+ },
11907
+ dockSignals: /* @__PURE__ */ new Map()
11900
11908
  });
11901
11909
  var DEFAULT_WINDOW_SIZE = { width: 600, height: 400 };
11902
11910
  var DEFAULT_CASCADE_OFFSET = { x: 30, y: 30 };
@@ -12001,6 +12009,22 @@ function WindowManagerProvider(props) {
12001
12009
  const closeWindow = useCallback(
12002
12010
  ((...args) => {
12003
12011
  const id = args[0];
12012
+ setMenuBars((prev) => {
12013
+ if (prev[id]) {
12014
+ const next = { ...prev };
12015
+ delete next[id];
12016
+ return next;
12017
+ }
12018
+ return prev;
12019
+ });
12020
+ setDockSignals((prev) => {
12021
+ if (prev.has(id)) {
12022
+ const next = new Map(prev);
12023
+ next.delete(id);
12024
+ return next;
12025
+ }
12026
+ return prev;
12027
+ });
12004
12028
  setWindows((prev) => {
12005
12029
  const closing = prev.find((w) => w.id === id);
12006
12030
  if (!closing) return prev;
@@ -12255,6 +12279,46 @@ function WindowManagerProvider(props) {
12255
12279
  const focused = windows.find((w) => w.focused);
12256
12280
  return focused ? focused.id : null;
12257
12281
  }, [windows]);
12282
+ const [menuBars, setMenuBars] = useState({});
12283
+ const [dockSignals, setDockSignals] = useState(/* @__PURE__ */ new Map());
12284
+ const setMenuBar = useCallback(
12285
+ ((...args) => {
12286
+ const appId = args[0];
12287
+ const menuBar = args[1];
12288
+ setMenuBars((prev) => ({ ...prev, [appId]: menuBar }));
12289
+ }),
12290
+ []
12291
+ );
12292
+ const clearMenuBar = useCallback(
12293
+ ((...args) => {
12294
+ const appId = args[0];
12295
+ setMenuBars((prev) => {
12296
+ const next = { ...prev };
12297
+ delete next[appId];
12298
+ return next;
12299
+ });
12300
+ }),
12301
+ []
12302
+ );
12303
+ const activeMenuBar = useMemo(() => {
12304
+ if (focusedWindowId && menuBars[focusedWindowId]) {
12305
+ return menuBars[focusedWindowId];
12306
+ }
12307
+ return null;
12308
+ }, [focusedWindowId, menuBars]);
12309
+ const signalDock = useCallback(
12310
+ ((...args) => {
12311
+ const appId = args[0];
12312
+ const signal = args[1];
12313
+ setDockSignals((prev) => {
12314
+ const next = new Map(prev);
12315
+ const existing = next.get(appId);
12316
+ next.set(appId, { ...existing, ...signal });
12317
+ return next;
12318
+ });
12319
+ }),
12320
+ []
12321
+ );
12258
12322
  const value = useMemo(
12259
12323
  () => ({
12260
12324
  windows,
@@ -12269,7 +12333,12 @@ function WindowManagerProvider(props) {
12269
12333
  tileWindows,
12270
12334
  cascadeWindows,
12271
12335
  minimizeAll,
12272
- focusedWindowId
12336
+ focusedWindowId,
12337
+ setMenuBar,
12338
+ clearMenuBar,
12339
+ activeMenuBar,
12340
+ signalDock,
12341
+ dockSignals
12273
12342
  }),
12274
12343
  [
12275
12344
  windows,
@@ -12284,7 +12353,12 @@ function WindowManagerProvider(props) {
12284
12353
  tileWindows,
12285
12354
  cascadeWindows,
12286
12355
  minimizeAll,
12287
- focusedWindowId
12356
+ focusedWindowId,
12357
+ setMenuBar,
12358
+ clearMenuBar,
12359
+ activeMenuBar,
12360
+ signalDock,
12361
+ dockSignals
12288
12362
  ]
12289
12363
  );
12290
12364
  return createElement(WindowManagerContext.Provider, { value }, props.children);
@@ -12634,10 +12708,154 @@ function UserMenu(props) {
12634
12708
  dropdown
12635
12709
  );
12636
12710
  }
12711
+ function AppMenuDropdown(props) {
12712
+ const { menu } = props;
12713
+ const { hover, onMouseEnter, onMouseLeave } = useHover();
12714
+ const [open, setOpen] = useState(false);
12715
+ const containerRef = useRef(null);
12716
+ const handleToggle = useCallback(() => {
12717
+ setOpen((prev) => !prev);
12718
+ }, []);
12719
+ const handleClose = useCallback(() => {
12720
+ setOpen(false);
12721
+ }, []);
12722
+ const handleKeyDown = useCallback((e) => {
12723
+ const ke = e;
12724
+ if (ke.key === "Enter" || ke.key === " ") {
12725
+ ke.preventDefault();
12726
+ setOpen((prev) => !prev);
12727
+ }
12728
+ if (ke.key === "Escape") {
12729
+ setOpen(false);
12730
+ }
12731
+ }, []);
12732
+ useEffect(() => {
12733
+ if (!open) return;
12734
+ const handleDocClick = (e) => {
12735
+ const container = containerRef.current;
12736
+ if (container && !container.contains(e.target)) {
12737
+ setOpen(false);
12738
+ }
12739
+ };
12740
+ document.addEventListener("click", handleDocClick, true);
12741
+ return () => {
12742
+ document.removeEventListener("click", handleDocClick, true);
12743
+ };
12744
+ }, [open]);
12745
+ const dropdown = open && menu.items.length > 0 ? createElement(
12746
+ "div",
12747
+ {
12748
+ role: "menu",
12749
+ "aria-label": menu.label + " menu",
12750
+ style: {
12751
+ position: "absolute",
12752
+ top: "100%",
12753
+ left: "0",
12754
+ marginTop: "2px",
12755
+ backgroundColor: "var(--panel-bg, #2c2c2c)",
12756
+ border: "1px solid var(--panel-divider, #555555)",
12757
+ borderRadius: "6px",
12758
+ boxShadow: "0 4px 12px rgba(0,0,0,0.3)",
12759
+ padding: "4px 0",
12760
+ minWidth: "180px",
12761
+ zIndex: "1000"
12762
+ }
12763
+ },
12764
+ ...menu.items.map(
12765
+ (item, i) => {
12766
+ if (item.divider) {
12767
+ return createElement("div", {
12768
+ key: "div-" + String(i),
12769
+ role: "separator",
12770
+ style: {
12771
+ height: "1px",
12772
+ backgroundColor: "var(--panel-divider, #555555)",
12773
+ margin: "4px 0"
12774
+ }
12775
+ });
12776
+ }
12777
+ return createElement(
12778
+ "button",
12779
+ {
12780
+ key: String(i),
12781
+ type: "button",
12782
+ role: "menuitem",
12783
+ tabIndex: -1,
12784
+ disabled: item.disabled ?? false,
12785
+ onClick: () => {
12786
+ if (item.onClick) item.onClick();
12787
+ handleClose();
12788
+ },
12789
+ style: {
12790
+ display: "flex",
12791
+ alignItems: "center",
12792
+ justifyContent: "space-between",
12793
+ width: "100%",
12794
+ padding: "6px 16px",
12795
+ border: "none",
12796
+ outline: "none",
12797
+ backgroundColor: "transparent",
12798
+ color: item.disabled ? "rgba(255,255,255,0.4)" : "var(--panel-text, #ffffff)",
12799
+ fontFamily: "inherit",
12800
+ fontSize: "13px",
12801
+ textAlign: "left",
12802
+ cursor: item.disabled ? "default" : "pointer",
12803
+ boxSizing: "border-box"
12804
+ }
12805
+ },
12806
+ createElement(
12807
+ "span",
12808
+ null,
12809
+ item.checked ? "\u2713 " : "",
12810
+ item.label || ""
12811
+ ),
12812
+ item.shortcut ? createElement("span", {
12813
+ style: { fontSize: "11px", opacity: "0.6", marginLeft: "16px" }
12814
+ }, item.shortcut) : null
12815
+ );
12816
+ }
12817
+ )
12818
+ ) : null;
12819
+ return createElement(
12820
+ "div",
12821
+ {
12822
+ ref: containerRef,
12823
+ className: "system-tray__app-menu",
12824
+ style: { position: "relative", display: "inline-flex", height: "100%" }
12825
+ },
12826
+ createElement("button", {
12827
+ type: "button",
12828
+ "aria-haspopup": "true",
12829
+ "aria-expanded": String(open),
12830
+ tabIndex: 0,
12831
+ onClick: handleToggle,
12832
+ onKeyDown: handleKeyDown,
12833
+ onMouseEnter,
12834
+ onMouseLeave,
12835
+ style: {
12836
+ display: "inline-flex",
12837
+ alignItems: "center",
12838
+ padding: "0 10px",
12839
+ height: "100%",
12840
+ border: "none",
12841
+ outline: "none",
12842
+ backgroundColor: hover || open ? "rgba(255,255,255,0.15)" : "transparent",
12843
+ color: "inherit",
12844
+ fontFamily: "inherit",
12845
+ fontSize: "13px",
12846
+ fontWeight: "500",
12847
+ cursor: "pointer",
12848
+ transition: "background-color 0.15s"
12849
+ }
12850
+ }, menu.label),
12851
+ dropdown
12852
+ );
12853
+ }
12637
12854
  function SystemTray(props) {
12638
12855
  const {
12639
12856
  activeAppName,
12640
12857
  activitiesButton,
12858
+ appMenuBar,
12641
12859
  clockFormat = "24h",
12642
12860
  showSeconds = true,
12643
12861
  showDate = true,
@@ -12674,6 +12892,16 @@ function SystemTray(props) {
12674
12892
  }, activeAppName)
12675
12893
  );
12676
12894
  }
12895
+ if (appMenuBar && appMenuBar.menus.length > 0) {
12896
+ for (let mi = 0; mi < appMenuBar.menus.length; mi++) {
12897
+ leftChildren.push(
12898
+ createElement(AppMenuDropdown, {
12899
+ key: "appmenu-" + String(mi),
12900
+ menu: appMenuBar.menus[mi]
12901
+ })
12902
+ );
12903
+ }
12904
+ }
12677
12905
  const leftSection = createElement("div", {
12678
12906
  style: {
12679
12907
  display: "flex",
@@ -12933,6 +13161,33 @@ function DockItemComponent(props) {
12933
13161
  },
12934
13162
  "aria-hidden": "true"
12935
13163
  }) : null;
13164
+ const progressEl = item.progress != null && item.progress > 0 ? createElement(
13165
+ "div",
13166
+ {
13167
+ style: {
13168
+ position: "absolute",
13169
+ bottom: "2px",
13170
+ left: "6px",
13171
+ right: "6px",
13172
+ height: "3px",
13173
+ backgroundColor: "rgba(255,255,255,0.2)",
13174
+ borderRadius: "2px",
13175
+ overflow: "hidden",
13176
+ pointerEvents: "none",
13177
+ zIndex: "2"
13178
+ },
13179
+ "aria-hidden": "true"
13180
+ },
13181
+ createElement("div", {
13182
+ style: {
13183
+ width: `${Math.min(1, Math.max(0, item.progress)) * 100}%`,
13184
+ height: "100%",
13185
+ backgroundColor: "var(--dock-progress-color, #3b82f6)",
13186
+ borderRadius: "2px",
13187
+ transition: "width 200ms ease"
13188
+ }
13189
+ })
13190
+ ) : null;
12936
13191
  const tooltipEl = hover ? createElement("div", {
12937
13192
  role: "tooltip",
12938
13193
  style: {
@@ -12962,7 +13217,8 @@ function DockItemComponent(props) {
12962
13217
  transition: "transform 100ms, background-color 100ms",
12963
13218
  borderRadius: "8px",
12964
13219
  outline: "none",
12965
- ...hover && !disabled ? { transform: "scale(1.1)", backgroundColor: "rgba(255,255,255,0.15)" } : {}
13220
+ ...hover && !disabled ? { transform: "scale(1.1)", backgroundColor: "rgba(255,255,255,0.15)" } : {},
13221
+ ...item.urgent && !disabled ? { animation: "dock-urgent-pulse 0.6s ease-in-out infinite alternate" } : {}
12966
13222
  };
12967
13223
  return createElement(
12968
13224
  "button",
@@ -12978,11 +13234,13 @@ function DockItemComponent(props) {
12978
13234
  onContextMenu: handleContextMenu,
12979
13235
  onMouseEnter: handleMouseEnter,
12980
13236
  onMouseLeave: handleMouseLeave,
12981
- "data-dock-item-id": item.id
13237
+ "data-dock-item-id": item.id,
13238
+ "data-urgent": item.urgent ? "true" : void 0
12982
13239
  },
12983
13240
  iconEl,
12984
13241
  badgeEl,
12985
13242
  activeDotEl,
13243
+ progressEl,
12986
13244
  tooltipEl
12987
13245
  );
12988
13246
  }
@@ -15988,6 +16246,9 @@ function getMockContent(title) {
15988
16246
  }
15989
16247
  function UnityDesktopInner(props) {
15990
16248
  const { apps, user, onAppOpen, onLogout, theme = "dark", children } = props;
16249
+ const wm = useWindowManager();
16250
+ const wmActiveMenuBar = wm.activeMenuBar;
16251
+ const wmDockSignals = wm.dockSignals;
15991
16252
  const [openWindows, setOpenWindows] = useState([]);
15992
16253
  const [toasts, setToasts] = useState([]);
15993
16254
  const [showAppsGrid, setShowAppsGrid] = useState(false);
@@ -16040,16 +16301,54 @@ function UnityDesktopInner(props) {
16040
16301
  };
16041
16302
  return [...prev.map((w) => ({ ...w, focused: false })), newWin];
16042
16303
  });
16304
+ if (id === "files") {
16305
+ wm.setMenuBar("files", {
16306
+ menus: [
16307
+ {
16308
+ label: "File",
16309
+ items: [
16310
+ { label: "New", shortcut: "Ctrl+N", onClick: () => {
16311
+ } },
16312
+ { label: "Open", shortcut: "Ctrl+O", onClick: () => {
16313
+ } },
16314
+ { label: "Save", shortcut: "Ctrl+S", onClick: () => {
16315
+ } }
16316
+ ]
16317
+ },
16318
+ {
16319
+ label: "Edit",
16320
+ items: [
16321
+ { label: "Cut", shortcut: "Ctrl+X", onClick: () => {
16322
+ } },
16323
+ { label: "Copy", shortcut: "Ctrl+C", onClick: () => {
16324
+ } },
16325
+ { label: "Paste", shortcut: "Ctrl+V", onClick: () => {
16326
+ } }
16327
+ ]
16328
+ }
16329
+ ]
16330
+ });
16331
+ }
16332
+ if (id === "terminal") {
16333
+ wm.signalDock("terminal", { badge: 3 });
16334
+ }
16043
16335
  if (onAppOpenRef.current) onAppOpenRef.current(id);
16044
- }, []);
16336
+ }, [wm]);
16045
16337
  const dockItems = apps.map((app) => {
16046
16338
  const isRunning = openWindows.some((w) => w.id === app.id);
16047
- return {
16339
+ const signal = wmDockSignals.get(app.id);
16340
+ const item = {
16048
16341
  id: app.id,
16049
16342
  icon: app.icon,
16050
- label: app.label,
16343
+ label: signal?.tooltip || app.label,
16051
16344
  active: isRunning
16052
16345
  };
16346
+ if (signal) {
16347
+ if (signal.badge != null) item.badge = signal.badge > 0 ? signal.badge : void 0;
16348
+ if (signal.progress != null) item.progress = signal.progress > 0 ? signal.progress : void 0;
16349
+ if (signal.urgent) item.urgent = true;
16350
+ }
16351
+ return item;
16053
16352
  });
16054
16353
  const focusedWindow = openWindows.find((w) => w.focused);
16055
16354
  const activeAppName = focusedWindow ? focusedWindow.title : void 0;
@@ -16111,6 +16410,7 @@ function UnityDesktopInner(props) {
16111
16410
  const systemTrayEl = createElement(SystemTray, {
16112
16411
  activeAppName,
16113
16412
  activitiesButton: { label: "Activities", onClick: toggleAppsGrid },
16413
+ appMenuBar: wmActiveMenuBar || void 0,
16114
16414
  clockFormat: "24h",
16115
16415
  showSeconds: true,
16116
16416
  showDate: true,
@@ -16387,22 +16687,36 @@ function UnityApp(props) {
16387
16687
  minSize,
16388
16688
  resizable = true,
16389
16689
  onClose,
16690
+ menuBar,
16691
+ onActivate,
16692
+ onDeactivate,
16390
16693
  children
16391
16694
  } = props;
16392
16695
  const windowManager = useWindowManager();
16393
16696
  const windowState = useMemo(() => {
16394
16697
  return windowManager.windows.find((w) => w.id === id);
16395
16698
  }, [windowManager.windows, id]);
16396
- if (!windowState) {
16397
- windowManager.openWindow({
16398
- id,
16399
- title,
16400
- icon,
16401
- position: defaultPosition,
16402
- size: defaultSize
16403
- });
16404
- return null;
16405
- }
16699
+ useEffect(() => {
16700
+ if (menuBar) {
16701
+ windowManager.setMenuBar(id, menuBar);
16702
+ } else {
16703
+ windowManager.clearMenuBar(id);
16704
+ }
16705
+ return () => {
16706
+ windowManager.clearMenuBar(id);
16707
+ };
16708
+ }, [menuBar, id, windowManager]);
16709
+ const wasFocusedRef = useRef(false);
16710
+ const isFocused = windowState ? windowState.focused : false;
16711
+ useEffect(() => {
16712
+ const wasFocused = wasFocusedRef.current;
16713
+ wasFocusedRef.current = isFocused;
16714
+ if (isFocused && !wasFocused) {
16715
+ if (onActivate) onActivate();
16716
+ } else if (!isFocused && wasFocused) {
16717
+ if (onDeactivate) onDeactivate();
16718
+ }
16719
+ }, [isFocused, onActivate, onDeactivate]);
16406
16720
  const handleClose = useCallback(() => {
16407
16721
  windowManager.closeWindow(id);
16408
16722
  if (onClose) onClose();
@@ -16426,6 +16740,16 @@ function UnityApp(props) {
16426
16740
  windowManager.maximizeWindow(id);
16427
16741
  }
16428
16742
  }, [windowManager, id, windowState]);
16743
+ if (!windowState) {
16744
+ windowManager.openWindow({
16745
+ id,
16746
+ title,
16747
+ icon,
16748
+ position: defaultPosition,
16749
+ size: defaultSize
16750
+ });
16751
+ return null;
16752
+ }
16429
16753
  return createElement(DraggableWindow, {
16430
16754
  id,
16431
16755
  title,