@asymmetric-effort/specifyjs 0.2.145 → 0.2.151

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.
@@ -91,16 +91,16 @@ function AnalogClock(props) {
91
91
  timezone,
92
92
  className
93
93
  } = props;
94
- const [now, setNow] = useState(getTimeInZone(timezone));
94
+ const [now2, setNow] = useState(getTimeInZone(timezone));
95
95
  useEffect(() => {
96
96
  const id = setInterval(() => {
97
97
  setNow(getTimeInZone(timezone));
98
98
  }, 1e3);
99
99
  return () => clearInterval(id);
100
100
  }, [timezone]);
101
- const hours = now.getHours();
102
- const minutes = now.getMinutes();
103
- const seconds = now.getSeconds();
101
+ const hours = now2.getHours();
102
+ const minutes = now2.getMinutes();
103
+ const seconds = now2.getSeconds();
104
104
  const hourAngle = hours % 12 * 30 + minutes * 0.5;
105
105
  const minuteAngle = minutes * 6 + seconds * 0.1;
106
106
  const secondAngle = seconds * 6;
@@ -210,7 +210,7 @@ function AnalogClock(props) {
210
210
  fontSize: "14px",
211
211
  color: COLORS.numbers
212
212
  }
213
- }, formatDate(now, dateFormat))
213
+ }, formatDate(now2, dateFormat))
214
214
  );
215
215
  }
216
216
  return createElement("div", {
@@ -932,14 +932,14 @@ function DigitalClock(props) {
932
932
  timezone,
933
933
  className
934
934
  } = props;
935
- const [now, setNow] = useState(/* @__PURE__ */ new Date());
935
+ const [now2, setNow] = useState(/* @__PURE__ */ new Date());
936
936
  useEffect(() => {
937
937
  const interval = setInterval(() => {
938
938
  setNow(/* @__PURE__ */ new Date());
939
939
  }, 1e3);
940
940
  return () => clearInterval(interval);
941
941
  }, []);
942
- const { hours, minutes, seconds } = getTimeParts(now, timezone);
942
+ const { hours, minutes, seconds } = getTimeParts(now2, timezone);
943
943
  let displayHours;
944
944
  let period = null;
945
945
  if (format === "12h") {
@@ -961,7 +961,7 @@ function DigitalClock(props) {
961
961
  ];
962
962
  if (showDate) {
963
963
  wrapperChildren.push(
964
- createElement("span", { style: dateStyle }, formatDate2(now, dateFormat, timezone))
964
+ createElement("span", { style: dateStyle }, formatDate2(now2, dateFormat, timezone))
965
965
  );
966
966
  }
967
967
  return createElement("div", {
@@ -12778,7 +12778,7 @@ function ActivitiesButton(props) {
12778
12778
  }
12779
12779
  function Clock(props) {
12780
12780
  const { format, showSeconds, showDate } = props;
12781
- const [now, setNow] = useState(/* @__PURE__ */ new Date());
12781
+ const [now2, setNow] = useState(/* @__PURE__ */ new Date());
12782
12782
  useEffect(() => {
12783
12783
  const id = setInterval(() => {
12784
12784
  setNow(/* @__PURE__ */ new Date());
@@ -12787,8 +12787,8 @@ function Clock(props) {
12787
12787
  clearInterval(id);
12788
12788
  };
12789
12789
  }, []);
12790
- const timeStr = useMemo(() => formatTime2(now, format, showSeconds), [now, format, showSeconds]);
12791
- const dateStr = useMemo(() => formatDate4(now), [now]);
12790
+ const timeStr = useMemo(() => formatTime2(now2, format, showSeconds), [now2, format, showSeconds]);
12791
+ const dateStr = useMemo(() => formatDate4(now2), [now2]);
12792
12792
  const dateEl = showDate ? createElement("span", {
12793
12793
  style: { fontSize: "11px", opacity: "0.85" }
12794
12794
  }, dateStr) : null;
@@ -16333,10 +16333,10 @@ function TradingDashboard(props) {
16333
16333
  }, []);
16334
16334
  useEffect(() => {
16335
16335
  const updateClock = () => {
16336
- const now = /* @__PURE__ */ new Date();
16337
- const h = String(now.getHours()).padStart(2, "0");
16338
- const m = String(now.getMinutes()).padStart(2, "0");
16339
- const s = String(now.getSeconds()).padStart(2, "0");
16336
+ const now2 = /* @__PURE__ */ new Date();
16337
+ const h = String(now2.getHours()).padStart(2, "0");
16338
+ const m = String(now2.getMinutes()).padStart(2, "0");
16339
+ const s = String(now2.getSeconds()).padStart(2, "0");
16340
16340
  setClockTime(`${h}:${m}:${s}`);
16341
16341
  };
16342
16342
  updateClock();
@@ -16453,314 +16453,149 @@ function TradingDashboard(props) {
16453
16453
  );
16454
16454
  }
16455
16455
 
16456
- // ../demos/project-manager/src/Toolbar.ts
16457
- var CARD_COLORS = [
16458
- "#fef9c3",
16459
- // yellow
16460
- "#fecaca",
16461
- // red
16462
- "#fed7aa",
16463
- // orange
16464
- "#bbf7d0",
16465
- // green
16466
- "#bfdbfe",
16467
- // blue
16468
- "#ddd6fe",
16469
- // purple
16470
- "#fbcfe8",
16471
- // pink
16472
- "#e5e7eb"
16473
- // gray
16474
- ];
16475
- function BoardToolbar(props) {
16476
- const {
16477
- zoom,
16478
- gridEnabled,
16479
- selectedColor,
16480
- colorFilter,
16481
- onNewCard,
16482
- onZoomIn,
16483
- onZoomOut,
16484
- onZoomReset,
16485
- onColorSelect,
16486
- onColorFilter,
16487
- onGridToggle,
16488
- onSearch
16489
- } = props;
16490
- const [searchText, setSearchText] = useState("");
16491
- const handleSearchInput = useCallback((e) => {
16492
- const value = e.target.value;
16493
- setSearchText(value);
16494
- onSearch(value);
16495
- }, [onSearch]);
16496
- const toolbarStyle = {
16497
- display: "flex",
16498
- alignItems: "center",
16499
- gap: "8px",
16500
- padding: "6px 12px",
16501
- backgroundColor: "rgba(255,255,255,0.95)",
16502
- borderBottom: "1px solid #e2e8f0",
16503
- fontSize: "12px",
16504
- flexShrink: "0",
16505
- flexWrap: "wrap"
16506
- };
16507
- const btnStyle = {
16508
- padding: "4px 10px",
16509
- border: "1px solid #d1d5db",
16510
- borderRadius: "4px",
16511
- backgroundColor: "#ffffff",
16512
- cursor: "pointer",
16513
- fontSize: "12px",
16514
- color: "#374151",
16515
- lineHeight: "1.4"
16516
- };
16517
- const activeBtnStyle = {
16518
- ...btnStyle,
16519
- backgroundColor: "#3b82f6",
16520
- color: "#ffffff",
16521
- borderColor: "#3b82f6"
16522
- };
16523
- const zoomText = {
16524
- fontSize: "12px",
16525
- color: "#64748b",
16526
- minWidth: "40px",
16527
- textAlign: "center",
16528
- cursor: "pointer"
16529
- };
16530
- const separatorStyle = {
16531
- width: "1px",
16532
- height: "20px",
16533
- backgroundColor: "#e2e8f0",
16534
- margin: "0 4px"
16535
- };
16536
- const inputStyle = {
16537
- padding: "4px 8px",
16538
- border: "1px solid #d1d5db",
16539
- borderRadius: "4px",
16540
- fontSize: "12px",
16541
- width: "120px",
16542
- outline: "none"
16543
- };
16544
- const swatches = CARD_COLORS.map((color) => {
16545
- const isActive = color === selectedColor;
16546
- const isFiltered = color === colorFilter;
16547
- const handleSwatchClick = () => {
16548
- if (isActive && onColorFilter) {
16549
- onColorFilter(isFiltered ? null : color);
16550
- } else {
16551
- onColorSelect(color);
16552
- }
16553
- };
16554
- let borderStyle = "1px solid rgba(0,0,0,0.15)";
16555
- if (isFiltered) {
16556
- borderStyle = "3px solid #ef4444";
16557
- } else if (isActive) {
16558
- borderStyle = "2px solid #3b82f6";
16559
- }
16560
- return createElement("button", {
16561
- key: color,
16562
- style: {
16563
- width: "18px",
16564
- height: "18px",
16565
- borderRadius: "50%",
16566
- backgroundColor: color,
16567
- border: borderStyle,
16568
- cursor: "pointer",
16569
- padding: "0",
16570
- flexShrink: "0",
16571
- opacity: isFiltered ? "1" : colorFilter ? "0.5" : "1"
16572
- },
16573
- onClick: handleSwatchClick,
16574
- "aria-label": isFiltered ? `Clear color filter ${color}` : `Select color ${color}`,
16575
- "data-testid": `color-swatch-${color}`
16576
- });
16456
+ // ../components/data/board/src/types.ts
16457
+ function isCard(item) {
16458
+ return item.type === "card";
16459
+ }
16460
+ function isContainer(item) {
16461
+ return item.type === "container";
16462
+ }
16463
+ function generateUUID() {
16464
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
16465
+ return crypto.randomUUID();
16466
+ }
16467
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
16468
+ const r = Math.random() * 16 | 0;
16469
+ const v = c === "x" ? r : r & 3 | 8;
16470
+ return v.toString(16);
16577
16471
  });
16578
- return createElement(
16579
- "div",
16580
- {
16581
- className: "board-toolbar",
16582
- style: toolbarStyle,
16583
- role: "toolbar",
16584
- "aria-label": "Board toolbar",
16585
- "data-testid": "board-toolbar"
16586
- },
16587
- // New card button
16588
- createElement("button", {
16589
- style: btnStyle,
16590
- onClick: onNewCard,
16591
- "data-testid": "btn-new-card",
16592
- "aria-label": "New card"
16593
- }, "+ New Card"),
16594
- createElement("div", { style: separatorStyle }),
16595
- // Zoom controls
16596
- createElement("button", {
16597
- style: btnStyle,
16598
- onClick: onZoomOut,
16599
- "data-testid": "btn-zoom-out",
16600
- "aria-label": "Zoom out"
16601
- }, "-"),
16602
- createElement("span", {
16603
- style: zoomText,
16604
- onClick: onZoomReset,
16605
- "data-testid": "zoom-level",
16606
- role: "status",
16607
- "aria-label": `Zoom ${Math.round(zoom * 100)}%`
16608
- }, `${Math.round(zoom * 100)}%`),
16609
- createElement("button", {
16610
- style: btnStyle,
16611
- onClick: onZoomIn,
16612
- "data-testid": "btn-zoom-in",
16613
- "aria-label": "Zoom in"
16614
- }, "+"),
16615
- createElement("div", { style: separatorStyle }),
16616
- ...swatches,
16617
- createElement("div", { style: separatorStyle }),
16618
- // Grid toggle
16619
- createElement("button", {
16620
- style: gridEnabled ? activeBtnStyle : btnStyle,
16621
- onClick: onGridToggle,
16622
- "data-testid": "btn-grid-toggle",
16623
- "aria-label": gridEnabled ? "Disable grid snapping" : "Enable grid snapping",
16624
- "aria-pressed": String(gridEnabled)
16625
- }, "Grid"),
16626
- createElement("div", { style: separatorStyle }),
16627
- // Search
16628
- createElement("input", {
16629
- type: "text",
16630
- placeholder: "Search cards...",
16631
- value: searchText,
16632
- onInput: handleSearchInput,
16633
- style: inputStyle,
16634
- "data-testid": "search-input",
16635
- "aria-label": "Search cards"
16636
- })
16637
- );
16472
+ }
16473
+ function getItemId(item) {
16474
+ return isCard(item) ? item.card_id : item.container_id;
16638
16475
  }
16639
16476
 
16640
- // ../demos/project-manager/src/Card.ts
16477
+ // ../components/data/board/src/Card.ts
16641
16478
  var PRIORITY_COLORS = {
16642
16479
  low: "#22c55e",
16643
16480
  medium: "#f59e0b",
16644
16481
  high: "#f97316",
16645
16482
  critical: "#ef4444"
16646
16483
  };
16647
- var CONTEXT_MENU_COLORS = CARD_COLORS;
16648
- var PRIORITY_OPTIONS = [
16649
- { label: "Low", value: "low" },
16650
- { label: "Medium", value: "medium" },
16651
- { label: "High", value: "high" },
16652
- { label: "Critical", value: "critical" }
16484
+ var CARD_TYPE_OPTIONS = [
16485
+ { label: "Text", value: "text" },
16486
+ { label: "JSON", value: "json" },
16487
+ { label: "Task", value: "task" },
16488
+ { label: "Project", value: "project" }
16653
16489
  ];
16654
- function Card2(props) {
16655
- const {
16656
- card,
16657
- selected,
16658
- onSelect,
16659
- onMove,
16660
- onResize,
16661
- onDelete,
16662
- onDoubleClick,
16663
- onDragStart,
16664
- onDuplicate,
16665
- onChangeColor,
16666
- onChangePriority,
16667
- onAnchorDragStart
16668
- } = props;
16490
+ function renderTextContent(card) {
16491
+ const content = card.content;
16492
+ return createElement("div", {
16493
+ style: {
16494
+ fontSize: "12px",
16495
+ color: "#555555",
16496
+ lineHeight: "1.4",
16497
+ overflow: "hidden",
16498
+ flex: "1"
16499
+ },
16500
+ "data-testid": `card-text-content-${card.card_id}`
16501
+ }, content.text || "");
16502
+ }
16503
+ function renderJsonContent(card) {
16504
+ const content = card.content;
16505
+ const entries = Object.entries(content);
16506
+ const fields = entries.map(
16507
+ ([key, value], i) => createElement(
16508
+ "div",
16509
+ {
16510
+ key: String(i),
16511
+ style: {
16512
+ display: "flex",
16513
+ gap: "4px",
16514
+ fontSize: "11px",
16515
+ lineHeight: "1.6",
16516
+ borderBottom: "1px solid rgba(0,0,0,0.05)",
16517
+ padding: "2px 0"
16518
+ }
16519
+ },
16520
+ createElement("span", {
16521
+ style: { fontWeight: "600", color: "#374151", minWidth: "60px" }
16522
+ }, `${key}:`),
16523
+ createElement("span", {
16524
+ style: { color: "#555555" }
16525
+ }, String(value ?? ""))
16526
+ )
16527
+ );
16528
+ return createElement("div", {
16529
+ style: { flex: "1", overflow: "auto" },
16530
+ "data-testid": `card-json-content-${card.card_id}`
16531
+ }, ...fields);
16532
+ }
16533
+ function renderTaskContent(card) {
16534
+ return createElement("div", {
16535
+ style: {
16536
+ fontSize: "12px",
16537
+ color: "#9ca3af",
16538
+ fontStyle: "italic",
16539
+ flex: "1",
16540
+ display: "flex",
16541
+ alignItems: "center",
16542
+ justifyContent: "center"
16543
+ },
16544
+ "data-testid": `card-task-content-${card.card_id}`
16545
+ }, "Task card (coming soon)");
16546
+ }
16547
+ function renderProjectContent(card, onOpenProject) {
16548
+ const content = card.content;
16549
+ return createElement("div", {
16550
+ style: {
16551
+ display: "inline-flex",
16552
+ alignItems: "center",
16553
+ justifyContent: "center",
16554
+ padding: "4px 16px",
16555
+ borderRadius: "999px",
16556
+ backgroundColor: card.color || "#e0e7ff",
16557
+ fontSize: "13px",
16558
+ fontWeight: "600",
16559
+ color: "#1e3a5f",
16560
+ cursor: "pointer",
16561
+ flex: "1"
16562
+ },
16563
+ onDblClick: (e) => {
16564
+ e.preventDefault();
16565
+ e.stopPropagation();
16566
+ if (onOpenProject && content.project_id) {
16567
+ onOpenProject(content.project_id);
16568
+ }
16569
+ },
16570
+ "data-testid": `card-project-content-${card.card_id}`
16571
+ }, content.project_name || "Untitled Project");
16572
+ }
16573
+ function CardComponent(props) {
16574
+ const { card, selected = false, onSelect, onMove, onResize, onDelete, dispatch, onOpenProject } = props;
16669
16575
  const [hovered, setHovered] = useState(false);
16670
16576
  const [contextMenu, setContextMenu] = useState(null);
16671
- const [colorSubmenuOpen, setColorSubmenuOpen] = useState(false);
16672
- const [prioritySubmenuOpen, setPrioritySubmenuOpen] = useState(false);
16577
+ const [typeSubmenuOpen, setTypeSubmenuOpen] = useState(false);
16673
16578
  const dragStartRef = useRef(null);
16674
16579
  const resizeStartRef = useRef(null);
16675
- const cardRef = useRef(null);
16676
- const contextMenuRef = useRef(null);
16677
16580
  const priorityColor = card.priority ? PRIORITY_COLORS[card.priority] || "#94a3b8" : "transparent";
16678
16581
  const handleContextMenu = useCallback((e) => {
16679
16582
  const me = e;
16680
16583
  me.preventDefault();
16681
16584
  me.stopPropagation();
16682
16585
  setContextMenu({ x: me.clientX, y: me.clientY });
16683
- setColorSubmenuOpen(false);
16684
- setPrioritySubmenuOpen(false);
16586
+ setTypeSubmenuOpen(false);
16685
16587
  }, []);
16686
16588
  const closeContextMenu = useCallback(() => {
16687
16589
  setContextMenu(null);
16688
- setColorSubmenuOpen(false);
16689
- setPrioritySubmenuOpen(false);
16690
- }, []);
16691
- useEffect(() => {
16692
- if (!contextMenu) return;
16693
- const handleClick = () => {
16694
- closeContextMenu();
16695
- };
16696
- const timer = setTimeout(() => {
16697
- document.addEventListener("click", handleClick);
16698
- document.addEventListener("contextmenu", handleClick);
16699
- }, 0);
16700
- return () => {
16701
- clearTimeout(timer);
16702
- document.removeEventListener("click", handleClick);
16703
- document.removeEventListener("contextmenu", handleClick);
16704
- };
16705
- }, [contextMenu, closeContextMenu]);
16706
- const handleDuplicateClick = useCallback((e) => {
16707
- e.stopPropagation();
16708
- closeContextMenu();
16709
- if (onDuplicate) onDuplicate(card.id);
16710
- }, [card.id, onDuplicate, closeContextMenu]);
16711
- const handleContextDeleteClick = useCallback((e) => {
16712
- e.stopPropagation();
16713
- closeContextMenu();
16714
- onDelete(card.id);
16715
- }, [card.id, onDelete, closeContextMenu]);
16716
- const handleColorMenuEnter = useCallback(() => {
16717
- setColorSubmenuOpen(true);
16718
- setPrioritySubmenuOpen(false);
16719
- }, []);
16720
- const handlePriorityMenuEnter = useCallback(() => {
16721
- setPrioritySubmenuOpen(true);
16722
- setColorSubmenuOpen(false);
16590
+ setTypeSubmenuOpen(false);
16723
16591
  }, []);
16724
- const handleColorSelect = useCallback((color) => {
16725
- closeContextMenu();
16726
- if (onChangeColor) onChangeColor(card.id, color);
16727
- }, [card.id, onChangeColor, closeContextMenu]);
16728
- const handlePrioritySelect = useCallback((priority) => {
16729
- closeContextMenu();
16730
- if (onChangePriority) onChangePriority(card.id, priority);
16731
- }, [card.id, onChangePriority, closeContextMenu]);
16732
- const handleAnchorMouseDown = useCallback((anchor, e) => {
16733
- const me = e;
16734
- me.preventDefault();
16735
- me.stopPropagation();
16736
- if (onAnchorDragStart) {
16737
- const cx = card.position.x + card.size.width / 2;
16738
- const cy = card.position.y + card.size.height / 2;
16739
- let ax = cx;
16740
- let ay = cy;
16741
- if (anchor === "top") {
16742
- ax = cx;
16743
- ay = card.position.y;
16744
- } else if (anchor === "bottom") {
16745
- ax = cx;
16746
- ay = card.position.y + card.size.height;
16747
- } else if (anchor === "left") {
16748
- ax = card.position.x;
16749
- ay = cy;
16750
- } else if (anchor === "right") {
16751
- ax = card.position.x + card.size.width;
16752
- ay = cy;
16753
- }
16754
- onAnchorDragStart(card.id, anchor, ax, ay);
16755
- }
16756
- }, [card.id, card.position, card.size, onAnchorDragStart]);
16757
16592
  const handleMouseDown = useCallback((e) => {
16758
16593
  const me = e;
16759
16594
  const target = me.target;
16760
- if (target.dataset && (target.dataset.role === "delete" || target.dataset.role === "resize" || target.dataset.role === "anchor")) return;
16595
+ if (target.dataset && (target.dataset.role === "delete" || target.dataset.role === "resize" || target.dataset.role === "drag-handle")) return;
16761
16596
  me.preventDefault();
16762
16597
  me.stopPropagation();
16763
- onSelect(card.id);
16598
+ if (onSelect) onSelect(card.card_id);
16764
16599
  dragStartRef.current = {
16765
16600
  x: me.clientX,
16766
16601
  y: me.clientY,
@@ -16772,10 +16607,12 @@ function Card2(props) {
16772
16607
  if (!dragStartRef.current) return;
16773
16608
  const dx = mev.clientX - dragStartRef.current.x;
16774
16609
  const dy = mev.clientY - dragStartRef.current.y;
16775
- onMove(card.id, {
16776
- x: dragStartRef.current.cardX + dx,
16777
- y: dragStartRef.current.cardY + dy
16778
- });
16610
+ if (onMove) {
16611
+ onMove(card.card_id, {
16612
+ x: dragStartRef.current.cardX + dx,
16613
+ y: dragStartRef.current.cardY + dy
16614
+ });
16615
+ }
16779
16616
  };
16780
16617
  const handleMouseUp = () => {
16781
16618
  dragStartRef.current = null;
@@ -16784,10 +16621,7 @@ function Card2(props) {
16784
16621
  };
16785
16622
  document.addEventListener("mousemove", handleMouseMove);
16786
16623
  document.addEventListener("mouseup", handleMouseUp);
16787
- if (onDragStart) {
16788
- onDragStart(card.id, e);
16789
- }
16790
- }, [card.id, card.position.x, card.position.y, onSelect, onMove, onDragStart]);
16624
+ }, [card.card_id, card.position.x, card.position.y, onSelect, onMove]);
16791
16625
  const handleResizeMouseDown = useCallback((e) => {
16792
16626
  const me = e;
16793
16627
  me.preventDefault();
@@ -16805,7 +16639,9 @@ function Card2(props) {
16805
16639
  const dy = mev.clientY - resizeStartRef.current.y;
16806
16640
  const newW = Math.max(120, resizeStartRef.current.w + dx);
16807
16641
  const newH = Math.max(80, resizeStartRef.current.h + dy);
16808
- onResize(card.id, { width: newW, height: newH });
16642
+ if (onResize) {
16643
+ onResize(card.card_id, { width: newW, height: newH });
16644
+ }
16809
16645
  };
16810
16646
  const handleMouseUp = () => {
16811
16647
  resizeStartRef.current = null;
@@ -16814,17 +16650,36 @@ function Card2(props) {
16814
16650
  };
16815
16651
  document.addEventListener("mousemove", handleMouseMove);
16816
16652
  document.addEventListener("mouseup", handleMouseUp);
16817
- }, [card.id, card.size.width, card.size.height, onResize]);
16818
- const handleDoubleClick = useCallback((e) => {
16819
- e.preventDefault();
16820
- e.stopPropagation();
16821
- onDoubleClick(card.id);
16822
- }, [card.id, onDoubleClick]);
16653
+ }, [card.card_id, card.size.width, card.size.height, onResize]);
16823
16654
  const handleDeleteClick = useCallback((e) => {
16824
16655
  e.preventDefault();
16825
16656
  e.stopPropagation();
16826
- onDelete(card.id);
16827
- }, [card.id, onDelete]);
16657
+ if (onDelete) onDelete(card.card_id);
16658
+ }, [card.card_id, onDelete]);
16659
+ const handleChangeType = useCallback((newType) => {
16660
+ if (dispatch) {
16661
+ dispatch({ type: "CHANGE_CARD_TYPE", cardId: card.card_id, newType });
16662
+ }
16663
+ closeContextMenu();
16664
+ }, [card.card_id, dispatch, closeContextMenu]);
16665
+ let contentEl;
16666
+ switch (card.card_type) {
16667
+ case "text":
16668
+ contentEl = renderTextContent(card);
16669
+ break;
16670
+ case "json":
16671
+ contentEl = renderJsonContent(card);
16672
+ break;
16673
+ case "task":
16674
+ contentEl = renderTaskContent(card);
16675
+ break;
16676
+ case "project":
16677
+ contentEl = renderProjectContent(card, onOpenProject);
16678
+ break;
16679
+ default:
16680
+ contentEl = renderTextContent(card);
16681
+ }
16682
+ const isProjectPill = card.card_type === "project";
16828
16683
  const cardStyle = {
16829
16684
  position: "absolute",
16830
16685
  left: `${card.position.x}px`,
@@ -16832,7 +16687,7 @@ function Card2(props) {
16832
16687
  width: `${card.size.width}px`,
16833
16688
  height: `${card.size.height}px`,
16834
16689
  backgroundColor: card.color || "#fef9c3",
16835
- borderRadius: "6px",
16690
+ borderRadius: isProjectPill ? "999px" : "6px",
16836
16691
  borderLeft: `4px solid ${priorityColor}`,
16837
16692
  boxShadow: selected ? "0 0 0 2px #3b82f6, 0 4px 12px rgba(0,0,0,0.15)" : "0 2px 8px rgba(0,0,0,0.1)",
16838
16693
  cursor: "grab",
@@ -16842,7 +16697,8 @@ function Card2(props) {
16842
16697
  flexDirection: "column",
16843
16698
  padding: "8px 10px",
16844
16699
  boxSizing: "border-box",
16845
- transition: "box-shadow 150ms ease"
16700
+ transition: "box-shadow 150ms ease",
16701
+ zIndex: "1"
16846
16702
  };
16847
16703
  const titleStyle = {
16848
16704
  fontWeight: "600",
@@ -16854,13 +16710,6 @@ function Card2(props) {
16854
16710
  textOverflow: "ellipsis",
16855
16711
  whiteSpace: "nowrap"
16856
16712
  };
16857
- const descStyle = {
16858
- fontSize: "12px",
16859
- color: "#555555",
16860
- lineHeight: "1.4",
16861
- overflow: "hidden",
16862
- flex: "1"
16863
- };
16864
16713
  const deleteStyle = {
16865
16714
  position: "absolute",
16866
16715
  top: "4px",
@@ -16888,6 +16737,53 @@ function Card2(props) {
16888
16737
  opacity: "0.4",
16889
16738
  background: "linear-gradient(135deg, transparent 50%, #666 50%)"
16890
16739
  };
16740
+ const dragHandleStyle = {
16741
+ position: "absolute",
16742
+ top: "4px",
16743
+ right: "24px",
16744
+ width: "18px",
16745
+ height: "18px",
16746
+ borderRadius: "3px",
16747
+ backgroundColor: "rgba(0,0,0,0.1)",
16748
+ color: "#333",
16749
+ fontSize: "10px",
16750
+ lineHeight: "18px",
16751
+ textAlign: "center",
16752
+ cursor: "grab",
16753
+ display: hovered ? "block" : "none",
16754
+ border: "none",
16755
+ padding: "0"
16756
+ };
16757
+ const assigneeEl = card.assignee ? createElement(
16758
+ "div",
16759
+ {
16760
+ style: {
16761
+ display: "flex",
16762
+ alignItems: "center",
16763
+ gap: "4px",
16764
+ marginTop: "4px",
16765
+ fontSize: "10px",
16766
+ color: "#555"
16767
+ },
16768
+ "data-testid": `card-assignee-${card.card_id}`
16769
+ },
16770
+ createElement("span", {
16771
+ style: {
16772
+ width: "16px",
16773
+ height: "16px",
16774
+ borderRadius: "50%",
16775
+ backgroundColor: "#3b82f6",
16776
+ color: "#fff",
16777
+ fontSize: "9px",
16778
+ fontWeight: "700",
16779
+ display: "inline-flex",
16780
+ alignItems: "center",
16781
+ justifyContent: "center",
16782
+ flexShrink: "0"
16783
+ }
16784
+ }, card.assignee.charAt(0).toUpperCase()),
16785
+ createElement("span", {}, card.assignee)
16786
+ ) : null;
16891
16787
  const tagsEl = card.tags && card.tags.length > 0 ? createElement(
16892
16788
  "div",
16893
16789
  {
@@ -16911,37 +16807,7 @@ function Card2(props) {
16911
16807
  }, tag)
16912
16808
  )
16913
16809
  ) : null;
16914
- const anchorBaseStyle = {
16915
- position: "absolute",
16916
- width: "10px",
16917
- height: "10px",
16918
- borderRadius: "50%",
16919
- backgroundColor: "#3b82f6",
16920
- border: "2px solid #ffffff",
16921
- cursor: "crosshair",
16922
- display: hovered ? "block" : "none",
16923
- zIndex: "10",
16924
- boxSizing: "border-box"
16925
- };
16926
- const anchorTop = { ...anchorBaseStyle, top: "-5px", left: "50%", transform: "translateX(-50%)" };
16927
- const anchorRight = { ...anchorBaseStyle, top: "50%", right: "-5px", transform: "translateY(-50%)" };
16928
- const anchorBottom = { ...anchorBaseStyle, bottom: "-5px", left: "50%", transform: "translateX(-50%)" };
16929
- const anchorLeft = { ...anchorBaseStyle, top: "50%", left: "-5px", transform: "translateY(-50%)" };
16930
- const contextMenuStyle = {
16931
- position: "fixed",
16932
- left: contextMenu ? `${contextMenu.x}px` : "0",
16933
- top: contextMenu ? `${contextMenu.y}px` : "0",
16934
- backgroundColor: "#ffffff",
16935
- border: "1px solid #d1d5db",
16936
- borderRadius: "6px",
16937
- boxShadow: "0 4px 16px rgba(0,0,0,0.15)",
16938
- padding: "4px 0",
16939
- zIndex: "10000",
16940
- minWidth: "160px",
16941
- fontSize: "13px",
16942
- color: "#1a1a1a"
16943
- };
16944
- const menuItemStyle = {
16810
+ const ctxMenuItemStyle = {
16945
16811
  padding: "6px 12px",
16946
16812
  cursor: "pointer",
16947
16813
  display: "flex",
@@ -16949,7 +16815,7 @@ function Card2(props) {
16949
16815
  justifyContent: "space-between",
16950
16816
  whiteSpace: "nowrap"
16951
16817
  };
16952
- const submenuContainerStyle = {
16818
+ const ctxSubmenuStyle = {
16953
16819
  position: "absolute",
16954
16820
  left: "100%",
16955
16821
  top: "0",
@@ -16963,156 +16829,147 @@ function Card2(props) {
16963
16829
  const contextMenuEl = contextMenu ? createElement(
16964
16830
  "div",
16965
16831
  {
16966
- ref: contextMenuRef,
16967
16832
  className: "card-context-menu",
16968
- style: contextMenuStyle,
16969
- "data-testid": `context-menu-${card.id}`,
16833
+ style: {
16834
+ position: "fixed",
16835
+ left: `${contextMenu.x}px`,
16836
+ top: `${contextMenu.y}px`,
16837
+ backgroundColor: "#ffffff",
16838
+ border: "1px solid #d1d5db",
16839
+ borderRadius: "6px",
16840
+ boxShadow: "0 4px 16px rgba(0,0,0,0.15)",
16841
+ padding: "4px 0",
16842
+ zIndex: "10000",
16843
+ minWidth: "160px",
16844
+ fontSize: "13px",
16845
+ color: "#1a1a1a"
16846
+ },
16847
+ "data-testid": `card-context-menu-${card.card_id}`,
16970
16848
  role: "menu",
16971
- "aria-label": "Card context menu"
16849
+ "aria-label": "Card context menu",
16850
+ onClick: (e) => e.stopPropagation()
16972
16851
  },
16973
- // Duplicate
16974
- createElement("div", {
16975
- style: menuItemStyle,
16976
- onClick: handleDuplicateClick,
16977
- role: "menuitem",
16978
- "data-testid": `context-menu-duplicate-${card.id}`
16979
- }, "Duplicate"),
16980
16852
  // Delete
16981
16853
  createElement("div", {
16982
- style: menuItemStyle,
16983
- onClick: handleContextDeleteClick,
16854
+ style: ctxMenuItemStyle,
16855
+ onClick: (e) => {
16856
+ e.stopPropagation();
16857
+ if (onDelete) onDelete(card.card_id);
16858
+ closeContextMenu();
16859
+ },
16984
16860
  role: "menuitem",
16985
- "data-testid": `context-menu-delete-${card.id}`
16861
+ "data-testid": `ctx-delete-${card.card_id}`
16986
16862
  }, "Delete"),
16987
- // Change Color submenu
16988
- createElement(
16989
- "div",
16990
- {
16991
- style: { ...menuItemStyle, position: "relative" },
16992
- onMouseEnter: handleColorMenuEnter,
16993
- role: "menuitem",
16994
- "aria-haspopup": "true",
16995
- "data-testid": `context-menu-color-${card.id}`
16996
- },
16997
- "Change Color",
16998
- createElement("span", { style: { marginLeft: "8px" } }, "\u25B6"),
16999
- colorSubmenuOpen ? createElement(
17000
- "div",
17001
- {
17002
- style: submenuContainerStyle,
17003
- role: "menu",
17004
- "data-testid": `context-submenu-color-${card.id}`
17005
- },
17006
- ...CONTEXT_MENU_COLORS.map(
17007
- (color) => createElement(
17008
- "div",
17009
- {
17010
- key: color,
17011
- style: {
17012
- ...menuItemStyle,
17013
- gap: "8px"
17014
- },
17015
- onClick: (e) => {
17016
- e.stopPropagation();
17017
- handleColorSelect(color);
17018
- },
17019
- role: "menuitem",
17020
- "data-testid": `context-color-${color}`
17021
- },
17022
- createElement("span", {
17023
- style: {
17024
- width: "14px",
17025
- height: "14px",
17026
- borderRadius: "50%",
17027
- backgroundColor: color,
17028
- border: "1px solid rgba(0,0,0,0.15)",
17029
- display: "inline-block",
17030
- flexShrink: "0"
17031
- }
17032
- }),
17033
- color === card.color ? "\u2713" : ""
17034
- )
17035
- )
17036
- ) : null
17037
- ),
17038
- // Set Priority submenu
16863
+ // Change Type submenu
17039
16864
  createElement(
17040
16865
  "div",
17041
16866
  {
17042
- style: { ...menuItemStyle, position: "relative" },
17043
- onMouseEnter: handlePriorityMenuEnter,
16867
+ style: { ...ctxMenuItemStyle, position: "relative" },
16868
+ onMouseEnter: () => setTypeSubmenuOpen(true),
17044
16869
  role: "menuitem",
17045
16870
  "aria-haspopup": "true",
17046
- "data-testid": `context-menu-priority-${card.id}`
16871
+ "data-testid": `ctx-change-type-${card.card_id}`
17047
16872
  },
17048
- "Set Priority",
16873
+ "Change Type",
17049
16874
  createElement("span", { style: { marginLeft: "8px" } }, "\u25B6"),
17050
- prioritySubmenuOpen ? createElement(
16875
+ typeSubmenuOpen ? createElement(
17051
16876
  "div",
17052
16877
  {
17053
- style: submenuContainerStyle,
16878
+ style: ctxSubmenuStyle,
17054
16879
  role: "menu",
17055
- "data-testid": `context-submenu-priority-${card.id}`
16880
+ "data-testid": `ctx-type-submenu-${card.card_id}`
17056
16881
  },
17057
- ...PRIORITY_OPTIONS.map(
16882
+ ...CARD_TYPE_OPTIONS.map(
17058
16883
  (opt) => createElement(
17059
16884
  "div",
17060
16885
  {
17061
16886
  key: opt.value,
17062
16887
  style: {
17063
- ...menuItemStyle,
17064
- gap: "8px"
16888
+ ...ctxMenuItemStyle,
16889
+ fontWeight: card.card_type === opt.value ? "700" : "400"
17065
16890
  },
17066
16891
  onClick: (e) => {
17067
16892
  e.stopPropagation();
17068
- handlePrioritySelect(opt.value);
16893
+ handleChangeType(opt.value);
17069
16894
  },
17070
16895
  role: "menuitem",
17071
- "data-testid": `context-priority-${opt.value}`
16896
+ "data-testid": `ctx-type-${opt.value}-${card.card_id}`
17072
16897
  },
17073
- createElement("span", {
17074
- style: {
17075
- width: "8px",
17076
- height: "8px",
17077
- borderRadius: "50%",
17078
- backgroundColor: PRIORITY_COLORS[opt.value] || "#94a3b8",
17079
- display: "inline-block",
17080
- flexShrink: "0"
17081
- }
17082
- }),
17083
16898
  opt.label,
17084
- opt.value === card.priority ? " \u2713" : ""
16899
+ card.card_type === opt.value ? " \u2713" : ""
17085
16900
  )
17086
16901
  )
17087
16902
  ) : null
17088
16903
  )
17089
16904
  ) : null;
16905
+ if (isProjectPill) {
16906
+ return createElement(
16907
+ "div",
16908
+ {
16909
+ className: "board-card board-card--project",
16910
+ style: cardStyle,
16911
+ onMouseDown: handleMouseDown,
16912
+ onContextMenu: handleContextMenu,
16913
+ onMouseEnter: () => setHovered(true),
16914
+ onMouseLeave: () => {
16915
+ setHovered(false);
16916
+ closeContextMenu();
16917
+ },
16918
+ "data-card-id": card.card_id,
16919
+ "data-testid": `card-${card.card_id}`,
16920
+ role: "button",
16921
+ "aria-label": `Project card: ${card.card_title}`,
16922
+ tabIndex: 0
16923
+ },
16924
+ contentEl,
16925
+ createElement("div", {
16926
+ style: dragHandleStyle,
16927
+ "data-role": "drag-handle",
16928
+ "data-testid": `card-drag-handle-${card.card_id}`,
16929
+ "aria-label": "Export drag handle",
16930
+ title: "Drag to export card"
16931
+ }, "\u2630"),
16932
+ contextMenuEl
16933
+ );
16934
+ }
17090
16935
  return createElement(
17091
16936
  "div",
17092
16937
  {
17093
- ref: cardRef,
17094
16938
  className: "board-card",
17095
16939
  style: cardStyle,
17096
16940
  onMouseDown: handleMouseDown,
17097
- onDblClick: handleDoubleClick,
17098
16941
  onContextMenu: handleContextMenu,
17099
16942
  onMouseEnter: () => setHovered(true),
17100
- onMouseLeave: () => setHovered(false),
17101
- "data-card-id": card.id,
17102
- "data-testid": `card-${card.id}`,
16943
+ onMouseLeave: () => {
16944
+ setHovered(false);
16945
+ closeContextMenu();
16946
+ },
16947
+ "data-card-id": card.card_id,
16948
+ "data-testid": `card-${card.card_id}`,
17103
16949
  role: "button",
17104
- "aria-label": `Card: ${card.title}`,
16950
+ "aria-label": `Card: ${card.card_title}`,
17105
16951
  tabIndex: 0
17106
16952
  },
17107
- createElement("div", { style: titleStyle }, card.title || "Untitled"),
17108
- createElement("div", { style: descStyle }, card.description || ""),
16953
+ createElement("div", {
16954
+ style: titleStyle,
16955
+ "data-testid": `card-title-${card.card_id}`
16956
+ }, card.card_title || "Untitled"),
16957
+ contentEl,
17109
16958
  tagsEl,
16959
+ assigneeEl,
16960
+ createElement("div", {
16961
+ style: dragHandleStyle,
16962
+ "data-role": "drag-handle",
16963
+ "data-testid": `card-drag-handle-${card.card_id}`,
16964
+ "aria-label": `Export drag handle for ${card.card_title}`,
16965
+ title: "Drag to export card"
16966
+ }, "\u2630"),
17110
16967
  createElement("button", {
17111
16968
  style: deleteStyle,
17112
16969
  "data-role": "delete",
17113
- "data-testid": `card-delete-${card.id}`,
16970
+ "data-testid": `card-delete-${card.card_id}`,
17114
16971
  onClick: handleDeleteClick,
17115
- "aria-label": `Delete ${card.title}`,
16972
+ "aria-label": `Delete ${card.card_title}`,
17116
16973
  tabIndex: -1
17117
16974
  }, "\xD7"),
17118
16975
  createElement("div", {
@@ -17121,270 +16978,245 @@ function Card2(props) {
17121
16978
  onMouseDown: handleResizeMouseDown,
17122
16979
  "aria-label": "Resize card"
17123
16980
  }),
17124
- // Anchor circles for connection creation
17125
- createElement("div", {
17126
- style: anchorTop,
17127
- "data-role": "anchor",
17128
- "data-anchor": "top",
17129
- "data-testid": `anchor-top-${card.id}`,
17130
- onMouseDown: (e) => handleAnchorMouseDown("top", e),
17131
- "aria-label": "Connection anchor top"
17132
- }),
17133
- createElement("div", {
17134
- style: anchorRight,
17135
- "data-role": "anchor",
17136
- "data-anchor": "right",
17137
- "data-testid": `anchor-right-${card.id}`,
17138
- onMouseDown: (e) => handleAnchorMouseDown("right", e),
17139
- "aria-label": "Connection anchor right"
17140
- }),
17141
- createElement("div", {
17142
- style: anchorBottom,
17143
- "data-role": "anchor",
17144
- "data-anchor": "bottom",
17145
- "data-testid": `anchor-bottom-${card.id}`,
17146
- onMouseDown: (e) => handleAnchorMouseDown("bottom", e),
17147
- "aria-label": "Connection anchor bottom"
17148
- }),
17149
- createElement("div", {
17150
- style: anchorLeft,
17151
- "data-role": "anchor",
17152
- "data-anchor": "left",
17153
- "data-testid": `anchor-left-${card.id}`,
17154
- onMouseDown: (e) => handleAnchorMouseDown("left", e),
17155
- "aria-label": "Connection anchor left"
17156
- }),
17157
16981
  contextMenuEl
17158
16982
  );
17159
16983
  }
17160
16984
 
17161
- // ../demos/project-manager/src/CardEditor.ts
17162
- function CardEditor(props) {
17163
- const { card, onSave, onClose } = props;
17164
- const [title, setTitle] = useState(card.title);
17165
- const [description, setDescription] = useState(card.description);
17166
- const titleRef = useRef(null);
17167
- const overlayRef = useRef(null);
17168
- useEffect(() => {
17169
- if (titleRef.current) {
17170
- titleRef.current.focus();
17171
- titleRef.current.select();
17172
- }
17173
- }, []);
17174
- const save = useCallback(() => {
17175
- onSave(card.id, { title, description });
17176
- onClose();
17177
- }, [card.id, title, description, onSave, onClose]);
17178
- const handleKeyDown = useCallback((e) => {
17179
- const ke = e;
17180
- if (ke.key === "Escape") {
17181
- save();
17182
- }
17183
- }, [save]);
17184
- const handleOverlayClick = useCallback((e) => {
16985
+ // ../components/data/board/src/Container.ts
16986
+ function ContainerComponent(props) {
16987
+ const { container, selected = false, onSelect, onMove, onResize, onDrop, children } = props;
16988
+ const [dragOver, setDragOver] = useState(false);
16989
+ const dragStartRef = useRef(null);
16990
+ const resizeStartRef = useRef(null);
16991
+ const handleTitleMouseDown = useCallback((e) => {
17185
16992
  const me = e;
17186
- if (me.target === overlayRef.current) {
17187
- save();
17188
- }
17189
- }, [save]);
17190
- const handleTitleChange = useCallback((e) => {
17191
- setTitle(e.target.value);
16993
+ me.preventDefault();
16994
+ me.stopPropagation();
16995
+ if (onSelect) onSelect(container.container_id);
16996
+ dragStartRef.current = {
16997
+ x: me.clientX,
16998
+ y: me.clientY,
16999
+ posX: container.position.x,
17000
+ posY: container.position.y
17001
+ };
17002
+ const handleMouseMove = (ev) => {
17003
+ const mev = ev;
17004
+ if (!dragStartRef.current) return;
17005
+ const dx = mev.clientX - dragStartRef.current.x;
17006
+ const dy = mev.clientY - dragStartRef.current.y;
17007
+ if (onMove) {
17008
+ onMove(container.container_id, {
17009
+ x: dragStartRef.current.posX + dx,
17010
+ y: dragStartRef.current.posY + dy
17011
+ });
17012
+ }
17013
+ };
17014
+ const handleMouseUp = () => {
17015
+ dragStartRef.current = null;
17016
+ document.removeEventListener("mousemove", handleMouseMove);
17017
+ document.removeEventListener("mouseup", handleMouseUp);
17018
+ };
17019
+ document.addEventListener("mousemove", handleMouseMove);
17020
+ document.addEventListener("mouseup", handleMouseUp);
17021
+ }, [container.container_id, container.position.x, container.position.y, onSelect, onMove]);
17022
+ const handleResizeMouseDown = useCallback((e) => {
17023
+ const me = e;
17024
+ me.preventDefault();
17025
+ me.stopPropagation();
17026
+ resizeStartRef.current = {
17027
+ x: me.clientX,
17028
+ y: me.clientY,
17029
+ w: container.size.width,
17030
+ h: container.size.height
17031
+ };
17032
+ const handleMouseMove = (ev) => {
17033
+ const mev = ev;
17034
+ if (!resizeStartRef.current) return;
17035
+ const dx = mev.clientX - resizeStartRef.current.x;
17036
+ const dy = mev.clientY - resizeStartRef.current.y;
17037
+ const newW = Math.max(160, resizeStartRef.current.w + dx);
17038
+ const newH = Math.max(120, resizeStartRef.current.h + dy);
17039
+ if (onResize) {
17040
+ onResize(container.container_id, { width: newW, height: newH });
17041
+ }
17042
+ };
17043
+ const handleMouseUp = () => {
17044
+ resizeStartRef.current = null;
17045
+ document.removeEventListener("mousemove", handleMouseMove);
17046
+ document.removeEventListener("mouseup", handleMouseUp);
17047
+ };
17048
+ document.addEventListener("mousemove", handleMouseMove);
17049
+ document.addEventListener("mouseup", handleMouseUp);
17050
+ }, [container.container_id, container.size.width, container.size.height, onResize]);
17051
+ const handleDragOver = useCallback((e) => {
17052
+ const de = e;
17053
+ de.preventDefault();
17054
+ setDragOver(true);
17192
17055
  }, []);
17193
- const handleDescChange = useCallback((e) => {
17194
- setDescription(e.target.value);
17056
+ const handleDragLeave = useCallback(() => {
17057
+ setDragOver(false);
17195
17058
  }, []);
17196
- const handleTitleKeyDown = useCallback((e) => {
17197
- const ke = e;
17198
- if (ke.key === "Tab") {
17199
- ke.preventDefault();
17200
- const textarea = ke.target.parentElement?.querySelector("textarea");
17201
- if (textarea) textarea.focus();
17202
- }
17203
- if (ke.key === "Escape") {
17204
- save();
17059
+ const handleDrop = useCallback((e) => {
17060
+ const de = e;
17061
+ de.preventDefault();
17062
+ setDragOver(false);
17063
+ if (onDrop && de.dataTransfer) {
17064
+ const itemId = de.dataTransfer.getData("text/plain");
17065
+ if (itemId) {
17066
+ onDrop(itemId, container.container_id);
17067
+ }
17205
17068
  }
17206
- }, [save]);
17207
- const overlayStyle = {
17069
+ }, [container.container_id, onDrop]);
17070
+ const containerStyle3 = {
17208
17071
  position: "absolute",
17209
- inset: "0",
17210
- backgroundColor: "rgba(0,0,0,0.3)",
17211
- display: "flex",
17212
- alignItems: "center",
17213
- justifyContent: "center",
17214
- zIndex: "100"
17215
- };
17216
- const editorStyle = {
17217
- backgroundColor: card.color || "#fef9c3",
17072
+ left: `${container.position.x}px`,
17073
+ top: `${container.position.y}px`,
17074
+ width: `${container.size.width}px`,
17075
+ height: `${container.size.height}px`,
17076
+ backgroundColor: "#ffffff",
17077
+ border: selected ? "2px solid #3b82f6" : "2px solid #d1d5db",
17218
17078
  borderRadius: "8px",
17219
- padding: "16px",
17220
- width: `${Math.max(card.size.width, 200)}px`,
17221
- boxShadow: "0 8px 24px rgba(0,0,0,0.2)",
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)",
17222
17080
  display: "flex",
17223
17081
  flexDirection: "column",
17224
- gap: "8px"
17225
- };
17226
- const inputStyle = {
17227
- border: "1px solid rgba(0,0,0,0.15)",
17228
- borderRadius: "4px",
17229
- padding: "6px 8px",
17230
- fontSize: "14px",
17231
- fontWeight: "600",
17232
- backgroundColor: "rgba(255,255,255,0.7)",
17233
- color: "#1a1a1a",
17234
- outline: "none",
17235
- width: "100%",
17082
+ overflow: "hidden",
17083
+ zIndex: "0",
17236
17084
  boxSizing: "border-box"
17237
17085
  };
17238
- const textareaStyle = {
17239
- border: "1px solid rgba(0,0,0,0.15)",
17240
- borderRadius: "4px",
17241
- padding: "6px 8px",
17242
- fontSize: "12px",
17243
- backgroundColor: "rgba(255,255,255,0.7)",
17244
- color: "#333",
17245
- outline: "none",
17246
- resize: "vertical",
17247
- minHeight: "60px",
17248
- width: "100%",
17249
- boxSizing: "border-box",
17250
- fontFamily: "inherit"
17086
+ const titleBarStyle = {
17087
+ padding: "6px 12px",
17088
+ borderBottom: "1px solid #e5e7eb",
17089
+ backgroundColor: "#f9fafb",
17090
+ cursor: "grab",
17091
+ userSelect: "none",
17092
+ textAlign: "center",
17093
+ fontWeight: "700",
17094
+ fontSize: "15px",
17095
+ color: "#1f2937",
17096
+ flexShrink: "0"
17251
17097
  };
17252
- const btnStyle = {
17253
- padding: "6px 14px",
17254
- border: "none",
17255
- borderRadius: "4px",
17256
- backgroundColor: "#3b82f6",
17257
- color: "#ffffff",
17258
- cursor: "pointer",
17259
- fontSize: "12px",
17260
- fontWeight: "600",
17261
- alignSelf: "flex-end"
17098
+ const contentsStyle = {
17099
+ flex: "1",
17100
+ overflow: "auto",
17101
+ position: "relative",
17102
+ padding: "4px"
17103
+ };
17104
+ const resizeHandleStyle = {
17105
+ position: "absolute",
17106
+ bottom: "0",
17107
+ right: "0",
17108
+ width: "14px",
17109
+ height: "14px",
17110
+ cursor: "nwse-resize",
17111
+ opacity: "0.4",
17112
+ background: "linear-gradient(135deg, transparent 50%, #666 50%)"
17262
17113
  };
17263
17114
  return createElement(
17264
17115
  "div",
17265
17116
  {
17266
- ref: overlayRef,
17267
- className: "card-editor-overlay",
17268
- style: overlayStyle,
17269
- onClick: handleOverlayClick,
17270
- onKeyDown: handleKeyDown,
17271
- "data-testid": "card-editor-overlay"
17117
+ className: "board-container",
17118
+ style: containerStyle3,
17119
+ "data-container-id": container.container_id,
17120
+ "data-testid": `container-${container.container_id}`,
17121
+ role: "group",
17122
+ "aria-label": `Container: ${container.name}`,
17123
+ onDragOver: handleDragOver,
17124
+ onDragLeave: handleDragLeave,
17125
+ onDrop: handleDrop
17272
17126
  },
17273
- createElement(
17274
- "div",
17275
- {
17276
- style: editorStyle,
17277
- "data-testid": "card-editor",
17278
- role: "dialog",
17279
- "aria-label": `Edit card: ${card.title}`
17280
- },
17281
- createElement("input", {
17282
- ref: titleRef,
17283
- type: "text",
17284
- value: title,
17285
- onInput: handleTitleChange,
17286
- onKeyDown: handleTitleKeyDown,
17287
- style: inputStyle,
17288
- placeholder: "Card title",
17289
- "data-testid": "card-editor-title",
17290
- "aria-label": "Card title"
17291
- }),
17292
- createElement("textarea", {
17293
- value: description,
17294
- onInput: handleDescChange,
17295
- onKeyDown: handleKeyDown,
17296
- style: textareaStyle,
17297
- placeholder: "Description...",
17298
- "data-testid": "card-editor-description",
17299
- "aria-label": "Card description"
17300
- }),
17301
- createElement("button", {
17302
- style: btnStyle,
17303
- onClick: save,
17304
- "data-testid": "card-editor-save"
17305
- }, "Done")
17306
- )
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", {
17134
+ className: "board-container__contents",
17135
+ style: contentsStyle,
17136
+ "data-testid": `container-contents-${container.container_id}`
17137
+ }, children),
17138
+ createElement("div", {
17139
+ style: resizeHandleStyle,
17140
+ "data-role": "resize",
17141
+ onMouseDown: handleResizeMouseDown,
17142
+ "aria-label": "Resize container"
17143
+ })
17307
17144
  );
17308
17145
  }
17309
17146
 
17310
- // ../demos/project-manager/src/Connection.ts
17147
+ // ../components/data/board/src/CardLink.ts
17311
17148
  function getCardCenter(card) {
17312
17149
  return {
17313
17150
  x: card.position.x + card.size.width / 2,
17314
17151
  y: card.position.y + card.size.height / 2
17315
17152
  };
17316
17153
  }
17317
- function getStrokeDasharray(style) {
17318
- switch (style) {
17319
- case "dashed":
17320
- return "8,4";
17321
- case "dotted":
17322
- return "2,4";
17323
- default:
17324
- return "none";
17325
- }
17326
- }
17327
- function ConnectionsOverlay(props) {
17328
- const { connections, cards, selectedConnectionId, onSelectConnection, canvasWidth, canvasHeight } = props;
17154
+ var ARROW_MARKER_ID = "board-card-link-arrowhead";
17155
+ function CardLinkOverlay(props) {
17156
+ const { links, cards, selectedLinkId, onSelectLink, canvasWidth, canvasHeight } = props;
17329
17157
  const cardMap = /* @__PURE__ */ new Map();
17330
17158
  for (let i = 0; i < cards.length; i++) {
17331
- cardMap.set(cards[i].id, cards[i]);
17159
+ cardMap.set(cards[i].card_id, cards[i]);
17332
17160
  }
17333
- const handleLineClick = useCallback((connectionId) => {
17334
- onSelectConnection(connectionId);
17335
- }, [onSelectConnection]);
17161
+ const handleLineClick = useCallback((linkId) => {
17162
+ onSelectLink(linkId);
17163
+ }, [onSelectLink]);
17336
17164
  const lineElements = [];
17337
- for (let i = 0; i < connections.length; i++) {
17338
- const conn = connections[i];
17339
- const fromCard = cardMap.get(conn.fromCardId);
17340
- const toCard = cardMap.get(conn.toCardId);
17341
- if (!fromCard || !toCard) continue;
17342
- const from = getCardCenter(fromCard);
17343
- const to = getCardCenter(toCard);
17344
- const isSelected = conn.id === selectedConnectionId;
17345
- const strokeColor = isSelected ? "#3b82f6" : "#94a3b8";
17346
- const dashArray = getStrokeDasharray(conn.style);
17165
+ for (let i = 0; i < links.length; i++) {
17166
+ const { source, link } = links[i];
17167
+ const targetCard = cardMap.get(link.target_card_id);
17168
+ if (!targetCard) continue;
17169
+ const from = getCardCenter(source);
17170
+ const to = getCardCenter(targetCard);
17171
+ const isSelected = link.link_id === selectedLinkId;
17172
+ const strokeColor = isSelected ? "#3b82f6" : link.color || "#94a3b8";
17173
+ const dx = to.x - from.x;
17174
+ const dy = to.y - from.y;
17175
+ const dist = Math.sqrt(dx * dx + dy * dy);
17176
+ const curveOffset = Math.min(40, dist * 0.15);
17177
+ const nx = dist > 0 ? -dy / dist : 0;
17178
+ const ny = dist > 0 ? dx / dist : 0;
17179
+ const midX = (from.x + to.x) / 2;
17180
+ const midY = (from.y + to.y) / 2;
17181
+ const cpX = midX + nx * curveOffset;
17182
+ const cpY = midY + ny * curveOffset;
17183
+ const pathD = `M ${from.x} ${from.y} Q ${cpX} ${cpY} ${to.x} ${to.y}`;
17347
17184
  lineElements.push(
17348
- createElement("line", {
17349
- key: `hit-${conn.id}`,
17350
- x1: String(from.x),
17351
- y1: String(from.y),
17352
- x2: String(to.x),
17353
- y2: String(to.y),
17185
+ createElement("path", {
17186
+ key: `hit-${link.link_id}`,
17187
+ d: pathD,
17188
+ fill: "none",
17354
17189
  stroke: "transparent",
17355
17190
  "stroke-width": "12",
17356
17191
  style: { cursor: "pointer" },
17357
- onClick: () => handleLineClick(conn.id),
17358
- "data-testid": `connection-hit-${conn.id}`
17192
+ onClick: () => handleLineClick(link.link_id),
17193
+ "data-testid": `link-hit-${link.link_id}`
17359
17194
  })
17360
17195
  );
17361
17196
  lineElements.push(
17362
- createElement("line", {
17363
- key: conn.id,
17364
- x1: String(from.x),
17365
- y1: String(from.y),
17366
- x2: String(to.x),
17367
- y2: String(to.y),
17197
+ createElement("path", {
17198
+ key: link.link_id,
17199
+ d: pathD,
17200
+ fill: "none",
17368
17201
  stroke: strokeColor,
17369
17202
  "stroke-width": isSelected ? "3" : "2",
17370
- "stroke-dasharray": dashArray,
17371
17203
  "pointer-events": "none",
17372
- "data-testid": `connection-${conn.id}`
17204
+ "marker-end": `url(#${ARROW_MARKER_ID})`,
17205
+ "data-testid": `link-${link.link_id}`
17373
17206
  })
17374
17207
  );
17375
- if (conn.label) {
17376
- const midX = (from.x + to.x) / 2;
17377
- const midY = (from.y + to.y) / 2;
17208
+ if (link.link_name) {
17378
17209
  lineElements.push(
17379
17210
  createElement("text", {
17380
- key: `label-${conn.id}`,
17381
- x: String(midX),
17382
- y: String(midY - 6),
17211
+ key: `label-${link.link_id}`,
17212
+ x: String(cpX),
17213
+ y: String(cpY - 6),
17383
17214
  "text-anchor": "middle",
17384
17215
  fill: "#64748b",
17385
17216
  "font-size": "11",
17386
- "pointer-events": "none"
17387
- }, conn.label)
17217
+ "pointer-events": "none",
17218
+ "data-testid": `link-label-${link.link_id}`
17219
+ }, link.link_name)
17388
17220
  );
17389
17221
  }
17390
17222
  }
@@ -17397,77 +17229,89 @@ function ConnectionsOverlay(props) {
17397
17229
  pointerEvents: "none",
17398
17230
  overflow: "visible"
17399
17231
  };
17232
+ const markerDef = createElement(
17233
+ "defs",
17234
+ {},
17235
+ createElement(
17236
+ "marker",
17237
+ {
17238
+ id: ARROW_MARKER_ID,
17239
+ viewBox: "0 0 10 10",
17240
+ refX: "10",
17241
+ refY: "5",
17242
+ markerWidth: "8",
17243
+ markerHeight: "8",
17244
+ orient: "auto-start-reverse"
17245
+ },
17246
+ createElement("path", {
17247
+ d: "M 0 0 L 10 5 L 0 10 z",
17248
+ fill: "#94a3b8"
17249
+ })
17250
+ )
17251
+ );
17400
17252
  return createElement(
17401
17253
  "svg",
17402
17254
  {
17403
17255
  style: svgStyle,
17404
17256
  width: String(canvasWidth),
17405
17257
  height: String(canvasHeight),
17406
- className: "connections-overlay",
17407
- "data-testid": "connections-overlay",
17258
+ className: "card-link-overlay",
17259
+ "data-testid": "card-link-overlay",
17408
17260
  role: "img",
17409
- "aria-label": "Card connections"
17261
+ "aria-label": "Card links"
17410
17262
  },
17263
+ markerDef,
17411
17264
  createElement("g", { style: { pointerEvents: "auto" } }, ...lineElements)
17412
17265
  );
17413
17266
  }
17414
17267
 
17415
- // ../demos/project-manager/src/Board.ts
17268
+ // ../components/data/board/src/Board.ts
17416
17269
  var GRID_SIZE = 20;
17417
17270
  var CANVAS_SIZE = 5e3;
17418
- function screenToCanvas(screenX, screenY, viewport) {
17271
+ function snapToGrid(pos, gridSize) {
17419
17272
  return {
17420
- x: (screenX - viewport.panX) / viewport.zoom,
17421
- y: (screenY - viewport.panY) / viewport.zoom
17273
+ x: Math.round(pos.x / gridSize) * gridSize,
17274
+ y: Math.round(pos.y / gridSize) * gridSize
17422
17275
  };
17423
17276
  }
17424
- function computeFitAll(cards, containerWidth, containerHeight, padding) {
17425
- const pad3 = padding ?? 40;
17426
- if (cards.length === 0) {
17427
- return { panX: 0, panY: 0, zoom: 1 };
17428
- }
17429
- let minX = Infinity;
17430
- let minY = Infinity;
17431
- let maxX = -Infinity;
17432
- let maxY = -Infinity;
17433
- for (let i = 0; i < cards.length; i++) {
17434
- const c = cards[i];
17435
- if (c.position.x < minX) minX = c.position.x;
17436
- if (c.position.y < minY) minY = c.position.y;
17437
- const right = c.position.x + c.size.width;
17438
- const bottom = c.position.y + c.size.height;
17439
- if (right > maxX) maxX = right;
17440
- if (bottom > maxY) maxY = bottom;
17277
+ function collectCardsAndLinks(items) {
17278
+ const cards = [];
17279
+ const links = [];
17280
+ const stack = [...items];
17281
+ while (stack.length > 0) {
17282
+ const item = stack.pop();
17283
+ if (isCard(item)) {
17284
+ cards.push(item);
17285
+ for (let j = 0; j < item.card_link.length; j++) {
17286
+ links.push({ source: item, link: item.card_link[j] });
17287
+ }
17288
+ } else if (isContainer(item)) {
17289
+ for (let j = item.contents.length - 1; j >= 0; j--) {
17290
+ stack.push(item.contents[j]);
17291
+ }
17292
+ }
17441
17293
  }
17442
- const contentW = maxX - minX + pad3 * 2;
17443
- const contentH = maxY - minY + pad3 * 2;
17444
- const zoomX = containerWidth / contentW;
17445
- const zoomY = containerHeight / contentH;
17446
- const zoom = Math.max(0.25, Math.min(4, Math.min(zoomX, zoomY)));
17447
- const panX = -minX * zoom + (containerWidth - (maxX - minX) * zoom) / 2;
17448
- const panY = -minY * zoom + (containerHeight - (maxY - minY) * zoom) / 2;
17449
- return { panX, panY, zoom };
17450
- }
17451
- var connIdCounter = 0;
17452
- function generateConnectionId() {
17453
- connIdCounter++;
17454
- return `conn-${Date.now()}-${connIdCounter}`;
17294
+ return { cards, links };
17455
17295
  }
17456
17296
  function Board(props) {
17457
- const { state, dispatch, searchQuery, gridEnabled, selectedCardId, onSelectCard, colorFilter } = props;
17458
- const { cards, connections, viewport } = state;
17459
- const [editingCardId, setEditingCardId] = useState(null);
17460
- const [selectedConnectionId, setSelectedConnectionId] = useState(null);
17297
+ const {
17298
+ state,
17299
+ dispatch,
17300
+ selectedId = null,
17301
+ onSelectItem,
17302
+ gridEnabled = false,
17303
+ searchQuery = "",
17304
+ colorFilter = null,
17305
+ onOpenProject
17306
+ } = props;
17307
+ const { collection, viewport } = state;
17461
17308
  const containerRef = useRef(null);
17462
17309
  const isPanningRef = useRef(false);
17463
17310
  const panStartRef = useRef(null);
17464
- const [connectionDrag, setConnectionDrag] = useState(null);
17465
- const connectionDragRef = useRef(connectionDrag);
17466
- connectionDragRef.current = connectionDrag;
17467
17311
  const handleCanvasMouseDown = useCallback((e) => {
17468
17312
  const me = e;
17469
17313
  const target = me.target;
17470
- if (target.closest(".board-card")) return;
17314
+ if (target.closest(".board-card") || target.closest(".board-container")) return;
17471
17315
  const isMiddle = me.button === 1;
17472
17316
  const isShiftLeft = me.button === 0 && me.shiftKey;
17473
17317
  if (isMiddle || isShiftLeft) {
@@ -17480,10 +17324,9 @@ function Board(props) {
17480
17324
  panY: viewport.panY
17481
17325
  };
17482
17326
  } else if (me.button === 0) {
17483
- onSelectCard(null);
17484
- setSelectedConnectionId(null);
17327
+ if (onSelectItem) onSelectItem(null);
17485
17328
  }
17486
- }, [viewport.panX, viewport.panY, onSelectCard]);
17329
+ }, [viewport.panX, viewport.panY, onSelectItem]);
17487
17330
  useEffect(() => {
17488
17331
  const handleMouseMove = (e) => {
17489
17332
  if (!isPanningRef.current || !panStartRef.current) return;
@@ -17514,145 +17357,155 @@ function Board(props) {
17514
17357
  const delta = we.deltaY > 0 ? -0.1 : 0.1;
17515
17358
  dispatch({ type: "ZOOM", zoom: viewport.zoom + delta });
17516
17359
  }, [viewport.zoom, dispatch]);
17360
+ const touchStartRef = useRef(null);
17517
17361
  useEffect(() => {
17518
- const handleKeyDown = (e) => {
17519
- const ke = e;
17520
- if (ke.key === "Delete" || ke.key === "Backspace") {
17521
- if (selectedConnectionId) {
17522
- dispatch({ type: "REMOVE_CONNECTION", connectionId: selectedConnectionId });
17523
- setSelectedConnectionId(null);
17524
- } else if (selectedCardId) {
17525
- dispatch({ type: "REMOVE_CARD", cardId: selectedCardId });
17526
- onSelectCard(null);
17527
- }
17362
+ const container = containerRef.current;
17363
+ if (!container) return;
17364
+ const getTouchPoints = (e) => {
17365
+ const pts = [];
17366
+ for (let i = 0; i < e.touches.length; i++) {
17367
+ pts.push({ x: e.touches[i].clientX, y: e.touches[i].clientY });
17528
17368
  }
17369
+ return pts;
17529
17370
  };
17530
- document.addEventListener("keydown", handleKeyDown);
17531
- return () => document.removeEventListener("keydown", handleKeyDown);
17532
- }, [selectedConnectionId, selectedCardId, dispatch, onSelectCard]);
17533
- const handleSelectCard = useCallback((cardId) => {
17534
- onSelectCard(cardId);
17535
- setSelectedConnectionId(null);
17536
- }, [onSelectCard]);
17537
- const handleMoveCard = useCallback((cardId, position) => {
17371
+ const getDist = (a, b) => Math.sqrt((a.x - b.x) ** 2 + (a.y - b.y) ** 2);
17372
+ const handleTouchStart = (e) => {
17373
+ const te = e;
17374
+ if (te.touches.length === 2) {
17375
+ te.preventDefault();
17376
+ const pts = getTouchPoints(te);
17377
+ touchStartRef.current = {
17378
+ touches: pts,
17379
+ panX: viewport.panX,
17380
+ panY: viewport.panY,
17381
+ zoom: viewport.zoom,
17382
+ dist: getDist(pts[0], pts[1])
17383
+ };
17384
+ }
17385
+ };
17386
+ const handleTouchMove = (e) => {
17387
+ const te = e;
17388
+ if (te.touches.length !== 2 || !touchStartRef.current) return;
17389
+ te.preventDefault();
17390
+ const pts = getTouchPoints(te);
17391
+ const start = touchStartRef.current;
17392
+ const startMidX = (start.touches[0].x + start.touches[1].x) / 2;
17393
+ const startMidY = (start.touches[0].y + start.touches[1].y) / 2;
17394
+ const curMidX = (pts[0].x + pts[1].x) / 2;
17395
+ const curMidY = (pts[0].y + pts[1].y) / 2;
17396
+ dispatch({ type: "PAN", panX: start.panX + (curMidX - startMidX), panY: start.panY + (curMidY - startMidY) });
17397
+ const curDist = getDist(pts[0], pts[1]);
17398
+ if (start.dist > 0) {
17399
+ dispatch({ type: "ZOOM", zoom: start.zoom * (curDist / start.dist) });
17400
+ }
17401
+ };
17402
+ const handleTouchEnd = () => {
17403
+ touchStartRef.current = null;
17404
+ };
17405
+ container.addEventListener("touchstart", handleTouchStart, { passive: false });
17406
+ container.addEventListener("touchmove", handleTouchMove, { passive: false });
17407
+ container.addEventListener("touchend", handleTouchEnd);
17408
+ return () => {
17409
+ container.removeEventListener("touchstart", handleTouchStart);
17410
+ container.removeEventListener("touchmove", handleTouchMove);
17411
+ container.removeEventListener("touchend", handleTouchEnd);
17412
+ };
17413
+ }, [viewport.panX, viewport.panY, viewport.zoom, dispatch]);
17414
+ const handleSelectItem = useCallback((itemId) => {
17415
+ if (onSelectItem) onSelectItem(itemId);
17416
+ }, [onSelectItem]);
17417
+ const handleMoveItem = useCallback((itemId, position) => {
17538
17418
  let pos = position;
17539
17419
  if (gridEnabled) {
17540
- pos = {
17541
- x: Math.round(position.x / GRID_SIZE) * GRID_SIZE,
17542
- y: Math.round(position.y / GRID_SIZE) * GRID_SIZE
17543
- };
17420
+ pos = snapToGrid(position, GRID_SIZE);
17544
17421
  }
17545
- dispatch({ type: "MOVE_CARD", cardId, position: pos });
17422
+ dispatch({ type: "MOVE_ITEM", itemId, position: pos });
17546
17423
  }, [dispatch, gridEnabled]);
17547
- const handleResizeCard = useCallback((cardId, size) => {
17548
- dispatch({ type: "RESIZE_CARD", cardId, size });
17549
- }, [dispatch]);
17550
- const handleDeleteCard = useCallback((cardId) => {
17551
- dispatch({ type: "REMOVE_CARD", cardId });
17552
- if (selectedCardId === cardId) onSelectCard(null);
17553
- }, [dispatch, selectedCardId, onSelectCard]);
17554
- const handleDoubleClickCard = useCallback((cardId) => {
17555
- setEditingCardId(cardId);
17556
- }, []);
17557
- const handleEditorSave = useCallback((cardId, updates) => {
17558
- dispatch({ type: "UPDATE_CARD", cardId, updates });
17559
- }, [dispatch]);
17560
- const handleEditorClose = useCallback(() => {
17561
- setEditingCardId(null);
17562
- }, []);
17563
- const handleSelectConnection = useCallback((connectionId) => {
17564
- setSelectedConnectionId(connectionId);
17565
- onSelectCard(null);
17566
- }, [onSelectCard]);
17567
- const handleDeleteConnection = useCallback((connectionId) => {
17568
- dispatch({ type: "REMOVE_CONNECTION", connectionId });
17569
- setSelectedConnectionId(null);
17424
+ const handleResizeItem = useCallback((itemId, size) => {
17425
+ dispatch({ type: "RESIZE_ITEM", itemId, size });
17570
17426
  }, [dispatch]);
17571
- const handleDuplicateCard = useCallback((cardId) => {
17572
- const newId = `card-${Date.now()}-dup`;
17573
- dispatch({ type: "DUPLICATE_CARD", cardId, newId });
17427
+ const handleDeleteItem = useCallback((itemId) => {
17428
+ dispatch({ type: "REMOVE_ITEM", itemId });
17429
+ if (onSelectItem && selectedId === itemId) onSelectItem(null);
17430
+ }, [dispatch, selectedId, onSelectItem]);
17431
+ const handleDropIntoContainer = useCallback((itemId, containerId) => {
17432
+ dispatch({ type: "NEST_ITEM", itemId, containerId });
17574
17433
  }, [dispatch]);
17575
- const handleChangeColor = useCallback((cardId, color) => {
17576
- dispatch({ type: "UPDATE_CARD", cardId, updates: { color } });
17577
- }, [dispatch]);
17578
- const handleChangePriority = useCallback((cardId, priority) => {
17579
- dispatch({ type: "UPDATE_CARD", cardId, updates: { priority } });
17580
- }, [dispatch]);
17581
- const handleAnchorDragStart = useCallback((cardId, anchor, ax, ay) => {
17582
- setConnectionDrag({
17583
- fromCardId: cardId,
17584
- fromAnchor: anchor,
17585
- fromX: ax,
17586
- fromY: ay,
17587
- toX: ax,
17588
- toY: ay
17589
- });
17590
- }, []);
17591
- useEffect(() => {
17592
- if (!connectionDragRef.current) return;
17593
- const handleMouseMove = (e) => {
17594
- const me = e;
17595
- if (!connectionDragRef.current) return;
17596
- const canvasPos = screenToCanvas(me.clientX, me.clientY, viewport);
17597
- setConnectionDrag((prev) => prev ? {
17598
- ...prev,
17599
- toX: canvasPos.x,
17600
- toY: canvasPos.y
17601
- } : null);
17602
- };
17603
- const handleMouseUp = (e) => {
17604
- const me = e;
17605
- if (!connectionDragRef.current) return;
17606
- const drag = connectionDragRef.current;
17607
- const target = me.target;
17608
- const anchorEl = target.closest ? target.closest("[data-anchor]") : null;
17609
- const cardEl = target.closest ? target.closest("[data-card-id]") : null;
17610
- if (anchorEl && cardEl) {
17611
- const targetCardId = cardEl.getAttribute("data-card-id");
17612
- if (targetCardId && targetCardId !== drag.fromCardId) {
17613
- dispatch({
17614
- type: "ADD_CONNECTION",
17615
- connection: {
17616
- id: generateConnectionId(),
17617
- fromCardId: drag.fromCardId,
17618
- toCardId: targetCardId
17619
- }
17620
- });
17621
- }
17622
- }
17623
- setConnectionDrag(null);
17624
- };
17625
- document.addEventListener("mousemove", handleMouseMove);
17626
- document.addEventListener("mouseup", handleMouseUp);
17627
- return () => {
17628
- document.removeEventListener("mousemove", handleMouseMove);
17629
- document.removeEventListener("mouseup", handleMouseUp);
17630
- };
17631
- }, [connectionDrag, viewport, dispatch]);
17632
17434
  const lowerSearch = searchQuery.toLowerCase();
17633
- const filteredCards = lowerSearch ? cards.filter((c) => c.title.toLowerCase().includes(lowerSearch)) : cards;
17634
- const dimmedCardIds = /* @__PURE__ */ new Set();
17435
+ const dimmedIds = /* @__PURE__ */ new Set();
17436
+ const allItems = [];
17437
+ const itemStack = [...collection];
17438
+ while (itemStack.length > 0) {
17439
+ const item = itemStack.pop();
17440
+ allItems.push(item);
17441
+ if (isContainer(item)) {
17442
+ for (let i = 0; i < item.contents.length; i++) {
17443
+ itemStack.push(item.contents[i]);
17444
+ }
17445
+ }
17446
+ }
17635
17447
  if (lowerSearch) {
17636
- for (let i = 0; i < cards.length; i++) {
17637
- if (!cards[i].title.toLowerCase().includes(lowerSearch)) {
17638
- dimmedCardIds.add(cards[i].id);
17448
+ for (let i = 0; i < allItems.length; i++) {
17449
+ const item = allItems[i];
17450
+ const name = isCard(item) ? item.card_title : item.name;
17451
+ if (!name.toLowerCase().includes(lowerSearch)) {
17452
+ dimmedIds.add(getItemId(item));
17639
17453
  }
17640
17454
  }
17641
17455
  }
17642
17456
  if (colorFilter) {
17643
- for (let i = 0; i < cards.length; i++) {
17644
- if (cards[i].color !== colorFilter) {
17645
- dimmedCardIds.add(cards[i].id);
17646
- }
17457
+ for (let i = 0; i < allItems.length; i++) {
17458
+ const item = allItems[i];
17459
+ if (isCard(item) && item.color !== colorFilter) {
17460
+ dimmedIds.add(item.card_id);
17461
+ }
17462
+ }
17463
+ }
17464
+ const { cards: allCards, links: allLinks } = collectCardsAndLinks(collection);
17465
+ function renderItem(item) {
17466
+ const id = getItemId(item);
17467
+ const isDimmed = dimmedIds.has(id);
17468
+ let el;
17469
+ if (isCard(item)) {
17470
+ el = createElement(CardComponent, {
17471
+ key: id,
17472
+ card: item,
17473
+ selected: id === selectedId,
17474
+ onSelect: handleSelectItem,
17475
+ onMove: handleMoveItem,
17476
+ onResize: handleResizeItem,
17477
+ onDelete: handleDeleteItem,
17478
+ dispatch,
17479
+ onOpenProject
17480
+ });
17481
+ } else {
17482
+ const childElements = item.contents.map((child) => renderItem(child));
17483
+ el = createElement(ContainerComponent, {
17484
+ key: id,
17485
+ container: item,
17486
+ selected: id === selectedId,
17487
+ onSelect: handleSelectItem,
17488
+ onMove: handleMoveItem,
17489
+ onResize: handleResizeItem,
17490
+ onDrop: handleDropIntoContainer
17491
+ }, ...childElements);
17492
+ }
17493
+ if (isDimmed) {
17494
+ return createElement("div", {
17495
+ key: `dim-${id}`,
17496
+ style: { opacity: "0.3" }
17497
+ }, el);
17647
17498
  }
17499
+ return el;
17648
17500
  }
17501
+ const itemElements = collection.map((item) => renderItem(item));
17649
17502
  const containerStyle3 = {
17650
17503
  flex: "1",
17651
17504
  overflow: "hidden",
17652
17505
  position: "relative",
17653
17506
  backgroundColor: "#f8fafc",
17654
- cursor: isPanningRef.current ? "grabbing" : "default",
17655
- backgroundImage: "radial-gradient(circle, #d1d5db 1px, transparent 1px)",
17507
+ cursor: "default",
17508
+ backgroundImage: gridEnabled ? "radial-gradient(circle, #d1d5db 1px, transparent 1px)" : "none",
17656
17509
  backgroundSize: `${GRID_SIZE}px ${GRID_SIZE}px`
17657
17510
  };
17658
17511
  const transformStyle = {
@@ -17662,64 +17515,6 @@ function Board(props) {
17662
17515
  width: `${CANVAS_SIZE}px`,
17663
17516
  height: `${CANVAS_SIZE}px`
17664
17517
  };
17665
- const cardElements = cards.map((card) => {
17666
- const isDimmed = dimmedCardIds.has(card.id);
17667
- const cardEl = createElement(Card2, {
17668
- key: card.id,
17669
- card,
17670
- selected: card.id === selectedCardId,
17671
- onSelect: handleSelectCard,
17672
- onMove: handleMoveCard,
17673
- onResize: handleResizeCard,
17674
- onDelete: handleDeleteCard,
17675
- onDoubleClick: handleDoubleClickCard,
17676
- onDuplicate: handleDuplicateCard,
17677
- onChangeColor: handleChangeColor,
17678
- onChangePriority: handleChangePriority,
17679
- onAnchorDragStart: handleAnchorDragStart
17680
- });
17681
- if (isDimmed) {
17682
- return createElement("div", {
17683
- key: `dim-${card.id}`,
17684
- style: { opacity: "0.3" }
17685
- }, cardEl);
17686
- }
17687
- return cardEl;
17688
- });
17689
- const editingCard = editingCardId ? cards.find((c) => c.id === editingCardId) : null;
17690
- const editorEl = editingCard ? createElement(CardEditor, {
17691
- card: editingCard,
17692
- onSave: handleEditorSave,
17693
- onClose: handleEditorClose
17694
- }) : null;
17695
- const connectionDragLine = connectionDrag ? createElement(
17696
- "svg",
17697
- {
17698
- style: {
17699
- position: "absolute",
17700
- top: "0",
17701
- left: "0",
17702
- width: "100%",
17703
- height: "100%",
17704
- pointerEvents: "none",
17705
- overflow: "visible",
17706
- zIndex: "5"
17707
- },
17708
- width: String(CANVAS_SIZE),
17709
- height: String(CANVAS_SIZE),
17710
- "data-testid": "connection-drag-line"
17711
- },
17712
- createElement("line", {
17713
- x1: String(connectionDrag.fromX),
17714
- y1: String(connectionDrag.fromY),
17715
- x2: String(connectionDrag.toX),
17716
- y2: String(connectionDrag.toY),
17717
- stroke: "#3b82f6",
17718
- "stroke-width": "2",
17719
- "stroke-dasharray": "6,4",
17720
- "pointer-events": "none"
17721
- })
17722
- ) : null;
17723
17518
  return createElement(
17724
17519
  "div",
17725
17520
  {
@@ -17730,7 +17525,7 @@ function Board(props) {
17730
17525
  onWheel: handleWheel,
17731
17526
  "data-testid": "board-canvas",
17732
17527
  role: "application",
17733
- "aria-label": "Project board canvas",
17528
+ "aria-label": `Board: ${state.name}`,
17734
17529
  tabIndex: 0
17735
17530
  },
17736
17531
  createElement(
@@ -17740,96 +17535,497 @@ function Board(props) {
17740
17535
  style: transformStyle,
17741
17536
  "data-testid": "board-canvas-inner"
17742
17537
  },
17743
- createElement(ConnectionsOverlay, {
17744
- connections,
17745
- cards,
17746
- selectedConnectionId,
17747
- onSelectConnection: handleSelectConnection,
17748
- onDeleteConnection: handleDeleteConnection,
17538
+ createElement(CardLinkOverlay, {
17539
+ links: allLinks,
17540
+ cards: allCards,
17541
+ selectedLinkId: null,
17542
+ onSelectLink: () => {
17543
+ },
17749
17544
  canvasWidth: CANVAS_SIZE,
17750
17545
  canvasHeight: CANVAS_SIZE
17751
17546
  }),
17752
- connectionDragLine,
17753
- ...cardElements
17754
- ),
17755
- editorEl
17547
+ ...itemElements
17548
+ )
17549
+ );
17550
+ }
17551
+
17552
+ // ../demos/project-manager/src/Board.ts
17553
+ function collectAllCards(items) {
17554
+ const cards = [];
17555
+ const stack = [...items];
17556
+ while (stack.length > 0) {
17557
+ const item = stack.pop();
17558
+ if (isCard(item)) {
17559
+ cards.push(item);
17560
+ } else if (isContainer(item)) {
17561
+ for (let i = item.contents.length - 1; i >= 0; i--) {
17562
+ stack.push(item.contents[i]);
17563
+ }
17564
+ }
17565
+ }
17566
+ return cards;
17567
+ }
17568
+ function computeFitAll(collection, containerWidth, containerHeight, padding) {
17569
+ const pad3 = padding ?? 40;
17570
+ const cards = collectAllCards(collection);
17571
+ if (cards.length === 0) {
17572
+ return { panX: 0, panY: 0, zoom: 1 };
17573
+ }
17574
+ let minX = Infinity;
17575
+ let minY = Infinity;
17576
+ let maxX = -Infinity;
17577
+ let maxY = -Infinity;
17578
+ for (let i = 0; i < cards.length; i++) {
17579
+ const c = cards[i];
17580
+ if (c.position.x < minX) minX = c.position.x;
17581
+ if (c.position.y < minY) minY = c.position.y;
17582
+ const right = c.position.x + c.size.width;
17583
+ const bottom = c.position.y + c.size.height;
17584
+ if (right > maxX) maxX = right;
17585
+ if (bottom > maxY) maxY = bottom;
17586
+ }
17587
+ const contentW = maxX - minX + pad3 * 2;
17588
+ const contentH = maxY - minY + pad3 * 2;
17589
+ const zoomX = containerWidth / contentW;
17590
+ const zoomY = containerHeight / contentH;
17591
+ const zoom = Math.max(0.25, Math.min(4, Math.min(zoomX, zoomY)));
17592
+ const panX = -minX * zoom + (containerWidth - (maxX - minX) * zoom) / 2;
17593
+ const panY = -minY * zoom + (containerHeight - (maxY - minY) * zoom) / 2;
17594
+ return { panX, panY, zoom };
17595
+ }
17596
+
17597
+ // ../demos/project-manager/src/Toolbar.ts
17598
+ var CARD_COLORS = [
17599
+ "transparent",
17600
+ // no background
17601
+ "#fef9c3",
17602
+ // yellow
17603
+ "#fecaca",
17604
+ // red
17605
+ "#fed7aa",
17606
+ // orange
17607
+ "#bbf7d0",
17608
+ // green
17609
+ "#bfdbfe",
17610
+ // blue
17611
+ "#ddd6fe",
17612
+ // purple
17613
+ "#fbcfe8",
17614
+ // pink
17615
+ "#e5e7eb"
17616
+ // gray
17617
+ ];
17618
+ function BoardToolbar(props) {
17619
+ const {
17620
+ zoom,
17621
+ gridEnabled,
17622
+ selectedColor,
17623
+ colorFilter,
17624
+ onNewCard,
17625
+ onZoomIn,
17626
+ onZoomOut,
17627
+ onZoomReset,
17628
+ onColorSelect,
17629
+ onColorFilter,
17630
+ onGridToggle,
17631
+ onSearch
17632
+ } = props;
17633
+ const [searchText, setSearchText] = useState("");
17634
+ const handleSearchInput = useCallback((e) => {
17635
+ const value = e.target.value;
17636
+ setSearchText(value);
17637
+ onSearch(value);
17638
+ }, [onSearch]);
17639
+ const toolbarStyle = {
17640
+ display: "flex",
17641
+ alignItems: "center",
17642
+ gap: "8px",
17643
+ padding: "6px 12px",
17644
+ backgroundColor: "rgba(255,255,255,0.95)",
17645
+ borderBottom: "1px solid #e2e8f0",
17646
+ fontSize: "12px",
17647
+ flexShrink: "0",
17648
+ flexWrap: "wrap"
17649
+ };
17650
+ const btnStyle = {
17651
+ padding: "4px 10px",
17652
+ border: "1px solid #d1d5db",
17653
+ borderRadius: "4px",
17654
+ backgroundColor: "#ffffff",
17655
+ cursor: "pointer",
17656
+ fontSize: "12px",
17657
+ color: "#374151",
17658
+ lineHeight: "1.4"
17659
+ };
17660
+ const activeBtnStyle = {
17661
+ ...btnStyle,
17662
+ backgroundColor: "#3b82f6",
17663
+ color: "#ffffff",
17664
+ borderColor: "#3b82f6"
17665
+ };
17666
+ const zoomText = {
17667
+ fontSize: "12px",
17668
+ color: "#64748b",
17669
+ minWidth: "40px",
17670
+ textAlign: "center",
17671
+ cursor: "pointer"
17672
+ };
17673
+ const separatorStyle = {
17674
+ width: "1px",
17675
+ height: "20px",
17676
+ backgroundColor: "#e2e8f0",
17677
+ margin: "0 4px"
17678
+ };
17679
+ const inputStyle = {
17680
+ padding: "4px 8px",
17681
+ border: "1px solid #d1d5db",
17682
+ borderRadius: "4px",
17683
+ fontSize: "12px",
17684
+ width: "120px",
17685
+ outline: "none"
17686
+ };
17687
+ const swatches = CARD_COLORS.map((color) => {
17688
+ const isActive = color === selectedColor;
17689
+ const isFiltered = color === colorFilter;
17690
+ const handleSwatchClick = () => {
17691
+ if (isActive && onColorFilter) {
17692
+ onColorFilter(isFiltered ? null : color);
17693
+ } else {
17694
+ onColorSelect(color);
17695
+ }
17696
+ };
17697
+ let borderStyle = "1px solid rgba(0,0,0,0.15)";
17698
+ if (isFiltered) {
17699
+ borderStyle = "3px solid #ef4444";
17700
+ } else if (isActive) {
17701
+ borderStyle = "2px solid #3b82f6";
17702
+ }
17703
+ const isTransparent = color === "transparent";
17704
+ return createElement("button", {
17705
+ key: color,
17706
+ title: isTransparent ? "Transparent" : color,
17707
+ style: {
17708
+ width: "18px",
17709
+ height: "18px",
17710
+ 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",
17715
+ border: borderStyle,
17716
+ cursor: "pointer",
17717
+ padding: "0",
17718
+ flexShrink: "0",
17719
+ opacity: isFiltered ? "1" : colorFilter ? "0.5" : "1"
17720
+ },
17721
+ onClick: handleSwatchClick,
17722
+ "aria-label": isFiltered ? `Clear color filter ${color}` : `Select color ${color}`,
17723
+ "data-testid": `color-swatch-${color}`
17724
+ });
17725
+ });
17726
+ return createElement(
17727
+ "div",
17728
+ {
17729
+ className: "board-toolbar",
17730
+ style: toolbarStyle,
17731
+ role: "toolbar",
17732
+ "aria-label": "Board toolbar",
17733
+ "data-testid": "board-toolbar"
17734
+ },
17735
+ // New card button
17736
+ createElement("button", {
17737
+ style: btnStyle,
17738
+ onClick: onNewCard,
17739
+ "data-testid": "btn-new-card",
17740
+ "aria-label": "New card"
17741
+ }, "+ New Card"),
17742
+ createElement("div", { style: separatorStyle }),
17743
+ // Zoom controls
17744
+ createElement("button", {
17745
+ style: btnStyle,
17746
+ onClick: onZoomOut,
17747
+ "data-testid": "btn-zoom-out",
17748
+ "aria-label": "Zoom out"
17749
+ }, "-"),
17750
+ createElement("span", {
17751
+ style: zoomText,
17752
+ onClick: onZoomReset,
17753
+ "data-testid": "zoom-level",
17754
+ role: "status",
17755
+ "aria-label": `Zoom ${Math.round(zoom * 100)}%`
17756
+ }, `${Math.round(zoom * 100)}%`),
17757
+ createElement("button", {
17758
+ style: btnStyle,
17759
+ onClick: onZoomIn,
17760
+ "data-testid": "btn-zoom-in",
17761
+ "aria-label": "Zoom in"
17762
+ }, "+"),
17763
+ createElement("div", { style: separatorStyle }),
17764
+ ...swatches,
17765
+ createElement("div", { style: separatorStyle }),
17766
+ // Grid toggle
17767
+ createElement("button", {
17768
+ style: gridEnabled ? activeBtnStyle : btnStyle,
17769
+ onClick: onGridToggle,
17770
+ "data-testid": "btn-grid-toggle",
17771
+ "aria-label": gridEnabled ? "Disable grid snapping" : "Enable grid snapping",
17772
+ "aria-pressed": String(gridEnabled)
17773
+ }, "Grid"),
17774
+ createElement("div", { style: separatorStyle }),
17775
+ // Search
17776
+ createElement("input", {
17777
+ type: "text",
17778
+ placeholder: "Search cards...",
17779
+ value: searchText,
17780
+ onInput: handleSearchInput,
17781
+ style: inputStyle,
17782
+ "data-testid": "search-input",
17783
+ "aria-label": "Search cards"
17784
+ })
17756
17785
  );
17757
17786
  }
17758
-
17759
- // ../demos/project-manager/src/BoardState.ts
17760
- var MAX_HISTORY = 50;
17761
- var DEFAULT_BOARD_STATE = {
17762
- cards: [],
17763
- connections: [],
17764
- viewport: { panX: 0, panY: 0, zoom: 1 }
17765
- };
17787
+
17788
+ // ../components/data/board/src/BoardReducer.ts
17789
+ var MAX_HISTORY = 50;
17790
+ var DEFAULT_BOARD_STATE = {
17791
+ id: generateUUID(),
17792
+ name: "Untitled",
17793
+ collection: [],
17794
+ viewport: { panX: 0, panY: 0, zoom: 1 }
17795
+ };
17796
+ function removeItemFromTree(collection, itemId) {
17797
+ let removed = null;
17798
+ function process(items) {
17799
+ const result = [];
17800
+ for (let i = 0; i < items.length; i++) {
17801
+ const item = items[i];
17802
+ const id = getItemId(item);
17803
+ if (id === itemId) {
17804
+ removed = item;
17805
+ continue;
17806
+ }
17807
+ if (isContainer(item)) {
17808
+ const newContents = process(item.contents);
17809
+ result.push({ ...item, contents: newContents });
17810
+ } else {
17811
+ result.push(item);
17812
+ }
17813
+ }
17814
+ return result;
17815
+ }
17816
+ const updated = process(collection);
17817
+ return [updated, removed];
17818
+ }
17819
+ function updateItemInTree(collection, itemId, updater) {
17820
+ const result = [];
17821
+ for (let i = 0; i < collection.length; i++) {
17822
+ const item = collection[i];
17823
+ const id = getItemId(item);
17824
+ if (id === itemId) {
17825
+ result.push(updater(item));
17826
+ } else if (isContainer(item)) {
17827
+ result.push({
17828
+ ...item,
17829
+ contents: updateItemInTree(item.contents, itemId, updater)
17830
+ });
17831
+ } else {
17832
+ result.push(item);
17833
+ }
17834
+ }
17835
+ return result;
17836
+ }
17837
+ function addItemToContainer(collection, containerId, newItem) {
17838
+ const result = [];
17839
+ for (let i = 0; i < collection.length; i++) {
17840
+ const item = collection[i];
17841
+ if (isContainer(item) && item.container_id === containerId) {
17842
+ result.push({
17843
+ ...item,
17844
+ contents: [...item.contents, newItem]
17845
+ });
17846
+ } else if (isContainer(item)) {
17847
+ result.push({
17848
+ ...item,
17849
+ contents: addItemToContainer(item.contents, containerId, newItem)
17850
+ });
17851
+ } else {
17852
+ result.push(item);
17853
+ }
17854
+ }
17855
+ return result;
17856
+ }
17857
+ function removeItemFromContainer(collection, containerId, itemId) {
17858
+ let removed = null;
17859
+ function process(items) {
17860
+ const result = [];
17861
+ for (let i = 0; i < items.length; i++) {
17862
+ const item = items[i];
17863
+ if (isContainer(item) && item.container_id === containerId) {
17864
+ const newContents = [];
17865
+ for (let j = 0; j < item.contents.length; j++) {
17866
+ const child = item.contents[j];
17867
+ if (getItemId(child) === itemId) {
17868
+ removed = child;
17869
+ } else {
17870
+ newContents.push(child);
17871
+ }
17872
+ }
17873
+ result.push({ ...item, contents: newContents });
17874
+ } else if (isContainer(item)) {
17875
+ result.push({
17876
+ ...item,
17877
+ contents: process(item.contents)
17878
+ });
17879
+ } else {
17880
+ result.push(item);
17881
+ }
17882
+ }
17883
+ return result;
17884
+ }
17885
+ const updated = process(collection);
17886
+ return [updated, removed];
17887
+ }
17888
+ function getDefaultContent(cardType) {
17889
+ switch (cardType) {
17890
+ case "text":
17891
+ return { text: "" };
17892
+ case "json":
17893
+ return {};
17894
+ case "task":
17895
+ return {};
17896
+ case "project":
17897
+ return { project_id: "", project_name: "" };
17898
+ }
17899
+ }
17766
17900
  function boardReducer(state, action) {
17767
17901
  switch (action.type) {
17768
- case "ADD_CARD":
17902
+ case "ADD_ITEM": {
17903
+ if (action.containerId) {
17904
+ return {
17905
+ ...state,
17906
+ collection: addItemToContainer(state.collection, action.containerId, action.item)
17907
+ };
17908
+ }
17769
17909
  return {
17770
17910
  ...state,
17771
- cards: [...state.cards, action.card]
17911
+ collection: [...state.collection, action.item]
17772
17912
  };
17773
- case "REMOVE_CARD":
17913
+ }
17914
+ case "REMOVE_ITEM": {
17915
+ const [newCollection] = removeItemFromTree(state.collection, action.itemId);
17774
17916
  return {
17775
17917
  ...state,
17776
- cards: state.cards.filter((c) => c.id !== action.cardId),
17777
- connections: state.connections.filter(
17778
- (conn) => conn.fromCardId !== action.cardId && conn.toCardId !== action.cardId
17779
- )
17918
+ collection: newCollection
17780
17919
  };
17781
- case "MOVE_CARD":
17920
+ }
17921
+ case "MOVE_ITEM": {
17782
17922
  return {
17783
17923
  ...state,
17784
- cards: state.cards.map(
17785
- (c) => c.id === action.cardId ? { ...c, position: action.position, updatedAt: Date.now() } : c
17786
- )
17924
+ collection: updateItemInTree(state.collection, action.itemId, (item) => ({
17925
+ ...item,
17926
+ position: action.position,
17927
+ ...isCard(item) ? { updatedAt: Date.now() } : {}
17928
+ }))
17787
17929
  };
17788
- case "RESIZE_CARD":
17930
+ }
17931
+ case "RESIZE_ITEM": {
17789
17932
  return {
17790
17933
  ...state,
17791
- cards: state.cards.map(
17792
- (c) => c.id === action.cardId ? { ...c, size: action.size, updatedAt: Date.now() } : c
17793
- )
17934
+ collection: updateItemInTree(state.collection, action.itemId, (item) => ({
17935
+ ...item,
17936
+ size: action.size,
17937
+ ...isCard(item) ? { updatedAt: Date.now() } : {}
17938
+ }))
17794
17939
  };
17795
- case "UPDATE_CARD":
17940
+ }
17941
+ case "UPDATE_CARD": {
17796
17942
  return {
17797
17943
  ...state,
17798
- cards: state.cards.map(
17799
- (c) => c.id === action.cardId ? { ...c, ...action.updates, updatedAt: Date.now() } : c
17800
- )
17944
+ collection: updateItemInTree(state.collection, action.cardId, (item) => {
17945
+ if (!isCard(item)) return item;
17946
+ return { ...item, ...action.updates, updatedAt: Date.now() };
17947
+ })
17801
17948
  };
17802
- case "DUPLICATE_CARD": {
17803
- const source = state.cards.find((c) => c.id === action.cardId);
17804
- if (!source) return state;
17805
- const offset = action.offset || { x: 20, y: 20 };
17806
- const duplicate = {
17807
- ...source,
17808
- id: action.newId,
17809
- position: {
17810
- x: source.position.x + offset.x,
17811
- y: source.position.y + offset.y
17812
- },
17813
- createdAt: Date.now(),
17814
- updatedAt: Date.now()
17949
+ }
17950
+ case "CHANGE_CARD_TYPE": {
17951
+ return {
17952
+ ...state,
17953
+ collection: updateItemInTree(state.collection, action.cardId, (item) => {
17954
+ if (!isCard(item)) return item;
17955
+ return {
17956
+ ...item,
17957
+ card_type: action.newType,
17958
+ content: getDefaultContent(action.newType),
17959
+ updatedAt: Date.now()
17960
+ };
17961
+ })
17962
+ };
17963
+ }
17964
+ case "ADD_CONTAINER": {
17965
+ if (action.parentContainerId) {
17966
+ return {
17967
+ ...state,
17968
+ collection: addItemToContainer(
17969
+ state.collection,
17970
+ action.parentContainerId,
17971
+ action.container
17972
+ )
17973
+ };
17974
+ }
17975
+ return {
17976
+ ...state,
17977
+ collection: [...state.collection, action.container]
17978
+ };
17979
+ }
17980
+ case "NEST_ITEM": {
17981
+ const [withoutItem, movedItem] = removeItemFromTree(
17982
+ state.collection,
17983
+ action.itemId
17984
+ );
17985
+ if (!movedItem) return state;
17986
+ return {
17987
+ ...state,
17988
+ collection: addItemToContainer(withoutItem, action.containerId, movedItem)
17815
17989
  };
17990
+ }
17991
+ case "UNNEST_ITEM": {
17992
+ const [withoutItem, movedItem] = removeItemFromContainer(
17993
+ state.collection,
17994
+ action.containerId,
17995
+ action.itemId
17996
+ );
17997
+ if (!movedItem) return state;
17816
17998
  return {
17817
17999
  ...state,
17818
- cards: [...state.cards, duplicate]
18000
+ collection: [...withoutItem, movedItem]
17819
18001
  };
17820
18002
  }
17821
- case "ADD_CONNECTION":
18003
+ case "ADD_LINK": {
17822
18004
  return {
17823
18005
  ...state,
17824
- connections: [...state.connections, action.connection]
18006
+ collection: updateItemInTree(state.collection, action.cardId, (item) => {
18007
+ if (!isCard(item)) return item;
18008
+ return {
18009
+ ...item,
18010
+ card_link: [...item.card_link, action.link],
18011
+ updatedAt: Date.now()
18012
+ };
18013
+ })
17825
18014
  };
17826
- case "REMOVE_CONNECTION":
18015
+ }
18016
+ case "REMOVE_LINK": {
17827
18017
  return {
17828
18018
  ...state,
17829
- connections: state.connections.filter(
17830
- (conn) => conn.id !== action.connectionId
17831
- )
18019
+ collection: updateItemInTree(state.collection, action.cardId, (item) => {
18020
+ if (!isCard(item)) return item;
18021
+ return {
18022
+ ...item,
18023
+ card_link: item.card_link.filter((l) => l.link_id !== action.linkId),
18024
+ updatedAt: Date.now()
18025
+ };
18026
+ })
17832
18027
  };
18028
+ }
17833
18029
  case "PAN":
17834
18030
  return {
17835
18031
  ...state,
@@ -17844,6 +18040,8 @@ function boardReducer(state, action) {
17844
18040
  }
17845
18041
  case "SET_BOARD":
17846
18042
  return action.state;
18043
+ case "RENAME_BOARD":
18044
+ return { ...state, name: action.name };
17847
18045
  default:
17848
18046
  return state;
17849
18047
  }
@@ -17896,10 +18094,10 @@ function historyReducer(state, action) {
17896
18094
  return state;
17897
18095
  }
17898
18096
  }
17899
- function useBoardState(storage2, boardId) {
18097
+ function useBoardReducer(initialState) {
17900
18098
  const initialHistory = {
17901
18099
  past: [],
17902
- present: DEFAULT_BOARD_STATE,
18100
+ present: initialState || DEFAULT_BOARD_STATE,
17903
18101
  future: []
17904
18102
  };
17905
18103
  const [history, historyDispatch] = useReducer(historyReducer, initialHistory);
@@ -17912,6 +18110,19 @@ function useBoardState(storage2, boardId) {
17912
18110
  const redo = useCallback(() => {
17913
18111
  historyDispatch({ type: "REDO" });
17914
18112
  }, [historyDispatch]);
18113
+ return {
18114
+ state: history.present,
18115
+ dispatch,
18116
+ undo,
18117
+ redo,
18118
+ canUndo: history.past.length > 0,
18119
+ canRedo: history.future.length > 0
18120
+ };
18121
+ }
18122
+
18123
+ // ../demos/project-manager/src/BoardState.ts
18124
+ function useBoardState(storage2, boardId) {
18125
+ const { state, dispatch, undo, redo, canUndo, canRedo } = useBoardReducer();
17915
18126
  const loadedRef = useRef(false);
17916
18127
  useEffect(() => {
17917
18128
  if (storage2 && boardId && !loadedRef.current) {
@@ -17923,8 +18134,8 @@ function useBoardState(storage2, boardId) {
17923
18134
  }
17924
18135
  }, [storage2, boardId, dispatch]);
17925
18136
  const saveTimerRef = useRef(null);
17926
- const stateRef = useRef(history.present);
17927
- stateRef.current = history.present;
18137
+ const stateRef = useRef(state);
18138
+ stateRef.current = state;
17928
18139
  useEffect(() => {
17929
18140
  if (!storage2 || !boardId) return;
17930
18141
  if (saveTimerRef.current !== null) {
@@ -17940,32 +18151,27 @@ function useBoardState(storage2, boardId) {
17940
18151
  clearTimeout(saveTimerRef.current);
17941
18152
  }
17942
18153
  };
17943
- }, [storage2, boardId, history.present]);
18154
+ }, [storage2, boardId, state]);
17944
18155
  return {
17945
- state: history.present,
18156
+ state,
17946
18157
  dispatch,
17947
18158
  undo,
17948
18159
  redo,
17949
- canUndo: history.past.length > 0,
17950
- canRedo: history.future.length > 0
18160
+ canUndo,
18161
+ canRedo
17951
18162
  };
17952
18163
  }
17953
18164
 
17954
18165
  // ../demos/project-manager/src/LocalStorage.ts
17955
- var DEFAULT_STATE = {
17956
- cards: [],
17957
- connections: [],
17958
- viewport: { panX: 0, panY: 0, zoom: 1 }
17959
- };
17960
18166
  var LocalBoardStorage = class {
17961
18167
  async load(boardId) {
17962
18168
  try {
17963
18169
  const raw = localStorage.getItem("board:" + boardId);
17964
- if (!raw) return DEFAULT_STATE;
18170
+ if (!raw) return { ...DEFAULT_BOARD_STATE };
17965
18171
  const parsed = JSON.parse(raw);
17966
18172
  return parsed;
17967
18173
  } catch {
17968
- return DEFAULT_STATE;
18174
+ return { ...DEFAULT_BOARD_STATE };
17969
18175
  }
17970
18176
  }
17971
18177
  async save(boardId, state) {
@@ -17977,34 +18183,50 @@ var LocalBoardStorage = class {
17977
18183
  };
17978
18184
 
17979
18185
  // ../demos/project-manager/src/InterApp.ts
18186
+ function collectCards(items) {
18187
+ const cards = [];
18188
+ const stack = [...items];
18189
+ while (stack.length > 0) {
18190
+ const item = stack.pop();
18191
+ if (isCard(item)) {
18192
+ cards.push(item);
18193
+ } else {
18194
+ for (let i = item.contents.length - 1; i >= 0; i--) {
18195
+ stack.push(item.contents[i]);
18196
+ }
18197
+ }
18198
+ }
18199
+ return cards;
18200
+ }
17980
18201
  function InterAppWrapper(props) {
17981
- const { cards, onCardDropped, children } = props;
18202
+ const { collection, onCardDropped, children } = props;
17982
18203
  const messageBus = useMessageBus();
17983
18204
  const prevCardsRef = useRef([]);
17984
18205
  useEffect(() => {
18206
+ const cards = collectCards(collection);
17985
18207
  const prevCards = prevCardsRef.current;
17986
- const prevIds = new Set(prevCards.map((c) => c.id));
17987
- const currIds = new Set(cards.map((c) => c.id));
18208
+ const prevIds = new Set(prevCards.map((c) => c.card_id));
18209
+ const currIds = new Set(cards.map((c) => c.card_id));
17988
18210
  for (const card of cards) {
17989
- if (!prevIds.has(card.id)) {
18211
+ if (!prevIds.has(card.card_id)) {
17990
18212
  messageBus.publish("project-board", { event: "card-created", card });
17991
18213
  }
17992
18214
  }
17993
18215
  for (const card of prevCards) {
17994
- if (!currIds.has(card.id)) {
17995
- messageBus.publish("project-board", { event: "card-deleted", cardId: card.id });
18216
+ if (!currIds.has(card.card_id)) {
18217
+ messageBus.publish("project-board", { event: "card-deleted", cardId: card.card_id });
17996
18218
  }
17997
18219
  }
17998
18220
  for (const card of cards) {
17999
- if (prevIds.has(card.id)) {
18000
- const prev = prevCards.find((c) => c.id === card.id);
18221
+ if (prevIds.has(card.card_id)) {
18222
+ const prev = prevCards.find((c) => c.card_id === card.card_id);
18001
18223
  if (prev && prev.updatedAt !== card.updatedAt) {
18002
18224
  messageBus.publish("project-board", { event: "card-updated", card });
18003
18225
  }
18004
18226
  }
18005
18227
  }
18006
18228
  prevCardsRef.current = cards;
18007
- }, [cards, messageBus]);
18229
+ }, [collection, messageBus]);
18008
18230
  const handleDrop = useCallback(
18009
18231
  (payload) => {
18010
18232
  if (payload.type === "text/plain" && typeof payload.data === "string") {
@@ -18035,27 +18257,93 @@ function InterAppWrapper(props) {
18035
18257
  }
18036
18258
 
18037
18259
  // ../demos/project-manager/src/index.ts
18038
- var cardIdCounter = 0;
18039
- function generateCardId() {
18040
- cardIdCounter++;
18041
- return `card-${Date.now()}-${cardIdCounter}`;
18042
- }
18043
18260
  var storage = new LocalBoardStorage();
18044
- var SAMPLE_CARDS = [
18045
- { id: "sample-1", title: "Auth API", description: "Design the auth flow", color: "#3b82f6", position: { x: 50, y: 50 }, size: { width: 180, height: 120 }, priority: "high", createdAt: Date.now(), updatedAt: Date.now() },
18046
- { id: "sample-2", title: "Dashboard", description: "Build the main dashboard", color: "#22c55e", position: { x: 300, y: 80 }, size: { width: 180, height: 120 }, priority: "medium", createdAt: Date.now(), updatedAt: Date.now() },
18047
- { id: "sample-3", title: "Deploy", description: "Set up CI pipeline", color: "#f59e0b", position: { x: 150, y: 250 }, size: { width: 180, height: 120 }, priority: "low", createdAt: Date.now(), updatedAt: Date.now() },
18048
- { id: "sample-4", title: "Docs", description: "Write API reference", color: "#a855f7", position: { x: 400, y: 280 }, size: { width: 180, height: 120 }, priority: "medium", createdAt: Date.now(), updatedAt: Date.now() }
18049
- ];
18261
+ function collectAllCards2(items) {
18262
+ const cards = [];
18263
+ const stack = [...items];
18264
+ while (stack.length > 0) {
18265
+ const item = stack.pop();
18266
+ if (isCard(item)) {
18267
+ cards.push(item);
18268
+ } else if (isContainer(item)) {
18269
+ for (let i = item.contents.length - 1; i >= 0; i--) {
18270
+ stack.push(item.contents[i]);
18271
+ }
18272
+ }
18273
+ }
18274
+ return cards;
18275
+ }
18276
+ var now = Date.now();
18050
18277
  var SAMPLE_BOARD = {
18051
- cards: SAMPLE_CARDS,
18052
- connections: [
18053
- { id: "sample-conn-1", fromCardId: "sample-1", toCardId: "sample-2" }
18278
+ id: "sample-board-001",
18279
+ name: "Sample Project",
18280
+ collection: [
18281
+ {
18282
+ type: "card",
18283
+ card_id: "sample-1",
18284
+ card_type: "text",
18285
+ card_title: "Auth API",
18286
+ card_link: [
18287
+ { link_id: "link-1", link_name: "blocks", target_card_id: "sample-2", color: "#94a3b8", attributes: {} }
18288
+ ],
18289
+ content: { text: "Design the auth flow" },
18290
+ position: { x: 50, y: 50 },
18291
+ size: { width: 180, height: 120 },
18292
+ color: "#3b82f6",
18293
+ priority: "high",
18294
+ assignee: "Alice",
18295
+ createdAt: now,
18296
+ updatedAt: now
18297
+ },
18298
+ {
18299
+ type: "card",
18300
+ card_id: "sample-2",
18301
+ card_type: "text",
18302
+ card_title: "Dashboard",
18303
+ card_link: [],
18304
+ content: { text: "Build the main dashboard" },
18305
+ position: { x: 300, y: 80 },
18306
+ size: { width: 180, height: 120 },
18307
+ color: "#22c55e",
18308
+ priority: "medium",
18309
+ assignee: "Bob",
18310
+ createdAt: now,
18311
+ updatedAt: now
18312
+ },
18313
+ {
18314
+ type: "card",
18315
+ card_id: "sample-3",
18316
+ card_type: "text",
18317
+ card_title: "Deploy",
18318
+ card_link: [],
18319
+ content: { text: "Set up CI pipeline" },
18320
+ position: { x: 150, y: 250 },
18321
+ size: { width: 180, height: 120 },
18322
+ color: "#f59e0b",
18323
+ priority: "low",
18324
+ createdAt: now,
18325
+ updatedAt: now
18326
+ },
18327
+ {
18328
+ type: "card",
18329
+ card_id: "sample-4",
18330
+ card_type: "text",
18331
+ card_title: "Docs",
18332
+ card_link: [],
18333
+ content: { text: "Write API reference" },
18334
+ position: { x: 400, y: 280 },
18335
+ size: { width: 180, height: 120 },
18336
+ color: "#a855f7",
18337
+ priority: "medium",
18338
+ assignee: "Carol",
18339
+ createdAt: now,
18340
+ updatedAt: now
18341
+ }
18054
18342
  ],
18055
18343
  viewport: { panX: 0, panY: 0, zoom: 1 }
18056
18344
  };
18057
18345
  function isBoardEmpty(state) {
18058
- return state.cards.length === 0 && state.connections.length === 0;
18346
+ return state.collection.length === 0;
18059
18347
  }
18060
18348
  function ProjectManagerApp(props) {
18061
18349
  const boardId = props.boardId || "default";
@@ -18065,30 +18353,38 @@ function ProjectManagerApp(props) {
18065
18353
  const [searchQuery, setSearchQuery] = useState("");
18066
18354
  const [selectedCardId, setSelectedCardId] = useState(null);
18067
18355
  const [colorFilter, setColorFilter] = useState(null);
18356
+ const [projectName, setProjectName] = useState(state.name || "Untitled");
18357
+ const [showRenameDialog, setShowRenameDialog] = useState(false);
18358
+ const [renameDraft, setRenameDraft] = useState("");
18068
18359
  const sampleLoadedRef = useRef(false);
18069
18360
  useEffect(() => {
18070
18361
  if (!sampleLoadedRef.current && isBoardEmpty(state)) {
18071
18362
  sampleLoadedRef.current = true;
18072
18363
  dispatch({ type: "SET_BOARD", state: SAMPLE_BOARD });
18073
- } else if (state.cards.length > 0) {
18364
+ } else if (state.collection.length > 0) {
18074
18365
  sampleLoadedRef.current = true;
18075
18366
  }
18076
18367
  }, [state, dispatch]);
18077
18368
  const handleNewCard = useCallback(() => {
18078
18369
  const cx = (-state.viewport.panX + 300) / state.viewport.zoom;
18079
18370
  const cy = (-state.viewport.panY + 200) / state.viewport.zoom;
18371
+ const offsetX = (Math.random() - 0.5) * 300;
18372
+ const offsetY = (Math.random() - 0.5) * 200;
18080
18373
  const newCard = {
18081
- id: generateCardId(),
18082
- title: "New Card",
18083
- description: "",
18374
+ type: "card",
18375
+ card_id: generateUUID(),
18376
+ card_type: "text",
18377
+ card_title: "New Card",
18378
+ card_link: [],
18379
+ content: { text: "" },
18084
18380
  color: selectedColor,
18085
- position: { x: Math.round(cx), y: Math.round(cy) },
18381
+ position: { x: Math.round(cx + offsetX), y: Math.round(cy + offsetY) },
18086
18382
  size: { width: 180, height: 120 },
18087
18383
  priority: "medium",
18088
18384
  createdAt: Date.now(),
18089
18385
  updatedAt: Date.now()
18090
18386
  };
18091
- dispatch({ type: "ADD_CARD", card: newCard });
18387
+ dispatch({ type: "ADD_ITEM", item: newCard });
18092
18388
  }, [state.viewport, selectedColor, dispatch]);
18093
18389
  const handleZoomIn = useCallback(() => {
18094
18390
  dispatch({ type: "ZOOM", zoom: state.viewport.zoom + 0.1 });
@@ -18128,32 +18424,69 @@ function ProjectManagerApp(props) {
18128
18424
  document.body.removeChild(a);
18129
18425
  URL.revokeObjectURL(url);
18130
18426
  }, [state, boardId]);
18427
+ const handleImportJSON = useCallback(() => {
18428
+ const input = document.createElement("input");
18429
+ input.type = "file";
18430
+ input.accept = ".json,application/json";
18431
+ input.style.display = "none";
18432
+ input.addEventListener("change", () => {
18433
+ const file = input.files && input.files[0];
18434
+ if (!file) return;
18435
+ const reader = new FileReader();
18436
+ reader.onload = () => {
18437
+ try {
18438
+ const parsed = JSON.parse(reader.result);
18439
+ if (parsed && parsed.collection && parsed.viewport) {
18440
+ dispatch({ type: "SET_BOARD", state: parsed });
18441
+ }
18442
+ } catch (_e) {
18443
+ }
18444
+ };
18445
+ reader.readAsText(file);
18446
+ });
18447
+ document.body.appendChild(input);
18448
+ input.click();
18449
+ document.body.removeChild(input);
18450
+ }, [dispatch]);
18451
+ const handlePrint = useCallback(() => {
18452
+ window.print();
18453
+ }, []);
18454
+ const allCards = collectAllCards2(state.collection);
18455
+ const handleSelectAll = useCallback(() => {
18456
+ const cards = collectAllCards2(state.collection);
18457
+ if (cards.length > 0) {
18458
+ setSelectedCardId(cards[0].card_id);
18459
+ }
18460
+ }, [state.collection]);
18131
18461
  const handleDeleteSelected = useCallback(() => {
18132
18462
  if (selectedCardId) {
18133
- dispatch({ type: "REMOVE_CARD", cardId: selectedCardId });
18463
+ dispatch({ type: "REMOVE_ITEM", itemId: selectedCardId });
18134
18464
  setSelectedCardId(null);
18135
18465
  }
18136
18466
  }, [selectedCardId, dispatch]);
18137
18467
  const handleFitAll = useCallback(() => {
18138
- if (state.cards.length === 0) return;
18468
+ if (state.collection.length === 0) return;
18139
18469
  const containerWidth = 800;
18140
18470
  const containerHeight = 600;
18141
- const fit = computeFitAll(state.cards, containerWidth, containerHeight);
18471
+ const fit = computeFitAll(state.collection, containerWidth, containerHeight);
18142
18472
  dispatch({ type: "PAN", panX: fit.panX, panY: fit.panY });
18143
18473
  dispatch({ type: "ZOOM", zoom: fit.zoom });
18144
- }, [state.cards, dispatch]);
18474
+ }, [state.collection, dispatch]);
18145
18475
  useEffect(() => {
18146
18476
  const _menuBar = {
18147
18477
  menus: [
18148
18478
  { label: "File", items: [
18149
18479
  { label: "New Board", onClick: handleNewBoard },
18150
18480
  { label: "Export JSON", onClick: handleExportJSON },
18151
- { divider: true }
18481
+ { label: "Import JSON", onClick: handleImportJSON },
18482
+ { divider: true },
18483
+ { label: "Print", onClick: handlePrint }
18152
18484
  ] },
18153
18485
  { label: "Edit", items: [
18154
18486
  { label: "Undo", shortcut: "Ctrl+Z", onClick: undo, disabled: !canUndo },
18155
18487
  { label: "Redo", shortcut: "Ctrl+Y", onClick: redo, disabled: !canRedo },
18156
18488
  { divider: true },
18489
+ { label: "Select All", shortcut: "Ctrl+A", onClick: handleSelectAll },
18157
18490
  { label: "Delete Selected", onClick: handleDeleteSelected }
18158
18491
  ] },
18159
18492
  { label: "View", items: [
@@ -18165,7 +18498,7 @@ function ProjectManagerApp(props) {
18165
18498
  ] }
18166
18499
  ]
18167
18500
  };
18168
- }, [handleNewBoard, handleExportJSON, undo, redo, canUndo, canRedo, handleDeleteSelected, handleZoomIn, handleZoomOut, handleFitAll, handleGridToggle]);
18501
+ }, [handleNewBoard, handleExportJSON, handleImportJSON, handlePrint, undo, redo, canUndo, canRedo, handleSelectAll, handleDeleteSelected, handleZoomIn, handleZoomOut, handleFitAll, handleGridToggle]);
18169
18502
  useEffect(() => {
18170
18503
  const handleKeyDown = (e) => {
18171
18504
  const ke = e;
@@ -18180,6 +18513,35 @@ function ProjectManagerApp(props) {
18180
18513
  document.addEventListener("keydown", handleKeyDown);
18181
18514
  return () => document.removeEventListener("keydown", handleKeyDown);
18182
18515
  }, [undo, redo]);
18516
+ const handleRenameProject = useCallback(() => {
18517
+ setRenameDraft(projectName);
18518
+ setShowRenameDialog(true);
18519
+ }, [projectName]);
18520
+ const handleRenameConfirm = useCallback(() => {
18521
+ const name = renameDraft.trim();
18522
+ if (name) {
18523
+ setProjectName(name);
18524
+ dispatch({ type: "RENAME_BOARD", name });
18525
+ }
18526
+ setShowRenameDialog(false);
18527
+ }, [renameDraft, dispatch]);
18528
+ const handleRenameCancel = useCallback(() => {
18529
+ setShowRenameDialog(false);
18530
+ }, []);
18531
+ const handleRenameDraftChange = useCallback((e) => {
18532
+ setRenameDraft(e.target.value);
18533
+ }, []);
18534
+ const handleRenameKeyDown = useCallback((e) => {
18535
+ const ke = e;
18536
+ if (ke.key === "Enter") {
18537
+ ke.preventDefault();
18538
+ handleRenameConfirm();
18539
+ }
18540
+ if (ke.key === "Escape") {
18541
+ ke.preventDefault();
18542
+ handleRenameCancel();
18543
+ }
18544
+ }, [handleRenameConfirm, handleRenameCancel]);
18183
18545
  const containerStyle3 = {
18184
18546
  display: "flex",
18185
18547
  flexDirection: "column",
@@ -18191,19 +18553,151 @@ function ProjectManagerApp(props) {
18191
18553
  const handleCardDropped = useCallback((title, description) => {
18192
18554
  const cx = (-state.viewport.panX + 300) / state.viewport.zoom;
18193
18555
  const cy = (-state.viewport.panY + 200) / state.viewport.zoom;
18556
+ const offsetX = (Math.random() - 0.5) * 300;
18557
+ const offsetY = (Math.random() - 0.5) * 200;
18194
18558
  const newCard = {
18195
- id: generateCardId(),
18196
- title,
18197
- description,
18559
+ type: "card",
18560
+ card_id: generateUUID(),
18561
+ card_type: "text",
18562
+ card_title: title,
18563
+ card_link: [],
18564
+ content: { text: description },
18198
18565
  color: selectedColor,
18199
- position: { x: Math.round(cx), y: Math.round(cy) },
18566
+ position: { x: Math.round(cx + offsetX), y: Math.round(cy + offsetY) },
18200
18567
  size: { width: 180, height: 120 },
18201
18568
  priority: "medium",
18202
18569
  createdAt: Date.now(),
18203
18570
  updatedAt: Date.now()
18204
18571
  };
18205
- dispatch({ type: "ADD_CARD", card: newCard });
18572
+ dispatch({ type: "ADD_ITEM", item: newCard });
18206
18573
  }, [state.viewport, selectedColor, dispatch]);
18574
+ const menuBarStyle = {
18575
+ display: "flex",
18576
+ alignItems: "center",
18577
+ height: "28px",
18578
+ backgroundColor: "#f1f5f9",
18579
+ borderBottom: "1px solid #e2e8f0",
18580
+ padding: "0 8px",
18581
+ fontSize: "13px",
18582
+ flexShrink: "0"
18583
+ };
18584
+ const menuBtnStyle = {
18585
+ padding: "2px 10px",
18586
+ border: "none",
18587
+ backgroundColor: "transparent",
18588
+ cursor: "pointer",
18589
+ fontSize: "13px",
18590
+ color: "#334155",
18591
+ borderRadius: "4px",
18592
+ fontFamily: "inherit"
18593
+ };
18594
+ const appMenuBar = createElement(
18595
+ "div",
18596
+ {
18597
+ style: menuBarStyle,
18598
+ "data-testid": "app-menu-bar"
18599
+ },
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"),
18613
+ createElement("span", {
18614
+ style: { marginLeft: "auto", fontSize: "12px", color: "#94a3b8" }
18615
+ }, `Project Board: ${projectName}`)
18616
+ );
18617
+ const renameDialogEl = showRenameDialog ? createElement(
18618
+ "div",
18619
+ {
18620
+ style: {
18621
+ position: "absolute",
18622
+ inset: "0",
18623
+ backgroundColor: "rgba(0,0,0,0.3)",
18624
+ display: "flex",
18625
+ alignItems: "center",
18626
+ justifyContent: "center",
18627
+ zIndex: "200"
18628
+ },
18629
+ onClick: handleRenameCancel
18630
+ },
18631
+ createElement(
18632
+ "div",
18633
+ {
18634
+ style: {
18635
+ backgroundColor: "#ffffff",
18636
+ borderRadius: "8px",
18637
+ padding: "20px",
18638
+ boxShadow: "0 8px 24px rgba(0,0,0,0.2)",
18639
+ minWidth: "300px"
18640
+ },
18641
+ onClick: (e) => e.stopPropagation(),
18642
+ role: "dialog",
18643
+ "aria-label": "Rename project"
18644
+ },
18645
+ createElement("div", {
18646
+ style: { fontWeight: "600", fontSize: "14px", marginBottom: "12px", color: "#1a1a1a" }
18647
+ }, "Rename Project"),
18648
+ createElement("input", {
18649
+ type: "text",
18650
+ value: renameDraft,
18651
+ onInput: handleRenameDraftChange,
18652
+ onKeyDown: handleRenameKeyDown,
18653
+ autoFocus: true,
18654
+ style: {
18655
+ width: "100%",
18656
+ padding: "8px 10px",
18657
+ border: "1px solid #d1d5db",
18658
+ borderRadius: "6px",
18659
+ fontSize: "14px",
18660
+ boxSizing: "border-box",
18661
+ outline: "none",
18662
+ fontFamily: "inherit"
18663
+ },
18664
+ "data-testid": "rename-input"
18665
+ }),
18666
+ createElement(
18667
+ "div",
18668
+ {
18669
+ style: { display: "flex", justifyContent: "flex-end", gap: "8px", marginTop: "12px" }
18670
+ },
18671
+ createElement("button", {
18672
+ onClick: handleRenameCancel,
18673
+ style: {
18674
+ padding: "6px 14px",
18675
+ border: "1px solid #d1d5db",
18676
+ borderRadius: "6px",
18677
+ backgroundColor: "#ffffff",
18678
+ cursor: "pointer",
18679
+ fontSize: "13px",
18680
+ fontFamily: "inherit"
18681
+ }
18682
+ }, "Cancel"),
18683
+ createElement("button", {
18684
+ onClick: handleRenameConfirm,
18685
+ style: {
18686
+ padding: "6px 14px",
18687
+ border: "none",
18688
+ borderRadius: "6px",
18689
+ backgroundColor: "#3b82f6",
18690
+ color: "#ffffff",
18691
+ cursor: "pointer",
18692
+ fontSize: "13px",
18693
+ fontWeight: "600",
18694
+ fontFamily: "inherit"
18695
+ },
18696
+ "data-testid": "rename-confirm"
18697
+ }, "Rename")
18698
+ )
18699
+ )
18700
+ ) : null;
18207
18701
  return createElement(
18208
18702
  "div",
18209
18703
  {
@@ -18211,6 +18705,7 @@ function ProjectManagerApp(props) {
18211
18705
  style: containerStyle3,
18212
18706
  "data-testid": "project-manager-app"
18213
18707
  },
18708
+ appMenuBar,
18214
18709
  createElement(BoardToolbar, {
18215
18710
  zoom: state.viewport.zoom,
18216
18711
  gridEnabled,
@@ -18228,7 +18723,7 @@ function ProjectManagerApp(props) {
18228
18723
  createElement(
18229
18724
  InterAppWrapper,
18230
18725
  {
18231
- cards: state.cards,
18726
+ collection: state.collection,
18232
18727
  onCardDropped: handleCardDropped
18233
18728
  },
18234
18729
  createElement(Board, {
@@ -18236,17 +18731,26 @@ function ProjectManagerApp(props) {
18236
18731
  dispatch,
18237
18732
  searchQuery,
18238
18733
  gridEnabled,
18239
- selectedCardId,
18240
- onSelectCard: handleSelectCard,
18734
+ selectedId: selectedCardId,
18735
+ onSelectItem: handleSelectCard,
18241
18736
  colorFilter
18242
18737
  })
18243
- )
18738
+ ),
18739
+ renameDialogEl
18244
18740
  );
18245
18741
  }
18246
18742
 
18247
18743
  // ../components/page/unity-desktop/src/UnityDesktop.ts
18248
18744
  var PANEL_HEIGHT = 28;
18249
18745
  var TOAST_TIMEOUT = 5e3;
18746
+ var instanceCounter = 0;
18747
+ function nextInstanceId(appId) {
18748
+ instanceCounter++;
18749
+ return `${appId}-${instanceCounter}`;
18750
+ }
18751
+ function baseLabel(title) {
18752
+ return title.replace(/\s*\(\d+\)$/, "");
18753
+ }
18250
18754
  function ToastContainer2(props) {
18251
18755
  const { toasts, onDismiss } = props;
18252
18756
  if (toasts.length === 0) return null;
@@ -18401,7 +18905,8 @@ function getMockContent(title) {
18401
18905
  height: "100%",
18402
18906
  overflow: "auto"
18403
18907
  };
18404
- switch (title) {
18908
+ const baseName = baseLabel(title);
18909
+ switch (baseName) {
18405
18910
  case "Files":
18406
18911
  return createElement(
18407
18912
  AppContextProvider,
@@ -18460,6 +18965,8 @@ function UnityDesktopInner(props) {
18460
18965
  const wm = useWindowManager();
18461
18966
  const wmActiveMenuBar = wm.activeMenuBar;
18462
18967
  const wmDockSignals = wm.dockSignals;
18968
+ const wmRef = useRef(wm);
18969
+ wmRef.current = wm;
18463
18970
  const [openWindows, setOpenWindows] = useState([]);
18464
18971
  const [toasts, setToasts] = useState([]);
18465
18972
  const [showAppsGrid, setShowAppsGrid] = useState(false);
@@ -18487,20 +18994,20 @@ function UnityDesktopInner(props) {
18487
18994
  appsRef.current = apps;
18488
18995
  const onAppOpenRef = useRef(onAppOpen);
18489
18996
  onAppOpenRef.current = onAppOpen;
18490
- const handleDockItemClick = useCallback((id) => {
18997
+ const openNewInstance = useCallback((appId) => {
18998
+ const currentApps = appsRef.current;
18999
+ const app = currentApps.find((a) => a.id === appId);
19000
+ if (!app) return;
18491
19001
  setOpenWindows((prev) => {
18492
- const existing = prev.find((w) => w.id === id);
18493
- if (existing) {
18494
- const maxZ2 = Math.max(...prev.map((w) => w.zIndex)) + 1;
18495
- return prev.map((w) => w.id === id ? { ...w, focused: true, zIndex: maxZ2, windowState: w.windowState === "minimized" ? "normal" : w.windowState } : { ...w, focused: false });
18496
- }
18497
- const currentApps = appsRef.current;
18498
- const app = currentApps.find((a) => a.id === id);
18499
- if (!app) return prev;
19002
+ const existingCount = prev.filter((w) => w.appId === appId).length;
19003
+ const instanceNum = existingCount + 1;
19004
+ const title = instanceNum === 1 ? app.label : `${app.label} (${instanceNum})`;
19005
+ const winId = nextInstanceId(appId);
18500
19006
  const maxZ = prev.length > 0 ? Math.max(...prev.map((w) => w.zIndex)) + 1 : 1;
18501
19007
  const newWin = {
18502
- id: app.id,
18503
- title: app.label,
19008
+ id: winId,
19009
+ appId: app.id,
19010
+ title,
18504
19011
  icon: app.icon,
18505
19012
  x: 60 + prev.length * 30,
18506
19013
  y: 40 + prev.length * 30,
@@ -18512,8 +19019,8 @@ function UnityDesktopInner(props) {
18512
19019
  };
18513
19020
  return [...prev.map((w) => ({ ...w, focused: false })), newWin];
18514
19021
  });
18515
- if (id === "files") {
18516
- wm.setMenuBar("files", {
19022
+ if (appId === "files") {
19023
+ wmRef.current.setMenuBar("files", {
18517
19024
  menus: [
18518
19025
  {
18519
19026
  label: "File",
@@ -18540,13 +19047,90 @@ function UnityDesktopInner(props) {
18540
19047
  ]
18541
19048
  });
18542
19049
  }
18543
- if (id === "terminal") {
18544
- wm.signalDock("terminal", { badge: 3 });
19050
+ if (appId === "terminal") {
19051
+ wmRef.current.signalDock("terminal", { badge: 3 });
18545
19052
  }
18546
- if (onAppOpenRef.current) onAppOpenRef.current(id);
18547
- }, [wm]);
19053
+ if (onAppOpenRef.current) onAppOpenRef.current(appId);
19054
+ }, []);
19055
+ const focusInstance = useCallback((winId) => {
19056
+ setOpenWindows((prev) => {
19057
+ const target = prev.find((w) => w.id === winId);
19058
+ if (!target) return prev;
19059
+ const maxZ = Math.max(...prev.map((w) => w.zIndex)) + 1;
19060
+ return prev.map((w) => w.id === winId ? { ...w, focused: true, zIndex: maxZ, windowState: w.windowState === "minimized" ? "normal" : w.windowState } : { ...w, focused: false });
19061
+ });
19062
+ }, []);
19063
+ const handleDockItemClick = useCallback((appId) => {
19064
+ setOpenWindows((prev) => {
19065
+ const instances = prev.filter((w) => w.appId === appId);
19066
+ if (instances.length === 0) {
19067
+ return prev;
19068
+ }
19069
+ const sorted = [...instances].sort((a, b) => b.zIndex - a.zIndex);
19070
+ const target = sorted[0];
19071
+ const maxZ = Math.max(...prev.map((w) => w.zIndex)) + 1;
19072
+ return prev.map((w) => w.id === target.id ? { ...w, focused: true, zIndex: maxZ, windowState: w.windowState === "minimized" ? "normal" : w.windowState } : { ...w, focused: false });
19073
+ });
19074
+ setOpenWindows((prev) => {
19075
+ const instances = prev.filter((w) => w.appId === appId);
19076
+ if (instances.length === 0) {
19077
+ const currentApps = appsRef.current;
19078
+ const app = currentApps.find((a) => a.id === appId);
19079
+ if (!app) return prev;
19080
+ const winId = nextInstanceId(appId);
19081
+ const maxZ = prev.length > 0 ? Math.max(...prev.map((w) => w.zIndex)) + 1 : 1;
19082
+ const newWin = {
19083
+ id: winId,
19084
+ appId: app.id,
19085
+ title: app.label,
19086
+ icon: app.icon,
19087
+ x: 60 + prev.length * 30,
19088
+ y: 40 + prev.length * 30,
19089
+ width: 600,
19090
+ height: 400,
19091
+ zIndex: maxZ,
19092
+ focused: true,
19093
+ windowState: "normal"
19094
+ };
19095
+ if (appId === "files") {
19096
+ wmRef.current.setMenuBar("files", {
19097
+ menus: [
19098
+ {
19099
+ label: "File",
19100
+ items: [
19101
+ { label: "New", shortcut: "Ctrl+N", onClick: () => {
19102
+ } },
19103
+ { label: "Open", shortcut: "Ctrl+O", onClick: () => {
19104
+ } },
19105
+ { label: "Save", shortcut: "Ctrl+S", onClick: () => {
19106
+ } }
19107
+ ]
19108
+ },
19109
+ {
19110
+ label: "Edit",
19111
+ items: [
19112
+ { label: "Cut", shortcut: "Ctrl+X", onClick: () => {
19113
+ } },
19114
+ { label: "Copy", shortcut: "Ctrl+C", onClick: () => {
19115
+ } },
19116
+ { label: "Paste", shortcut: "Ctrl+V", onClick: () => {
19117
+ } }
19118
+ ]
19119
+ }
19120
+ ]
19121
+ });
19122
+ }
19123
+ if (appId === "terminal") {
19124
+ wmRef.current.signalDock("terminal", { badge: 3 });
19125
+ }
19126
+ if (onAppOpenRef.current) onAppOpenRef.current(appId);
19127
+ return [...prev.map((w) => ({ ...w, focused: false })), newWin];
19128
+ }
19129
+ return prev;
19130
+ });
19131
+ }, []);
18548
19132
  const dockItems = apps.map((app) => {
18549
- const isRunning = openWindows.some((w) => w.id === app.id);
19133
+ const isRunning = openWindows.some((w) => w.appId === app.id);
18550
19134
  const signal = wmDockSignals.get(app.id);
18551
19135
  const item = {
18552
19136
  id: app.id,
@@ -18754,20 +19338,70 @@ function UnityDesktopInner(props) {
18754
19338
  createElement("div", { style: { fontSize: "24px", fontWeight: "600", marginBottom: "8px" } }, "Locked"),
18755
19339
  createElement("div", { style: { fontSize: "14px", opacity: "0.7" } }, "Click to unlock")
18756
19340
  ) : null;
18757
- const contextMenuEl = contextMenuAppId ? createElement(
18758
- "div",
18759
- {
18760
- className: "unity-desktop__context-menu-backdrop",
18761
- style: {
18762
- position: "absolute",
18763
- inset: "0",
18764
- zIndex: "9000"
19341
+ const contextMenuEl = (() => {
19342
+ if (!contextMenuAppId) return null;
19343
+ const ctxApp = apps.find((a) => a.id === contextMenuAppId);
19344
+ const ctxInstances = openWindows.filter((w) => w.appId === contextMenuAppId);
19345
+ const menuItemStyle = { padding: "6px 14px", cursor: "pointer" };
19346
+ const menuItemHoverHandlers = {
19347
+ onMouseEnter: (e) => {
19348
+ e.currentTarget.style.backgroundColor = "#444";
18765
19349
  },
18766
- onClick: closeContextMenu
18767
- },
18768
- createElement(
19350
+ onMouseLeave: (e) => {
19351
+ e.currentTarget.style.backgroundColor = "transparent";
19352
+ }
19353
+ };
19354
+ const separatorStyle = { borderBottom: "1px solid #444", margin: "4px 0" };
19355
+ const menuChildren = [];
19356
+ menuChildren.push(createElement("div", {
19357
+ key: "new",
19358
+ style: menuItemStyle,
19359
+ ...menuItemHoverHandlers,
19360
+ onClick: () => {
19361
+ openNewInstance(contextMenuAppId);
19362
+ setContextMenuAppId(null);
19363
+ },
19364
+ role: "menuitem"
19365
+ }, "\u25CF New"));
19366
+ if (ctxInstances.length > 0) {
19367
+ menuChildren.push(createElement("div", { key: "sep-1", style: separatorStyle }));
19368
+ ctxInstances.forEach((inst, idx) => {
19369
+ const displayLabel = ctxInstances.length === 1 ? ctxApp?.label || inst.title : `${ctxApp?.label || baseLabel(inst.title)} (${idx + 1})`;
19370
+ menuChildren.push(createElement("div", {
19371
+ key: `inst-${inst.id}`,
19372
+ style: menuItemStyle,
19373
+ ...menuItemHoverHandlers,
19374
+ onClick: () => {
19375
+ focusInstance(inst.id);
19376
+ setContextMenuAppId(null);
19377
+ },
19378
+ role: "menuitem"
19379
+ }, displayLabel));
19380
+ });
19381
+ }
19382
+ menuChildren.push(createElement("div", { key: "sep-2", style: separatorStyle }));
19383
+ menuChildren.push(createElement("div", {
19384
+ key: "about",
19385
+ style: menuItemStyle,
19386
+ ...menuItemHoverHandlers,
19387
+ onClick: () => {
19388
+ setAboutAppId(contextMenuAppId);
19389
+ setContextMenuAppId(null);
19390
+ },
19391
+ role: "menuitem"
19392
+ }, "About"));
19393
+ return createElement(
18769
19394
  "div",
18770
19395
  {
19396
+ className: "unity-desktop__context-menu-backdrop",
19397
+ style: {
19398
+ position: "absolute",
19399
+ inset: "0",
19400
+ zIndex: "9000"
19401
+ },
19402
+ onClick: closeContextMenu
19403
+ },
19404
+ createElement("div", {
18771
19405
  className: "unity-desktop__context-menu",
18772
19406
  style: {
18773
19407
  position: "absolute",
@@ -18784,20 +19418,9 @@ function UnityDesktopInner(props) {
18784
19418
  fontSize: "13px"
18785
19419
  },
18786
19420
  onClick: (e) => e.stopPropagation()
18787
- },
18788
- createElement("div", {
18789
- style: { padding: "6px 14px", fontWeight: "600", borderBottom: "1px solid #444", marginBottom: "4px" }
18790
- }, apps.find((a) => a.id === contextMenuAppId)?.label || contextMenuAppId),
18791
- createElement("div", {
18792
- style: { padding: "6px 14px", cursor: "pointer" },
18793
- onClick: () => {
18794
- setAboutAppId(contextMenuAppId);
18795
- setContextMenuAppId(null);
18796
- },
18797
- role: "menuitem"
18798
- }, "About")
18799
- )
18800
- ) : null;
19421
+ }, ...menuChildren)
19422
+ );
19423
+ })();
18801
19424
  const aboutApp = aboutAppId ? apps.find((a) => a.id === aboutAppId) : null;
18802
19425
  const aboutDialogEl = aboutApp ? createElement(
18803
19426
  "div",
@@ -21059,9 +21682,9 @@ function CalendarHeatMap(props) {
21059
21682
  if (latest === null || parsed > latest) latest = parsed;
21060
21683
  }
21061
21684
  if (earliest === null || latest === null) {
21062
- const now = /* @__PURE__ */ new Date();
21063
- earliest = new Date(now.getFullYear(), 0, 1);
21064
- latest = new Date(now.getFullYear(), 11, 31);
21685
+ const now2 = /* @__PURE__ */ new Date();
21686
+ earliest = new Date(now2.getFullYear(), 0, 1);
21687
+ latest = new Date(now2.getFullYear(), 11, 31);
21065
21688
  }
21066
21689
  const start = new Date(earliest);
21067
21690
  start.setDate(start.getDate() - start.getDay());