Skip to content

Commit 640c719

Browse files
committed
feat: migrate core components and utils
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 5c04494 commit 640c719

13 files changed

Lines changed: 325 additions & 150 deletions

src/components/DraggableElement.vue

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,15 @@ SPDX-License-Identifier: AGPL-3.0-or-later
5454
</div>
5555
</template>
5656

57-
<script>
58-
export default {
57+
<script lang="ts">
58+
import { defineComponent, type PropType, type CSSProperties } from 'vue'
59+
import type { PDFElementObject } from '../types'
60+
61+
export default defineComponent({
5962
name: 'DraggableElement',
6063
props: {
6164
object: {
62-
type: Object,
65+
type: Object as PropType<PDFElementObject>,
6366
required: true,
6467
},
6568
pagesScale: {
@@ -75,35 +78,35 @@ export default {
7578
required: true,
7679
},
7780
onUpdate: {
78-
type: Function,
81+
type: Function as PropType<(...args: any[]) => void>,
7982
default: () => {},
8083
},
8184
onDelete: {
82-
type: Function,
85+
type: Function as PropType<(...args: any[]) => void>,
8386
default: () => {},
8487
},
8588
onDuplicate: {
86-
type: Function,
89+
type: Function as PropType<(...args: any[]) => void>,
8790
default: () => {},
8891
},
8992
onDragStart: {
90-
type: Function,
93+
type: Function as PropType<(...args: any[]) => void>,
9194
default: () => {},
9295
},
9396
onDragMove: {
94-
type: Function,
97+
type: Function as PropType<(...args: any[]) => void>,
9598
default: () => {},
9699
},
97100
onDragEnd: {
98-
type: Function,
101+
type: Function as PropType<(...args: any[]) => void>,
99102
default: () => {},
100103
},
101104
isBeingDraggedGlobally: {
102105
type: Boolean,
103106
default: false,
104107
},
105108
draggingClientPos: {
106-
type: Object,
109+
type: Object as PropType<{ x: number; y: number }>,
107110
default: () => ({ x: 0, y: 0 }),
108111
},
109112
currentDocIndex: {
@@ -135,7 +138,7 @@ export default {
135138
default: false,
136139
},
137140
ignoreClickOutsideSelectors: {
138-
type: Array,
141+
type: Array as PropType<string[]>,
139142
default: () => [],
140143
},
141144
},
@@ -188,7 +191,7 @@ export default {
188191
width: `${currentWidth * scale}px`,
189192
height: `${currentHeight * scale}px`,
190193
pointerEvents: this.readOnly ? 'none' : 'auto',
191-
}
194+
} as CSSProperties
192195
},
193196
toolbarStyle() {
194197
const scale = this.pagesScale || 1
@@ -209,7 +212,7 @@ export default {
209212
left: `${(x + width / 2) * scale}px`,
210213
top: `${top * scale}px`,
211214
transform: 'translateX(-50%)',
212-
}
215+
} as CSSProperties
213216
},
214217
dragElementStyle() {
215218
if (!this.isBeingDraggedGlobally || !this.draggingClientPos) {
@@ -218,7 +221,7 @@ export default {
218221
return {
219222
opacity: 0,
220223
pointerEvents: 'none',
221-
}
224+
} as CSSProperties
222225
},
223226
},
224227
mounted() {
@@ -476,7 +479,7 @@ export default {
476479
this.currentPageRect = null
477480
},
478481
},
479-
}
482+
})
480483
</script>
481484

482485
<style scoped>

0 commit comments

Comments
 (0)