|
40 | 40 | </Draggable> |
41 | 41 | </template> |
42 | 42 |
|
43 | | -<script setup> |
| 43 | +<script setup lang="ts"> |
44 | 44 | import { ref, onMounted, computed, watch, nextTick, onBeforeUnmount } from 'vue' |
45 | 45 | import { VueDraggableNext as Draggable } from 'vue-draggable-next' |
46 | 46 | import VDraggableAttribute from './VDraggableAttribute.vue' |
47 | 47 |
|
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 | +}>() |
54 | 63 |
|
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: () => ({}) |
96 | 87 | }) |
97 | 88 |
|
98 | | -const modelItems = ref([]) |
| 89 | +const modelItems = ref<string[]>([]) |
99 | 90 | const showDraggable = ref(false) |
100 | 91 |
|
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) => { |
102 | 102 | const draggedItem = event.draggedContext.element |
103 | 103 | const isCrossCellMove = event.from !== event.to |
104 | 104 |
|
|
0 commit comments