@asymmetric-effort/specifyjs 0.2.150 → 0.2.153
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/components-barrel.js +2400 -1211
- package/dist/specifyjs-components.cjs.js +3 -3
- package/dist/specifyjs-components.esm.js +2400 -1211
- package/dist/types/components/data/board/src/Board.d.ts +14 -1
- package/dist/types/components/data/board/src/Card.d.ts +14 -0
- package/dist/types/components/data/board/src/CardLink.d.ts +4 -0
- package/dist/types/components/data/board/src/Container.d.ts +2 -0
- package/dist/types/demos/project-manager/src/Board.d.ts +10 -30
- package/dist/types/demos/project-manager/src/BoardState.d.ts +5 -76
- package/dist/types/demos/project-manager/src/InterApp.d.ts +2 -2
- package/dist/types/demos/project-manager/src/index.d.ts +2 -10
- package/dist/types/demos/project-manager/src/types.d.ts +6 -45
- package/package.json +2 -2
- package/dist/types/demos/project-manager/src/Card.d.ts +0 -36
- package/dist/types/demos/project-manager/src/CardEditor.d.ts +0 -10
- package/dist/types/demos/project-manager/src/Connection.d.ts +0 -11
|
@@ -91,16 +91,16 @@ function AnalogClock(props) {
|
|
|
91
91
|
timezone,
|
|
92
92
|
className
|
|
93
93
|
} = props;
|
|
94
|
-
const [
|
|
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 =
|
|
102
|
-
const minutes =
|
|
103
|
-
const seconds =
|
|
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(
|
|
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 [
|
|
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(
|
|
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(
|
|
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 [
|
|
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(
|
|
12791
|
-
const dateStr = useMemo(() => formatDate4(
|
|
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
|
|
16337
|
-
const h = String(
|
|
16338
|
-
const m = String(
|
|
16339
|
-
const s = String(
|
|
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,379 +16453,184 @@ function TradingDashboard(props) {
|
|
|
16453
16453
|
);
|
|
16454
16454
|
}
|
|
16455
16455
|
|
|
16456
|
-
// ../
|
|
16457
|
-
|
|
16458
|
-
"
|
|
16459
|
-
|
|
16460
|
-
|
|
16461
|
-
|
|
16462
|
-
|
|
16463
|
-
|
|
16464
|
-
"
|
|
16465
|
-
|
|
16466
|
-
|
|
16467
|
-
|
|
16468
|
-
|
|
16469
|
-
|
|
16470
|
-
|
|
16471
|
-
// purple
|
|
16472
|
-
"#fbcfe8",
|
|
16473
|
-
// pink
|
|
16474
|
-
"#e5e7eb"
|
|
16475
|
-
// gray
|
|
16476
|
-
];
|
|
16477
|
-
function BoardToolbar(props) {
|
|
16478
|
-
const {
|
|
16479
|
-
zoom,
|
|
16480
|
-
gridEnabled,
|
|
16481
|
-
selectedColor,
|
|
16482
|
-
colorFilter,
|
|
16483
|
-
onNewCard,
|
|
16484
|
-
onZoomIn,
|
|
16485
|
-
onZoomOut,
|
|
16486
|
-
onZoomReset,
|
|
16487
|
-
onColorSelect,
|
|
16488
|
-
onColorFilter,
|
|
16489
|
-
onGridToggle,
|
|
16490
|
-
onSearch
|
|
16491
|
-
} = props;
|
|
16492
|
-
const [searchText, setSearchText] = useState("");
|
|
16493
|
-
const handleSearchInput = useCallback((e) => {
|
|
16494
|
-
const value = e.target.value;
|
|
16495
|
-
setSearchText(value);
|
|
16496
|
-
onSearch(value);
|
|
16497
|
-
}, [onSearch]);
|
|
16498
|
-
const toolbarStyle = {
|
|
16499
|
-
display: "flex",
|
|
16500
|
-
alignItems: "center",
|
|
16501
|
-
gap: "8px",
|
|
16502
|
-
padding: "6px 12px",
|
|
16503
|
-
backgroundColor: "rgba(255,255,255,0.95)",
|
|
16504
|
-
borderBottom: "1px solid #e2e8f0",
|
|
16505
|
-
fontSize: "12px",
|
|
16506
|
-
flexShrink: "0",
|
|
16507
|
-
flexWrap: "wrap"
|
|
16508
|
-
};
|
|
16509
|
-
const btnStyle = {
|
|
16510
|
-
padding: "4px 10px",
|
|
16511
|
-
border: "1px solid #d1d5db",
|
|
16512
|
-
borderRadius: "4px",
|
|
16513
|
-
backgroundColor: "#ffffff",
|
|
16514
|
-
cursor: "pointer",
|
|
16515
|
-
fontSize: "12px",
|
|
16516
|
-
color: "#374151",
|
|
16517
|
-
lineHeight: "1.4"
|
|
16518
|
-
};
|
|
16519
|
-
const activeBtnStyle = {
|
|
16520
|
-
...btnStyle,
|
|
16521
|
-
backgroundColor: "#3b82f6",
|
|
16522
|
-
color: "#ffffff",
|
|
16523
|
-
borderColor: "#3b82f6"
|
|
16524
|
-
};
|
|
16525
|
-
const zoomText = {
|
|
16526
|
-
fontSize: "12px",
|
|
16527
|
-
color: "#64748b",
|
|
16528
|
-
minWidth: "40px",
|
|
16529
|
-
textAlign: "center",
|
|
16530
|
-
cursor: "pointer"
|
|
16531
|
-
};
|
|
16532
|
-
const separatorStyle = {
|
|
16533
|
-
width: "1px",
|
|
16534
|
-
height: "20px",
|
|
16535
|
-
backgroundColor: "#e2e8f0",
|
|
16536
|
-
margin: "0 4px"
|
|
16537
|
-
};
|
|
16538
|
-
const inputStyle = {
|
|
16539
|
-
padding: "4px 8px",
|
|
16540
|
-
border: "1px solid #d1d5db",
|
|
16541
|
-
borderRadius: "4px",
|
|
16542
|
-
fontSize: "12px",
|
|
16543
|
-
width: "120px",
|
|
16544
|
-
outline: "none"
|
|
16545
|
-
};
|
|
16546
|
-
const swatches = CARD_COLORS.map((color) => {
|
|
16547
|
-
const isActive = color === selectedColor;
|
|
16548
|
-
const isFiltered = color === colorFilter;
|
|
16549
|
-
const handleSwatchClick = () => {
|
|
16550
|
-
if (isActive && onColorFilter) {
|
|
16551
|
-
onColorFilter(isFiltered ? null : color);
|
|
16552
|
-
} else {
|
|
16553
|
-
onColorSelect(color);
|
|
16554
|
-
}
|
|
16555
|
-
};
|
|
16556
|
-
let borderStyle = "1px solid rgba(0,0,0,0.15)";
|
|
16557
|
-
if (isFiltered) {
|
|
16558
|
-
borderStyle = "3px solid #ef4444";
|
|
16559
|
-
} else if (isActive) {
|
|
16560
|
-
borderStyle = "2px solid #3b82f6";
|
|
16561
|
-
}
|
|
16562
|
-
const isTransparent = color === "transparent";
|
|
16563
|
-
return createElement("button", {
|
|
16564
|
-
key: color,
|
|
16565
|
-
title: isTransparent ? "Transparent" : color,
|
|
16566
|
-
style: {
|
|
16567
|
-
width: "18px",
|
|
16568
|
-
height: "18px",
|
|
16569
|
-
borderRadius: "50%",
|
|
16570
|
-
backgroundColor: isTransparent ? "#ffffff" : color,
|
|
16571
|
-
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",
|
|
16572
|
-
backgroundSize: isTransparent ? "6px 6px" : "auto",
|
|
16573
|
-
backgroundPosition: isTransparent ? "0 0, 3px 3px" : "0 0",
|
|
16574
|
-
border: borderStyle,
|
|
16575
|
-
cursor: "pointer",
|
|
16576
|
-
padding: "0",
|
|
16577
|
-
flexShrink: "0",
|
|
16578
|
-
opacity: isFiltered ? "1" : colorFilter ? "0.5" : "1"
|
|
16579
|
-
},
|
|
16580
|
-
onClick: handleSwatchClick,
|
|
16581
|
-
"aria-label": isFiltered ? `Clear color filter ${color}` : `Select color ${color}`,
|
|
16582
|
-
"data-testid": `color-swatch-${color}`
|
|
16583
|
-
});
|
|
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);
|
|
16584
16471
|
});
|
|
16585
|
-
|
|
16586
|
-
|
|
16587
|
-
|
|
16588
|
-
className: "board-toolbar",
|
|
16589
|
-
style: toolbarStyle,
|
|
16590
|
-
role: "toolbar",
|
|
16591
|
-
"aria-label": "Board toolbar",
|
|
16592
|
-
"data-testid": "board-toolbar"
|
|
16593
|
-
},
|
|
16594
|
-
// New card button
|
|
16595
|
-
createElement("button", {
|
|
16596
|
-
style: btnStyle,
|
|
16597
|
-
onClick: onNewCard,
|
|
16598
|
-
"data-testid": "btn-new-card",
|
|
16599
|
-
"aria-label": "New card"
|
|
16600
|
-
}, "+ New Card"),
|
|
16601
|
-
createElement("div", { style: separatorStyle }),
|
|
16602
|
-
// Zoom controls
|
|
16603
|
-
createElement("button", {
|
|
16604
|
-
style: btnStyle,
|
|
16605
|
-
onClick: onZoomOut,
|
|
16606
|
-
"data-testid": "btn-zoom-out",
|
|
16607
|
-
"aria-label": "Zoom out"
|
|
16608
|
-
}, "-"),
|
|
16609
|
-
createElement("span", {
|
|
16610
|
-
style: zoomText,
|
|
16611
|
-
onClick: onZoomReset,
|
|
16612
|
-
"data-testid": "zoom-level",
|
|
16613
|
-
role: "status",
|
|
16614
|
-
"aria-label": `Zoom ${Math.round(zoom * 100)}%`
|
|
16615
|
-
}, `${Math.round(zoom * 100)}%`),
|
|
16616
|
-
createElement("button", {
|
|
16617
|
-
style: btnStyle,
|
|
16618
|
-
onClick: onZoomIn,
|
|
16619
|
-
"data-testid": "btn-zoom-in",
|
|
16620
|
-
"aria-label": "Zoom in"
|
|
16621
|
-
}, "+"),
|
|
16622
|
-
createElement("div", { style: separatorStyle }),
|
|
16623
|
-
...swatches,
|
|
16624
|
-
createElement("div", { style: separatorStyle }),
|
|
16625
|
-
// Grid toggle
|
|
16626
|
-
createElement("button", {
|
|
16627
|
-
style: gridEnabled ? activeBtnStyle : btnStyle,
|
|
16628
|
-
onClick: onGridToggle,
|
|
16629
|
-
"data-testid": "btn-grid-toggle",
|
|
16630
|
-
"aria-label": gridEnabled ? "Disable grid snapping" : "Enable grid snapping",
|
|
16631
|
-
"aria-pressed": String(gridEnabled)
|
|
16632
|
-
}, "Grid"),
|
|
16633
|
-
createElement("div", { style: separatorStyle }),
|
|
16634
|
-
// Search
|
|
16635
|
-
createElement("input", {
|
|
16636
|
-
type: "text",
|
|
16637
|
-
placeholder: "Search cards...",
|
|
16638
|
-
value: searchText,
|
|
16639
|
-
onInput: handleSearchInput,
|
|
16640
|
-
style: inputStyle,
|
|
16641
|
-
"data-testid": "search-input",
|
|
16642
|
-
"aria-label": "Search cards"
|
|
16643
|
-
})
|
|
16644
|
-
);
|
|
16472
|
+
}
|
|
16473
|
+
function getItemId(item) {
|
|
16474
|
+
return isCard(item) ? item.card_id : item.container_id;
|
|
16645
16475
|
}
|
|
16646
16476
|
|
|
16647
|
-
// ../
|
|
16477
|
+
// ../components/data/board/src/Card.ts
|
|
16648
16478
|
var PRIORITY_COLORS = {
|
|
16649
16479
|
low: "#22c55e",
|
|
16650
16480
|
medium: "#f59e0b",
|
|
16651
16481
|
high: "#f97316",
|
|
16652
16482
|
critical: "#ef4444"
|
|
16653
16483
|
};
|
|
16654
|
-
var
|
|
16655
|
-
|
|
16656
|
-
{ label: "
|
|
16657
|
-
{ label: "
|
|
16658
|
-
{ label: "
|
|
16659
|
-
{ 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" }
|
|
16660
16489
|
];
|
|
16661
|
-
function
|
|
16662
|
-
const
|
|
16663
|
-
|
|
16664
|
-
|
|
16665
|
-
|
|
16666
|
-
|
|
16667
|
-
|
|
16668
|
-
|
|
16669
|
-
|
|
16670
|
-
|
|
16671
|
-
|
|
16672
|
-
|
|
16673
|
-
|
|
16674
|
-
|
|
16675
|
-
|
|
16676
|
-
|
|
16677
|
-
|
|
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, onCardContextMenu, onUpdate, onDragStart, onDragEnd, onAnchorDragStart } = props;
|
|
16678
16575
|
const [hovered, setHovered] = useState(false);
|
|
16576
|
+
const [contextMenu, setContextMenu] = useState(null);
|
|
16577
|
+
const [typeSubmenuOpen, setTypeSubmenuOpen] = useState(false);
|
|
16679
16578
|
const [editingTitle, setEditingTitle] = useState(false);
|
|
16680
16579
|
const [editingDescription, setEditingDescription] = useState(false);
|
|
16681
|
-
const [titleDraft, setTitleDraft] = useState(card.
|
|
16682
|
-
const [descDraft, setDescDraft] = useState(
|
|
16580
|
+
const [titleDraft, setTitleDraft] = useState(card.card_title || "");
|
|
16581
|
+
const [descDraft, setDescDraft] = useState("");
|
|
16683
16582
|
const dragStartRef = useRef(null);
|
|
16684
16583
|
const resizeStartRef = useRef(null);
|
|
16685
|
-
const cardRef = useRef(null);
|
|
16686
|
-
const titleInputRef = useRef(null);
|
|
16687
|
-
const descTextareaRef = useRef(null);
|
|
16688
16584
|
const priorityColor = card.priority ? PRIORITY_COLORS[card.priority] || "#94a3b8" : "transparent";
|
|
16689
|
-
const { onMouseDown: onDragHandleMouseDown, isDragging: isExportDragging } = useDraggable(
|
|
16690
|
-
"application/project-card",
|
|
16691
|
-
{ id: card.id, title: card.title, description: card.description, color: card.color }
|
|
16692
|
-
);
|
|
16693
16585
|
const handleContextMenu = useCallback((e) => {
|
|
16694
16586
|
const me = e;
|
|
16695
16587
|
me.preventDefault();
|
|
16696
16588
|
me.stopPropagation();
|
|
16589
|
+
setContextMenu({ x: me.clientX, y: me.clientY });
|
|
16590
|
+
setTypeSubmenuOpen(false);
|
|
16697
16591
|
if (onCardContextMenu) {
|
|
16698
|
-
onCardContextMenu(card.
|
|
16592
|
+
onCardContextMenu(card.card_id, { x: me.clientX, y: me.clientY });
|
|
16699
16593
|
}
|
|
16700
|
-
}, [card.
|
|
16701
|
-
|
|
16702
|
-
|
|
16703
|
-
|
|
16704
|
-
input.focus();
|
|
16705
|
-
const len = input.value.length;
|
|
16706
|
-
input.setSelectionRange(len, len);
|
|
16707
|
-
}
|
|
16708
|
-
}, [editingTitle]);
|
|
16709
|
-
useEffect(() => {
|
|
16710
|
-
if (editingDescription && descTextareaRef.current) {
|
|
16711
|
-
const textarea = descTextareaRef.current;
|
|
16712
|
-
textarea.focus();
|
|
16713
|
-
const len = textarea.value.length;
|
|
16714
|
-
textarea.setSelectionRange(len, len);
|
|
16715
|
-
}
|
|
16716
|
-
}, [editingDescription]);
|
|
16717
|
-
const handleTitleDoubleClick = useCallback((e) => {
|
|
16718
|
-
e.preventDefault();
|
|
16719
|
-
e.stopPropagation();
|
|
16720
|
-
setTitleDraft(card.title || "");
|
|
16721
|
-
setEditingTitle(true);
|
|
16722
|
-
}, [card.title]);
|
|
16723
|
-
const handleTitleInput = useCallback((e) => {
|
|
16724
|
-
setTitleDraft(e.target.value);
|
|
16725
|
-
}, []);
|
|
16726
|
-
const saveTitleAndClose = useCallback(() => {
|
|
16727
|
-
const newTitle = titleDraft.trim();
|
|
16728
|
-
if (newTitle && newTitle !== card.title && onUpdate) {
|
|
16729
|
-
onUpdate(card.id, { title: newTitle });
|
|
16730
|
-
}
|
|
16731
|
-
setEditingTitle(false);
|
|
16732
|
-
}, [titleDraft, card.id, card.title, onUpdate]);
|
|
16733
|
-
const handleTitleKeyDown = useCallback((e) => {
|
|
16734
|
-
const ke = e;
|
|
16735
|
-
if (ke.key === "Enter") {
|
|
16736
|
-
ke.preventDefault();
|
|
16737
|
-
saveTitleAndClose();
|
|
16738
|
-
} else if (ke.key === "Escape") {
|
|
16739
|
-
ke.preventDefault();
|
|
16740
|
-
setEditingTitle(false);
|
|
16741
|
-
}
|
|
16742
|
-
}, [saveTitleAndClose]);
|
|
16743
|
-
const handleTitleBlur = useCallback(() => {
|
|
16744
|
-
saveTitleAndClose();
|
|
16745
|
-
}, [saveTitleAndClose]);
|
|
16746
|
-
const handleDescriptionClick = useCallback((e) => {
|
|
16747
|
-
e.stopPropagation();
|
|
16748
|
-
setDescDraft(card.description || "");
|
|
16749
|
-
setEditingDescription(true);
|
|
16750
|
-
}, [card.description]);
|
|
16751
|
-
const handleDescInput = useCallback((e) => {
|
|
16752
|
-
setDescDraft(e.target.value);
|
|
16594
|
+
}, [onCardContextMenu, card.card_id]);
|
|
16595
|
+
const closeContextMenu = useCallback(() => {
|
|
16596
|
+
setContextMenu(null);
|
|
16597
|
+
setTypeSubmenuOpen(false);
|
|
16753
16598
|
}, []);
|
|
16754
|
-
const saveDescAndClose = useCallback(() => {
|
|
16755
|
-
if (descDraft !== card.description && onUpdate) {
|
|
16756
|
-
onUpdate(card.id, { description: descDraft });
|
|
16757
|
-
}
|
|
16758
|
-
setEditingDescription(false);
|
|
16759
|
-
}, [descDraft, card.id, card.description, onUpdate]);
|
|
16760
|
-
const handleDescriptionKeyDown = useCallback((e) => {
|
|
16761
|
-
const ke = e;
|
|
16762
|
-
if (ke.key === "Escape") {
|
|
16763
|
-
ke.preventDefault();
|
|
16764
|
-
saveDescAndClose();
|
|
16765
|
-
}
|
|
16766
|
-
}, [saveDescAndClose]);
|
|
16767
|
-
const handleDescriptionBlur = useCallback(() => {
|
|
16768
|
-
saveDescAndClose();
|
|
16769
|
-
}, [saveDescAndClose]);
|
|
16770
|
-
const handleAnchorMouseDown = useCallback((anchor, e) => {
|
|
16771
|
-
const me = e;
|
|
16772
|
-
me.preventDefault();
|
|
16773
|
-
me.stopPropagation();
|
|
16774
|
-
if (onAnchorDragStart) {
|
|
16775
|
-
const cx = card.position.x + card.size.width / 2;
|
|
16776
|
-
const cy = card.position.y + card.size.height / 2;
|
|
16777
|
-
let ax = cx;
|
|
16778
|
-
let ay = cy;
|
|
16779
|
-
if (anchor === "top") {
|
|
16780
|
-
ax = cx;
|
|
16781
|
-
ay = card.position.y;
|
|
16782
|
-
} else if (anchor === "bottom") {
|
|
16783
|
-
ax = cx;
|
|
16784
|
-
ay = card.position.y + card.size.height;
|
|
16785
|
-
} else if (anchor === "left") {
|
|
16786
|
-
ax = card.position.x;
|
|
16787
|
-
ay = cy;
|
|
16788
|
-
} else if (anchor === "right") {
|
|
16789
|
-
ax = card.position.x + card.size.width;
|
|
16790
|
-
ay = cy;
|
|
16791
|
-
}
|
|
16792
|
-
onAnchorDragStart(card.id, anchor, ax, ay);
|
|
16793
|
-
}
|
|
16794
|
-
}, [card.id, card.position, card.size, onAnchorDragStart]);
|
|
16795
16599
|
const handleMouseDown = useCallback((e) => {
|
|
16796
16600
|
const me = e;
|
|
16797
16601
|
const target = me.target;
|
|
16798
|
-
if (target.dataset && (target.dataset.role === "delete" || target.dataset.role === "resize" || target.dataset.role === "
|
|
16602
|
+
if (target.dataset && (target.dataset.role === "delete" || target.dataset.role === "resize" || target.dataset.role === "drag-handle" || target.dataset.role === "inline-edit" || target.dataset.role === "anchor")) return;
|
|
16799
16603
|
me.preventDefault();
|
|
16800
16604
|
me.stopPropagation();
|
|
16801
|
-
onSelect(card.
|
|
16605
|
+
if (onSelect) onSelect(card.card_id);
|
|
16802
16606
|
dragStartRef.current = {
|
|
16803
16607
|
x: me.clientX,
|
|
16804
16608
|
y: me.clientY,
|
|
16805
16609
|
cardX: card.position.x,
|
|
16806
16610
|
cardY: card.position.y
|
|
16807
16611
|
};
|
|
16612
|
+
if (onDragStart) onDragStart(card.card_id);
|
|
16808
16613
|
const handleMouseMove = (ev) => {
|
|
16809
16614
|
const mev = ev;
|
|
16810
16615
|
if (!dragStartRef.current) return;
|
|
16811
16616
|
const dx = mev.clientX - dragStartRef.current.x;
|
|
16812
16617
|
const dy = mev.clientY - dragStartRef.current.y;
|
|
16813
|
-
onMove
|
|
16814
|
-
|
|
16815
|
-
|
|
16816
|
-
|
|
16618
|
+
if (onMove) {
|
|
16619
|
+
onMove(card.card_id, {
|
|
16620
|
+
x: dragStartRef.current.cardX + dx,
|
|
16621
|
+
y: dragStartRef.current.cardY + dy
|
|
16622
|
+
});
|
|
16623
|
+
}
|
|
16817
16624
|
};
|
|
16818
16625
|
const handleMouseUp = () => {
|
|
16819
16626
|
dragStartRef.current = null;
|
|
16627
|
+
if (onDragEnd) onDragEnd(card.card_id);
|
|
16820
16628
|
document.removeEventListener("mousemove", handleMouseMove);
|
|
16821
16629
|
document.removeEventListener("mouseup", handleMouseUp);
|
|
16822
16630
|
};
|
|
16823
16631
|
document.addEventListener("mousemove", handleMouseMove);
|
|
16824
16632
|
document.addEventListener("mouseup", handleMouseUp);
|
|
16825
|
-
|
|
16826
|
-
onDragStart(card.id, e);
|
|
16827
|
-
}
|
|
16828
|
-
}, [card.id, card.position.x, card.position.y, onSelect, onMove, onDragStart]);
|
|
16633
|
+
}, [card.card_id, card.position.x, card.position.y, onSelect, onMove, onDragStart, onDragEnd]);
|
|
16829
16634
|
const handleResizeMouseDown = useCallback((e) => {
|
|
16830
16635
|
const me = e;
|
|
16831
16636
|
me.preventDefault();
|
|
@@ -16843,7 +16648,9 @@ function Card2(props) {
|
|
|
16843
16648
|
const dy = mev.clientY - resizeStartRef.current.y;
|
|
16844
16649
|
const newW = Math.max(120, resizeStartRef.current.w + dx);
|
|
16845
16650
|
const newH = Math.max(80, resizeStartRef.current.h + dy);
|
|
16846
|
-
onResize
|
|
16651
|
+
if (onResize) {
|
|
16652
|
+
onResize(card.card_id, { width: newW, height: newH });
|
|
16653
|
+
}
|
|
16847
16654
|
};
|
|
16848
16655
|
const handleMouseUp = () => {
|
|
16849
16656
|
resizeStartRef.current = null;
|
|
@@ -16852,16 +16659,157 @@ function Card2(props) {
|
|
|
16852
16659
|
};
|
|
16853
16660
|
document.addEventListener("mousemove", handleMouseMove);
|
|
16854
16661
|
document.addEventListener("mouseup", handleMouseUp);
|
|
16855
|
-
}, [card.
|
|
16856
|
-
const
|
|
16662
|
+
}, [card.card_id, card.size.width, card.size.height, onResize]);
|
|
16663
|
+
const handleDeleteClick = useCallback((e) => {
|
|
16857
16664
|
e.preventDefault();
|
|
16858
16665
|
e.stopPropagation();
|
|
16859
|
-
|
|
16860
|
-
|
|
16666
|
+
if (onDelete) onDelete(card.card_id);
|
|
16667
|
+
}, [card.card_id, onDelete]);
|
|
16668
|
+
const handleAnchorMouseDown = useCallback((e) => {
|
|
16669
|
+
const me = e;
|
|
16670
|
+
me.preventDefault();
|
|
16671
|
+
me.stopPropagation();
|
|
16672
|
+
const target = me.target;
|
|
16673
|
+
const anchor = target.dataset.anchor;
|
|
16674
|
+
if (!anchor || !onAnchorDragStart) return;
|
|
16675
|
+
const posX = card.position.x;
|
|
16676
|
+
const posY = card.position.y;
|
|
16677
|
+
const w = card.size.width;
|
|
16678
|
+
const h = card.size.height;
|
|
16679
|
+
let ax = posX + w / 2;
|
|
16680
|
+
let ay = posY + h / 2;
|
|
16681
|
+
if (anchor === "top") {
|
|
16682
|
+
ax = posX + w / 2;
|
|
16683
|
+
ay = posY;
|
|
16684
|
+
} else if (anchor === "right") {
|
|
16685
|
+
ax = posX + w;
|
|
16686
|
+
ay = posY + h / 2;
|
|
16687
|
+
} else if (anchor === "bottom") {
|
|
16688
|
+
ax = posX + w / 2;
|
|
16689
|
+
ay = posY + h;
|
|
16690
|
+
} else if (anchor === "left") {
|
|
16691
|
+
ax = posX;
|
|
16692
|
+
ay = posY + h / 2;
|
|
16693
|
+
}
|
|
16694
|
+
onAnchorDragStart(card.card_id, anchor, { x: ax, y: ay });
|
|
16695
|
+
}, [card.card_id, card.position.x, card.position.y, card.size.width, card.size.height, onAnchorDragStart]);
|
|
16696
|
+
const handleChangeType = useCallback((newType) => {
|
|
16697
|
+
if (dispatch) {
|
|
16698
|
+
dispatch({ type: "CHANGE_CARD_TYPE", cardId: card.card_id, newType });
|
|
16699
|
+
}
|
|
16700
|
+
closeContextMenu();
|
|
16701
|
+
}, [card.card_id, dispatch, closeContextMenu]);
|
|
16702
|
+
const handleTitleDblClick = useCallback((e) => {
|
|
16861
16703
|
e.preventDefault();
|
|
16862
16704
|
e.stopPropagation();
|
|
16863
|
-
|
|
16864
|
-
|
|
16705
|
+
setTitleDraft(card.card_title || "");
|
|
16706
|
+
setEditingTitle(true);
|
|
16707
|
+
}, [card.card_title]);
|
|
16708
|
+
const handleTitleSave = useCallback(() => {
|
|
16709
|
+
setEditingTitle(false);
|
|
16710
|
+
if (onUpdate && titleDraft !== card.card_title) {
|
|
16711
|
+
onUpdate(card.card_id, { card_title: titleDraft });
|
|
16712
|
+
}
|
|
16713
|
+
}, [onUpdate, card.card_id, card.card_title, titleDraft]);
|
|
16714
|
+
const handleTitleKeyDown = useCallback((e) => {
|
|
16715
|
+
const ke = e;
|
|
16716
|
+
if (ke.key === "Enter") {
|
|
16717
|
+
ke.preventDefault();
|
|
16718
|
+
handleTitleSave();
|
|
16719
|
+
} else if (ke.key === "Escape") {
|
|
16720
|
+
ke.preventDefault();
|
|
16721
|
+
setEditingTitle(false);
|
|
16722
|
+
setTitleDraft(card.card_title || "");
|
|
16723
|
+
}
|
|
16724
|
+
}, [handleTitleSave, card.card_title]);
|
|
16725
|
+
const handleTitleInput = useCallback((e) => {
|
|
16726
|
+
const target = e.target;
|
|
16727
|
+
setTitleDraft(target.value);
|
|
16728
|
+
}, []);
|
|
16729
|
+
const handleDescClick = useCallback((e) => {
|
|
16730
|
+
e.stopPropagation();
|
|
16731
|
+
const content = card.content;
|
|
16732
|
+
setDescDraft(content.text || "");
|
|
16733
|
+
setEditingDescription(true);
|
|
16734
|
+
}, [card.content]);
|
|
16735
|
+
const handleDescSave = useCallback(() => {
|
|
16736
|
+
setEditingDescription(false);
|
|
16737
|
+
if (onUpdate) {
|
|
16738
|
+
onUpdate(card.card_id, { content: { text: descDraft } });
|
|
16739
|
+
}
|
|
16740
|
+
}, [onUpdate, card.card_id, descDraft]);
|
|
16741
|
+
const handleDescKeyDown = useCallback((e) => {
|
|
16742
|
+
const ke = e;
|
|
16743
|
+
if (ke.key === "Escape") {
|
|
16744
|
+
ke.preventDefault();
|
|
16745
|
+
setEditingDescription(false);
|
|
16746
|
+
const content = card.content;
|
|
16747
|
+
setDescDraft(content.text || "");
|
|
16748
|
+
}
|
|
16749
|
+
}, [card.content]);
|
|
16750
|
+
const handleDescInput = useCallback((e) => {
|
|
16751
|
+
const target = e.target;
|
|
16752
|
+
setDescDraft(target.value);
|
|
16753
|
+
}, []);
|
|
16754
|
+
let contentEl;
|
|
16755
|
+
switch (card.card_type) {
|
|
16756
|
+
case "text":
|
|
16757
|
+
if (editingDescription) {
|
|
16758
|
+
contentEl = createElement("textarea", {
|
|
16759
|
+
"data-role": "inline-edit",
|
|
16760
|
+
"data-testid": `card-desc-edit-${card.card_id}`,
|
|
16761
|
+
value: descDraft,
|
|
16762
|
+
onInput: handleDescInput,
|
|
16763
|
+
onBlur: handleDescSave,
|
|
16764
|
+
onKeyDown: handleDescKeyDown,
|
|
16765
|
+
onFocus: (e) => {
|
|
16766
|
+
const ta = e.target;
|
|
16767
|
+
ta.setSelectionRange(ta.value.length, ta.value.length);
|
|
16768
|
+
},
|
|
16769
|
+
style: {
|
|
16770
|
+
fontSize: "12px",
|
|
16771
|
+
color: "#555555",
|
|
16772
|
+
lineHeight: "1.4",
|
|
16773
|
+
flex: "1",
|
|
16774
|
+
border: "1px solid #3b82f6",
|
|
16775
|
+
borderRadius: "3px",
|
|
16776
|
+
padding: "2px 4px",
|
|
16777
|
+
resize: "none",
|
|
16778
|
+
outline: "none",
|
|
16779
|
+
fontFamily: "inherit",
|
|
16780
|
+
backgroundColor: "#fff",
|
|
16781
|
+
width: "100%",
|
|
16782
|
+
boxSizing: "border-box"
|
|
16783
|
+
}
|
|
16784
|
+
});
|
|
16785
|
+
} else {
|
|
16786
|
+
contentEl = createElement("div", {
|
|
16787
|
+
style: {
|
|
16788
|
+
fontSize: "12px",
|
|
16789
|
+
color: "#555555",
|
|
16790
|
+
lineHeight: "1.4",
|
|
16791
|
+
overflow: "hidden",
|
|
16792
|
+
flex: "1",
|
|
16793
|
+
cursor: "text"
|
|
16794
|
+
},
|
|
16795
|
+
"data-testid": `card-text-content-${card.card_id}`,
|
|
16796
|
+
onClick: handleDescClick
|
|
16797
|
+
}, card.content.text || "");
|
|
16798
|
+
}
|
|
16799
|
+
break;
|
|
16800
|
+
case "json":
|
|
16801
|
+
contentEl = renderJsonContent(card);
|
|
16802
|
+
break;
|
|
16803
|
+
case "task":
|
|
16804
|
+
contentEl = renderTaskContent(card);
|
|
16805
|
+
break;
|
|
16806
|
+
case "project":
|
|
16807
|
+
contentEl = renderProjectContent(card, onOpenProject);
|
|
16808
|
+
break;
|
|
16809
|
+
default:
|
|
16810
|
+
contentEl = renderTextContent(card);
|
|
16811
|
+
}
|
|
16812
|
+
const isProjectPill = card.card_type === "project";
|
|
16865
16813
|
const cardStyle = {
|
|
16866
16814
|
position: "absolute",
|
|
16867
16815
|
left: `${card.position.x}px`,
|
|
@@ -16869,7 +16817,7 @@ function Card2(props) {
|
|
|
16869
16817
|
width: `${card.size.width}px`,
|
|
16870
16818
|
height: `${card.size.height}px`,
|
|
16871
16819
|
backgroundColor: card.color || "#fef9c3",
|
|
16872
|
-
borderRadius: "6px",
|
|
16820
|
+
borderRadius: isProjectPill ? "999px" : "6px",
|
|
16873
16821
|
borderLeft: `4px solid ${priorityColor}`,
|
|
16874
16822
|
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)",
|
|
16875
16823
|
cursor: "grab",
|
|
@@ -16879,7 +16827,8 @@ function Card2(props) {
|
|
|
16879
16827
|
flexDirection: "column",
|
|
16880
16828
|
padding: "8px 10px",
|
|
16881
16829
|
boxSizing: "border-box",
|
|
16882
|
-
transition: "box-shadow 150ms ease"
|
|
16830
|
+
transition: "box-shadow 150ms ease",
|
|
16831
|
+
zIndex: "1"
|
|
16883
16832
|
};
|
|
16884
16833
|
const titleStyle = {
|
|
16885
16834
|
fontWeight: "600",
|
|
@@ -16891,13 +16840,6 @@ function Card2(props) {
|
|
|
16891
16840
|
textOverflow: "ellipsis",
|
|
16892
16841
|
whiteSpace: "nowrap"
|
|
16893
16842
|
};
|
|
16894
|
-
const descStyle = {
|
|
16895
|
-
fontSize: "12px",
|
|
16896
|
-
color: "#555555",
|
|
16897
|
-
lineHeight: "1.4",
|
|
16898
|
-
overflow: "hidden",
|
|
16899
|
-
flex: "1"
|
|
16900
|
-
};
|
|
16901
16843
|
const deleteStyle = {
|
|
16902
16844
|
position: "absolute",
|
|
16903
16845
|
top: "4px",
|
|
@@ -16925,29 +16867,64 @@ function Card2(props) {
|
|
|
16925
16867
|
opacity: "0.4",
|
|
16926
16868
|
background: "linear-gradient(135deg, transparent 50%, #666 50%)"
|
|
16927
16869
|
};
|
|
16928
|
-
const
|
|
16929
|
-
"
|
|
16870
|
+
const dragHandleStyle = {
|
|
16871
|
+
position: "absolute",
|
|
16872
|
+
top: "4px",
|
|
16873
|
+
right: "24px",
|
|
16874
|
+
width: "18px",
|
|
16875
|
+
height: "18px",
|
|
16876
|
+
borderRadius: "3px",
|
|
16877
|
+
backgroundColor: "rgba(0,0,0,0.1)",
|
|
16878
|
+
color: "#333",
|
|
16879
|
+
fontSize: "10px",
|
|
16880
|
+
lineHeight: "18px",
|
|
16881
|
+
textAlign: "center",
|
|
16882
|
+
cursor: "grab",
|
|
16883
|
+
display: hovered ? "block" : "none",
|
|
16884
|
+
border: "none",
|
|
16885
|
+
padding: "0"
|
|
16886
|
+
};
|
|
16887
|
+
const anchorSize = 8;
|
|
16888
|
+
const anchorBaseStyle = {
|
|
16889
|
+
position: "absolute",
|
|
16890
|
+
width: `${anchorSize}px`,
|
|
16891
|
+
height: `${anchorSize}px`,
|
|
16892
|
+
borderRadius: "50%",
|
|
16893
|
+
backgroundColor: "#3b82f6",
|
|
16894
|
+
border: "2px solid #fff",
|
|
16895
|
+
boxSizing: "border-box",
|
|
16896
|
+
cursor: "crosshair",
|
|
16897
|
+
display: hovered ? "block" : "none",
|
|
16898
|
+
zIndex: "10"
|
|
16899
|
+
};
|
|
16900
|
+
const anchorPositions = [
|
|
16930
16901
|
{
|
|
16931
|
-
|
|
16932
|
-
|
|
16933
|
-
gap: "4px",
|
|
16934
|
-
flexWrap: "wrap",
|
|
16935
|
-
marginTop: "4px"
|
|
16936
|
-
}
|
|
16902
|
+
anchor: "top",
|
|
16903
|
+
style: { ...anchorBaseStyle, top: `${-anchorSize / 2}px`, left: "50%", marginLeft: `${-anchorSize / 2}px` }
|
|
16937
16904
|
},
|
|
16938
|
-
|
|
16939
|
-
|
|
16940
|
-
|
|
16941
|
-
|
|
16942
|
-
|
|
16943
|
-
|
|
16944
|
-
|
|
16945
|
-
|
|
16946
|
-
|
|
16947
|
-
|
|
16948
|
-
|
|
16949
|
-
|
|
16950
|
-
|
|
16905
|
+
{
|
|
16906
|
+
anchor: "right",
|
|
16907
|
+
style: { ...anchorBaseStyle, top: "50%", right: `${-anchorSize / 2}px`, marginTop: `${-anchorSize / 2}px` }
|
|
16908
|
+
},
|
|
16909
|
+
{
|
|
16910
|
+
anchor: "bottom",
|
|
16911
|
+
style: { ...anchorBaseStyle, bottom: `${-anchorSize / 2}px`, left: "50%", marginLeft: `${-anchorSize / 2}px` }
|
|
16912
|
+
},
|
|
16913
|
+
{
|
|
16914
|
+
anchor: "left",
|
|
16915
|
+
style: { ...anchorBaseStyle, top: "50%", left: `${-anchorSize / 2}px`, marginTop: `${-anchorSize / 2}px` }
|
|
16916
|
+
}
|
|
16917
|
+
];
|
|
16918
|
+
const anchorElements = anchorPositions.map(
|
|
16919
|
+
(ap, i) => createElement("div", {
|
|
16920
|
+
key: `anchor-${ap.anchor}`,
|
|
16921
|
+
style: ap.style,
|
|
16922
|
+
"data-role": "anchor",
|
|
16923
|
+
"data-anchor": ap.anchor,
|
|
16924
|
+
"data-testid": `card-anchor-${ap.anchor}-${card.card_id}`,
|
|
16925
|
+
onMouseDown: handleAnchorMouseDown
|
|
16926
|
+
})
|
|
16927
|
+
);
|
|
16951
16928
|
const assigneeEl = card.assignee ? createElement(
|
|
16952
16929
|
"div",
|
|
16953
16930
|
{
|
|
@@ -16959,7 +16936,7 @@ function Card2(props) {
|
|
|
16959
16936
|
fontSize: "10px",
|
|
16960
16937
|
color: "#555"
|
|
16961
16938
|
},
|
|
16962
|
-
"data-testid": `card-assignee-${card.
|
|
16939
|
+
"data-testid": `card-assignee-${card.card_id}`
|
|
16963
16940
|
},
|
|
16964
16941
|
createElement("span", {
|
|
16965
16942
|
style: {
|
|
@@ -16978,127 +16955,215 @@ function Card2(props) {
|
|
|
16978
16955
|
}, card.assignee.charAt(0).toUpperCase()),
|
|
16979
16956
|
createElement("span", {}, card.assignee)
|
|
16980
16957
|
) : null;
|
|
16981
|
-
const
|
|
16982
|
-
|
|
16983
|
-
|
|
16984
|
-
|
|
16985
|
-
|
|
16986
|
-
|
|
16987
|
-
|
|
16988
|
-
|
|
16989
|
-
|
|
16990
|
-
|
|
16991
|
-
|
|
16992
|
-
|
|
16993
|
-
|
|
16994
|
-
|
|
16995
|
-
|
|
16996
|
-
|
|
16958
|
+
const tagsEl = card.tags && card.tags.length > 0 ? createElement(
|
|
16959
|
+
"div",
|
|
16960
|
+
{
|
|
16961
|
+
style: {
|
|
16962
|
+
display: "flex",
|
|
16963
|
+
gap: "4px",
|
|
16964
|
+
flexWrap: "wrap",
|
|
16965
|
+
marginTop: "4px"
|
|
16966
|
+
}
|
|
16967
|
+
},
|
|
16968
|
+
...card.tags.map(
|
|
16969
|
+
(tag, i) => createElement("span", {
|
|
16970
|
+
key: String(i),
|
|
16971
|
+
style: {
|
|
16972
|
+
fontSize: "10px",
|
|
16973
|
+
padding: "1px 4px",
|
|
16974
|
+
borderRadius: "3px",
|
|
16975
|
+
backgroundColor: "rgba(0,0,0,0.08)",
|
|
16976
|
+
color: "#444"
|
|
16977
|
+
}
|
|
16978
|
+
}, tag)
|
|
16979
|
+
)
|
|
16980
|
+
) : null;
|
|
16981
|
+
const ctxMenuItemStyle = {
|
|
16982
|
+
padding: "6px 12px",
|
|
16983
|
+
cursor: "pointer",
|
|
16984
|
+
display: "flex",
|
|
16985
|
+
alignItems: "center",
|
|
16986
|
+
justifyContent: "space-between",
|
|
16987
|
+
whiteSpace: "nowrap"
|
|
16997
16988
|
};
|
|
16998
|
-
const
|
|
16989
|
+
const ctxSubmenuStyle = {
|
|
16999
16990
|
position: "absolute",
|
|
17000
|
-
|
|
17001
|
-
|
|
17002
|
-
|
|
17003
|
-
|
|
17004
|
-
|
|
17005
|
-
|
|
17006
|
-
|
|
17007
|
-
|
|
17008
|
-
boxSizing: "border-box"
|
|
16991
|
+
left: "100%",
|
|
16992
|
+
top: "0",
|
|
16993
|
+
backgroundColor: "#ffffff",
|
|
16994
|
+
border: "1px solid #d1d5db",
|
|
16995
|
+
borderRadius: "6px",
|
|
16996
|
+
boxShadow: "0 4px 16px rgba(0,0,0,0.15)",
|
|
16997
|
+
padding: "4px 0",
|
|
16998
|
+
minWidth: "120px"
|
|
17009
16999
|
};
|
|
17010
|
-
const
|
|
17011
|
-
|
|
17012
|
-
|
|
17013
|
-
|
|
17000
|
+
const contextMenuEl = contextMenu ? createElement(
|
|
17001
|
+
"div",
|
|
17002
|
+
{
|
|
17003
|
+
className: "card-context-menu",
|
|
17004
|
+
style: {
|
|
17005
|
+
position: "fixed",
|
|
17006
|
+
left: `${contextMenu.x}px`,
|
|
17007
|
+
top: `${contextMenu.y}px`,
|
|
17008
|
+
backgroundColor: "#ffffff",
|
|
17009
|
+
border: "1px solid #d1d5db",
|
|
17010
|
+
borderRadius: "6px",
|
|
17011
|
+
boxShadow: "0 4px 16px rgba(0,0,0,0.15)",
|
|
17012
|
+
padding: "4px 0",
|
|
17013
|
+
zIndex: "10000",
|
|
17014
|
+
minWidth: "160px",
|
|
17015
|
+
fontSize: "13px",
|
|
17016
|
+
color: "#1a1a1a"
|
|
17017
|
+
},
|
|
17018
|
+
"data-testid": `card-context-menu-${card.card_id}`,
|
|
17019
|
+
role: "menu",
|
|
17020
|
+
"aria-label": "Card context menu",
|
|
17021
|
+
onClick: (e) => e.stopPropagation()
|
|
17022
|
+
},
|
|
17023
|
+
// Delete
|
|
17024
|
+
createElement("div", {
|
|
17025
|
+
style: ctxMenuItemStyle,
|
|
17026
|
+
onClick: (e) => {
|
|
17027
|
+
e.stopPropagation();
|
|
17028
|
+
if (onDelete) onDelete(card.card_id);
|
|
17029
|
+
closeContextMenu();
|
|
17030
|
+
},
|
|
17031
|
+
role: "menuitem",
|
|
17032
|
+
"data-testid": `ctx-delete-${card.card_id}`
|
|
17033
|
+
}, "Delete"),
|
|
17034
|
+
// Change Type submenu
|
|
17035
|
+
createElement(
|
|
17036
|
+
"div",
|
|
17037
|
+
{
|
|
17038
|
+
style: { ...ctxMenuItemStyle, position: "relative" },
|
|
17039
|
+
onMouseEnter: () => setTypeSubmenuOpen(true),
|
|
17040
|
+
role: "menuitem",
|
|
17041
|
+
"aria-haspopup": "true",
|
|
17042
|
+
"data-testid": `ctx-change-type-${card.card_id}`
|
|
17043
|
+
},
|
|
17044
|
+
"Change Type",
|
|
17045
|
+
createElement("span", { style: { marginLeft: "8px" } }, "\u25B6"),
|
|
17046
|
+
typeSubmenuOpen ? createElement(
|
|
17047
|
+
"div",
|
|
17048
|
+
{
|
|
17049
|
+
style: ctxSubmenuStyle,
|
|
17050
|
+
role: "menu",
|
|
17051
|
+
"data-testid": `ctx-type-submenu-${card.card_id}`
|
|
17052
|
+
},
|
|
17053
|
+
...CARD_TYPE_OPTIONS.map(
|
|
17054
|
+
(opt) => createElement(
|
|
17055
|
+
"div",
|
|
17056
|
+
{
|
|
17057
|
+
key: opt.value,
|
|
17058
|
+
style: {
|
|
17059
|
+
...ctxMenuItemStyle,
|
|
17060
|
+
fontWeight: card.card_type === opt.value ? "700" : "400"
|
|
17061
|
+
},
|
|
17062
|
+
onClick: (e) => {
|
|
17063
|
+
e.stopPropagation();
|
|
17064
|
+
handleChangeType(opt.value);
|
|
17065
|
+
},
|
|
17066
|
+
role: "menuitem",
|
|
17067
|
+
"data-testid": `ctx-type-${opt.value}-${card.card_id}`
|
|
17068
|
+
},
|
|
17069
|
+
opt.label,
|
|
17070
|
+
card.card_type === opt.value ? " \u2713" : ""
|
|
17071
|
+
)
|
|
17072
|
+
)
|
|
17073
|
+
) : null
|
|
17074
|
+
)
|
|
17075
|
+
) : null;
|
|
17076
|
+
if (isProjectPill) {
|
|
17077
|
+
return createElement(
|
|
17078
|
+
"div",
|
|
17079
|
+
{
|
|
17080
|
+
className: "board-card board-card--project",
|
|
17081
|
+
style: cardStyle,
|
|
17082
|
+
onMouseDown: handleMouseDown,
|
|
17083
|
+
onContextMenu: handleContextMenu,
|
|
17084
|
+
onMouseEnter: () => setHovered(true),
|
|
17085
|
+
onMouseLeave: () => {
|
|
17086
|
+
setHovered(false);
|
|
17087
|
+
closeContextMenu();
|
|
17088
|
+
},
|
|
17089
|
+
"data-card-id": card.card_id,
|
|
17090
|
+
"data-testid": `card-${card.card_id}`,
|
|
17091
|
+
role: "button",
|
|
17092
|
+
"aria-label": `Project card: ${card.card_title}`,
|
|
17093
|
+
tabIndex: 0
|
|
17094
|
+
},
|
|
17095
|
+
contentEl,
|
|
17096
|
+
createElement("div", {
|
|
17097
|
+
style: dragHandleStyle,
|
|
17098
|
+
"data-role": "drag-handle",
|
|
17099
|
+
"data-testid": `card-drag-handle-${card.card_id}`,
|
|
17100
|
+
"aria-label": "Export drag handle",
|
|
17101
|
+
title: "Drag to export card"
|
|
17102
|
+
}, "\u2630"),
|
|
17103
|
+
...anchorElements,
|
|
17104
|
+
contextMenuEl
|
|
17105
|
+
);
|
|
17106
|
+
}
|
|
17014
17107
|
return createElement(
|
|
17015
17108
|
"div",
|
|
17016
17109
|
{
|
|
17017
|
-
ref: cardRef,
|
|
17018
17110
|
className: "board-card",
|
|
17019
17111
|
style: cardStyle,
|
|
17020
17112
|
onMouseDown: handleMouseDown,
|
|
17021
|
-
onDblClick: handleDoubleClick,
|
|
17022
17113
|
onContextMenu: handleContextMenu,
|
|
17023
17114
|
onMouseEnter: () => setHovered(true),
|
|
17024
|
-
onMouseLeave: () =>
|
|
17025
|
-
|
|
17026
|
-
|
|
17115
|
+
onMouseLeave: () => {
|
|
17116
|
+
setHovered(false);
|
|
17117
|
+
closeContextMenu();
|
|
17118
|
+
},
|
|
17119
|
+
"data-card-id": card.card_id,
|
|
17120
|
+
"data-testid": `card-${card.card_id}`,
|
|
17027
17121
|
role: "button",
|
|
17028
|
-
"aria-label": `Card: ${card.
|
|
17122
|
+
"aria-label": `Card: ${card.card_title}`,
|
|
17029
17123
|
tabIndex: 0
|
|
17030
17124
|
},
|
|
17031
17125
|
editingTitle ? createElement("input", {
|
|
17032
|
-
|
|
17033
|
-
|
|
17126
|
+
"data-role": "inline-edit",
|
|
17127
|
+
"data-testid": `card-title-edit-${card.card_id}`,
|
|
17034
17128
|
value: titleDraft,
|
|
17035
17129
|
onInput: handleTitleInput,
|
|
17130
|
+
onBlur: handleTitleSave,
|
|
17131
|
+
onKeyDown: handleTitleKeyDown,
|
|
17132
|
+
onFocus: (e) => {
|
|
17133
|
+
const inp = e.target;
|
|
17134
|
+
inp.setSelectionRange(inp.value.length, inp.value.length);
|
|
17135
|
+
},
|
|
17036
17136
|
style: {
|
|
17037
17137
|
...titleStyle,
|
|
17038
|
-
|
|
17039
|
-
|
|
17138
|
+
border: "1px solid #3b82f6",
|
|
17139
|
+
borderRadius: "3px",
|
|
17140
|
+
padding: "1px 4px",
|
|
17040
17141
|
outline: "none",
|
|
17041
|
-
backgroundColor: "transparent",
|
|
17042
|
-
padding: "0",
|
|
17043
|
-
margin: "0",
|
|
17044
|
-
fontFamily: "inherit",
|
|
17045
|
-
boxSizing: "border-box"
|
|
17046
|
-
},
|
|
17047
|
-
"data-role": "inline-edit",
|
|
17048
|
-
"data-testid": `card-title-input-${card.id}`,
|
|
17049
|
-
onKeyDown: handleTitleKeyDown,
|
|
17050
|
-
onBlur: handleTitleBlur,
|
|
17051
|
-
onMouseDown: (e) => e.stopPropagation()
|
|
17052
|
-
}) : createElement("div", {
|
|
17053
|
-
style: titleStyle,
|
|
17054
|
-
onDblClick: handleTitleDoubleClick,
|
|
17055
|
-
"data-testid": `card-title-${card.id}`
|
|
17056
|
-
}, card.title || "Untitled"),
|
|
17057
|
-
editingDescription ? createElement("textarea", {
|
|
17058
|
-
ref: descTextareaRef,
|
|
17059
|
-
value: descDraft,
|
|
17060
|
-
onInput: handleDescInput,
|
|
17061
|
-
style: {
|
|
17062
|
-
...descStyle,
|
|
17063
17142
|
width: "100%",
|
|
17064
|
-
|
|
17065
|
-
|
|
17066
|
-
|
|
17067
|
-
padding: "0",
|
|
17068
|
-
margin: "0",
|
|
17069
|
-
fontFamily: "inherit",
|
|
17070
|
-
resize: "none",
|
|
17071
|
-
boxSizing: "border-box"
|
|
17072
|
-
},
|
|
17073
|
-
"data-role": "inline-edit",
|
|
17074
|
-
"data-testid": `card-desc-input-${card.id}`,
|
|
17075
|
-
onKeyDown: handleDescriptionKeyDown,
|
|
17076
|
-
onBlur: handleDescriptionBlur,
|
|
17077
|
-
onMouseDown: (e) => e.stopPropagation()
|
|
17143
|
+
boxSizing: "border-box",
|
|
17144
|
+
backgroundColor: "#fff"
|
|
17145
|
+
}
|
|
17078
17146
|
}) : createElement("div", {
|
|
17079
|
-
style:
|
|
17080
|
-
|
|
17081
|
-
|
|
17082
|
-
}, card.
|
|
17147
|
+
style: titleStyle,
|
|
17148
|
+
"data-testid": `card-title-${card.card_id}`,
|
|
17149
|
+
onDblClick: handleTitleDblClick
|
|
17150
|
+
}, card.card_title || "Untitled"),
|
|
17151
|
+
contentEl,
|
|
17083
17152
|
tagsEl,
|
|
17084
17153
|
assigneeEl,
|
|
17085
17154
|
createElement("div", {
|
|
17086
17155
|
style: dragHandleStyle,
|
|
17087
17156
|
"data-role": "drag-handle",
|
|
17088
|
-
"data-testid": `card-drag-handle-${card.
|
|
17089
|
-
|
|
17090
|
-
e.stopPropagation();
|
|
17091
|
-
onDragHandleMouseDown(e);
|
|
17092
|
-
},
|
|
17093
|
-
"aria-label": `Export drag handle for ${card.title}`,
|
|
17157
|
+
"data-testid": `card-drag-handle-${card.card_id}`,
|
|
17158
|
+
"aria-label": `Export drag handle for ${card.card_title}`,
|
|
17094
17159
|
title: "Drag to export card"
|
|
17095
17160
|
}, "\u2630"),
|
|
17096
17161
|
createElement("button", {
|
|
17097
17162
|
style: deleteStyle,
|
|
17098
17163
|
"data-role": "delete",
|
|
17099
|
-
"data-testid": `card-delete-${card.
|
|
17164
|
+
"data-testid": `card-delete-${card.card_id}`,
|
|
17100
17165
|
onClick: handleDeleteClick,
|
|
17101
|
-
"aria-label": `Delete ${card.
|
|
17166
|
+
"aria-label": `Delete ${card.card_title}`,
|
|
17102
17167
|
tabIndex: -1
|
|
17103
17168
|
}, "\xD7"),
|
|
17104
17169
|
createElement("div", {
|
|
@@ -17107,228 +17172,271 @@ function Card2(props) {
|
|
|
17107
17172
|
onMouseDown: handleResizeMouseDown,
|
|
17108
17173
|
"aria-label": "Resize card"
|
|
17109
17174
|
}),
|
|
17110
|
-
|
|
17111
|
-
|
|
17112
|
-
style: anchorTop,
|
|
17113
|
-
"data-role": "anchor",
|
|
17114
|
-
"data-anchor": "top",
|
|
17115
|
-
"data-testid": `anchor-top-${card.id}`,
|
|
17116
|
-
onMouseDown: (e) => handleAnchorMouseDown("top", e),
|
|
17117
|
-
"aria-label": "Connection anchor top"
|
|
17118
|
-
}),
|
|
17119
|
-
createElement("div", {
|
|
17120
|
-
style: anchorRight,
|
|
17121
|
-
"data-role": "anchor",
|
|
17122
|
-
"data-anchor": "right",
|
|
17123
|
-
"data-testid": `anchor-right-${card.id}`,
|
|
17124
|
-
onMouseDown: (e) => handleAnchorMouseDown("right", e),
|
|
17125
|
-
"aria-label": "Connection anchor right"
|
|
17126
|
-
}),
|
|
17127
|
-
createElement("div", {
|
|
17128
|
-
style: anchorBottom,
|
|
17129
|
-
"data-role": "anchor",
|
|
17130
|
-
"data-anchor": "bottom",
|
|
17131
|
-
"data-testid": `anchor-bottom-${card.id}`,
|
|
17132
|
-
onMouseDown: (e) => handleAnchorMouseDown("bottom", e),
|
|
17133
|
-
"aria-label": "Connection anchor bottom"
|
|
17134
|
-
}),
|
|
17135
|
-
createElement("div", {
|
|
17136
|
-
style: anchorLeft,
|
|
17137
|
-
"data-role": "anchor",
|
|
17138
|
-
"data-anchor": "left",
|
|
17139
|
-
"data-testid": `anchor-left-${card.id}`,
|
|
17140
|
-
onMouseDown: (e) => handleAnchorMouseDown("left", e),
|
|
17141
|
-
"aria-label": "Connection anchor left"
|
|
17142
|
-
})
|
|
17175
|
+
...anchorElements,
|
|
17176
|
+
contextMenuEl
|
|
17143
17177
|
);
|
|
17144
17178
|
}
|
|
17145
17179
|
|
|
17146
|
-
// ../
|
|
17147
|
-
function
|
|
17148
|
-
const {
|
|
17149
|
-
const [
|
|
17150
|
-
const [
|
|
17151
|
-
const
|
|
17152
|
-
const
|
|
17153
|
-
|
|
17154
|
-
|
|
17155
|
-
|
|
17156
|
-
|
|
17157
|
-
|
|
17180
|
+
// ../components/data/board/src/Container.ts
|
|
17181
|
+
function ContainerComponent(props) {
|
|
17182
|
+
const { container, selected = false, highlighted = false, onSelect, onMove, onResize, onDelete, onDrop, children } = props;
|
|
17183
|
+
const [dragOver, setDragOver] = useState(false);
|
|
17184
|
+
const [minimized, setMinimized] = useState(false);
|
|
17185
|
+
const dragStartRef = useRef(null);
|
|
17186
|
+
const resizeStartRef = useRef(null);
|
|
17187
|
+
const handleDeleteClick = useCallback((e) => {
|
|
17188
|
+
e.stopPropagation();
|
|
17189
|
+
if (onDelete) onDelete(container.container_id);
|
|
17190
|
+
}, [container.container_id, onDelete]);
|
|
17191
|
+
const handleMinimizeClick = useCallback((e) => {
|
|
17192
|
+
e.stopPropagation();
|
|
17193
|
+
setMinimized((prev) => !prev);
|
|
17158
17194
|
}, []);
|
|
17159
|
-
const
|
|
17160
|
-
onSave(card.id, { title, description });
|
|
17161
|
-
onClose();
|
|
17162
|
-
}, [card.id, title, description, onSave, onClose]);
|
|
17163
|
-
const handleKeyDown = useCallback((e) => {
|
|
17164
|
-
const ke = e;
|
|
17165
|
-
if (ke.key === "Escape") {
|
|
17166
|
-
save();
|
|
17167
|
-
}
|
|
17168
|
-
}, [save]);
|
|
17169
|
-
const handleOverlayClick = useCallback((e) => {
|
|
17195
|
+
const handleTitleMouseDown = useCallback((e) => {
|
|
17170
17196
|
const me = e;
|
|
17171
|
-
|
|
17172
|
-
|
|
17173
|
-
|
|
17174
|
-
|
|
17175
|
-
|
|
17176
|
-
|
|
17197
|
+
me.preventDefault();
|
|
17198
|
+
me.stopPropagation();
|
|
17199
|
+
if (onSelect) onSelect(container.container_id);
|
|
17200
|
+
dragStartRef.current = {
|
|
17201
|
+
x: me.clientX,
|
|
17202
|
+
y: me.clientY,
|
|
17203
|
+
posX: container.position.x,
|
|
17204
|
+
posY: container.position.y
|
|
17205
|
+
};
|
|
17206
|
+
const handleMouseMove = (ev) => {
|
|
17207
|
+
const mev = ev;
|
|
17208
|
+
if (!dragStartRef.current) return;
|
|
17209
|
+
const dx = mev.clientX - dragStartRef.current.x;
|
|
17210
|
+
const dy = mev.clientY - dragStartRef.current.y;
|
|
17211
|
+
if (onMove) {
|
|
17212
|
+
onMove(container.container_id, {
|
|
17213
|
+
x: dragStartRef.current.posX + dx,
|
|
17214
|
+
y: dragStartRef.current.posY + dy
|
|
17215
|
+
});
|
|
17216
|
+
}
|
|
17217
|
+
};
|
|
17218
|
+
const handleMouseUp = () => {
|
|
17219
|
+
dragStartRef.current = null;
|
|
17220
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
17221
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
17222
|
+
};
|
|
17223
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
17224
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
17225
|
+
}, [container.container_id, container.position.x, container.position.y, onSelect, onMove]);
|
|
17226
|
+
const handleResizeMouseDown = useCallback((e) => {
|
|
17227
|
+
const me = e;
|
|
17228
|
+
me.preventDefault();
|
|
17229
|
+
me.stopPropagation();
|
|
17230
|
+
resizeStartRef.current = {
|
|
17231
|
+
x: me.clientX,
|
|
17232
|
+
y: me.clientY,
|
|
17233
|
+
w: container.size.width,
|
|
17234
|
+
h: container.size.height
|
|
17235
|
+
};
|
|
17236
|
+
const handleMouseMove = (ev) => {
|
|
17237
|
+
const mev = ev;
|
|
17238
|
+
if (!resizeStartRef.current) return;
|
|
17239
|
+
const dx = mev.clientX - resizeStartRef.current.x;
|
|
17240
|
+
const dy = mev.clientY - resizeStartRef.current.y;
|
|
17241
|
+
const newW = Math.max(160, resizeStartRef.current.w + dx);
|
|
17242
|
+
const newH = Math.max(120, resizeStartRef.current.h + dy);
|
|
17243
|
+
if (onResize) {
|
|
17244
|
+
onResize(container.container_id, { width: newW, height: newH });
|
|
17245
|
+
}
|
|
17246
|
+
};
|
|
17247
|
+
const handleMouseUp = () => {
|
|
17248
|
+
resizeStartRef.current = null;
|
|
17249
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
17250
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
17251
|
+
};
|
|
17252
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
17253
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
17254
|
+
}, [container.container_id, container.size.width, container.size.height, onResize]);
|
|
17255
|
+
const handleDragOver = useCallback((e) => {
|
|
17256
|
+
const de = e;
|
|
17257
|
+
de.preventDefault();
|
|
17258
|
+
setDragOver(true);
|
|
17177
17259
|
}, []);
|
|
17178
|
-
const
|
|
17179
|
-
|
|
17260
|
+
const handleDragLeave = useCallback(() => {
|
|
17261
|
+
setDragOver(false);
|
|
17180
17262
|
}, []);
|
|
17181
|
-
const
|
|
17182
|
-
const
|
|
17183
|
-
|
|
17184
|
-
|
|
17185
|
-
|
|
17186
|
-
|
|
17187
|
-
|
|
17188
|
-
|
|
17189
|
-
|
|
17190
|
-
}
|
|
17191
|
-
}, [
|
|
17192
|
-
const
|
|
17263
|
+
const handleDrop = useCallback((e) => {
|
|
17264
|
+
const de = e;
|
|
17265
|
+
de.preventDefault();
|
|
17266
|
+
setDragOver(false);
|
|
17267
|
+
if (onDrop && de.dataTransfer) {
|
|
17268
|
+
const itemId = de.dataTransfer.getData("text/plain");
|
|
17269
|
+
if (itemId) {
|
|
17270
|
+
onDrop(itemId, container.container_id);
|
|
17271
|
+
}
|
|
17272
|
+
}
|
|
17273
|
+
}, [container.container_id, onDrop]);
|
|
17274
|
+
const isHighlightedOrDragOver = highlighted || dragOver;
|
|
17275
|
+
const containerStyle3 = {
|
|
17193
17276
|
position: "absolute",
|
|
17194
|
-
|
|
17195
|
-
|
|
17196
|
-
|
|
17197
|
-
|
|
17198
|
-
|
|
17199
|
-
|
|
17200
|
-
};
|
|
17201
|
-
const editorStyle = {
|
|
17202
|
-
backgroundColor: card.color || "#fef9c3",
|
|
17277
|
+
left: `${container.position.x}px`,
|
|
17278
|
+
top: `${container.position.y}px`,
|
|
17279
|
+
width: `${container.size.width}px`,
|
|
17280
|
+
height: `${container.size.height}px`,
|
|
17281
|
+
backgroundColor: highlighted ? "#eff6ff" : "#ffffff",
|
|
17282
|
+
border: highlighted ? "2px dashed #3b82f6" : selected ? "2px solid #3b82f6" : "2px solid #d1d5db",
|
|
17203
17283
|
borderRadius: "8px",
|
|
17204
|
-
|
|
17205
|
-
width: `${Math.max(card.size.width, 200)}px`,
|
|
17206
|
-
boxShadow: "0 8px 24px rgba(0,0,0,0.2)",
|
|
17284
|
+
boxShadow: isHighlightedOrDragOver ? "0 0 0 3px rgba(59,130,246,0.3), 0 4px 16px rgba(0,0,0,0.1)" : "0 2px 8px rgba(0,0,0,0.08)",
|
|
17207
17285
|
display: "flex",
|
|
17208
17286
|
flexDirection: "column",
|
|
17209
|
-
|
|
17287
|
+
overflow: "hidden",
|
|
17288
|
+
zIndex: "0",
|
|
17289
|
+
boxSizing: "border-box",
|
|
17290
|
+
transition: "border 150ms ease, background-color 150ms ease, box-shadow 150ms ease"
|
|
17210
17291
|
};
|
|
17211
|
-
const
|
|
17212
|
-
|
|
17213
|
-
|
|
17214
|
-
|
|
17215
|
-
|
|
17216
|
-
|
|
17217
|
-
|
|
17218
|
-
|
|
17219
|
-
|
|
17220
|
-
|
|
17221
|
-
|
|
17292
|
+
const titleBarStyle = {
|
|
17293
|
+
padding: "6px 12px",
|
|
17294
|
+
borderBottom: "1px solid #e5e7eb",
|
|
17295
|
+
backgroundColor: "#f9fafb",
|
|
17296
|
+
cursor: "grab",
|
|
17297
|
+
userSelect: "none",
|
|
17298
|
+
textAlign: "center",
|
|
17299
|
+
fontWeight: "700",
|
|
17300
|
+
fontSize: "15px",
|
|
17301
|
+
color: "#1f2937",
|
|
17302
|
+
flexShrink: "0"
|
|
17222
17303
|
};
|
|
17223
|
-
const
|
|
17224
|
-
|
|
17225
|
-
|
|
17226
|
-
|
|
17227
|
-
|
|
17228
|
-
backgroundColor: "rgba(255,255,255,0.7)",
|
|
17229
|
-
color: "#333",
|
|
17230
|
-
outline: "none",
|
|
17231
|
-
resize: "vertical",
|
|
17232
|
-
minHeight: "60px",
|
|
17233
|
-
width: "100%",
|
|
17234
|
-
boxSizing: "border-box",
|
|
17235
|
-
fontFamily: "inherit"
|
|
17304
|
+
const contentsStyle = {
|
|
17305
|
+
flex: "1",
|
|
17306
|
+
overflow: "auto",
|
|
17307
|
+
position: "relative",
|
|
17308
|
+
padding: "4px"
|
|
17236
17309
|
};
|
|
17237
|
-
const
|
|
17238
|
-
|
|
17239
|
-
|
|
17240
|
-
|
|
17241
|
-
|
|
17242
|
-
|
|
17243
|
-
cursor: "
|
|
17244
|
-
|
|
17245
|
-
|
|
17246
|
-
alignSelf: "flex-end"
|
|
17310
|
+
const resizeHandleStyle = {
|
|
17311
|
+
position: "absolute",
|
|
17312
|
+
bottom: "0",
|
|
17313
|
+
right: "0",
|
|
17314
|
+
width: "14px",
|
|
17315
|
+
height: "14px",
|
|
17316
|
+
cursor: "nwse-resize",
|
|
17317
|
+
opacity: "0.4",
|
|
17318
|
+
background: "linear-gradient(135deg, transparent 50%, #666 50%)"
|
|
17247
17319
|
};
|
|
17248
17320
|
return createElement(
|
|
17249
17321
|
"div",
|
|
17250
17322
|
{
|
|
17251
|
-
|
|
17252
|
-
|
|
17253
|
-
|
|
17254
|
-
|
|
17255
|
-
|
|
17256
|
-
"
|
|
17323
|
+
className: "board-container",
|
|
17324
|
+
style: containerStyle3,
|
|
17325
|
+
"data-container-id": container.container_id,
|
|
17326
|
+
"data-testid": `container-${container.container_id}`,
|
|
17327
|
+
role: "group",
|
|
17328
|
+
"aria-label": `Container: ${container.name}`,
|
|
17329
|
+
onDragOver: handleDragOver,
|
|
17330
|
+
onDragLeave: handleDragLeave,
|
|
17331
|
+
onDrop: handleDrop
|
|
17257
17332
|
},
|
|
17258
17333
|
createElement(
|
|
17259
17334
|
"div",
|
|
17260
17335
|
{
|
|
17261
|
-
|
|
17262
|
-
"
|
|
17263
|
-
|
|
17264
|
-
"
|
|
17336
|
+
className: "board-container__title",
|
|
17337
|
+
style: { ...titleBarStyle, display: "flex", alignItems: "center", justifyContent: "space-between" },
|
|
17338
|
+
onMouseDown: handleTitleMouseDown,
|
|
17339
|
+
"data-testid": `container-title-${container.container_id}`
|
|
17265
17340
|
},
|
|
17266
|
-
createElement("
|
|
17267
|
-
|
|
17268
|
-
|
|
17269
|
-
|
|
17270
|
-
|
|
17271
|
-
|
|
17272
|
-
|
|
17273
|
-
|
|
17274
|
-
|
|
17275
|
-
|
|
17276
|
-
|
|
17277
|
-
|
|
17278
|
-
|
|
17279
|
-
|
|
17280
|
-
|
|
17281
|
-
|
|
17282
|
-
|
|
17283
|
-
"
|
|
17284
|
-
"
|
|
17285
|
-
|
|
17286
|
-
|
|
17287
|
-
|
|
17288
|
-
|
|
17289
|
-
|
|
17290
|
-
|
|
17291
|
-
|
|
17341
|
+
createElement("span", null, container.name),
|
|
17342
|
+
createElement(
|
|
17343
|
+
"span",
|
|
17344
|
+
{ style: { display: "flex", gap: "4px" } },
|
|
17345
|
+
createElement("button", {
|
|
17346
|
+
style: {
|
|
17347
|
+
border: "none",
|
|
17348
|
+
backgroundColor: "transparent",
|
|
17349
|
+
cursor: "pointer",
|
|
17350
|
+
color: "#94a3b8",
|
|
17351
|
+
fontSize: "12px",
|
|
17352
|
+
padding: "0 2px",
|
|
17353
|
+
lineHeight: "1"
|
|
17354
|
+
},
|
|
17355
|
+
onClick: handleMinimizeClick,
|
|
17356
|
+
"aria-label": minimized ? "Expand container" : "Minimize container",
|
|
17357
|
+
title: minimized ? "Expand" : "Minimize"
|
|
17358
|
+
}, minimized ? "\u25B2" : "\u2014"),
|
|
17359
|
+
createElement("button", {
|
|
17360
|
+
style: {
|
|
17361
|
+
border: "none",
|
|
17362
|
+
backgroundColor: "transparent",
|
|
17363
|
+
cursor: "pointer",
|
|
17364
|
+
color: "#94a3b8",
|
|
17365
|
+
fontSize: "14px",
|
|
17366
|
+
padding: "0 2px",
|
|
17367
|
+
lineHeight: "1"
|
|
17368
|
+
},
|
|
17369
|
+
onClick: handleDeleteClick,
|
|
17370
|
+
"aria-label": "Delete container",
|
|
17371
|
+
title: "Delete"
|
|
17372
|
+
}, "\xD7")
|
|
17373
|
+
)
|
|
17374
|
+
),
|
|
17375
|
+
minimized ? null : createElement("div", {
|
|
17376
|
+
className: "board-container__contents",
|
|
17377
|
+
style: contentsStyle,
|
|
17378
|
+
"data-testid": `container-contents-${container.container_id}`
|
|
17379
|
+
}, children),
|
|
17380
|
+
minimized ? null : createElement("div", {
|
|
17381
|
+
style: resizeHandleStyle,
|
|
17382
|
+
"data-role": "resize",
|
|
17383
|
+
onMouseDown: handleResizeMouseDown,
|
|
17384
|
+
"aria-label": "Resize container"
|
|
17385
|
+
})
|
|
17292
17386
|
);
|
|
17293
17387
|
}
|
|
17294
17388
|
|
|
17295
|
-
// ../
|
|
17296
|
-
function
|
|
17389
|
+
// ../components/data/board/src/CardLink.ts
|
|
17390
|
+
function getCardAnchors(card) {
|
|
17391
|
+
const cx = card.position.x + card.size.width / 2;
|
|
17392
|
+
const cy = card.position.y + card.size.height / 2;
|
|
17297
17393
|
return {
|
|
17298
|
-
|
|
17299
|
-
|
|
17394
|
+
top: { x: cx, y: card.position.y },
|
|
17395
|
+
right: { x: card.position.x + card.size.width, y: cy },
|
|
17396
|
+
bottom: { x: cx, y: card.position.y + card.size.height },
|
|
17397
|
+
left: { x: card.position.x, y: cy }
|
|
17300
17398
|
};
|
|
17301
17399
|
}
|
|
17302
|
-
function
|
|
17303
|
-
|
|
17304
|
-
|
|
17305
|
-
|
|
17306
|
-
|
|
17307
|
-
|
|
17308
|
-
|
|
17309
|
-
|
|
17310
|
-
|
|
17311
|
-
|
|
17312
|
-
|
|
17313
|
-
|
|
17400
|
+
function getNearestAnchors(source, target) {
|
|
17401
|
+
const sa = getCardAnchors(source);
|
|
17402
|
+
const ta = getCardAnchors(target);
|
|
17403
|
+
const sourceAnchors = [sa.top, sa.right, sa.bottom, sa.left];
|
|
17404
|
+
const targetAnchors = [ta.top, ta.right, ta.bottom, ta.left];
|
|
17405
|
+
let bestDist = Infinity;
|
|
17406
|
+
let bestFrom = sa.right;
|
|
17407
|
+
let bestTo = ta.left;
|
|
17408
|
+
for (let i = 0; i < sourceAnchors.length; i++) {
|
|
17409
|
+
for (let j = 0; j < targetAnchors.length; j++) {
|
|
17410
|
+
const dx = targetAnchors[j].x - sourceAnchors[i].x;
|
|
17411
|
+
const dy = targetAnchors[j].y - sourceAnchors[i].y;
|
|
17412
|
+
const d = dx * dx + dy * dy;
|
|
17413
|
+
if (d < bestDist) {
|
|
17414
|
+
bestDist = d;
|
|
17415
|
+
bestFrom = sourceAnchors[i];
|
|
17416
|
+
bestTo = targetAnchors[j];
|
|
17417
|
+
}
|
|
17418
|
+
}
|
|
17419
|
+
}
|
|
17420
|
+
return { from: bestFrom, to: bestTo };
|
|
17421
|
+
}
|
|
17422
|
+
var ARROW_MARKER_ID = "board-card-link-arrowhead";
|
|
17423
|
+
function CardLinkOverlay(props) {
|
|
17424
|
+
const { links, cards, selectedLinkId, onSelectLink, onLinkContextMenu, canvasWidth, canvasHeight } = props;
|
|
17314
17425
|
const cardMap = /* @__PURE__ */ new Map();
|
|
17315
17426
|
for (let i = 0; i < cards.length; i++) {
|
|
17316
|
-
cardMap.set(cards[i].
|
|
17427
|
+
cardMap.set(cards[i].card_id, cards[i]);
|
|
17317
17428
|
}
|
|
17318
|
-
const handleLineClick = useCallback((
|
|
17319
|
-
|
|
17320
|
-
}, [
|
|
17429
|
+
const handleLineClick = useCallback((linkId) => {
|
|
17430
|
+
onSelectLink(linkId);
|
|
17431
|
+
}, [onSelectLink]);
|
|
17321
17432
|
const lineElements = [];
|
|
17322
|
-
for (let i = 0; i <
|
|
17323
|
-
const
|
|
17324
|
-
const
|
|
17325
|
-
|
|
17326
|
-
|
|
17327
|
-
const
|
|
17328
|
-
const
|
|
17329
|
-
const isSelected = conn.id === selectedConnectionId;
|
|
17330
|
-
const strokeColor = isSelected ? "#3b82f6" : "#94a3b8";
|
|
17331
|
-
const dashArray = getStrokeDasharray(conn.style);
|
|
17433
|
+
for (let i = 0; i < links.length; i++) {
|
|
17434
|
+
const { source, link } = links[i];
|
|
17435
|
+
const targetCard = cardMap.get(link.target_card_id);
|
|
17436
|
+
if (!targetCard) continue;
|
|
17437
|
+
const { from, to } = getNearestAnchors(source, targetCard);
|
|
17438
|
+
const isSelected = link.link_id === selectedLinkId;
|
|
17439
|
+
const strokeColor = isSelected ? "#3b82f6" : link.color || "#94a3b8";
|
|
17332
17440
|
const dx = to.x - from.x;
|
|
17333
17441
|
const dy = to.y - from.y;
|
|
17334
17442
|
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
@@ -17340,41 +17448,49 @@ function ConnectionsOverlay(props) {
|
|
|
17340
17448
|
const cpX = midX + nx * curveOffset;
|
|
17341
17449
|
const cpY = midY + ny * curveOffset;
|
|
17342
17450
|
const pathD = `M ${from.x} ${from.y} Q ${cpX} ${cpY} ${to.x} ${to.y}`;
|
|
17451
|
+
const srcId = source.card_id;
|
|
17343
17452
|
lineElements.push(
|
|
17344
17453
|
createElement("path", {
|
|
17345
|
-
key: `hit-${
|
|
17454
|
+
key: `hit-${link.link_id}`,
|
|
17346
17455
|
d: pathD,
|
|
17347
17456
|
fill: "none",
|
|
17348
17457
|
stroke: "transparent",
|
|
17349
17458
|
"stroke-width": "12",
|
|
17350
|
-
style: { cursor: "pointer" },
|
|
17351
|
-
onClick: () => handleLineClick(
|
|
17352
|
-
|
|
17459
|
+
style: { cursor: "pointer", pointerEvents: "stroke" },
|
|
17460
|
+
onClick: () => handleLineClick(link.link_id),
|
|
17461
|
+
onContextMenu: (e) => {
|
|
17462
|
+
const me = e;
|
|
17463
|
+
me.preventDefault();
|
|
17464
|
+
me.stopPropagation();
|
|
17465
|
+
if (onLinkContextMenu) onLinkContextMenu(link.link_id, srcId, { x: me.clientX, y: me.clientY });
|
|
17466
|
+
},
|
|
17467
|
+
"data-testid": `link-hit-${link.link_id}`
|
|
17353
17468
|
})
|
|
17354
17469
|
);
|
|
17355
17470
|
lineElements.push(
|
|
17356
17471
|
createElement("path", {
|
|
17357
|
-
key:
|
|
17472
|
+
key: link.link_id,
|
|
17358
17473
|
d: pathD,
|
|
17359
17474
|
fill: "none",
|
|
17360
17475
|
stroke: strokeColor,
|
|
17361
17476
|
"stroke-width": isSelected ? "3" : "2",
|
|
17362
|
-
"stroke-dasharray": dashArray,
|
|
17363
17477
|
"pointer-events": "none",
|
|
17364
|
-
"
|
|
17478
|
+
"marker-end": `url(#${ARROW_MARKER_ID})`,
|
|
17479
|
+
"data-testid": `link-${link.link_id}`
|
|
17365
17480
|
})
|
|
17366
17481
|
);
|
|
17367
|
-
if (
|
|
17482
|
+
if (link.link_name) {
|
|
17368
17483
|
lineElements.push(
|
|
17369
17484
|
createElement("text", {
|
|
17370
|
-
key: `label-${
|
|
17485
|
+
key: `label-${link.link_id}`,
|
|
17371
17486
|
x: String(cpX),
|
|
17372
17487
|
y: String(cpY - 6),
|
|
17373
17488
|
"text-anchor": "middle",
|
|
17374
17489
|
fill: "#64748b",
|
|
17375
17490
|
"font-size": "11",
|
|
17376
|
-
"pointer-events": "none"
|
|
17377
|
-
|
|
17491
|
+
"pointer-events": "none",
|
|
17492
|
+
"data-testid": `link-label-${link.link_id}`
|
|
17493
|
+
}, link.link_name)
|
|
17378
17494
|
);
|
|
17379
17495
|
}
|
|
17380
17496
|
}
|
|
@@ -17385,83 +17501,140 @@ function ConnectionsOverlay(props) {
|
|
|
17385
17501
|
width: "100%",
|
|
17386
17502
|
height: "100%",
|
|
17387
17503
|
pointerEvents: "none",
|
|
17388
|
-
overflow: "visible"
|
|
17504
|
+
overflow: "visible",
|
|
17505
|
+
zIndex: "9999"
|
|
17389
17506
|
};
|
|
17507
|
+
const markerDef = createElement(
|
|
17508
|
+
"defs",
|
|
17509
|
+
{},
|
|
17510
|
+
createElement(
|
|
17511
|
+
"marker",
|
|
17512
|
+
{
|
|
17513
|
+
id: ARROW_MARKER_ID,
|
|
17514
|
+
viewBox: "0 0 10 10",
|
|
17515
|
+
refX: "10",
|
|
17516
|
+
refY: "5",
|
|
17517
|
+
markerWidth: "8",
|
|
17518
|
+
markerHeight: "8",
|
|
17519
|
+
orient: "auto-start-reverse"
|
|
17520
|
+
},
|
|
17521
|
+
createElement("path", {
|
|
17522
|
+
d: "M 0 0 L 10 5 L 0 10 z",
|
|
17523
|
+
fill: "#94a3b8"
|
|
17524
|
+
})
|
|
17525
|
+
)
|
|
17526
|
+
);
|
|
17390
17527
|
return createElement(
|
|
17391
17528
|
"svg",
|
|
17392
17529
|
{
|
|
17393
17530
|
style: svgStyle,
|
|
17394
17531
|
width: String(canvasWidth),
|
|
17395
17532
|
height: String(canvasHeight),
|
|
17396
|
-
className: "
|
|
17397
|
-
"data-testid": "
|
|
17533
|
+
className: "card-link-overlay",
|
|
17534
|
+
"data-testid": "card-link-overlay",
|
|
17398
17535
|
role: "img",
|
|
17399
|
-
"aria-label": "Card
|
|
17536
|
+
"aria-label": "Card links"
|
|
17400
17537
|
},
|
|
17538
|
+
markerDef,
|
|
17401
17539
|
createElement("g", { style: { pointerEvents: "auto" } }, ...lineElements)
|
|
17402
17540
|
);
|
|
17403
17541
|
}
|
|
17404
17542
|
|
|
17405
|
-
// ../
|
|
17543
|
+
// ../components/data/board/src/Board.ts
|
|
17544
|
+
var CONTEXT_COLORS = [
|
|
17545
|
+
{ value: "#fef9c3", label: "Yellow" },
|
|
17546
|
+
{ value: "#fecaca", label: "Red" },
|
|
17547
|
+
{ value: "#fed7aa", label: "Orange" },
|
|
17548
|
+
{ value: "#bbf7d0", label: "Green" },
|
|
17549
|
+
{ value: "#bfdbfe", label: "Blue" },
|
|
17550
|
+
{ value: "#ddd6fe", label: "Purple" },
|
|
17551
|
+
{ value: "#fbcfe8", label: "Pink" },
|
|
17552
|
+
{ value: "#e5e7eb", label: "Gray" }
|
|
17553
|
+
];
|
|
17406
17554
|
var GRID_SIZE = 20;
|
|
17407
17555
|
var CANVAS_SIZE = 5e3;
|
|
17556
|
+
function findContainerAtPoint(collection, x, y, excludeId) {
|
|
17557
|
+
for (let i = 0; i < collection.length; i++) {
|
|
17558
|
+
const item = collection[i];
|
|
17559
|
+
if (!isContainer(item)) continue;
|
|
17560
|
+
if (item.container_id === excludeId) continue;
|
|
17561
|
+
if (x >= item.position.x && x <= item.position.x + item.size.width && y >= item.position.y && y <= item.position.y + item.size.height) {
|
|
17562
|
+
return item.container_id;
|
|
17563
|
+
}
|
|
17564
|
+
}
|
|
17565
|
+
return null;
|
|
17566
|
+
}
|
|
17567
|
+
function snapToGrid(pos, gridSize) {
|
|
17568
|
+
return {
|
|
17569
|
+
x: Math.round(pos.x / gridSize) * gridSize,
|
|
17570
|
+
y: Math.round(pos.y / gridSize) * gridSize
|
|
17571
|
+
};
|
|
17572
|
+
}
|
|
17408
17573
|
function screenToCanvas(screenX, screenY, viewport) {
|
|
17409
17574
|
return {
|
|
17410
17575
|
x: (screenX - viewport.panX) / viewport.zoom,
|
|
17411
17576
|
y: (screenY - viewport.panY) / viewport.zoom
|
|
17412
17577
|
};
|
|
17413
17578
|
}
|
|
17414
|
-
function
|
|
17415
|
-
const
|
|
17416
|
-
|
|
17417
|
-
|
|
17579
|
+
function collectCardsAndLinks(items) {
|
|
17580
|
+
const cards = [];
|
|
17581
|
+
const links = [];
|
|
17582
|
+
const stack = [];
|
|
17583
|
+
for (let i = items.length - 1; i >= 0; i--) {
|
|
17584
|
+
stack.push([items[i], 0, 0]);
|
|
17418
17585
|
}
|
|
17419
|
-
|
|
17420
|
-
|
|
17421
|
-
|
|
17422
|
-
|
|
17423
|
-
|
|
17424
|
-
|
|
17425
|
-
|
|
17426
|
-
|
|
17427
|
-
|
|
17428
|
-
|
|
17429
|
-
|
|
17430
|
-
|
|
17586
|
+
while (stack.length > 0) {
|
|
17587
|
+
const [item, offsetX, offsetY] = stack.pop();
|
|
17588
|
+
if (isCard(item)) {
|
|
17589
|
+
const absCard = {
|
|
17590
|
+
...item,
|
|
17591
|
+
position: {
|
|
17592
|
+
x: item.position.x + offsetX,
|
|
17593
|
+
y: item.position.y + offsetY
|
|
17594
|
+
}
|
|
17595
|
+
};
|
|
17596
|
+
cards.push(absCard);
|
|
17597
|
+
for (let j = 0; j < item.card_link.length; j++) {
|
|
17598
|
+
links.push({ source: absCard, link: item.card_link[j] });
|
|
17599
|
+
}
|
|
17600
|
+
} else if (isContainer(item)) {
|
|
17601
|
+
const childOffsetX = offsetX + item.position.x;
|
|
17602
|
+
const childOffsetY = offsetY + item.position.y + 30;
|
|
17603
|
+
for (let j = item.contents.length - 1; j >= 0; j--) {
|
|
17604
|
+
stack.push([item.contents[j], childOffsetX, childOffsetY]);
|
|
17605
|
+
}
|
|
17606
|
+
}
|
|
17431
17607
|
}
|
|
17432
|
-
|
|
17433
|
-
const contentH = maxY - minY + pad3 * 2;
|
|
17434
|
-
const zoomX = containerWidth / contentW;
|
|
17435
|
-
const zoomY = containerHeight / contentH;
|
|
17436
|
-
const zoom = Math.max(0.25, Math.min(4, Math.min(zoomX, zoomY)));
|
|
17437
|
-
const panX = -minX * zoom + (containerWidth - (maxX - minX) * zoom) / 2;
|
|
17438
|
-
const panY = -minY * zoom + (containerHeight - (maxY - minY) * zoom) / 2;
|
|
17439
|
-
return { panX, panY, zoom };
|
|
17440
|
-
}
|
|
17441
|
-
var connIdCounter = 0;
|
|
17442
|
-
function generateConnectionId() {
|
|
17443
|
-
connIdCounter++;
|
|
17444
|
-
return `conn-${Date.now()}-${connIdCounter}`;
|
|
17608
|
+
return { cards, links };
|
|
17445
17609
|
}
|
|
17446
17610
|
function Board(props) {
|
|
17447
|
-
const {
|
|
17448
|
-
|
|
17449
|
-
|
|
17450
|
-
|
|
17451
|
-
|
|
17452
|
-
|
|
17453
|
-
|
|
17454
|
-
|
|
17611
|
+
const {
|
|
17612
|
+
state,
|
|
17613
|
+
dispatch,
|
|
17614
|
+
selectedId = null,
|
|
17615
|
+
onSelectItem,
|
|
17616
|
+
gridEnabled = false,
|
|
17617
|
+
searchQuery = "",
|
|
17618
|
+
colorFilter = null,
|
|
17619
|
+
onOpenProject,
|
|
17620
|
+
onCardContextMenu,
|
|
17621
|
+
onUpdateItem
|
|
17622
|
+
} = props;
|
|
17623
|
+
const { collection, viewport } = state;
|
|
17455
17624
|
const containerRef = useRef(null);
|
|
17456
17625
|
const isPanningRef = useRef(false);
|
|
17457
17626
|
const panStartRef = useRef(null);
|
|
17458
|
-
const [
|
|
17459
|
-
const
|
|
17460
|
-
|
|
17627
|
+
const [dropTargetId, setDropTargetId] = useState(null);
|
|
17628
|
+
const [draggingCardId, setDraggingCardId] = useState(null);
|
|
17629
|
+
const [linkDrag, setLinkDrag] = useState(null);
|
|
17630
|
+
const [cardContextMenu, setCardContextMenu] = useState(null);
|
|
17631
|
+
const [colorSubmenuOpen, setColorSubmenuOpen] = useState(false);
|
|
17632
|
+
const [typeSubmenuOpen, setTypeSubmenuOpen] = useState(false);
|
|
17633
|
+
const [linkContextMenu, setLinkContextMenu] = useState(null);
|
|
17461
17634
|
const handleCanvasMouseDown = useCallback((e) => {
|
|
17462
17635
|
const me = e;
|
|
17463
17636
|
const target = me.target;
|
|
17464
|
-
if (target.closest(".board-card")) return;
|
|
17637
|
+
if (target.closest(".board-card") || target.closest(".board-container")) return;
|
|
17465
17638
|
const isMiddle = me.button === 1;
|
|
17466
17639
|
const isShiftLeft = me.button === 0 && me.shiftKey;
|
|
17467
17640
|
if (isMiddle || isShiftLeft) {
|
|
@@ -17474,10 +17647,9 @@ function Board(props) {
|
|
|
17474
17647
|
panY: viewport.panY
|
|
17475
17648
|
};
|
|
17476
17649
|
} else if (me.button === 0) {
|
|
17477
|
-
|
|
17478
|
-
setSelectedConnectionId(null);
|
|
17650
|
+
if (onSelectItem) onSelectItem(null);
|
|
17479
17651
|
}
|
|
17480
|
-
}, [viewport.panX, viewport.panY,
|
|
17652
|
+
}, [viewport.panX, viewport.panY, onSelectItem]);
|
|
17481
17653
|
useEffect(() => {
|
|
17482
17654
|
const handleMouseMove = (e) => {
|
|
17483
17655
|
if (!isPanningRef.current || !panStartRef.current) return;
|
|
@@ -17544,13 +17716,10 @@ function Board(props) {
|
|
|
17544
17716
|
const startMidY = (start.touches[0].y + start.touches[1].y) / 2;
|
|
17545
17717
|
const curMidX = (pts[0].x + pts[1].x) / 2;
|
|
17546
17718
|
const curMidY = (pts[0].y + pts[1].y) / 2;
|
|
17547
|
-
|
|
17548
|
-
const dy = curMidY - startMidY;
|
|
17549
|
-
dispatch({ type: "PAN", panX: start.panX + dx, panY: start.panY + dy });
|
|
17719
|
+
dispatch({ type: "PAN", panX: start.panX + (curMidX - startMidX), panY: start.panY + (curMidY - startMidY) });
|
|
17550
17720
|
const curDist = getDist(pts[0], pts[1]);
|
|
17551
17721
|
if (start.dist > 0) {
|
|
17552
|
-
|
|
17553
|
-
dispatch({ type: "ZOOM", zoom: start.zoom * scale });
|
|
17722
|
+
dispatch({ type: "ZOOM", zoom: start.zoom * (curDist / start.dist) });
|
|
17554
17723
|
}
|
|
17555
17724
|
};
|
|
17556
17725
|
const handleTouchEnd = () => {
|
|
@@ -17565,176 +17734,146 @@ function Board(props) {
|
|
|
17565
17734
|
container.removeEventListener("touchend", handleTouchEnd);
|
|
17566
17735
|
};
|
|
17567
17736
|
}, [viewport.panX, viewport.panY, viewport.zoom, dispatch]);
|
|
17568
|
-
useEffect(() => {
|
|
17569
|
-
const handleKeyDown = (e) => {
|
|
17570
|
-
const ke = e;
|
|
17571
|
-
if (ke.key === "Delete" || ke.key === "Backspace") {
|
|
17572
|
-
if (selectedConnectionId) {
|
|
17573
|
-
dispatch({ type: "REMOVE_CONNECTION", connectionId: selectedConnectionId });
|
|
17574
|
-
setSelectedConnectionId(null);
|
|
17575
|
-
} else if (selectedCardId) {
|
|
17576
|
-
dispatch({ type: "REMOVE_CARD", cardId: selectedCardId });
|
|
17577
|
-
onSelectCard(null);
|
|
17578
|
-
}
|
|
17579
|
-
}
|
|
17580
|
-
};
|
|
17581
|
-
document.addEventListener("keydown", handleKeyDown);
|
|
17582
|
-
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
17583
|
-
}, [selectedConnectionId, selectedCardId, dispatch, onSelectCard]);
|
|
17584
|
-
const handleSelectCard = useCallback((cardId) => {
|
|
17585
|
-
onSelectCard(cardId);
|
|
17586
|
-
setSelectedConnectionId(null);
|
|
17587
|
-
}, [onSelectCard]);
|
|
17588
|
-
const handleMoveCard = useCallback((cardId, position) => {
|
|
17589
|
-
let pos = position;
|
|
17590
|
-
if (gridEnabled) {
|
|
17591
|
-
pos = {
|
|
17592
|
-
x: Math.round(position.x / GRID_SIZE) * GRID_SIZE,
|
|
17593
|
-
y: Math.round(position.y / GRID_SIZE) * GRID_SIZE
|
|
17594
|
-
};
|
|
17595
|
-
}
|
|
17596
|
-
dispatch({ type: "MOVE_CARD", cardId, position: pos });
|
|
17597
|
-
}, [dispatch, gridEnabled]);
|
|
17598
|
-
const handleResizeCard = useCallback((cardId, size) => {
|
|
17599
|
-
dispatch({ type: "RESIZE_CARD", cardId, size });
|
|
17600
|
-
}, [dispatch]);
|
|
17601
|
-
const handleDeleteCard = useCallback((cardId) => {
|
|
17602
|
-
dispatch({ type: "REMOVE_CARD", cardId });
|
|
17603
|
-
if (selectedCardId === cardId) onSelectCard(null);
|
|
17604
|
-
}, [dispatch, selectedCardId, onSelectCard]);
|
|
17605
|
-
const handleDoubleClickCard = useCallback((_cardId) => {
|
|
17606
|
-
}, []);
|
|
17607
|
-
const handleUpdateCard = useCallback((cardId, updates) => {
|
|
17608
|
-
dispatch({ type: "UPDATE_CARD", cardId, updates });
|
|
17609
|
-
}, [dispatch]);
|
|
17610
|
-
const handleEditorSave = useCallback((cardId, updates) => {
|
|
17611
|
-
dispatch({ type: "UPDATE_CARD", cardId, updates });
|
|
17612
|
-
}, [dispatch]);
|
|
17613
|
-
const handleEditorClose = useCallback(() => {
|
|
17614
|
-
setEditingCardId(null);
|
|
17615
|
-
}, []);
|
|
17616
|
-
const handleSelectConnection = useCallback((connectionId) => {
|
|
17617
|
-
setSelectedConnectionId(connectionId);
|
|
17618
|
-
onSelectCard(null);
|
|
17619
|
-
}, [onSelectCard]);
|
|
17620
|
-
const handleDeleteConnection = useCallback((connectionId) => {
|
|
17621
|
-
dispatch({ type: "REMOVE_CONNECTION", connectionId });
|
|
17622
|
-
setSelectedConnectionId(null);
|
|
17623
|
-
}, [dispatch]);
|
|
17624
|
-
const handleDuplicateCard = useCallback((cardId) => {
|
|
17625
|
-
const newId = `card-${Date.now()}-dup`;
|
|
17626
|
-
dispatch({ type: "DUPLICATE_CARD", cardId, newId });
|
|
17627
|
-
}, [dispatch]);
|
|
17628
|
-
const handleChangeColor = useCallback((cardId, color) => {
|
|
17629
|
-
dispatch({ type: "UPDATE_CARD", cardId, updates: { color } });
|
|
17630
|
-
}, [dispatch]);
|
|
17631
|
-
const handleChangePriority = useCallback((cardId, priority) => {
|
|
17632
|
-
dispatch({ type: "UPDATE_CARD", cardId, updates: { priority } });
|
|
17633
|
-
}, [dispatch]);
|
|
17634
17737
|
const handleCardContextMenu = useCallback((cardId, pos) => {
|
|
17635
17738
|
setCardContextMenu({ cardId, x: pos.x, y: pos.y });
|
|
17636
17739
|
setColorSubmenuOpen(false);
|
|
17637
|
-
|
|
17638
|
-
|
|
17740
|
+
setTypeSubmenuOpen(false);
|
|
17741
|
+
if (onCardContextMenu) {
|
|
17742
|
+
onCardContextMenu(cardId, pos);
|
|
17743
|
+
}
|
|
17744
|
+
}, [onCardContextMenu]);
|
|
17639
17745
|
const closeCardContextMenu = useCallback(() => {
|
|
17640
17746
|
setCardContextMenu(null);
|
|
17641
17747
|
setColorSubmenuOpen(false);
|
|
17642
|
-
|
|
17748
|
+
setTypeSubmenuOpen(false);
|
|
17643
17749
|
}, []);
|
|
17644
17750
|
useEffect(() => {
|
|
17645
17751
|
if (!cardContextMenu) return;
|
|
17646
|
-
const
|
|
17752
|
+
const handleDocumentClick = () => {
|
|
17647
17753
|
closeCardContextMenu();
|
|
17648
17754
|
};
|
|
17649
|
-
|
|
17650
|
-
document.addEventListener("click", handleClick);
|
|
17651
|
-
document.addEventListener("contextmenu", handleClick);
|
|
17652
|
-
}, 0);
|
|
17755
|
+
document.addEventListener("click", handleDocumentClick);
|
|
17653
17756
|
return () => {
|
|
17654
|
-
|
|
17655
|
-
document.removeEventListener("click", handleClick);
|
|
17656
|
-
document.removeEventListener("contextmenu", handleClick);
|
|
17757
|
+
document.removeEventListener("click", handleDocumentClick);
|
|
17657
17758
|
};
|
|
17658
17759
|
}, [cardContextMenu, closeCardContextMenu]);
|
|
17659
|
-
const
|
|
17660
|
-
|
|
17661
|
-
if (cardContextMenu) {
|
|
17662
|
-
const newId = `card-${Date.now()}-dup`;
|
|
17663
|
-
dispatch({ type: "DUPLICATE_CARD", cardId: cardContextMenu.cardId, newId });
|
|
17664
|
-
}
|
|
17665
|
-
closeCardContextMenu();
|
|
17666
|
-
}, [cardContextMenu, dispatch, closeCardContextMenu]);
|
|
17667
|
-
const handleCtxDeleteClick = useCallback((e) => {
|
|
17668
|
-
e.stopPropagation();
|
|
17669
|
-
if (cardContextMenu) {
|
|
17670
|
-
dispatch({ type: "REMOVE_CARD", cardId: cardContextMenu.cardId });
|
|
17671
|
-
if (selectedCardId === cardContextMenu.cardId) onSelectCard(null);
|
|
17672
|
-
}
|
|
17760
|
+
const handleLinkContextMenu = useCallback((linkId, cardId, pos) => {
|
|
17761
|
+
setLinkContextMenu({ linkId, cardId, x: pos.x, y: pos.y });
|
|
17673
17762
|
closeCardContextMenu();
|
|
17674
|
-
}, [
|
|
17675
|
-
const
|
|
17676
|
-
|
|
17677
|
-
setPrioritySubmenuOpen(false);
|
|
17678
|
-
}, []);
|
|
17679
|
-
const handleCtxPriorityMenuEnter = useCallback(() => {
|
|
17680
|
-
setPrioritySubmenuOpen(true);
|
|
17681
|
-
setColorSubmenuOpen(false);
|
|
17763
|
+
}, [closeCardContextMenu]);
|
|
17764
|
+
const closeLinkContextMenu = useCallback(() => {
|
|
17765
|
+
setLinkContextMenu(null);
|
|
17682
17766
|
}, []);
|
|
17683
|
-
|
|
17684
|
-
if (
|
|
17685
|
-
|
|
17686
|
-
|
|
17687
|
-
|
|
17688
|
-
}, [
|
|
17689
|
-
const
|
|
17690
|
-
if (
|
|
17691
|
-
|
|
17767
|
+
useEffect(() => {
|
|
17768
|
+
if (!linkContextMenu) return;
|
|
17769
|
+
const handleDocumentClick = () => closeLinkContextMenu();
|
|
17770
|
+
document.addEventListener("click", handleDocumentClick);
|
|
17771
|
+
return () => document.removeEventListener("click", handleDocumentClick);
|
|
17772
|
+
}, [linkContextMenu, closeLinkContextMenu]);
|
|
17773
|
+
const handleSelectItem = useCallback((itemId) => {
|
|
17774
|
+
if (onSelectItem) onSelectItem(itemId);
|
|
17775
|
+
}, [onSelectItem]);
|
|
17776
|
+
const handleMoveItem = useCallback((itemId, position) => {
|
|
17777
|
+
let pos = position;
|
|
17778
|
+
if (gridEnabled) {
|
|
17779
|
+
pos = snapToGrid(position, GRID_SIZE);
|
|
17780
|
+
}
|
|
17781
|
+
dispatch({ type: "MOVE_ITEM", itemId, position: pos });
|
|
17782
|
+
if (draggingCardId === itemId) {
|
|
17783
|
+
let cardWidth = 0;
|
|
17784
|
+
let cardHeight = 0;
|
|
17785
|
+
const searchStack = [...collection];
|
|
17786
|
+
while (searchStack.length > 0) {
|
|
17787
|
+
const si = searchStack.pop();
|
|
17788
|
+
if (isCard(si) && si.card_id === itemId) {
|
|
17789
|
+
cardWidth = si.size.width;
|
|
17790
|
+
cardHeight = si.size.height;
|
|
17791
|
+
break;
|
|
17792
|
+
}
|
|
17793
|
+
if (isContainer(si)) {
|
|
17794
|
+
for (let k = 0; k < si.contents.length; k++) searchStack.push(si.contents[k]);
|
|
17795
|
+
}
|
|
17796
|
+
}
|
|
17797
|
+
const centerX = pos.x + cardWidth / 2;
|
|
17798
|
+
const centerY = pos.y + cardHeight / 2;
|
|
17799
|
+
const containerId = findContainerAtPoint(collection, centerX, centerY, itemId);
|
|
17800
|
+
setDropTargetId(containerId);
|
|
17692
17801
|
}
|
|
17693
|
-
|
|
17694
|
-
|
|
17695
|
-
|
|
17696
|
-
|
|
17802
|
+
}, [dispatch, gridEnabled, draggingCardId, collection]);
|
|
17803
|
+
const handleResizeItem = useCallback((itemId, size) => {
|
|
17804
|
+
dispatch({ type: "RESIZE_ITEM", itemId, size });
|
|
17805
|
+
}, [dispatch]);
|
|
17806
|
+
const handleDeleteItem = useCallback((itemId) => {
|
|
17807
|
+
dispatch({ type: "REMOVE_ITEM", itemId });
|
|
17808
|
+
if (onSelectItem && selectedId === itemId) onSelectItem(null);
|
|
17809
|
+
}, [dispatch, selectedId, onSelectItem]);
|
|
17810
|
+
const handleDropIntoContainer = useCallback((itemId, containerId) => {
|
|
17811
|
+
dispatch({ type: "NEST_ITEM", itemId, containerId });
|
|
17812
|
+
}, [dispatch]);
|
|
17813
|
+
const handleCardDragStart = useCallback((cardId) => {
|
|
17814
|
+
setDraggingCardId(cardId);
|
|
17815
|
+
setDropTargetId(null);
|
|
17816
|
+
}, []);
|
|
17817
|
+
const dropTargetIdRef = useRef(null);
|
|
17818
|
+
dropTargetIdRef.current = dropTargetId;
|
|
17819
|
+
const handleCardDragEnd = useCallback((cardId) => {
|
|
17820
|
+
const target = dropTargetIdRef.current;
|
|
17821
|
+
if (target) {
|
|
17822
|
+
dispatch({ type: "NEST_ITEM", itemId: cardId, containerId: target });
|
|
17823
|
+
}
|
|
17824
|
+
setDraggingCardId(null);
|
|
17825
|
+
setDropTargetId(null);
|
|
17826
|
+
}, [dispatch]);
|
|
17827
|
+
const handleAnchorDragStart = useCallback((cardId, anchor, pos) => {
|
|
17828
|
+
setLinkDrag({
|
|
17697
17829
|
fromCardId: cardId,
|
|
17698
17830
|
fromAnchor: anchor,
|
|
17699
|
-
|
|
17700
|
-
|
|
17701
|
-
toX: ax,
|
|
17702
|
-
toY: ay
|
|
17831
|
+
fromPos: pos,
|
|
17832
|
+
currentPos: pos
|
|
17703
17833
|
});
|
|
17704
17834
|
}, []);
|
|
17835
|
+
const linkDragRef = useRef(null);
|
|
17836
|
+
linkDragRef.current = linkDrag;
|
|
17705
17837
|
useEffect(() => {
|
|
17706
|
-
if (!
|
|
17838
|
+
if (!linkDrag) return;
|
|
17707
17839
|
const handleMouseMove = (e) => {
|
|
17708
17840
|
const me = e;
|
|
17709
|
-
|
|
17710
|
-
|
|
17711
|
-
|
|
17712
|
-
|
|
17713
|
-
|
|
17714
|
-
|
|
17715
|
-
}
|
|
17841
|
+
let offsetX = 0;
|
|
17842
|
+
let offsetY = 0;
|
|
17843
|
+
if (containerRef.current) {
|
|
17844
|
+
const rect = containerRef.current.getBoundingClientRect();
|
|
17845
|
+
offsetX = rect.left;
|
|
17846
|
+
offsetY = rect.top;
|
|
17847
|
+
}
|
|
17848
|
+
const canvasPos = screenToCanvas(me.clientX - offsetX, me.clientY - offsetY, viewport);
|
|
17849
|
+
setLinkDrag((prev) => prev ? { ...prev, currentPos: canvasPos } : null);
|
|
17716
17850
|
};
|
|
17717
17851
|
const handleMouseUp = (e) => {
|
|
17718
17852
|
const me = e;
|
|
17719
|
-
|
|
17720
|
-
|
|
17721
|
-
|
|
17722
|
-
|
|
17723
|
-
|
|
17724
|
-
|
|
17725
|
-
|
|
17726
|
-
|
|
17853
|
+
const current = linkDragRef.current;
|
|
17854
|
+
if (!current) {
|
|
17855
|
+
setLinkDrag(null);
|
|
17856
|
+
return;
|
|
17857
|
+
}
|
|
17858
|
+
const el = document.elementFromPoint(me.clientX, me.clientY);
|
|
17859
|
+
if (el && el.dataset && el.dataset.role === "anchor" && el.dataset.anchor) {
|
|
17860
|
+
const cardEl = el.closest("[data-card-id]");
|
|
17861
|
+
if (cardEl && cardEl.dataset.cardId && cardEl.dataset.cardId !== current.fromCardId) {
|
|
17862
|
+
const targetCardId = cardEl.dataset.cardId;
|
|
17727
17863
|
dispatch({
|
|
17728
|
-
type: "
|
|
17729
|
-
|
|
17730
|
-
|
|
17731
|
-
|
|
17732
|
-
|
|
17864
|
+
type: "ADD_LINK",
|
|
17865
|
+
cardId: current.fromCardId,
|
|
17866
|
+
link: {
|
|
17867
|
+
link_id: generateUUID(),
|
|
17868
|
+
link_name: "relates to",
|
|
17869
|
+
target_card_id: targetCardId,
|
|
17870
|
+
color: "#94a3b8",
|
|
17871
|
+
attributes: {}
|
|
17733
17872
|
}
|
|
17734
17873
|
});
|
|
17735
17874
|
}
|
|
17736
17875
|
}
|
|
17737
|
-
|
|
17876
|
+
setLinkDrag(null);
|
|
17738
17877
|
};
|
|
17739
17878
|
document.addEventListener("mousemove", handleMouseMove);
|
|
17740
17879
|
document.addEventListener("mouseup", handleMouseUp);
|
|
@@ -17742,109 +17881,109 @@ function Board(props) {
|
|
|
17742
17881
|
document.removeEventListener("mousemove", handleMouseMove);
|
|
17743
17882
|
document.removeEventListener("mouseup", handleMouseUp);
|
|
17744
17883
|
};
|
|
17745
|
-
}, [
|
|
17884
|
+
}, [linkDrag !== null, viewport.panX, viewport.panY, viewport.zoom, dispatch]);
|
|
17746
17885
|
const lowerSearch = searchQuery.toLowerCase();
|
|
17747
|
-
const
|
|
17748
|
-
const
|
|
17749
|
-
|
|
17750
|
-
|
|
17751
|
-
|
|
17752
|
-
|
|
17886
|
+
const dimmedIds = /* @__PURE__ */ new Set();
|
|
17887
|
+
const allItems = [];
|
|
17888
|
+
const itemStack = [...collection];
|
|
17889
|
+
while (itemStack.length > 0) {
|
|
17890
|
+
const item = itemStack.pop();
|
|
17891
|
+
allItems.push(item);
|
|
17892
|
+
if (isContainer(item)) {
|
|
17893
|
+
for (let i = 0; i < item.contents.length; i++) {
|
|
17894
|
+
itemStack.push(item.contents[i]);
|
|
17753
17895
|
}
|
|
17754
17896
|
}
|
|
17755
17897
|
}
|
|
17756
|
-
if (
|
|
17757
|
-
for (let i = 0; i <
|
|
17758
|
-
|
|
17759
|
-
|
|
17898
|
+
if (lowerSearch) {
|
|
17899
|
+
for (let i = 0; i < allItems.length; i++) {
|
|
17900
|
+
const item = allItems[i];
|
|
17901
|
+
const name = isCard(item) ? item.card_title : item.name;
|
|
17902
|
+
if (!name.toLowerCase().includes(lowerSearch)) {
|
|
17903
|
+
dimmedIds.add(getItemId(item));
|
|
17760
17904
|
}
|
|
17761
17905
|
}
|
|
17762
17906
|
}
|
|
17763
|
-
|
|
17764
|
-
|
|
17765
|
-
|
|
17766
|
-
|
|
17767
|
-
|
|
17768
|
-
|
|
17769
|
-
|
|
17770
|
-
|
|
17771
|
-
};
|
|
17772
|
-
|
|
17773
|
-
|
|
17774
|
-
|
|
17775
|
-
|
|
17776
|
-
|
|
17777
|
-
|
|
17778
|
-
|
|
17779
|
-
|
|
17780
|
-
|
|
17781
|
-
|
|
17782
|
-
|
|
17783
|
-
|
|
17784
|
-
|
|
17785
|
-
|
|
17786
|
-
|
|
17787
|
-
|
|
17788
|
-
|
|
17789
|
-
|
|
17790
|
-
|
|
17791
|
-
|
|
17792
|
-
|
|
17793
|
-
|
|
17794
|
-
|
|
17795
|
-
|
|
17796
|
-
|
|
17907
|
+
if (colorFilter) {
|
|
17908
|
+
for (let i = 0; i < allItems.length; i++) {
|
|
17909
|
+
const item = allItems[i];
|
|
17910
|
+
if (isCard(item) && item.color !== colorFilter) {
|
|
17911
|
+
dimmedIds.add(item.card_id);
|
|
17912
|
+
}
|
|
17913
|
+
}
|
|
17914
|
+
}
|
|
17915
|
+
const { cards: allCards, links: allLinks } = collectCardsAndLinks(collection);
|
|
17916
|
+
function renderItem(item) {
|
|
17917
|
+
const id = getItemId(item);
|
|
17918
|
+
const isDimmed = dimmedIds.has(id);
|
|
17919
|
+
let el;
|
|
17920
|
+
if (isCard(item)) {
|
|
17921
|
+
el = createElement(CardComponent, {
|
|
17922
|
+
key: id,
|
|
17923
|
+
card: item,
|
|
17924
|
+
selected: id === selectedId,
|
|
17925
|
+
onSelect: handleSelectItem,
|
|
17926
|
+
onMove: handleMoveItem,
|
|
17927
|
+
onResize: handleResizeItem,
|
|
17928
|
+
onDelete: handleDeleteItem,
|
|
17929
|
+
dispatch,
|
|
17930
|
+
onOpenProject,
|
|
17931
|
+
onCardContextMenu: handleCardContextMenu,
|
|
17932
|
+
onUpdate: onUpdateItem,
|
|
17933
|
+
onDragStart: handleCardDragStart,
|
|
17934
|
+
onDragEnd: handleCardDragEnd,
|
|
17935
|
+
onAnchorDragStart: handleAnchorDragStart
|
|
17936
|
+
});
|
|
17937
|
+
} else {
|
|
17938
|
+
const childElements = item.contents.map((child) => renderItem(child));
|
|
17939
|
+
el = createElement(ContainerComponent, {
|
|
17940
|
+
key: id,
|
|
17941
|
+
container: item,
|
|
17942
|
+
selected: id === selectedId,
|
|
17943
|
+
highlighted: dropTargetId === item.container_id,
|
|
17944
|
+
onSelect: handleSelectItem,
|
|
17945
|
+
onMove: handleMoveItem,
|
|
17946
|
+
onResize: handleResizeItem,
|
|
17947
|
+
onDelete: handleDeleteItem,
|
|
17948
|
+
onDrop: handleDropIntoContainer
|
|
17949
|
+
}, ...childElements);
|
|
17950
|
+
}
|
|
17797
17951
|
if (isDimmed) {
|
|
17798
17952
|
return createElement("div", {
|
|
17799
|
-
key: `dim-${
|
|
17800
|
-
style: { opacity: "0.3" }
|
|
17801
|
-
},
|
|
17802
|
-
}
|
|
17803
|
-
return
|
|
17804
|
-
}
|
|
17805
|
-
const
|
|
17806
|
-
const
|
|
17807
|
-
|
|
17808
|
-
|
|
17809
|
-
|
|
17810
|
-
|
|
17811
|
-
|
|
17812
|
-
"
|
|
17813
|
-
{
|
|
17814
|
-
|
|
17815
|
-
|
|
17816
|
-
|
|
17817
|
-
|
|
17818
|
-
|
|
17819
|
-
|
|
17820
|
-
|
|
17821
|
-
|
|
17822
|
-
zIndex: "5"
|
|
17823
|
-
},
|
|
17824
|
-
width: String(CANVAS_SIZE),
|
|
17825
|
-
height: String(CANVAS_SIZE),
|
|
17826
|
-
"data-testid": "connection-drag-line"
|
|
17827
|
-
},
|
|
17828
|
-
createElement("line", {
|
|
17829
|
-
x1: String(connectionDrag.fromX),
|
|
17830
|
-
y1: String(connectionDrag.fromY),
|
|
17831
|
-
x2: String(connectionDrag.toX),
|
|
17832
|
-
y2: String(connectionDrag.toY),
|
|
17833
|
-
stroke: "#3b82f6",
|
|
17834
|
-
"stroke-width": "2",
|
|
17835
|
-
"stroke-dasharray": "6,4",
|
|
17836
|
-
"pointer-events": "none"
|
|
17837
|
-
})
|
|
17838
|
-
) : null;
|
|
17953
|
+
key: `dim-${id}`,
|
|
17954
|
+
style: { opacity: "0.3" }
|
|
17955
|
+
}, el);
|
|
17956
|
+
}
|
|
17957
|
+
return el;
|
|
17958
|
+
}
|
|
17959
|
+
const itemElements = collection.map((item) => renderItem(item));
|
|
17960
|
+
const containerStyle3 = {
|
|
17961
|
+
flex: "1",
|
|
17962
|
+
overflow: "hidden",
|
|
17963
|
+
position: "relative",
|
|
17964
|
+
backgroundColor: "#f8fafc",
|
|
17965
|
+
cursor: "default",
|
|
17966
|
+
backgroundImage: gridEnabled ? "radial-gradient(circle, #d1d5db 1px, transparent 1px)" : "none",
|
|
17967
|
+
backgroundSize: `${GRID_SIZE}px ${GRID_SIZE}px`
|
|
17968
|
+
};
|
|
17969
|
+
const transformStyle = {
|
|
17970
|
+
transform: `translate(${viewport.panX}px, ${viewport.panY}px) scale(${viewport.zoom})`,
|
|
17971
|
+
transformOrigin: "0 0",
|
|
17972
|
+
position: "relative",
|
|
17973
|
+
width: `${CANVAS_SIZE}px`,
|
|
17974
|
+
height: `${CANVAS_SIZE}px`
|
|
17975
|
+
};
|
|
17839
17976
|
const ctxMenuItemStyle = {
|
|
17840
17977
|
padding: "6px 12px",
|
|
17841
17978
|
cursor: "pointer",
|
|
17842
17979
|
display: "flex",
|
|
17843
17980
|
alignItems: "center",
|
|
17844
17981
|
justifyContent: "space-between",
|
|
17845
|
-
whiteSpace: "nowrap"
|
|
17982
|
+
whiteSpace: "nowrap",
|
|
17983
|
+
fontSize: "13px",
|
|
17984
|
+
color: "#1a1a1a"
|
|
17846
17985
|
};
|
|
17847
|
-
const
|
|
17986
|
+
const ctxSubmenuStyle = {
|
|
17848
17987
|
position: "absolute",
|
|
17849
17988
|
left: "100%",
|
|
17850
17989
|
top: "0",
|
|
@@ -17855,11 +17994,15 @@ function Board(props) {
|
|
|
17855
17994
|
padding: "4px 0",
|
|
17856
17995
|
minWidth: "120px"
|
|
17857
17996
|
};
|
|
17858
|
-
const
|
|
17859
|
-
|
|
17997
|
+
const ctxSeparatorStyle = {
|
|
17998
|
+
height: "1px",
|
|
17999
|
+
backgroundColor: "#e5e7eb",
|
|
18000
|
+
margin: "4px 0"
|
|
18001
|
+
};
|
|
18002
|
+
const boardContextMenuEl = cardContextMenu ? createElement(
|
|
17860
18003
|
"div",
|
|
17861
18004
|
{
|
|
17862
|
-
className: "
|
|
18005
|
+
className: "board-context-menu",
|
|
17863
18006
|
style: {
|
|
17864
18007
|
position: "fixed",
|
|
17865
18008
|
left: `${cardContextMenu.x}px`,
|
|
@@ -17874,240 +18017,792 @@ function Board(props) {
|
|
|
17874
18017
|
fontSize: "13px",
|
|
17875
18018
|
color: "#1a1a1a"
|
|
17876
18019
|
},
|
|
17877
|
-
"data-testid": `context-menu-${cardContextMenu.cardId}`,
|
|
18020
|
+
"data-testid": `board-context-menu-${cardContextMenu.cardId}`,
|
|
17878
18021
|
role: "menu",
|
|
17879
|
-
"aria-label": "Card context menu"
|
|
18022
|
+
"aria-label": "Card context menu",
|
|
18023
|
+
onClick: (e) => e.stopPropagation()
|
|
17880
18024
|
},
|
|
17881
|
-
// Duplicate
|
|
17882
|
-
createElement("div", {
|
|
17883
|
-
style: ctxMenuItemStyle,
|
|
17884
|
-
onClick: handleCtxDuplicateClick,
|
|
17885
|
-
role: "menuitem",
|
|
17886
|
-
"data-testid": `context-menu-duplicate-${cardContextMenu.cardId}`
|
|
17887
|
-
}, "Duplicate"),
|
|
17888
|
-
// Delete
|
|
17889
|
-
createElement("div", {
|
|
17890
|
-
style: ctxMenuItemStyle,
|
|
17891
|
-
onClick: handleCtxDeleteClick,
|
|
17892
|
-
role: "menuitem",
|
|
17893
|
-
"data-testid": `context-menu-delete-${cardContextMenu.cardId}`
|
|
17894
|
-
}, "Delete"),
|
|
17895
18025
|
// Change Color submenu
|
|
17896
18026
|
createElement(
|
|
17897
18027
|
"div",
|
|
17898
18028
|
{
|
|
17899
18029
|
style: { ...ctxMenuItemStyle, position: "relative" },
|
|
17900
|
-
onMouseEnter:
|
|
18030
|
+
onMouseEnter: () => {
|
|
18031
|
+
setColorSubmenuOpen(true);
|
|
18032
|
+
setTypeSubmenuOpen(false);
|
|
18033
|
+
},
|
|
17901
18034
|
role: "menuitem",
|
|
17902
18035
|
"aria-haspopup": "true",
|
|
17903
|
-
"data-testid": `
|
|
18036
|
+
"data-testid": `board-ctx-change-color-${cardContextMenu.cardId}`
|
|
17904
18037
|
},
|
|
17905
18038
|
"Change Color",
|
|
17906
18039
|
createElement("span", { style: { marginLeft: "8px" } }, "\u25B6"),
|
|
17907
18040
|
colorSubmenuOpen ? createElement(
|
|
17908
18041
|
"div",
|
|
17909
18042
|
{
|
|
17910
|
-
style:
|
|
18043
|
+
style: ctxSubmenuStyle,
|
|
17911
18044
|
role: "menu",
|
|
17912
|
-
"data-testid": `
|
|
18045
|
+
"data-testid": `board-ctx-color-submenu-${cardContextMenu.cardId}`
|
|
17913
18046
|
},
|
|
17914
|
-
...
|
|
17915
|
-
(
|
|
18047
|
+
...CONTEXT_COLORS.map(
|
|
18048
|
+
(opt) => createElement(
|
|
17916
18049
|
"div",
|
|
17917
18050
|
{
|
|
17918
|
-
key:
|
|
18051
|
+
key: opt.value,
|
|
17919
18052
|
style: {
|
|
17920
18053
|
...ctxMenuItemStyle,
|
|
17921
18054
|
gap: "8px"
|
|
17922
18055
|
},
|
|
17923
18056
|
onClick: (e) => {
|
|
17924
18057
|
e.stopPropagation();
|
|
17925
|
-
|
|
18058
|
+
dispatch({ type: "UPDATE_CARD", cardId: cardContextMenu.cardId, updates: { color: opt.value } });
|
|
18059
|
+
closeCardContextMenu();
|
|
17926
18060
|
},
|
|
17927
18061
|
role: "menuitem",
|
|
17928
|
-
"data-testid": `
|
|
18062
|
+
"data-testid": `board-ctx-color-${opt.label.toLowerCase()}-${cardContextMenu.cardId}`
|
|
17929
18063
|
},
|
|
17930
18064
|
createElement("span", {
|
|
17931
18065
|
style: {
|
|
18066
|
+
display: "inline-block",
|
|
17932
18067
|
width: "14px",
|
|
17933
18068
|
height: "14px",
|
|
17934
|
-
borderRadius: "
|
|
17935
|
-
backgroundColor:
|
|
17936
|
-
border: "1px solid
|
|
17937
|
-
display: "inline-block",
|
|
18069
|
+
borderRadius: "3px",
|
|
18070
|
+
backgroundColor: opt.value,
|
|
18071
|
+
border: "1px solid #d1d5db",
|
|
17938
18072
|
flexShrink: "0"
|
|
17939
18073
|
}
|
|
17940
18074
|
}),
|
|
17941
|
-
|
|
18075
|
+
opt.label
|
|
17942
18076
|
)
|
|
17943
18077
|
)
|
|
17944
18078
|
) : null
|
|
17945
18079
|
),
|
|
17946
|
-
//
|
|
18080
|
+
// Change Type submenu
|
|
17947
18081
|
createElement(
|
|
17948
18082
|
"div",
|
|
17949
18083
|
{
|
|
17950
18084
|
style: { ...ctxMenuItemStyle, position: "relative" },
|
|
17951
|
-
onMouseEnter:
|
|
18085
|
+
onMouseEnter: () => {
|
|
18086
|
+
setTypeSubmenuOpen(true);
|
|
18087
|
+
setColorSubmenuOpen(false);
|
|
18088
|
+
},
|
|
17952
18089
|
role: "menuitem",
|
|
17953
18090
|
"aria-haspopup": "true",
|
|
17954
|
-
"data-testid": `
|
|
18091
|
+
"data-testid": `board-ctx-change-type-${cardContextMenu.cardId}`
|
|
18092
|
+
},
|
|
18093
|
+
"Change Type",
|
|
18094
|
+
createElement("span", { style: { marginLeft: "8px" } }, "\u25B6"),
|
|
18095
|
+
typeSubmenuOpen ? createElement(
|
|
18096
|
+
"div",
|
|
18097
|
+
{
|
|
18098
|
+
style: ctxSubmenuStyle,
|
|
18099
|
+
role: "menu",
|
|
18100
|
+
"data-testid": `board-ctx-type-submenu-${cardContextMenu.cardId}`
|
|
18101
|
+
},
|
|
18102
|
+
...CARD_TYPE_OPTIONS.map(
|
|
18103
|
+
(opt) => createElement("div", {
|
|
18104
|
+
key: opt.value,
|
|
18105
|
+
style: ctxMenuItemStyle,
|
|
18106
|
+
onClick: (e) => {
|
|
18107
|
+
e.stopPropagation();
|
|
18108
|
+
dispatch({ type: "CHANGE_CARD_TYPE", cardId: cardContextMenu.cardId, newType: opt.value });
|
|
18109
|
+
closeCardContextMenu();
|
|
18110
|
+
},
|
|
18111
|
+
role: "menuitem",
|
|
18112
|
+
"data-testid": `board-ctx-type-${opt.value}-${cardContextMenu.cardId}`
|
|
18113
|
+
}, opt.label)
|
|
18114
|
+
)
|
|
18115
|
+
) : null
|
|
18116
|
+
),
|
|
18117
|
+
// Separator
|
|
18118
|
+
createElement("div", { style: ctxSeparatorStyle, role: "separator" }),
|
|
18119
|
+
// Delete
|
|
18120
|
+
createElement("div", {
|
|
18121
|
+
style: { ...ctxMenuItemStyle, color: "#dc2626" },
|
|
18122
|
+
onClick: (e) => {
|
|
18123
|
+
e.stopPropagation();
|
|
18124
|
+
dispatch({ type: "REMOVE_ITEM", itemId: cardContextMenu.cardId });
|
|
18125
|
+
if (onSelectItem && selectedId === cardContextMenu.cardId) onSelectItem(null);
|
|
18126
|
+
closeCardContextMenu();
|
|
18127
|
+
},
|
|
18128
|
+
role: "menuitem",
|
|
18129
|
+
"data-testid": `board-ctx-delete-${cardContextMenu.cardId}`
|
|
18130
|
+
}, "Delete")
|
|
18131
|
+
) : null;
|
|
18132
|
+
const EDGE_TYPES = [
|
|
18133
|
+
"relates to",
|
|
18134
|
+
"depends on",
|
|
18135
|
+
"blocks",
|
|
18136
|
+
"is blocked by",
|
|
18137
|
+
"implements",
|
|
18138
|
+
"is implemented by",
|
|
18139
|
+
"extends",
|
|
18140
|
+
"includes",
|
|
18141
|
+
"references",
|
|
18142
|
+
"duplicates",
|
|
18143
|
+
"parent of",
|
|
18144
|
+
"child of"
|
|
18145
|
+
];
|
|
18146
|
+
const linkContextMenuEl = linkContextMenu ? createElement(
|
|
18147
|
+
"div",
|
|
18148
|
+
{
|
|
18149
|
+
className: "board-link-context-menu",
|
|
18150
|
+
style: {
|
|
18151
|
+
position: "fixed",
|
|
18152
|
+
left: `${linkContextMenu.x}px`,
|
|
18153
|
+
top: `${linkContextMenu.y}px`,
|
|
18154
|
+
backgroundColor: "#ffffff",
|
|
18155
|
+
border: "1px solid #d1d5db",
|
|
18156
|
+
borderRadius: "6px",
|
|
18157
|
+
boxShadow: "0 4px 16px rgba(0,0,0,0.15)",
|
|
18158
|
+
padding: "4px 0",
|
|
18159
|
+
minWidth: "180px",
|
|
18160
|
+
maxHeight: "240px",
|
|
18161
|
+
overflowY: "auto",
|
|
18162
|
+
zIndex: "10001",
|
|
18163
|
+
fontSize: "13px"
|
|
18164
|
+
},
|
|
18165
|
+
onClick: (e) => e.stopPropagation()
|
|
18166
|
+
},
|
|
18167
|
+
createElement("div", {
|
|
18168
|
+
style: { padding: "4px 14px", fontSize: "11px", color: "#94a3b8", fontWeight: "600" }
|
|
18169
|
+
}, "Edge Type"),
|
|
18170
|
+
...EDGE_TYPES.map(
|
|
18171
|
+
(edgeType) => createElement("button", {
|
|
18172
|
+
key: edgeType,
|
|
18173
|
+
style: {
|
|
18174
|
+
display: "block",
|
|
18175
|
+
width: "100%",
|
|
18176
|
+
padding: "6px 14px",
|
|
18177
|
+
border: "none",
|
|
18178
|
+
backgroundColor: "transparent",
|
|
18179
|
+
textAlign: "left",
|
|
18180
|
+
cursor: "pointer",
|
|
18181
|
+
fontSize: "13px",
|
|
18182
|
+
color: "#334155",
|
|
18183
|
+
fontFamily: "inherit",
|
|
18184
|
+
boxSizing: "border-box"
|
|
18185
|
+
},
|
|
18186
|
+
onClick: () => {
|
|
18187
|
+
dispatch({
|
|
18188
|
+
type: "UPDATE_CARD",
|
|
18189
|
+
cardId: linkContextMenu.cardId,
|
|
18190
|
+
updates: {
|
|
18191
|
+
card_link: (() => {
|
|
18192
|
+
let targetCard = null;
|
|
18193
|
+
const stack = [...collection];
|
|
18194
|
+
while (stack.length > 0) {
|
|
18195
|
+
const item = stack.pop();
|
|
18196
|
+
if (isCard(item) && item.card_id === linkContextMenu.cardId) {
|
|
18197
|
+
targetCard = item;
|
|
18198
|
+
break;
|
|
18199
|
+
}
|
|
18200
|
+
if (isContainer(item)) {
|
|
18201
|
+
for (const child of item.contents) stack.push(child);
|
|
18202
|
+
}
|
|
18203
|
+
}
|
|
18204
|
+
if (!targetCard) return [];
|
|
18205
|
+
return targetCard.card_link.map(
|
|
18206
|
+
(l) => l.link_id === linkContextMenu.linkId ? { ...l, link_name: edgeType } : l
|
|
18207
|
+
);
|
|
18208
|
+
})()
|
|
18209
|
+
}
|
|
18210
|
+
});
|
|
18211
|
+
closeLinkContextMenu();
|
|
18212
|
+
},
|
|
18213
|
+
role: "menuitem"
|
|
18214
|
+
}, edgeType)
|
|
18215
|
+
),
|
|
18216
|
+
createElement("div", { style: { height: "1px", backgroundColor: "#e5e7eb", margin: "4px 0" } }),
|
|
18217
|
+
createElement("button", {
|
|
18218
|
+
style: {
|
|
18219
|
+
display: "block",
|
|
18220
|
+
width: "100%",
|
|
18221
|
+
padding: "6px 14px",
|
|
18222
|
+
border: "none",
|
|
18223
|
+
backgroundColor: "transparent",
|
|
18224
|
+
textAlign: "left",
|
|
18225
|
+
cursor: "pointer",
|
|
18226
|
+
fontSize: "13px",
|
|
18227
|
+
color: "#ef4444",
|
|
18228
|
+
fontFamily: "inherit"
|
|
18229
|
+
},
|
|
18230
|
+
onClick: () => {
|
|
18231
|
+
dispatch({ type: "REMOVE_LINK", cardId: linkContextMenu.cardId, linkId: linkContextMenu.linkId });
|
|
18232
|
+
closeLinkContextMenu();
|
|
18233
|
+
},
|
|
18234
|
+
role: "menuitem"
|
|
18235
|
+
}, "Delete Link")
|
|
18236
|
+
) : null;
|
|
18237
|
+
return createElement(
|
|
18238
|
+
"div",
|
|
18239
|
+
{
|
|
18240
|
+
ref: containerRef,
|
|
18241
|
+
className: "board-canvas",
|
|
18242
|
+
style: containerStyle3,
|
|
18243
|
+
onMouseDown: handleCanvasMouseDown,
|
|
18244
|
+
onWheel: handleWheel,
|
|
18245
|
+
"data-testid": "board-canvas",
|
|
18246
|
+
role: "application",
|
|
18247
|
+
"aria-label": `Board: ${state.name}`,
|
|
18248
|
+
tabIndex: 0
|
|
18249
|
+
},
|
|
18250
|
+
createElement(
|
|
18251
|
+
"div",
|
|
18252
|
+
{
|
|
18253
|
+
className: "board-canvas__inner",
|
|
18254
|
+
style: transformStyle,
|
|
18255
|
+
"data-testid": "board-canvas-inner"
|
|
18256
|
+
},
|
|
18257
|
+
createElement(CardLinkOverlay, {
|
|
18258
|
+
links: allLinks,
|
|
18259
|
+
cards: allCards,
|
|
18260
|
+
selectedLinkId: null,
|
|
18261
|
+
onSelectLink: () => {
|
|
18262
|
+
},
|
|
18263
|
+
onLinkContextMenu: handleLinkContextMenu,
|
|
18264
|
+
canvasWidth: CANVAS_SIZE,
|
|
18265
|
+
canvasHeight: CANVAS_SIZE
|
|
18266
|
+
}),
|
|
18267
|
+
linkDrag ? createElement(
|
|
18268
|
+
"svg",
|
|
18269
|
+
{
|
|
18270
|
+
style: {
|
|
18271
|
+
position: "absolute",
|
|
18272
|
+
top: "0",
|
|
18273
|
+
left: "0",
|
|
18274
|
+
width: "100%",
|
|
18275
|
+
height: "100%",
|
|
18276
|
+
pointerEvents: "none",
|
|
18277
|
+
overflow: "visible"
|
|
18278
|
+
},
|
|
18279
|
+
width: String(CANVAS_SIZE),
|
|
18280
|
+
height: String(CANVAS_SIZE),
|
|
18281
|
+
className: "link-drag-overlay",
|
|
18282
|
+
"data-testid": "link-drag-overlay"
|
|
18283
|
+
},
|
|
18284
|
+
createElement("line", {
|
|
18285
|
+
x1: String(linkDrag.fromPos.x),
|
|
18286
|
+
y1: String(linkDrag.fromPos.y),
|
|
18287
|
+
x2: String(linkDrag.currentPos.x),
|
|
18288
|
+
y2: String(linkDrag.currentPos.y),
|
|
18289
|
+
stroke: "#3b82f6",
|
|
18290
|
+
"stroke-width": "2",
|
|
18291
|
+
"stroke-dasharray": "6 4",
|
|
18292
|
+
"pointer-events": "none",
|
|
18293
|
+
"data-testid": "link-drag-line"
|
|
18294
|
+
})
|
|
18295
|
+
) : null,
|
|
18296
|
+
...itemElements
|
|
18297
|
+
),
|
|
18298
|
+
boardContextMenuEl,
|
|
18299
|
+
linkContextMenuEl
|
|
18300
|
+
);
|
|
18301
|
+
}
|
|
18302
|
+
|
|
18303
|
+
// ../demos/project-manager/src/Board.ts
|
|
18304
|
+
function collectAllCards(items) {
|
|
18305
|
+
const cards = [];
|
|
18306
|
+
const stack = [...items];
|
|
18307
|
+
while (stack.length > 0) {
|
|
18308
|
+
const item = stack.pop();
|
|
18309
|
+
if (isCard(item)) {
|
|
18310
|
+
cards.push(item);
|
|
18311
|
+
} else if (isContainer(item)) {
|
|
18312
|
+
for (let i = item.contents.length - 1; i >= 0; i--) {
|
|
18313
|
+
stack.push(item.contents[i]);
|
|
18314
|
+
}
|
|
18315
|
+
}
|
|
18316
|
+
}
|
|
18317
|
+
return cards;
|
|
18318
|
+
}
|
|
18319
|
+
function computeFitAll(collection, containerWidth, containerHeight, padding) {
|
|
18320
|
+
const pad3 = padding ?? 40;
|
|
18321
|
+
const cards = collectAllCards(collection);
|
|
18322
|
+
if (cards.length === 0) {
|
|
18323
|
+
return { panX: 0, panY: 0, zoom: 1 };
|
|
18324
|
+
}
|
|
18325
|
+
let minX = Infinity;
|
|
18326
|
+
let minY = Infinity;
|
|
18327
|
+
let maxX = -Infinity;
|
|
18328
|
+
let maxY = -Infinity;
|
|
18329
|
+
for (let i = 0; i < cards.length; i++) {
|
|
18330
|
+
const c = cards[i];
|
|
18331
|
+
if (c.position.x < minX) minX = c.position.x;
|
|
18332
|
+
if (c.position.y < minY) minY = c.position.y;
|
|
18333
|
+
const right = c.position.x + c.size.width;
|
|
18334
|
+
const bottom = c.position.y + c.size.height;
|
|
18335
|
+
if (right > maxX) maxX = right;
|
|
18336
|
+
if (bottom > maxY) maxY = bottom;
|
|
18337
|
+
}
|
|
18338
|
+
const contentW = maxX - minX + pad3 * 2;
|
|
18339
|
+
const contentH = maxY - minY + pad3 * 2;
|
|
18340
|
+
const zoomX = containerWidth / contentW;
|
|
18341
|
+
const zoomY = containerHeight / contentH;
|
|
18342
|
+
const zoom = Math.max(0.25, Math.min(4, Math.min(zoomX, zoomY)));
|
|
18343
|
+
const panX = -minX * zoom + (containerWidth - (maxX - minX) * zoom) / 2;
|
|
18344
|
+
const panY = -minY * zoom + (containerHeight - (maxY - minY) * zoom) / 2;
|
|
18345
|
+
return { panX, panY, zoom };
|
|
18346
|
+
}
|
|
18347
|
+
|
|
18348
|
+
// ../demos/project-manager/src/Toolbar.ts
|
|
18349
|
+
var CARD_COLORS = [
|
|
18350
|
+
"#fef9c3",
|
|
18351
|
+
// yellow
|
|
18352
|
+
"#fecaca",
|
|
18353
|
+
// red
|
|
18354
|
+
"#fed7aa",
|
|
18355
|
+
// orange
|
|
18356
|
+
"#bbf7d0",
|
|
18357
|
+
// green
|
|
18358
|
+
"#bfdbfe",
|
|
18359
|
+
// blue
|
|
18360
|
+
"#ddd6fe",
|
|
18361
|
+
// purple
|
|
18362
|
+
"#fbcfe8",
|
|
18363
|
+
// pink
|
|
18364
|
+
"#e5e7eb"
|
|
18365
|
+
// gray
|
|
18366
|
+
];
|
|
18367
|
+
function BoardToolbar(props) {
|
|
18368
|
+
const {
|
|
18369
|
+
zoom,
|
|
18370
|
+
gridEnabled,
|
|
18371
|
+
selectedColor,
|
|
18372
|
+
colorFilter,
|
|
18373
|
+
onNewCard,
|
|
18374
|
+
onZoomIn,
|
|
18375
|
+
onZoomOut,
|
|
18376
|
+
onZoomReset,
|
|
18377
|
+
onColorSelect,
|
|
18378
|
+
onColorFilter,
|
|
18379
|
+
onGridToggle,
|
|
18380
|
+
onSearch
|
|
18381
|
+
} = props;
|
|
18382
|
+
const [searchText, setSearchText] = useState("");
|
|
18383
|
+
const handleSearchInput = useCallback((e) => {
|
|
18384
|
+
const value = e.target.value;
|
|
18385
|
+
setSearchText(value);
|
|
18386
|
+
onSearch(value);
|
|
18387
|
+
}, [onSearch]);
|
|
18388
|
+
const toolbarStyle = {
|
|
18389
|
+
display: "flex",
|
|
18390
|
+
alignItems: "center",
|
|
18391
|
+
gap: "8px",
|
|
18392
|
+
padding: "6px 12px",
|
|
18393
|
+
backgroundColor: "rgba(255,255,255,0.95)",
|
|
18394
|
+
borderBottom: "1px solid #e2e8f0",
|
|
18395
|
+
fontSize: "12px",
|
|
18396
|
+
flexShrink: "0",
|
|
18397
|
+
flexWrap: "wrap"
|
|
18398
|
+
};
|
|
18399
|
+
const btnStyle = {
|
|
18400
|
+
padding: "4px 10px",
|
|
18401
|
+
border: "1px solid #d1d5db",
|
|
18402
|
+
borderRadius: "4px",
|
|
18403
|
+
backgroundColor: "#ffffff",
|
|
18404
|
+
cursor: "pointer",
|
|
18405
|
+
fontSize: "12px",
|
|
18406
|
+
color: "#374151",
|
|
18407
|
+
lineHeight: "1.4"
|
|
18408
|
+
};
|
|
18409
|
+
const activeBtnStyle = {
|
|
18410
|
+
...btnStyle,
|
|
18411
|
+
backgroundColor: "#3b82f6",
|
|
18412
|
+
color: "#ffffff",
|
|
18413
|
+
borderColor: "#3b82f6"
|
|
18414
|
+
};
|
|
18415
|
+
const zoomText = {
|
|
18416
|
+
fontSize: "12px",
|
|
18417
|
+
color: "#64748b",
|
|
18418
|
+
minWidth: "40px",
|
|
18419
|
+
textAlign: "center",
|
|
18420
|
+
cursor: "pointer"
|
|
18421
|
+
};
|
|
18422
|
+
const separatorStyle = {
|
|
18423
|
+
width: "1px",
|
|
18424
|
+
height: "20px",
|
|
18425
|
+
backgroundColor: "#e2e8f0",
|
|
18426
|
+
margin: "0 4px"
|
|
18427
|
+
};
|
|
18428
|
+
const inputStyle = {
|
|
18429
|
+
padding: "4px 8px",
|
|
18430
|
+
border: "1px solid #d1d5db",
|
|
18431
|
+
borderRadius: "4px",
|
|
18432
|
+
fontSize: "12px",
|
|
18433
|
+
width: "120px",
|
|
18434
|
+
outline: "none"
|
|
18435
|
+
};
|
|
18436
|
+
const swatches = CARD_COLORS.map((color) => {
|
|
18437
|
+
const isActive = color === selectedColor;
|
|
18438
|
+
const isFiltered = color === colorFilter;
|
|
18439
|
+
const handleSwatchClick = () => {
|
|
18440
|
+
if (isActive && onColorFilter) {
|
|
18441
|
+
onColorFilter(isFiltered ? null : color);
|
|
18442
|
+
} else {
|
|
18443
|
+
onColorSelect(color);
|
|
18444
|
+
}
|
|
18445
|
+
};
|
|
18446
|
+
let borderStyle = "1px solid rgba(0,0,0,0.15)";
|
|
18447
|
+
if (isFiltered) {
|
|
18448
|
+
borderStyle = "3px solid #ef4444";
|
|
18449
|
+
} else if (isActive) {
|
|
18450
|
+
borderStyle = "2px solid #3b82f6";
|
|
18451
|
+
}
|
|
18452
|
+
return createElement("button", {
|
|
18453
|
+
key: color,
|
|
18454
|
+
title: color,
|
|
18455
|
+
style: {
|
|
18456
|
+
width: "18px",
|
|
18457
|
+
height: "18px",
|
|
18458
|
+
borderRadius: "50%",
|
|
18459
|
+
backgroundColor: color,
|
|
18460
|
+
border: borderStyle,
|
|
18461
|
+
cursor: "pointer",
|
|
18462
|
+
padding: "0",
|
|
18463
|
+
flexShrink: "0",
|
|
18464
|
+
opacity: isFiltered ? "1" : colorFilter ? "0.5" : "1"
|
|
17955
18465
|
},
|
|
17956
|
-
|
|
17957
|
-
|
|
17958
|
-
|
|
17959
|
-
|
|
17960
|
-
|
|
17961
|
-
style: ctxSubmenuContainerStyle,
|
|
17962
|
-
role: "menu",
|
|
17963
|
-
"data-testid": `context-submenu-priority-${cardContextMenu.cardId}`
|
|
17964
|
-
},
|
|
17965
|
-
...PRIORITY_OPTIONS.map(
|
|
17966
|
-
(opt) => createElement(
|
|
17967
|
-
"div",
|
|
17968
|
-
{
|
|
17969
|
-
key: opt.value,
|
|
17970
|
-
style: {
|
|
17971
|
-
...ctxMenuItemStyle,
|
|
17972
|
-
gap: "8px"
|
|
17973
|
-
},
|
|
17974
|
-
onClick: (e) => {
|
|
17975
|
-
e.stopPropagation();
|
|
17976
|
-
handleCtxPrioritySelect(opt.value);
|
|
17977
|
-
},
|
|
17978
|
-
role: "menuitem",
|
|
17979
|
-
"data-testid": `context-priority-${opt.value}`
|
|
17980
|
-
},
|
|
17981
|
-
createElement("span", {
|
|
17982
|
-
style: {
|
|
17983
|
-
width: "8px",
|
|
17984
|
-
height: "8px",
|
|
17985
|
-
borderRadius: "50%",
|
|
17986
|
-
backgroundColor: PRIORITY_COLORS[opt.value] || "#94a3b8",
|
|
17987
|
-
display: "inline-block",
|
|
17988
|
-
flexShrink: "0"
|
|
17989
|
-
}
|
|
17990
|
-
}),
|
|
17991
|
-
opt.label,
|
|
17992
|
-
contextMenuCard && opt.value === contextMenuCard.priority ? " \u2713" : ""
|
|
17993
|
-
)
|
|
17994
|
-
)
|
|
17995
|
-
) : null
|
|
17996
|
-
)
|
|
17997
|
-
) : null;
|
|
18466
|
+
onClick: handleSwatchClick,
|
|
18467
|
+
"aria-label": isFiltered ? `Clear color filter ${color}` : `Select color ${color}`,
|
|
18468
|
+
"data-testid": `color-swatch-${color}`
|
|
18469
|
+
});
|
|
18470
|
+
});
|
|
17998
18471
|
return createElement(
|
|
17999
18472
|
"div",
|
|
18000
18473
|
{
|
|
18001
|
-
|
|
18002
|
-
|
|
18003
|
-
|
|
18004
|
-
|
|
18005
|
-
|
|
18006
|
-
"data-testid": "board-canvas",
|
|
18007
|
-
role: "application",
|
|
18008
|
-
"aria-label": "Project board canvas",
|
|
18009
|
-
tabIndex: 0
|
|
18474
|
+
className: "board-toolbar",
|
|
18475
|
+
style: toolbarStyle,
|
|
18476
|
+
role: "toolbar",
|
|
18477
|
+
"aria-label": "Board toolbar",
|
|
18478
|
+
"data-testid": "board-toolbar"
|
|
18010
18479
|
},
|
|
18011
|
-
|
|
18012
|
-
|
|
18013
|
-
|
|
18014
|
-
|
|
18015
|
-
|
|
18016
|
-
|
|
18017
|
-
|
|
18018
|
-
|
|
18019
|
-
|
|
18020
|
-
|
|
18021
|
-
|
|
18022
|
-
|
|
18023
|
-
|
|
18024
|
-
|
|
18025
|
-
|
|
18026
|
-
|
|
18027
|
-
|
|
18028
|
-
|
|
18029
|
-
|
|
18030
|
-
|
|
18031
|
-
|
|
18480
|
+
// New card button
|
|
18481
|
+
createElement("button", {
|
|
18482
|
+
style: btnStyle,
|
|
18483
|
+
onClick: onNewCard,
|
|
18484
|
+
"data-testid": "btn-new-card",
|
|
18485
|
+
"aria-label": "New card"
|
|
18486
|
+
}, "+ New Card"),
|
|
18487
|
+
createElement("div", { style: separatorStyle }),
|
|
18488
|
+
// Zoom controls
|
|
18489
|
+
createElement("button", {
|
|
18490
|
+
style: btnStyle,
|
|
18491
|
+
onClick: onZoomOut,
|
|
18492
|
+
"data-testid": "btn-zoom-out",
|
|
18493
|
+
"aria-label": "Zoom out"
|
|
18494
|
+
}, "-"),
|
|
18495
|
+
createElement("span", {
|
|
18496
|
+
style: zoomText,
|
|
18497
|
+
onClick: onZoomReset,
|
|
18498
|
+
"data-testid": "zoom-level",
|
|
18499
|
+
role: "status",
|
|
18500
|
+
"aria-label": `Zoom ${Math.round(zoom * 100)}%`
|
|
18501
|
+
}, `${Math.round(zoom * 100)}%`),
|
|
18502
|
+
createElement("button", {
|
|
18503
|
+
style: btnStyle,
|
|
18504
|
+
onClick: onZoomIn,
|
|
18505
|
+
"data-testid": "btn-zoom-in",
|
|
18506
|
+
"aria-label": "Zoom in"
|
|
18507
|
+
}, "+"),
|
|
18508
|
+
createElement("div", { style: separatorStyle }),
|
|
18509
|
+
...swatches,
|
|
18510
|
+
createElement("div", { style: separatorStyle }),
|
|
18511
|
+
// Grid toggle
|
|
18512
|
+
createElement("button", {
|
|
18513
|
+
style: gridEnabled ? activeBtnStyle : btnStyle,
|
|
18514
|
+
onClick: onGridToggle,
|
|
18515
|
+
"data-testid": "btn-grid-toggle",
|
|
18516
|
+
"aria-label": gridEnabled ? "Disable grid snapping" : "Enable grid snapping",
|
|
18517
|
+
"aria-pressed": String(gridEnabled)
|
|
18518
|
+
}, "Grid"),
|
|
18519
|
+
createElement("div", { style: separatorStyle }),
|
|
18520
|
+
// Search
|
|
18521
|
+
createElement("input", {
|
|
18522
|
+
type: "text",
|
|
18523
|
+
placeholder: "Search cards...",
|
|
18524
|
+
value: searchText,
|
|
18525
|
+
onInput: handleSearchInput,
|
|
18526
|
+
style: inputStyle,
|
|
18527
|
+
"data-testid": "search-input",
|
|
18528
|
+
"aria-label": "Search cards"
|
|
18529
|
+
})
|
|
18032
18530
|
);
|
|
18033
18531
|
}
|
|
18034
18532
|
|
|
18035
|
-
// ../
|
|
18533
|
+
// ../components/data/board/src/BoardReducer.ts
|
|
18036
18534
|
var MAX_HISTORY = 50;
|
|
18037
18535
|
var DEFAULT_BOARD_STATE = {
|
|
18038
|
-
id:
|
|
18536
|
+
id: generateUUID(),
|
|
18039
18537
|
name: "Untitled",
|
|
18040
|
-
|
|
18041
|
-
connections: [],
|
|
18538
|
+
collection: [],
|
|
18042
18539
|
viewport: { panX: 0, panY: 0, zoom: 1 }
|
|
18043
18540
|
};
|
|
18541
|
+
function removeItemFromTree(collection, itemId) {
|
|
18542
|
+
let removed = null;
|
|
18543
|
+
function process(items) {
|
|
18544
|
+
const result = [];
|
|
18545
|
+
for (let i = 0; i < items.length; i++) {
|
|
18546
|
+
const item = items[i];
|
|
18547
|
+
const id = getItemId(item);
|
|
18548
|
+
if (id === itemId) {
|
|
18549
|
+
removed = item;
|
|
18550
|
+
continue;
|
|
18551
|
+
}
|
|
18552
|
+
if (isContainer(item)) {
|
|
18553
|
+
const newContents = process(item.contents);
|
|
18554
|
+
result.push({ ...item, contents: newContents });
|
|
18555
|
+
} else {
|
|
18556
|
+
result.push(item);
|
|
18557
|
+
}
|
|
18558
|
+
}
|
|
18559
|
+
return result;
|
|
18560
|
+
}
|
|
18561
|
+
const updated = process(collection);
|
|
18562
|
+
return [updated, removed];
|
|
18563
|
+
}
|
|
18564
|
+
function updateItemInTree(collection, itemId, updater) {
|
|
18565
|
+
const result = [];
|
|
18566
|
+
for (let i = 0; i < collection.length; i++) {
|
|
18567
|
+
const item = collection[i];
|
|
18568
|
+
const id = getItemId(item);
|
|
18569
|
+
if (id === itemId) {
|
|
18570
|
+
result.push(updater(item));
|
|
18571
|
+
} else if (isContainer(item)) {
|
|
18572
|
+
result.push({
|
|
18573
|
+
...item,
|
|
18574
|
+
contents: updateItemInTree(item.contents, itemId, updater)
|
|
18575
|
+
});
|
|
18576
|
+
} else {
|
|
18577
|
+
result.push(item);
|
|
18578
|
+
}
|
|
18579
|
+
}
|
|
18580
|
+
return result;
|
|
18581
|
+
}
|
|
18582
|
+
function addItemToContainer(collection, containerId, newItem) {
|
|
18583
|
+
const result = [];
|
|
18584
|
+
for (let i = 0; i < collection.length; i++) {
|
|
18585
|
+
const item = collection[i];
|
|
18586
|
+
if (isContainer(item) && item.container_id === containerId) {
|
|
18587
|
+
result.push({
|
|
18588
|
+
...item,
|
|
18589
|
+
contents: [...item.contents, newItem]
|
|
18590
|
+
});
|
|
18591
|
+
} else if (isContainer(item)) {
|
|
18592
|
+
result.push({
|
|
18593
|
+
...item,
|
|
18594
|
+
contents: addItemToContainer(item.contents, containerId, newItem)
|
|
18595
|
+
});
|
|
18596
|
+
} else {
|
|
18597
|
+
result.push(item);
|
|
18598
|
+
}
|
|
18599
|
+
}
|
|
18600
|
+
return result;
|
|
18601
|
+
}
|
|
18602
|
+
function findContainerById(collection, containerId) {
|
|
18603
|
+
const stack = [...collection];
|
|
18604
|
+
while (stack.length > 0) {
|
|
18605
|
+
const item = stack.pop();
|
|
18606
|
+
if (isContainer(item)) {
|
|
18607
|
+
if (item.container_id === containerId) return item;
|
|
18608
|
+
for (let i = 0; i < item.contents.length; i++) {
|
|
18609
|
+
stack.push(item.contents[i]);
|
|
18610
|
+
}
|
|
18611
|
+
}
|
|
18612
|
+
}
|
|
18613
|
+
return null;
|
|
18614
|
+
}
|
|
18615
|
+
function removeItemFromContainer(collection, containerId, itemId) {
|
|
18616
|
+
let removed = null;
|
|
18617
|
+
function process(items) {
|
|
18618
|
+
const result = [];
|
|
18619
|
+
for (let i = 0; i < items.length; i++) {
|
|
18620
|
+
const item = items[i];
|
|
18621
|
+
if (isContainer(item) && item.container_id === containerId) {
|
|
18622
|
+
const newContents = [];
|
|
18623
|
+
for (let j = 0; j < item.contents.length; j++) {
|
|
18624
|
+
const child = item.contents[j];
|
|
18625
|
+
if (getItemId(child) === itemId) {
|
|
18626
|
+
removed = child;
|
|
18627
|
+
} else {
|
|
18628
|
+
newContents.push(child);
|
|
18629
|
+
}
|
|
18630
|
+
}
|
|
18631
|
+
result.push({ ...item, contents: newContents });
|
|
18632
|
+
} else if (isContainer(item)) {
|
|
18633
|
+
result.push({
|
|
18634
|
+
...item,
|
|
18635
|
+
contents: process(item.contents)
|
|
18636
|
+
});
|
|
18637
|
+
} else {
|
|
18638
|
+
result.push(item);
|
|
18639
|
+
}
|
|
18640
|
+
}
|
|
18641
|
+
return result;
|
|
18642
|
+
}
|
|
18643
|
+
const updated = process(collection);
|
|
18644
|
+
return [updated, removed];
|
|
18645
|
+
}
|
|
18646
|
+
function getDefaultContent(cardType) {
|
|
18647
|
+
switch (cardType) {
|
|
18648
|
+
case "text":
|
|
18649
|
+
return { text: "" };
|
|
18650
|
+
case "json":
|
|
18651
|
+
return {};
|
|
18652
|
+
case "task":
|
|
18653
|
+
return {};
|
|
18654
|
+
case "project":
|
|
18655
|
+
return { project_id: "", project_name: "" };
|
|
18656
|
+
}
|
|
18657
|
+
}
|
|
18044
18658
|
function boardReducer(state, action) {
|
|
18045
18659
|
switch (action.type) {
|
|
18046
|
-
case "
|
|
18660
|
+
case "ADD_ITEM": {
|
|
18661
|
+
if (action.containerId) {
|
|
18662
|
+
return {
|
|
18663
|
+
...state,
|
|
18664
|
+
collection: addItemToContainer(state.collection, action.containerId, action.item)
|
|
18665
|
+
};
|
|
18666
|
+
}
|
|
18047
18667
|
return {
|
|
18048
18668
|
...state,
|
|
18049
|
-
|
|
18669
|
+
collection: [...state.collection, action.item]
|
|
18050
18670
|
};
|
|
18051
|
-
|
|
18671
|
+
}
|
|
18672
|
+
case "REMOVE_ITEM": {
|
|
18673
|
+
const [newCollection] = removeItemFromTree(state.collection, action.itemId);
|
|
18052
18674
|
return {
|
|
18053
18675
|
...state,
|
|
18054
|
-
|
|
18055
|
-
|
|
18056
|
-
|
|
18057
|
-
|
|
18676
|
+
collection: newCollection
|
|
18677
|
+
};
|
|
18678
|
+
}
|
|
18679
|
+
case "MOVE_ITEM": {
|
|
18680
|
+
return {
|
|
18681
|
+
...state,
|
|
18682
|
+
collection: updateItemInTree(state.collection, action.itemId, (item) => {
|
|
18683
|
+
return {
|
|
18684
|
+
...item,
|
|
18685
|
+
position: action.position,
|
|
18686
|
+
...isCard(item) ? { updatedAt: Date.now() } : {}
|
|
18687
|
+
};
|
|
18688
|
+
})
|
|
18058
18689
|
};
|
|
18059
|
-
|
|
18690
|
+
}
|
|
18691
|
+
case "RESIZE_ITEM": {
|
|
18060
18692
|
return {
|
|
18061
18693
|
...state,
|
|
18062
|
-
|
|
18063
|
-
|
|
18064
|
-
|
|
18694
|
+
collection: updateItemInTree(state.collection, action.itemId, (item) => ({
|
|
18695
|
+
...item,
|
|
18696
|
+
size: action.size,
|
|
18697
|
+
...isCard(item) ? { updatedAt: Date.now() } : {}
|
|
18698
|
+
}))
|
|
18065
18699
|
};
|
|
18066
|
-
|
|
18700
|
+
}
|
|
18701
|
+
case "UPDATE_CARD": {
|
|
18067
18702
|
return {
|
|
18068
18703
|
...state,
|
|
18069
|
-
|
|
18070
|
-
|
|
18071
|
-
|
|
18704
|
+
collection: updateItemInTree(state.collection, action.cardId, (item) => {
|
|
18705
|
+
if (!isCard(item)) return item;
|
|
18706
|
+
return { ...item, ...action.updates, updatedAt: Date.now() };
|
|
18707
|
+
})
|
|
18072
18708
|
};
|
|
18073
|
-
|
|
18709
|
+
}
|
|
18710
|
+
case "CHANGE_CARD_TYPE": {
|
|
18074
18711
|
return {
|
|
18075
18712
|
...state,
|
|
18076
|
-
|
|
18077
|
-
|
|
18078
|
-
|
|
18713
|
+
collection: updateItemInTree(state.collection, action.cardId, (item) => {
|
|
18714
|
+
if (!isCard(item)) return item;
|
|
18715
|
+
return {
|
|
18716
|
+
...item,
|
|
18717
|
+
card_type: action.newType,
|
|
18718
|
+
content: getDefaultContent(action.newType),
|
|
18719
|
+
updatedAt: Date.now()
|
|
18720
|
+
};
|
|
18721
|
+
})
|
|
18722
|
+
};
|
|
18723
|
+
}
|
|
18724
|
+
case "ADD_CONTAINER": {
|
|
18725
|
+
if (action.parentContainerId) {
|
|
18726
|
+
return {
|
|
18727
|
+
...state,
|
|
18728
|
+
collection: addItemToContainer(
|
|
18729
|
+
state.collection,
|
|
18730
|
+
action.parentContainerId,
|
|
18731
|
+
action.container
|
|
18732
|
+
)
|
|
18733
|
+
};
|
|
18734
|
+
}
|
|
18735
|
+
return {
|
|
18736
|
+
...state,
|
|
18737
|
+
collection: [...state.collection, action.container]
|
|
18079
18738
|
};
|
|
18080
|
-
|
|
18081
|
-
|
|
18082
|
-
|
|
18083
|
-
|
|
18084
|
-
const
|
|
18085
|
-
|
|
18086
|
-
|
|
18739
|
+
}
|
|
18740
|
+
case "NEST_ITEM": {
|
|
18741
|
+
const targetContainer = findContainerById(state.collection, action.containerId);
|
|
18742
|
+
if (!targetContainer) return state;
|
|
18743
|
+
const [withoutItem, movedItem] = removeItemFromTree(
|
|
18744
|
+
state.collection,
|
|
18745
|
+
action.itemId
|
|
18746
|
+
);
|
|
18747
|
+
if (!movedItem) return state;
|
|
18748
|
+
const relativeItem = {
|
|
18749
|
+
...movedItem,
|
|
18087
18750
|
position: {
|
|
18088
|
-
x:
|
|
18089
|
-
y:
|
|
18090
|
-
}
|
|
18091
|
-
createdAt: Date.now(),
|
|
18092
|
-
updatedAt: Date.now()
|
|
18751
|
+
x: movedItem.position.x - targetContainer.position.x,
|
|
18752
|
+
y: movedItem.position.y - targetContainer.position.y - 30
|
|
18753
|
+
}
|
|
18093
18754
|
};
|
|
18094
18755
|
return {
|
|
18095
18756
|
...state,
|
|
18096
|
-
|
|
18757
|
+
collection: addItemToContainer(withoutItem, action.containerId, relativeItem)
|
|
18097
18758
|
};
|
|
18098
18759
|
}
|
|
18099
|
-
case "
|
|
18760
|
+
case "UNNEST_ITEM": {
|
|
18761
|
+
const sourceContainer = findContainerById(state.collection, action.containerId);
|
|
18762
|
+
const [withoutItem, movedItem] = removeItemFromContainer(
|
|
18763
|
+
state.collection,
|
|
18764
|
+
action.containerId,
|
|
18765
|
+
action.itemId
|
|
18766
|
+
);
|
|
18767
|
+
if (!movedItem) return state;
|
|
18768
|
+
const absoluteItem = sourceContainer ? {
|
|
18769
|
+
...movedItem,
|
|
18770
|
+
position: {
|
|
18771
|
+
x: movedItem.position.x + sourceContainer.position.x,
|
|
18772
|
+
y: movedItem.position.y + sourceContainer.position.y + 30
|
|
18773
|
+
}
|
|
18774
|
+
} : movedItem;
|
|
18100
18775
|
return {
|
|
18101
18776
|
...state,
|
|
18102
|
-
|
|
18777
|
+
collection: [...withoutItem, absoluteItem]
|
|
18103
18778
|
};
|
|
18104
|
-
|
|
18779
|
+
}
|
|
18780
|
+
case "ADD_LINK": {
|
|
18105
18781
|
return {
|
|
18106
18782
|
...state,
|
|
18107
|
-
|
|
18108
|
-
(
|
|
18109
|
-
|
|
18783
|
+
collection: updateItemInTree(state.collection, action.cardId, (item) => {
|
|
18784
|
+
if (!isCard(item)) return item;
|
|
18785
|
+
return {
|
|
18786
|
+
...item,
|
|
18787
|
+
card_link: [...item.card_link, action.link],
|
|
18788
|
+
updatedAt: Date.now()
|
|
18789
|
+
};
|
|
18790
|
+
})
|
|
18791
|
+
};
|
|
18792
|
+
}
|
|
18793
|
+
case "REMOVE_LINK": {
|
|
18794
|
+
return {
|
|
18795
|
+
...state,
|
|
18796
|
+
collection: updateItemInTree(state.collection, action.cardId, (item) => {
|
|
18797
|
+
if (!isCard(item)) return item;
|
|
18798
|
+
return {
|
|
18799
|
+
...item,
|
|
18800
|
+
card_link: item.card_link.filter((l) => l.link_id !== action.linkId),
|
|
18801
|
+
updatedAt: Date.now()
|
|
18802
|
+
};
|
|
18803
|
+
})
|
|
18110
18804
|
};
|
|
18805
|
+
}
|
|
18111
18806
|
case "PAN":
|
|
18112
18807
|
return {
|
|
18113
18808
|
...state,
|
|
@@ -18122,6 +18817,8 @@ function boardReducer(state, action) {
|
|
|
18122
18817
|
}
|
|
18123
18818
|
case "SET_BOARD":
|
|
18124
18819
|
return action.state;
|
|
18820
|
+
case "RENAME_BOARD":
|
|
18821
|
+
return { ...state, name: action.name };
|
|
18125
18822
|
default:
|
|
18126
18823
|
return state;
|
|
18127
18824
|
}
|
|
@@ -18174,10 +18871,10 @@ function historyReducer(state, action) {
|
|
|
18174
18871
|
return state;
|
|
18175
18872
|
}
|
|
18176
18873
|
}
|
|
18177
|
-
function
|
|
18874
|
+
function useBoardReducer(initialState) {
|
|
18178
18875
|
const initialHistory = {
|
|
18179
18876
|
past: [],
|
|
18180
|
-
present: DEFAULT_BOARD_STATE,
|
|
18877
|
+
present: initialState || DEFAULT_BOARD_STATE,
|
|
18181
18878
|
future: []
|
|
18182
18879
|
};
|
|
18183
18880
|
const [history, historyDispatch] = useReducer(historyReducer, initialHistory);
|
|
@@ -18190,6 +18887,19 @@ function useBoardState(storage2, boardId) {
|
|
|
18190
18887
|
const redo = useCallback(() => {
|
|
18191
18888
|
historyDispatch({ type: "REDO" });
|
|
18192
18889
|
}, [historyDispatch]);
|
|
18890
|
+
return {
|
|
18891
|
+
state: history.present,
|
|
18892
|
+
dispatch,
|
|
18893
|
+
undo,
|
|
18894
|
+
redo,
|
|
18895
|
+
canUndo: history.past.length > 0,
|
|
18896
|
+
canRedo: history.future.length > 0
|
|
18897
|
+
};
|
|
18898
|
+
}
|
|
18899
|
+
|
|
18900
|
+
// ../demos/project-manager/src/BoardState.ts
|
|
18901
|
+
function useBoardState(storage2, boardId) {
|
|
18902
|
+
const { state, dispatch, undo, redo, canUndo, canRedo } = useBoardReducer();
|
|
18193
18903
|
const loadedRef = useRef(false);
|
|
18194
18904
|
useEffect(() => {
|
|
18195
18905
|
if (storage2 && boardId && !loadedRef.current) {
|
|
@@ -18201,8 +18911,8 @@ function useBoardState(storage2, boardId) {
|
|
|
18201
18911
|
}
|
|
18202
18912
|
}, [storage2, boardId, dispatch]);
|
|
18203
18913
|
const saveTimerRef = useRef(null);
|
|
18204
|
-
const stateRef = useRef(
|
|
18205
|
-
stateRef.current =
|
|
18914
|
+
const stateRef = useRef(state);
|
|
18915
|
+
stateRef.current = state;
|
|
18206
18916
|
useEffect(() => {
|
|
18207
18917
|
if (!storage2 || !boardId) return;
|
|
18208
18918
|
if (saveTimerRef.current !== null) {
|
|
@@ -18218,32 +18928,27 @@ function useBoardState(storage2, boardId) {
|
|
|
18218
18928
|
clearTimeout(saveTimerRef.current);
|
|
18219
18929
|
}
|
|
18220
18930
|
};
|
|
18221
|
-
}, [storage2, boardId,
|
|
18931
|
+
}, [storage2, boardId, state]);
|
|
18222
18932
|
return {
|
|
18223
|
-
state
|
|
18933
|
+
state,
|
|
18224
18934
|
dispatch,
|
|
18225
18935
|
undo,
|
|
18226
18936
|
redo,
|
|
18227
|
-
canUndo
|
|
18228
|
-
canRedo
|
|
18937
|
+
canUndo,
|
|
18938
|
+
canRedo
|
|
18229
18939
|
};
|
|
18230
18940
|
}
|
|
18231
18941
|
|
|
18232
18942
|
// ../demos/project-manager/src/LocalStorage.ts
|
|
18233
|
-
var DEFAULT_STATE = {
|
|
18234
|
-
cards: [],
|
|
18235
|
-
connections: [],
|
|
18236
|
-
viewport: { panX: 0, panY: 0, zoom: 1 }
|
|
18237
|
-
};
|
|
18238
18943
|
var LocalBoardStorage = class {
|
|
18239
18944
|
async load(boardId) {
|
|
18240
18945
|
try {
|
|
18241
18946
|
const raw = localStorage.getItem("board:" + boardId);
|
|
18242
|
-
if (!raw) return
|
|
18947
|
+
if (!raw) return { ...DEFAULT_BOARD_STATE };
|
|
18243
18948
|
const parsed = JSON.parse(raw);
|
|
18244
18949
|
return parsed;
|
|
18245
18950
|
} catch {
|
|
18246
|
-
return
|
|
18951
|
+
return { ...DEFAULT_BOARD_STATE };
|
|
18247
18952
|
}
|
|
18248
18953
|
}
|
|
18249
18954
|
async save(boardId, state) {
|
|
@@ -18255,34 +18960,50 @@ var LocalBoardStorage = class {
|
|
|
18255
18960
|
};
|
|
18256
18961
|
|
|
18257
18962
|
// ../demos/project-manager/src/InterApp.ts
|
|
18963
|
+
function collectCards(items) {
|
|
18964
|
+
const cards = [];
|
|
18965
|
+
const stack = [...items];
|
|
18966
|
+
while (stack.length > 0) {
|
|
18967
|
+
const item = stack.pop();
|
|
18968
|
+
if (isCard(item)) {
|
|
18969
|
+
cards.push(item);
|
|
18970
|
+
} else {
|
|
18971
|
+
for (let i = item.contents.length - 1; i >= 0; i--) {
|
|
18972
|
+
stack.push(item.contents[i]);
|
|
18973
|
+
}
|
|
18974
|
+
}
|
|
18975
|
+
}
|
|
18976
|
+
return cards;
|
|
18977
|
+
}
|
|
18258
18978
|
function InterAppWrapper(props) {
|
|
18259
|
-
const {
|
|
18979
|
+
const { collection, onCardDropped, children } = props;
|
|
18260
18980
|
const messageBus = useMessageBus();
|
|
18261
18981
|
const prevCardsRef = useRef([]);
|
|
18262
18982
|
useEffect(() => {
|
|
18983
|
+
const cards = collectCards(collection);
|
|
18263
18984
|
const prevCards = prevCardsRef.current;
|
|
18264
|
-
const prevIds = new Set(prevCards.map((c) => c.
|
|
18265
|
-
const currIds = new Set(cards.map((c) => c.
|
|
18985
|
+
const prevIds = new Set(prevCards.map((c) => c.card_id));
|
|
18986
|
+
const currIds = new Set(cards.map((c) => c.card_id));
|
|
18266
18987
|
for (const card of cards) {
|
|
18267
|
-
if (!prevIds.has(card.
|
|
18988
|
+
if (!prevIds.has(card.card_id)) {
|
|
18268
18989
|
messageBus.publish("project-board", { event: "card-created", card });
|
|
18269
18990
|
}
|
|
18270
18991
|
}
|
|
18271
18992
|
for (const card of prevCards) {
|
|
18272
|
-
if (!currIds.has(card.
|
|
18273
|
-
messageBus.publish("project-board", { event: "card-deleted", cardId: card.
|
|
18993
|
+
if (!currIds.has(card.card_id)) {
|
|
18994
|
+
messageBus.publish("project-board", { event: "card-deleted", cardId: card.card_id });
|
|
18274
18995
|
}
|
|
18275
18996
|
}
|
|
18276
18997
|
for (const card of cards) {
|
|
18277
|
-
if (prevIds.has(card.
|
|
18278
|
-
const prev = prevCards.find((c) => c.
|
|
18998
|
+
if (prevIds.has(card.card_id)) {
|
|
18999
|
+
const prev = prevCards.find((c) => c.card_id === card.card_id);
|
|
18279
19000
|
if (prev && prev.updatedAt !== card.updatedAt) {
|
|
18280
19001
|
messageBus.publish("project-board", { event: "card-updated", card });
|
|
18281
19002
|
}
|
|
18282
19003
|
}
|
|
18283
19004
|
}
|
|
18284
19005
|
prevCardsRef.current = cards;
|
|
18285
|
-
}, [
|
|
19006
|
+
}, [collection, messageBus]);
|
|
18286
19007
|
const handleDrop = useCallback(
|
|
18287
19008
|
(payload) => {
|
|
18288
19009
|
if (payload.type === "text/plain" && typeof payload.data === "string") {
|
|
@@ -18313,29 +19034,93 @@ function InterAppWrapper(props) {
|
|
|
18313
19034
|
}
|
|
18314
19035
|
|
|
18315
19036
|
// ../demos/project-manager/src/index.ts
|
|
18316
|
-
var
|
|
18317
|
-
function
|
|
18318
|
-
|
|
18319
|
-
|
|
19037
|
+
var storage = new LocalBoardStorage();
|
|
19038
|
+
function collectAllCards2(items) {
|
|
19039
|
+
const cards = [];
|
|
19040
|
+
const stack = [...items];
|
|
19041
|
+
while (stack.length > 0) {
|
|
19042
|
+
const item = stack.pop();
|
|
19043
|
+
if (isCard(item)) {
|
|
19044
|
+
cards.push(item);
|
|
19045
|
+
} else if (isContainer(item)) {
|
|
19046
|
+
for (let i = item.contents.length - 1; i >= 0; i--) {
|
|
19047
|
+
stack.push(item.contents[i]);
|
|
19048
|
+
}
|
|
19049
|
+
}
|
|
19050
|
+
}
|
|
19051
|
+
return cards;
|
|
18320
19052
|
}
|
|
18321
|
-
var
|
|
18322
|
-
var SAMPLE_CARDS = [
|
|
18323
|
-
{ 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", assignee: "Alice", createdAt: Date.now(), updatedAt: Date.now() },
|
|
18324
|
-
{ id: "sample-2", title: "Dashboard", description: "Build the main dashboard", color: "#22c55e", position: { x: 300, y: 80 }, size: { width: 180, height: 120 }, priority: "medium", assignee: "Bob", createdAt: Date.now(), updatedAt: Date.now() },
|
|
18325
|
-
{ 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() },
|
|
18326
|
-
{ id: "sample-4", title: "Docs", description: "Write API reference", color: "#a855f7", position: { x: 400, y: 280 }, size: { width: 180, height: 120 }, priority: "medium", assignee: "Carol", createdAt: Date.now(), updatedAt: Date.now() }
|
|
18327
|
-
];
|
|
19053
|
+
var now = Date.now();
|
|
18328
19054
|
var SAMPLE_BOARD = {
|
|
18329
19055
|
id: "sample-board-001",
|
|
18330
19056
|
name: "Sample Project",
|
|
18331
|
-
|
|
18332
|
-
|
|
18333
|
-
|
|
19057
|
+
collection: [
|
|
19058
|
+
{
|
|
19059
|
+
type: "card",
|
|
19060
|
+
card_id: "sample-1",
|
|
19061
|
+
card_type: "text",
|
|
19062
|
+
card_title: "Auth API",
|
|
19063
|
+
card_link: [
|
|
19064
|
+
{ link_id: "link-1", link_name: "blocks", target_card_id: "sample-2", color: "#94a3b8", attributes: {} }
|
|
19065
|
+
],
|
|
19066
|
+
content: { text: "Design the auth flow" },
|
|
19067
|
+
position: { x: 50, y: 50 },
|
|
19068
|
+
size: { width: 180, height: 120 },
|
|
19069
|
+
color: "#3b82f6",
|
|
19070
|
+
priority: "high",
|
|
19071
|
+
assignee: "Alice",
|
|
19072
|
+
createdAt: now,
|
|
19073
|
+
updatedAt: now
|
|
19074
|
+
},
|
|
19075
|
+
{
|
|
19076
|
+
type: "card",
|
|
19077
|
+
card_id: "sample-2",
|
|
19078
|
+
card_type: "text",
|
|
19079
|
+
card_title: "Dashboard",
|
|
19080
|
+
card_link: [],
|
|
19081
|
+
content: { text: "Build the main dashboard" },
|
|
19082
|
+
position: { x: 300, y: 80 },
|
|
19083
|
+
size: { width: 180, height: 120 },
|
|
19084
|
+
color: "#22c55e",
|
|
19085
|
+
priority: "medium",
|
|
19086
|
+
assignee: "Bob",
|
|
19087
|
+
createdAt: now,
|
|
19088
|
+
updatedAt: now
|
|
19089
|
+
},
|
|
19090
|
+
{
|
|
19091
|
+
type: "card",
|
|
19092
|
+
card_id: "sample-3",
|
|
19093
|
+
card_type: "text",
|
|
19094
|
+
card_title: "Deploy",
|
|
19095
|
+
card_link: [],
|
|
19096
|
+
content: { text: "Set up CI pipeline" },
|
|
19097
|
+
position: { x: 150, y: 250 },
|
|
19098
|
+
size: { width: 180, height: 120 },
|
|
19099
|
+
color: "#f59e0b",
|
|
19100
|
+
priority: "low",
|
|
19101
|
+
createdAt: now,
|
|
19102
|
+
updatedAt: now
|
|
19103
|
+
},
|
|
19104
|
+
{
|
|
19105
|
+
type: "card",
|
|
19106
|
+
card_id: "sample-4",
|
|
19107
|
+
card_type: "text",
|
|
19108
|
+
card_title: "Docs",
|
|
19109
|
+
card_link: [],
|
|
19110
|
+
content: { text: "Write API reference" },
|
|
19111
|
+
position: { x: 400, y: 280 },
|
|
19112
|
+
size: { width: 180, height: 120 },
|
|
19113
|
+
color: "#a855f7",
|
|
19114
|
+
priority: "medium",
|
|
19115
|
+
assignee: "Carol",
|
|
19116
|
+
createdAt: now,
|
|
19117
|
+
updatedAt: now
|
|
19118
|
+
}
|
|
18334
19119
|
],
|
|
18335
19120
|
viewport: { panX: 0, panY: 0, zoom: 1 }
|
|
18336
19121
|
};
|
|
18337
19122
|
function isBoardEmpty(state) {
|
|
18338
|
-
return state.
|
|
19123
|
+
return state.collection.length === 0;
|
|
18339
19124
|
}
|
|
18340
19125
|
function ProjectManagerApp(props) {
|
|
18341
19126
|
const boardId = props.boardId || "default";
|
|
@@ -18345,16 +19130,29 @@ function ProjectManagerApp(props) {
|
|
|
18345
19130
|
const [searchQuery, setSearchQuery] = useState("");
|
|
18346
19131
|
const [selectedCardId, setSelectedCardId] = useState(null);
|
|
18347
19132
|
const [colorFilter, setColorFilter] = useState(null);
|
|
18348
|
-
const [showConnections, setShowConnections] = useState(true);
|
|
18349
19133
|
const [projectName, setProjectName] = useState(state.name || "Untitled");
|
|
18350
19134
|
const [showRenameDialog, setShowRenameDialog] = useState(false);
|
|
18351
19135
|
const [renameDraft, setRenameDraft] = useState("");
|
|
19136
|
+
const [openMenu, setOpenMenu] = useState(null);
|
|
19137
|
+
const [showConnections, setShowConnections] = useState(true);
|
|
19138
|
+
const [graphAttributes, setGraphAttributes] = useState([
|
|
19139
|
+
{ name: "relates to", weight: 1 },
|
|
19140
|
+
{ name: "depends on", weight: 2 },
|
|
19141
|
+
{ name: "blocks", weight: 3 },
|
|
19142
|
+
{ name: "is blocked by", weight: 3 },
|
|
19143
|
+
{ name: "implements", weight: 2 },
|
|
19144
|
+
{ name: "references", weight: 1 }
|
|
19145
|
+
]);
|
|
19146
|
+
const [graphDialog, setGraphDialog] = useState(null);
|
|
19147
|
+
const [attrNameDraft, setAttrNameDraft] = useState("");
|
|
19148
|
+
const [attrWeightDraft, setAttrWeightDraft] = useState("1");
|
|
19149
|
+
const [editAttrs, setEditAttrs] = useState([]);
|
|
18352
19150
|
const sampleLoadedRef = useRef(false);
|
|
18353
19151
|
useEffect(() => {
|
|
18354
19152
|
if (!sampleLoadedRef.current && isBoardEmpty(state)) {
|
|
18355
19153
|
sampleLoadedRef.current = true;
|
|
18356
19154
|
dispatch({ type: "SET_BOARD", state: SAMPLE_BOARD });
|
|
18357
|
-
} else if (state.
|
|
19155
|
+
} else if (state.collection.length > 0) {
|
|
18358
19156
|
sampleLoadedRef.current = true;
|
|
18359
19157
|
}
|
|
18360
19158
|
}, [state, dispatch]);
|
|
@@ -18364,9 +19162,12 @@ function ProjectManagerApp(props) {
|
|
|
18364
19162
|
const offsetX = (Math.random() - 0.5) * 300;
|
|
18365
19163
|
const offsetY = (Math.random() - 0.5) * 200;
|
|
18366
19164
|
const newCard = {
|
|
18367
|
-
|
|
18368
|
-
|
|
18369
|
-
|
|
19165
|
+
type: "card",
|
|
19166
|
+
card_id: generateUUID(),
|
|
19167
|
+
card_type: "text",
|
|
19168
|
+
card_title: "New Card",
|
|
19169
|
+
card_link: [],
|
|
19170
|
+
content: { text: "" },
|
|
18370
19171
|
color: selectedColor,
|
|
18371
19172
|
position: { x: Math.round(cx + offsetX), y: Math.round(cy + offsetY) },
|
|
18372
19173
|
size: { width: 180, height: 120 },
|
|
@@ -18374,7 +19175,7 @@ function ProjectManagerApp(props) {
|
|
|
18374
19175
|
createdAt: Date.now(),
|
|
18375
19176
|
updatedAt: Date.now()
|
|
18376
19177
|
};
|
|
18377
|
-
dispatch({ type: "
|
|
19178
|
+
dispatch({ type: "ADD_ITEM", item: newCard });
|
|
18378
19179
|
}, [state.viewport, selectedColor, dispatch]);
|
|
18379
19180
|
const handleZoomIn = useCallback(() => {
|
|
18380
19181
|
dispatch({ type: "ZOOM", zoom: state.viewport.zoom + 0.1 });
|
|
@@ -18397,6 +19198,9 @@ function ProjectManagerApp(props) {
|
|
|
18397
19198
|
const handleColorFilter = useCallback((color) => {
|
|
18398
19199
|
setColorFilter(color);
|
|
18399
19200
|
}, []);
|
|
19201
|
+
const handleToggleConnections = useCallback(() => {
|
|
19202
|
+
setShowConnections((prev) => !prev);
|
|
19203
|
+
}, []);
|
|
18400
19204
|
const handleNewBoard = useCallback(() => {
|
|
18401
19205
|
dispatch({ type: "SET_BOARD", state: DEFAULT_BOARD_STATE });
|
|
18402
19206
|
setSelectedCardId(null);
|
|
@@ -18426,7 +19230,7 @@ function ProjectManagerApp(props) {
|
|
|
18426
19230
|
reader.onload = () => {
|
|
18427
19231
|
try {
|
|
18428
19232
|
const parsed = JSON.parse(reader.result);
|
|
18429
|
-
if (parsed && parsed.
|
|
19233
|
+
if (parsed && parsed.collection && parsed.viewport) {
|
|
18430
19234
|
dispatch({ type: "SET_BOARD", state: parsed });
|
|
18431
19235
|
}
|
|
18432
19236
|
} catch (_e) {
|
|
@@ -18441,54 +19245,27 @@ function ProjectManagerApp(props) {
|
|
|
18441
19245
|
const handlePrint = useCallback(() => {
|
|
18442
19246
|
window.print();
|
|
18443
19247
|
}, []);
|
|
19248
|
+
const allCards = collectAllCards2(state.collection);
|
|
18444
19249
|
const handleSelectAll = useCallback(() => {
|
|
18445
|
-
|
|
18446
|
-
|
|
19250
|
+
const cards = collectAllCards2(state.collection);
|
|
19251
|
+
if (cards.length > 0) {
|
|
19252
|
+
setSelectedCardId(cards[0].card_id);
|
|
18447
19253
|
}
|
|
18448
|
-
}, [state.
|
|
18449
|
-
const handleToggleConnections = useCallback(() => {
|
|
18450
|
-
setShowConnections((prev) => !prev);
|
|
18451
|
-
}, []);
|
|
19254
|
+
}, [state.collection]);
|
|
18452
19255
|
const handleDeleteSelected = useCallback(() => {
|
|
18453
19256
|
if (selectedCardId) {
|
|
18454
|
-
dispatch({ type: "
|
|
19257
|
+
dispatch({ type: "REMOVE_ITEM", itemId: selectedCardId });
|
|
18455
19258
|
setSelectedCardId(null);
|
|
18456
19259
|
}
|
|
18457
19260
|
}, [selectedCardId, dispatch]);
|
|
18458
19261
|
const handleFitAll = useCallback(() => {
|
|
18459
|
-
if (state.
|
|
19262
|
+
if (state.collection.length === 0) return;
|
|
18460
19263
|
const containerWidth = 800;
|
|
18461
19264
|
const containerHeight = 600;
|
|
18462
|
-
const fit = computeFitAll(state.
|
|
19265
|
+
const fit = computeFitAll(state.collection, containerWidth, containerHeight);
|
|
18463
19266
|
dispatch({ type: "PAN", panX: fit.panX, panY: fit.panY });
|
|
18464
19267
|
dispatch({ type: "ZOOM", zoom: fit.zoom });
|
|
18465
|
-
}, [state.
|
|
18466
|
-
const handleRenameProject = useCallback(() => {
|
|
18467
|
-
setRenameDraft(projectName);
|
|
18468
|
-
setShowRenameDialog(true);
|
|
18469
|
-
}, [projectName]);
|
|
18470
|
-
const handleRenameConfirm = useCallback(() => {
|
|
18471
|
-
const name = renameDraft.trim();
|
|
18472
|
-
if (name) setProjectName(name);
|
|
18473
|
-
setShowRenameDialog(false);
|
|
18474
|
-
}, [renameDraft]);
|
|
18475
|
-
const handleRenameCancel = useCallback(() => {
|
|
18476
|
-
setShowRenameDialog(false);
|
|
18477
|
-
}, []);
|
|
18478
|
-
const handleRenameDraftChange = useCallback((e) => {
|
|
18479
|
-
setRenameDraft(e.target.value);
|
|
18480
|
-
}, []);
|
|
18481
|
-
const handleRenameKeyDown = useCallback((e) => {
|
|
18482
|
-
const ke = e;
|
|
18483
|
-
if (ke.key === "Enter") {
|
|
18484
|
-
ke.preventDefault();
|
|
18485
|
-
handleRenameConfirm();
|
|
18486
|
-
}
|
|
18487
|
-
if (ke.key === "Escape") {
|
|
18488
|
-
ke.preventDefault();
|
|
18489
|
-
handleRenameCancel();
|
|
18490
|
-
}
|
|
18491
|
-
}, [handleRenameConfirm, handleRenameCancel]);
|
|
19268
|
+
}, [state.collection, dispatch]);
|
|
18492
19269
|
useEffect(() => {
|
|
18493
19270
|
const _menuBar = {
|
|
18494
19271
|
menus: [
|
|
@@ -18511,12 +19288,11 @@ function ProjectManagerApp(props) {
|
|
|
18511
19288
|
{ label: "Zoom Out", onClick: handleZoomOut },
|
|
18512
19289
|
{ label: "Fit All", onClick: handleFitAll },
|
|
18513
19290
|
{ divider: true },
|
|
18514
|
-
{ label: "Toggle Grid", onClick: handleGridToggle }
|
|
18515
|
-
{ label: showConnections ? "Hide Connections" : "Show Connections", onClick: handleToggleConnections }
|
|
19291
|
+
{ label: "Toggle Grid", onClick: handleGridToggle }
|
|
18516
19292
|
] }
|
|
18517
19293
|
]
|
|
18518
19294
|
};
|
|
18519
|
-
}, [handleNewBoard, handleExportJSON, handleImportJSON, handlePrint, undo, redo, canUndo, canRedo, handleSelectAll, handleDeleteSelected, handleZoomIn, handleZoomOut, handleFitAll, handleGridToggle
|
|
19295
|
+
}, [handleNewBoard, handleExportJSON, handleImportJSON, handlePrint, undo, redo, canUndo, canRedo, handleSelectAll, handleDeleteSelected, handleZoomIn, handleZoomOut, handleFitAll, handleGridToggle]);
|
|
18520
19296
|
useEffect(() => {
|
|
18521
19297
|
const handleKeyDown = (e) => {
|
|
18522
19298
|
const ke = e;
|
|
@@ -18531,6 +19307,45 @@ function ProjectManagerApp(props) {
|
|
|
18531
19307
|
document.addEventListener("keydown", handleKeyDown);
|
|
18532
19308
|
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
18533
19309
|
}, [undo, redo]);
|
|
19310
|
+
useEffect(() => {
|
|
19311
|
+
if (!openMenu) return;
|
|
19312
|
+
const handleClick = () => setOpenMenu(null);
|
|
19313
|
+
const timer = setTimeout(() => document.addEventListener("click", handleClick), 0);
|
|
19314
|
+
return () => {
|
|
19315
|
+
clearTimeout(timer);
|
|
19316
|
+
document.removeEventListener("click", handleClick);
|
|
19317
|
+
};
|
|
19318
|
+
}, [openMenu]);
|
|
19319
|
+
const handleRenameProject = useCallback(() => {
|
|
19320
|
+
setRenameDraft(projectName);
|
|
19321
|
+
setShowRenameDialog(true);
|
|
19322
|
+
}, [projectName]);
|
|
19323
|
+
const handleRenameConfirm = useCallback(() => {
|
|
19324
|
+
const name = renameDraft.trim();
|
|
19325
|
+
if (name) {
|
|
19326
|
+
setProjectName(name);
|
|
19327
|
+
dispatch({ type: "RENAME_BOARD", name });
|
|
19328
|
+
if (props.onTitleChange) props.onTitleChange(`Project Board: ${name}`);
|
|
19329
|
+
}
|
|
19330
|
+
setShowRenameDialog(false);
|
|
19331
|
+
}, [renameDraft, dispatch, props.onTitleChange]);
|
|
19332
|
+
const handleRenameCancel = useCallback(() => {
|
|
19333
|
+
setShowRenameDialog(false);
|
|
19334
|
+
}, []);
|
|
19335
|
+
const handleRenameDraftChange = useCallback((e) => {
|
|
19336
|
+
setRenameDraft(e.target.value);
|
|
19337
|
+
}, []);
|
|
19338
|
+
const handleRenameKeyDown = useCallback((e) => {
|
|
19339
|
+
const ke = e;
|
|
19340
|
+
if (ke.key === "Enter") {
|
|
19341
|
+
ke.preventDefault();
|
|
19342
|
+
handleRenameConfirm();
|
|
19343
|
+
}
|
|
19344
|
+
if (ke.key === "Escape") {
|
|
19345
|
+
ke.preventDefault();
|
|
19346
|
+
handleRenameCancel();
|
|
19347
|
+
}
|
|
19348
|
+
}, [handleRenameConfirm, handleRenameCancel]);
|
|
18534
19349
|
const containerStyle3 = {
|
|
18535
19350
|
display: "flex",
|
|
18536
19351
|
flexDirection: "column",
|
|
@@ -18545,9 +19360,12 @@ function ProjectManagerApp(props) {
|
|
|
18545
19360
|
const offsetX = (Math.random() - 0.5) * 300;
|
|
18546
19361
|
const offsetY = (Math.random() - 0.5) * 200;
|
|
18547
19362
|
const newCard = {
|
|
18548
|
-
|
|
18549
|
-
|
|
18550
|
-
|
|
19363
|
+
type: "card",
|
|
19364
|
+
card_id: generateUUID(),
|
|
19365
|
+
card_type: "text",
|
|
19366
|
+
card_title: title,
|
|
19367
|
+
card_link: [],
|
|
19368
|
+
content: { text: description },
|
|
18551
19369
|
color: selectedColor,
|
|
18552
19370
|
position: { x: Math.round(cx + offsetX), y: Math.round(cy + offsetY) },
|
|
18553
19371
|
size: { width: 180, height: 120 },
|
|
@@ -18555,7 +19373,7 @@ function ProjectManagerApp(props) {
|
|
|
18555
19373
|
createdAt: Date.now(),
|
|
18556
19374
|
updatedAt: Date.now()
|
|
18557
19375
|
};
|
|
18558
|
-
dispatch({ type: "
|
|
19376
|
+
dispatch({ type: "ADD_ITEM", item: newCard });
|
|
18559
19377
|
}, [state.viewport, selectedColor, dispatch]);
|
|
18560
19378
|
const menuBarStyle = {
|
|
18561
19379
|
display: "flex",
|
|
@@ -18577,25 +19395,153 @@ function ProjectManagerApp(props) {
|
|
|
18577
19395
|
borderRadius: "4px",
|
|
18578
19396
|
fontFamily: "inherit"
|
|
18579
19397
|
};
|
|
19398
|
+
const handleNewContainer = useCallback(() => {
|
|
19399
|
+
const cx = (-state.viewport.panX + 300) / state.viewport.zoom;
|
|
19400
|
+
const cy = (-state.viewport.panY + 200) / state.viewport.zoom;
|
|
19401
|
+
const offsetX = (Math.random() - 0.5) * 300;
|
|
19402
|
+
const offsetY = (Math.random() - 0.5) * 200;
|
|
19403
|
+
dispatch({
|
|
19404
|
+
type: "ADD_CONTAINER",
|
|
19405
|
+
container: {
|
|
19406
|
+
type: "container",
|
|
19407
|
+
container_id: generateUUID(),
|
|
19408
|
+
name: "New Container",
|
|
19409
|
+
position: { x: Math.round(cx + offsetX), y: Math.round(cy + offsetY) },
|
|
19410
|
+
size: { width: 300, height: 250 },
|
|
19411
|
+
contents: []
|
|
19412
|
+
}
|
|
19413
|
+
});
|
|
19414
|
+
setOpenMenu(null);
|
|
19415
|
+
}, [state.viewport, dispatch]);
|
|
19416
|
+
const menuDropdownStyle = {
|
|
19417
|
+
position: "absolute",
|
|
19418
|
+
top: "100%",
|
|
19419
|
+
left: "0",
|
|
19420
|
+
marginTop: "2px",
|
|
19421
|
+
backgroundColor: "#ffffff",
|
|
19422
|
+
border: "1px solid #d1d5db",
|
|
19423
|
+
borderRadius: "6px",
|
|
19424
|
+
boxShadow: "0 4px 12px rgba(0,0,0,0.15)",
|
|
19425
|
+
padding: "4px 0",
|
|
19426
|
+
minWidth: "180px",
|
|
19427
|
+
zIndex: "1000"
|
|
19428
|
+
};
|
|
19429
|
+
const menuDropdownItemStyle = {
|
|
19430
|
+
display: "block",
|
|
19431
|
+
width: "100%",
|
|
19432
|
+
padding: "6px 14px",
|
|
19433
|
+
border: "none",
|
|
19434
|
+
backgroundColor: "transparent",
|
|
19435
|
+
textAlign: "left",
|
|
19436
|
+
cursor: "pointer",
|
|
19437
|
+
fontSize: "13px",
|
|
19438
|
+
color: "#334155",
|
|
19439
|
+
fontFamily: "inherit",
|
|
19440
|
+
boxSizing: "border-box"
|
|
19441
|
+
};
|
|
18580
19442
|
const appMenuBar = createElement(
|
|
18581
19443
|
"div",
|
|
18582
19444
|
{
|
|
18583
19445
|
style: menuBarStyle,
|
|
18584
19446
|
"data-testid": "app-menu-bar"
|
|
18585
19447
|
},
|
|
18586
|
-
|
|
18587
|
-
|
|
18588
|
-
|
|
18589
|
-
|
|
18590
|
-
|
|
18591
|
-
|
|
18592
|
-
|
|
18593
|
-
|
|
18594
|
-
|
|
18595
|
-
|
|
18596
|
-
|
|
18597
|
-
|
|
18598
|
-
|
|
19448
|
+
// Project menu
|
|
19449
|
+
createElement(
|
|
19450
|
+
"div",
|
|
19451
|
+
{ style: { position: "relative", display: "inline-flex" } },
|
|
19452
|
+
createElement("button", {
|
|
19453
|
+
style: menuBtnStyle,
|
|
19454
|
+
onClick: () => setOpenMenu(openMenu === "project" ? null : "project")
|
|
19455
|
+
}, "Project"),
|
|
19456
|
+
openMenu === "project" ? createElement(
|
|
19457
|
+
"div",
|
|
19458
|
+
{ style: menuDropdownStyle },
|
|
19459
|
+
createElement("button", { style: menuDropdownItemStyle, onClick: () => {
|
|
19460
|
+
handleRenameProject();
|
|
19461
|
+
setOpenMenu(null);
|
|
19462
|
+
} }, "Rename Project..."),
|
|
19463
|
+
createElement("div", { style: { height: "1px", backgroundColor: "#e5e7eb", margin: "4px 0" } }),
|
|
19464
|
+
createElement("button", { style: menuDropdownItemStyle, onClick: () => {
|
|
19465
|
+
handleNewContainer();
|
|
19466
|
+
} }, "New Container"),
|
|
19467
|
+
createElement("button", { style: menuDropdownItemStyle, onClick: () => {
|
|
19468
|
+
handleNewCard();
|
|
19469
|
+
setOpenMenu(null);
|
|
19470
|
+
} }, "New Card")
|
|
19471
|
+
) : null
|
|
19472
|
+
),
|
|
19473
|
+
// Graphs menu
|
|
19474
|
+
createElement(
|
|
19475
|
+
"div",
|
|
19476
|
+
{ style: { position: "relative", display: "inline-flex" } },
|
|
19477
|
+
createElement("button", {
|
|
19478
|
+
style: menuBtnStyle,
|
|
19479
|
+
onClick: () => setOpenMenu(openMenu === "graphs" ? null : "graphs")
|
|
19480
|
+
}, "Graphs"),
|
|
19481
|
+
openMenu === "graphs" ? createElement(
|
|
19482
|
+
"div",
|
|
19483
|
+
{ style: menuDropdownStyle },
|
|
19484
|
+
createElement("button", { style: menuDropdownItemStyle, onClick: () => {
|
|
19485
|
+
setAttrNameDraft("");
|
|
19486
|
+
setAttrWeightDraft("1");
|
|
19487
|
+
setGraphDialog("add");
|
|
19488
|
+
setOpenMenu(null);
|
|
19489
|
+
} }, "Add Attribute..."),
|
|
19490
|
+
createElement("button", { style: menuDropdownItemStyle, onClick: () => {
|
|
19491
|
+
setGraphDialog("delete");
|
|
19492
|
+
setOpenMenu(null);
|
|
19493
|
+
} }, "Delete Attribute..."),
|
|
19494
|
+
createElement("button", { style: menuDropdownItemStyle, onClick: () => {
|
|
19495
|
+
setEditAttrs(graphAttributes.map((a) => ({ ...a })));
|
|
19496
|
+
setGraphDialog("edit");
|
|
19497
|
+
setOpenMenu(null);
|
|
19498
|
+
} }, "Edit Attributes...")
|
|
19499
|
+
) : null
|
|
19500
|
+
),
|
|
19501
|
+
// Settings menu
|
|
19502
|
+
createElement(
|
|
19503
|
+
"div",
|
|
19504
|
+
{ style: { position: "relative", display: "inline-flex" } },
|
|
19505
|
+
createElement("button", {
|
|
19506
|
+
style: menuBtnStyle,
|
|
19507
|
+
onClick: () => setOpenMenu(openMenu === "settings" ? null : "settings")
|
|
19508
|
+
}, "Settings"),
|
|
19509
|
+
openMenu === "settings" ? createElement(
|
|
19510
|
+
"div",
|
|
19511
|
+
{ style: menuDropdownStyle },
|
|
19512
|
+
createElement(
|
|
19513
|
+
"button",
|
|
19514
|
+
{ style: menuDropdownItemStyle, onClick: () => {
|
|
19515
|
+
handleGridToggle();
|
|
19516
|
+
setOpenMenu(null);
|
|
19517
|
+
} },
|
|
19518
|
+
gridEnabled ? "Disable Grid Snap" : "Enable Grid Snap"
|
|
19519
|
+
),
|
|
19520
|
+
createElement(
|
|
19521
|
+
"button",
|
|
19522
|
+
{ style: menuDropdownItemStyle, onClick: () => {
|
|
19523
|
+
handleToggleConnections();
|
|
19524
|
+
setOpenMenu(null);
|
|
19525
|
+
} },
|
|
19526
|
+
showConnections ? "Hide Links" : "Show Links"
|
|
19527
|
+
)
|
|
19528
|
+
) : null
|
|
19529
|
+
),
|
|
19530
|
+
// Help menu
|
|
19531
|
+
createElement(
|
|
19532
|
+
"div",
|
|
19533
|
+
{ style: { position: "relative", display: "inline-flex" } },
|
|
19534
|
+
createElement("button", {
|
|
19535
|
+
style: menuBtnStyle,
|
|
19536
|
+
onClick: () => setOpenMenu(openMenu === "help" ? null : "help")
|
|
19537
|
+
}, "Help"),
|
|
19538
|
+
openMenu === "help" ? createElement(
|
|
19539
|
+
"div",
|
|
19540
|
+
{ style: menuDropdownStyle },
|
|
19541
|
+
createElement("button", { style: menuDropdownItemStyle, onClick: () => setOpenMenu(null) }, "About Project Board"),
|
|
19542
|
+
createElement("button", { style: menuDropdownItemStyle, onClick: () => setOpenMenu(null) }, "Keyboard Shortcuts")
|
|
19543
|
+
) : null
|
|
19544
|
+
),
|
|
18599
19545
|
createElement("span", {
|
|
18600
19546
|
style: { marginLeft: "auto", fontSize: "12px", color: "#94a3b8" }
|
|
18601
19547
|
}, `Project Board: ${projectName}`)
|
|
@@ -18684,6 +19630,228 @@ function ProjectManagerApp(props) {
|
|
|
18684
19630
|
)
|
|
18685
19631
|
)
|
|
18686
19632
|
) : null;
|
|
19633
|
+
const dialogOverlayStyle = {
|
|
19634
|
+
position: "absolute",
|
|
19635
|
+
inset: "0",
|
|
19636
|
+
backgroundColor: "rgba(0,0,0,0.3)",
|
|
19637
|
+
display: "flex",
|
|
19638
|
+
alignItems: "center",
|
|
19639
|
+
justifyContent: "center",
|
|
19640
|
+
zIndex: "200"
|
|
19641
|
+
};
|
|
19642
|
+
const dialogBoxStyle = {
|
|
19643
|
+
backgroundColor: "#ffffff",
|
|
19644
|
+
borderRadius: "8px",
|
|
19645
|
+
padding: "20px",
|
|
19646
|
+
boxShadow: "0 8px 24px rgba(0,0,0,0.2)",
|
|
19647
|
+
minWidth: "320px",
|
|
19648
|
+
maxHeight: "400px",
|
|
19649
|
+
overflow: "auto"
|
|
19650
|
+
};
|
|
19651
|
+
const dialogTitleStyle = {
|
|
19652
|
+
fontWeight: "600",
|
|
19653
|
+
fontSize: "14px",
|
|
19654
|
+
marginBottom: "12px",
|
|
19655
|
+
color: "#1a1a1a"
|
|
19656
|
+
};
|
|
19657
|
+
const dialogInputStyle = {
|
|
19658
|
+
width: "100%",
|
|
19659
|
+
padding: "8px 10px",
|
|
19660
|
+
border: "1px solid #d1d5db",
|
|
19661
|
+
borderRadius: "6px",
|
|
19662
|
+
fontSize: "14px",
|
|
19663
|
+
boxSizing: "border-box",
|
|
19664
|
+
outline: "none",
|
|
19665
|
+
fontFamily: "inherit"
|
|
19666
|
+
};
|
|
19667
|
+
const dialogBtnPrimary = {
|
|
19668
|
+
padding: "6px 14px",
|
|
19669
|
+
border: "none",
|
|
19670
|
+
borderRadius: "6px",
|
|
19671
|
+
backgroundColor: "#3b82f6",
|
|
19672
|
+
color: "#ffffff",
|
|
19673
|
+
cursor: "pointer",
|
|
19674
|
+
fontSize: "13px",
|
|
19675
|
+
fontWeight: "600",
|
|
19676
|
+
fontFamily: "inherit"
|
|
19677
|
+
};
|
|
19678
|
+
const dialogBtnSecondary = {
|
|
19679
|
+
padding: "6px 14px",
|
|
19680
|
+
border: "1px solid #d1d5db",
|
|
19681
|
+
borderRadius: "6px",
|
|
19682
|
+
backgroundColor: "#ffffff",
|
|
19683
|
+
cursor: "pointer",
|
|
19684
|
+
fontSize: "13px",
|
|
19685
|
+
fontFamily: "inherit"
|
|
19686
|
+
};
|
|
19687
|
+
let graphDialogEl = null;
|
|
19688
|
+
if (graphDialog === "add") {
|
|
19689
|
+
graphDialogEl = createElement(
|
|
19690
|
+
"div",
|
|
19691
|
+
{
|
|
19692
|
+
style: dialogOverlayStyle,
|
|
19693
|
+
onClick: () => setGraphDialog(null)
|
|
19694
|
+
},
|
|
19695
|
+
createElement(
|
|
19696
|
+
"div",
|
|
19697
|
+
{
|
|
19698
|
+
style: dialogBoxStyle,
|
|
19699
|
+
onClick: (e) => e.stopPropagation(),
|
|
19700
|
+
role: "dialog",
|
|
19701
|
+
"aria-label": "Add edge attribute"
|
|
19702
|
+
},
|
|
19703
|
+
createElement("div", { style: dialogTitleStyle }, "Add Edge Attribute"),
|
|
19704
|
+
createElement(
|
|
19705
|
+
"div",
|
|
19706
|
+
{ style: { marginBottom: "8px" } },
|
|
19707
|
+
createElement("label", { style: { fontSize: "12px", color: "#64748b", display: "block", marginBottom: "4px" } }, "Name"),
|
|
19708
|
+
createElement("input", {
|
|
19709
|
+
type: "text",
|
|
19710
|
+
value: attrNameDraft,
|
|
19711
|
+
style: dialogInputStyle,
|
|
19712
|
+
placeholder: "e.g. depends on",
|
|
19713
|
+
onInput: (e) => setAttrNameDraft(e.target.value)
|
|
19714
|
+
})
|
|
19715
|
+
),
|
|
19716
|
+
createElement(
|
|
19717
|
+
"div",
|
|
19718
|
+
{ style: { marginBottom: "12px" } },
|
|
19719
|
+
createElement("label", { style: { fontSize: "12px", color: "#64748b", display: "block", marginBottom: "4px" } }, "Weight"),
|
|
19720
|
+
createElement("input", {
|
|
19721
|
+
type: "number",
|
|
19722
|
+
value: attrWeightDraft,
|
|
19723
|
+
style: dialogInputStyle,
|
|
19724
|
+
min: "0",
|
|
19725
|
+
step: "1",
|
|
19726
|
+
onInput: (e) => setAttrWeightDraft(e.target.value)
|
|
19727
|
+
})
|
|
19728
|
+
),
|
|
19729
|
+
createElement(
|
|
19730
|
+
"div",
|
|
19731
|
+
{ style: { display: "flex", justifyContent: "flex-end", gap: "8px" } },
|
|
19732
|
+
createElement("button", { style: dialogBtnSecondary, onClick: () => setGraphDialog(null) }, "Cancel"),
|
|
19733
|
+
createElement("button", { style: dialogBtnPrimary, onClick: () => {
|
|
19734
|
+
const name = attrNameDraft.trim();
|
|
19735
|
+
const weight = parseFloat(attrWeightDraft) || 1;
|
|
19736
|
+
if (name) {
|
|
19737
|
+
setGraphAttributes((prev) => [...prev, { name, weight }]);
|
|
19738
|
+
}
|
|
19739
|
+
setGraphDialog(null);
|
|
19740
|
+
} }, "Add")
|
|
19741
|
+
)
|
|
19742
|
+
)
|
|
19743
|
+
);
|
|
19744
|
+
}
|
|
19745
|
+
if (graphDialog === "delete") {
|
|
19746
|
+
graphDialogEl = createElement(
|
|
19747
|
+
"div",
|
|
19748
|
+
{
|
|
19749
|
+
style: dialogOverlayStyle,
|
|
19750
|
+
onClick: () => setGraphDialog(null)
|
|
19751
|
+
},
|
|
19752
|
+
createElement(
|
|
19753
|
+
"div",
|
|
19754
|
+
{
|
|
19755
|
+
style: dialogBoxStyle,
|
|
19756
|
+
onClick: (e) => e.stopPropagation(),
|
|
19757
|
+
role: "dialog",
|
|
19758
|
+
"aria-label": "Delete edge attribute"
|
|
19759
|
+
},
|
|
19760
|
+
createElement("div", { style: dialogTitleStyle }, "Delete Edge Attribute"),
|
|
19761
|
+
graphAttributes.length === 0 ? createElement("div", { style: { color: "#94a3b8", padding: "8px 0" } }, "No attributes defined.") : createElement(
|
|
19762
|
+
"div",
|
|
19763
|
+
{ style: { display: "flex", flexDirection: "column", gap: "4px" } },
|
|
19764
|
+
...graphAttributes.map(
|
|
19765
|
+
(attr, idx) => createElement(
|
|
19766
|
+
"div",
|
|
19767
|
+
{
|
|
19768
|
+
key: String(idx),
|
|
19769
|
+
style: {
|
|
19770
|
+
display: "flex",
|
|
19771
|
+
alignItems: "center",
|
|
19772
|
+
justifyContent: "space-between",
|
|
19773
|
+
padding: "6px 8px",
|
|
19774
|
+
borderRadius: "4px",
|
|
19775
|
+
border: "1px solid #e5e7eb"
|
|
19776
|
+
}
|
|
19777
|
+
},
|
|
19778
|
+
createElement("span", { style: { fontSize: "13px" } }, `${attr.name} (weight: ${attr.weight})`),
|
|
19779
|
+
createElement("button", {
|
|
19780
|
+
style: { border: "none", backgroundColor: "transparent", color: "#ef4444", cursor: "pointer", fontSize: "16px" },
|
|
19781
|
+
onClick: () => setGraphAttributes((prev) => prev.filter((_, i) => i !== idx))
|
|
19782
|
+
}, "\xD7")
|
|
19783
|
+
)
|
|
19784
|
+
)
|
|
19785
|
+
),
|
|
19786
|
+
createElement(
|
|
19787
|
+
"div",
|
|
19788
|
+
{ style: { display: "flex", justifyContent: "flex-end", marginTop: "12px" } },
|
|
19789
|
+
createElement("button", { style: dialogBtnSecondary, onClick: () => setGraphDialog(null) }, "Done")
|
|
19790
|
+
)
|
|
19791
|
+
)
|
|
19792
|
+
);
|
|
19793
|
+
}
|
|
19794
|
+
if (graphDialog === "edit") {
|
|
19795
|
+
graphDialogEl = createElement(
|
|
19796
|
+
"div",
|
|
19797
|
+
{
|
|
19798
|
+
style: dialogOverlayStyle,
|
|
19799
|
+
onClick: () => setGraphDialog(null)
|
|
19800
|
+
},
|
|
19801
|
+
createElement(
|
|
19802
|
+
"div",
|
|
19803
|
+
{
|
|
19804
|
+
style: { ...dialogBoxStyle, minWidth: "400px" },
|
|
19805
|
+
onClick: (e) => e.stopPropagation(),
|
|
19806
|
+
role: "dialog",
|
|
19807
|
+
"aria-label": "Edit edge attributes"
|
|
19808
|
+
},
|
|
19809
|
+
createElement("div", { style: dialogTitleStyle }, "Edit Edge Attributes"),
|
|
19810
|
+
editAttrs.length === 0 ? createElement("div", { style: { color: "#94a3b8", padding: "8px 0" } }, "No attributes defined.") : createElement(
|
|
19811
|
+
"div",
|
|
19812
|
+
{ style: { display: "flex", flexDirection: "column", gap: "6px" } },
|
|
19813
|
+
...editAttrs.map(
|
|
19814
|
+
(attr, idx) => createElement(
|
|
19815
|
+
"div",
|
|
19816
|
+
{
|
|
19817
|
+
key: String(idx),
|
|
19818
|
+
style: { display: "flex", alignItems: "center", gap: "8px" }
|
|
19819
|
+
},
|
|
19820
|
+
createElement("input", {
|
|
19821
|
+
type: "text",
|
|
19822
|
+
value: attr.name,
|
|
19823
|
+
style: { ...dialogInputStyle, flex: "1" },
|
|
19824
|
+
onInput: (e) => {
|
|
19825
|
+
const val = e.target.value;
|
|
19826
|
+
setEditAttrs((prev) => prev.map((a, i) => i === idx ? { ...a, name: val } : a));
|
|
19827
|
+
}
|
|
19828
|
+
}),
|
|
19829
|
+
createElement("input", {
|
|
19830
|
+
type: "number",
|
|
19831
|
+
value: String(attr.weight),
|
|
19832
|
+
min: "0",
|
|
19833
|
+
step: "1",
|
|
19834
|
+
style: { ...dialogInputStyle, width: "80px" },
|
|
19835
|
+
onInput: (e) => {
|
|
19836
|
+
const val = parseFloat(e.target.value) || 0;
|
|
19837
|
+
setEditAttrs((prev) => prev.map((a, i) => i === idx ? { ...a, weight: val } : a));
|
|
19838
|
+
}
|
|
19839
|
+
})
|
|
19840
|
+
)
|
|
19841
|
+
)
|
|
19842
|
+
),
|
|
19843
|
+
createElement(
|
|
19844
|
+
"div",
|
|
19845
|
+
{ style: { display: "flex", justifyContent: "flex-end", gap: "8px", marginTop: "12px" } },
|
|
19846
|
+
createElement("button", { style: dialogBtnSecondary, onClick: () => setGraphDialog(null) }, "Cancel"),
|
|
19847
|
+
createElement("button", { style: dialogBtnPrimary, onClick: () => {
|
|
19848
|
+
setGraphAttributes(editAttrs.filter((a) => a.name.trim()));
|
|
19849
|
+
setGraphDialog(null);
|
|
19850
|
+
} }, "Save")
|
|
19851
|
+
)
|
|
19852
|
+
)
|
|
19853
|
+
);
|
|
19854
|
+
}
|
|
18687
19855
|
return createElement(
|
|
18688
19856
|
"div",
|
|
18689
19857
|
{
|
|
@@ -18709,7 +19877,7 @@ function ProjectManagerApp(props) {
|
|
|
18709
19877
|
createElement(
|
|
18710
19878
|
InterAppWrapper,
|
|
18711
19879
|
{
|
|
18712
|
-
|
|
19880
|
+
collection: state.collection,
|
|
18713
19881
|
onCardDropped: handleCardDropped
|
|
18714
19882
|
},
|
|
18715
19883
|
createElement(Board, {
|
|
@@ -18717,13 +19885,18 @@ function ProjectManagerApp(props) {
|
|
|
18717
19885
|
dispatch,
|
|
18718
19886
|
searchQuery,
|
|
18719
19887
|
gridEnabled,
|
|
18720
|
-
selectedCardId,
|
|
18721
|
-
|
|
19888
|
+
selectedId: selectedCardId,
|
|
19889
|
+
onSelectItem: handleSelectCard,
|
|
18722
19890
|
colorFilter,
|
|
18723
|
-
|
|
19891
|
+
onUpdateItem: (cardId, updates) => {
|
|
19892
|
+
dispatch({ type: "UPDATE_CARD", cardId, updates });
|
|
19893
|
+
},
|
|
19894
|
+
onCardContextMenu: (cardId, pos) => {
|
|
19895
|
+
}
|
|
18724
19896
|
})
|
|
18725
19897
|
),
|
|
18726
|
-
renameDialogEl
|
|
19898
|
+
renameDialogEl,
|
|
19899
|
+
graphDialogEl
|
|
18727
19900
|
);
|
|
18728
19901
|
}
|
|
18729
19902
|
|
|
@@ -18884,7 +20057,7 @@ function FilesContent() {
|
|
|
18884
20057
|
) : null
|
|
18885
20058
|
);
|
|
18886
20059
|
}
|
|
18887
|
-
function getMockContent(title) {
|
|
20060
|
+
function getMockContent(title, windowId, onTitleChange) {
|
|
18888
20061
|
const contentStyle = {
|
|
18889
20062
|
padding: "16px",
|
|
18890
20063
|
fontSize: "13px",
|
|
@@ -18938,7 +20111,10 @@ function getMockContent(title) {
|
|
|
18938
20111
|
case "Trading":
|
|
18939
20112
|
return createElement(TradingDashboard, null);
|
|
18940
20113
|
case "Project Board":
|
|
18941
|
-
return createElement(ProjectManagerApp,
|
|
20114
|
+
return createElement(ProjectManagerApp, {
|
|
20115
|
+
boardId: windowId || "default",
|
|
20116
|
+
onTitleChange: onTitleChange || void 0
|
|
20117
|
+
});
|
|
18942
20118
|
default:
|
|
18943
20119
|
return createElement(
|
|
18944
20120
|
"div",
|
|
@@ -18981,6 +20157,15 @@ function UnityDesktopInner(props) {
|
|
|
18981
20157
|
appsRef.current = apps;
|
|
18982
20158
|
const onAppOpenRef = useRef(onAppOpen);
|
|
18983
20159
|
onAppOpenRef.current = onAppOpen;
|
|
20160
|
+
const titleChangeCallbacks = useRef({});
|
|
20161
|
+
for (const w of openWindows) {
|
|
20162
|
+
if (!titleChangeCallbacks.current[w.id]) {
|
|
20163
|
+
const winId = w.id;
|
|
20164
|
+
titleChangeCallbacks.current[winId] = (newTitle) => {
|
|
20165
|
+
setOpenWindows((prev) => prev.map((ww) => ww.id === winId ? { ...ww, title: newTitle } : ww));
|
|
20166
|
+
};
|
|
20167
|
+
}
|
|
20168
|
+
}
|
|
18984
20169
|
const openNewInstance = useCallback((appId) => {
|
|
18985
20170
|
const currentApps = appsRef.current;
|
|
18986
20171
|
const app = currentApps.find((a) => a.id === appId);
|
|
@@ -19240,7 +20425,11 @@ function UnityDesktopInner(props) {
|
|
|
19240
20425
|
setOpenWindows((prev) => prev.map((ww) => ww.id === w.id ? { ...ww, windowState: ww.windowState === "maximized" ? "normal" : "maximized" } : ww));
|
|
19241
20426
|
}
|
|
19242
20427
|
},
|
|
19243
|
-
getMockContent(
|
|
20428
|
+
getMockContent(
|
|
20429
|
+
apps.find((a) => a.id === w.appId)?.label || w.title,
|
|
20430
|
+
w.id,
|
|
20431
|
+
titleChangeCallbacks.current[w.id]
|
|
20432
|
+
)
|
|
19244
20433
|
));
|
|
19245
20434
|
const desktopContentChildren = [];
|
|
19246
20435
|
if (children) {
|
|
@@ -19353,7 +20542,7 @@ function UnityDesktopInner(props) {
|
|
|
19353
20542
|
if (ctxInstances.length > 0) {
|
|
19354
20543
|
menuChildren.push(createElement("div", { key: "sep-1", style: separatorStyle }));
|
|
19355
20544
|
ctxInstances.forEach((inst, idx) => {
|
|
19356
|
-
const displayLabel =
|
|
20545
|
+
const displayLabel = inst.title;
|
|
19357
20546
|
menuChildren.push(createElement("div", {
|
|
19358
20547
|
key: `inst-${inst.id}`,
|
|
19359
20548
|
style: menuItemStyle,
|
|
@@ -19470,7 +20659,7 @@ function UnityDesktopInner(props) {
|
|
|
19470
20659
|
}, dockEl),
|
|
19471
20660
|
createElement("main", {
|
|
19472
20661
|
className: "unity-desktop__desktop",
|
|
19473
|
-
style: { flex: "1", position: "relative" }
|
|
20662
|
+
style: { flex: "1", position: "relative", overflow: "hidden", minHeight: "0" }
|
|
19474
20663
|
}, desktopEl, appsGridEl)
|
|
19475
20664
|
),
|
|
19476
20665
|
// Overlays
|
|
@@ -21669,9 +22858,9 @@ function CalendarHeatMap(props) {
|
|
|
21669
22858
|
if (latest === null || parsed > latest) latest = parsed;
|
|
21670
22859
|
}
|
|
21671
22860
|
if (earliest === null || latest === null) {
|
|
21672
|
-
const
|
|
21673
|
-
earliest = new Date(
|
|
21674
|
-
latest = new Date(
|
|
22861
|
+
const now2 = /* @__PURE__ */ new Date();
|
|
22862
|
+
earliest = new Date(now2.getFullYear(), 0, 1);
|
|
22863
|
+
latest = new Date(now2.getFullYear(), 11, 31);
|
|
21675
22864
|
}
|
|
21676
22865
|
const start = new Date(earliest);
|
|
21677
22866
|
start.setDate(start.getDate() - start.getDay());
|