@emberai-engg/task-board 0.3.5 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -297,6 +297,7 @@ function useTaskBoard(isDragging) {
297
297
  tasks,
298
298
  setTasks,
299
299
  columnTotals,
300
+ setColumnTotals,
300
301
  columnUnreads,
301
302
  setColumnUnreads,
302
303
  boardLoading,
@@ -312,7 +313,7 @@ function useTaskBoard(isDragging) {
312
313
 
313
314
  // src/hooks/useTaskActions.ts
314
315
  import { useCallback as useCallback2, useRef as useRef2 } from "react";
315
- function useTaskActions(tasks, setTasks, fetchTasks, isDragging) {
316
+ function useTaskActions(tasks, setTasks, fetchTasks, isDragging, setColumnTotals) {
316
317
  const { service, config } = useTaskBoardContext();
317
318
  const internalDragging = useRef2(false);
318
319
  const draggingRef = isDragging ?? internalDragging;
@@ -366,6 +367,13 @@ function useTaskActions(tasks, setTasks, fetchTasks, isDragging) {
366
367
  }
367
368
  return newTasks;
368
369
  });
370
+ if (sourceStatus !== destStatus && setColumnTotals) {
371
+ setColumnTotals((prev) => ({
372
+ ...prev,
373
+ [sourceStatus]: Math.max(0, (prev[sourceStatus] || 0) - 1),
374
+ [destStatus]: (prev[destStatus] || 0) + 1
375
+ }));
376
+ }
369
377
  try {
370
378
  await service.updateTask(taskId, { status: destStatus, position: newPosition });
371
379
  } catch {
@@ -373,7 +381,7 @@ function useTaskActions(tasks, setTasks, fetchTasks, isDragging) {
373
381
  } finally {
374
382
  draggingRef.current = false;
375
383
  }
376
- }, [setTasks, service, fetchTasks]);
384
+ }, [setTasks, setColumnTotals, service, fetchTasks]);
377
385
  return { createTask, updateTask, deleteTask, markTaskRead, moveTask };
378
386
  }
379
387
 
@@ -619,18 +627,20 @@ var TaskCard = memo(function TaskCard2({ task, index, onClick, onShare, copied }
619
627
  import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
620
628
  function LoadMoreSentinel({ loading, onLoadMore, remaining }) {
621
629
  const sentinelRef = useRef3(null);
630
+ const onLoadMoreRef = useRef3(onLoadMore);
631
+ onLoadMoreRef.current = onLoadMore;
622
632
  useEffect2(() => {
623
633
  const el = sentinelRef.current;
624
634
  if (!el) return;
625
635
  const observer = new IntersectionObserver(
626
636
  ([entry]) => {
627
- if (entry.isIntersecting && !loading) onLoadMore();
637
+ if (entry.isIntersecting && !loading) onLoadMoreRef.current();
628
638
  },
629
639
  { threshold: 0.1 }
630
640
  );
631
641
  observer.observe(el);
632
642
  return () => observer.disconnect();
633
- }, [loading, onLoadMore]);
643
+ }, [loading]);
634
644
  const skeletonCount = loading ? Math.min(remaining, 10) : 0;
635
645
  return /* @__PURE__ */ jsx8("div", { ref: sentinelRef, className: "space-y-2 pt-2", children: Array.from({ length: skeletonCount }).map((_, i) => /* @__PURE__ */ jsx8(SkeletonCard, {}, i)) });
636
646
  }
@@ -2025,7 +2035,7 @@ function TaskBoard({
2025
2035
  const { columns, features, service } = useTaskBoardContext();
2026
2036
  const isDraggingRef = useRef8(false);
2027
2037
  const board = useTaskBoard(isDraggingRef);
2028
- const actions = useTaskActions(board.tasks, board.setTasks, board.fetchTasks, isDraggingRef);
2038
+ const actions = useTaskActions(board.tasks, board.setTasks, board.fetchTasks, isDraggingRef, board.setColumnTotals);
2029
2039
  const { copiedTaskId, copyShareLink } = useShareLink();
2030
2040
  const [selectedTask, setSelectedTask] = useState9(null);
2031
2041
  const [createForStatus, setCreateForStatus] = useState9("");