@asymmetric-effort/specifyjs 0.2.150 → 0.2.151
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/components-barrel.js +1320 -1307
- package/dist/specifyjs-components.cjs.js +3 -3
- package/dist/specifyjs-components.esm.js +1320 -1307
- 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/Card.d.ts +6 -31
- package/dist/types/demos/project-manager/src/CardEditor.d.ts +2 -2
- package/dist/types/demos/project-manager/src/Connection.d.ts +6 -11
- package/dist/types/demos/project-manager/src/InterApp.d.ts +2 -2
- package/dist/types/demos/project-manager/src/index.d.ts +3 -2
- package/dist/types/demos/project-manager/src/types.d.ts +6 -45
- package/package.json +1 -1
|
@@ -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,352 +16453,149 @@ 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 } = props;
|
|
16678
16575
|
const [hovered, setHovered] = useState(false);
|
|
16679
|
-
const [
|
|
16680
|
-
const [
|
|
16681
|
-
const [titleDraft, setTitleDraft] = useState(card.title || "");
|
|
16682
|
-
const [descDraft, setDescDraft] = useState(card.description || "");
|
|
16576
|
+
const [contextMenu, setContextMenu] = useState(null);
|
|
16577
|
+
const [typeSubmenuOpen, setTypeSubmenuOpen] = useState(false);
|
|
16683
16578
|
const dragStartRef = useRef(null);
|
|
16684
16579
|
const resizeStartRef = useRef(null);
|
|
16685
|
-
const cardRef = useRef(null);
|
|
16686
|
-
const titleInputRef = useRef(null);
|
|
16687
|
-
const descTextareaRef = useRef(null);
|
|
16688
16580
|
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
16581
|
const handleContextMenu = useCallback((e) => {
|
|
16694
16582
|
const me = e;
|
|
16695
16583
|
me.preventDefault();
|
|
16696
16584
|
me.stopPropagation();
|
|
16697
|
-
|
|
16698
|
-
|
|
16699
|
-
}
|
|
16700
|
-
}, [card.id, onCardContextMenu]);
|
|
16701
|
-
useEffect(() => {
|
|
16702
|
-
if (editingTitle && titleInputRef.current) {
|
|
16703
|
-
const input = titleInputRef.current;
|
|
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);
|
|
16585
|
+
setContextMenu({ x: me.clientX, y: me.clientY });
|
|
16586
|
+
setTypeSubmenuOpen(false);
|
|
16725
16587
|
}, []);
|
|
16726
|
-
const
|
|
16727
|
-
|
|
16728
|
-
|
|
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);
|
|
16588
|
+
const closeContextMenu = useCallback(() => {
|
|
16589
|
+
setContextMenu(null);
|
|
16590
|
+
setTypeSubmenuOpen(false);
|
|
16753
16591
|
}, []);
|
|
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
16592
|
const handleMouseDown = useCallback((e) => {
|
|
16796
16593
|
const me = e;
|
|
16797
16594
|
const target = me.target;
|
|
16798
|
-
if (target.dataset && (target.dataset.role === "delete" || target.dataset.role === "resize" || target.dataset.role === "
|
|
16595
|
+
if (target.dataset && (target.dataset.role === "delete" || target.dataset.role === "resize" || target.dataset.role === "drag-handle")) return;
|
|
16799
16596
|
me.preventDefault();
|
|
16800
16597
|
me.stopPropagation();
|
|
16801
|
-
onSelect(card.
|
|
16598
|
+
if (onSelect) onSelect(card.card_id);
|
|
16802
16599
|
dragStartRef.current = {
|
|
16803
16600
|
x: me.clientX,
|
|
16804
16601
|
y: me.clientY,
|
|
@@ -16810,10 +16607,12 @@ function Card2(props) {
|
|
|
16810
16607
|
if (!dragStartRef.current) return;
|
|
16811
16608
|
const dx = mev.clientX - dragStartRef.current.x;
|
|
16812
16609
|
const dy = mev.clientY - dragStartRef.current.y;
|
|
16813
|
-
onMove
|
|
16814
|
-
|
|
16815
|
-
|
|
16816
|
-
|
|
16610
|
+
if (onMove) {
|
|
16611
|
+
onMove(card.card_id, {
|
|
16612
|
+
x: dragStartRef.current.cardX + dx,
|
|
16613
|
+
y: dragStartRef.current.cardY + dy
|
|
16614
|
+
});
|
|
16615
|
+
}
|
|
16817
16616
|
};
|
|
16818
16617
|
const handleMouseUp = () => {
|
|
16819
16618
|
dragStartRef.current = null;
|
|
@@ -16822,10 +16621,7 @@ function Card2(props) {
|
|
|
16822
16621
|
};
|
|
16823
16622
|
document.addEventListener("mousemove", handleMouseMove);
|
|
16824
16623
|
document.addEventListener("mouseup", handleMouseUp);
|
|
16825
|
-
|
|
16826
|
-
onDragStart(card.id, e);
|
|
16827
|
-
}
|
|
16828
|
-
}, [card.id, card.position.x, card.position.y, onSelect, onMove, onDragStart]);
|
|
16624
|
+
}, [card.card_id, card.position.x, card.position.y, onSelect, onMove]);
|
|
16829
16625
|
const handleResizeMouseDown = useCallback((e) => {
|
|
16830
16626
|
const me = e;
|
|
16831
16627
|
me.preventDefault();
|
|
@@ -16843,7 +16639,9 @@ function Card2(props) {
|
|
|
16843
16639
|
const dy = mev.clientY - resizeStartRef.current.y;
|
|
16844
16640
|
const newW = Math.max(120, resizeStartRef.current.w + dx);
|
|
16845
16641
|
const newH = Math.max(80, resizeStartRef.current.h + dy);
|
|
16846
|
-
onResize
|
|
16642
|
+
if (onResize) {
|
|
16643
|
+
onResize(card.card_id, { width: newW, height: newH });
|
|
16644
|
+
}
|
|
16847
16645
|
};
|
|
16848
16646
|
const handleMouseUp = () => {
|
|
16849
16647
|
resizeStartRef.current = null;
|
|
@@ -16852,16 +16650,36 @@ function Card2(props) {
|
|
|
16852
16650
|
};
|
|
16853
16651
|
document.addEventListener("mousemove", handleMouseMove);
|
|
16854
16652
|
document.addEventListener("mouseup", handleMouseUp);
|
|
16855
|
-
}, [card.
|
|
16856
|
-
const handleDoubleClick = useCallback((e) => {
|
|
16857
|
-
e.preventDefault();
|
|
16858
|
-
e.stopPropagation();
|
|
16859
|
-
}, []);
|
|
16653
|
+
}, [card.card_id, card.size.width, card.size.height, onResize]);
|
|
16860
16654
|
const handleDeleteClick = useCallback((e) => {
|
|
16861
16655
|
e.preventDefault();
|
|
16862
16656
|
e.stopPropagation();
|
|
16863
|
-
onDelete(card.
|
|
16864
|
-
}, [card.
|
|
16657
|
+
if (onDelete) onDelete(card.card_id);
|
|
16658
|
+
}, [card.card_id, onDelete]);
|
|
16659
|
+
const handleChangeType = useCallback((newType) => {
|
|
16660
|
+
if (dispatch) {
|
|
16661
|
+
dispatch({ type: "CHANGE_CARD_TYPE", cardId: card.card_id, newType });
|
|
16662
|
+
}
|
|
16663
|
+
closeContextMenu();
|
|
16664
|
+
}, [card.card_id, dispatch, closeContextMenu]);
|
|
16665
|
+
let contentEl;
|
|
16666
|
+
switch (card.card_type) {
|
|
16667
|
+
case "text":
|
|
16668
|
+
contentEl = renderTextContent(card);
|
|
16669
|
+
break;
|
|
16670
|
+
case "json":
|
|
16671
|
+
contentEl = renderJsonContent(card);
|
|
16672
|
+
break;
|
|
16673
|
+
case "task":
|
|
16674
|
+
contentEl = renderTaskContent(card);
|
|
16675
|
+
break;
|
|
16676
|
+
case "project":
|
|
16677
|
+
contentEl = renderProjectContent(card, onOpenProject);
|
|
16678
|
+
break;
|
|
16679
|
+
default:
|
|
16680
|
+
contentEl = renderTextContent(card);
|
|
16681
|
+
}
|
|
16682
|
+
const isProjectPill = card.card_type === "project";
|
|
16865
16683
|
const cardStyle = {
|
|
16866
16684
|
position: "absolute",
|
|
16867
16685
|
left: `${card.position.x}px`,
|
|
@@ -16869,7 +16687,7 @@ function Card2(props) {
|
|
|
16869
16687
|
width: `${card.size.width}px`,
|
|
16870
16688
|
height: `${card.size.height}px`,
|
|
16871
16689
|
backgroundColor: card.color || "#fef9c3",
|
|
16872
|
-
borderRadius: "6px",
|
|
16690
|
+
borderRadius: isProjectPill ? "999px" : "6px",
|
|
16873
16691
|
borderLeft: `4px solid ${priorityColor}`,
|
|
16874
16692
|
boxShadow: selected ? "0 0 0 2px #3b82f6, 0 4px 12px rgba(0,0,0,0.15)" : "0 2px 8px rgba(0,0,0,0.1)",
|
|
16875
16693
|
cursor: "grab",
|
|
@@ -16879,7 +16697,8 @@ function Card2(props) {
|
|
|
16879
16697
|
flexDirection: "column",
|
|
16880
16698
|
padding: "8px 10px",
|
|
16881
16699
|
boxSizing: "border-box",
|
|
16882
|
-
transition: "box-shadow 150ms ease"
|
|
16700
|
+
transition: "box-shadow 150ms ease",
|
|
16701
|
+
zIndex: "1"
|
|
16883
16702
|
};
|
|
16884
16703
|
const titleStyle = {
|
|
16885
16704
|
fontWeight: "600",
|
|
@@ -16891,13 +16710,6 @@ function Card2(props) {
|
|
|
16891
16710
|
textOverflow: "ellipsis",
|
|
16892
16711
|
whiteSpace: "nowrap"
|
|
16893
16712
|
};
|
|
16894
|
-
const descStyle = {
|
|
16895
|
-
fontSize: "12px",
|
|
16896
|
-
color: "#555555",
|
|
16897
|
-
lineHeight: "1.4",
|
|
16898
|
-
overflow: "hidden",
|
|
16899
|
-
flex: "1"
|
|
16900
|
-
};
|
|
16901
16713
|
const deleteStyle = {
|
|
16902
16714
|
position: "absolute",
|
|
16903
16715
|
top: "4px",
|
|
@@ -16925,29 +16737,23 @@ function Card2(props) {
|
|
|
16925
16737
|
opacity: "0.4",
|
|
16926
16738
|
background: "linear-gradient(135deg, transparent 50%, #666 50%)"
|
|
16927
16739
|
};
|
|
16928
|
-
const
|
|
16929
|
-
"
|
|
16930
|
-
|
|
16931
|
-
|
|
16932
|
-
|
|
16933
|
-
|
|
16934
|
-
|
|
16935
|
-
|
|
16936
|
-
|
|
16937
|
-
|
|
16938
|
-
|
|
16939
|
-
|
|
16940
|
-
|
|
16941
|
-
|
|
16942
|
-
|
|
16943
|
-
|
|
16944
|
-
|
|
16945
|
-
backgroundColor: "rgba(0,0,0,0.08)",
|
|
16946
|
-
color: "#444"
|
|
16947
|
-
}
|
|
16948
|
-
}, tag)
|
|
16949
|
-
)
|
|
16950
|
-
) : null;
|
|
16740
|
+
const dragHandleStyle = {
|
|
16741
|
+
position: "absolute",
|
|
16742
|
+
top: "4px",
|
|
16743
|
+
right: "24px",
|
|
16744
|
+
width: "18px",
|
|
16745
|
+
height: "18px",
|
|
16746
|
+
borderRadius: "3px",
|
|
16747
|
+
backgroundColor: "rgba(0,0,0,0.1)",
|
|
16748
|
+
color: "#333",
|
|
16749
|
+
fontSize: "10px",
|
|
16750
|
+
lineHeight: "18px",
|
|
16751
|
+
textAlign: "center",
|
|
16752
|
+
cursor: "grab",
|
|
16753
|
+
display: hovered ? "block" : "none",
|
|
16754
|
+
border: "none",
|
|
16755
|
+
padding: "0"
|
|
16756
|
+
};
|
|
16951
16757
|
const assigneeEl = card.assignee ? createElement(
|
|
16952
16758
|
"div",
|
|
16953
16759
|
{
|
|
@@ -16959,7 +16765,7 @@ function Card2(props) {
|
|
|
16959
16765
|
fontSize: "10px",
|
|
16960
16766
|
color: "#555"
|
|
16961
16767
|
},
|
|
16962
|
-
"data-testid": `card-assignee-${card.
|
|
16768
|
+
"data-testid": `card-assignee-${card.card_id}`
|
|
16963
16769
|
},
|
|
16964
16770
|
createElement("span", {
|
|
16965
16771
|
style: {
|
|
@@ -16978,127 +16784,192 @@ function Card2(props) {
|
|
|
16978
16784
|
}, card.assignee.charAt(0).toUpperCase()),
|
|
16979
16785
|
createElement("span", {}, card.assignee)
|
|
16980
16786
|
) : null;
|
|
16981
|
-
const
|
|
16982
|
-
|
|
16983
|
-
|
|
16984
|
-
|
|
16985
|
-
|
|
16986
|
-
|
|
16987
|
-
|
|
16988
|
-
|
|
16989
|
-
|
|
16990
|
-
|
|
16991
|
-
|
|
16992
|
-
|
|
16993
|
-
|
|
16994
|
-
|
|
16995
|
-
|
|
16996
|
-
|
|
16787
|
+
const tagsEl = card.tags && card.tags.length > 0 ? createElement(
|
|
16788
|
+
"div",
|
|
16789
|
+
{
|
|
16790
|
+
style: {
|
|
16791
|
+
display: "flex",
|
|
16792
|
+
gap: "4px",
|
|
16793
|
+
flexWrap: "wrap",
|
|
16794
|
+
marginTop: "4px"
|
|
16795
|
+
}
|
|
16796
|
+
},
|
|
16797
|
+
...card.tags.map(
|
|
16798
|
+
(tag, i) => createElement("span", {
|
|
16799
|
+
key: String(i),
|
|
16800
|
+
style: {
|
|
16801
|
+
fontSize: "10px",
|
|
16802
|
+
padding: "1px 4px",
|
|
16803
|
+
borderRadius: "3px",
|
|
16804
|
+
backgroundColor: "rgba(0,0,0,0.08)",
|
|
16805
|
+
color: "#444"
|
|
16806
|
+
}
|
|
16807
|
+
}, tag)
|
|
16808
|
+
)
|
|
16809
|
+
) : null;
|
|
16810
|
+
const ctxMenuItemStyle = {
|
|
16811
|
+
padding: "6px 12px",
|
|
16812
|
+
cursor: "pointer",
|
|
16813
|
+
display: "flex",
|
|
16814
|
+
alignItems: "center",
|
|
16815
|
+
justifyContent: "space-between",
|
|
16816
|
+
whiteSpace: "nowrap"
|
|
16997
16817
|
};
|
|
16998
|
-
const
|
|
16818
|
+
const ctxSubmenuStyle = {
|
|
16999
16819
|
position: "absolute",
|
|
17000
|
-
|
|
17001
|
-
|
|
17002
|
-
|
|
17003
|
-
|
|
17004
|
-
|
|
17005
|
-
|
|
17006
|
-
|
|
17007
|
-
|
|
17008
|
-
boxSizing: "border-box"
|
|
16820
|
+
left: "100%",
|
|
16821
|
+
top: "0",
|
|
16822
|
+
backgroundColor: "#ffffff",
|
|
16823
|
+
border: "1px solid #d1d5db",
|
|
16824
|
+
borderRadius: "6px",
|
|
16825
|
+
boxShadow: "0 4px 16px rgba(0,0,0,0.15)",
|
|
16826
|
+
padding: "4px 0",
|
|
16827
|
+
minWidth: "120px"
|
|
17009
16828
|
};
|
|
17010
|
-
const
|
|
17011
|
-
|
|
17012
|
-
|
|
17013
|
-
|
|
16829
|
+
const contextMenuEl = contextMenu ? createElement(
|
|
16830
|
+
"div",
|
|
16831
|
+
{
|
|
16832
|
+
className: "card-context-menu",
|
|
16833
|
+
style: {
|
|
16834
|
+
position: "fixed",
|
|
16835
|
+
left: `${contextMenu.x}px`,
|
|
16836
|
+
top: `${contextMenu.y}px`,
|
|
16837
|
+
backgroundColor: "#ffffff",
|
|
16838
|
+
border: "1px solid #d1d5db",
|
|
16839
|
+
borderRadius: "6px",
|
|
16840
|
+
boxShadow: "0 4px 16px rgba(0,0,0,0.15)",
|
|
16841
|
+
padding: "4px 0",
|
|
16842
|
+
zIndex: "10000",
|
|
16843
|
+
minWidth: "160px",
|
|
16844
|
+
fontSize: "13px",
|
|
16845
|
+
color: "#1a1a1a"
|
|
16846
|
+
},
|
|
16847
|
+
"data-testid": `card-context-menu-${card.card_id}`,
|
|
16848
|
+
role: "menu",
|
|
16849
|
+
"aria-label": "Card context menu",
|
|
16850
|
+
onClick: (e) => e.stopPropagation()
|
|
16851
|
+
},
|
|
16852
|
+
// Delete
|
|
16853
|
+
createElement("div", {
|
|
16854
|
+
style: ctxMenuItemStyle,
|
|
16855
|
+
onClick: (e) => {
|
|
16856
|
+
e.stopPropagation();
|
|
16857
|
+
if (onDelete) onDelete(card.card_id);
|
|
16858
|
+
closeContextMenu();
|
|
16859
|
+
},
|
|
16860
|
+
role: "menuitem",
|
|
16861
|
+
"data-testid": `ctx-delete-${card.card_id}`
|
|
16862
|
+
}, "Delete"),
|
|
16863
|
+
// Change Type submenu
|
|
16864
|
+
createElement(
|
|
16865
|
+
"div",
|
|
16866
|
+
{
|
|
16867
|
+
style: { ...ctxMenuItemStyle, position: "relative" },
|
|
16868
|
+
onMouseEnter: () => setTypeSubmenuOpen(true),
|
|
16869
|
+
role: "menuitem",
|
|
16870
|
+
"aria-haspopup": "true",
|
|
16871
|
+
"data-testid": `ctx-change-type-${card.card_id}`
|
|
16872
|
+
},
|
|
16873
|
+
"Change Type",
|
|
16874
|
+
createElement("span", { style: { marginLeft: "8px" } }, "\u25B6"),
|
|
16875
|
+
typeSubmenuOpen ? createElement(
|
|
16876
|
+
"div",
|
|
16877
|
+
{
|
|
16878
|
+
style: ctxSubmenuStyle,
|
|
16879
|
+
role: "menu",
|
|
16880
|
+
"data-testid": `ctx-type-submenu-${card.card_id}`
|
|
16881
|
+
},
|
|
16882
|
+
...CARD_TYPE_OPTIONS.map(
|
|
16883
|
+
(opt) => createElement(
|
|
16884
|
+
"div",
|
|
16885
|
+
{
|
|
16886
|
+
key: opt.value,
|
|
16887
|
+
style: {
|
|
16888
|
+
...ctxMenuItemStyle,
|
|
16889
|
+
fontWeight: card.card_type === opt.value ? "700" : "400"
|
|
16890
|
+
},
|
|
16891
|
+
onClick: (e) => {
|
|
16892
|
+
e.stopPropagation();
|
|
16893
|
+
handleChangeType(opt.value);
|
|
16894
|
+
},
|
|
16895
|
+
role: "menuitem",
|
|
16896
|
+
"data-testid": `ctx-type-${opt.value}-${card.card_id}`
|
|
16897
|
+
},
|
|
16898
|
+
opt.label,
|
|
16899
|
+
card.card_type === opt.value ? " \u2713" : ""
|
|
16900
|
+
)
|
|
16901
|
+
)
|
|
16902
|
+
) : null
|
|
16903
|
+
)
|
|
16904
|
+
) : null;
|
|
16905
|
+
if (isProjectPill) {
|
|
16906
|
+
return createElement(
|
|
16907
|
+
"div",
|
|
16908
|
+
{
|
|
16909
|
+
className: "board-card board-card--project",
|
|
16910
|
+
style: cardStyle,
|
|
16911
|
+
onMouseDown: handleMouseDown,
|
|
16912
|
+
onContextMenu: handleContextMenu,
|
|
16913
|
+
onMouseEnter: () => setHovered(true),
|
|
16914
|
+
onMouseLeave: () => {
|
|
16915
|
+
setHovered(false);
|
|
16916
|
+
closeContextMenu();
|
|
16917
|
+
},
|
|
16918
|
+
"data-card-id": card.card_id,
|
|
16919
|
+
"data-testid": `card-${card.card_id}`,
|
|
16920
|
+
role: "button",
|
|
16921
|
+
"aria-label": `Project card: ${card.card_title}`,
|
|
16922
|
+
tabIndex: 0
|
|
16923
|
+
},
|
|
16924
|
+
contentEl,
|
|
16925
|
+
createElement("div", {
|
|
16926
|
+
style: dragHandleStyle,
|
|
16927
|
+
"data-role": "drag-handle",
|
|
16928
|
+
"data-testid": `card-drag-handle-${card.card_id}`,
|
|
16929
|
+
"aria-label": "Export drag handle",
|
|
16930
|
+
title: "Drag to export card"
|
|
16931
|
+
}, "\u2630"),
|
|
16932
|
+
contextMenuEl
|
|
16933
|
+
);
|
|
16934
|
+
}
|
|
17014
16935
|
return createElement(
|
|
17015
16936
|
"div",
|
|
17016
16937
|
{
|
|
17017
|
-
ref: cardRef,
|
|
17018
16938
|
className: "board-card",
|
|
17019
16939
|
style: cardStyle,
|
|
17020
16940
|
onMouseDown: handleMouseDown,
|
|
17021
|
-
onDblClick: handleDoubleClick,
|
|
17022
16941
|
onContextMenu: handleContextMenu,
|
|
17023
16942
|
onMouseEnter: () => setHovered(true),
|
|
17024
|
-
onMouseLeave: () =>
|
|
17025
|
-
|
|
17026
|
-
|
|
16943
|
+
onMouseLeave: () => {
|
|
16944
|
+
setHovered(false);
|
|
16945
|
+
closeContextMenu();
|
|
16946
|
+
},
|
|
16947
|
+
"data-card-id": card.card_id,
|
|
16948
|
+
"data-testid": `card-${card.card_id}`,
|
|
17027
16949
|
role: "button",
|
|
17028
|
-
"aria-label": `Card: ${card.
|
|
16950
|
+
"aria-label": `Card: ${card.card_title}`,
|
|
17029
16951
|
tabIndex: 0
|
|
17030
16952
|
},
|
|
17031
|
-
|
|
17032
|
-
ref: titleInputRef,
|
|
17033
|
-
type: "text",
|
|
17034
|
-
value: titleDraft,
|
|
17035
|
-
onInput: handleTitleInput,
|
|
17036
|
-
style: {
|
|
17037
|
-
...titleStyle,
|
|
17038
|
-
width: "100%",
|
|
17039
|
-
border: "none",
|
|
17040
|
-
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", {
|
|
16953
|
+
createElement("div", {
|
|
17053
16954
|
style: titleStyle,
|
|
17054
|
-
|
|
17055
|
-
|
|
17056
|
-
|
|
17057
|
-
editingDescription ? createElement("textarea", {
|
|
17058
|
-
ref: descTextareaRef,
|
|
17059
|
-
value: descDraft,
|
|
17060
|
-
onInput: handleDescInput,
|
|
17061
|
-
style: {
|
|
17062
|
-
...descStyle,
|
|
17063
|
-
width: "100%",
|
|
17064
|
-
border: "none",
|
|
17065
|
-
outline: "none",
|
|
17066
|
-
backgroundColor: "transparent",
|
|
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()
|
|
17078
|
-
}) : createElement("div", {
|
|
17079
|
-
style: descStyle,
|
|
17080
|
-
onClick: handleDescriptionClick,
|
|
17081
|
-
"data-testid": `card-desc-${card.id}`
|
|
17082
|
-
}, card.description || ""),
|
|
16955
|
+
"data-testid": `card-title-${card.card_id}`
|
|
16956
|
+
}, card.card_title || "Untitled"),
|
|
16957
|
+
contentEl,
|
|
17083
16958
|
tagsEl,
|
|
17084
16959
|
assigneeEl,
|
|
17085
16960
|
createElement("div", {
|
|
17086
16961
|
style: dragHandleStyle,
|
|
17087
16962
|
"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}`,
|
|
16963
|
+
"data-testid": `card-drag-handle-${card.card_id}`,
|
|
16964
|
+
"aria-label": `Export drag handle for ${card.card_title}`,
|
|
17094
16965
|
title: "Drag to export card"
|
|
17095
16966
|
}, "\u2630"),
|
|
17096
16967
|
createElement("button", {
|
|
17097
16968
|
style: deleteStyle,
|
|
17098
16969
|
"data-role": "delete",
|
|
17099
|
-
"data-testid": `card-delete-${card.
|
|
16970
|
+
"data-testid": `card-delete-${card.card_id}`,
|
|
17100
16971
|
onClick: handleDeleteClick,
|
|
17101
|
-
"aria-label": `Delete ${card.
|
|
16972
|
+
"aria-label": `Delete ${card.card_title}`,
|
|
17102
16973
|
tabIndex: -1
|
|
17103
16974
|
}, "\xD7"),
|
|
17104
16975
|
createElement("div", {
|
|
@@ -17107,228 +16978,198 @@ function Card2(props) {
|
|
|
17107
16978
|
onMouseDown: handleResizeMouseDown,
|
|
17108
16979
|
"aria-label": "Resize card"
|
|
17109
16980
|
}),
|
|
17110
|
-
|
|
17111
|
-
createElement("div", {
|
|
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
|
-
})
|
|
16981
|
+
contextMenuEl
|
|
17143
16982
|
);
|
|
17144
16983
|
}
|
|
17145
16984
|
|
|
17146
|
-
// ../
|
|
17147
|
-
function
|
|
17148
|
-
const {
|
|
17149
|
-
const [
|
|
17150
|
-
const
|
|
17151
|
-
const
|
|
17152
|
-
const
|
|
17153
|
-
useEffect(() => {
|
|
17154
|
-
if (titleRef.current) {
|
|
17155
|
-
titleRef.current.focus();
|
|
17156
|
-
titleRef.current.select();
|
|
17157
|
-
}
|
|
17158
|
-
}, []);
|
|
17159
|
-
const save = useCallback(() => {
|
|
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) => {
|
|
16985
|
+
// ../components/data/board/src/Container.ts
|
|
16986
|
+
function ContainerComponent(props) {
|
|
16987
|
+
const { container, selected = false, onSelect, onMove, onResize, onDrop, children } = props;
|
|
16988
|
+
const [dragOver, setDragOver] = useState(false);
|
|
16989
|
+
const dragStartRef = useRef(null);
|
|
16990
|
+
const resizeStartRef = useRef(null);
|
|
16991
|
+
const handleTitleMouseDown = useCallback((e) => {
|
|
17170
16992
|
const me = e;
|
|
17171
|
-
|
|
17172
|
-
|
|
17173
|
-
|
|
17174
|
-
|
|
17175
|
-
|
|
17176
|
-
|
|
17177
|
-
|
|
17178
|
-
|
|
17179
|
-
|
|
17180
|
-
|
|
17181
|
-
|
|
17182
|
-
|
|
17183
|
-
|
|
17184
|
-
|
|
17185
|
-
|
|
17186
|
-
|
|
17187
|
-
|
|
17188
|
-
|
|
17189
|
-
|
|
17190
|
-
|
|
17191
|
-
|
|
17192
|
-
|
|
17193
|
-
|
|
17194
|
-
|
|
17195
|
-
|
|
17196
|
-
|
|
17197
|
-
|
|
17198
|
-
|
|
17199
|
-
|
|
17200
|
-
|
|
17201
|
-
|
|
17202
|
-
|
|
17203
|
-
|
|
17204
|
-
|
|
17205
|
-
|
|
17206
|
-
|
|
17207
|
-
|
|
17208
|
-
|
|
17209
|
-
|
|
17210
|
-
|
|
17211
|
-
|
|
17212
|
-
|
|
17213
|
-
|
|
17214
|
-
|
|
17215
|
-
|
|
17216
|
-
|
|
17217
|
-
|
|
17218
|
-
|
|
17219
|
-
|
|
17220
|
-
|
|
16993
|
+
me.preventDefault();
|
|
16994
|
+
me.stopPropagation();
|
|
16995
|
+
if (onSelect) onSelect(container.container_id);
|
|
16996
|
+
dragStartRef.current = {
|
|
16997
|
+
x: me.clientX,
|
|
16998
|
+
y: me.clientY,
|
|
16999
|
+
posX: container.position.x,
|
|
17000
|
+
posY: container.position.y
|
|
17001
|
+
};
|
|
17002
|
+
const handleMouseMove = (ev) => {
|
|
17003
|
+
const mev = ev;
|
|
17004
|
+
if (!dragStartRef.current) return;
|
|
17005
|
+
const dx = mev.clientX - dragStartRef.current.x;
|
|
17006
|
+
const dy = mev.clientY - dragStartRef.current.y;
|
|
17007
|
+
if (onMove) {
|
|
17008
|
+
onMove(container.container_id, {
|
|
17009
|
+
x: dragStartRef.current.posX + dx,
|
|
17010
|
+
y: dragStartRef.current.posY + dy
|
|
17011
|
+
});
|
|
17012
|
+
}
|
|
17013
|
+
};
|
|
17014
|
+
const handleMouseUp = () => {
|
|
17015
|
+
dragStartRef.current = null;
|
|
17016
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
17017
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
17018
|
+
};
|
|
17019
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
17020
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
17021
|
+
}, [container.container_id, container.position.x, container.position.y, onSelect, onMove]);
|
|
17022
|
+
const handleResizeMouseDown = useCallback((e) => {
|
|
17023
|
+
const me = e;
|
|
17024
|
+
me.preventDefault();
|
|
17025
|
+
me.stopPropagation();
|
|
17026
|
+
resizeStartRef.current = {
|
|
17027
|
+
x: me.clientX,
|
|
17028
|
+
y: me.clientY,
|
|
17029
|
+
w: container.size.width,
|
|
17030
|
+
h: container.size.height
|
|
17031
|
+
};
|
|
17032
|
+
const handleMouseMove = (ev) => {
|
|
17033
|
+
const mev = ev;
|
|
17034
|
+
if (!resizeStartRef.current) return;
|
|
17035
|
+
const dx = mev.clientX - resizeStartRef.current.x;
|
|
17036
|
+
const dy = mev.clientY - resizeStartRef.current.y;
|
|
17037
|
+
const newW = Math.max(160, resizeStartRef.current.w + dx);
|
|
17038
|
+
const newH = Math.max(120, resizeStartRef.current.h + dy);
|
|
17039
|
+
if (onResize) {
|
|
17040
|
+
onResize(container.container_id, { width: newW, height: newH });
|
|
17041
|
+
}
|
|
17042
|
+
};
|
|
17043
|
+
const handleMouseUp = () => {
|
|
17044
|
+
resizeStartRef.current = null;
|
|
17045
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
17046
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
17047
|
+
};
|
|
17048
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
17049
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
17050
|
+
}, [container.container_id, container.size.width, container.size.height, onResize]);
|
|
17051
|
+
const handleDragOver = useCallback((e) => {
|
|
17052
|
+
const de = e;
|
|
17053
|
+
de.preventDefault();
|
|
17054
|
+
setDragOver(true);
|
|
17055
|
+
}, []);
|
|
17056
|
+
const handleDragLeave = useCallback(() => {
|
|
17057
|
+
setDragOver(false);
|
|
17058
|
+
}, []);
|
|
17059
|
+
const handleDrop = useCallback((e) => {
|
|
17060
|
+
const de = e;
|
|
17061
|
+
de.preventDefault();
|
|
17062
|
+
setDragOver(false);
|
|
17063
|
+
if (onDrop && de.dataTransfer) {
|
|
17064
|
+
const itemId = de.dataTransfer.getData("text/plain");
|
|
17065
|
+
if (itemId) {
|
|
17066
|
+
onDrop(itemId, container.container_id);
|
|
17067
|
+
}
|
|
17068
|
+
}
|
|
17069
|
+
}, [container.container_id, onDrop]);
|
|
17070
|
+
const containerStyle3 = {
|
|
17071
|
+
position: "absolute",
|
|
17072
|
+
left: `${container.position.x}px`,
|
|
17073
|
+
top: `${container.position.y}px`,
|
|
17074
|
+
width: `${container.size.width}px`,
|
|
17075
|
+
height: `${container.size.height}px`,
|
|
17076
|
+
backgroundColor: "#ffffff",
|
|
17077
|
+
border: selected ? "2px solid #3b82f6" : "2px solid #d1d5db",
|
|
17078
|
+
borderRadius: "8px",
|
|
17079
|
+
boxShadow: dragOver ? "0 0 0 3px rgba(59,130,246,0.3), 0 4px 16px rgba(0,0,0,0.1)" : "0 2px 8px rgba(0,0,0,0.08)",
|
|
17080
|
+
display: "flex",
|
|
17081
|
+
flexDirection: "column",
|
|
17082
|
+
overflow: "hidden",
|
|
17083
|
+
zIndex: "0",
|
|
17221
17084
|
boxSizing: "border-box"
|
|
17222
17085
|
};
|
|
17223
|
-
const
|
|
17224
|
-
|
|
17225
|
-
|
|
17226
|
-
|
|
17227
|
-
|
|
17228
|
-
|
|
17229
|
-
|
|
17230
|
-
|
|
17231
|
-
|
|
17232
|
-
|
|
17233
|
-
|
|
17234
|
-
boxSizing: "border-box",
|
|
17235
|
-
fontFamily: "inherit"
|
|
17086
|
+
const titleBarStyle = {
|
|
17087
|
+
padding: "6px 12px",
|
|
17088
|
+
borderBottom: "1px solid #e5e7eb",
|
|
17089
|
+
backgroundColor: "#f9fafb",
|
|
17090
|
+
cursor: "grab",
|
|
17091
|
+
userSelect: "none",
|
|
17092
|
+
textAlign: "center",
|
|
17093
|
+
fontWeight: "700",
|
|
17094
|
+
fontSize: "15px",
|
|
17095
|
+
color: "#1f2937",
|
|
17096
|
+
flexShrink: "0"
|
|
17236
17097
|
};
|
|
17237
|
-
const
|
|
17238
|
-
|
|
17239
|
-
|
|
17240
|
-
|
|
17241
|
-
|
|
17242
|
-
|
|
17243
|
-
|
|
17244
|
-
|
|
17245
|
-
|
|
17246
|
-
|
|
17098
|
+
const contentsStyle = {
|
|
17099
|
+
flex: "1",
|
|
17100
|
+
overflow: "auto",
|
|
17101
|
+
position: "relative",
|
|
17102
|
+
padding: "4px"
|
|
17103
|
+
};
|
|
17104
|
+
const resizeHandleStyle = {
|
|
17105
|
+
position: "absolute",
|
|
17106
|
+
bottom: "0",
|
|
17107
|
+
right: "0",
|
|
17108
|
+
width: "14px",
|
|
17109
|
+
height: "14px",
|
|
17110
|
+
cursor: "nwse-resize",
|
|
17111
|
+
opacity: "0.4",
|
|
17112
|
+
background: "linear-gradient(135deg, transparent 50%, #666 50%)"
|
|
17247
17113
|
};
|
|
17248
17114
|
return createElement(
|
|
17249
17115
|
"div",
|
|
17250
17116
|
{
|
|
17251
|
-
|
|
17252
|
-
|
|
17253
|
-
|
|
17254
|
-
|
|
17255
|
-
|
|
17256
|
-
"
|
|
17117
|
+
className: "board-container",
|
|
17118
|
+
style: containerStyle3,
|
|
17119
|
+
"data-container-id": container.container_id,
|
|
17120
|
+
"data-testid": `container-${container.container_id}`,
|
|
17121
|
+
role: "group",
|
|
17122
|
+
"aria-label": `Container: ${container.name}`,
|
|
17123
|
+
onDragOver: handleDragOver,
|
|
17124
|
+
onDragLeave: handleDragLeave,
|
|
17125
|
+
onDrop: handleDrop
|
|
17257
17126
|
},
|
|
17258
|
-
createElement(
|
|
17259
|
-
"
|
|
17260
|
-
|
|
17261
|
-
|
|
17262
|
-
|
|
17263
|
-
|
|
17264
|
-
|
|
17265
|
-
|
|
17266
|
-
|
|
17267
|
-
|
|
17268
|
-
|
|
17269
|
-
|
|
17270
|
-
|
|
17271
|
-
|
|
17272
|
-
|
|
17273
|
-
|
|
17274
|
-
|
|
17275
|
-
"aria-label": "Card title"
|
|
17276
|
-
}),
|
|
17277
|
-
createElement("textarea", {
|
|
17278
|
-
value: description,
|
|
17279
|
-
onInput: handleDescChange,
|
|
17280
|
-
onKeyDown: handleKeyDown,
|
|
17281
|
-
style: textareaStyle,
|
|
17282
|
-
placeholder: "Description...",
|
|
17283
|
-
"data-testid": "card-editor-description",
|
|
17284
|
-
"aria-label": "Card description"
|
|
17285
|
-
}),
|
|
17286
|
-
createElement("button", {
|
|
17287
|
-
style: btnStyle,
|
|
17288
|
-
onClick: save,
|
|
17289
|
-
"data-testid": "card-editor-save"
|
|
17290
|
-
}, "Done")
|
|
17291
|
-
)
|
|
17127
|
+
createElement("div", {
|
|
17128
|
+
className: "board-container__title",
|
|
17129
|
+
style: titleBarStyle,
|
|
17130
|
+
onMouseDown: handleTitleMouseDown,
|
|
17131
|
+
"data-testid": `container-title-${container.container_id}`
|
|
17132
|
+
}, container.name),
|
|
17133
|
+
createElement("div", {
|
|
17134
|
+
className: "board-container__contents",
|
|
17135
|
+
style: contentsStyle,
|
|
17136
|
+
"data-testid": `container-contents-${container.container_id}`
|
|
17137
|
+
}, children),
|
|
17138
|
+
createElement("div", {
|
|
17139
|
+
style: resizeHandleStyle,
|
|
17140
|
+
"data-role": "resize",
|
|
17141
|
+
onMouseDown: handleResizeMouseDown,
|
|
17142
|
+
"aria-label": "Resize container"
|
|
17143
|
+
})
|
|
17292
17144
|
);
|
|
17293
17145
|
}
|
|
17294
17146
|
|
|
17295
|
-
// ../
|
|
17147
|
+
// ../components/data/board/src/CardLink.ts
|
|
17296
17148
|
function getCardCenter(card) {
|
|
17297
17149
|
return {
|
|
17298
17150
|
x: card.position.x + card.size.width / 2,
|
|
17299
17151
|
y: card.position.y + card.size.height / 2
|
|
17300
17152
|
};
|
|
17301
17153
|
}
|
|
17302
|
-
|
|
17303
|
-
|
|
17304
|
-
|
|
17305
|
-
return "8,4";
|
|
17306
|
-
case "dotted":
|
|
17307
|
-
return "2,4";
|
|
17308
|
-
default:
|
|
17309
|
-
return "none";
|
|
17310
|
-
}
|
|
17311
|
-
}
|
|
17312
|
-
function ConnectionsOverlay(props) {
|
|
17313
|
-
const { connections, cards, selectedConnectionId, onSelectConnection, canvasWidth, canvasHeight } = props;
|
|
17154
|
+
var ARROW_MARKER_ID = "board-card-link-arrowhead";
|
|
17155
|
+
function CardLinkOverlay(props) {
|
|
17156
|
+
const { links, cards, selectedLinkId, onSelectLink, canvasWidth, canvasHeight } = props;
|
|
17314
17157
|
const cardMap = /* @__PURE__ */ new Map();
|
|
17315
17158
|
for (let i = 0; i < cards.length; i++) {
|
|
17316
|
-
cardMap.set(cards[i].
|
|
17159
|
+
cardMap.set(cards[i].card_id, cards[i]);
|
|
17317
17160
|
}
|
|
17318
|
-
const handleLineClick = useCallback((
|
|
17319
|
-
|
|
17320
|
-
}, [
|
|
17161
|
+
const handleLineClick = useCallback((linkId) => {
|
|
17162
|
+
onSelectLink(linkId);
|
|
17163
|
+
}, [onSelectLink]);
|
|
17321
17164
|
const lineElements = [];
|
|
17322
|
-
for (let i = 0; i <
|
|
17323
|
-
const
|
|
17324
|
-
const
|
|
17325
|
-
|
|
17326
|
-
|
|
17327
|
-
const
|
|
17328
|
-
const
|
|
17329
|
-
const
|
|
17330
|
-
const strokeColor = isSelected ? "#3b82f6" : "#94a3b8";
|
|
17331
|
-
const dashArray = getStrokeDasharray(conn.style);
|
|
17165
|
+
for (let i = 0; i < links.length; i++) {
|
|
17166
|
+
const { source, link } = links[i];
|
|
17167
|
+
const targetCard = cardMap.get(link.target_card_id);
|
|
17168
|
+
if (!targetCard) continue;
|
|
17169
|
+
const from = getCardCenter(source);
|
|
17170
|
+
const to = getCardCenter(targetCard);
|
|
17171
|
+
const isSelected = link.link_id === selectedLinkId;
|
|
17172
|
+
const strokeColor = isSelected ? "#3b82f6" : link.color || "#94a3b8";
|
|
17332
17173
|
const dx = to.x - from.x;
|
|
17333
17174
|
const dy = to.y - from.y;
|
|
17334
17175
|
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
@@ -17342,39 +17183,40 @@ function ConnectionsOverlay(props) {
|
|
|
17342
17183
|
const pathD = `M ${from.x} ${from.y} Q ${cpX} ${cpY} ${to.x} ${to.y}`;
|
|
17343
17184
|
lineElements.push(
|
|
17344
17185
|
createElement("path", {
|
|
17345
|
-
key: `hit-${
|
|
17186
|
+
key: `hit-${link.link_id}`,
|
|
17346
17187
|
d: pathD,
|
|
17347
17188
|
fill: "none",
|
|
17348
17189
|
stroke: "transparent",
|
|
17349
17190
|
"stroke-width": "12",
|
|
17350
17191
|
style: { cursor: "pointer" },
|
|
17351
|
-
onClick: () => handleLineClick(
|
|
17352
|
-
"data-testid": `
|
|
17192
|
+
onClick: () => handleLineClick(link.link_id),
|
|
17193
|
+
"data-testid": `link-hit-${link.link_id}`
|
|
17353
17194
|
})
|
|
17354
17195
|
);
|
|
17355
17196
|
lineElements.push(
|
|
17356
17197
|
createElement("path", {
|
|
17357
|
-
key:
|
|
17198
|
+
key: link.link_id,
|
|
17358
17199
|
d: pathD,
|
|
17359
17200
|
fill: "none",
|
|
17360
17201
|
stroke: strokeColor,
|
|
17361
17202
|
"stroke-width": isSelected ? "3" : "2",
|
|
17362
|
-
"stroke-dasharray": dashArray,
|
|
17363
17203
|
"pointer-events": "none",
|
|
17364
|
-
"
|
|
17204
|
+
"marker-end": `url(#${ARROW_MARKER_ID})`,
|
|
17205
|
+
"data-testid": `link-${link.link_id}`
|
|
17365
17206
|
})
|
|
17366
17207
|
);
|
|
17367
|
-
if (
|
|
17208
|
+
if (link.link_name) {
|
|
17368
17209
|
lineElements.push(
|
|
17369
17210
|
createElement("text", {
|
|
17370
|
-
key: `label-${
|
|
17211
|
+
key: `label-${link.link_id}`,
|
|
17371
17212
|
x: String(cpX),
|
|
17372
17213
|
y: String(cpY - 6),
|
|
17373
17214
|
"text-anchor": "middle",
|
|
17374
17215
|
fill: "#64748b",
|
|
17375
17216
|
"font-size": "11",
|
|
17376
|
-
"pointer-events": "none"
|
|
17377
|
-
|
|
17217
|
+
"pointer-events": "none",
|
|
17218
|
+
"data-testid": `link-label-${link.link_id}`
|
|
17219
|
+
}, link.link_name)
|
|
17378
17220
|
);
|
|
17379
17221
|
}
|
|
17380
17222
|
}
|
|
@@ -17387,81 +17229,89 @@ function ConnectionsOverlay(props) {
|
|
|
17387
17229
|
pointerEvents: "none",
|
|
17388
17230
|
overflow: "visible"
|
|
17389
17231
|
};
|
|
17232
|
+
const markerDef = createElement(
|
|
17233
|
+
"defs",
|
|
17234
|
+
{},
|
|
17235
|
+
createElement(
|
|
17236
|
+
"marker",
|
|
17237
|
+
{
|
|
17238
|
+
id: ARROW_MARKER_ID,
|
|
17239
|
+
viewBox: "0 0 10 10",
|
|
17240
|
+
refX: "10",
|
|
17241
|
+
refY: "5",
|
|
17242
|
+
markerWidth: "8",
|
|
17243
|
+
markerHeight: "8",
|
|
17244
|
+
orient: "auto-start-reverse"
|
|
17245
|
+
},
|
|
17246
|
+
createElement("path", {
|
|
17247
|
+
d: "M 0 0 L 10 5 L 0 10 z",
|
|
17248
|
+
fill: "#94a3b8"
|
|
17249
|
+
})
|
|
17250
|
+
)
|
|
17251
|
+
);
|
|
17390
17252
|
return createElement(
|
|
17391
17253
|
"svg",
|
|
17392
17254
|
{
|
|
17393
17255
|
style: svgStyle,
|
|
17394
17256
|
width: String(canvasWidth),
|
|
17395
17257
|
height: String(canvasHeight),
|
|
17396
|
-
className: "
|
|
17397
|
-
"data-testid": "
|
|
17258
|
+
className: "card-link-overlay",
|
|
17259
|
+
"data-testid": "card-link-overlay",
|
|
17398
17260
|
role: "img",
|
|
17399
|
-
"aria-label": "Card
|
|
17261
|
+
"aria-label": "Card links"
|
|
17400
17262
|
},
|
|
17263
|
+
markerDef,
|
|
17401
17264
|
createElement("g", { style: { pointerEvents: "auto" } }, ...lineElements)
|
|
17402
17265
|
);
|
|
17403
17266
|
}
|
|
17404
17267
|
|
|
17405
|
-
// ../
|
|
17268
|
+
// ../components/data/board/src/Board.ts
|
|
17406
17269
|
var GRID_SIZE = 20;
|
|
17407
17270
|
var CANVAS_SIZE = 5e3;
|
|
17408
|
-
function
|
|
17271
|
+
function snapToGrid(pos, gridSize) {
|
|
17409
17272
|
return {
|
|
17410
|
-
x: (
|
|
17411
|
-
y: (
|
|
17273
|
+
x: Math.round(pos.x / gridSize) * gridSize,
|
|
17274
|
+
y: Math.round(pos.y / gridSize) * gridSize
|
|
17412
17275
|
};
|
|
17413
17276
|
}
|
|
17414
|
-
function
|
|
17415
|
-
const
|
|
17416
|
-
|
|
17417
|
-
|
|
17418
|
-
|
|
17419
|
-
|
|
17420
|
-
|
|
17421
|
-
|
|
17422
|
-
|
|
17423
|
-
|
|
17424
|
-
|
|
17425
|
-
if (
|
|
17426
|
-
|
|
17427
|
-
|
|
17428
|
-
|
|
17429
|
-
|
|
17430
|
-
if (bottom > maxY) maxY = bottom;
|
|
17277
|
+
function collectCardsAndLinks(items) {
|
|
17278
|
+
const cards = [];
|
|
17279
|
+
const links = [];
|
|
17280
|
+
const stack = [...items];
|
|
17281
|
+
while (stack.length > 0) {
|
|
17282
|
+
const item = stack.pop();
|
|
17283
|
+
if (isCard(item)) {
|
|
17284
|
+
cards.push(item);
|
|
17285
|
+
for (let j = 0; j < item.card_link.length; j++) {
|
|
17286
|
+
links.push({ source: item, link: item.card_link[j] });
|
|
17287
|
+
}
|
|
17288
|
+
} else if (isContainer(item)) {
|
|
17289
|
+
for (let j = item.contents.length - 1; j >= 0; j--) {
|
|
17290
|
+
stack.push(item.contents[j]);
|
|
17291
|
+
}
|
|
17292
|
+
}
|
|
17431
17293
|
}
|
|
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}`;
|
|
17294
|
+
return { cards, links };
|
|
17445
17295
|
}
|
|
17446
17296
|
function Board(props) {
|
|
17447
|
-
const {
|
|
17448
|
-
|
|
17449
|
-
|
|
17450
|
-
|
|
17451
|
-
|
|
17452
|
-
|
|
17453
|
-
|
|
17454
|
-
|
|
17297
|
+
const {
|
|
17298
|
+
state,
|
|
17299
|
+
dispatch,
|
|
17300
|
+
selectedId = null,
|
|
17301
|
+
onSelectItem,
|
|
17302
|
+
gridEnabled = false,
|
|
17303
|
+
searchQuery = "",
|
|
17304
|
+
colorFilter = null,
|
|
17305
|
+
onOpenProject
|
|
17306
|
+
} = props;
|
|
17307
|
+
const { collection, viewport } = state;
|
|
17455
17308
|
const containerRef = useRef(null);
|
|
17456
17309
|
const isPanningRef = useRef(false);
|
|
17457
17310
|
const panStartRef = useRef(null);
|
|
17458
|
-
const [connectionDrag, setConnectionDrag] = useState(null);
|
|
17459
|
-
const connectionDragRef = useRef(connectionDrag);
|
|
17460
|
-
connectionDragRef.current = connectionDrag;
|
|
17461
17311
|
const handleCanvasMouseDown = useCallback((e) => {
|
|
17462
17312
|
const me = e;
|
|
17463
17313
|
const target = me.target;
|
|
17464
|
-
if (target.closest(".board-card")) return;
|
|
17314
|
+
if (target.closest(".board-card") || target.closest(".board-container")) return;
|
|
17465
17315
|
const isMiddle = me.button === 1;
|
|
17466
17316
|
const isShiftLeft = me.button === 0 && me.shiftKey;
|
|
17467
17317
|
if (isMiddle || isShiftLeft) {
|
|
@@ -17474,10 +17324,9 @@ function Board(props) {
|
|
|
17474
17324
|
panY: viewport.panY
|
|
17475
17325
|
};
|
|
17476
17326
|
} else if (me.button === 0) {
|
|
17477
|
-
|
|
17478
|
-
setSelectedConnectionId(null);
|
|
17327
|
+
if (onSelectItem) onSelectItem(null);
|
|
17479
17328
|
}
|
|
17480
|
-
}, [viewport.panX, viewport.panY,
|
|
17329
|
+
}, [viewport.panX, viewport.panY, onSelectItem]);
|
|
17481
17330
|
useEffect(() => {
|
|
17482
17331
|
const handleMouseMove = (e) => {
|
|
17483
17332
|
if (!isPanningRef.current || !panStartRef.current) return;
|
|
@@ -17544,13 +17393,10 @@ function Board(props) {
|
|
|
17544
17393
|
const startMidY = (start.touches[0].y + start.touches[1].y) / 2;
|
|
17545
17394
|
const curMidX = (pts[0].x + pts[1].x) / 2;
|
|
17546
17395
|
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 });
|
|
17396
|
+
dispatch({ type: "PAN", panX: start.panX + (curMidX - startMidX), panY: start.panY + (curMidY - startMidY) });
|
|
17550
17397
|
const curDist = getDist(pts[0], pts[1]);
|
|
17551
17398
|
if (start.dist > 0) {
|
|
17552
|
-
|
|
17553
|
-
dispatch({ type: "ZOOM", zoom: start.zoom * scale });
|
|
17399
|
+
dispatch({ type: "ZOOM", zoom: start.zoom * (curDist / start.dist) });
|
|
17554
17400
|
}
|
|
17555
17401
|
};
|
|
17556
17402
|
const handleTouchEnd = () => {
|
|
@@ -17565,208 +17411,101 @@ function Board(props) {
|
|
|
17565
17411
|
container.removeEventListener("touchend", handleTouchEnd);
|
|
17566
17412
|
};
|
|
17567
17413
|
}, [viewport.panX, viewport.panY, viewport.zoom, dispatch]);
|
|
17568
|
-
|
|
17569
|
-
|
|
17570
|
-
|
|
17571
|
-
|
|
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) => {
|
|
17414
|
+
const handleSelectItem = useCallback((itemId) => {
|
|
17415
|
+
if (onSelectItem) onSelectItem(itemId);
|
|
17416
|
+
}, [onSelectItem]);
|
|
17417
|
+
const handleMoveItem = useCallback((itemId, position) => {
|
|
17589
17418
|
let pos = position;
|
|
17590
17419
|
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
|
-
};
|
|
17420
|
+
pos = snapToGrid(position, GRID_SIZE);
|
|
17595
17421
|
}
|
|
17596
|
-
dispatch({ type: "
|
|
17422
|
+
dispatch({ type: "MOVE_ITEM", itemId, position: pos });
|
|
17597
17423
|
}, [dispatch, gridEnabled]);
|
|
17598
|
-
const
|
|
17599
|
-
dispatch({ type: "
|
|
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 });
|
|
17424
|
+
const handleResizeItem = useCallback((itemId, size) => {
|
|
17425
|
+
dispatch({ type: "RESIZE_ITEM", itemId, size });
|
|
17609
17426
|
}, [dispatch]);
|
|
17610
|
-
const
|
|
17611
|
-
dispatch({ type: "
|
|
17427
|
+
const handleDeleteItem = useCallback((itemId) => {
|
|
17428
|
+
dispatch({ type: "REMOVE_ITEM", itemId });
|
|
17429
|
+
if (onSelectItem && selectedId === itemId) onSelectItem(null);
|
|
17430
|
+
}, [dispatch, selectedId, onSelectItem]);
|
|
17431
|
+
const handleDropIntoContainer = useCallback((itemId, containerId) => {
|
|
17432
|
+
dispatch({ type: "NEST_ITEM", itemId, containerId });
|
|
17612
17433
|
}, [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
|
-
const handleCardContextMenu = useCallback((cardId, pos) => {
|
|
17635
|
-
setCardContextMenu({ cardId, x: pos.x, y: pos.y });
|
|
17636
|
-
setColorSubmenuOpen(false);
|
|
17637
|
-
setPrioritySubmenuOpen(false);
|
|
17638
|
-
}, []);
|
|
17639
|
-
const closeCardContextMenu = useCallback(() => {
|
|
17640
|
-
setCardContextMenu(null);
|
|
17641
|
-
setColorSubmenuOpen(false);
|
|
17642
|
-
setPrioritySubmenuOpen(false);
|
|
17643
|
-
}, []);
|
|
17644
|
-
useEffect(() => {
|
|
17645
|
-
if (!cardContextMenu) return;
|
|
17646
|
-
const handleClick = () => {
|
|
17647
|
-
closeCardContextMenu();
|
|
17648
|
-
};
|
|
17649
|
-
const timer = setTimeout(() => {
|
|
17650
|
-
document.addEventListener("click", handleClick);
|
|
17651
|
-
document.addEventListener("contextmenu", handleClick);
|
|
17652
|
-
}, 0);
|
|
17653
|
-
return () => {
|
|
17654
|
-
clearTimeout(timer);
|
|
17655
|
-
document.removeEventListener("click", handleClick);
|
|
17656
|
-
document.removeEventListener("contextmenu", handleClick);
|
|
17657
|
-
};
|
|
17658
|
-
}, [cardContextMenu, closeCardContextMenu]);
|
|
17659
|
-
const handleCtxDuplicateClick = useCallback((e) => {
|
|
17660
|
-
e.stopPropagation();
|
|
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
|
-
}
|
|
17673
|
-
closeCardContextMenu();
|
|
17674
|
-
}, [cardContextMenu, dispatch, selectedCardId, onSelectCard, closeCardContextMenu]);
|
|
17675
|
-
const handleCtxColorMenuEnter = useCallback(() => {
|
|
17676
|
-
setColorSubmenuOpen(true);
|
|
17677
|
-
setPrioritySubmenuOpen(false);
|
|
17678
|
-
}, []);
|
|
17679
|
-
const handleCtxPriorityMenuEnter = useCallback(() => {
|
|
17680
|
-
setPrioritySubmenuOpen(true);
|
|
17681
|
-
setColorSubmenuOpen(false);
|
|
17682
|
-
}, []);
|
|
17683
|
-
const handleCtxColorSelect = useCallback((color) => {
|
|
17684
|
-
if (cardContextMenu) {
|
|
17685
|
-
dispatch({ type: "UPDATE_CARD", cardId: cardContextMenu.cardId, updates: { color } });
|
|
17686
|
-
}
|
|
17687
|
-
closeCardContextMenu();
|
|
17688
|
-
}, [cardContextMenu, dispatch, closeCardContextMenu]);
|
|
17689
|
-
const handleCtxPrioritySelect = useCallback((priority) => {
|
|
17690
|
-
if (cardContextMenu) {
|
|
17691
|
-
dispatch({ type: "UPDATE_CARD", cardId: cardContextMenu.cardId, updates: { priority } });
|
|
17692
|
-
}
|
|
17693
|
-
closeCardContextMenu();
|
|
17694
|
-
}, [cardContextMenu, dispatch, closeCardContextMenu]);
|
|
17695
|
-
const handleAnchorDragStart = useCallback((cardId, anchor, ax, ay) => {
|
|
17696
|
-
setConnectionDrag({
|
|
17697
|
-
fromCardId: cardId,
|
|
17698
|
-
fromAnchor: anchor,
|
|
17699
|
-
fromX: ax,
|
|
17700
|
-
fromY: ay,
|
|
17701
|
-
toX: ax,
|
|
17702
|
-
toY: ay
|
|
17703
|
-
});
|
|
17704
|
-
}, []);
|
|
17705
|
-
useEffect(() => {
|
|
17706
|
-
if (!connectionDragRef.current) return;
|
|
17707
|
-
const handleMouseMove = (e) => {
|
|
17708
|
-
const me = e;
|
|
17709
|
-
if (!connectionDragRef.current) return;
|
|
17710
|
-
const canvasPos = screenToCanvas(me.clientX, me.clientY, viewport);
|
|
17711
|
-
setConnectionDrag((prev) => prev ? {
|
|
17712
|
-
...prev,
|
|
17713
|
-
toX: canvasPos.x,
|
|
17714
|
-
toY: canvasPos.y
|
|
17715
|
-
} : null);
|
|
17716
|
-
};
|
|
17717
|
-
const handleMouseUp = (e) => {
|
|
17718
|
-
const me = e;
|
|
17719
|
-
if (!connectionDragRef.current) return;
|
|
17720
|
-
const drag = connectionDragRef.current;
|
|
17721
|
-
const target = me.target;
|
|
17722
|
-
const anchorEl = target.closest ? target.closest("[data-anchor]") : null;
|
|
17723
|
-
const cardEl = target.closest ? target.closest("[data-card-id]") : null;
|
|
17724
|
-
if (anchorEl && cardEl) {
|
|
17725
|
-
const targetCardId = cardEl.getAttribute("data-card-id");
|
|
17726
|
-
if (targetCardId && targetCardId !== drag.fromCardId) {
|
|
17727
|
-
dispatch({
|
|
17728
|
-
type: "ADD_CONNECTION",
|
|
17729
|
-
connection: {
|
|
17730
|
-
id: generateConnectionId(),
|
|
17731
|
-
fromCardId: drag.fromCardId,
|
|
17732
|
-
toCardId: targetCardId
|
|
17733
|
-
}
|
|
17734
|
-
});
|
|
17735
|
-
}
|
|
17736
|
-
}
|
|
17737
|
-
setConnectionDrag(null);
|
|
17738
|
-
};
|
|
17739
|
-
document.addEventListener("mousemove", handleMouseMove);
|
|
17740
|
-
document.addEventListener("mouseup", handleMouseUp);
|
|
17741
|
-
return () => {
|
|
17742
|
-
document.removeEventListener("mousemove", handleMouseMove);
|
|
17743
|
-
document.removeEventListener("mouseup", handleMouseUp);
|
|
17744
|
-
};
|
|
17745
|
-
}, [connectionDrag, viewport, dispatch]);
|
|
17746
17434
|
const lowerSearch = searchQuery.toLowerCase();
|
|
17747
|
-
const
|
|
17748
|
-
const
|
|
17435
|
+
const dimmedIds = /* @__PURE__ */ new Set();
|
|
17436
|
+
const allItems = [];
|
|
17437
|
+
const itemStack = [...collection];
|
|
17438
|
+
while (itemStack.length > 0) {
|
|
17439
|
+
const item = itemStack.pop();
|
|
17440
|
+
allItems.push(item);
|
|
17441
|
+
if (isContainer(item)) {
|
|
17442
|
+
for (let i = 0; i < item.contents.length; i++) {
|
|
17443
|
+
itemStack.push(item.contents[i]);
|
|
17444
|
+
}
|
|
17445
|
+
}
|
|
17446
|
+
}
|
|
17749
17447
|
if (lowerSearch) {
|
|
17750
|
-
for (let i = 0; i <
|
|
17751
|
-
|
|
17752
|
-
|
|
17448
|
+
for (let i = 0; i < allItems.length; i++) {
|
|
17449
|
+
const item = allItems[i];
|
|
17450
|
+
const name = isCard(item) ? item.card_title : item.name;
|
|
17451
|
+
if (!name.toLowerCase().includes(lowerSearch)) {
|
|
17452
|
+
dimmedIds.add(getItemId(item));
|
|
17753
17453
|
}
|
|
17754
17454
|
}
|
|
17755
17455
|
}
|
|
17756
17456
|
if (colorFilter) {
|
|
17757
|
-
for (let i = 0; i <
|
|
17758
|
-
|
|
17759
|
-
|
|
17760
|
-
|
|
17457
|
+
for (let i = 0; i < allItems.length; i++) {
|
|
17458
|
+
const item = allItems[i];
|
|
17459
|
+
if (isCard(item) && item.color !== colorFilter) {
|
|
17460
|
+
dimmedIds.add(item.card_id);
|
|
17461
|
+
}
|
|
17462
|
+
}
|
|
17463
|
+
}
|
|
17464
|
+
const { cards: allCards, links: allLinks } = collectCardsAndLinks(collection);
|
|
17465
|
+
function renderItem(item) {
|
|
17466
|
+
const id = getItemId(item);
|
|
17467
|
+
const isDimmed = dimmedIds.has(id);
|
|
17468
|
+
let el;
|
|
17469
|
+
if (isCard(item)) {
|
|
17470
|
+
el = createElement(CardComponent, {
|
|
17471
|
+
key: id,
|
|
17472
|
+
card: item,
|
|
17473
|
+
selected: id === selectedId,
|
|
17474
|
+
onSelect: handleSelectItem,
|
|
17475
|
+
onMove: handleMoveItem,
|
|
17476
|
+
onResize: handleResizeItem,
|
|
17477
|
+
onDelete: handleDeleteItem,
|
|
17478
|
+
dispatch,
|
|
17479
|
+
onOpenProject
|
|
17480
|
+
});
|
|
17481
|
+
} else {
|
|
17482
|
+
const childElements = item.contents.map((child) => renderItem(child));
|
|
17483
|
+
el = createElement(ContainerComponent, {
|
|
17484
|
+
key: id,
|
|
17485
|
+
container: item,
|
|
17486
|
+
selected: id === selectedId,
|
|
17487
|
+
onSelect: handleSelectItem,
|
|
17488
|
+
onMove: handleMoveItem,
|
|
17489
|
+
onResize: handleResizeItem,
|
|
17490
|
+
onDrop: handleDropIntoContainer
|
|
17491
|
+
}, ...childElements);
|
|
17761
17492
|
}
|
|
17493
|
+
if (isDimmed) {
|
|
17494
|
+
return createElement("div", {
|
|
17495
|
+
key: `dim-${id}`,
|
|
17496
|
+
style: { opacity: "0.3" }
|
|
17497
|
+
}, el);
|
|
17498
|
+
}
|
|
17499
|
+
return el;
|
|
17762
17500
|
}
|
|
17501
|
+
const itemElements = collection.map((item) => renderItem(item));
|
|
17763
17502
|
const containerStyle3 = {
|
|
17764
17503
|
flex: "1",
|
|
17765
17504
|
overflow: "hidden",
|
|
17766
17505
|
position: "relative",
|
|
17767
17506
|
backgroundColor: "#f8fafc",
|
|
17768
|
-
cursor:
|
|
17769
|
-
backgroundImage: "radial-gradient(circle, #d1d5db 1px, transparent 1px)",
|
|
17507
|
+
cursor: "default",
|
|
17508
|
+
backgroundImage: gridEnabled ? "radial-gradient(circle, #d1d5db 1px, transparent 1px)" : "none",
|
|
17770
17509
|
backgroundSize: `${GRID_SIZE}px ${GRID_SIZE}px`
|
|
17771
17510
|
};
|
|
17772
17511
|
const transformStyle = {
|
|
@@ -17776,338 +17515,517 @@ function Board(props) {
|
|
|
17776
17515
|
width: `${CANVAS_SIZE}px`,
|
|
17777
17516
|
height: `${CANVAS_SIZE}px`
|
|
17778
17517
|
};
|
|
17779
|
-
|
|
17780
|
-
const isDimmed = dimmedCardIds.has(card.id);
|
|
17781
|
-
const cardEl = createElement(Card2, {
|
|
17782
|
-
key: card.id,
|
|
17783
|
-
card,
|
|
17784
|
-
selected: card.id === selectedCardId,
|
|
17785
|
-
onSelect: handleSelectCard,
|
|
17786
|
-
onMove: handleMoveCard,
|
|
17787
|
-
onResize: handleResizeCard,
|
|
17788
|
-
onDelete: handleDeleteCard,
|
|
17789
|
-
onDoubleClick: handleDoubleClickCard,
|
|
17790
|
-
onUpdate: handleUpdateCard,
|
|
17791
|
-
onDuplicate: handleDuplicateCard,
|
|
17792
|
-
onChangeColor: handleChangeColor,
|
|
17793
|
-
onChangePriority: handleChangePriority,
|
|
17794
|
-
onAnchorDragStart: handleAnchorDragStart,
|
|
17795
|
-
onCardContextMenu: handleCardContextMenu
|
|
17796
|
-
});
|
|
17797
|
-
if (isDimmed) {
|
|
17798
|
-
return createElement("div", {
|
|
17799
|
-
key: `dim-${card.id}`,
|
|
17800
|
-
style: { opacity: "0.3" }
|
|
17801
|
-
}, cardEl);
|
|
17802
|
-
}
|
|
17803
|
-
return cardEl;
|
|
17804
|
-
});
|
|
17805
|
-
const editingCard = editingCardId ? cards.find((c) => c.id === editingCardId) : null;
|
|
17806
|
-
const editorEl = editingCard ? createElement(CardEditor, {
|
|
17807
|
-
card: editingCard,
|
|
17808
|
-
onSave: handleEditorSave,
|
|
17809
|
-
onClose: handleEditorClose
|
|
17810
|
-
}) : null;
|
|
17811
|
-
const connectionDragLine = connectionDrag ? createElement(
|
|
17812
|
-
"svg",
|
|
17813
|
-
{
|
|
17814
|
-
style: {
|
|
17815
|
-
position: "absolute",
|
|
17816
|
-
top: "0",
|
|
17817
|
-
left: "0",
|
|
17818
|
-
width: "100%",
|
|
17819
|
-
height: "100%",
|
|
17820
|
-
pointerEvents: "none",
|
|
17821
|
-
overflow: "visible",
|
|
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;
|
|
17839
|
-
const ctxMenuItemStyle = {
|
|
17840
|
-
padding: "6px 12px",
|
|
17841
|
-
cursor: "pointer",
|
|
17842
|
-
display: "flex",
|
|
17843
|
-
alignItems: "center",
|
|
17844
|
-
justifyContent: "space-between",
|
|
17845
|
-
whiteSpace: "nowrap"
|
|
17846
|
-
};
|
|
17847
|
-
const ctxSubmenuContainerStyle = {
|
|
17848
|
-
position: "absolute",
|
|
17849
|
-
left: "100%",
|
|
17850
|
-
top: "0",
|
|
17851
|
-
backgroundColor: "#ffffff",
|
|
17852
|
-
border: "1px solid #d1d5db",
|
|
17853
|
-
borderRadius: "6px",
|
|
17854
|
-
boxShadow: "0 4px 16px rgba(0,0,0,0.15)",
|
|
17855
|
-
padding: "4px 0",
|
|
17856
|
-
minWidth: "120px"
|
|
17857
|
-
};
|
|
17858
|
-
const contextMenuCard = cardContextMenu ? cards.find((c) => c.id === cardContextMenu.cardId) : null;
|
|
17859
|
-
const contextMenuEl = cardContextMenu ? createElement(
|
|
17518
|
+
return createElement(
|
|
17860
17519
|
"div",
|
|
17861
17520
|
{
|
|
17862
|
-
|
|
17863
|
-
|
|
17864
|
-
|
|
17865
|
-
|
|
17866
|
-
|
|
17867
|
-
|
|
17868
|
-
|
|
17869
|
-
|
|
17870
|
-
|
|
17871
|
-
padding: "4px 0",
|
|
17872
|
-
zIndex: "10000",
|
|
17873
|
-
minWidth: "160px",
|
|
17874
|
-
fontSize: "13px",
|
|
17875
|
-
color: "#1a1a1a"
|
|
17876
|
-
},
|
|
17877
|
-
"data-testid": `context-menu-${cardContextMenu.cardId}`,
|
|
17878
|
-
role: "menu",
|
|
17879
|
-
"aria-label": "Card context menu"
|
|
17521
|
+
ref: containerRef,
|
|
17522
|
+
className: "board-canvas",
|
|
17523
|
+
style: containerStyle3,
|
|
17524
|
+
onMouseDown: handleCanvasMouseDown,
|
|
17525
|
+
onWheel: handleWheel,
|
|
17526
|
+
"data-testid": "board-canvas",
|
|
17527
|
+
role: "application",
|
|
17528
|
+
"aria-label": `Board: ${state.name}`,
|
|
17529
|
+
tabIndex: 0
|
|
17880
17530
|
},
|
|
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
|
-
// Change Color submenu
|
|
17896
17531
|
createElement(
|
|
17897
17532
|
"div",
|
|
17898
17533
|
{
|
|
17899
|
-
|
|
17900
|
-
|
|
17901
|
-
|
|
17902
|
-
"aria-haspopup": "true",
|
|
17903
|
-
"data-testid": `context-menu-color-${cardContextMenu.cardId}`
|
|
17904
|
-
},
|
|
17905
|
-
"Change Color",
|
|
17906
|
-
createElement("span", { style: { marginLeft: "8px" } }, "\u25B6"),
|
|
17907
|
-
colorSubmenuOpen ? createElement(
|
|
17908
|
-
"div",
|
|
17909
|
-
{
|
|
17910
|
-
style: ctxSubmenuContainerStyle,
|
|
17911
|
-
role: "menu",
|
|
17912
|
-
"data-testid": `context-submenu-color-${cardContextMenu.cardId}`
|
|
17913
|
-
},
|
|
17914
|
-
...CONTEXT_MENU_COLORS.map(
|
|
17915
|
-
(color) => createElement(
|
|
17916
|
-
"div",
|
|
17917
|
-
{
|
|
17918
|
-
key: color,
|
|
17919
|
-
style: {
|
|
17920
|
-
...ctxMenuItemStyle,
|
|
17921
|
-
gap: "8px"
|
|
17922
|
-
},
|
|
17923
|
-
onClick: (e) => {
|
|
17924
|
-
e.stopPropagation();
|
|
17925
|
-
handleCtxColorSelect(color);
|
|
17926
|
-
},
|
|
17927
|
-
role: "menuitem",
|
|
17928
|
-
"data-testid": `context-color-${color}`
|
|
17929
|
-
},
|
|
17930
|
-
createElement("span", {
|
|
17931
|
-
style: {
|
|
17932
|
-
width: "14px",
|
|
17933
|
-
height: "14px",
|
|
17934
|
-
borderRadius: "50%",
|
|
17935
|
-
backgroundColor: color,
|
|
17936
|
-
border: "1px solid rgba(0,0,0,0.15)",
|
|
17937
|
-
display: "inline-block",
|
|
17938
|
-
flexShrink: "0"
|
|
17939
|
-
}
|
|
17940
|
-
}),
|
|
17941
|
-
contextMenuCard && color === contextMenuCard.color ? "\u2713" : ""
|
|
17942
|
-
)
|
|
17943
|
-
)
|
|
17944
|
-
) : null
|
|
17945
|
-
),
|
|
17946
|
-
// Set Priority submenu
|
|
17947
|
-
createElement(
|
|
17948
|
-
"div",
|
|
17949
|
-
{
|
|
17950
|
-
style: { ...ctxMenuItemStyle, position: "relative" },
|
|
17951
|
-
onMouseEnter: handleCtxPriorityMenuEnter,
|
|
17952
|
-
role: "menuitem",
|
|
17953
|
-
"aria-haspopup": "true",
|
|
17954
|
-
"data-testid": `context-menu-priority-${cardContextMenu.cardId}`
|
|
17534
|
+
className: "board-canvas__inner",
|
|
17535
|
+
style: transformStyle,
|
|
17536
|
+
"data-testid": "board-canvas-inner"
|
|
17955
17537
|
},
|
|
17956
|
-
|
|
17957
|
-
|
|
17958
|
-
|
|
17959
|
-
|
|
17960
|
-
{
|
|
17961
|
-
style: ctxSubmenuContainerStyle,
|
|
17962
|
-
role: "menu",
|
|
17963
|
-
"data-testid": `context-submenu-priority-${cardContextMenu.cardId}`
|
|
17538
|
+
createElement(CardLinkOverlay, {
|
|
17539
|
+
links: allLinks,
|
|
17540
|
+
cards: allCards,
|
|
17541
|
+
selectedLinkId: null,
|
|
17542
|
+
onSelectLink: () => {
|
|
17964
17543
|
},
|
|
17965
|
-
|
|
17966
|
-
|
|
17967
|
-
|
|
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
|
|
17544
|
+
canvasWidth: CANVAS_SIZE,
|
|
17545
|
+
canvasHeight: CANVAS_SIZE
|
|
17546
|
+
}),
|
|
17547
|
+
...itemElements
|
|
17996
17548
|
)
|
|
17997
|
-
)
|
|
17549
|
+
);
|
|
17550
|
+
}
|
|
17551
|
+
|
|
17552
|
+
// ../demos/project-manager/src/Board.ts
|
|
17553
|
+
function collectAllCards(items) {
|
|
17554
|
+
const cards = [];
|
|
17555
|
+
const stack = [...items];
|
|
17556
|
+
while (stack.length > 0) {
|
|
17557
|
+
const item = stack.pop();
|
|
17558
|
+
if (isCard(item)) {
|
|
17559
|
+
cards.push(item);
|
|
17560
|
+
} else if (isContainer(item)) {
|
|
17561
|
+
for (let i = item.contents.length - 1; i >= 0; i--) {
|
|
17562
|
+
stack.push(item.contents[i]);
|
|
17563
|
+
}
|
|
17564
|
+
}
|
|
17565
|
+
}
|
|
17566
|
+
return cards;
|
|
17567
|
+
}
|
|
17568
|
+
function computeFitAll(collection, containerWidth, containerHeight, padding) {
|
|
17569
|
+
const pad3 = padding ?? 40;
|
|
17570
|
+
const cards = collectAllCards(collection);
|
|
17571
|
+
if (cards.length === 0) {
|
|
17572
|
+
return { panX: 0, panY: 0, zoom: 1 };
|
|
17573
|
+
}
|
|
17574
|
+
let minX = Infinity;
|
|
17575
|
+
let minY = Infinity;
|
|
17576
|
+
let maxX = -Infinity;
|
|
17577
|
+
let maxY = -Infinity;
|
|
17578
|
+
for (let i = 0; i < cards.length; i++) {
|
|
17579
|
+
const c = cards[i];
|
|
17580
|
+
if (c.position.x < minX) minX = c.position.x;
|
|
17581
|
+
if (c.position.y < minY) minY = c.position.y;
|
|
17582
|
+
const right = c.position.x + c.size.width;
|
|
17583
|
+
const bottom = c.position.y + c.size.height;
|
|
17584
|
+
if (right > maxX) maxX = right;
|
|
17585
|
+
if (bottom > maxY) maxY = bottom;
|
|
17586
|
+
}
|
|
17587
|
+
const contentW = maxX - minX + pad3 * 2;
|
|
17588
|
+
const contentH = maxY - minY + pad3 * 2;
|
|
17589
|
+
const zoomX = containerWidth / contentW;
|
|
17590
|
+
const zoomY = containerHeight / contentH;
|
|
17591
|
+
const zoom = Math.max(0.25, Math.min(4, Math.min(zoomX, zoomY)));
|
|
17592
|
+
const panX = -minX * zoom + (containerWidth - (maxX - minX) * zoom) / 2;
|
|
17593
|
+
const panY = -minY * zoom + (containerHeight - (maxY - minY) * zoom) / 2;
|
|
17594
|
+
return { panX, panY, zoom };
|
|
17595
|
+
}
|
|
17596
|
+
|
|
17597
|
+
// ../demos/project-manager/src/Toolbar.ts
|
|
17598
|
+
var CARD_COLORS = [
|
|
17599
|
+
"transparent",
|
|
17600
|
+
// no background
|
|
17601
|
+
"#fef9c3",
|
|
17602
|
+
// yellow
|
|
17603
|
+
"#fecaca",
|
|
17604
|
+
// red
|
|
17605
|
+
"#fed7aa",
|
|
17606
|
+
// orange
|
|
17607
|
+
"#bbf7d0",
|
|
17608
|
+
// green
|
|
17609
|
+
"#bfdbfe",
|
|
17610
|
+
// blue
|
|
17611
|
+
"#ddd6fe",
|
|
17612
|
+
// purple
|
|
17613
|
+
"#fbcfe8",
|
|
17614
|
+
// pink
|
|
17615
|
+
"#e5e7eb"
|
|
17616
|
+
// gray
|
|
17617
|
+
];
|
|
17618
|
+
function BoardToolbar(props) {
|
|
17619
|
+
const {
|
|
17620
|
+
zoom,
|
|
17621
|
+
gridEnabled,
|
|
17622
|
+
selectedColor,
|
|
17623
|
+
colorFilter,
|
|
17624
|
+
onNewCard,
|
|
17625
|
+
onZoomIn,
|
|
17626
|
+
onZoomOut,
|
|
17627
|
+
onZoomReset,
|
|
17628
|
+
onColorSelect,
|
|
17629
|
+
onColorFilter,
|
|
17630
|
+
onGridToggle,
|
|
17631
|
+
onSearch
|
|
17632
|
+
} = props;
|
|
17633
|
+
const [searchText, setSearchText] = useState("");
|
|
17634
|
+
const handleSearchInput = useCallback((e) => {
|
|
17635
|
+
const value = e.target.value;
|
|
17636
|
+
setSearchText(value);
|
|
17637
|
+
onSearch(value);
|
|
17638
|
+
}, [onSearch]);
|
|
17639
|
+
const toolbarStyle = {
|
|
17640
|
+
display: "flex",
|
|
17641
|
+
alignItems: "center",
|
|
17642
|
+
gap: "8px",
|
|
17643
|
+
padding: "6px 12px",
|
|
17644
|
+
backgroundColor: "rgba(255,255,255,0.95)",
|
|
17645
|
+
borderBottom: "1px solid #e2e8f0",
|
|
17646
|
+
fontSize: "12px",
|
|
17647
|
+
flexShrink: "0",
|
|
17648
|
+
flexWrap: "wrap"
|
|
17649
|
+
};
|
|
17650
|
+
const btnStyle = {
|
|
17651
|
+
padding: "4px 10px",
|
|
17652
|
+
border: "1px solid #d1d5db",
|
|
17653
|
+
borderRadius: "4px",
|
|
17654
|
+
backgroundColor: "#ffffff",
|
|
17655
|
+
cursor: "pointer",
|
|
17656
|
+
fontSize: "12px",
|
|
17657
|
+
color: "#374151",
|
|
17658
|
+
lineHeight: "1.4"
|
|
17659
|
+
};
|
|
17660
|
+
const activeBtnStyle = {
|
|
17661
|
+
...btnStyle,
|
|
17662
|
+
backgroundColor: "#3b82f6",
|
|
17663
|
+
color: "#ffffff",
|
|
17664
|
+
borderColor: "#3b82f6"
|
|
17665
|
+
};
|
|
17666
|
+
const zoomText = {
|
|
17667
|
+
fontSize: "12px",
|
|
17668
|
+
color: "#64748b",
|
|
17669
|
+
minWidth: "40px",
|
|
17670
|
+
textAlign: "center",
|
|
17671
|
+
cursor: "pointer"
|
|
17672
|
+
};
|
|
17673
|
+
const separatorStyle = {
|
|
17674
|
+
width: "1px",
|
|
17675
|
+
height: "20px",
|
|
17676
|
+
backgroundColor: "#e2e8f0",
|
|
17677
|
+
margin: "0 4px"
|
|
17678
|
+
};
|
|
17679
|
+
const inputStyle = {
|
|
17680
|
+
padding: "4px 8px",
|
|
17681
|
+
border: "1px solid #d1d5db",
|
|
17682
|
+
borderRadius: "4px",
|
|
17683
|
+
fontSize: "12px",
|
|
17684
|
+
width: "120px",
|
|
17685
|
+
outline: "none"
|
|
17686
|
+
};
|
|
17687
|
+
const swatches = CARD_COLORS.map((color) => {
|
|
17688
|
+
const isActive = color === selectedColor;
|
|
17689
|
+
const isFiltered = color === colorFilter;
|
|
17690
|
+
const handleSwatchClick = () => {
|
|
17691
|
+
if (isActive && onColorFilter) {
|
|
17692
|
+
onColorFilter(isFiltered ? null : color);
|
|
17693
|
+
} else {
|
|
17694
|
+
onColorSelect(color);
|
|
17695
|
+
}
|
|
17696
|
+
};
|
|
17697
|
+
let borderStyle = "1px solid rgba(0,0,0,0.15)";
|
|
17698
|
+
if (isFiltered) {
|
|
17699
|
+
borderStyle = "3px solid #ef4444";
|
|
17700
|
+
} else if (isActive) {
|
|
17701
|
+
borderStyle = "2px solid #3b82f6";
|
|
17702
|
+
}
|
|
17703
|
+
const isTransparent = color === "transparent";
|
|
17704
|
+
return createElement("button", {
|
|
17705
|
+
key: color,
|
|
17706
|
+
title: isTransparent ? "Transparent" : color,
|
|
17707
|
+
style: {
|
|
17708
|
+
width: "18px",
|
|
17709
|
+
height: "18px",
|
|
17710
|
+
borderRadius: "50%",
|
|
17711
|
+
backgroundColor: isTransparent ? "#ffffff" : color,
|
|
17712
|
+
backgroundImage: isTransparent ? "linear-gradient(45deg, #ccc 25%, transparent 25%, transparent 75%, #ccc 75%), linear-gradient(45deg, #ccc 25%, transparent 25%, transparent 75%, #ccc 75%)" : "none",
|
|
17713
|
+
backgroundSize: isTransparent ? "6px 6px" : "auto",
|
|
17714
|
+
backgroundPosition: isTransparent ? "0 0, 3px 3px" : "0 0",
|
|
17715
|
+
border: borderStyle,
|
|
17716
|
+
cursor: "pointer",
|
|
17717
|
+
padding: "0",
|
|
17718
|
+
flexShrink: "0",
|
|
17719
|
+
opacity: isFiltered ? "1" : colorFilter ? "0.5" : "1"
|
|
17720
|
+
},
|
|
17721
|
+
onClick: handleSwatchClick,
|
|
17722
|
+
"aria-label": isFiltered ? `Clear color filter ${color}` : `Select color ${color}`,
|
|
17723
|
+
"data-testid": `color-swatch-${color}`
|
|
17724
|
+
});
|
|
17725
|
+
});
|
|
17998
17726
|
return createElement(
|
|
17999
17727
|
"div",
|
|
18000
17728
|
{
|
|
18001
|
-
|
|
18002
|
-
|
|
18003
|
-
|
|
18004
|
-
|
|
18005
|
-
|
|
18006
|
-
"data-testid": "board-canvas",
|
|
18007
|
-
role: "application",
|
|
18008
|
-
"aria-label": "Project board canvas",
|
|
18009
|
-
tabIndex: 0
|
|
17729
|
+
className: "board-toolbar",
|
|
17730
|
+
style: toolbarStyle,
|
|
17731
|
+
role: "toolbar",
|
|
17732
|
+
"aria-label": "Board toolbar",
|
|
17733
|
+
"data-testid": "board-toolbar"
|
|
18010
17734
|
},
|
|
18011
|
-
|
|
18012
|
-
|
|
18013
|
-
|
|
18014
|
-
|
|
18015
|
-
|
|
18016
|
-
|
|
18017
|
-
|
|
18018
|
-
|
|
18019
|
-
|
|
18020
|
-
|
|
18021
|
-
|
|
18022
|
-
|
|
18023
|
-
|
|
18024
|
-
|
|
18025
|
-
|
|
18026
|
-
|
|
18027
|
-
|
|
18028
|
-
|
|
18029
|
-
|
|
18030
|
-
|
|
18031
|
-
|
|
17735
|
+
// New card button
|
|
17736
|
+
createElement("button", {
|
|
17737
|
+
style: btnStyle,
|
|
17738
|
+
onClick: onNewCard,
|
|
17739
|
+
"data-testid": "btn-new-card",
|
|
17740
|
+
"aria-label": "New card"
|
|
17741
|
+
}, "+ New Card"),
|
|
17742
|
+
createElement("div", { style: separatorStyle }),
|
|
17743
|
+
// Zoom controls
|
|
17744
|
+
createElement("button", {
|
|
17745
|
+
style: btnStyle,
|
|
17746
|
+
onClick: onZoomOut,
|
|
17747
|
+
"data-testid": "btn-zoom-out",
|
|
17748
|
+
"aria-label": "Zoom out"
|
|
17749
|
+
}, "-"),
|
|
17750
|
+
createElement("span", {
|
|
17751
|
+
style: zoomText,
|
|
17752
|
+
onClick: onZoomReset,
|
|
17753
|
+
"data-testid": "zoom-level",
|
|
17754
|
+
role: "status",
|
|
17755
|
+
"aria-label": `Zoom ${Math.round(zoom * 100)}%`
|
|
17756
|
+
}, `${Math.round(zoom * 100)}%`),
|
|
17757
|
+
createElement("button", {
|
|
17758
|
+
style: btnStyle,
|
|
17759
|
+
onClick: onZoomIn,
|
|
17760
|
+
"data-testid": "btn-zoom-in",
|
|
17761
|
+
"aria-label": "Zoom in"
|
|
17762
|
+
}, "+"),
|
|
17763
|
+
createElement("div", { style: separatorStyle }),
|
|
17764
|
+
...swatches,
|
|
17765
|
+
createElement("div", { style: separatorStyle }),
|
|
17766
|
+
// Grid toggle
|
|
17767
|
+
createElement("button", {
|
|
17768
|
+
style: gridEnabled ? activeBtnStyle : btnStyle,
|
|
17769
|
+
onClick: onGridToggle,
|
|
17770
|
+
"data-testid": "btn-grid-toggle",
|
|
17771
|
+
"aria-label": gridEnabled ? "Disable grid snapping" : "Enable grid snapping",
|
|
17772
|
+
"aria-pressed": String(gridEnabled)
|
|
17773
|
+
}, "Grid"),
|
|
17774
|
+
createElement("div", { style: separatorStyle }),
|
|
17775
|
+
// Search
|
|
17776
|
+
createElement("input", {
|
|
17777
|
+
type: "text",
|
|
17778
|
+
placeholder: "Search cards...",
|
|
17779
|
+
value: searchText,
|
|
17780
|
+
onInput: handleSearchInput,
|
|
17781
|
+
style: inputStyle,
|
|
17782
|
+
"data-testid": "search-input",
|
|
17783
|
+
"aria-label": "Search cards"
|
|
17784
|
+
})
|
|
18032
17785
|
);
|
|
18033
17786
|
}
|
|
18034
17787
|
|
|
18035
|
-
// ../
|
|
17788
|
+
// ../components/data/board/src/BoardReducer.ts
|
|
18036
17789
|
var MAX_HISTORY = 50;
|
|
18037
17790
|
var DEFAULT_BOARD_STATE = {
|
|
18038
|
-
id:
|
|
17791
|
+
id: generateUUID(),
|
|
18039
17792
|
name: "Untitled",
|
|
18040
|
-
|
|
18041
|
-
connections: [],
|
|
17793
|
+
collection: [],
|
|
18042
17794
|
viewport: { panX: 0, panY: 0, zoom: 1 }
|
|
18043
17795
|
};
|
|
17796
|
+
function removeItemFromTree(collection, itemId) {
|
|
17797
|
+
let removed = null;
|
|
17798
|
+
function process(items) {
|
|
17799
|
+
const result = [];
|
|
17800
|
+
for (let i = 0; i < items.length; i++) {
|
|
17801
|
+
const item = items[i];
|
|
17802
|
+
const id = getItemId(item);
|
|
17803
|
+
if (id === itemId) {
|
|
17804
|
+
removed = item;
|
|
17805
|
+
continue;
|
|
17806
|
+
}
|
|
17807
|
+
if (isContainer(item)) {
|
|
17808
|
+
const newContents = process(item.contents);
|
|
17809
|
+
result.push({ ...item, contents: newContents });
|
|
17810
|
+
} else {
|
|
17811
|
+
result.push(item);
|
|
17812
|
+
}
|
|
17813
|
+
}
|
|
17814
|
+
return result;
|
|
17815
|
+
}
|
|
17816
|
+
const updated = process(collection);
|
|
17817
|
+
return [updated, removed];
|
|
17818
|
+
}
|
|
17819
|
+
function updateItemInTree(collection, itemId, updater) {
|
|
17820
|
+
const result = [];
|
|
17821
|
+
for (let i = 0; i < collection.length; i++) {
|
|
17822
|
+
const item = collection[i];
|
|
17823
|
+
const id = getItemId(item);
|
|
17824
|
+
if (id === itemId) {
|
|
17825
|
+
result.push(updater(item));
|
|
17826
|
+
} else if (isContainer(item)) {
|
|
17827
|
+
result.push({
|
|
17828
|
+
...item,
|
|
17829
|
+
contents: updateItemInTree(item.contents, itemId, updater)
|
|
17830
|
+
});
|
|
17831
|
+
} else {
|
|
17832
|
+
result.push(item);
|
|
17833
|
+
}
|
|
17834
|
+
}
|
|
17835
|
+
return result;
|
|
17836
|
+
}
|
|
17837
|
+
function addItemToContainer(collection, containerId, newItem) {
|
|
17838
|
+
const result = [];
|
|
17839
|
+
for (let i = 0; i < collection.length; i++) {
|
|
17840
|
+
const item = collection[i];
|
|
17841
|
+
if (isContainer(item) && item.container_id === containerId) {
|
|
17842
|
+
result.push({
|
|
17843
|
+
...item,
|
|
17844
|
+
contents: [...item.contents, newItem]
|
|
17845
|
+
});
|
|
17846
|
+
} else if (isContainer(item)) {
|
|
17847
|
+
result.push({
|
|
17848
|
+
...item,
|
|
17849
|
+
contents: addItemToContainer(item.contents, containerId, newItem)
|
|
17850
|
+
});
|
|
17851
|
+
} else {
|
|
17852
|
+
result.push(item);
|
|
17853
|
+
}
|
|
17854
|
+
}
|
|
17855
|
+
return result;
|
|
17856
|
+
}
|
|
17857
|
+
function removeItemFromContainer(collection, containerId, itemId) {
|
|
17858
|
+
let removed = null;
|
|
17859
|
+
function process(items) {
|
|
17860
|
+
const result = [];
|
|
17861
|
+
for (let i = 0; i < items.length; i++) {
|
|
17862
|
+
const item = items[i];
|
|
17863
|
+
if (isContainer(item) && item.container_id === containerId) {
|
|
17864
|
+
const newContents = [];
|
|
17865
|
+
for (let j = 0; j < item.contents.length; j++) {
|
|
17866
|
+
const child = item.contents[j];
|
|
17867
|
+
if (getItemId(child) === itemId) {
|
|
17868
|
+
removed = child;
|
|
17869
|
+
} else {
|
|
17870
|
+
newContents.push(child);
|
|
17871
|
+
}
|
|
17872
|
+
}
|
|
17873
|
+
result.push({ ...item, contents: newContents });
|
|
17874
|
+
} else if (isContainer(item)) {
|
|
17875
|
+
result.push({
|
|
17876
|
+
...item,
|
|
17877
|
+
contents: process(item.contents)
|
|
17878
|
+
});
|
|
17879
|
+
} else {
|
|
17880
|
+
result.push(item);
|
|
17881
|
+
}
|
|
17882
|
+
}
|
|
17883
|
+
return result;
|
|
17884
|
+
}
|
|
17885
|
+
const updated = process(collection);
|
|
17886
|
+
return [updated, removed];
|
|
17887
|
+
}
|
|
17888
|
+
function getDefaultContent(cardType) {
|
|
17889
|
+
switch (cardType) {
|
|
17890
|
+
case "text":
|
|
17891
|
+
return { text: "" };
|
|
17892
|
+
case "json":
|
|
17893
|
+
return {};
|
|
17894
|
+
case "task":
|
|
17895
|
+
return {};
|
|
17896
|
+
case "project":
|
|
17897
|
+
return { project_id: "", project_name: "" };
|
|
17898
|
+
}
|
|
17899
|
+
}
|
|
18044
17900
|
function boardReducer(state, action) {
|
|
18045
17901
|
switch (action.type) {
|
|
18046
|
-
case "
|
|
17902
|
+
case "ADD_ITEM": {
|
|
17903
|
+
if (action.containerId) {
|
|
17904
|
+
return {
|
|
17905
|
+
...state,
|
|
17906
|
+
collection: addItemToContainer(state.collection, action.containerId, action.item)
|
|
17907
|
+
};
|
|
17908
|
+
}
|
|
17909
|
+
return {
|
|
17910
|
+
...state,
|
|
17911
|
+
collection: [...state.collection, action.item]
|
|
17912
|
+
};
|
|
17913
|
+
}
|
|
17914
|
+
case "REMOVE_ITEM": {
|
|
17915
|
+
const [newCollection] = removeItemFromTree(state.collection, action.itemId);
|
|
18047
17916
|
return {
|
|
18048
17917
|
...state,
|
|
18049
|
-
|
|
17918
|
+
collection: newCollection
|
|
18050
17919
|
};
|
|
18051
|
-
|
|
17920
|
+
}
|
|
17921
|
+
case "MOVE_ITEM": {
|
|
18052
17922
|
return {
|
|
18053
17923
|
...state,
|
|
18054
|
-
|
|
18055
|
-
|
|
18056
|
-
|
|
18057
|
-
|
|
17924
|
+
collection: updateItemInTree(state.collection, action.itemId, (item) => ({
|
|
17925
|
+
...item,
|
|
17926
|
+
position: action.position,
|
|
17927
|
+
...isCard(item) ? { updatedAt: Date.now() } : {}
|
|
17928
|
+
}))
|
|
18058
17929
|
};
|
|
18059
|
-
|
|
17930
|
+
}
|
|
17931
|
+
case "RESIZE_ITEM": {
|
|
18060
17932
|
return {
|
|
18061
17933
|
...state,
|
|
18062
|
-
|
|
18063
|
-
|
|
18064
|
-
|
|
17934
|
+
collection: updateItemInTree(state.collection, action.itemId, (item) => ({
|
|
17935
|
+
...item,
|
|
17936
|
+
size: action.size,
|
|
17937
|
+
...isCard(item) ? { updatedAt: Date.now() } : {}
|
|
17938
|
+
}))
|
|
18065
17939
|
};
|
|
18066
|
-
|
|
17940
|
+
}
|
|
17941
|
+
case "UPDATE_CARD": {
|
|
18067
17942
|
return {
|
|
18068
17943
|
...state,
|
|
18069
|
-
|
|
18070
|
-
|
|
18071
|
-
|
|
17944
|
+
collection: updateItemInTree(state.collection, action.cardId, (item) => {
|
|
17945
|
+
if (!isCard(item)) return item;
|
|
17946
|
+
return { ...item, ...action.updates, updatedAt: Date.now() };
|
|
17947
|
+
})
|
|
18072
17948
|
};
|
|
18073
|
-
|
|
17949
|
+
}
|
|
17950
|
+
case "CHANGE_CARD_TYPE": {
|
|
18074
17951
|
return {
|
|
18075
17952
|
...state,
|
|
18076
|
-
|
|
18077
|
-
|
|
18078
|
-
|
|
17953
|
+
collection: updateItemInTree(state.collection, action.cardId, (item) => {
|
|
17954
|
+
if (!isCard(item)) return item;
|
|
17955
|
+
return {
|
|
17956
|
+
...item,
|
|
17957
|
+
card_type: action.newType,
|
|
17958
|
+
content: getDefaultContent(action.newType),
|
|
17959
|
+
updatedAt: Date.now()
|
|
17960
|
+
};
|
|
17961
|
+
})
|
|
18079
17962
|
};
|
|
18080
|
-
|
|
18081
|
-
|
|
18082
|
-
if (
|
|
18083
|
-
|
|
18084
|
-
|
|
18085
|
-
|
|
18086
|
-
|
|
18087
|
-
|
|
18088
|
-
|
|
18089
|
-
|
|
18090
|
-
}
|
|
18091
|
-
|
|
18092
|
-
|
|
17963
|
+
}
|
|
17964
|
+
case "ADD_CONTAINER": {
|
|
17965
|
+
if (action.parentContainerId) {
|
|
17966
|
+
return {
|
|
17967
|
+
...state,
|
|
17968
|
+
collection: addItemToContainer(
|
|
17969
|
+
state.collection,
|
|
17970
|
+
action.parentContainerId,
|
|
17971
|
+
action.container
|
|
17972
|
+
)
|
|
17973
|
+
};
|
|
17974
|
+
}
|
|
17975
|
+
return {
|
|
17976
|
+
...state,
|
|
17977
|
+
collection: [...state.collection, action.container]
|
|
17978
|
+
};
|
|
17979
|
+
}
|
|
17980
|
+
case "NEST_ITEM": {
|
|
17981
|
+
const [withoutItem, movedItem] = removeItemFromTree(
|
|
17982
|
+
state.collection,
|
|
17983
|
+
action.itemId
|
|
17984
|
+
);
|
|
17985
|
+
if (!movedItem) return state;
|
|
17986
|
+
return {
|
|
17987
|
+
...state,
|
|
17988
|
+
collection: addItemToContainer(withoutItem, action.containerId, movedItem)
|
|
18093
17989
|
};
|
|
17990
|
+
}
|
|
17991
|
+
case "UNNEST_ITEM": {
|
|
17992
|
+
const [withoutItem, movedItem] = removeItemFromContainer(
|
|
17993
|
+
state.collection,
|
|
17994
|
+
action.containerId,
|
|
17995
|
+
action.itemId
|
|
17996
|
+
);
|
|
17997
|
+
if (!movedItem) return state;
|
|
18094
17998
|
return {
|
|
18095
17999
|
...state,
|
|
18096
|
-
|
|
18000
|
+
collection: [...withoutItem, movedItem]
|
|
18097
18001
|
};
|
|
18098
18002
|
}
|
|
18099
|
-
case "
|
|
18003
|
+
case "ADD_LINK": {
|
|
18100
18004
|
return {
|
|
18101
18005
|
...state,
|
|
18102
|
-
|
|
18006
|
+
collection: updateItemInTree(state.collection, action.cardId, (item) => {
|
|
18007
|
+
if (!isCard(item)) return item;
|
|
18008
|
+
return {
|
|
18009
|
+
...item,
|
|
18010
|
+
card_link: [...item.card_link, action.link],
|
|
18011
|
+
updatedAt: Date.now()
|
|
18012
|
+
};
|
|
18013
|
+
})
|
|
18103
18014
|
};
|
|
18104
|
-
|
|
18015
|
+
}
|
|
18016
|
+
case "REMOVE_LINK": {
|
|
18105
18017
|
return {
|
|
18106
18018
|
...state,
|
|
18107
|
-
|
|
18108
|
-
(
|
|
18109
|
-
|
|
18019
|
+
collection: updateItemInTree(state.collection, action.cardId, (item) => {
|
|
18020
|
+
if (!isCard(item)) return item;
|
|
18021
|
+
return {
|
|
18022
|
+
...item,
|
|
18023
|
+
card_link: item.card_link.filter((l) => l.link_id !== action.linkId),
|
|
18024
|
+
updatedAt: Date.now()
|
|
18025
|
+
};
|
|
18026
|
+
})
|
|
18110
18027
|
};
|
|
18028
|
+
}
|
|
18111
18029
|
case "PAN":
|
|
18112
18030
|
return {
|
|
18113
18031
|
...state,
|
|
@@ -18122,6 +18040,8 @@ function boardReducer(state, action) {
|
|
|
18122
18040
|
}
|
|
18123
18041
|
case "SET_BOARD":
|
|
18124
18042
|
return action.state;
|
|
18043
|
+
case "RENAME_BOARD":
|
|
18044
|
+
return { ...state, name: action.name };
|
|
18125
18045
|
default:
|
|
18126
18046
|
return state;
|
|
18127
18047
|
}
|
|
@@ -18174,10 +18094,10 @@ function historyReducer(state, action) {
|
|
|
18174
18094
|
return state;
|
|
18175
18095
|
}
|
|
18176
18096
|
}
|
|
18177
|
-
function
|
|
18097
|
+
function useBoardReducer(initialState) {
|
|
18178
18098
|
const initialHistory = {
|
|
18179
18099
|
past: [],
|
|
18180
|
-
present: DEFAULT_BOARD_STATE,
|
|
18100
|
+
present: initialState || DEFAULT_BOARD_STATE,
|
|
18181
18101
|
future: []
|
|
18182
18102
|
};
|
|
18183
18103
|
const [history, historyDispatch] = useReducer(historyReducer, initialHistory);
|
|
@@ -18190,6 +18110,19 @@ function useBoardState(storage2, boardId) {
|
|
|
18190
18110
|
const redo = useCallback(() => {
|
|
18191
18111
|
historyDispatch({ type: "REDO" });
|
|
18192
18112
|
}, [historyDispatch]);
|
|
18113
|
+
return {
|
|
18114
|
+
state: history.present,
|
|
18115
|
+
dispatch,
|
|
18116
|
+
undo,
|
|
18117
|
+
redo,
|
|
18118
|
+
canUndo: history.past.length > 0,
|
|
18119
|
+
canRedo: history.future.length > 0
|
|
18120
|
+
};
|
|
18121
|
+
}
|
|
18122
|
+
|
|
18123
|
+
// ../demos/project-manager/src/BoardState.ts
|
|
18124
|
+
function useBoardState(storage2, boardId) {
|
|
18125
|
+
const { state, dispatch, undo, redo, canUndo, canRedo } = useBoardReducer();
|
|
18193
18126
|
const loadedRef = useRef(false);
|
|
18194
18127
|
useEffect(() => {
|
|
18195
18128
|
if (storage2 && boardId && !loadedRef.current) {
|
|
@@ -18201,8 +18134,8 @@ function useBoardState(storage2, boardId) {
|
|
|
18201
18134
|
}
|
|
18202
18135
|
}, [storage2, boardId, dispatch]);
|
|
18203
18136
|
const saveTimerRef = useRef(null);
|
|
18204
|
-
const stateRef = useRef(
|
|
18205
|
-
stateRef.current =
|
|
18137
|
+
const stateRef = useRef(state);
|
|
18138
|
+
stateRef.current = state;
|
|
18206
18139
|
useEffect(() => {
|
|
18207
18140
|
if (!storage2 || !boardId) return;
|
|
18208
18141
|
if (saveTimerRef.current !== null) {
|
|
@@ -18218,32 +18151,27 @@ function useBoardState(storage2, boardId) {
|
|
|
18218
18151
|
clearTimeout(saveTimerRef.current);
|
|
18219
18152
|
}
|
|
18220
18153
|
};
|
|
18221
|
-
}, [storage2, boardId,
|
|
18154
|
+
}, [storage2, boardId, state]);
|
|
18222
18155
|
return {
|
|
18223
|
-
state
|
|
18156
|
+
state,
|
|
18224
18157
|
dispatch,
|
|
18225
18158
|
undo,
|
|
18226
18159
|
redo,
|
|
18227
|
-
canUndo
|
|
18228
|
-
canRedo
|
|
18160
|
+
canUndo,
|
|
18161
|
+
canRedo
|
|
18229
18162
|
};
|
|
18230
18163
|
}
|
|
18231
18164
|
|
|
18232
18165
|
// ../demos/project-manager/src/LocalStorage.ts
|
|
18233
|
-
var DEFAULT_STATE = {
|
|
18234
|
-
cards: [],
|
|
18235
|
-
connections: [],
|
|
18236
|
-
viewport: { panX: 0, panY: 0, zoom: 1 }
|
|
18237
|
-
};
|
|
18238
18166
|
var LocalBoardStorage = class {
|
|
18239
18167
|
async load(boardId) {
|
|
18240
18168
|
try {
|
|
18241
18169
|
const raw = localStorage.getItem("board:" + boardId);
|
|
18242
|
-
if (!raw) return
|
|
18170
|
+
if (!raw) return { ...DEFAULT_BOARD_STATE };
|
|
18243
18171
|
const parsed = JSON.parse(raw);
|
|
18244
18172
|
return parsed;
|
|
18245
18173
|
} catch {
|
|
18246
|
-
return
|
|
18174
|
+
return { ...DEFAULT_BOARD_STATE };
|
|
18247
18175
|
}
|
|
18248
18176
|
}
|
|
18249
18177
|
async save(boardId, state) {
|
|
@@ -18255,34 +18183,50 @@ var LocalBoardStorage = class {
|
|
|
18255
18183
|
};
|
|
18256
18184
|
|
|
18257
18185
|
// ../demos/project-manager/src/InterApp.ts
|
|
18186
|
+
function collectCards(items) {
|
|
18187
|
+
const cards = [];
|
|
18188
|
+
const stack = [...items];
|
|
18189
|
+
while (stack.length > 0) {
|
|
18190
|
+
const item = stack.pop();
|
|
18191
|
+
if (isCard(item)) {
|
|
18192
|
+
cards.push(item);
|
|
18193
|
+
} else {
|
|
18194
|
+
for (let i = item.contents.length - 1; i >= 0; i--) {
|
|
18195
|
+
stack.push(item.contents[i]);
|
|
18196
|
+
}
|
|
18197
|
+
}
|
|
18198
|
+
}
|
|
18199
|
+
return cards;
|
|
18200
|
+
}
|
|
18258
18201
|
function InterAppWrapper(props) {
|
|
18259
|
-
const {
|
|
18202
|
+
const { collection, onCardDropped, children } = props;
|
|
18260
18203
|
const messageBus = useMessageBus();
|
|
18261
18204
|
const prevCardsRef = useRef([]);
|
|
18262
18205
|
useEffect(() => {
|
|
18206
|
+
const cards = collectCards(collection);
|
|
18263
18207
|
const prevCards = prevCardsRef.current;
|
|
18264
|
-
const prevIds = new Set(prevCards.map((c) => c.
|
|
18265
|
-
const currIds = new Set(cards.map((c) => c.
|
|
18208
|
+
const prevIds = new Set(prevCards.map((c) => c.card_id));
|
|
18209
|
+
const currIds = new Set(cards.map((c) => c.card_id));
|
|
18266
18210
|
for (const card of cards) {
|
|
18267
|
-
if (!prevIds.has(card.
|
|
18211
|
+
if (!prevIds.has(card.card_id)) {
|
|
18268
18212
|
messageBus.publish("project-board", { event: "card-created", card });
|
|
18269
18213
|
}
|
|
18270
18214
|
}
|
|
18271
18215
|
for (const card of prevCards) {
|
|
18272
|
-
if (!currIds.has(card.
|
|
18273
|
-
messageBus.publish("project-board", { event: "card-deleted", cardId: card.
|
|
18216
|
+
if (!currIds.has(card.card_id)) {
|
|
18217
|
+
messageBus.publish("project-board", { event: "card-deleted", cardId: card.card_id });
|
|
18274
18218
|
}
|
|
18275
18219
|
}
|
|
18276
18220
|
for (const card of cards) {
|
|
18277
|
-
if (prevIds.has(card.
|
|
18278
|
-
const prev = prevCards.find((c) => c.
|
|
18221
|
+
if (prevIds.has(card.card_id)) {
|
|
18222
|
+
const prev = prevCards.find((c) => c.card_id === card.card_id);
|
|
18279
18223
|
if (prev && prev.updatedAt !== card.updatedAt) {
|
|
18280
18224
|
messageBus.publish("project-board", { event: "card-updated", card });
|
|
18281
18225
|
}
|
|
18282
18226
|
}
|
|
18283
18227
|
}
|
|
18284
18228
|
prevCardsRef.current = cards;
|
|
18285
|
-
}, [
|
|
18229
|
+
}, [collection, messageBus]);
|
|
18286
18230
|
const handleDrop = useCallback(
|
|
18287
18231
|
(payload) => {
|
|
18288
18232
|
if (payload.type === "text/plain" && typeof payload.data === "string") {
|
|
@@ -18313,29 +18257,93 @@ function InterAppWrapper(props) {
|
|
|
18313
18257
|
}
|
|
18314
18258
|
|
|
18315
18259
|
// ../demos/project-manager/src/index.ts
|
|
18316
|
-
var cardIdCounter = 0;
|
|
18317
|
-
function generateCardId() {
|
|
18318
|
-
cardIdCounter++;
|
|
18319
|
-
return `card-${Date.now()}-${cardIdCounter}`;
|
|
18320
|
-
}
|
|
18321
18260
|
var storage = new LocalBoardStorage();
|
|
18322
|
-
|
|
18323
|
-
|
|
18324
|
-
|
|
18325
|
-
|
|
18326
|
-
|
|
18327
|
-
|
|
18261
|
+
function collectAllCards2(items) {
|
|
18262
|
+
const cards = [];
|
|
18263
|
+
const stack = [...items];
|
|
18264
|
+
while (stack.length > 0) {
|
|
18265
|
+
const item = stack.pop();
|
|
18266
|
+
if (isCard(item)) {
|
|
18267
|
+
cards.push(item);
|
|
18268
|
+
} else if (isContainer(item)) {
|
|
18269
|
+
for (let i = item.contents.length - 1; i >= 0; i--) {
|
|
18270
|
+
stack.push(item.contents[i]);
|
|
18271
|
+
}
|
|
18272
|
+
}
|
|
18273
|
+
}
|
|
18274
|
+
return cards;
|
|
18275
|
+
}
|
|
18276
|
+
var now = Date.now();
|
|
18328
18277
|
var SAMPLE_BOARD = {
|
|
18329
18278
|
id: "sample-board-001",
|
|
18330
18279
|
name: "Sample Project",
|
|
18331
|
-
|
|
18332
|
-
|
|
18333
|
-
|
|
18280
|
+
collection: [
|
|
18281
|
+
{
|
|
18282
|
+
type: "card",
|
|
18283
|
+
card_id: "sample-1",
|
|
18284
|
+
card_type: "text",
|
|
18285
|
+
card_title: "Auth API",
|
|
18286
|
+
card_link: [
|
|
18287
|
+
{ link_id: "link-1", link_name: "blocks", target_card_id: "sample-2", color: "#94a3b8", attributes: {} }
|
|
18288
|
+
],
|
|
18289
|
+
content: { text: "Design the auth flow" },
|
|
18290
|
+
position: { x: 50, y: 50 },
|
|
18291
|
+
size: { width: 180, height: 120 },
|
|
18292
|
+
color: "#3b82f6",
|
|
18293
|
+
priority: "high",
|
|
18294
|
+
assignee: "Alice",
|
|
18295
|
+
createdAt: now,
|
|
18296
|
+
updatedAt: now
|
|
18297
|
+
},
|
|
18298
|
+
{
|
|
18299
|
+
type: "card",
|
|
18300
|
+
card_id: "sample-2",
|
|
18301
|
+
card_type: "text",
|
|
18302
|
+
card_title: "Dashboard",
|
|
18303
|
+
card_link: [],
|
|
18304
|
+
content: { text: "Build the main dashboard" },
|
|
18305
|
+
position: { x: 300, y: 80 },
|
|
18306
|
+
size: { width: 180, height: 120 },
|
|
18307
|
+
color: "#22c55e",
|
|
18308
|
+
priority: "medium",
|
|
18309
|
+
assignee: "Bob",
|
|
18310
|
+
createdAt: now,
|
|
18311
|
+
updatedAt: now
|
|
18312
|
+
},
|
|
18313
|
+
{
|
|
18314
|
+
type: "card",
|
|
18315
|
+
card_id: "sample-3",
|
|
18316
|
+
card_type: "text",
|
|
18317
|
+
card_title: "Deploy",
|
|
18318
|
+
card_link: [],
|
|
18319
|
+
content: { text: "Set up CI pipeline" },
|
|
18320
|
+
position: { x: 150, y: 250 },
|
|
18321
|
+
size: { width: 180, height: 120 },
|
|
18322
|
+
color: "#f59e0b",
|
|
18323
|
+
priority: "low",
|
|
18324
|
+
createdAt: now,
|
|
18325
|
+
updatedAt: now
|
|
18326
|
+
},
|
|
18327
|
+
{
|
|
18328
|
+
type: "card",
|
|
18329
|
+
card_id: "sample-4",
|
|
18330
|
+
card_type: "text",
|
|
18331
|
+
card_title: "Docs",
|
|
18332
|
+
card_link: [],
|
|
18333
|
+
content: { text: "Write API reference" },
|
|
18334
|
+
position: { x: 400, y: 280 },
|
|
18335
|
+
size: { width: 180, height: 120 },
|
|
18336
|
+
color: "#a855f7",
|
|
18337
|
+
priority: "medium",
|
|
18338
|
+
assignee: "Carol",
|
|
18339
|
+
createdAt: now,
|
|
18340
|
+
updatedAt: now
|
|
18341
|
+
}
|
|
18334
18342
|
],
|
|
18335
18343
|
viewport: { panX: 0, panY: 0, zoom: 1 }
|
|
18336
18344
|
};
|
|
18337
18345
|
function isBoardEmpty(state) {
|
|
18338
|
-
return state.
|
|
18346
|
+
return state.collection.length === 0;
|
|
18339
18347
|
}
|
|
18340
18348
|
function ProjectManagerApp(props) {
|
|
18341
18349
|
const boardId = props.boardId || "default";
|
|
@@ -18345,7 +18353,6 @@ function ProjectManagerApp(props) {
|
|
|
18345
18353
|
const [searchQuery, setSearchQuery] = useState("");
|
|
18346
18354
|
const [selectedCardId, setSelectedCardId] = useState(null);
|
|
18347
18355
|
const [colorFilter, setColorFilter] = useState(null);
|
|
18348
|
-
const [showConnections, setShowConnections] = useState(true);
|
|
18349
18356
|
const [projectName, setProjectName] = useState(state.name || "Untitled");
|
|
18350
18357
|
const [showRenameDialog, setShowRenameDialog] = useState(false);
|
|
18351
18358
|
const [renameDraft, setRenameDraft] = useState("");
|
|
@@ -18354,7 +18361,7 @@ function ProjectManagerApp(props) {
|
|
|
18354
18361
|
if (!sampleLoadedRef.current && isBoardEmpty(state)) {
|
|
18355
18362
|
sampleLoadedRef.current = true;
|
|
18356
18363
|
dispatch({ type: "SET_BOARD", state: SAMPLE_BOARD });
|
|
18357
|
-
} else if (state.
|
|
18364
|
+
} else if (state.collection.length > 0) {
|
|
18358
18365
|
sampleLoadedRef.current = true;
|
|
18359
18366
|
}
|
|
18360
18367
|
}, [state, dispatch]);
|
|
@@ -18364,9 +18371,12 @@ function ProjectManagerApp(props) {
|
|
|
18364
18371
|
const offsetX = (Math.random() - 0.5) * 300;
|
|
18365
18372
|
const offsetY = (Math.random() - 0.5) * 200;
|
|
18366
18373
|
const newCard = {
|
|
18367
|
-
|
|
18368
|
-
|
|
18369
|
-
|
|
18374
|
+
type: "card",
|
|
18375
|
+
card_id: generateUUID(),
|
|
18376
|
+
card_type: "text",
|
|
18377
|
+
card_title: "New Card",
|
|
18378
|
+
card_link: [],
|
|
18379
|
+
content: { text: "" },
|
|
18370
18380
|
color: selectedColor,
|
|
18371
18381
|
position: { x: Math.round(cx + offsetX), y: Math.round(cy + offsetY) },
|
|
18372
18382
|
size: { width: 180, height: 120 },
|
|
@@ -18374,7 +18384,7 @@ function ProjectManagerApp(props) {
|
|
|
18374
18384
|
createdAt: Date.now(),
|
|
18375
18385
|
updatedAt: Date.now()
|
|
18376
18386
|
};
|
|
18377
|
-
dispatch({ type: "
|
|
18387
|
+
dispatch({ type: "ADD_ITEM", item: newCard });
|
|
18378
18388
|
}, [state.viewport, selectedColor, dispatch]);
|
|
18379
18389
|
const handleZoomIn = useCallback(() => {
|
|
18380
18390
|
dispatch({ type: "ZOOM", zoom: state.viewport.zoom + 0.1 });
|
|
@@ -18426,7 +18436,7 @@ function ProjectManagerApp(props) {
|
|
|
18426
18436
|
reader.onload = () => {
|
|
18427
18437
|
try {
|
|
18428
18438
|
const parsed = JSON.parse(reader.result);
|
|
18429
|
-
if (parsed && parsed.
|
|
18439
|
+
if (parsed && parsed.collection && parsed.viewport) {
|
|
18430
18440
|
dispatch({ type: "SET_BOARD", state: parsed });
|
|
18431
18441
|
}
|
|
18432
18442
|
} catch (_e) {
|
|
@@ -18441,54 +18451,27 @@ function ProjectManagerApp(props) {
|
|
|
18441
18451
|
const handlePrint = useCallback(() => {
|
|
18442
18452
|
window.print();
|
|
18443
18453
|
}, []);
|
|
18454
|
+
const allCards = collectAllCards2(state.collection);
|
|
18444
18455
|
const handleSelectAll = useCallback(() => {
|
|
18445
|
-
|
|
18446
|
-
|
|
18456
|
+
const cards = collectAllCards2(state.collection);
|
|
18457
|
+
if (cards.length > 0) {
|
|
18458
|
+
setSelectedCardId(cards[0].card_id);
|
|
18447
18459
|
}
|
|
18448
|
-
}, [state.
|
|
18449
|
-
const handleToggleConnections = useCallback(() => {
|
|
18450
|
-
setShowConnections((prev) => !prev);
|
|
18451
|
-
}, []);
|
|
18460
|
+
}, [state.collection]);
|
|
18452
18461
|
const handleDeleteSelected = useCallback(() => {
|
|
18453
18462
|
if (selectedCardId) {
|
|
18454
|
-
dispatch({ type: "
|
|
18463
|
+
dispatch({ type: "REMOVE_ITEM", itemId: selectedCardId });
|
|
18455
18464
|
setSelectedCardId(null);
|
|
18456
18465
|
}
|
|
18457
18466
|
}, [selectedCardId, dispatch]);
|
|
18458
18467
|
const handleFitAll = useCallback(() => {
|
|
18459
|
-
if (state.
|
|
18468
|
+
if (state.collection.length === 0) return;
|
|
18460
18469
|
const containerWidth = 800;
|
|
18461
18470
|
const containerHeight = 600;
|
|
18462
|
-
const fit = computeFitAll(state.
|
|
18471
|
+
const fit = computeFitAll(state.collection, containerWidth, containerHeight);
|
|
18463
18472
|
dispatch({ type: "PAN", panX: fit.panX, panY: fit.panY });
|
|
18464
18473
|
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]);
|
|
18474
|
+
}, [state.collection, dispatch]);
|
|
18492
18475
|
useEffect(() => {
|
|
18493
18476
|
const _menuBar = {
|
|
18494
18477
|
menus: [
|
|
@@ -18511,12 +18494,11 @@ function ProjectManagerApp(props) {
|
|
|
18511
18494
|
{ label: "Zoom Out", onClick: handleZoomOut },
|
|
18512
18495
|
{ label: "Fit All", onClick: handleFitAll },
|
|
18513
18496
|
{ divider: true },
|
|
18514
|
-
{ label: "Toggle Grid", onClick: handleGridToggle }
|
|
18515
|
-
{ label: showConnections ? "Hide Connections" : "Show Connections", onClick: handleToggleConnections }
|
|
18497
|
+
{ label: "Toggle Grid", onClick: handleGridToggle }
|
|
18516
18498
|
] }
|
|
18517
18499
|
]
|
|
18518
18500
|
};
|
|
18519
|
-
}, [handleNewBoard, handleExportJSON, handleImportJSON, handlePrint, undo, redo, canUndo, canRedo, handleSelectAll, handleDeleteSelected, handleZoomIn, handleZoomOut, handleFitAll, handleGridToggle
|
|
18501
|
+
}, [handleNewBoard, handleExportJSON, handleImportJSON, handlePrint, undo, redo, canUndo, canRedo, handleSelectAll, handleDeleteSelected, handleZoomIn, handleZoomOut, handleFitAll, handleGridToggle]);
|
|
18520
18502
|
useEffect(() => {
|
|
18521
18503
|
const handleKeyDown = (e) => {
|
|
18522
18504
|
const ke = e;
|
|
@@ -18531,6 +18513,35 @@ function ProjectManagerApp(props) {
|
|
|
18531
18513
|
document.addEventListener("keydown", handleKeyDown);
|
|
18532
18514
|
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
18533
18515
|
}, [undo, redo]);
|
|
18516
|
+
const handleRenameProject = useCallback(() => {
|
|
18517
|
+
setRenameDraft(projectName);
|
|
18518
|
+
setShowRenameDialog(true);
|
|
18519
|
+
}, [projectName]);
|
|
18520
|
+
const handleRenameConfirm = useCallback(() => {
|
|
18521
|
+
const name = renameDraft.trim();
|
|
18522
|
+
if (name) {
|
|
18523
|
+
setProjectName(name);
|
|
18524
|
+
dispatch({ type: "RENAME_BOARD", name });
|
|
18525
|
+
}
|
|
18526
|
+
setShowRenameDialog(false);
|
|
18527
|
+
}, [renameDraft, dispatch]);
|
|
18528
|
+
const handleRenameCancel = useCallback(() => {
|
|
18529
|
+
setShowRenameDialog(false);
|
|
18530
|
+
}, []);
|
|
18531
|
+
const handleRenameDraftChange = useCallback((e) => {
|
|
18532
|
+
setRenameDraft(e.target.value);
|
|
18533
|
+
}, []);
|
|
18534
|
+
const handleRenameKeyDown = useCallback((e) => {
|
|
18535
|
+
const ke = e;
|
|
18536
|
+
if (ke.key === "Enter") {
|
|
18537
|
+
ke.preventDefault();
|
|
18538
|
+
handleRenameConfirm();
|
|
18539
|
+
}
|
|
18540
|
+
if (ke.key === "Escape") {
|
|
18541
|
+
ke.preventDefault();
|
|
18542
|
+
handleRenameCancel();
|
|
18543
|
+
}
|
|
18544
|
+
}, [handleRenameConfirm, handleRenameCancel]);
|
|
18534
18545
|
const containerStyle3 = {
|
|
18535
18546
|
display: "flex",
|
|
18536
18547
|
flexDirection: "column",
|
|
@@ -18545,9 +18556,12 @@ function ProjectManagerApp(props) {
|
|
|
18545
18556
|
const offsetX = (Math.random() - 0.5) * 300;
|
|
18546
18557
|
const offsetY = (Math.random() - 0.5) * 200;
|
|
18547
18558
|
const newCard = {
|
|
18548
|
-
|
|
18549
|
-
|
|
18550
|
-
|
|
18559
|
+
type: "card",
|
|
18560
|
+
card_id: generateUUID(),
|
|
18561
|
+
card_type: "text",
|
|
18562
|
+
card_title: title,
|
|
18563
|
+
card_link: [],
|
|
18564
|
+
content: { text: description },
|
|
18551
18565
|
color: selectedColor,
|
|
18552
18566
|
position: { x: Math.round(cx + offsetX), y: Math.round(cy + offsetY) },
|
|
18553
18567
|
size: { width: 180, height: 120 },
|
|
@@ -18555,7 +18569,7 @@ function ProjectManagerApp(props) {
|
|
|
18555
18569
|
createdAt: Date.now(),
|
|
18556
18570
|
updatedAt: Date.now()
|
|
18557
18571
|
};
|
|
18558
|
-
dispatch({ type: "
|
|
18572
|
+
dispatch({ type: "ADD_ITEM", item: newCard });
|
|
18559
18573
|
}, [state.viewport, selectedColor, dispatch]);
|
|
18560
18574
|
const menuBarStyle = {
|
|
18561
18575
|
display: "flex",
|
|
@@ -18709,7 +18723,7 @@ function ProjectManagerApp(props) {
|
|
|
18709
18723
|
createElement(
|
|
18710
18724
|
InterAppWrapper,
|
|
18711
18725
|
{
|
|
18712
|
-
|
|
18726
|
+
collection: state.collection,
|
|
18713
18727
|
onCardDropped: handleCardDropped
|
|
18714
18728
|
},
|
|
18715
18729
|
createElement(Board, {
|
|
@@ -18717,10 +18731,9 @@ function ProjectManagerApp(props) {
|
|
|
18717
18731
|
dispatch,
|
|
18718
18732
|
searchQuery,
|
|
18719
18733
|
gridEnabled,
|
|
18720
|
-
selectedCardId,
|
|
18721
|
-
|
|
18722
|
-
colorFilter
|
|
18723
|
-
showConnections
|
|
18734
|
+
selectedId: selectedCardId,
|
|
18735
|
+
onSelectItem: handleSelectCard,
|
|
18736
|
+
colorFilter
|
|
18724
18737
|
})
|
|
18725
18738
|
),
|
|
18726
18739
|
renameDialogEl
|
|
@@ -21669,9 +21682,9 @@ function CalendarHeatMap(props) {
|
|
|
21669
21682
|
if (latest === null || parsed > latest) latest = parsed;
|
|
21670
21683
|
}
|
|
21671
21684
|
if (earliest === null || latest === null) {
|
|
21672
|
-
const
|
|
21673
|
-
earliest = new Date(
|
|
21674
|
-
latest = new Date(
|
|
21685
|
+
const now2 = /* @__PURE__ */ new Date();
|
|
21686
|
+
earliest = new Date(now2.getFullYear(), 0, 1);
|
|
21687
|
+
latest = new Date(now2.getFullYear(), 11, 31);
|
|
21675
21688
|
}
|
|
21676
21689
|
const start = new Date(earliest);
|
|
21677
21690
|
start.setDate(start.getDate() - start.getDay());
|