Skip to content

Commit 546d968

Browse files
refactor: migrate VDraggableAttribute to TypeScript
1 parent 31276ca commit 546d968

File tree

2 files changed

+38
-41
lines changed

2 files changed

+38
-41
lines changed

pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/pivottable-ui/VDraggableAttribute.vue

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
<slot
88
name="pvtAttr"
99
:attr-name="attributeName"
10-
>{{ attributeName }}</slot>
10+
>{{ attributeName }}</slot
11+
>
1112
<span
1213
v-if="!hideDropDown"
1314
@mousedown.stop
@@ -23,7 +24,9 @@
2324
:filter-box-values="attributeValues"
2425
:z-index="zIndex"
2526
@mousedown.stop
26-
@update:z-index-of-filter-box="$emit('update:zIndexOfFilterBox', $event)"
27+
@update:z-index-of-filter-box="
28+
$emit('update:zIndexOfFilterBox', $event)
29+
"
2730
@update:unselected-filter-values="
2831
$emit('update:unselectedFilterValues', $event)
2932
"
@@ -32,45 +35,39 @@
3235
</li>
3336
</template>
3437

35-
<script setup>
38+
<script setup lang="ts">
3639
import VFilterBox from './VFilterBox.vue'
3740
import { computed } from 'vue'
3841
39-
const emit = defineEmits([
40-
'update:zIndexOfFilterBox',
41-
'update:unselectedFilterValues',
42-
'update:openStatusOfFilterBox'
43-
])
42+
const emit = defineEmits<{
43+
(event: 'update:zIndexOfFilterBox', attributeName: string): void
44+
(
45+
event: 'update:unselectedFilterValues',
46+
payload: { key: string; value: Record<string, boolean> }
47+
): void
48+
(
49+
event: 'update:openStatusOfFilterBox',
50+
payload: { key: string; value: boolean }
51+
): void
52+
}>()
4453
45-
const props = defineProps({
46-
attributeName: {
47-
type: String,
48-
required: true
49-
},
50-
attributeValues: {
51-
type: Object,
52-
default: () => ({})
53-
},
54-
restricted: {
55-
type: Boolean,
56-
default: false
57-
},
58-
open: {
59-
type: Boolean,
60-
default: false
61-
},
62-
unselectedFilterValues: {
63-
type: Object,
64-
default: () => ({})
65-
},
66-
zIndex: {
67-
default: 1000,
68-
type: Number
69-
},
70-
hideDropDownForUnused: {
71-
type: Boolean,
72-
default: false
73-
}
54+
interface DraggableAttributeProps {
55+
attributeName: string
56+
attributeValues?: Record<string, number>
57+
restricted?: boolean
58+
open?: boolean
59+
unselectedFilterValues?: Record<string, boolean>
60+
zIndex?: number
61+
hideDropDownForUnused?: boolean
62+
}
63+
64+
const props = withDefaults(defineProps<DraggableAttributeProps>(), {
65+
attributeValues: () => ({}),
66+
restricted: false,
67+
open: false,
68+
unselectedFilterValues: () => ({}),
69+
zIndex: 1000,
70+
hideDropDownForUnused: false
7471
})
7572
7673
const toggleFilterBox = () => {

0 commit comments

Comments
 (0)