Skip to content

Commit 0bc142f

Browse files
refactor: migrate VDragAndDropCell to TypeScript
1 parent 546d968 commit 0bc142f

File tree

1 file changed

+50
-50
lines changed

1 file changed

+50
-50
lines changed

src/components/pivottable-ui/VDragAndDropCell.vue

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -40,65 +40,65 @@
4040
</Draggable>
4141
</template>
4242

43-
<script setup>
43+
<script setup lang="ts">
4444
import { ref, onMounted, computed, watch, nextTick, onBeforeUnmount } from 'vue'
4545
import { VueDraggableNext as Draggable } from 'vue-draggable-next'
4646
import VDraggableAttribute from './VDraggableAttribute.vue'
4747
48-
const emit = defineEmits([
49-
'update:draggedAttribute',
50-
'update:zIndexOfFilterBox',
51-
'update:unselectedFilterValues',
52-
'update:openStatusOfFilterBox'
53-
])
48+
const emit = defineEmits<{
49+
(
50+
event: 'update:draggedAttribute',
51+
payload: { key: string; value: string[] }
52+
): void
53+
(event: 'update:zIndexOfFilterBox', attributeName: string): void
54+
(
55+
event: 'update:unselectedFilterValues',
56+
payload: { key: string; value: Record<string, boolean> }
57+
): void
58+
(
59+
event: 'update:openStatusOfFilterBox',
60+
payload: { key: string; value: boolean }
61+
): void
62+
}>()
5463
55-
const props = defineProps({
56-
cellType: {
57-
type: String,
58-
required: true
59-
},
60-
classes: {
61-
type: String,
62-
default: ''
63-
},
64-
attributeNames: {
65-
type: Array,
66-
default: () => []
67-
},
68-
allFilters: {
69-
type: Object,
70-
default: () => ({})
71-
},
72-
valueFilter: {
73-
type: Object,
74-
default: () => ({})
75-
},
76-
restrictedFromDragDrop: {
77-
type: Array,
78-
default: () => []
79-
},
80-
hideFilterBoxOfUnusedAttributes: {
81-
type: Boolean,
82-
default: false
83-
},
84-
zIndices: {
85-
type: Object,
86-
default: () => ({})
87-
},
88-
maxZIndex: {
89-
type: Number,
90-
default: 1000
91-
},
92-
openStatus: {
93-
type: Object,
94-
default: () => ({})
95-
}
64+
interface DragAndDropCellProps {
65+
cellType: string
66+
classes?: string
67+
attributeNames?: string[]
68+
allFilters?: Record<string, Record<string, number>>
69+
valueFilter?: Record<string, Record<string, boolean>>
70+
restrictedFromDragDrop?: string[]
71+
hideFilterBoxOfUnusedAttributes?: boolean
72+
zIndices?: Record<string, number>
73+
maxZIndex?: number
74+
openStatus?: Record<string, boolean>
75+
}
76+
77+
const props = withDefaults(defineProps<DragAndDropCellProps>(), {
78+
classes: '',
79+
attributeNames: () => [],
80+
allFilters: () => ({}),
81+
valueFilter: () => ({}),
82+
restrictedFromDragDrop: () => [],
83+
hideFilterBoxOfUnusedAttributes: false,
84+
zIndices: () => ({}),
85+
maxZIndex: 1000,
86+
openStatus: () => ({})
9687
})
9788
98-
const modelItems = ref([])
89+
const modelItems = ref<string[]>([])
9990
const showDraggable = ref(false)
10091
101-
const onDragMove = (event) => {
92+
interface DragMoveEvent {
93+
from: HTMLElement
94+
to: HTMLElement
95+
draggedContext: {
96+
element: string
97+
index: number
98+
}
99+
}
100+
101+
const onDragMove = (event: DragMoveEvent) => {
102102
const draggedItem = event.draggedContext.element
103103
const isCrossCellMove = event.from !== event.to
104104

0 commit comments

Comments
 (0)