@innertia-solutions/innertia-nuxt 0.1.61 → 0.1.62
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.
|
@@ -459,21 +459,37 @@ const onDragStart = (row, state) => {
|
|
|
459
459
|
}
|
|
460
460
|
const onDragOver = (e, state) => {
|
|
461
461
|
e.preventDefault()
|
|
462
|
-
dragOverState.value = state
|
|
462
|
+
if (dragOverState.value !== state) dragOverState.value = state
|
|
463
463
|
if (!props.reorderEndpoint) return
|
|
464
464
|
if (dragOverIndex.value === null) dragOverIndex.value = columnRows.value[state]?.length ?? 0
|
|
465
465
|
}
|
|
466
|
-
|
|
466
|
+
// Parpadeo: el drag nativo dispara `dragleave` al entrar a un hijo (tarjeta/placeholder).
|
|
467
|
+
// Si limpiamos el estado ahí, el fondo de la columna + el placeholder parpadean. Solo
|
|
468
|
+
// limpiamos cuando el cursor sale de verdad de la columna (relatedTarget fuera).
|
|
469
|
+
const onDragLeave = (e) => {
|
|
470
|
+
if (e.currentTarget.contains(e.relatedTarget)) return
|
|
471
|
+
dragOverState.value = null
|
|
472
|
+
dragOverIndex.value = null
|
|
473
|
+
}
|
|
474
|
+
// Al terminar el arrastre (drop o cancelado) limpiar siempre el estado visual.
|
|
475
|
+
const onDragEnd = () => {
|
|
476
|
+
dragOverState.value = null
|
|
477
|
+
dragOverIndex.value = null
|
|
478
|
+
draggedId.value = null
|
|
479
|
+
draggedFrom.value = null
|
|
480
|
+
}
|
|
467
481
|
|
|
468
482
|
// Llamado desde cada tarjeta: calcula si el cursor está en la mitad superior o inferior.
|
|
483
|
+
// Solo escribe el índice si cambió (evita reactividad redundante = menos re-render/parpadeo).
|
|
469
484
|
const onCardDragOver = (e, state, index) => {
|
|
470
485
|
if (!props.reorderEndpoint) return
|
|
471
486
|
e.preventDefault()
|
|
472
487
|
e.stopPropagation()
|
|
473
|
-
dragOverState.value = state
|
|
488
|
+
if (dragOverState.value !== state) dragOverState.value = state
|
|
474
489
|
const rect = e.currentTarget.getBoundingClientRect()
|
|
475
490
|
const after = (e.clientY - rect.top) > rect.height / 2
|
|
476
|
-
|
|
491
|
+
const next = after ? index + 1 : index
|
|
492
|
+
if (dragOverIndex.value !== next) dragOverIndex.value = next
|
|
477
493
|
}
|
|
478
494
|
|
|
479
495
|
const onDrop = async (targetState) => {
|
|
@@ -827,15 +843,17 @@ defineExpose({ reload: fetchAll, rows })
|
|
|
827
843
|
<template v-for="(row, ci) in columnRows[state.key]" :key="row.id">
|
|
828
844
|
<div
|
|
829
845
|
v-if="reorderEndpoint && dragOverState === state.key && dragOverIndex === ci"
|
|
830
|
-
class="rounded-card border-2 border-dashed border-primary/50 bg-primary/5 h-10"
|
|
846
|
+
class="rounded-card border-2 border-dashed border-primary/50 bg-primary/5 h-10 pointer-events-none"
|
|
831
847
|
/>
|
|
832
848
|
<div
|
|
833
849
|
draggable="true"
|
|
834
850
|
@dragstart="onDragStart(row, state.key)"
|
|
835
851
|
@dragover="onCardDragOver($event, state.key, ci)"
|
|
852
|
+
@dragend="onDragEnd"
|
|
836
853
|
@click="handleCardClick(row)"
|
|
837
|
-
class="bg-card border border-card-line rounded-card p-3 cursor-grab active:cursor-grabbing
|
|
854
|
+
class="bg-card border border-card-line rounded-card p-3 cursor-grab active:cursor-grabbing transition-colors select-none"
|
|
838
855
|
:class="[
|
|
856
|
+
draggedId ? '' : 'hover:border-primary/40 hover:shadow-sm',
|
|
839
857
|
draggedId === row.id ? 'opacity-40' : '',
|
|
840
858
|
previewRow?.id === row.id ? 'ring-2 ring-primary/30' : '',
|
|
841
859
|
]"
|