@moontra/moonui-pro 2.14.0 → 2.14.1

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
@@ -12503,6 +12503,9 @@ function Kanban({
12503
12503
  const [selectedColor, setSelectedColor] = useState("#6B7280");
12504
12504
  const { scrollRef, startAutoScroll, stopAutoScroll } = useAutoScroll();
12505
12505
  const { toast: toast3 } = useToast();
12506
+ useEffect(() => {
12507
+ setColumns(initialColumns);
12508
+ }, [initialColumns]);
12506
12509
  const filteredColumns = useMemo(() => {
12507
12510
  if (!searchQuery && !activeFilter)
12508
12511
  return columns;
@@ -12604,7 +12607,7 @@ function Kanban({
12604
12607
  stopAutoScroll();
12605
12608
  };
12606
12609
  const handleDrop = (e, targetColumnId, targetIndex) => {
12607
- if (disabled || !draggedCard || !onCardMove)
12610
+ if (disabled || !draggedCard)
12608
12611
  return;
12609
12612
  e.preventDefault();
12610
12613
  const targetColumn = columns.find((col) => col.id === targetColumnId);
@@ -12623,7 +12626,27 @@ function Kanban({
12623
12626
  }
12624
12627
  }
12625
12628
  if (sourceColumnId && sourceCard) {
12626
- onCardMove(draggedCard, sourceColumnId, targetColumnId, targetIndex);
12629
+ const newColumns = columns.map((col) => {
12630
+ if (col.id === sourceColumnId) {
12631
+ return {
12632
+ ...col,
12633
+ cards: col.cards.filter((c2) => c2.id !== draggedCard)
12634
+ };
12635
+ }
12636
+ if (col.id === targetColumnId) {
12637
+ const newCards = [...col.cards];
12638
+ newCards.splice(targetIndex, 0, sourceCard);
12639
+ return {
12640
+ ...col,
12641
+ cards: newCards
12642
+ };
12643
+ }
12644
+ return col;
12645
+ });
12646
+ setColumns(newColumns);
12647
+ if (onCardMove) {
12648
+ onCardMove(draggedCard, sourceColumnId, targetColumnId, targetIndex);
12649
+ }
12627
12650
  }
12628
12651
  handleDragEnd();
12629
12652
  };
@@ -12705,10 +12728,9 @@ function Kanban({
12705
12728
  }
12706
12729
  };
12707
12730
  const handleCardClick = (card) => {
12731
+ setSelectedCard(card);
12708
12732
  if (onCardClick) {
12709
12733
  onCardClick(card);
12710
- } else {
12711
- setSelectedCard(card);
12712
12734
  }
12713
12735
  };
12714
12736
  const handleCardUpdate = (updatedCard) => {
@@ -12719,11 +12741,7 @@ function Kanban({
12719
12741
  })));
12720
12742
  };
12721
12743
  const handleAddCard = (columnId, newCard) => {
12722
- if (onAddCard) {
12723
- onAddCard(columnId, newCard);
12724
- } else {
12725
- setAddCardColumnId(columnId);
12726
- }
12744
+ setAddCardColumnId(columnId);
12727
12745
  };
12728
12746
  const handleAddNewCard = (card) => {
12729
12747
  if (!addCardColumnId)
@@ -12743,7 +12761,9 @@ function Kanban({
12743
12761
  }
12744
12762
  return col;
12745
12763
  }));
12746
- onAddCard?.(addCardColumnId, newCard);
12764
+ if (onAddCard) {
12765
+ onAddCard(addCardColumnId, newCard);
12766
+ }
12747
12767
  toast3({
12748
12768
  title: "Card added",
12749
12769
  description: `"${newCard.title}" has been added`
@@ -13173,7 +13193,7 @@ function Kanban({
13173
13193
  cardTemplates.map((template, index2) => /* @__PURE__ */ jsxs(
13174
13194
  MoonUIDropdownMenuItemPro,
13175
13195
  {
13176
- onClick: () => handleAddCard(column.id, template),
13196
+ onClick: () => handleAddCard(column.id),
13177
13197
  children: [
13178
13198
  /* @__PURE__ */ jsx(Star, { className: "mr-2 h-4 w-4" }),
13179
13199
  template.title || `Template ${index2 + 1}`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moontra/moonui-pro",
3
- "version": "2.14.0",
3
+ "version": "2.14.1",
4
4
  "description": "Premium React components for MoonUI - Advanced UI library with 50+ pro components including performance, interactive, and gesture components",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",
@@ -603,6 +603,11 @@ export function Kanban({
603
603
  const { scrollRef, startAutoScroll, stopAutoScroll } = useAutoScroll()
604
604
  const { toast } = useToast()
605
605
 
606
+ // Update state when props change
607
+ useEffect(() => {
608
+ setColumns(initialColumns)
609
+ }, [initialColumns])
610
+
606
611
  // Filter cards based on search and filters
607
612
  const filteredColumns = useMemo(() => {
608
613
  if (!searchQuery && !activeFilter) return columns
@@ -728,7 +733,7 @@ export function Kanban({
728
733
  }
729
734
 
730
735
  const handleDrop = (e: React.DragEvent, targetColumnId: string, targetIndex: number) => {
731
- if (disabled || !draggedCard || !onCardMove) return
736
+ if (disabled || !draggedCard) return
732
737
  e.preventDefault()
733
738
 
734
739
  const targetColumn = columns.find(col => col.id === targetColumnId)
@@ -752,7 +757,30 @@ export function Kanban({
752
757
  }
753
758
 
754
759
  if (sourceColumnId && sourceCard) {
755
- onCardMove(draggedCard, sourceColumnId, targetColumnId, targetIndex)
760
+ // Update local state immediately for better UX
761
+ const newColumns = columns.map(col => {
762
+ if (col.id === sourceColumnId) {
763
+ return {
764
+ ...col,
765
+ cards: col.cards.filter(c => c.id !== draggedCard)
766
+ }
767
+ }
768
+ if (col.id === targetColumnId) {
769
+ const newCards = [...col.cards]
770
+ newCards.splice(targetIndex, 0, sourceCard!)
771
+ return {
772
+ ...col,
773
+ cards: newCards
774
+ }
775
+ }
776
+ return col
777
+ })
778
+ setColumns(newColumns)
779
+
780
+ // Call the callback if provided
781
+ if (onCardMove) {
782
+ onCardMove(draggedCard, sourceColumnId, targetColumnId, targetIndex)
783
+ }
756
784
  }
757
785
 
758
786
  handleDragEnd()
@@ -838,10 +866,9 @@ export function Kanban({
838
866
 
839
867
  // Card handlers
840
868
  const handleCardClick = (card: KanbanCard) => {
869
+ setSelectedCard(card)
841
870
  if (onCardClick) {
842
871
  onCardClick(card)
843
- } else {
844
- setSelectedCard(card)
845
872
  }
846
873
  }
847
874
 
@@ -854,11 +881,7 @@ export function Kanban({
854
881
  }
855
882
 
856
883
  const handleAddCard = (columnId: string, newCard?: Partial<KanbanCard>) => {
857
- if (onAddCard) {
858
- onAddCard(columnId, newCard)
859
- } else {
860
- setAddCardColumnId(columnId)
861
- }
884
+ setAddCardColumnId(columnId)
862
885
  }
863
886
 
864
887
  const handleAddNewCard = (card: Partial<KanbanCard>) => {
@@ -871,6 +894,7 @@ export function Kanban({
871
894
  ...card
872
895
  }
873
896
 
897
+ // Update local state
874
898
  setColumns(columns.map(col => {
875
899
  if (col.id === addCardColumnId) {
876
900
  return {
@@ -881,7 +905,11 @@ export function Kanban({
881
905
  return col
882
906
  }))
883
907
 
884
- onAddCard?.(addCardColumnId, newCard)
908
+ // Call the callback if provided
909
+ if (onAddCard) {
910
+ onAddCard(addCardColumnId, newCard)
911
+ }
912
+
885
913
  toast({
886
914
  title: "Card added",
887
915
  description: `"${newCard.title}" has been added`