ywana-core8 0.2.6 → 0.2.9

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.umd.js CHANGED
@@ -1988,7 +1988,9 @@
1988
1988
  icon: loading ? "hourglass_empty" : icon,
1989
1989
  size: size === "small" ? "small" : size === "large" ? "normal" : "small",
1990
1990
  disabled: disabled || loading,
1991
- className: loading ? "loading-icon" : ""
1991
+ className: loading ? "loading-icon" : "",
1992
+ eventPropagation: true
1993
+ // Allow click events to bubble up to button
1992
1994
  };
1993
1995
  return /* @__PURE__ */ React.createElement(
1994
1996
  "button",
@@ -31711,6 +31713,7 @@ const rows = [
31711
31713
  this.windows = /* @__PURE__ */ new Map();
31712
31714
  this.activeWindowId = null;
31713
31715
  this.nextZIndex = 1e3;
31716
+ this.maxZIndex = 9999;
31714
31717
  this.listeners = /* @__PURE__ */ new Set();
31715
31718
  this.desktopSize = desktopSize;
31716
31719
  }
@@ -31772,7 +31775,7 @@ const rows = [
31772
31775
  size,
31773
31776
  minimized: false,
31774
31777
  maximized: false,
31775
- zIndex: this.nextZIndex++,
31778
+ zIndex: Math.min(this.nextZIndex++, this.maxZIndex),
31776
31779
  ...config
31777
31780
  };
31778
31781
  this.windows.set(window2.id, window2);
@@ -31791,7 +31794,7 @@ const rows = [
31791
31794
  let x = baseX + existingWindows.length * offsetStep;
31792
31795
  let y = baseY + existingWindows.length * offsetStep;
31793
31796
  const maxX = this.desktopSize.width - windowSize.width - 20;
31794
- const maxY = this.desktopSize.height - windowSize.height - 100;
31797
+ const maxY = this.desktopSize.height - windowSize.height - 20;
31795
31798
  if (x > maxX || y > maxY) {
31796
31799
  const cascadeIndex = existingWindows.length % 8;
31797
31800
  x = baseX + cascadeIndex * 30;
@@ -31827,7 +31830,10 @@ const rows = [
31827
31830
  if (window2.minimized) {
31828
31831
  window2.minimized = false;
31829
31832
  }
31830
- window2.zIndex = this.nextZIndex++;
31833
+ if (this.nextZIndex >= this.maxZIndex) {
31834
+ this.resetZIndexes();
31835
+ }
31836
+ window2.zIndex = Math.min(this.nextZIndex++, this.maxZIndex);
31831
31837
  this.activeWindowId = windowId;
31832
31838
  this.notifyListeners();
31833
31839
  return true;
@@ -31879,7 +31885,7 @@ const rows = [
31879
31885
  const minWidth = 200;
31880
31886
  const minHeight = 150;
31881
31887
  const maxWidth = this.desktopSize.width;
31882
- const maxHeight = this.desktopSize.height - 50;
31888
+ const maxHeight = this.desktopSize.height;
31883
31889
  const constrainedSize = {
31884
31890
  width: Math.max(minWidth, Math.min(size.width || window2.size.width, maxWidth)),
31885
31891
  height: Math.max(minHeight, Math.min(size.height || window2.size.height, maxHeight))
@@ -31915,7 +31921,7 @@ const rows = [
31915
31921
  this.windows.forEach((window2) => {
31916
31922
  if (window2.maximized) return;
31917
31923
  const maxX = this.desktopSize.width - window2.size.width;
31918
- const maxY = this.desktopSize.height - window2.size.height - 50;
31924
+ const maxY = this.desktopSize.height - window2.size.height;
31919
31925
  if (window2.position.x > maxX) {
31920
31926
  window2.position.x = Math.max(0, maxX);
31921
31927
  }
@@ -31950,7 +31956,7 @@ const rows = [
31950
31956
  const cols = Math.ceil(Math.sqrt(visibleWindows.length));
31951
31957
  const rows = Math.ceil(visibleWindows.length / cols);
31952
31958
  const windowWidth = Math.floor(this.desktopSize.width / cols);
31953
- const windowHeight = Math.floor((this.desktopSize.height - 80) / rows);
31959
+ const windowHeight = Math.floor(this.desktopSize.height / rows);
31954
31960
  visibleWindows.forEach((window2, index) => {
31955
31961
  const col = index % cols;
31956
31962
  const row = Math.floor(index / cols);
@@ -31975,8 +31981,8 @@ const rows = [
31975
31981
  if (!window2 || window2.maximized) return false;
31976
31982
  window2.position = {
31977
31983
  x: (this.desktopSize.width - window2.size.width) / 2,
31978
- y: (this.desktopSize.height - window2.size.height - 50) / 2
31979
- // Space for taskbar
31984
+ y: (this.desktopSize.height - window2.size.height) / 2
31985
+ // Workspace center
31980
31986
  };
31981
31987
  this.notifyListeners();
31982
31988
  return true;
@@ -31989,7 +31995,7 @@ const rows = [
31989
31995
  const offsetStep = 20;
31990
31996
  visibleWindows.forEach((window2, index) => {
31991
31997
  const baseX = (this.desktopSize.width - window2.size.width) / 2;
31992
- const baseY = (this.desktopSize.height - window2.size.height - 50) / 2;
31998
+ const baseY = (this.desktopSize.height - window2.size.height) / 2;
31993
31999
  window2.position = {
31994
32000
  x: baseX + index * offsetStep,
31995
32001
  y: baseY + index * offsetStep
@@ -32010,6 +32016,19 @@ const rows = [
32010
32016
  desktopSize: this.desktopSize
32011
32017
  };
32012
32018
  }
32019
+ /**
32020
+ * Reset z-indexes when they reach the maximum
32021
+ */
32022
+ resetZIndexes() {
32023
+ const windows = Array.from(this.windows.values());
32024
+ windows.sort((a, b) => a.zIndex - b.zIndex);
32025
+ this.nextZIndex = 1e3;
32026
+ windows.forEach((window2, index) => {
32027
+ window2.zIndex = this.nextZIndex + index;
32028
+ });
32029
+ this.nextZIndex = 1e3 + windows.length;
32030
+ this.notifyListeners();
32031
+ }
32013
32032
  }
32014
32033
  const WindowContext = React.createContext(null);
32015
32034
  const WindowProvider = ({ children, desktopSize }) => {
@@ -32034,8 +32053,10 @@ const rows = [
32034
32053
  }
32035
32054
  }, [desktopSize]);
32036
32055
  if (!state || !windowManagerRef.current) {
32056
+ console.log("WindowProvider not ready - state:", state, "windowManager:", windowManagerRef.current);
32037
32057
  return null;
32038
32058
  }
32059
+ console.log("WindowProvider ready - providing context");
32039
32060
  const value = {
32040
32061
  // Current state
32041
32062
  windows: state.windows,
@@ -32177,6 +32198,86 @@ const rows = [
32177
32198
  };
32178
32199
  updateWindowPosition(id, finalPosition);
32179
32200
  };
32201
+ const handleResizeStart = (e, direction) => {
32202
+ if (!resizable || maximized) return;
32203
+ e.preventDefault();
32204
+ e.stopPropagation();
32205
+ setIsResizing(true);
32206
+ setResizeDirection(direction);
32207
+ setResizeStartSize(size);
32208
+ setResizeStartPosition(position);
32209
+ setResizeStartMouse({ x: e.clientX, y: e.clientY });
32210
+ focusWindow(id);
32211
+ };
32212
+ const handleResizeMove = (e) => {
32213
+ if (!isResizing) return;
32214
+ e.preventDefault();
32215
+ const deltaX = e.clientX - resizeStartMouse.x;
32216
+ const deltaY = e.clientY - resizeStartMouse.y;
32217
+ let newSize = { ...resizeStartSize };
32218
+ let newPosition = { ...resizeStartPosition };
32219
+ switch (resizeDirection) {
32220
+ case "n":
32221
+ newSize.height = Math.max(150, resizeStartSize.height - deltaY);
32222
+ newPosition.y = resizeStartPosition.y + (resizeStartSize.height - newSize.height);
32223
+ break;
32224
+ case "s":
32225
+ newSize.height = Math.max(150, resizeStartSize.height + deltaY);
32226
+ break;
32227
+ case "e":
32228
+ newSize.width = Math.max(200, resizeStartSize.width + deltaX);
32229
+ break;
32230
+ case "w":
32231
+ newSize.width = Math.max(200, resizeStartSize.width - deltaX);
32232
+ newPosition.x = resizeStartPosition.x + (resizeStartSize.width - newSize.width);
32233
+ break;
32234
+ case "ne":
32235
+ newSize.width = Math.max(200, resizeStartSize.width + deltaX);
32236
+ newSize.height = Math.max(150, resizeStartSize.height - deltaY);
32237
+ newPosition.y = resizeStartPosition.y + (resizeStartSize.height - newSize.height);
32238
+ break;
32239
+ case "nw":
32240
+ newSize.width = Math.max(200, resizeStartSize.width - deltaX);
32241
+ newSize.height = Math.max(150, resizeStartSize.height - deltaY);
32242
+ newPosition.x = resizeStartPosition.x + (resizeStartSize.width - newSize.width);
32243
+ newPosition.y = resizeStartPosition.y + (resizeStartSize.height - newSize.height);
32244
+ break;
32245
+ case "se":
32246
+ newSize.width = Math.max(200, resizeStartSize.width + deltaX);
32247
+ newSize.height = Math.max(150, resizeStartSize.height + deltaY);
32248
+ break;
32249
+ case "sw":
32250
+ newSize.width = Math.max(200, resizeStartSize.width - deltaX);
32251
+ newSize.height = Math.max(150, resizeStartSize.height + deltaY);
32252
+ newPosition.x = resizeStartPosition.x + (resizeStartSize.width - newSize.width);
32253
+ break;
32254
+ }
32255
+ if (windowRef.current) {
32256
+ windowRef.current.style.width = `${newSize.width}px`;
32257
+ windowRef.current.style.height = `${newSize.height}px`;
32258
+ windowRef.current.style.left = `${newPosition.x}px`;
32259
+ windowRef.current.style.top = `${newPosition.y}px`;
32260
+ }
32261
+ };
32262
+ const handleResizeEnd = () => {
32263
+ if (!isResizing) return;
32264
+ setIsResizing(false);
32265
+ setResizeDirection("");
32266
+ const desktopContainer = windowRef.current?.parentElement;
32267
+ if (!desktopContainer) return;
32268
+ const windowRect = windowRef.current.getBoundingClientRect();
32269
+ const desktopRect = desktopContainer.getBoundingClientRect();
32270
+ const finalSize = {
32271
+ width: windowRect.width,
32272
+ height: windowRect.height
32273
+ };
32274
+ const finalPosition = {
32275
+ x: windowRect.left - desktopRect.left,
32276
+ y: windowRect.top - desktopRect.top
32277
+ };
32278
+ updateWindowSize(id, finalSize);
32279
+ updateWindowPosition(id, finalPosition);
32280
+ };
32180
32281
  React.useEffect(() => {
32181
32282
  if (isDragging) {
32182
32283
  document.addEventListener("mousemove", handleMouseMove);
@@ -32191,6 +32292,18 @@ const rows = [
32191
32292
  };
32192
32293
  }
32193
32294
  }, [isDragging]);
32295
+ React.useEffect(() => {
32296
+ if (isResizing) {
32297
+ document.addEventListener("mousemove", handleResizeMove);
32298
+ document.addEventListener("mouseup", handleResizeEnd);
32299
+ document.body.style.userSelect = "none";
32300
+ return () => {
32301
+ document.removeEventListener("mousemove", handleResizeMove);
32302
+ document.removeEventListener("mouseup", handleResizeEnd);
32303
+ document.body.style.userSelect = "";
32304
+ };
32305
+ }
32306
+ }, [isResizing]);
32194
32307
  const handleMinimize = (e) => {
32195
32308
  e.stopPropagation();
32196
32309
  minimizeWindow(id, !minimized);
@@ -32225,6 +32338,7 @@ const rows = [
32225
32338
  "window",
32226
32339
  maximized && "window--maximized",
32227
32340
  isDragging && "window--dragging",
32341
+ isResizing && "window--resizing",
32228
32342
  className
32229
32343
  ].filter(Boolean).join(" ");
32230
32344
  return /* @__PURE__ */ React.createElement(
@@ -32274,15 +32388,67 @@ const rows = [
32274
32388
  ),
32275
32389
  toolbar && /* @__PURE__ */ React.createElement("div", { className: "window__toolbar" }, toolbar),
32276
32390
  /* @__PURE__ */ React.createElement("div", { className: "window__content" }, content || children),
32277
- statusBar && /* @__PURE__ */ React.createElement("div", { className: "window__status-bar" }, statusBar)
32391
+ statusBar && /* @__PURE__ */ React.createElement("div", { className: "window__status-bar" }, statusBar),
32392
+ resizable && !maximized && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
32393
+ "div",
32394
+ {
32395
+ className: "window__resize-handle window__resize-handle--n",
32396
+ onMouseDown: (e) => handleResizeStart(e, "n")
32397
+ }
32398
+ ), /* @__PURE__ */ React.createElement(
32399
+ "div",
32400
+ {
32401
+ className: "window__resize-handle window__resize-handle--s",
32402
+ onMouseDown: (e) => handleResizeStart(e, "s")
32403
+ }
32404
+ ), /* @__PURE__ */ React.createElement(
32405
+ "div",
32406
+ {
32407
+ className: "window__resize-handle window__resize-handle--e",
32408
+ onMouseDown: (e) => handleResizeStart(e, "e")
32409
+ }
32410
+ ), /* @__PURE__ */ React.createElement(
32411
+ "div",
32412
+ {
32413
+ className: "window__resize-handle window__resize-handle--w",
32414
+ onMouseDown: (e) => handleResizeStart(e, "w")
32415
+ }
32416
+ ), /* @__PURE__ */ React.createElement(
32417
+ "div",
32418
+ {
32419
+ className: "window__resize-handle window__resize-handle--ne",
32420
+ onMouseDown: (e) => handleResizeStart(e, "ne")
32421
+ }
32422
+ ), /* @__PURE__ */ React.createElement(
32423
+ "div",
32424
+ {
32425
+ className: "window__resize-handle window__resize-handle--nw",
32426
+ onMouseDown: (e) => handleResizeStart(e, "nw")
32427
+ }
32428
+ ), /* @__PURE__ */ React.createElement(
32429
+ "div",
32430
+ {
32431
+ className: "window__resize-handle window__resize-handle--se",
32432
+ onMouseDown: (e) => handleResizeStart(e, "se")
32433
+ }
32434
+ ), /* @__PURE__ */ React.createElement(
32435
+ "div",
32436
+ {
32437
+ className: "window__resize-handle window__resize-handle--sw",
32438
+ onMouseDown: (e) => handleResizeStart(e, "sw")
32439
+ }
32440
+ ))
32278
32441
  );
32279
32442
  };
32280
32443
  const ApplicationMenu = ({ isOpen, onClose }) => {
32444
+ console.log("ApplicationMenu render - isOpen:", isOpen, "onClose:", onClose);
32281
32445
  const appManager = useAppManager();
32282
32446
  const [searchTerm, setSearchTerm] = React.useState("");
32283
32447
  const [selectedCategory, setSelectedCategory] = React.useState("all");
32284
32448
  const [apps, setApps] = React.useState([]);
32285
32449
  const [categories, setCategories] = React.useState([]);
32450
+ const [viewMode, setViewMode] = React.useState("list");
32451
+ const [isCondensed, setIsCondensed] = React.useState(true);
32286
32452
  const searchInputRef = React.useRef(null);
32287
32453
  const { createWindow } = useWindows();
32288
32454
  React.useEffect(() => {
@@ -32344,7 +32510,31 @@ const rows = [
32344
32510
  setSearchTerm("");
32345
32511
  };
32346
32512
  if (!isOpen) return null;
32347
- return /* @__PURE__ */ React.createElement("div", { className: "application-menu-overlay", onClick: onClose }, /* @__PURE__ */ React.createElement("div", { className: "application-menu", onClick: (e) => e.stopPropagation() }, /* @__PURE__ */ React.createElement("div", { className: "application-menu__header" }, /* @__PURE__ */ React.createElement("h2", null, "Applications"), /* @__PURE__ */ React.createElement(
32513
+ return /* @__PURE__ */ React.createElement("div", { className: "application-menu-overlay", onClick: onClose }, /* @__PURE__ */ React.createElement("div", { className: `application-menu ${isCondensed ? "application-menu--condensed" : ""}`, onClick: (e) => e.stopPropagation() }, /* @__PURE__ */ React.createElement("div", { className: "application-menu__header" }, /* @__PURE__ */ React.createElement("div", { className: "application-menu__header-controls" }, /* @__PURE__ */ React.createElement(
32514
+ "button",
32515
+ {
32516
+ className: `application-menu__view-toggle ${isCondensed ? "active" : ""}`,
32517
+ onClick: () => setIsCondensed(!isCondensed),
32518
+ title: isCondensed ? "Normal view" : "Condensed view"
32519
+ },
32520
+ "⚏"
32521
+ ), /* @__PURE__ */ React.createElement(
32522
+ "button",
32523
+ {
32524
+ className: `application-menu__view-toggle ${viewMode === "grid" ? "active" : ""}`,
32525
+ onClick: () => setViewMode("grid"),
32526
+ title: "Grid view"
32527
+ },
32528
+ "⊞"
32529
+ ), /* @__PURE__ */ React.createElement(
32530
+ "button",
32531
+ {
32532
+ className: `application-menu__view-toggle ${viewMode === "list" ? "active" : ""}`,
32533
+ onClick: () => setViewMode("list"),
32534
+ title: "List view"
32535
+ },
32536
+ "☰"
32537
+ ), /* @__PURE__ */ React.createElement(
32348
32538
  "button",
32349
32539
  {
32350
32540
  className: "application-menu__close",
@@ -32352,7 +32542,7 @@ const rows = [
32352
32542
  title: "Close menu"
32353
32543
  },
32354
32544
  "×"
32355
- )), /* @__PURE__ */ React.createElement("div", { className: "application-menu__search" }, /* @__PURE__ */ React.createElement(
32545
+ ))), /* @__PURE__ */ React.createElement("div", { className: "application-menu__search" }, /* @__PURE__ */ React.createElement(
32356
32546
  "input",
32357
32547
  {
32358
32548
  ref: searchInputRef,
@@ -32362,151 +32552,52 @@ const rows = [
32362
32552
  onChange: (e) => setSearchTerm(e.target.value),
32363
32553
  className: "application-menu__search-input"
32364
32554
  }
32365
- )), /* @__PURE__ */ React.createElement("div", { className: "application-menu__categories" }, /* @__PURE__ */ React.createElement(
32555
+ )), /* @__PURE__ */ React.createElement("div", { className: "application-menu__main" }, /* @__PURE__ */ React.createElement("div", { className: "application-menu__sidebar" }, /* @__PURE__ */ React.createElement("div", { className: "application-menu__categories" }, /* @__PURE__ */ React.createElement(
32366
32556
  "button",
32367
32557
  {
32368
32558
  className: `application-menu__category ${selectedCategory === "all" ? "active" : ""}`,
32369
- onClick: () => handleCategorySelect("all")
32559
+ onClick: () => handleCategorySelect("all"),
32560
+ title: "All Apps"
32370
32561
  },
32371
32562
  /* @__PURE__ */ React.createElement("span", { className: "category-icon" }, "📱"),
32372
- "All Apps"
32563
+ /* @__PURE__ */ React.createElement("span", { className: "category-name" }, "All Apps")
32373
32564
  ), categories.map((category) => /* @__PURE__ */ React.createElement(
32374
32565
  "button",
32375
32566
  {
32376
32567
  key: category.id,
32377
32568
  className: `application-menu__category ${selectedCategory === category.id ? "active" : ""}`,
32378
- onClick: () => handleCategorySelect(category.id)
32569
+ onClick: () => handleCategorySelect(category.id),
32570
+ title: category.name
32379
32571
  },
32380
32572
  /* @__PURE__ */ React.createElement("span", { className: "category-icon" }, category.icon),
32381
- category.name
32382
- ))), /* @__PURE__ */ React.createElement("div", { className: "application-menu__content" }, searchTerm && /* @__PURE__ */ React.createElement("div", { className: "application-menu__search-results" }, /* @__PURE__ */ React.createElement("h3", null, "Search Results (", filteredApps.length, ")"), /* @__PURE__ */ React.createElement("div", { className: "application-menu__apps-grid" }, filteredApps.map((app) => /* @__PURE__ */ React.createElement(
32573
+ /* @__PURE__ */ React.createElement("span", { className: "category-name" }, category.name)
32574
+ )))), /* @__PURE__ */ React.createElement("div", { className: "application-menu__content" }, searchTerm && /* @__PURE__ */ React.createElement("div", { className: "application-menu__search-results" }, /* @__PURE__ */ React.createElement("h3", null, "Search Results (", filteredApps.length, ")"), /* @__PURE__ */ React.createElement("div", { className: `application-menu__apps-${viewMode}` }, filteredApps.map((app) => /* @__PURE__ */ React.createElement(
32383
32575
  "div",
32384
32576
  {
32385
32577
  key: app.id,
32386
- className: "application-menu__app",
32578
+ className: `application-menu__app--${viewMode}`,
32387
32579
  onClick: () => handleLaunchApp(app),
32388
32580
  title: app.description
32389
32581
  },
32390
32582
  /* @__PURE__ */ React.createElement("div", { className: "app-icon" }, app.icon),
32391
- /* @__PURE__ */ React.createElement("div", { className: "app-name" }, app.name)
32392
- )))), !searchTerm && /* @__PURE__ */ React.createElement("div", { className: "application-menu__categories-content" }, Object.entries(groupedApps).map(([categoryName, categoryApps]) => /* @__PURE__ */ React.createElement("div", { key: categoryName, className: "application-menu__category-section" }, /* @__PURE__ */ React.createElement("h3", { className: "category-title" }, categoryName), /* @__PURE__ */ React.createElement("div", { className: "application-menu__apps-grid" }, categoryApps.map((app) => /* @__PURE__ */ React.createElement(
32583
+ viewMode === "list" ? /* @__PURE__ */ React.createElement("div", { className: "app-info" }, /* @__PURE__ */ React.createElement("div", { className: "app-name" }, app.name), /* @__PURE__ */ React.createElement("div", { className: "app-description" }, app.description)) : /* @__PURE__ */ React.createElement("div", { className: "app-name" }, app.name)
32584
+ )))), !searchTerm && /* @__PURE__ */ React.createElement("div", { className: "application-menu__categories-content" }, Object.entries(groupedApps).map(([categoryName, categoryApps]) => /* @__PURE__ */ React.createElement("div", { key: categoryName, className: "application-menu__category-section" }, /* @__PURE__ */ React.createElement("h3", { className: "category-title" }, categoryName), /* @__PURE__ */ React.createElement("div", { className: `application-menu__apps-${viewMode}` }, categoryApps.map((app) => /* @__PURE__ */ React.createElement(
32393
32585
  "div",
32394
32586
  {
32395
32587
  key: app.id,
32396
- className: "application-menu__app",
32588
+ className: `application-menu__app--${viewMode}`,
32397
32589
  onClick: () => handleLaunchApp(app),
32398
32590
  title: app.description
32399
32591
  },
32400
32592
  /* @__PURE__ */ React.createElement("div", { className: "app-icon" }, app.icon),
32401
- /* @__PURE__ */ React.createElement("div", { className: "app-name" }, app.name)
32402
- )))))), filteredApps.length === 0 && /* @__PURE__ */ React.createElement("div", { className: "application-menu__no-results" }, /* @__PURE__ */ React.createElement("div", { style: { fontSize: "48px", marginBottom: "16px" } }, "🔍"), /* @__PURE__ */ React.createElement("h3", null, "No applications found"), /* @__PURE__ */ React.createElement("p", null, "Try adjusting your search or category filter.")))));
32593
+ viewMode === "list" ? /* @__PURE__ */ React.createElement("div", { className: "app-info" }, /* @__PURE__ */ React.createElement("div", { className: "app-name" }, app.name), /* @__PURE__ */ React.createElement("div", { className: "app-description" }, app.description)) : /* @__PURE__ */ React.createElement("div", { className: "app-name" }, app.name)
32594
+ )))))), filteredApps.length === 0 && /* @__PURE__ */ React.createElement("div", { className: "application-menu__no-results" }, /* @__PURE__ */ React.createElement("div", { style: { fontSize: "48px", marginBottom: "16px" } }, "🔍"), /* @__PURE__ */ React.createElement("h3", null, "No applications found"), /* @__PURE__ */ React.createElement("p", null, "Try adjusting your search or category filter."))))));
32403
32595
  };
32404
32596
  class AppManager {
32405
32597
  constructor() {
32406
32598
  this.applications = /* @__PURE__ */ new Map();
32407
32599
  this.categories = /* @__PURE__ */ new Map();
32408
32600
  this.listeners = /* @__PURE__ */ new Set();
32409
- this.initializeDefaultApps();
32410
- }
32411
- /**
32412
- * Initialize default applications
32413
- */
32414
- initializeDefaultApps() {
32415
- this.registerApp({
32416
- id: "file-explorer",
32417
- name: "File Explorer",
32418
- description: "Browse and manage files",
32419
- icon: "📁",
32420
- category: "System",
32421
- component: null,
32422
- // Will be set when registering actual components
32423
- size: { width: 600, height: 400 },
32424
- toolbar: null,
32425
- statusBar: null
32426
- });
32427
- this.registerApp({
32428
- id: "text-editor",
32429
- name: "Text Editor",
32430
- description: "Edit text files",
32431
- icon: "📝",
32432
- category: "Productivity",
32433
- component: null,
32434
- size: { width: 500, height: 350 },
32435
- toolbar: null,
32436
- statusBar: null
32437
- });
32438
- this.registerApp({
32439
- id: "calculator",
32440
- name: "Calculator",
32441
- description: "Perform calculations",
32442
- icon: "🧮",
32443
- category: "Utilities",
32444
- component: null,
32445
- size: { width: 300, height: 400 }
32446
- });
32447
- this.registerApp({
32448
- id: "settings",
32449
- name: "Settings",
32450
- description: "System configuration",
32451
- icon: "⚙️",
32452
- category: "System",
32453
- component: null,
32454
- size: { width: 450, height: 300 }
32455
- });
32456
- this.registerApp({
32457
- id: "browser",
32458
- name: "Web Browser",
32459
- description: "Browse the internet",
32460
- icon: "🌐",
32461
- category: "Internet",
32462
- component: null,
32463
- size: { width: 800, height: 500 }
32464
- });
32465
- this.registerApp({
32466
- id: "terminal",
32467
- name: "Terminal",
32468
- description: "Command line interface",
32469
- icon: "💻",
32470
- category: "Development",
32471
- component: null,
32472
- size: { width: 700, height: 400 }
32473
- });
32474
- this.registerApp({
32475
- id: "image-viewer",
32476
- name: "Image Viewer",
32477
- description: "View and edit images",
32478
- icon: "🖼️",
32479
- category: "Media",
32480
- component: null,
32481
- size: { width: 600, height: 500 }
32482
- });
32483
- this.registerApp({
32484
- id: "music-player",
32485
- name: "Music Player",
32486
- description: "Play audio files",
32487
- icon: "🎵",
32488
- category: "Media",
32489
- component: null,
32490
- size: { width: 400, height: 300 }
32491
- });
32492
- this.initializeCategories();
32493
- }
32494
- /**
32495
- * Initialize application categories
32496
- */
32497
- initializeCategories() {
32498
- const categoryData = [
32499
- { id: "system", name: "System", icon: "⚙️", color: "#607d8b" },
32500
- { id: "productivity", name: "Productivity", icon: "📊", color: "#2196f3" },
32501
- { id: "utilities", name: "Utilities", icon: "🔧", color: "#ff9800" },
32502
- { id: "internet", name: "Internet", icon: "🌐", color: "#4caf50" },
32503
- { id: "development", name: "Development", icon: "💻", color: "#9c27b0" },
32504
- { id: "media", name: "Media", icon: "🎬", color: "#e91e63" },
32505
- { id: "games", name: "Games", icon: "🎮", color: "#f44336" }
32506
- ];
32507
- categoryData.forEach((category) => {
32508
- this.categories.set(category.id, category);
32509
- });
32510
32601
  }
32511
32602
  /**
32512
32603
  * Register a new application
@@ -32626,6 +32717,160 @@ const rows = [
32626
32717
  return grouped;
32627
32718
  }
32628
32719
  }
32720
+ class AppLoader {
32721
+ /**
32722
+ * Load configuration into AppManager
32723
+ * @param {AppManager} appManager - The AppManager instance
32724
+ * @param {Object} config - JSON configuration object
32725
+ * @param {Array} config.categories - Array of category definitions
32726
+ * @param {Array} config.applications - Array of application definitions
32727
+ */
32728
+ static load(appManager, config) {
32729
+ if (!config) {
32730
+ console.warn("AppLoader: No configuration provided");
32731
+ return;
32732
+ }
32733
+ if (config.categories && Array.isArray(config.categories)) {
32734
+ this.loadCategories(appManager, config.categories);
32735
+ }
32736
+ if (config.applications && Array.isArray(config.applications)) {
32737
+ this.loadApplications(appManager, config.applications);
32738
+ }
32739
+ }
32740
+ /**
32741
+ * Load categories from configuration
32742
+ * @param {AppManager} appManager - The AppManager instance
32743
+ * @param {Array} categories - Array of category definitions
32744
+ */
32745
+ static loadCategories(appManager, categories) {
32746
+ categories.forEach((category) => {
32747
+ if (this.validateCategory(category)) {
32748
+ appManager.categories.set(category.id, category);
32749
+ } else {
32750
+ console.warn("AppLoader: Invalid category configuration:", category);
32751
+ }
32752
+ });
32753
+ }
32754
+ /**
32755
+ * Load applications from configuration
32756
+ * @param {AppManager} appManager - The AppManager instance
32757
+ * @param {Array} applications - Array of application definitions
32758
+ */
32759
+ static loadApplications(appManager, applications) {
32760
+ applications.forEach((app) => {
32761
+ if (this.validateApplication(app)) {
32762
+ appManager.registerApp(app);
32763
+ } else {
32764
+ console.warn("AppLoader: Invalid application configuration:", app);
32765
+ }
32766
+ });
32767
+ }
32768
+ /**
32769
+ * Validate category configuration
32770
+ * @param {Object} category - Category definition
32771
+ * @returns {boolean} - True if valid
32772
+ */
32773
+ static validateCategory(category) {
32774
+ return category && typeof category.id === "string" && typeof category.name === "string" && category.id.length > 0 && category.name.length > 0;
32775
+ }
32776
+ /**
32777
+ * Validate application configuration
32778
+ * @param {Object} app - Application definition
32779
+ * @returns {boolean} - True if valid
32780
+ */
32781
+ static validateApplication(app) {
32782
+ return app && typeof app.id === "string" && typeof app.name === "string" && app.id.length > 0 && app.name.length > 0;
32783
+ }
32784
+ }
32785
+ const defaultDesktopConfig = {
32786
+ categories: [
32787
+ { id: "system", name: "System", icon: "⚙️", color: "#607d8b" },
32788
+ { id: "productivity", name: "Productivity", icon: "📊", color: "#2196f3" },
32789
+ { id: "utilities", name: "Utilities", icon: "🔧", color: "#ff9800" },
32790
+ { id: "internet", name: "Internet", icon: "🌐", color: "#4caf50" },
32791
+ { id: "development", name: "Development", icon: "💻", color: "#9c27b0" },
32792
+ { id: "media", name: "Media", icon: "🎬", color: "#e91e63" },
32793
+ { id: "games", name: "Games", icon: "🎮", color: "#f44336" }
32794
+ ],
32795
+ applications: [
32796
+ {
32797
+ id: "file-explorer",
32798
+ name: "File Explorer",
32799
+ description: "Browse and manage files",
32800
+ icon: "📁",
32801
+ category: "System",
32802
+ component: null,
32803
+ size: { width: 600, height: 400 },
32804
+ toolbar: null,
32805
+ statusBar: null
32806
+ },
32807
+ {
32808
+ id: "text-editor",
32809
+ name: "Text Editor",
32810
+ description: "Edit text files",
32811
+ icon: "📝",
32812
+ category: "Productivity",
32813
+ component: null,
32814
+ size: { width: 500, height: 350 },
32815
+ toolbar: null,
32816
+ statusBar: null
32817
+ },
32818
+ {
32819
+ id: "calculator",
32820
+ name: "Calculator",
32821
+ description: "Perform calculations",
32822
+ icon: "🧮",
32823
+ category: "Utilities",
32824
+ component: null,
32825
+ size: { width: 300, height: 400 }
32826
+ },
32827
+ {
32828
+ id: "settings",
32829
+ name: "Settings",
32830
+ description: "System configuration",
32831
+ icon: "⚙️",
32832
+ category: "System",
32833
+ component: null,
32834
+ size: { width: 450, height: 300 }
32835
+ },
32836
+ {
32837
+ id: "browser",
32838
+ name: "Web Browser",
32839
+ description: "Browse the internet",
32840
+ icon: "🌐",
32841
+ category: "Internet",
32842
+ component: null,
32843
+ size: { width: 800, height: 500 }
32844
+ },
32845
+ {
32846
+ id: "terminal",
32847
+ name: "Terminal",
32848
+ description: "Command line interface",
32849
+ icon: "💻",
32850
+ category: "Development",
32851
+ component: null,
32852
+ size: { width: 700, height: 400 }
32853
+ },
32854
+ {
32855
+ id: "image-viewer",
32856
+ name: "Image Viewer",
32857
+ description: "View and edit images",
32858
+ icon: "🖼️",
32859
+ category: "Media",
32860
+ component: null,
32861
+ size: { width: 600, height: 500 }
32862
+ },
32863
+ {
32864
+ id: "music-player",
32865
+ name: "Music Player",
32866
+ description: "Play audio files",
32867
+ icon: "🎵",
32868
+ category: "Media",
32869
+ component: null,
32870
+ size: { width: 400, height: 300 }
32871
+ }
32872
+ ]
32873
+ };
32629
32874
  const defaultAppManager = new AppManager();
32630
32875
  const AppContext = React.createContext();
32631
32876
  const useApplicationMenu = () => {
@@ -32642,8 +32887,17 @@ const rows = [
32642
32887
  }
32643
32888
  return context.appManager;
32644
32889
  };
32645
- const AppProvider = ({ children, appManager = defaultAppManager }) => {
32890
+ const AppProvider = ({
32891
+ children,
32892
+ desktopConfig = defaultDesktopConfig
32893
+ }) => {
32894
+ const appManager = new AppManager();
32646
32895
  const [isApplicationMenuOpen, setIsApplicationMenuOpen] = React.useState(false);
32896
+ React.useEffect(() => {
32897
+ if (appManager.getAllApps().length === 0 && desktopConfig) {
32898
+ AppLoader.load(appManager, desktopConfig);
32899
+ }
32900
+ }, [appManager, desktopConfig]);
32647
32901
  const value = {
32648
32902
  // Application Menu state
32649
32903
  applicationMenu: {
@@ -32657,14 +32911,14 @@ const rows = [
32657
32911
  };
32658
32912
  return /* @__PURE__ */ React.createElement(AppContext.Provider, { value }, children);
32659
32913
  };
32660
- const DesktopLayout = ({ children, className = "", theme = "windows", ...props }) => {
32914
+ const DesktopLayout = ({ children, className = "", theme = "windows", workspaceRef, ...props }) => {
32661
32915
  const desktopRef = React.useRef(null);
32662
32916
  const { windowManager } = useWindows();
32663
32917
  React.useEffect(() => {
32664
- let currentSize = { width: 1200, height: 800 };
32665
- const measureDesktop = () => {
32666
- if (desktopRef.current) {
32667
- const rect = desktopRef.current.getBoundingClientRect();
32918
+ let currentSize = { width: 1200, height: 750 };
32919
+ const measureWorkspace = () => {
32920
+ if (workspaceRef.current) {
32921
+ const rect = workspaceRef.current.getBoundingClientRect();
32668
32922
  const newSize = {
32669
32923
  width: rect.width,
32670
32924
  height: rect.height
@@ -32675,10 +32929,10 @@ const rows = [
32675
32929
  }
32676
32930
  }
32677
32931
  };
32678
- measureDesktop();
32679
- const resizeObserver = new ResizeObserver(measureDesktop);
32680
- if (desktopRef.current) {
32681
- resizeObserver.observe(desktopRef.current);
32932
+ measureWorkspace();
32933
+ const resizeObserver = new ResizeObserver(measureWorkspace);
32934
+ if (workspaceRef.current) {
32935
+ resizeObserver.observe(workspaceRef.current);
32682
32936
  }
32683
32937
  return () => {
32684
32938
  resizeObserver.disconnect();
@@ -32703,7 +32957,7 @@ const rows = [
32703
32957
  };
32704
32958
  const Workspace = ({ children }) => {
32705
32959
  const { windows } = useWindows();
32706
- return /* @__PURE__ */ React.createElement(React.Fragment, null, children, windows.map((window2) => /* @__PURE__ */ React.createElement(
32960
+ return /* @__PURE__ */ React.createElement("div", { className: "workspace" }, children, windows.map((window2) => /* @__PURE__ */ React.createElement(
32707
32961
  Window,
32708
32962
  {
32709
32963
  key: window2.id,
@@ -32717,6 +32971,9 @@ const rows = [
32717
32971
  )));
32718
32972
  };
32719
32973
  const DesktopTaskbar = () => {
32974
+ console.log("DesktopTaskbar render");
32975
+ const windowsContext = useWindows();
32976
+ console.log("useWindows result:", windowsContext);
32720
32977
  const {
32721
32978
  createWindow,
32722
32979
  windows,
@@ -32724,26 +32981,14 @@ const rows = [
32724
32981
  activeWindowId,
32725
32982
  focusWindow,
32726
32983
  minimizeWindow,
32727
- closeWindow
32728
- } = useWindows();
32729
- const { open: openApplicationMenu } = useApplicationMenu();
32730
- const handleCreateWindow = () => {
32731
- const windowTypes = [
32732
- { title: "File Explorer", icon: "📁", size: { width: 600, height: 400 } },
32733
- { title: "Text Editor", icon: "📝", size: { width: 500, height: 350 } },
32734
- { title: "Calculator", icon: "🧮", size: { width: 300, height: 400 } },
32735
- { title: "Settings", icon: "⚙️", size: { width: 450, height: 300 } },
32736
- { title: "Browser", icon: "🌐", size: { width: 800, height: 500 } }
32737
- ];
32738
- const randomType = windowTypes[Math.floor(Math.random() * windowTypes.length)];
32739
- createWindow({
32740
- title: randomType.title,
32741
- icon: randomType.icon,
32742
- size: randomType.size,
32743
- toolbar: randomType.title === "Text Editor" ? /* @__PURE__ */ React.createElement("div", { style: { display: "flex", gap: "8px" } }, /* @__PURE__ */ React.createElement("button", { style: { padding: "4px 8px", fontSize: "12px" } }, "File"), /* @__PURE__ */ React.createElement("button", { style: { padding: "4px 8px", fontSize: "12px" } }, "Edit"), /* @__PURE__ */ React.createElement("button", { style: { padding: "4px 8px", fontSize: "12px" } }, "View")) : null,
32744
- statusBar: randomType.title === "Text Editor" ? /* @__PURE__ */ React.createElement("span", null, "Ready | Line 1, Column 1") : null
32745
- });
32746
- };
32984
+ closeWindow,
32985
+ cascadeWindows,
32986
+ tileWindows,
32987
+ centerAllWindows,
32988
+ clearAllWindows
32989
+ } = windowsContext;
32990
+ const { isOpen, toggle } = useApplicationMenu();
32991
+ console.log("DesktopTaskbar - isOpen:", isOpen, "toggle:", toggle);
32747
32992
  const handleWindowClick = (window2) => {
32748
32993
  if (window2.minimized) {
32749
32994
  minimizeWindow(window2.id, false);
@@ -32766,11 +33011,7 @@ const rows = [
32766
33011
  closeWindow(window2.id);
32767
33012
  }
32768
33013
  };
32769
- return /* @__PURE__ */ React.createElement("div", { style: {
32770
- position: "absolute",
32771
- bottom: 0,
32772
- left: 0,
32773
- right: 0,
33014
+ return /* @__PURE__ */ React.createElement("div", { className: "desktop-taskbar", style: {
32774
33015
  height: "50px",
32775
33016
  background: "rgba(0,0,0,0.8)",
32776
33017
  display: "flex",
@@ -32778,44 +33019,16 @@ const rows = [
32778
33019
  padding: "0 16px",
32779
33020
  gap: "8px"
32780
33021
  } }, /* @__PURE__ */ React.createElement(
32781
- "button",
33022
+ ToggleButton,
32782
33023
  {
32783
- onClick: openApplicationMenu,
32784
- style: {
32785
- padding: "8px 16px",
32786
- background: "#1976d2",
32787
- color: "white",
32788
- border: "none",
32789
- borderRadius: "4px",
32790
- cursor: "pointer",
32791
- fontSize: "14px",
32792
- fontWeight: "bold",
32793
- flexShrink: 0,
32794
- display: "flex",
32795
- alignItems: "center",
32796
- gap: "6px"
33024
+ checked: isOpen,
33025
+ onToggle: () => {
33026
+ console.log("Start button toggled, current state:", isOpen);
33027
+ toggle();
32797
33028
  },
32798
- title: "Open application menu"
32799
- },
32800
- /* @__PURE__ */ React.createElement("span", { style: { fontSize: "16px" } }, "🚀"),
32801
- "Start"
32802
- ), /* @__PURE__ */ React.createElement(
32803
- "button",
32804
- {
32805
- onClick: handleCreateWindow,
32806
- style: {
32807
- padding: "8px 12px",
32808
- background: "#666",
32809
- color: "white",
32810
- border: "none",
32811
- borderRadius: "4px",
32812
- cursor: "pointer",
32813
- fontSize: "12px",
32814
- flexShrink: 0
32815
- },
32816
- title: "Create random window (for testing)"
32817
- },
32818
- "+"
33029
+ icon: "start",
33030
+ label: "Start"
33031
+ }
32819
33032
  ), /* @__PURE__ */ React.createElement("div", { style: {
32820
33033
  width: "1px",
32821
33034
  height: "30px",
@@ -32876,6 +33089,60 @@ Middle click: Close`
32876
33089
  borderRadius: "1px"
32877
33090
  } })
32878
33091
  ))), /* @__PURE__ */ React.createElement("div", { style: {
33092
+ display: "flex",
33093
+ gap: "4px",
33094
+ alignItems: "center",
33095
+ marginLeft: "auto",
33096
+ marginRight: "8px"
33097
+ } }, /* @__PURE__ */ React.createElement(
33098
+ Icon,
33099
+ {
33100
+ clickable: true,
33101
+ size: "small",
33102
+ action: () => {
33103
+ console.log("Cascade windows clicked!");
33104
+ cascadeWindows();
33105
+ },
33106
+ icon: "view_stream",
33107
+ label: "Cascade"
33108
+ }
33109
+ ), /* @__PURE__ */ React.createElement(
33110
+ Icon,
33111
+ {
33112
+ clickable: true,
33113
+ size: "small",
33114
+ action: () => {
33115
+ console.log("Tile windows clicked!");
33116
+ tileWindows();
33117
+ },
33118
+ icon: "view_module",
33119
+ label: "Tile"
33120
+ }
33121
+ ), /* @__PURE__ */ React.createElement(
33122
+ Icon,
33123
+ {
33124
+ clickable: true,
33125
+ size: "small",
33126
+ action: () => {
33127
+ console.log("Center all windows clicked!");
33128
+ centerAllWindows();
33129
+ },
33130
+ icon: "center_focus_strong",
33131
+ label: "Center"
33132
+ }
33133
+ ), /* @__PURE__ */ React.createElement(
33134
+ Icon,
33135
+ {
33136
+ clickable: true,
33137
+ size: "small",
33138
+ action: () => {
33139
+ console.log("Clear all windows clicked!");
33140
+ clearAllWindows();
33141
+ },
33142
+ icon: "clear_all",
33143
+ label: "Clear"
33144
+ }
33145
+ )), /* @__PURE__ */ React.createElement("div", { style: {
32879
33146
  color: "rgba(255,255,255,0.7)",
32880
33147
  fontSize: "11px",
32881
33148
  fontFamily: "monospace",
@@ -32885,16 +33152,28 @@ Middle click: Close`
32885
33152
  };
32886
33153
  const DesktopInternal = ({ desktopSize, children, ...props }) => {
32887
33154
  const { isOpen, close } = useApplicationMenu();
32888
- return /* @__PURE__ */ React.createElement(WindowProvider, { desktopSize }, /* @__PURE__ */ React.createElement(DesktopLayout, { ...props }, /* @__PURE__ */ React.createElement(Workspace, null, children), /* @__PURE__ */ React.createElement(DesktopTaskbar, null), /* @__PURE__ */ React.createElement(
33155
+ const workspaceRef = React.useRef(null);
33156
+ return /* @__PURE__ */ React.createElement(WindowProvider, { desktopSize }, /* @__PURE__ */ React.createElement(DesktopLayout, { workspaceRef, ...props }, /* @__PURE__ */ React.createElement("div", { ref: workspaceRef, className: "desktop__workspace-container" }, /* @__PURE__ */ React.createElement(Workspace, null, children), /* @__PURE__ */ React.createElement(
32889
33157
  ApplicationMenu,
32890
33158
  {
32891
33159
  isOpen,
32892
33160
  onClose: close
32893
33161
  }
32894
- )));
33162
+ )), /* @__PURE__ */ React.createElement(DesktopTaskbar, null)));
32895
33163
  };
32896
- const Desktop = ({ desktopSize, children, ...props }) => {
32897
- return /* @__PURE__ */ React.createElement(AppProvider, null, /* @__PURE__ */ React.createElement(DesktopInternal, { desktopSize, ...props }, children));
33164
+ const Desktop = ({
33165
+ desktopSize,
33166
+ children,
33167
+ desktopConfig,
33168
+ ...props
33169
+ }) => {
33170
+ return /* @__PURE__ */ React.createElement(
33171
+ AppProvider,
33172
+ {
33173
+ desktopConfig
33174
+ },
33175
+ /* @__PURE__ */ React.createElement(DesktopInternal, { desktopSize, ...props }, children)
33176
+ );
32898
33177
  };
32899
33178
  const ContentForm = ({ content, columns = 1, filter, rules, onChange }) => {
32900
33179
  const form = content.form();