@asymmetric-effort/specifyjs 0.2.151 → 0.2.153

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.
@@ -16571,10 +16571,14 @@ function renderProjectContent(card, onOpenProject) {
16571
16571
  }, content.project_name || "Untitled Project");
16572
16572
  }
16573
16573
  function CardComponent(props) {
16574
- const { card, selected = false, onSelect, onMove, onResize, onDelete, dispatch, onOpenProject } = props;
16574
+ const { card, selected = false, onSelect, onMove, onResize, onDelete, dispatch, onOpenProject, onCardContextMenu, onUpdate, onDragStart, onDragEnd, onAnchorDragStart } = props;
16575
16575
  const [hovered, setHovered] = useState(false);
16576
16576
  const [contextMenu, setContextMenu] = useState(null);
16577
16577
  const [typeSubmenuOpen, setTypeSubmenuOpen] = useState(false);
16578
+ const [editingTitle, setEditingTitle] = useState(false);
16579
+ const [editingDescription, setEditingDescription] = useState(false);
16580
+ const [titleDraft, setTitleDraft] = useState(card.card_title || "");
16581
+ const [descDraft, setDescDraft] = useState("");
16578
16582
  const dragStartRef = useRef(null);
16579
16583
  const resizeStartRef = useRef(null);
16580
16584
  const priorityColor = card.priority ? PRIORITY_COLORS[card.priority] || "#94a3b8" : "transparent";
@@ -16584,7 +16588,10 @@ function CardComponent(props) {
16584
16588
  me.stopPropagation();
16585
16589
  setContextMenu({ x: me.clientX, y: me.clientY });
16586
16590
  setTypeSubmenuOpen(false);
16587
- }, []);
16591
+ if (onCardContextMenu) {
16592
+ onCardContextMenu(card.card_id, { x: me.clientX, y: me.clientY });
16593
+ }
16594
+ }, [onCardContextMenu, card.card_id]);
16588
16595
  const closeContextMenu = useCallback(() => {
16589
16596
  setContextMenu(null);
16590
16597
  setTypeSubmenuOpen(false);
@@ -16592,7 +16599,7 @@ function CardComponent(props) {
16592
16599
  const handleMouseDown = useCallback((e) => {
16593
16600
  const me = e;
16594
16601
  const target = me.target;
16595
- if (target.dataset && (target.dataset.role === "delete" || target.dataset.role === "resize" || target.dataset.role === "drag-handle")) return;
16602
+ if (target.dataset && (target.dataset.role === "delete" || target.dataset.role === "resize" || target.dataset.role === "drag-handle" || target.dataset.role === "inline-edit" || target.dataset.role === "anchor")) return;
16596
16603
  me.preventDefault();
16597
16604
  me.stopPropagation();
16598
16605
  if (onSelect) onSelect(card.card_id);
@@ -16602,6 +16609,7 @@ function CardComponent(props) {
16602
16609
  cardX: card.position.x,
16603
16610
  cardY: card.position.y
16604
16611
  };
16612
+ if (onDragStart) onDragStart(card.card_id);
16605
16613
  const handleMouseMove = (ev) => {
16606
16614
  const mev = ev;
16607
16615
  if (!dragStartRef.current) return;
@@ -16616,12 +16624,13 @@ function CardComponent(props) {
16616
16624
  };
16617
16625
  const handleMouseUp = () => {
16618
16626
  dragStartRef.current = null;
16627
+ if (onDragEnd) onDragEnd(card.card_id);
16619
16628
  document.removeEventListener("mousemove", handleMouseMove);
16620
16629
  document.removeEventListener("mouseup", handleMouseUp);
16621
16630
  };
16622
16631
  document.addEventListener("mousemove", handleMouseMove);
16623
16632
  document.addEventListener("mouseup", handleMouseUp);
16624
- }, [card.card_id, card.position.x, card.position.y, onSelect, onMove]);
16633
+ }, [card.card_id, card.position.x, card.position.y, onSelect, onMove, onDragStart, onDragEnd]);
16625
16634
  const handleResizeMouseDown = useCallback((e) => {
16626
16635
  const me = e;
16627
16636
  me.preventDefault();
@@ -16656,16 +16665,137 @@ function CardComponent(props) {
16656
16665
  e.stopPropagation();
16657
16666
  if (onDelete) onDelete(card.card_id);
16658
16667
  }, [card.card_id, onDelete]);
16668
+ const handleAnchorMouseDown = useCallback((e) => {
16669
+ const me = e;
16670
+ me.preventDefault();
16671
+ me.stopPropagation();
16672
+ const target = me.target;
16673
+ const anchor = target.dataset.anchor;
16674
+ if (!anchor || !onAnchorDragStart) return;
16675
+ const posX = card.position.x;
16676
+ const posY = card.position.y;
16677
+ const w = card.size.width;
16678
+ const h = card.size.height;
16679
+ let ax = posX + w / 2;
16680
+ let ay = posY + h / 2;
16681
+ if (anchor === "top") {
16682
+ ax = posX + w / 2;
16683
+ ay = posY;
16684
+ } else if (anchor === "right") {
16685
+ ax = posX + w;
16686
+ ay = posY + h / 2;
16687
+ } else if (anchor === "bottom") {
16688
+ ax = posX + w / 2;
16689
+ ay = posY + h;
16690
+ } else if (anchor === "left") {
16691
+ ax = posX;
16692
+ ay = posY + h / 2;
16693
+ }
16694
+ onAnchorDragStart(card.card_id, anchor, { x: ax, y: ay });
16695
+ }, [card.card_id, card.position.x, card.position.y, card.size.width, card.size.height, onAnchorDragStart]);
16659
16696
  const handleChangeType = useCallback((newType) => {
16660
16697
  if (dispatch) {
16661
16698
  dispatch({ type: "CHANGE_CARD_TYPE", cardId: card.card_id, newType });
16662
16699
  }
16663
16700
  closeContextMenu();
16664
16701
  }, [card.card_id, dispatch, closeContextMenu]);
16702
+ const handleTitleDblClick = useCallback((e) => {
16703
+ e.preventDefault();
16704
+ e.stopPropagation();
16705
+ setTitleDraft(card.card_title || "");
16706
+ setEditingTitle(true);
16707
+ }, [card.card_title]);
16708
+ const handleTitleSave = useCallback(() => {
16709
+ setEditingTitle(false);
16710
+ if (onUpdate && titleDraft !== card.card_title) {
16711
+ onUpdate(card.card_id, { card_title: titleDraft });
16712
+ }
16713
+ }, [onUpdate, card.card_id, card.card_title, titleDraft]);
16714
+ const handleTitleKeyDown = useCallback((e) => {
16715
+ const ke = e;
16716
+ if (ke.key === "Enter") {
16717
+ ke.preventDefault();
16718
+ handleTitleSave();
16719
+ } else if (ke.key === "Escape") {
16720
+ ke.preventDefault();
16721
+ setEditingTitle(false);
16722
+ setTitleDraft(card.card_title || "");
16723
+ }
16724
+ }, [handleTitleSave, card.card_title]);
16725
+ const handleTitleInput = useCallback((e) => {
16726
+ const target = e.target;
16727
+ setTitleDraft(target.value);
16728
+ }, []);
16729
+ const handleDescClick = useCallback((e) => {
16730
+ e.stopPropagation();
16731
+ const content = card.content;
16732
+ setDescDraft(content.text || "");
16733
+ setEditingDescription(true);
16734
+ }, [card.content]);
16735
+ const handleDescSave = useCallback(() => {
16736
+ setEditingDescription(false);
16737
+ if (onUpdate) {
16738
+ onUpdate(card.card_id, { content: { text: descDraft } });
16739
+ }
16740
+ }, [onUpdate, card.card_id, descDraft]);
16741
+ const handleDescKeyDown = useCallback((e) => {
16742
+ const ke = e;
16743
+ if (ke.key === "Escape") {
16744
+ ke.preventDefault();
16745
+ setEditingDescription(false);
16746
+ const content = card.content;
16747
+ setDescDraft(content.text || "");
16748
+ }
16749
+ }, [card.content]);
16750
+ const handleDescInput = useCallback((e) => {
16751
+ const target = e.target;
16752
+ setDescDraft(target.value);
16753
+ }, []);
16665
16754
  let contentEl;
16666
16755
  switch (card.card_type) {
16667
16756
  case "text":
16668
- contentEl = renderTextContent(card);
16757
+ if (editingDescription) {
16758
+ contentEl = createElement("textarea", {
16759
+ "data-role": "inline-edit",
16760
+ "data-testid": `card-desc-edit-${card.card_id}`,
16761
+ value: descDraft,
16762
+ onInput: handleDescInput,
16763
+ onBlur: handleDescSave,
16764
+ onKeyDown: handleDescKeyDown,
16765
+ onFocus: (e) => {
16766
+ const ta = e.target;
16767
+ ta.setSelectionRange(ta.value.length, ta.value.length);
16768
+ },
16769
+ style: {
16770
+ fontSize: "12px",
16771
+ color: "#555555",
16772
+ lineHeight: "1.4",
16773
+ flex: "1",
16774
+ border: "1px solid #3b82f6",
16775
+ borderRadius: "3px",
16776
+ padding: "2px 4px",
16777
+ resize: "none",
16778
+ outline: "none",
16779
+ fontFamily: "inherit",
16780
+ backgroundColor: "#fff",
16781
+ width: "100%",
16782
+ boxSizing: "border-box"
16783
+ }
16784
+ });
16785
+ } else {
16786
+ contentEl = createElement("div", {
16787
+ style: {
16788
+ fontSize: "12px",
16789
+ color: "#555555",
16790
+ lineHeight: "1.4",
16791
+ overflow: "hidden",
16792
+ flex: "1",
16793
+ cursor: "text"
16794
+ },
16795
+ "data-testid": `card-text-content-${card.card_id}`,
16796
+ onClick: handleDescClick
16797
+ }, card.content.text || "");
16798
+ }
16669
16799
  break;
16670
16800
  case "json":
16671
16801
  contentEl = renderJsonContent(card);
@@ -16754,6 +16884,47 @@ function CardComponent(props) {
16754
16884
  border: "none",
16755
16885
  padding: "0"
16756
16886
  };
16887
+ const anchorSize = 8;
16888
+ const anchorBaseStyle = {
16889
+ position: "absolute",
16890
+ width: `${anchorSize}px`,
16891
+ height: `${anchorSize}px`,
16892
+ borderRadius: "50%",
16893
+ backgroundColor: "#3b82f6",
16894
+ border: "2px solid #fff",
16895
+ boxSizing: "border-box",
16896
+ cursor: "crosshair",
16897
+ display: hovered ? "block" : "none",
16898
+ zIndex: "10"
16899
+ };
16900
+ const anchorPositions = [
16901
+ {
16902
+ anchor: "top",
16903
+ style: { ...anchorBaseStyle, top: `${-anchorSize / 2}px`, left: "50%", marginLeft: `${-anchorSize / 2}px` }
16904
+ },
16905
+ {
16906
+ anchor: "right",
16907
+ style: { ...anchorBaseStyle, top: "50%", right: `${-anchorSize / 2}px`, marginTop: `${-anchorSize / 2}px` }
16908
+ },
16909
+ {
16910
+ anchor: "bottom",
16911
+ style: { ...anchorBaseStyle, bottom: `${-anchorSize / 2}px`, left: "50%", marginLeft: `${-anchorSize / 2}px` }
16912
+ },
16913
+ {
16914
+ anchor: "left",
16915
+ style: { ...anchorBaseStyle, top: "50%", left: `${-anchorSize / 2}px`, marginTop: `${-anchorSize / 2}px` }
16916
+ }
16917
+ ];
16918
+ const anchorElements = anchorPositions.map(
16919
+ (ap, i) => createElement("div", {
16920
+ key: `anchor-${ap.anchor}`,
16921
+ style: ap.style,
16922
+ "data-role": "anchor",
16923
+ "data-anchor": ap.anchor,
16924
+ "data-testid": `card-anchor-${ap.anchor}-${card.card_id}`,
16925
+ onMouseDown: handleAnchorMouseDown
16926
+ })
16927
+ );
16757
16928
  const assigneeEl = card.assignee ? createElement(
16758
16929
  "div",
16759
16930
  {
@@ -16929,6 +17100,7 @@ function CardComponent(props) {
16929
17100
  "aria-label": "Export drag handle",
16930
17101
  title: "Drag to export card"
16931
17102
  }, "\u2630"),
17103
+ ...anchorElements,
16932
17104
  contextMenuEl
16933
17105
  );
16934
17106
  }
@@ -16950,9 +17122,31 @@ function CardComponent(props) {
16950
17122
  "aria-label": `Card: ${card.card_title}`,
16951
17123
  tabIndex: 0
16952
17124
  },
16953
- createElement("div", {
17125
+ editingTitle ? createElement("input", {
17126
+ "data-role": "inline-edit",
17127
+ "data-testid": `card-title-edit-${card.card_id}`,
17128
+ value: titleDraft,
17129
+ onInput: handleTitleInput,
17130
+ onBlur: handleTitleSave,
17131
+ onKeyDown: handleTitleKeyDown,
17132
+ onFocus: (e) => {
17133
+ const inp = e.target;
17134
+ inp.setSelectionRange(inp.value.length, inp.value.length);
17135
+ },
17136
+ style: {
17137
+ ...titleStyle,
17138
+ border: "1px solid #3b82f6",
17139
+ borderRadius: "3px",
17140
+ padding: "1px 4px",
17141
+ outline: "none",
17142
+ width: "100%",
17143
+ boxSizing: "border-box",
17144
+ backgroundColor: "#fff"
17145
+ }
17146
+ }) : createElement("div", {
16954
17147
  style: titleStyle,
16955
- "data-testid": `card-title-${card.card_id}`
17148
+ "data-testid": `card-title-${card.card_id}`,
17149
+ onDblClick: handleTitleDblClick
16956
17150
  }, card.card_title || "Untitled"),
16957
17151
  contentEl,
16958
17152
  tagsEl,
@@ -16978,16 +17172,26 @@ function CardComponent(props) {
16978
17172
  onMouseDown: handleResizeMouseDown,
16979
17173
  "aria-label": "Resize card"
16980
17174
  }),
17175
+ ...anchorElements,
16981
17176
  contextMenuEl
16982
17177
  );
16983
17178
  }
16984
17179
 
16985
17180
  // ../components/data/board/src/Container.ts
16986
17181
  function ContainerComponent(props) {
16987
- const { container, selected = false, onSelect, onMove, onResize, onDrop, children } = props;
17182
+ const { container, selected = false, highlighted = false, onSelect, onMove, onResize, onDelete, onDrop, children } = props;
16988
17183
  const [dragOver, setDragOver] = useState(false);
17184
+ const [minimized, setMinimized] = useState(false);
16989
17185
  const dragStartRef = useRef(null);
16990
17186
  const resizeStartRef = useRef(null);
17187
+ const handleDeleteClick = useCallback((e) => {
17188
+ e.stopPropagation();
17189
+ if (onDelete) onDelete(container.container_id);
17190
+ }, [container.container_id, onDelete]);
17191
+ const handleMinimizeClick = useCallback((e) => {
17192
+ e.stopPropagation();
17193
+ setMinimized((prev) => !prev);
17194
+ }, []);
16991
17195
  const handleTitleMouseDown = useCallback((e) => {
16992
17196
  const me = e;
16993
17197
  me.preventDefault();
@@ -17067,21 +17271,23 @@ function ContainerComponent(props) {
17067
17271
  }
17068
17272
  }
17069
17273
  }, [container.container_id, onDrop]);
17274
+ const isHighlightedOrDragOver = highlighted || dragOver;
17070
17275
  const containerStyle3 = {
17071
17276
  position: "absolute",
17072
17277
  left: `${container.position.x}px`,
17073
17278
  top: `${container.position.y}px`,
17074
17279
  width: `${container.size.width}px`,
17075
17280
  height: `${container.size.height}px`,
17076
- backgroundColor: "#ffffff",
17077
- border: selected ? "2px solid #3b82f6" : "2px solid #d1d5db",
17281
+ backgroundColor: highlighted ? "#eff6ff" : "#ffffff",
17282
+ border: highlighted ? "2px dashed #3b82f6" : selected ? "2px solid #3b82f6" : "2px solid #d1d5db",
17078
17283
  borderRadius: "8px",
17079
- boxShadow: dragOver ? "0 0 0 3px rgba(59,130,246,0.3), 0 4px 16px rgba(0,0,0,0.1)" : "0 2px 8px rgba(0,0,0,0.08)",
17284
+ boxShadow: isHighlightedOrDragOver ? "0 0 0 3px rgba(59,130,246,0.3), 0 4px 16px rgba(0,0,0,0.1)" : "0 2px 8px rgba(0,0,0,0.08)",
17080
17285
  display: "flex",
17081
17286
  flexDirection: "column",
17082
17287
  overflow: "hidden",
17083
17288
  zIndex: "0",
17084
- boxSizing: "border-box"
17289
+ boxSizing: "border-box",
17290
+ transition: "border 150ms ease, background-color 150ms ease, box-shadow 150ms ease"
17085
17291
  };
17086
17292
  const titleBarStyle = {
17087
17293
  padding: "6px 12px",
@@ -17124,18 +17330,54 @@ function ContainerComponent(props) {
17124
17330
  onDragLeave: handleDragLeave,
17125
17331
  onDrop: handleDrop
17126
17332
  },
17127
- createElement("div", {
17128
- className: "board-container__title",
17129
- style: titleBarStyle,
17130
- onMouseDown: handleTitleMouseDown,
17131
- "data-testid": `container-title-${container.container_id}`
17132
- }, container.name),
17133
- createElement("div", {
17333
+ createElement(
17334
+ "div",
17335
+ {
17336
+ className: "board-container__title",
17337
+ style: { ...titleBarStyle, display: "flex", alignItems: "center", justifyContent: "space-between" },
17338
+ onMouseDown: handleTitleMouseDown,
17339
+ "data-testid": `container-title-${container.container_id}`
17340
+ },
17341
+ createElement("span", null, container.name),
17342
+ createElement(
17343
+ "span",
17344
+ { style: { display: "flex", gap: "4px" } },
17345
+ createElement("button", {
17346
+ style: {
17347
+ border: "none",
17348
+ backgroundColor: "transparent",
17349
+ cursor: "pointer",
17350
+ color: "#94a3b8",
17351
+ fontSize: "12px",
17352
+ padding: "0 2px",
17353
+ lineHeight: "1"
17354
+ },
17355
+ onClick: handleMinimizeClick,
17356
+ "aria-label": minimized ? "Expand container" : "Minimize container",
17357
+ title: minimized ? "Expand" : "Minimize"
17358
+ }, minimized ? "\u25B2" : "\u2014"),
17359
+ createElement("button", {
17360
+ style: {
17361
+ border: "none",
17362
+ backgroundColor: "transparent",
17363
+ cursor: "pointer",
17364
+ color: "#94a3b8",
17365
+ fontSize: "14px",
17366
+ padding: "0 2px",
17367
+ lineHeight: "1"
17368
+ },
17369
+ onClick: handleDeleteClick,
17370
+ "aria-label": "Delete container",
17371
+ title: "Delete"
17372
+ }, "\xD7")
17373
+ )
17374
+ ),
17375
+ minimized ? null : createElement("div", {
17134
17376
  className: "board-container__contents",
17135
17377
  style: contentsStyle,
17136
17378
  "data-testid": `container-contents-${container.container_id}`
17137
17379
  }, children),
17138
- createElement("div", {
17380
+ minimized ? null : createElement("div", {
17139
17381
  style: resizeHandleStyle,
17140
17382
  "data-role": "resize",
17141
17383
  onMouseDown: handleResizeMouseDown,
@@ -17145,15 +17387,41 @@ function ContainerComponent(props) {
17145
17387
  }
17146
17388
 
17147
17389
  // ../components/data/board/src/CardLink.ts
17148
- function getCardCenter(card) {
17390
+ function getCardAnchors(card) {
17391
+ const cx = card.position.x + card.size.width / 2;
17392
+ const cy = card.position.y + card.size.height / 2;
17149
17393
  return {
17150
- x: card.position.x + card.size.width / 2,
17151
- y: card.position.y + card.size.height / 2
17394
+ top: { x: cx, y: card.position.y },
17395
+ right: { x: card.position.x + card.size.width, y: cy },
17396
+ bottom: { x: cx, y: card.position.y + card.size.height },
17397
+ left: { x: card.position.x, y: cy }
17152
17398
  };
17153
17399
  }
17400
+ function getNearestAnchors(source, target) {
17401
+ const sa = getCardAnchors(source);
17402
+ const ta = getCardAnchors(target);
17403
+ const sourceAnchors = [sa.top, sa.right, sa.bottom, sa.left];
17404
+ const targetAnchors = [ta.top, ta.right, ta.bottom, ta.left];
17405
+ let bestDist = Infinity;
17406
+ let bestFrom = sa.right;
17407
+ let bestTo = ta.left;
17408
+ for (let i = 0; i < sourceAnchors.length; i++) {
17409
+ for (let j = 0; j < targetAnchors.length; j++) {
17410
+ const dx = targetAnchors[j].x - sourceAnchors[i].x;
17411
+ const dy = targetAnchors[j].y - sourceAnchors[i].y;
17412
+ const d = dx * dx + dy * dy;
17413
+ if (d < bestDist) {
17414
+ bestDist = d;
17415
+ bestFrom = sourceAnchors[i];
17416
+ bestTo = targetAnchors[j];
17417
+ }
17418
+ }
17419
+ }
17420
+ return { from: bestFrom, to: bestTo };
17421
+ }
17154
17422
  var ARROW_MARKER_ID = "board-card-link-arrowhead";
17155
17423
  function CardLinkOverlay(props) {
17156
- const { links, cards, selectedLinkId, onSelectLink, canvasWidth, canvasHeight } = props;
17424
+ const { links, cards, selectedLinkId, onSelectLink, onLinkContextMenu, canvasWidth, canvasHeight } = props;
17157
17425
  const cardMap = /* @__PURE__ */ new Map();
17158
17426
  for (let i = 0; i < cards.length; i++) {
17159
17427
  cardMap.set(cards[i].card_id, cards[i]);
@@ -17166,8 +17434,7 @@ function CardLinkOverlay(props) {
17166
17434
  const { source, link } = links[i];
17167
17435
  const targetCard = cardMap.get(link.target_card_id);
17168
17436
  if (!targetCard) continue;
17169
- const from = getCardCenter(source);
17170
- const to = getCardCenter(targetCard);
17437
+ const { from, to } = getNearestAnchors(source, targetCard);
17171
17438
  const isSelected = link.link_id === selectedLinkId;
17172
17439
  const strokeColor = isSelected ? "#3b82f6" : link.color || "#94a3b8";
17173
17440
  const dx = to.x - from.x;
@@ -17181,6 +17448,7 @@ function CardLinkOverlay(props) {
17181
17448
  const cpX = midX + nx * curveOffset;
17182
17449
  const cpY = midY + ny * curveOffset;
17183
17450
  const pathD = `M ${from.x} ${from.y} Q ${cpX} ${cpY} ${to.x} ${to.y}`;
17451
+ const srcId = source.card_id;
17184
17452
  lineElements.push(
17185
17453
  createElement("path", {
17186
17454
  key: `hit-${link.link_id}`,
@@ -17188,8 +17456,14 @@ function CardLinkOverlay(props) {
17188
17456
  fill: "none",
17189
17457
  stroke: "transparent",
17190
17458
  "stroke-width": "12",
17191
- style: { cursor: "pointer" },
17459
+ style: { cursor: "pointer", pointerEvents: "stroke" },
17192
17460
  onClick: () => handleLineClick(link.link_id),
17461
+ onContextMenu: (e) => {
17462
+ const me = e;
17463
+ me.preventDefault();
17464
+ me.stopPropagation();
17465
+ if (onLinkContextMenu) onLinkContextMenu(link.link_id, srcId, { x: me.clientX, y: me.clientY });
17466
+ },
17193
17467
  "data-testid": `link-hit-${link.link_id}`
17194
17468
  })
17195
17469
  );
@@ -17227,7 +17501,8 @@ function CardLinkOverlay(props) {
17227
17501
  width: "100%",
17228
17502
  height: "100%",
17229
17503
  pointerEvents: "none",
17230
- overflow: "visible"
17504
+ overflow: "visible",
17505
+ zIndex: "9999"
17231
17506
  };
17232
17507
  const markerDef = createElement(
17233
17508
  "defs",
@@ -17266,28 +17541,67 @@ function CardLinkOverlay(props) {
17266
17541
  }
17267
17542
 
17268
17543
  // ../components/data/board/src/Board.ts
17544
+ var CONTEXT_COLORS = [
17545
+ { value: "#fef9c3", label: "Yellow" },
17546
+ { value: "#fecaca", label: "Red" },
17547
+ { value: "#fed7aa", label: "Orange" },
17548
+ { value: "#bbf7d0", label: "Green" },
17549
+ { value: "#bfdbfe", label: "Blue" },
17550
+ { value: "#ddd6fe", label: "Purple" },
17551
+ { value: "#fbcfe8", label: "Pink" },
17552
+ { value: "#e5e7eb", label: "Gray" }
17553
+ ];
17269
17554
  var GRID_SIZE = 20;
17270
17555
  var CANVAS_SIZE = 5e3;
17556
+ function findContainerAtPoint(collection, x, y, excludeId) {
17557
+ for (let i = 0; i < collection.length; i++) {
17558
+ const item = collection[i];
17559
+ if (!isContainer(item)) continue;
17560
+ if (item.container_id === excludeId) continue;
17561
+ if (x >= item.position.x && x <= item.position.x + item.size.width && y >= item.position.y && y <= item.position.y + item.size.height) {
17562
+ return item.container_id;
17563
+ }
17564
+ }
17565
+ return null;
17566
+ }
17271
17567
  function snapToGrid(pos, gridSize) {
17272
17568
  return {
17273
17569
  x: Math.round(pos.x / gridSize) * gridSize,
17274
17570
  y: Math.round(pos.y / gridSize) * gridSize
17275
17571
  };
17276
17572
  }
17573
+ function screenToCanvas(screenX, screenY, viewport) {
17574
+ return {
17575
+ x: (screenX - viewport.panX) / viewport.zoom,
17576
+ y: (screenY - viewport.panY) / viewport.zoom
17577
+ };
17578
+ }
17277
17579
  function collectCardsAndLinks(items) {
17278
17580
  const cards = [];
17279
17581
  const links = [];
17280
- const stack = [...items];
17582
+ const stack = [];
17583
+ for (let i = items.length - 1; i >= 0; i--) {
17584
+ stack.push([items[i], 0, 0]);
17585
+ }
17281
17586
  while (stack.length > 0) {
17282
- const item = stack.pop();
17587
+ const [item, offsetX, offsetY] = stack.pop();
17283
17588
  if (isCard(item)) {
17284
- cards.push(item);
17589
+ const absCard = {
17590
+ ...item,
17591
+ position: {
17592
+ x: item.position.x + offsetX,
17593
+ y: item.position.y + offsetY
17594
+ }
17595
+ };
17596
+ cards.push(absCard);
17285
17597
  for (let j = 0; j < item.card_link.length; j++) {
17286
- links.push({ source: item, link: item.card_link[j] });
17598
+ links.push({ source: absCard, link: item.card_link[j] });
17287
17599
  }
17288
17600
  } else if (isContainer(item)) {
17601
+ const childOffsetX = offsetX + item.position.x;
17602
+ const childOffsetY = offsetY + item.position.y + 30;
17289
17603
  for (let j = item.contents.length - 1; j >= 0; j--) {
17290
- stack.push(item.contents[j]);
17604
+ stack.push([item.contents[j], childOffsetX, childOffsetY]);
17291
17605
  }
17292
17606
  }
17293
17607
  }
@@ -17302,12 +17616,21 @@ function Board(props) {
17302
17616
  gridEnabled = false,
17303
17617
  searchQuery = "",
17304
17618
  colorFilter = null,
17305
- onOpenProject
17619
+ onOpenProject,
17620
+ onCardContextMenu,
17621
+ onUpdateItem
17306
17622
  } = props;
17307
17623
  const { collection, viewport } = state;
17308
17624
  const containerRef = useRef(null);
17309
17625
  const isPanningRef = useRef(false);
17310
17626
  const panStartRef = useRef(null);
17627
+ const [dropTargetId, setDropTargetId] = useState(null);
17628
+ const [draggingCardId, setDraggingCardId] = useState(null);
17629
+ const [linkDrag, setLinkDrag] = useState(null);
17630
+ const [cardContextMenu, setCardContextMenu] = useState(null);
17631
+ const [colorSubmenuOpen, setColorSubmenuOpen] = useState(false);
17632
+ const [typeSubmenuOpen, setTypeSubmenuOpen] = useState(false);
17633
+ const [linkContextMenu, setLinkContextMenu] = useState(null);
17311
17634
  const handleCanvasMouseDown = useCallback((e) => {
17312
17635
  const me = e;
17313
17636
  const target = me.target;
@@ -17411,6 +17734,42 @@ function Board(props) {
17411
17734
  container.removeEventListener("touchend", handleTouchEnd);
17412
17735
  };
17413
17736
  }, [viewport.panX, viewport.panY, viewport.zoom, dispatch]);
17737
+ const handleCardContextMenu = useCallback((cardId, pos) => {
17738
+ setCardContextMenu({ cardId, x: pos.x, y: pos.y });
17739
+ setColorSubmenuOpen(false);
17740
+ setTypeSubmenuOpen(false);
17741
+ if (onCardContextMenu) {
17742
+ onCardContextMenu(cardId, pos);
17743
+ }
17744
+ }, [onCardContextMenu]);
17745
+ const closeCardContextMenu = useCallback(() => {
17746
+ setCardContextMenu(null);
17747
+ setColorSubmenuOpen(false);
17748
+ setTypeSubmenuOpen(false);
17749
+ }, []);
17750
+ useEffect(() => {
17751
+ if (!cardContextMenu) return;
17752
+ const handleDocumentClick = () => {
17753
+ closeCardContextMenu();
17754
+ };
17755
+ document.addEventListener("click", handleDocumentClick);
17756
+ return () => {
17757
+ document.removeEventListener("click", handleDocumentClick);
17758
+ };
17759
+ }, [cardContextMenu, closeCardContextMenu]);
17760
+ const handleLinkContextMenu = useCallback((linkId, cardId, pos) => {
17761
+ setLinkContextMenu({ linkId, cardId, x: pos.x, y: pos.y });
17762
+ closeCardContextMenu();
17763
+ }, [closeCardContextMenu]);
17764
+ const closeLinkContextMenu = useCallback(() => {
17765
+ setLinkContextMenu(null);
17766
+ }, []);
17767
+ useEffect(() => {
17768
+ if (!linkContextMenu) return;
17769
+ const handleDocumentClick = () => closeLinkContextMenu();
17770
+ document.addEventListener("click", handleDocumentClick);
17771
+ return () => document.removeEventListener("click", handleDocumentClick);
17772
+ }, [linkContextMenu, closeLinkContextMenu]);
17414
17773
  const handleSelectItem = useCallback((itemId) => {
17415
17774
  if (onSelectItem) onSelectItem(itemId);
17416
17775
  }, [onSelectItem]);
@@ -17420,7 +17779,27 @@ function Board(props) {
17420
17779
  pos = snapToGrid(position, GRID_SIZE);
17421
17780
  }
17422
17781
  dispatch({ type: "MOVE_ITEM", itemId, position: pos });
17423
- }, [dispatch, gridEnabled]);
17782
+ if (draggingCardId === itemId) {
17783
+ let cardWidth = 0;
17784
+ let cardHeight = 0;
17785
+ const searchStack = [...collection];
17786
+ while (searchStack.length > 0) {
17787
+ const si = searchStack.pop();
17788
+ if (isCard(si) && si.card_id === itemId) {
17789
+ cardWidth = si.size.width;
17790
+ cardHeight = si.size.height;
17791
+ break;
17792
+ }
17793
+ if (isContainer(si)) {
17794
+ for (let k = 0; k < si.contents.length; k++) searchStack.push(si.contents[k]);
17795
+ }
17796
+ }
17797
+ const centerX = pos.x + cardWidth / 2;
17798
+ const centerY = pos.y + cardHeight / 2;
17799
+ const containerId = findContainerAtPoint(collection, centerX, centerY, itemId);
17800
+ setDropTargetId(containerId);
17801
+ }
17802
+ }, [dispatch, gridEnabled, draggingCardId, collection]);
17424
17803
  const handleResizeItem = useCallback((itemId, size) => {
17425
17804
  dispatch({ type: "RESIZE_ITEM", itemId, size });
17426
17805
  }, [dispatch]);
@@ -17431,6 +17810,78 @@ function Board(props) {
17431
17810
  const handleDropIntoContainer = useCallback((itemId, containerId) => {
17432
17811
  dispatch({ type: "NEST_ITEM", itemId, containerId });
17433
17812
  }, [dispatch]);
17813
+ const handleCardDragStart = useCallback((cardId) => {
17814
+ setDraggingCardId(cardId);
17815
+ setDropTargetId(null);
17816
+ }, []);
17817
+ const dropTargetIdRef = useRef(null);
17818
+ dropTargetIdRef.current = dropTargetId;
17819
+ const handleCardDragEnd = useCallback((cardId) => {
17820
+ const target = dropTargetIdRef.current;
17821
+ if (target) {
17822
+ dispatch({ type: "NEST_ITEM", itemId: cardId, containerId: target });
17823
+ }
17824
+ setDraggingCardId(null);
17825
+ setDropTargetId(null);
17826
+ }, [dispatch]);
17827
+ const handleAnchorDragStart = useCallback((cardId, anchor, pos) => {
17828
+ setLinkDrag({
17829
+ fromCardId: cardId,
17830
+ fromAnchor: anchor,
17831
+ fromPos: pos,
17832
+ currentPos: pos
17833
+ });
17834
+ }, []);
17835
+ const linkDragRef = useRef(null);
17836
+ linkDragRef.current = linkDrag;
17837
+ useEffect(() => {
17838
+ if (!linkDrag) return;
17839
+ const handleMouseMove = (e) => {
17840
+ const me = e;
17841
+ let offsetX = 0;
17842
+ let offsetY = 0;
17843
+ if (containerRef.current) {
17844
+ const rect = containerRef.current.getBoundingClientRect();
17845
+ offsetX = rect.left;
17846
+ offsetY = rect.top;
17847
+ }
17848
+ const canvasPos = screenToCanvas(me.clientX - offsetX, me.clientY - offsetY, viewport);
17849
+ setLinkDrag((prev) => prev ? { ...prev, currentPos: canvasPos } : null);
17850
+ };
17851
+ const handleMouseUp = (e) => {
17852
+ const me = e;
17853
+ const current = linkDragRef.current;
17854
+ if (!current) {
17855
+ setLinkDrag(null);
17856
+ return;
17857
+ }
17858
+ const el = document.elementFromPoint(me.clientX, me.clientY);
17859
+ if (el && el.dataset && el.dataset.role === "anchor" && el.dataset.anchor) {
17860
+ const cardEl = el.closest("[data-card-id]");
17861
+ if (cardEl && cardEl.dataset.cardId && cardEl.dataset.cardId !== current.fromCardId) {
17862
+ const targetCardId = cardEl.dataset.cardId;
17863
+ dispatch({
17864
+ type: "ADD_LINK",
17865
+ cardId: current.fromCardId,
17866
+ link: {
17867
+ link_id: generateUUID(),
17868
+ link_name: "relates to",
17869
+ target_card_id: targetCardId,
17870
+ color: "#94a3b8",
17871
+ attributes: {}
17872
+ }
17873
+ });
17874
+ }
17875
+ }
17876
+ setLinkDrag(null);
17877
+ };
17878
+ document.addEventListener("mousemove", handleMouseMove);
17879
+ document.addEventListener("mouseup", handleMouseUp);
17880
+ return () => {
17881
+ document.removeEventListener("mousemove", handleMouseMove);
17882
+ document.removeEventListener("mouseup", handleMouseUp);
17883
+ };
17884
+ }, [linkDrag !== null, viewport.panX, viewport.panY, viewport.zoom, dispatch]);
17434
17885
  const lowerSearch = searchQuery.toLowerCase();
17435
17886
  const dimmedIds = /* @__PURE__ */ new Set();
17436
17887
  const allItems = [];
@@ -17476,7 +17927,12 @@ function Board(props) {
17476
17927
  onResize: handleResizeItem,
17477
17928
  onDelete: handleDeleteItem,
17478
17929
  dispatch,
17479
- onOpenProject
17930
+ onOpenProject,
17931
+ onCardContextMenu: handleCardContextMenu,
17932
+ onUpdate: onUpdateItem,
17933
+ onDragStart: handleCardDragStart,
17934
+ onDragEnd: handleCardDragEnd,
17935
+ onAnchorDragStart: handleAnchorDragStart
17480
17936
  });
17481
17937
  } else {
17482
17938
  const childElements = item.contents.map((child) => renderItem(child));
@@ -17484,9 +17940,11 @@ function Board(props) {
17484
17940
  key: id,
17485
17941
  container: item,
17486
17942
  selected: id === selectedId,
17943
+ highlighted: dropTargetId === item.container_id,
17487
17944
  onSelect: handleSelectItem,
17488
17945
  onMove: handleMoveItem,
17489
17946
  onResize: handleResizeItem,
17947
+ onDelete: handleDeleteItem,
17490
17948
  onDrop: handleDropIntoContainer
17491
17949
  }, ...childElements);
17492
17950
  }
@@ -17515,6 +17973,267 @@ function Board(props) {
17515
17973
  width: `${CANVAS_SIZE}px`,
17516
17974
  height: `${CANVAS_SIZE}px`
17517
17975
  };
17976
+ const ctxMenuItemStyle = {
17977
+ padding: "6px 12px",
17978
+ cursor: "pointer",
17979
+ display: "flex",
17980
+ alignItems: "center",
17981
+ justifyContent: "space-between",
17982
+ whiteSpace: "nowrap",
17983
+ fontSize: "13px",
17984
+ color: "#1a1a1a"
17985
+ };
17986
+ const ctxSubmenuStyle = {
17987
+ position: "absolute",
17988
+ left: "100%",
17989
+ top: "0",
17990
+ backgroundColor: "#ffffff",
17991
+ border: "1px solid #d1d5db",
17992
+ borderRadius: "6px",
17993
+ boxShadow: "0 4px 16px rgba(0,0,0,0.15)",
17994
+ padding: "4px 0",
17995
+ minWidth: "120px"
17996
+ };
17997
+ const ctxSeparatorStyle = {
17998
+ height: "1px",
17999
+ backgroundColor: "#e5e7eb",
18000
+ margin: "4px 0"
18001
+ };
18002
+ const boardContextMenuEl = cardContextMenu ? createElement(
18003
+ "div",
18004
+ {
18005
+ className: "board-context-menu",
18006
+ style: {
18007
+ position: "fixed",
18008
+ left: `${cardContextMenu.x}px`,
18009
+ top: `${cardContextMenu.y}px`,
18010
+ backgroundColor: "#ffffff",
18011
+ border: "1px solid #d1d5db",
18012
+ borderRadius: "6px",
18013
+ boxShadow: "0 4px 16px rgba(0,0,0,0.15)",
18014
+ padding: "4px 0",
18015
+ zIndex: "10000",
18016
+ minWidth: "160px",
18017
+ fontSize: "13px",
18018
+ color: "#1a1a1a"
18019
+ },
18020
+ "data-testid": `board-context-menu-${cardContextMenu.cardId}`,
18021
+ role: "menu",
18022
+ "aria-label": "Card context menu",
18023
+ onClick: (e) => e.stopPropagation()
18024
+ },
18025
+ // Change Color submenu
18026
+ createElement(
18027
+ "div",
18028
+ {
18029
+ style: { ...ctxMenuItemStyle, position: "relative" },
18030
+ onMouseEnter: () => {
18031
+ setColorSubmenuOpen(true);
18032
+ setTypeSubmenuOpen(false);
18033
+ },
18034
+ role: "menuitem",
18035
+ "aria-haspopup": "true",
18036
+ "data-testid": `board-ctx-change-color-${cardContextMenu.cardId}`
18037
+ },
18038
+ "Change Color",
18039
+ createElement("span", { style: { marginLeft: "8px" } }, "\u25B6"),
18040
+ colorSubmenuOpen ? createElement(
18041
+ "div",
18042
+ {
18043
+ style: ctxSubmenuStyle,
18044
+ role: "menu",
18045
+ "data-testid": `board-ctx-color-submenu-${cardContextMenu.cardId}`
18046
+ },
18047
+ ...CONTEXT_COLORS.map(
18048
+ (opt) => createElement(
18049
+ "div",
18050
+ {
18051
+ key: opt.value,
18052
+ style: {
18053
+ ...ctxMenuItemStyle,
18054
+ gap: "8px"
18055
+ },
18056
+ onClick: (e) => {
18057
+ e.stopPropagation();
18058
+ dispatch({ type: "UPDATE_CARD", cardId: cardContextMenu.cardId, updates: { color: opt.value } });
18059
+ closeCardContextMenu();
18060
+ },
18061
+ role: "menuitem",
18062
+ "data-testid": `board-ctx-color-${opt.label.toLowerCase()}-${cardContextMenu.cardId}`
18063
+ },
18064
+ createElement("span", {
18065
+ style: {
18066
+ display: "inline-block",
18067
+ width: "14px",
18068
+ height: "14px",
18069
+ borderRadius: "3px",
18070
+ backgroundColor: opt.value,
18071
+ border: "1px solid #d1d5db",
18072
+ flexShrink: "0"
18073
+ }
18074
+ }),
18075
+ opt.label
18076
+ )
18077
+ )
18078
+ ) : null
18079
+ ),
18080
+ // Change Type submenu
18081
+ createElement(
18082
+ "div",
18083
+ {
18084
+ style: { ...ctxMenuItemStyle, position: "relative" },
18085
+ onMouseEnter: () => {
18086
+ setTypeSubmenuOpen(true);
18087
+ setColorSubmenuOpen(false);
18088
+ },
18089
+ role: "menuitem",
18090
+ "aria-haspopup": "true",
18091
+ "data-testid": `board-ctx-change-type-${cardContextMenu.cardId}`
18092
+ },
18093
+ "Change Type",
18094
+ createElement("span", { style: { marginLeft: "8px" } }, "\u25B6"),
18095
+ typeSubmenuOpen ? createElement(
18096
+ "div",
18097
+ {
18098
+ style: ctxSubmenuStyle,
18099
+ role: "menu",
18100
+ "data-testid": `board-ctx-type-submenu-${cardContextMenu.cardId}`
18101
+ },
18102
+ ...CARD_TYPE_OPTIONS.map(
18103
+ (opt) => createElement("div", {
18104
+ key: opt.value,
18105
+ style: ctxMenuItemStyle,
18106
+ onClick: (e) => {
18107
+ e.stopPropagation();
18108
+ dispatch({ type: "CHANGE_CARD_TYPE", cardId: cardContextMenu.cardId, newType: opt.value });
18109
+ closeCardContextMenu();
18110
+ },
18111
+ role: "menuitem",
18112
+ "data-testid": `board-ctx-type-${opt.value}-${cardContextMenu.cardId}`
18113
+ }, opt.label)
18114
+ )
18115
+ ) : null
18116
+ ),
18117
+ // Separator
18118
+ createElement("div", { style: ctxSeparatorStyle, role: "separator" }),
18119
+ // Delete
18120
+ createElement("div", {
18121
+ style: { ...ctxMenuItemStyle, color: "#dc2626" },
18122
+ onClick: (e) => {
18123
+ e.stopPropagation();
18124
+ dispatch({ type: "REMOVE_ITEM", itemId: cardContextMenu.cardId });
18125
+ if (onSelectItem && selectedId === cardContextMenu.cardId) onSelectItem(null);
18126
+ closeCardContextMenu();
18127
+ },
18128
+ role: "menuitem",
18129
+ "data-testid": `board-ctx-delete-${cardContextMenu.cardId}`
18130
+ }, "Delete")
18131
+ ) : null;
18132
+ const EDGE_TYPES = [
18133
+ "relates to",
18134
+ "depends on",
18135
+ "blocks",
18136
+ "is blocked by",
18137
+ "implements",
18138
+ "is implemented by",
18139
+ "extends",
18140
+ "includes",
18141
+ "references",
18142
+ "duplicates",
18143
+ "parent of",
18144
+ "child of"
18145
+ ];
18146
+ const linkContextMenuEl = linkContextMenu ? createElement(
18147
+ "div",
18148
+ {
18149
+ className: "board-link-context-menu",
18150
+ style: {
18151
+ position: "fixed",
18152
+ left: `${linkContextMenu.x}px`,
18153
+ top: `${linkContextMenu.y}px`,
18154
+ backgroundColor: "#ffffff",
18155
+ border: "1px solid #d1d5db",
18156
+ borderRadius: "6px",
18157
+ boxShadow: "0 4px 16px rgba(0,0,0,0.15)",
18158
+ padding: "4px 0",
18159
+ minWidth: "180px",
18160
+ maxHeight: "240px",
18161
+ overflowY: "auto",
18162
+ zIndex: "10001",
18163
+ fontSize: "13px"
18164
+ },
18165
+ onClick: (e) => e.stopPropagation()
18166
+ },
18167
+ createElement("div", {
18168
+ style: { padding: "4px 14px", fontSize: "11px", color: "#94a3b8", fontWeight: "600" }
18169
+ }, "Edge Type"),
18170
+ ...EDGE_TYPES.map(
18171
+ (edgeType) => createElement("button", {
18172
+ key: edgeType,
18173
+ style: {
18174
+ display: "block",
18175
+ width: "100%",
18176
+ padding: "6px 14px",
18177
+ border: "none",
18178
+ backgroundColor: "transparent",
18179
+ textAlign: "left",
18180
+ cursor: "pointer",
18181
+ fontSize: "13px",
18182
+ color: "#334155",
18183
+ fontFamily: "inherit",
18184
+ boxSizing: "border-box"
18185
+ },
18186
+ onClick: () => {
18187
+ dispatch({
18188
+ type: "UPDATE_CARD",
18189
+ cardId: linkContextMenu.cardId,
18190
+ updates: {
18191
+ card_link: (() => {
18192
+ let targetCard = null;
18193
+ const stack = [...collection];
18194
+ while (stack.length > 0) {
18195
+ const item = stack.pop();
18196
+ if (isCard(item) && item.card_id === linkContextMenu.cardId) {
18197
+ targetCard = item;
18198
+ break;
18199
+ }
18200
+ if (isContainer(item)) {
18201
+ for (const child of item.contents) stack.push(child);
18202
+ }
18203
+ }
18204
+ if (!targetCard) return [];
18205
+ return targetCard.card_link.map(
18206
+ (l) => l.link_id === linkContextMenu.linkId ? { ...l, link_name: edgeType } : l
18207
+ );
18208
+ })()
18209
+ }
18210
+ });
18211
+ closeLinkContextMenu();
18212
+ },
18213
+ role: "menuitem"
18214
+ }, edgeType)
18215
+ ),
18216
+ createElement("div", { style: { height: "1px", backgroundColor: "#e5e7eb", margin: "4px 0" } }),
18217
+ createElement("button", {
18218
+ style: {
18219
+ display: "block",
18220
+ width: "100%",
18221
+ padding: "6px 14px",
18222
+ border: "none",
18223
+ backgroundColor: "transparent",
18224
+ textAlign: "left",
18225
+ cursor: "pointer",
18226
+ fontSize: "13px",
18227
+ color: "#ef4444",
18228
+ fontFamily: "inherit"
18229
+ },
18230
+ onClick: () => {
18231
+ dispatch({ type: "REMOVE_LINK", cardId: linkContextMenu.cardId, linkId: linkContextMenu.linkId });
18232
+ closeLinkContextMenu();
18233
+ },
18234
+ role: "menuitem"
18235
+ }, "Delete Link")
18236
+ ) : null;
17518
18237
  return createElement(
17519
18238
  "div",
17520
18239
  {
@@ -17541,11 +18260,43 @@ function Board(props) {
17541
18260
  selectedLinkId: null,
17542
18261
  onSelectLink: () => {
17543
18262
  },
18263
+ onLinkContextMenu: handleLinkContextMenu,
17544
18264
  canvasWidth: CANVAS_SIZE,
17545
18265
  canvasHeight: CANVAS_SIZE
17546
18266
  }),
18267
+ linkDrag ? createElement(
18268
+ "svg",
18269
+ {
18270
+ style: {
18271
+ position: "absolute",
18272
+ top: "0",
18273
+ left: "0",
18274
+ width: "100%",
18275
+ height: "100%",
18276
+ pointerEvents: "none",
18277
+ overflow: "visible"
18278
+ },
18279
+ width: String(CANVAS_SIZE),
18280
+ height: String(CANVAS_SIZE),
18281
+ className: "link-drag-overlay",
18282
+ "data-testid": "link-drag-overlay"
18283
+ },
18284
+ createElement("line", {
18285
+ x1: String(linkDrag.fromPos.x),
18286
+ y1: String(linkDrag.fromPos.y),
18287
+ x2: String(linkDrag.currentPos.x),
18288
+ y2: String(linkDrag.currentPos.y),
18289
+ stroke: "#3b82f6",
18290
+ "stroke-width": "2",
18291
+ "stroke-dasharray": "6 4",
18292
+ "pointer-events": "none",
18293
+ "data-testid": "link-drag-line"
18294
+ })
18295
+ ) : null,
17547
18296
  ...itemElements
17548
- )
18297
+ ),
18298
+ boardContextMenuEl,
18299
+ linkContextMenuEl
17549
18300
  );
17550
18301
  }
17551
18302
 
@@ -17596,8 +18347,6 @@ function computeFitAll(collection, containerWidth, containerHeight, padding) {
17596
18347
 
17597
18348
  // ../demos/project-manager/src/Toolbar.ts
17598
18349
  var CARD_COLORS = [
17599
- "transparent",
17600
- // no background
17601
18350
  "#fef9c3",
17602
18351
  // yellow
17603
18352
  "#fecaca",
@@ -17700,18 +18449,14 @@ function BoardToolbar(props) {
17700
18449
  } else if (isActive) {
17701
18450
  borderStyle = "2px solid #3b82f6";
17702
18451
  }
17703
- const isTransparent = color === "transparent";
17704
18452
  return createElement("button", {
17705
18453
  key: color,
17706
- title: isTransparent ? "Transparent" : color,
18454
+ title: color,
17707
18455
  style: {
17708
18456
  width: "18px",
17709
18457
  height: "18px",
17710
18458
  borderRadius: "50%",
17711
- backgroundColor: isTransparent ? "#ffffff" : color,
17712
- backgroundImage: isTransparent ? "linear-gradient(45deg, #ccc 25%, transparent 25%, transparent 75%, #ccc 75%), linear-gradient(45deg, #ccc 25%, transparent 25%, transparent 75%, #ccc 75%)" : "none",
17713
- backgroundSize: isTransparent ? "6px 6px" : "auto",
17714
- backgroundPosition: isTransparent ? "0 0, 3px 3px" : "0 0",
18459
+ backgroundColor: color,
17715
18460
  border: borderStyle,
17716
18461
  cursor: "pointer",
17717
18462
  padding: "0",
@@ -17854,6 +18599,19 @@ function addItemToContainer(collection, containerId, newItem) {
17854
18599
  }
17855
18600
  return result;
17856
18601
  }
18602
+ function findContainerById(collection, containerId) {
18603
+ const stack = [...collection];
18604
+ while (stack.length > 0) {
18605
+ const item = stack.pop();
18606
+ if (isContainer(item)) {
18607
+ if (item.container_id === containerId) return item;
18608
+ for (let i = 0; i < item.contents.length; i++) {
18609
+ stack.push(item.contents[i]);
18610
+ }
18611
+ }
18612
+ }
18613
+ return null;
18614
+ }
17857
18615
  function removeItemFromContainer(collection, containerId, itemId) {
17858
18616
  let removed = null;
17859
18617
  function process(items) {
@@ -17921,11 +18679,13 @@ function boardReducer(state, action) {
17921
18679
  case "MOVE_ITEM": {
17922
18680
  return {
17923
18681
  ...state,
17924
- collection: updateItemInTree(state.collection, action.itemId, (item) => ({
17925
- ...item,
17926
- position: action.position,
17927
- ...isCard(item) ? { updatedAt: Date.now() } : {}
17928
- }))
18682
+ collection: updateItemInTree(state.collection, action.itemId, (item) => {
18683
+ return {
18684
+ ...item,
18685
+ position: action.position,
18686
+ ...isCard(item) ? { updatedAt: Date.now() } : {}
18687
+ };
18688
+ })
17929
18689
  };
17930
18690
  }
17931
18691
  case "RESIZE_ITEM": {
@@ -17978,26 +18738,43 @@ function boardReducer(state, action) {
17978
18738
  };
17979
18739
  }
17980
18740
  case "NEST_ITEM": {
18741
+ const targetContainer = findContainerById(state.collection, action.containerId);
18742
+ if (!targetContainer) return state;
17981
18743
  const [withoutItem, movedItem] = removeItemFromTree(
17982
18744
  state.collection,
17983
18745
  action.itemId
17984
18746
  );
17985
18747
  if (!movedItem) return state;
18748
+ const relativeItem = {
18749
+ ...movedItem,
18750
+ position: {
18751
+ x: movedItem.position.x - targetContainer.position.x,
18752
+ y: movedItem.position.y - targetContainer.position.y - 30
18753
+ }
18754
+ };
17986
18755
  return {
17987
18756
  ...state,
17988
- collection: addItemToContainer(withoutItem, action.containerId, movedItem)
18757
+ collection: addItemToContainer(withoutItem, action.containerId, relativeItem)
17989
18758
  };
17990
18759
  }
17991
18760
  case "UNNEST_ITEM": {
18761
+ const sourceContainer = findContainerById(state.collection, action.containerId);
17992
18762
  const [withoutItem, movedItem] = removeItemFromContainer(
17993
18763
  state.collection,
17994
18764
  action.containerId,
17995
18765
  action.itemId
17996
18766
  );
17997
18767
  if (!movedItem) return state;
18768
+ const absoluteItem = sourceContainer ? {
18769
+ ...movedItem,
18770
+ position: {
18771
+ x: movedItem.position.x + sourceContainer.position.x,
18772
+ y: movedItem.position.y + sourceContainer.position.y + 30
18773
+ }
18774
+ } : movedItem;
17998
18775
  return {
17999
18776
  ...state,
18000
- collection: [...withoutItem, movedItem]
18777
+ collection: [...withoutItem, absoluteItem]
18001
18778
  };
18002
18779
  }
18003
18780
  case "ADD_LINK": {
@@ -18356,6 +19133,20 @@ function ProjectManagerApp(props) {
18356
19133
  const [projectName, setProjectName] = useState(state.name || "Untitled");
18357
19134
  const [showRenameDialog, setShowRenameDialog] = useState(false);
18358
19135
  const [renameDraft, setRenameDraft] = useState("");
19136
+ const [openMenu, setOpenMenu] = useState(null);
19137
+ const [showConnections, setShowConnections] = useState(true);
19138
+ const [graphAttributes, setGraphAttributes] = useState([
19139
+ { name: "relates to", weight: 1 },
19140
+ { name: "depends on", weight: 2 },
19141
+ { name: "blocks", weight: 3 },
19142
+ { name: "is blocked by", weight: 3 },
19143
+ { name: "implements", weight: 2 },
19144
+ { name: "references", weight: 1 }
19145
+ ]);
19146
+ const [graphDialog, setGraphDialog] = useState(null);
19147
+ const [attrNameDraft, setAttrNameDraft] = useState("");
19148
+ const [attrWeightDraft, setAttrWeightDraft] = useState("1");
19149
+ const [editAttrs, setEditAttrs] = useState([]);
18359
19150
  const sampleLoadedRef = useRef(false);
18360
19151
  useEffect(() => {
18361
19152
  if (!sampleLoadedRef.current && isBoardEmpty(state)) {
@@ -18407,6 +19198,9 @@ function ProjectManagerApp(props) {
18407
19198
  const handleColorFilter = useCallback((color) => {
18408
19199
  setColorFilter(color);
18409
19200
  }, []);
19201
+ const handleToggleConnections = useCallback(() => {
19202
+ setShowConnections((prev) => !prev);
19203
+ }, []);
18410
19204
  const handleNewBoard = useCallback(() => {
18411
19205
  dispatch({ type: "SET_BOARD", state: DEFAULT_BOARD_STATE });
18412
19206
  setSelectedCardId(null);
@@ -18513,6 +19307,15 @@ function ProjectManagerApp(props) {
18513
19307
  document.addEventListener("keydown", handleKeyDown);
18514
19308
  return () => document.removeEventListener("keydown", handleKeyDown);
18515
19309
  }, [undo, redo]);
19310
+ useEffect(() => {
19311
+ if (!openMenu) return;
19312
+ const handleClick = () => setOpenMenu(null);
19313
+ const timer = setTimeout(() => document.addEventListener("click", handleClick), 0);
19314
+ return () => {
19315
+ clearTimeout(timer);
19316
+ document.removeEventListener("click", handleClick);
19317
+ };
19318
+ }, [openMenu]);
18516
19319
  const handleRenameProject = useCallback(() => {
18517
19320
  setRenameDraft(projectName);
18518
19321
  setShowRenameDialog(true);
@@ -18522,9 +19325,10 @@ function ProjectManagerApp(props) {
18522
19325
  if (name) {
18523
19326
  setProjectName(name);
18524
19327
  dispatch({ type: "RENAME_BOARD", name });
19328
+ if (props.onTitleChange) props.onTitleChange(`Project Board: ${name}`);
18525
19329
  }
18526
19330
  setShowRenameDialog(false);
18527
- }, [renameDraft, dispatch]);
19331
+ }, [renameDraft, dispatch, props.onTitleChange]);
18528
19332
  const handleRenameCancel = useCallback(() => {
18529
19333
  setShowRenameDialog(false);
18530
19334
  }, []);
@@ -18591,25 +19395,153 @@ function ProjectManagerApp(props) {
18591
19395
  borderRadius: "4px",
18592
19396
  fontFamily: "inherit"
18593
19397
  };
19398
+ const handleNewContainer = useCallback(() => {
19399
+ const cx = (-state.viewport.panX + 300) / state.viewport.zoom;
19400
+ const cy = (-state.viewport.panY + 200) / state.viewport.zoom;
19401
+ const offsetX = (Math.random() - 0.5) * 300;
19402
+ const offsetY = (Math.random() - 0.5) * 200;
19403
+ dispatch({
19404
+ type: "ADD_CONTAINER",
19405
+ container: {
19406
+ type: "container",
19407
+ container_id: generateUUID(),
19408
+ name: "New Container",
19409
+ position: { x: Math.round(cx + offsetX), y: Math.round(cy + offsetY) },
19410
+ size: { width: 300, height: 250 },
19411
+ contents: []
19412
+ }
19413
+ });
19414
+ setOpenMenu(null);
19415
+ }, [state.viewport, dispatch]);
19416
+ const menuDropdownStyle = {
19417
+ position: "absolute",
19418
+ top: "100%",
19419
+ left: "0",
19420
+ marginTop: "2px",
19421
+ backgroundColor: "#ffffff",
19422
+ border: "1px solid #d1d5db",
19423
+ borderRadius: "6px",
19424
+ boxShadow: "0 4px 12px rgba(0,0,0,0.15)",
19425
+ padding: "4px 0",
19426
+ minWidth: "180px",
19427
+ zIndex: "1000"
19428
+ };
19429
+ const menuDropdownItemStyle = {
19430
+ display: "block",
19431
+ width: "100%",
19432
+ padding: "6px 14px",
19433
+ border: "none",
19434
+ backgroundColor: "transparent",
19435
+ textAlign: "left",
19436
+ cursor: "pointer",
19437
+ fontSize: "13px",
19438
+ color: "#334155",
19439
+ fontFamily: "inherit",
19440
+ boxSizing: "border-box"
19441
+ };
18594
19442
  const appMenuBar = createElement(
18595
19443
  "div",
18596
19444
  {
18597
19445
  style: menuBarStyle,
18598
19446
  "data-testid": "app-menu-bar"
18599
19447
  },
18600
- createElement("button", {
18601
- style: menuBtnStyle,
18602
- onClick: handleRenameProject,
18603
- title: "Project menu"
18604
- }, "Project"),
18605
- createElement("button", {
18606
- style: menuBtnStyle,
18607
- title: "Settings"
18608
- }, "Settings"),
18609
- createElement("button", {
18610
- style: menuBtnStyle,
18611
- title: "Help"
18612
- }, "Help"),
19448
+ // Project menu
19449
+ createElement(
19450
+ "div",
19451
+ { style: { position: "relative", display: "inline-flex" } },
19452
+ createElement("button", {
19453
+ style: menuBtnStyle,
19454
+ onClick: () => setOpenMenu(openMenu === "project" ? null : "project")
19455
+ }, "Project"),
19456
+ openMenu === "project" ? createElement(
19457
+ "div",
19458
+ { style: menuDropdownStyle },
19459
+ createElement("button", { style: menuDropdownItemStyle, onClick: () => {
19460
+ handleRenameProject();
19461
+ setOpenMenu(null);
19462
+ } }, "Rename Project..."),
19463
+ createElement("div", { style: { height: "1px", backgroundColor: "#e5e7eb", margin: "4px 0" } }),
19464
+ createElement("button", { style: menuDropdownItemStyle, onClick: () => {
19465
+ handleNewContainer();
19466
+ } }, "New Container"),
19467
+ createElement("button", { style: menuDropdownItemStyle, onClick: () => {
19468
+ handleNewCard();
19469
+ setOpenMenu(null);
19470
+ } }, "New Card")
19471
+ ) : null
19472
+ ),
19473
+ // Graphs menu
19474
+ createElement(
19475
+ "div",
19476
+ { style: { position: "relative", display: "inline-flex" } },
19477
+ createElement("button", {
19478
+ style: menuBtnStyle,
19479
+ onClick: () => setOpenMenu(openMenu === "graphs" ? null : "graphs")
19480
+ }, "Graphs"),
19481
+ openMenu === "graphs" ? createElement(
19482
+ "div",
19483
+ { style: menuDropdownStyle },
19484
+ createElement("button", { style: menuDropdownItemStyle, onClick: () => {
19485
+ setAttrNameDraft("");
19486
+ setAttrWeightDraft("1");
19487
+ setGraphDialog("add");
19488
+ setOpenMenu(null);
19489
+ } }, "Add Attribute..."),
19490
+ createElement("button", { style: menuDropdownItemStyle, onClick: () => {
19491
+ setGraphDialog("delete");
19492
+ setOpenMenu(null);
19493
+ } }, "Delete Attribute..."),
19494
+ createElement("button", { style: menuDropdownItemStyle, onClick: () => {
19495
+ setEditAttrs(graphAttributes.map((a) => ({ ...a })));
19496
+ setGraphDialog("edit");
19497
+ setOpenMenu(null);
19498
+ } }, "Edit Attributes...")
19499
+ ) : null
19500
+ ),
19501
+ // Settings menu
19502
+ createElement(
19503
+ "div",
19504
+ { style: { position: "relative", display: "inline-flex" } },
19505
+ createElement("button", {
19506
+ style: menuBtnStyle,
19507
+ onClick: () => setOpenMenu(openMenu === "settings" ? null : "settings")
19508
+ }, "Settings"),
19509
+ openMenu === "settings" ? createElement(
19510
+ "div",
19511
+ { style: menuDropdownStyle },
19512
+ createElement(
19513
+ "button",
19514
+ { style: menuDropdownItemStyle, onClick: () => {
19515
+ handleGridToggle();
19516
+ setOpenMenu(null);
19517
+ } },
19518
+ gridEnabled ? "Disable Grid Snap" : "Enable Grid Snap"
19519
+ ),
19520
+ createElement(
19521
+ "button",
19522
+ { style: menuDropdownItemStyle, onClick: () => {
19523
+ handleToggleConnections();
19524
+ setOpenMenu(null);
19525
+ } },
19526
+ showConnections ? "Hide Links" : "Show Links"
19527
+ )
19528
+ ) : null
19529
+ ),
19530
+ // Help menu
19531
+ createElement(
19532
+ "div",
19533
+ { style: { position: "relative", display: "inline-flex" } },
19534
+ createElement("button", {
19535
+ style: menuBtnStyle,
19536
+ onClick: () => setOpenMenu(openMenu === "help" ? null : "help")
19537
+ }, "Help"),
19538
+ openMenu === "help" ? createElement(
19539
+ "div",
19540
+ { style: menuDropdownStyle },
19541
+ createElement("button", { style: menuDropdownItemStyle, onClick: () => setOpenMenu(null) }, "About Project Board"),
19542
+ createElement("button", { style: menuDropdownItemStyle, onClick: () => setOpenMenu(null) }, "Keyboard Shortcuts")
19543
+ ) : null
19544
+ ),
18613
19545
  createElement("span", {
18614
19546
  style: { marginLeft: "auto", fontSize: "12px", color: "#94a3b8" }
18615
19547
  }, `Project Board: ${projectName}`)
@@ -18698,6 +19630,228 @@ function ProjectManagerApp(props) {
18698
19630
  )
18699
19631
  )
18700
19632
  ) : null;
19633
+ const dialogOverlayStyle = {
19634
+ position: "absolute",
19635
+ inset: "0",
19636
+ backgroundColor: "rgba(0,0,0,0.3)",
19637
+ display: "flex",
19638
+ alignItems: "center",
19639
+ justifyContent: "center",
19640
+ zIndex: "200"
19641
+ };
19642
+ const dialogBoxStyle = {
19643
+ backgroundColor: "#ffffff",
19644
+ borderRadius: "8px",
19645
+ padding: "20px",
19646
+ boxShadow: "0 8px 24px rgba(0,0,0,0.2)",
19647
+ minWidth: "320px",
19648
+ maxHeight: "400px",
19649
+ overflow: "auto"
19650
+ };
19651
+ const dialogTitleStyle = {
19652
+ fontWeight: "600",
19653
+ fontSize: "14px",
19654
+ marginBottom: "12px",
19655
+ color: "#1a1a1a"
19656
+ };
19657
+ const dialogInputStyle = {
19658
+ width: "100%",
19659
+ padding: "8px 10px",
19660
+ border: "1px solid #d1d5db",
19661
+ borderRadius: "6px",
19662
+ fontSize: "14px",
19663
+ boxSizing: "border-box",
19664
+ outline: "none",
19665
+ fontFamily: "inherit"
19666
+ };
19667
+ const dialogBtnPrimary = {
19668
+ padding: "6px 14px",
19669
+ border: "none",
19670
+ borderRadius: "6px",
19671
+ backgroundColor: "#3b82f6",
19672
+ color: "#ffffff",
19673
+ cursor: "pointer",
19674
+ fontSize: "13px",
19675
+ fontWeight: "600",
19676
+ fontFamily: "inherit"
19677
+ };
19678
+ const dialogBtnSecondary = {
19679
+ padding: "6px 14px",
19680
+ border: "1px solid #d1d5db",
19681
+ borderRadius: "6px",
19682
+ backgroundColor: "#ffffff",
19683
+ cursor: "pointer",
19684
+ fontSize: "13px",
19685
+ fontFamily: "inherit"
19686
+ };
19687
+ let graphDialogEl = null;
19688
+ if (graphDialog === "add") {
19689
+ graphDialogEl = createElement(
19690
+ "div",
19691
+ {
19692
+ style: dialogOverlayStyle,
19693
+ onClick: () => setGraphDialog(null)
19694
+ },
19695
+ createElement(
19696
+ "div",
19697
+ {
19698
+ style: dialogBoxStyle,
19699
+ onClick: (e) => e.stopPropagation(),
19700
+ role: "dialog",
19701
+ "aria-label": "Add edge attribute"
19702
+ },
19703
+ createElement("div", { style: dialogTitleStyle }, "Add Edge Attribute"),
19704
+ createElement(
19705
+ "div",
19706
+ { style: { marginBottom: "8px" } },
19707
+ createElement("label", { style: { fontSize: "12px", color: "#64748b", display: "block", marginBottom: "4px" } }, "Name"),
19708
+ createElement("input", {
19709
+ type: "text",
19710
+ value: attrNameDraft,
19711
+ style: dialogInputStyle,
19712
+ placeholder: "e.g. depends on",
19713
+ onInput: (e) => setAttrNameDraft(e.target.value)
19714
+ })
19715
+ ),
19716
+ createElement(
19717
+ "div",
19718
+ { style: { marginBottom: "12px" } },
19719
+ createElement("label", { style: { fontSize: "12px", color: "#64748b", display: "block", marginBottom: "4px" } }, "Weight"),
19720
+ createElement("input", {
19721
+ type: "number",
19722
+ value: attrWeightDraft,
19723
+ style: dialogInputStyle,
19724
+ min: "0",
19725
+ step: "1",
19726
+ onInput: (e) => setAttrWeightDraft(e.target.value)
19727
+ })
19728
+ ),
19729
+ createElement(
19730
+ "div",
19731
+ { style: { display: "flex", justifyContent: "flex-end", gap: "8px" } },
19732
+ createElement("button", { style: dialogBtnSecondary, onClick: () => setGraphDialog(null) }, "Cancel"),
19733
+ createElement("button", { style: dialogBtnPrimary, onClick: () => {
19734
+ const name = attrNameDraft.trim();
19735
+ const weight = parseFloat(attrWeightDraft) || 1;
19736
+ if (name) {
19737
+ setGraphAttributes((prev) => [...prev, { name, weight }]);
19738
+ }
19739
+ setGraphDialog(null);
19740
+ } }, "Add")
19741
+ )
19742
+ )
19743
+ );
19744
+ }
19745
+ if (graphDialog === "delete") {
19746
+ graphDialogEl = createElement(
19747
+ "div",
19748
+ {
19749
+ style: dialogOverlayStyle,
19750
+ onClick: () => setGraphDialog(null)
19751
+ },
19752
+ createElement(
19753
+ "div",
19754
+ {
19755
+ style: dialogBoxStyle,
19756
+ onClick: (e) => e.stopPropagation(),
19757
+ role: "dialog",
19758
+ "aria-label": "Delete edge attribute"
19759
+ },
19760
+ createElement("div", { style: dialogTitleStyle }, "Delete Edge Attribute"),
19761
+ graphAttributes.length === 0 ? createElement("div", { style: { color: "#94a3b8", padding: "8px 0" } }, "No attributes defined.") : createElement(
19762
+ "div",
19763
+ { style: { display: "flex", flexDirection: "column", gap: "4px" } },
19764
+ ...graphAttributes.map(
19765
+ (attr, idx) => createElement(
19766
+ "div",
19767
+ {
19768
+ key: String(idx),
19769
+ style: {
19770
+ display: "flex",
19771
+ alignItems: "center",
19772
+ justifyContent: "space-between",
19773
+ padding: "6px 8px",
19774
+ borderRadius: "4px",
19775
+ border: "1px solid #e5e7eb"
19776
+ }
19777
+ },
19778
+ createElement("span", { style: { fontSize: "13px" } }, `${attr.name} (weight: ${attr.weight})`),
19779
+ createElement("button", {
19780
+ style: { border: "none", backgroundColor: "transparent", color: "#ef4444", cursor: "pointer", fontSize: "16px" },
19781
+ onClick: () => setGraphAttributes((prev) => prev.filter((_, i) => i !== idx))
19782
+ }, "\xD7")
19783
+ )
19784
+ )
19785
+ ),
19786
+ createElement(
19787
+ "div",
19788
+ { style: { display: "flex", justifyContent: "flex-end", marginTop: "12px" } },
19789
+ createElement("button", { style: dialogBtnSecondary, onClick: () => setGraphDialog(null) }, "Done")
19790
+ )
19791
+ )
19792
+ );
19793
+ }
19794
+ if (graphDialog === "edit") {
19795
+ graphDialogEl = createElement(
19796
+ "div",
19797
+ {
19798
+ style: dialogOverlayStyle,
19799
+ onClick: () => setGraphDialog(null)
19800
+ },
19801
+ createElement(
19802
+ "div",
19803
+ {
19804
+ style: { ...dialogBoxStyle, minWidth: "400px" },
19805
+ onClick: (e) => e.stopPropagation(),
19806
+ role: "dialog",
19807
+ "aria-label": "Edit edge attributes"
19808
+ },
19809
+ createElement("div", { style: dialogTitleStyle }, "Edit Edge Attributes"),
19810
+ editAttrs.length === 0 ? createElement("div", { style: { color: "#94a3b8", padding: "8px 0" } }, "No attributes defined.") : createElement(
19811
+ "div",
19812
+ { style: { display: "flex", flexDirection: "column", gap: "6px" } },
19813
+ ...editAttrs.map(
19814
+ (attr, idx) => createElement(
19815
+ "div",
19816
+ {
19817
+ key: String(idx),
19818
+ style: { display: "flex", alignItems: "center", gap: "8px" }
19819
+ },
19820
+ createElement("input", {
19821
+ type: "text",
19822
+ value: attr.name,
19823
+ style: { ...dialogInputStyle, flex: "1" },
19824
+ onInput: (e) => {
19825
+ const val = e.target.value;
19826
+ setEditAttrs((prev) => prev.map((a, i) => i === idx ? { ...a, name: val } : a));
19827
+ }
19828
+ }),
19829
+ createElement("input", {
19830
+ type: "number",
19831
+ value: String(attr.weight),
19832
+ min: "0",
19833
+ step: "1",
19834
+ style: { ...dialogInputStyle, width: "80px" },
19835
+ onInput: (e) => {
19836
+ const val = parseFloat(e.target.value) || 0;
19837
+ setEditAttrs((prev) => prev.map((a, i) => i === idx ? { ...a, weight: val } : a));
19838
+ }
19839
+ })
19840
+ )
19841
+ )
19842
+ ),
19843
+ createElement(
19844
+ "div",
19845
+ { style: { display: "flex", justifyContent: "flex-end", gap: "8px", marginTop: "12px" } },
19846
+ createElement("button", { style: dialogBtnSecondary, onClick: () => setGraphDialog(null) }, "Cancel"),
19847
+ createElement("button", { style: dialogBtnPrimary, onClick: () => {
19848
+ setGraphAttributes(editAttrs.filter((a) => a.name.trim()));
19849
+ setGraphDialog(null);
19850
+ } }, "Save")
19851
+ )
19852
+ )
19853
+ );
19854
+ }
18701
19855
  return createElement(
18702
19856
  "div",
18703
19857
  {
@@ -18733,10 +19887,16 @@ function ProjectManagerApp(props) {
18733
19887
  gridEnabled,
18734
19888
  selectedId: selectedCardId,
18735
19889
  onSelectItem: handleSelectCard,
18736
- colorFilter
19890
+ colorFilter,
19891
+ onUpdateItem: (cardId, updates) => {
19892
+ dispatch({ type: "UPDATE_CARD", cardId, updates });
19893
+ },
19894
+ onCardContextMenu: (cardId, pos) => {
19895
+ }
18737
19896
  })
18738
19897
  ),
18739
- renameDialogEl
19898
+ renameDialogEl,
19899
+ graphDialogEl
18740
19900
  );
18741
19901
  }
18742
19902
 
@@ -18897,7 +20057,7 @@ function FilesContent() {
18897
20057
  ) : null
18898
20058
  );
18899
20059
  }
18900
- function getMockContent(title) {
20060
+ function getMockContent(title, windowId, onTitleChange) {
18901
20061
  const contentStyle = {
18902
20062
  padding: "16px",
18903
20063
  fontSize: "13px",
@@ -18951,7 +20111,10 @@ function getMockContent(title) {
18951
20111
  case "Trading":
18952
20112
  return createElement(TradingDashboard, null);
18953
20113
  case "Project Board":
18954
- return createElement(ProjectManagerApp, null);
20114
+ return createElement(ProjectManagerApp, {
20115
+ boardId: windowId || "default",
20116
+ onTitleChange: onTitleChange || void 0
20117
+ });
18955
20118
  default:
18956
20119
  return createElement(
18957
20120
  "div",
@@ -18994,6 +20157,15 @@ function UnityDesktopInner(props) {
18994
20157
  appsRef.current = apps;
18995
20158
  const onAppOpenRef = useRef(onAppOpen);
18996
20159
  onAppOpenRef.current = onAppOpen;
20160
+ const titleChangeCallbacks = useRef({});
20161
+ for (const w of openWindows) {
20162
+ if (!titleChangeCallbacks.current[w.id]) {
20163
+ const winId = w.id;
20164
+ titleChangeCallbacks.current[winId] = (newTitle) => {
20165
+ setOpenWindows((prev) => prev.map((ww) => ww.id === winId ? { ...ww, title: newTitle } : ww));
20166
+ };
20167
+ }
20168
+ }
18997
20169
  const openNewInstance = useCallback((appId) => {
18998
20170
  const currentApps = appsRef.current;
18999
20171
  const app = currentApps.find((a) => a.id === appId);
@@ -19253,7 +20425,11 @@ function UnityDesktopInner(props) {
19253
20425
  setOpenWindows((prev) => prev.map((ww) => ww.id === w.id ? { ...ww, windowState: ww.windowState === "maximized" ? "normal" : "maximized" } : ww));
19254
20426
  }
19255
20427
  },
19256
- getMockContent(w.title)
20428
+ getMockContent(
20429
+ apps.find((a) => a.id === w.appId)?.label || w.title,
20430
+ w.id,
20431
+ titleChangeCallbacks.current[w.id]
20432
+ )
19257
20433
  ));
19258
20434
  const desktopContentChildren = [];
19259
20435
  if (children) {
@@ -19366,7 +20542,7 @@ function UnityDesktopInner(props) {
19366
20542
  if (ctxInstances.length > 0) {
19367
20543
  menuChildren.push(createElement("div", { key: "sep-1", style: separatorStyle }));
19368
20544
  ctxInstances.forEach((inst, idx) => {
19369
- const displayLabel = ctxInstances.length === 1 ? ctxApp?.label || inst.title : `${ctxApp?.label || baseLabel(inst.title)} (${idx + 1})`;
20545
+ const displayLabel = inst.title;
19370
20546
  menuChildren.push(createElement("div", {
19371
20547
  key: `inst-${inst.id}`,
19372
20548
  style: menuItemStyle,
@@ -19483,7 +20659,7 @@ function UnityDesktopInner(props) {
19483
20659
  }, dockEl),
19484
20660
  createElement("main", {
19485
20661
  className: "unity-desktop__desktop",
19486
- style: { flex: "1", position: "relative" }
20662
+ style: { flex: "1", position: "relative", overflow: "hidden", minHeight: "0" }
19487
20663
  }, desktopEl, appsGridEl)
19488
20664
  ),
19489
20665
  // Overlays