@moontra/moonui-pro 2.14.0 → 2.14.2

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
@@ -11243,49 +11243,37 @@ function CardDetailModal({
11243
11243
  });
11244
11244
  };
11245
11245
  return /* @__PURE__ */ jsx(MoonUIDialogPro, { open: isOpen, onOpenChange: onClose, children: /* @__PURE__ */ jsxs(MoonUIDialogContentPro, { className: "max-w-4xl max-h-[90vh] overflow-hidden p-0", children: [
11246
- /* @__PURE__ */ jsx("div", { className: "p-6 pb-0", children: /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between", children: [
11247
- /* @__PURE__ */ jsxs("div", { className: "flex-1", children: [
11248
- isEditingTitle ? /* @__PURE__ */ jsx(
11249
- MoonUIInputPro,
11250
- {
11251
- value: card.title,
11252
- onChange: (e) => updateCard({ title: e.target.value }),
11253
- onBlur: () => setIsEditingTitle(false),
11254
- onKeyDown: (e) => {
11255
- if (e.key === "Enter")
11256
- setIsEditingTitle(false);
11257
- if (e.key === "Escape") {
11258
- setCard(initialCard);
11259
- setIsEditingTitle(false);
11260
- }
11261
- },
11262
- className: "text-xl font-semibold",
11263
- autoFocus: true
11264
- }
11265
- ) : /* @__PURE__ */ jsx(
11266
- "h2",
11267
- {
11268
- className: "text-xl font-semibold cursor-pointer hover:bg-muted rounded px-2 -mx-2 py-1",
11269
- onClick: () => setIsEditingTitle(true),
11270
- children: card.title
11271
- }
11272
- ),
11273
- currentColumn && /* @__PURE__ */ jsxs("p", { className: "text-sm text-muted-foreground mt-1", children: [
11274
- "in ",
11275
- currentColumn
11276
- ] })
11277
- ] }),
11278
- /* @__PURE__ */ jsx(
11279
- MoonUIButtonPro,
11246
+ /* @__PURE__ */ jsx("div", { className: "p-6 pb-0", children: /* @__PURE__ */ jsx("div", { className: "flex items-start justify-between", children: /* @__PURE__ */ jsxs("div", { className: "flex-1", children: [
11247
+ isEditingTitle ? /* @__PURE__ */ jsx(
11248
+ MoonUIInputPro,
11280
11249
  {
11281
- variant: "ghost",
11282
- size: "icon",
11283
- onClick: onClose,
11284
- className: "h-8 w-8",
11285
- children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
11250
+ value: card.title,
11251
+ onChange: (e) => updateCard({ title: e.target.value }),
11252
+ onBlur: () => setIsEditingTitle(false),
11253
+ onKeyDown: (e) => {
11254
+ if (e.key === "Enter")
11255
+ setIsEditingTitle(false);
11256
+ if (e.key === "Escape") {
11257
+ setCard(initialCard);
11258
+ setIsEditingTitle(false);
11259
+ }
11260
+ },
11261
+ className: "text-xl font-semibold",
11262
+ autoFocus: true
11286
11263
  }
11287
- )
11288
- ] }) }),
11264
+ ) : /* @__PURE__ */ jsx(
11265
+ "h2",
11266
+ {
11267
+ className: "text-xl font-semibold cursor-pointer hover:bg-muted rounded px-2 -mx-2 py-1",
11268
+ onClick: () => setIsEditingTitle(true),
11269
+ children: card.title
11270
+ }
11271
+ ),
11272
+ currentColumn && /* @__PURE__ */ jsxs("p", { className: "text-sm text-muted-foreground mt-1", children: [
11273
+ "in ",
11274
+ currentColumn
11275
+ ] })
11276
+ ] }) }) }),
11289
11277
  /* @__PURE__ */ jsxs(MoonUITabsPro, { value: selectedTab, onValueChange: setSelectedTab, className: "flex-1", children: [
11290
11278
  /* @__PURE__ */ jsx("div", { className: "px-6 pt-4", children: /* @__PURE__ */ jsxs(MoonUITabsListPro, { children: [
11291
11279
  /* @__PURE__ */ jsx(MoonUITabsTriggerPro, { value: "overview", children: "Overview" }),
@@ -12503,6 +12491,9 @@ function Kanban({
12503
12491
  const [selectedColor, setSelectedColor] = useState("#6B7280");
12504
12492
  const { scrollRef, startAutoScroll, stopAutoScroll } = useAutoScroll();
12505
12493
  const { toast: toast3 } = useToast();
12494
+ useEffect(() => {
12495
+ setColumns(initialColumns);
12496
+ }, [initialColumns]);
12506
12497
  const filteredColumns = useMemo(() => {
12507
12498
  if (!searchQuery && !activeFilter)
12508
12499
  return columns;
@@ -12604,7 +12595,7 @@ function Kanban({
12604
12595
  stopAutoScroll();
12605
12596
  };
12606
12597
  const handleDrop = (e, targetColumnId, targetIndex) => {
12607
- if (disabled || !draggedCard || !onCardMove)
12598
+ if (disabled || !draggedCard)
12608
12599
  return;
12609
12600
  e.preventDefault();
12610
12601
  const targetColumn = columns.find((col) => col.id === targetColumnId);
@@ -12623,7 +12614,27 @@ function Kanban({
12623
12614
  }
12624
12615
  }
12625
12616
  if (sourceColumnId && sourceCard) {
12626
- onCardMove(draggedCard, sourceColumnId, targetColumnId, targetIndex);
12617
+ const newColumns = columns.map((col) => {
12618
+ if (col.id === sourceColumnId) {
12619
+ return {
12620
+ ...col,
12621
+ cards: col.cards.filter((c2) => c2.id !== draggedCard)
12622
+ };
12623
+ }
12624
+ if (col.id === targetColumnId) {
12625
+ const newCards = [...col.cards];
12626
+ newCards.splice(targetIndex, 0, sourceCard);
12627
+ return {
12628
+ ...col,
12629
+ cards: newCards
12630
+ };
12631
+ }
12632
+ return col;
12633
+ });
12634
+ setColumns(newColumns);
12635
+ if (onCardMove) {
12636
+ onCardMove(draggedCard, sourceColumnId, targetColumnId, targetIndex);
12637
+ }
12627
12638
  }
12628
12639
  handleDragEnd();
12629
12640
  };
@@ -12705,10 +12716,9 @@ function Kanban({
12705
12716
  }
12706
12717
  };
12707
12718
  const handleCardClick = (card) => {
12719
+ setSelectedCard(card);
12708
12720
  if (onCardClick) {
12709
12721
  onCardClick(card);
12710
- } else {
12711
- setSelectedCard(card);
12712
12722
  }
12713
12723
  };
12714
12724
  const handleCardUpdate = (updatedCard) => {
@@ -12719,11 +12729,7 @@ function Kanban({
12719
12729
  })));
12720
12730
  };
12721
12731
  const handleAddCard = (columnId, newCard) => {
12722
- if (onAddCard) {
12723
- onAddCard(columnId, newCard);
12724
- } else {
12725
- setAddCardColumnId(columnId);
12726
- }
12732
+ setAddCardColumnId(columnId);
12727
12733
  };
12728
12734
  const handleAddNewCard = (card) => {
12729
12735
  if (!addCardColumnId)
@@ -12743,7 +12749,9 @@ function Kanban({
12743
12749
  }
12744
12750
  return col;
12745
12751
  }));
12746
- onAddCard?.(addCardColumnId, newCard);
12752
+ if (onAddCard) {
12753
+ onAddCard(addCardColumnId, newCard);
12754
+ }
12747
12755
  toast3({
12748
12756
  title: "Card added",
12749
12757
  description: `"${newCard.title}" has been added`
@@ -13173,7 +13181,7 @@ function Kanban({
13173
13181
  cardTemplates.map((template, index2) => /* @__PURE__ */ jsxs(
13174
13182
  MoonUIDropdownMenuItemPro,
13175
13183
  {
13176
- onClick: () => handleAddCard(column.id, template),
13184
+ onClick: () => handleAddCard(column.id),
13177
13185
  children: [
13178
13186
  /* @__PURE__ */ jsx(Star, { className: "mr-2 h-4 w-4" }),
13179
13187
  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.2",
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",
@@ -241,14 +241,6 @@ export function CardDetailModal({
241
241
  </p>
242
242
  )}
243
243
  </div>
244
- <Button
245
- variant="ghost"
246
- size="icon"
247
- onClick={onClose}
248
- className="h-8 w-8"
249
- >
250
- <X className="h-4 w-4" />
251
- </Button>
252
244
  </div>
253
245
  </div>
254
246
 
@@ -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`